chore: update stage0
This commit is contained in:
parent
8f580a5a70
commit
d2f9e43ca0
6 changed files with 1092 additions and 2166 deletions
33
stage0/src/Lean/Meta/Tactic/Simp/Rewrite.lean
generated
33
stage0/src/Lean/Meta/Tactic/Simp/Rewrite.lean
generated
|
|
@ -42,39 +42,15 @@ def rewrite (e : Expr) (s : DiscrTree SimpLemma) (erased : SimpLemmaNameSet) (di
|
|||
else
|
||||
let lemmas := lemmas.insertionSort fun e₁ e₂ => e₁.priority < e₂.priority
|
||||
for lemma in lemmas do
|
||||
unless inErasedSet lemma do
|
||||
unless inErasedSet lemma do
|
||||
if let some result ← tryLemma? lemma then
|
||||
return result
|
||||
return { expr := e }
|
||||
where
|
||||
inErasedSet (lemma : SimpLemma) : Bool :=
|
||||
match lemma.name? with
|
||||
match lemma.name? with
|
||||
| none => false
|
||||
| some name => erased.contains name
|
||||
|
||||
getLHS (kind : SimpLemmaKind) (type : Expr) : MetaM Expr :=
|
||||
match kind with
|
||||
| SimpLemmaKind.pos => return type
|
||||
| SimpLemmaKind.neg => return type.appArg!
|
||||
| SimpLemmaKind.eq => return type.appFn!.appArg!
|
||||
| SimpLemmaKind.iff => return type.appFn!.appArg!
|
||||
| SimpLemmaKind.ne => mkEq type.appFn!.appArg! type.appArg!
|
||||
|
||||
getRHS (kind : SimpLemmaKind) (type : Expr) : MetaM Expr :=
|
||||
match kind with
|
||||
| SimpLemmaKind.pos => return mkConst `True
|
||||
| SimpLemmaKind.neg => return mkConst `False
|
||||
| SimpLemmaKind.eq => return type.appArg!
|
||||
| SimpLemmaKind.iff => return type.appArg!
|
||||
| SimpLemmaKind.ne => return mkConst `False
|
||||
|
||||
finalizeProof (kind : SimpLemmaKind) (proof : Expr) : MetaM Expr :=
|
||||
match kind with
|
||||
| SimpLemmaKind.eq => return proof
|
||||
| SimpLemmaKind.iff => mkPropExt proof
|
||||
| SimpLemmaKind.pos => mkEqTrue proof
|
||||
| SimpLemmaKind.neg => mkEqFalse proof
|
||||
| SimpLemmaKind.ne => mkEqFalse proof
|
||||
|
||||
tryLemma? (lemma : SimpLemma) : SimpM (Option Result) :=
|
||||
withNewMCtxDepth do
|
||||
|
|
@ -82,20 +58,19 @@ where
|
|||
let type ← inferType val
|
||||
let (xs, bis, type) ← forallMetaTelescopeReducing type
|
||||
let type ← instantiateMVars type
|
||||
let lhs ← getLHS lemma.kind type
|
||||
let lhs := type.appFn!.appArg!
|
||||
if (← isDefEq lhs e) then
|
||||
unless (← synthesizeArgs lemma.getName xs bis discharge?) do
|
||||
return none
|
||||
let proof ← instantiateMVars (mkAppN val xs)
|
||||
if ← hasAssignableMVar proof then
|
||||
return none
|
||||
let rhs ← instantiateMVars (← getRHS lemma.kind type)
|
||||
let rhs ← instantiateMVars type.appArg!
|
||||
if e == rhs then
|
||||
return none
|
||||
if lemma.perm && !Expr.lt rhs e then
|
||||
trace[Meta.Tactic.simp.rewrite]! "{lemma}, perm rejected {e} ==> {rhs}"
|
||||
return none
|
||||
let proof ← finalizeProof lemma.kind proof
|
||||
trace[Meta.Tactic.simp.rewrite]! "{lemma}, {e} ==> {rhs}"
|
||||
return some { expr := rhs, proof? := proof }
|
||||
else
|
||||
|
|
|
|||
12
stage0/src/Lean/Meta/Tactic/Simp/SimpLemmas.lean
generated
12
stage0/src/Lean/Meta/Tactic/Simp/SimpLemmas.lean
generated
|
|
@ -11,11 +11,6 @@ import Lean.Meta.AppBuilder
|
|||
import Lean.Meta.Tactic.AuxLemma
|
||||
namespace Lean.Meta
|
||||
|
||||
-- TODO: remove
|
||||
inductive SimpLemmaKind where
|
||||
| eq | iff | ne | pos | neg
|
||||
deriving Inhabited, BEq
|
||||
|
||||
structure SimpLemma where
|
||||
keys : Array DiscrTree.Key
|
||||
val : Expr
|
||||
|
|
@ -23,7 +18,6 @@ structure SimpLemma where
|
|||
post : Bool
|
||||
perm : Bool -- true is lhs and rhs are identical modulo permutation of variables
|
||||
name? : Option Name := none -- for debugging and tracing purposes
|
||||
kind : SimpLemmaKind
|
||||
deriving Inhabited
|
||||
|
||||
def SimpLemma.getName (s : SimpLemma) : Name :=
|
||||
|
|
@ -133,11 +127,11 @@ def mkSimpLemmaCore (e : Expr) (val : Expr) (post : Bool) (prio : Nat) (name? :
|
|||
let type ← instantiateMVars (← inferType e)
|
||||
withNewMCtxDepth do
|
||||
let (xs, _, type) ← withReducible <| forallMetaTelescopeReducing type
|
||||
let (keys, perm, kind) ←
|
||||
let (keys, perm) ←
|
||||
match type.eq? with
|
||||
| some (_, lhs, rhs) => pure (← DiscrTree.mkPath lhs, ← isPerm lhs rhs, SimpLemmaKind.eq)
|
||||
| some (_, lhs, rhs) => pure (← DiscrTree.mkPath lhs, ← isPerm lhs rhs)
|
||||
| none => throwError! "unexpected kind of 'simp' lemma"
|
||||
return { keys := keys, perm := perm, kind := kind, post := post, val := val, name? := name?, priority := prio }
|
||||
return { keys := keys, perm := perm, post := post, val := val, name? := name?, priority := prio }
|
||||
|
||||
def mkSimpLemmasFromConst (declName : Name) (post : Bool) (prio : Nat) : MetaM (Array SimpLemma) := do
|
||||
let cinfo ← getConstInfo declName
|
||||
|
|
|
|||
8
stage0/stdlib/Lean/Elab/Tactic/Simp.c
generated
8
stage0/stdlib/Lean/Elab/Tactic/Simp.c
generated
|
|
@ -53,6 +53,7 @@ lean_object* lean_string_append(lean_object*, lean_object*);
|
|||
lean_object* l_Lean_Elab_Tactic_simpLocalDeclFVarId(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_List_map___at_Lean_resolveGlobalConst___spec__2(lean_object*);
|
||||
lean_object* l___private_Lean_Elab_Tactic_Simp_0__Lean_Elab_Tactic_elabSimpLemmas___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
extern lean_object* l_Lean_Meta_initFn____x40_Lean_Meta_Tactic_Simp_SimpLemmas___hyg_278____closed__3;
|
||||
lean_object* l_Lean_resolveGlobalConst___at___private_Lean_Elab_Tactic_Simp_0__Lean_Elab_Tactic_elabSimpLemmas___spec__4(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_throwError___at___private_Lean_Elab_Tactic_Simp_0__Lean_Elab_Tactic_elabSimpLemmas___spec__2(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_KeyedDeclsAttribute_addBuiltin___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
|
|
@ -81,7 +82,6 @@ lean_object* l_Lean_Elab_Tactic_expandOptLocation(lean_object*);
|
|||
lean_object* l_Array_forInUnsafe_loop___at___private_Lean_Elab_Tactic_Simp_0__Lean_Elab_Tactic_elabSimpLemmas___spec__9(lean_object*, size_t, size_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_Elab_Tactic_simpAll___lambda__1(lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_Elab_Tactic_evalSimp___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
extern lean_object* l_Lean_Meta_initFn____x40_Lean_Meta_Tactic_Simp_SimpLemmas___hyg_2025____closed__1;
|
||||
lean_object* l_Lean_throwError___at___private_Lean_Elab_Tactic_Simp_0__Lean_Elab_Tactic_elabSimpLemmas___spec__7(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_Elab_Tactic_elabSimpConfig(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
extern lean_object* l_Lean_Meta_initFn____x40_Lean_Meta_Basic___hyg_556____closed__1;
|
||||
|
|
@ -130,7 +130,6 @@ lean_object* l_Lean_Elab_Tactic_evalExact___lambda__1___boxed(lean_object*, lean
|
|||
lean_object* l_Lean_Elab_Tactic_try___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_Meta_withNewMCtxDepth___at_Lean_Elab_Tactic_elabSimpConfig___spec__1___at_Lean_Elab_Tactic_elabSimpConfig___spec__2___closed__2;
|
||||
lean_object* l_Lean_LocalDecl_fvarId(lean_object*);
|
||||
extern lean_object* l_Lean_Meta_initFn____x40_Lean_Meta_Tactic_Simp_SimpLemmas___hyg_339____closed__3;
|
||||
lean_object* l_Lean_Meta_withNewMCtxDepth___at_Lean_Elab_Tactic_elabSimpConfig___spec__1___at_Lean_Elab_Tactic_elabSimpConfig___spec__2___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_LocalDecl_type(lean_object*);
|
||||
lean_object* l_Lean_Meta_throwTacticEx___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
|
|
@ -154,6 +153,7 @@ lean_object* l_ReaderT_bind___at_Lean_Elab_Tactic_liftMetaTacticAux___spec__1___
|
|||
lean_object* l_Lean_Syntax_getKind(lean_object*);
|
||||
lean_object* l_Lean_Elab_Tactic_saveBacktrackableState___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_Meta_SimpLemmas_erase___at___private_Lean_Elab_Tactic_Simp_0__Lean_Elab_Tactic_elabSimpLemmas___spec__8___boxed(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
extern lean_object* l_Lean_Meta_initFn____x40_Lean_Meta_Tactic_Simp_SimpLemmas___hyg_1957____closed__1;
|
||||
lean_object* l_Lean_Elab_Tactic_setGoals(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_Meta_withMVarContext___at_Lean_Elab_Tactic_withMainMVarContext___spec__1___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Lean_Meta_SimpLemmas_add(lean_object*, lean_object*, uint8_t, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
|
|
@ -1034,7 +1034,7 @@ lean_dec(x_22);
|
|||
x_25 = lean_ctor_get(x_23, 0);
|
||||
lean_inc(x_25);
|
||||
lean_dec(x_23);
|
||||
x_26 = l_Lean_Meta_initFn____x40_Lean_Meta_Tactic_Simp_SimpLemmas___hyg_2025____closed__1;
|
||||
x_26 = l_Lean_Meta_initFn____x40_Lean_Meta_Tactic_Simp_SimpLemmas___hyg_1957____closed__1;
|
||||
x_27 = l_Lean_Elab_Tactic_simpAll___lambda__1___closed__3;
|
||||
x_28 = lean_box(0);
|
||||
x_29 = l_Lean_Meta_throwTacticEx___rarg(x_26, x_25, x_27, x_28, x_8, x_9, x_10, x_11, x_24);
|
||||
|
|
@ -3616,7 +3616,7 @@ else
|
|||
{
|
||||
lean_object* x_80;
|
||||
lean_dec(x_21);
|
||||
x_80 = l_Lean_Meta_initFn____x40_Lean_Meta_Tactic_Simp_SimpLemmas___hyg_339____closed__3;
|
||||
x_80 = l_Lean_Meta_initFn____x40_Lean_Meta_Tactic_Simp_SimpLemmas___hyg_278____closed__3;
|
||||
x_29 = x_80;
|
||||
goto block_79;
|
||||
}
|
||||
|
|
|
|||
1958
stage0/stdlib/Lean/Meta/Tactic/Simp/Rewrite.c
generated
1958
stage0/stdlib/Lean/Meta/Tactic/Simp/Rewrite.c
generated
File diff suppressed because it is too large
Load diff
1197
stage0/stdlib/Lean/Meta/Tactic/Simp/SimpLemmas.c
generated
1197
stage0/stdlib/Lean/Meta/Tactic/Simp/SimpLemmas.c
generated
File diff suppressed because it is too large
Load diff
50
stage0/stdlib/Std/Data/PersistentHashMap.c
generated
50
stage0/stdlib/Std/Data/PersistentHashMap.c
generated
|
|
@ -73,7 +73,6 @@ lean_object* l_Std_PersistentHashMap_collectStats___rarg___boxed(lean_object*, l
|
|||
lean_object* l_Std_PersistentHashMap_foldlMAux___rarg___lambda__1(lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_foldlM(lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_findEntryAtAux(lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_isUnaryEntries_match__2(lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_find_x3f_match__1___rarg(lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_toList___rarg(lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_stats___rarg___closed__1;
|
||||
|
|
@ -217,7 +216,6 @@ lean_object* l_Std_PersistentHashMap_find_x21___rarg(lean_object*, lean_object*,
|
|||
lean_object* l_Std_PersistentHashMap_insertAux_match__1___rarg(lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_instInhabitedPersistentHashMap___rarg___boxed(lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_foldl___rarg(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_isUnaryEntries_match__2___rarg(lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_insert_match__1(lean_object*, lean_object*, lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_eraseAux_match__5(lean_object*, lean_object*, lean_object*);
|
||||
lean_object* l_Std_PersistentHashMap_eraseAux_match__4(lean_object*, lean_object*, lean_object*);
|
||||
|
|
@ -2335,54 +2333,6 @@ x_4 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_isUnaryEntries_match__1
|
|||
return x_4;
|
||||
}
|
||||
}
|
||||
lean_object* l_Std_PersistentHashMap_isUnaryEntries_match__2___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3, lean_object* x_4) {
|
||||
_start:
|
||||
{
|
||||
switch (lean_obj_tag(x_1)) {
|
||||
case 0:
|
||||
{
|
||||
lean_object* x_5; lean_object* x_6; lean_object* x_7;
|
||||
lean_dec(x_3);
|
||||
lean_dec(x_2);
|
||||
x_5 = lean_ctor_get(x_1, 0);
|
||||
lean_inc(x_5);
|
||||
x_6 = lean_ctor_get(x_1, 1);
|
||||
lean_inc(x_6);
|
||||
lean_dec(x_1);
|
||||
x_7 = lean_apply_2(x_4, x_5, x_6);
|
||||
return x_7;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
lean_object* x_8; lean_object* x_9;
|
||||
lean_dec(x_4);
|
||||
lean_dec(x_2);
|
||||
x_8 = lean_ctor_get(x_1, 0);
|
||||
lean_inc(x_8);
|
||||
lean_dec(x_1);
|
||||
x_9 = lean_apply_1(x_3, x_8);
|
||||
return x_9;
|
||||
}
|
||||
default:
|
||||
{
|
||||
lean_object* x_10; lean_object* x_11;
|
||||
lean_dec(x_4);
|
||||
lean_dec(x_3);
|
||||
x_10 = lean_box(0);
|
||||
x_11 = lean_apply_1(x_2, x_10);
|
||||
return x_11;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
lean_object* l_Std_PersistentHashMap_isUnaryEntries_match__2(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
|
||||
_start:
|
||||
{
|
||||
lean_object* x_4;
|
||||
x_4 = lean_alloc_closure((void*)(l_Std_PersistentHashMap_isUnaryEntries_match__2___rarg), 4, 0);
|
||||
return x_4;
|
||||
}
|
||||
}
|
||||
lean_object* l_Std_PersistentHashMap_isUnaryEntries___rarg(lean_object* x_1, lean_object* x_2, lean_object* x_3) {
|
||||
_start:
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue