feat: better support for eta expanded terms in grind (#12415)

This PR improves the support for eta expanded terms in `grind` patterns.

Closes #12390
This commit is contained in:
Leonardo de Moura 2026-02-10 11:46:00 -08:00 committed by GitHub
parent 80257a6901
commit 14b595e952
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 1 deletions

View file

@ -9,6 +9,7 @@ public import Lean.Meta.Tactic.Grind.Extension
import Lean.Meta.Tactic.Grind.Util
import Lean.Meta.Tactic.TryThis
import Lean.Meta.Sym.Util
import Lean.Meta.Sym.Eta
public section
namespace Lean.Meta.Grind
/-!
@ -280,7 +281,10 @@ private theorem normConfig_zetaDelta : normConfig.zetaDelta = true := rfl
def preprocessPattern (pat : Expr) (normalizePattern := true) : MetaM Expr := do
let pat ← instantiateMVars pat
let pat ← Sym.unfoldReducible pat
let pat ← if normalizePattern then normalize pat normConfig else pure pat
let pat ← if normalizePattern then
Sym.etaReduceAll (← normalize pat normConfig)
else
pure pat
let pat ← detectOffsets pat
let pat ← foldProjs pat
return pat

View file

@ -0,0 +1,24 @@
variable {α β : Type}
axiom foo (f : α → β) : β
axiom fooProp : β → Prop
axiom fooProp_foo {f : α → β} : fooProp (foo (fun x ↦ f x))
axiom fooProp_foo' {f : α → β} : fooProp (foo f)
attribute [grind ←] fooProp_foo -- should work
example {f : α → β} : fooProp (foo f) := by grind -- succeeds, using `fooProp_foo`
/--
info: Try these:
[apply] grind only [← fooProp_foo]
[apply] grind => instantiate only [← fooProp_foo]
-/
#guard_msgs in
example {f : α → β} : fooProp (foo f) := by grind? -- succeeds, using `fooProp_foo`
attribute [grind ←] fooProp_foo' -- succeeds
example {f : α → β} : fooProp (foo f) := by grind