Skip to content

Commit

Permalink
fix: let_fun support in grind (#6531)
Browse files Browse the repository at this point in the history
This PR fixes the support for `let_fun` in `grind`.
  • Loading branch information
leodemoura authored Jan 4, 2025
1 parent a5b1ed9 commit d22233f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Lean/Meta/Tactic/Grind/Intro.lean
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private def introNext (goal : Goal) (generation : Nat) : GrindM IntroResult := d
-- `p` and `p'` are definitionally equal
goal.mvarId.assign h
return .newHyp fvarId { goal with mvarId := mvarIdNew }
else if target.isLet || target.isForall then
else if target.isLet || target.isForall || target.isLetFun then
let (fvarId, mvarId) ← goal.mvarId.intro1P
mvarId.withContext do
let localDecl ← fvarId.getDecl
Expand All @@ -59,8 +59,8 @@ private def introNext (goal : Goal) (generation : Nat) : GrindM IntroResult := d
return .newDepHyp { goal with mvarId }
else
let goal := { goal with mvarId }
if target.isLet then
let v := target.letValue!
if target.isLet || target.isLetFun then
let v := (← fvarId.getDecl).value
let r ← simp v
let x ← shareCommon (mkFVar fvarId)
let goal ← GoalM.run' goal <| addNewEq x r.expr (← r.getProof) generation
Expand Down
19 changes: 19 additions & 0 deletions tests/lean/run/grind_t1.lean
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,24 @@ example (foo : Nat → Nat)

end dite_propagator_test

/--
info: [grind.eqc] x = 2 * a
[grind.eqc] y = x
[grind.eqc] (y = 2 * a) = False
[grind.eqc] (y = 2 * a) = True
-/
#guard_msgs (info) in
set_option trace.grind.eqc true in
example (a : Nat) : let x := a + a; y = x → y = a + a := by
grind

/--
info: [grind.eqc] x = 2 * a
[grind.eqc] y = x
[grind.eqc] (y = 2 * a) = False
[grind.eqc] (y = 2 * a) = True
-/
#guard_msgs (info) in
set_option trace.grind.eqc true in
example (a : Nat) : let_fun x := a + a; y = x → y = a + a := by
grind

0 comments on commit d22233f

Please sign in to comment.