lean4-htt/src
Joachim Breitner 52d0f715c3
refactor: rewrite: produce simpler proof terms (#3121)
Consider
```
import Std.Tactic.ShowTerm

opaque a : Nat
opaque b : Nat
axiom a_eq_b : a = b
opaque P : Nat → Prop

set_option pp.explicit true

-- Using rw
example (h : P b) : P a := by show_term rw [a_eq_b]; assumption
```

Before, a typical proof term for `rewrite` looked like this:
```
-- Using the proof term that rw produces
example (h : P b) : P a :=
  @Eq.mpr (P a) (P b)
  (@id (@Eq Prop (P a) (P b))
    (@Eq.ndrec Nat a (fun _a => @Eq Prop (P a) (P _a))
      (@Eq.refl Prop (P a)) b a_eq_b))
  h
```
which is rather round-about, applying `ndrec` to `refl`. It would be
more direct to write
```
example (h : P b) : P a :=
  @Eq.mpr (P a) (P b)
  (@id (@Eq Prop (P a) (P b))
    (@congrArg Nat Prop a b (fun _a => (P _a)) a_eq_b))
  h
```
which this change does.

This makes proof terms smaller, causing mild general speed up throughout
the code; if the brenchmarks don’t lie the highlights are

* olean size -2.034 %
* lint wall-clock -3.401 %
* buildtactic execution s -10.462 %

H'T to @digama0 for advice and help.

NB: One might even expect the even simpler
```
-- Using the proof term that I would have expected
example (h : P b) : P a :=
  @Eq.ndrec Nat b (fun _a => P _a) h a a_eq_b.symm
```
but that would require non-local changes to the source code, so one step
at a time.
2024-01-19 07:20:58 +00:00
..
bin feat: Web Assembly Build (#2599) 2023-10-04 09:04:20 +02:00
cmake
include/lean feat: Runtime.markMultiThreaded/Persistent 2023-11-14 17:33:04 +01:00
Init feat: new implementation for simp (config := { ground := true }) (#3187) 2024-01-18 17:39:06 +00:00
initialize chore: fix more typos in comments 2023-10-08 14:37:34 -07:00
kernel feat: add bitwise operations to reduceNat? and kernel (#3134) 2024-01-11 18:12:45 +00:00
lake feat: lake: GNU/BSD OS detection in test scripts (#3180) 2024-01-14 02:49:38 +00:00
Lean refactor: rewrite: produce simpler proof terms (#3121) 2024-01-19 07:20:58 +00:00
library feat: embed and check githash in .olean (#2766) 2023-11-27 10:24:43 +00:00
runtime fix: run_task/deactivate_task race condition on m_imp->m_closure (#2959) 2023-12-12 02:01:40 +00:00
shell feat: Web Assembly Build (#2599) 2023-10-04 09:04:20 +02:00
util fix: remove target triple parameter from FFI that no longer exists in the Lean API 2023-11-02 23:21:47 +01:00
CMakeLists.txt chore: begin development cycle for v4.6.0 (#3109) 2023-12-21 22:39:04 +00:00
config.h.in
githash.h.in
Init.lean feat: simproc declaration vs simproc attribute 2024-01-09 12:57:15 +01:00
lean-toolchain doc: VS Code dev setup (#2961) 2023-11-30 08:35:03 +00:00
Lean.lean feat: add linter.deprecated option to silence deprecation warnings 2022-10-23 21:11:57 +02:00
lean.mk.in feat: LLVM bc separation for CMake 2023-11-02 23:21:47 +01:00
Leanc.lean fix: default for MACOSX_DEPLOYMENT_TARGET (#2598) 2023-10-02 13:03:19 +00:00
stdlib.make.in chore: set warningAsError in CI only (#3030) 2023-12-06 08:18:39 +00:00
stdlib_flags.h chore: update domain 2023-09-20 15:13:27 -07:00
version.h.in feat: embed and check githash in .olean (#2766) 2023-11-27 10:24:43 +00:00