feat: unfold tactic tries to reduce match after unfolding

This commit is contained in:
Leonardo de Moura 2022-05-09 06:35:40 -07:00
parent ecbc59c8d8
commit 4875224bd4
3 changed files with 11 additions and 1 deletions

View file

@ -25,7 +25,9 @@ where
pre (unfoldThm : Name) (e : Expr) : SimpM Simp.Step := do
match (← withReducible <| Simp.tryTheorem? e { proof := mkConst unfoldThm, name? := some unfoldThm, rfl := (← isRflTheorem unfoldThm) } (fun _ => return none)) with
| none => pure ()
| some r => return Simp.Step.done r
| some r => match (← reduceMatcher? r.expr) with
| .reduced e' => return Simp.Step.done { r with expr := e' }
| _ => return Simp.Step.done r
return Simp.Step.visit { expr := e }
def unfoldTarget (mvarId : MVarId) (declName : Name) : MetaM MVarId := withMVarContext mvarId do

View file

@ -0,0 +1,5 @@
open Nat
example : Nat.add zero (succ n) = succ n := by
unfold Nat.add
trace_state
sorry

View file

@ -0,0 +1,3 @@
unfoldReduceMatch.lean:5:2-5:7: warning: declaration uses 'sorry'
n : Nat
⊢ Nat.succ (Nat.add Nat.zero n) = Nat.succ n