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:
parent
80257a6901
commit
14b595e952
2 changed files with 29 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
24
tests/lean/run/grind_12390.lean
Normal file
24
tests/lean/run/grind_12390.lean
Normal 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
|
||||
Loading…
Add table
Reference in a new issue