lean4-htt/src/Lean/Meta
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
..
Match refactor: CasesOnApp.refineThrough can return a lambda, not an open term (#2974) 2023-11-29 15:58:03 +00:00
Tactic refactor: rewrite: produce simpler proof terms (#3121) 2024-01-19 07:20:58 +00:00
AbstractMVars.lean
AbstractNestedProofs.lean chore: do not abstract nested proofs in a proof 2023-11-07 06:23:45 -08:00
ACLt.lean refactor: add configuration options to control WHNF 2023-10-25 03:12:35 -07:00
AppBuilder.lean feat: encode let_fun using a letFun function (#2973) 2023-12-18 09:01:42 +00:00
Basic.lean doc: fix typos (#3178) 2024-01-14 14:02:51 +00:00
CasesOn.lean refactor: CasesOnApp.refineThrough can return a lambda, not an open term (#2974) 2023-11-29 15:58:03 +00:00
Check.lean
Closure.lean fix: use mkAuxTheoremFor when creating helper proof_n theorems 2023-06-21 20:28:17 -07:00
Coe.lean fix: allow function coercion to assign universe mvars 2023-03-08 15:54:07 -08:00
CollectFVars.lean
CollectMVars.lean doc: fix typos (#2996) 2023-11-30 10:16:33 +00:00
CongrTheorems.lean fix: fixes #1808 2022-11-28 07:48:54 -08:00
Constructions.lean
DecLevel.lean
DiscrTree.lean refactor: termination_by changes in stdlib 2024-01-10 17:27:35 +01:00
DiscrTreeTypes.lean feat: add builtin simproc support 2024-01-09 12:57:15 +01:00
Eqns.lean doc: fix typos (#3178) 2024-01-14 14:02:51 +00:00
Eval.lean
ExprDefEq.lean feat: encode let_fun using a letFun function (#2973) 2023-12-18 09:01:42 +00:00
ExprLens.lean
ExprTraverse.lean
ForEachExpr.lean
FunInfo.lean
GeneralizeTelescope.lean
GeneralizeVars.lean
GetUnfoldableConst.lean doc: improve doc-string for Meta.getConst? 2023-08-24 07:42:28 -07:00
GlobalInstances.lean
IndPredBelow.lean fix: missing whnf in mkBelowBinder and mkMotiveBinder (#2991) 2023-12-01 14:46:09 +00:00
Inductive.lean
InferType.lean doc: fix typos (#3114) 2023-12-23 18:55:48 +00:00
Injective.lean feat: trace nodes for SizeOf and injectivity theorem generation 2023-06-27 16:17:46 -07:00
Instances.lean chore: remove unused argument 2023-12-28 10:41:04 -08:00
KAbstract.lean feat: do not instantiate metavariables in kabstract/rw for disallowed occurrences (#2539) 2024-01-03 00:01:40 +00:00
KExprMap.lean chore: fix typos in comments 2023-10-08 10:46:05 +02:00
LevelDefEq.lean refactor: replace ignoreLevelMVarDepth by levelAssignDepth 2022-12-19 20:14:17 +01:00
Match.lean
MatchUtil.lean
Offset.lean chore: fix typos in comments 2023-10-08 10:46:05 +02:00
PPGoal.lean chore: fix typos in comments 2023-10-08 10:46:05 +02:00
RecursorInfo.lean
Reduce.lean
ReduceEval.lean
SizeOf.lean feat: trace nodes for SizeOf and injectivity theorem generation 2023-06-27 16:17:46 -07:00
Structure.lean
SynthInstance.lean fix: fixes #2775 2023-11-03 05:56:59 -07:00
Tactic.lean
Transform.lean fix: PackMutual: Eta-Expand as needed (#2902) 2023-11-22 14:25:56 +00:00
TransparencyMode.lean
UnificationHint.lean chore: remove unused argument 2023-12-28 10:41:04 -08:00
WHNF.lean feat: add bitwise operations to reduceNat? and kernel (#3134) 2024-01-11 18:12:45 +00:00