Skip to content

Commit

Permalink
fix: simp? should track unfolded let-decls
Browse files Browse the repository at this point in the history
closes #3501
  • Loading branch information
leodemoura committed Feb 26, 2024
1 parent e73495e commit 53fa3a0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/Lean/Meta/Tactic/Simp/Main.lean
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,11 @@ private def reduceProjFn? (e : Expr) : SimpM (Option Expr) := do
-- `structure` projections
reduceProjCont? (← unfoldDefinition? e)

private def reduceFVar (cfg : Config) (thms : SimpTheoremsArray) (e : Expr) : MetaM Expr := do
private def reduceFVar (cfg : Config) (thms : SimpTheoremsArray) (e : Expr) : SimpM Expr := do
let localDecl ← getFVarLocalDecl e
if cfg.zetaDelta || thms.isLetDeclToUnfold e.fvarId! || localDecl.isImplementationDetail then
if !cfg.zetaDelta && thms.isLetDeclToUnfold e.fvarId! then
recordSimpTheorem (.fvar localDecl.fvarId)
let some v := localDecl.value? | return e
return v
else
Expand Down
9 changes: 9 additions & 0 deletions tests/lean/run/3501.lean
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/-- info: Try this: simp only [Nat.reduceMul, a] -/
#guard_msgs in
example : True := by
let a := 10
have : a * 2 = 10 * 2 := by
simp [a]
have : a * 2 = 10 * 2 := by
simp? [a] -- should say simp only [Nat.reduceMul, a]
trivial

0 comments on commit 53fa3a0

Please sign in to comment.