fix: unfold constants at simp

This commit is contained in:
Leonardo de Moura 2021-02-16 15:42:31 -08:00
parent 3e65f586cc
commit 5f80659b45
3 changed files with 9 additions and 3 deletions

View file

@ -12,7 +12,7 @@ namespace Simp
builtin_initialize congrHypothesisExceptionId : InternalExceptionId ←
registerInternalExceptionId `congrHypothesisFailed
def throwCongrHypothesisFailed {α} : MetaM α :=
def throwCongrHypothesisFailed : MetaM α :=
throw <| Exception.internal congrHypothesisExceptionId
def Result.getProof (r : Result) : MetaM Expr := do

View file

@ -141,7 +141,7 @@ def rewriteUsingDecide? (e : Expr) : MetaM (Option Result) := withReducibleAndIn
x
@[inline] def tryUnfold (e : Expr) (x : SimpM Step) : SimpM Step := do
if e.isApp && e.getAppFn.isConst && (← read).toUnfold.contains e.getAppFn.constName! then
if e.getAppFn.isConst && (← read).toUnfold.contains e.getAppFn.constName! then
-- TODO: try simp lemmas
match (← withDefault <| unfoldDefinition? e) with
| some eNew => return Step.visit { expr := eNew }

View file

@ -29,5 +29,11 @@ def head [Inhabited α] : List αα
| [] => arbitrary
| a::_ => a
theorem ex [Inhabited α] (a : α) (as : List α) : head (a::as) = a :=
theorem ex4 [Inhabited α] (a : α) (as : List α) : head (a::as) = a :=
by simp [head]
def foo := 10
theorem ex5 (x : Nat) : foo + x = 10 + x := by
simp [foo]
done