lean4-htt/tests/lean/run/grind_attrs.lean
Leonardo de Moura 6ca699b1ff
feat: enable new E-matching pattern inference procedure in grind (#10432)
This PR enables the new E-matching pattern inference heuristic for
`grind`, implemented in PR #10422.
**Important**: Users can still use the old pattern inference heuristic
by setting:

```lean
set_option backward.grind.inferPattern true
```

In PR #10422, we introduced the new modifier `@[grind!]` for enabling
the minimal indexable subexpression condition. This option can now also
be set in `grind` parameters. Example:

```lean
opaque f : Nat → Nat
opaque fInv : Nat → Nat 
axiom fInv_f : fInv (f x) = x

/-- trace: [grind.ematch.pattern] fInv_f: [f #0] -/
#guard_msgs in 
set_option trace.grind.ematch.pattern true in
example {x y} : f x = f y → x = y := by
  /-
  The modifier `!` instructs `grind` to use the minimal indexable subexpression 
  (i.e., `f x` in this case).   
  -/
  grind [!fInv_f] 
```
2025-09-18 04:13:54 +00:00

62 lines
1.8 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

module
opaque R : Nat → Nat → Prop
@[grind ->]
axiom Rtrans {x y z : Nat} : R x y → R y z → R x z
@[grind →]
axiom Rtrans' {x y z : Nat} : R x y → R y z → R x z
@[grind <-]
axiom Rsymm {x y : Nat} : R x y → R y x
@[grind ←]
axiom Rsymm' {x y : Nat} : R x y → R y x
example : R a b → R b c → R d c → R a d := by
grind only [-> Rtrans, <- Rsymm]
example : R a b → R b c → R d c → R a d := by
grind only [→ Rtrans, ← Rsymm]
opaque State : Type
opaque State.le (σ₁ σ₂ : State) : Prop
axiom State.update : State → Nat → Nat → State
opaque Expr : Type
opaque Expr.eval : Expr → State → Nat
axiom Expr.constProp : Expr → State → Expr
/-- trace: [grind.ematch.pattern] eval_constProp_of_sub: [State.le #3 #2, constProp #1 #3] -/
#guard_msgs (trace) in
set_option trace.grind.ematch.pattern true in
@[grind! =>] theorem Expr.eval_constProp_of_sub (e : Expr) (h : State.le σ' σ) : (e.constProp σ').eval σ = e.eval σ :=
sorry
/-- trace: [grind.ematch.pattern] eval_constProp_of_eq_of_sub: [State.le #3 #2, constProp #1 #3] -/
#guard_msgs (trace) in
set_option trace.grind.ematch.pattern true in
@[grind! =>] theorem Expr.eval_constProp_of_eq_of_sub {e : Expr} (h₂ : State.le σ' σ) : (e.constProp σ').eval σ = e.eval σ :=
sorry
/-- trace: [grind.ematch.pattern] update_le_update: [le #4 #3, update #4 #2 #1] -/
#guard_msgs (trace) in
set_option trace.grind.ematch.pattern true in
@[grind! =>] theorem State.update_le_update (h : State.le σ' σ) : State.le (σ'.update x v) (σ.update x v) :=
sorry
namespace Foo
/-- info: Rtrans: [R #4 #3, R #3 #2] -/
#guard_msgs (info) in
@[grind? ->]
axiom Rtrans {x y z : Nat} : R x y → R y z → R x z
/-- info: Rtrans': [R #4 #3, R #3 #2] -/
#guard_msgs (info) in
@[grind? →]
axiom Rtrans' {x y z : Nat} : R x y → R y z → R x z
end Foo