grind: An SMT-Inspired Tactic for Lean 4

Kim Morrison, Leonardo de Moura
Lean FRO | AWS and Lean FRO
IJCAR 2026, Lisbon | July 2026
Lean

What Is grind?

A virtual whiteboard, inspired by modern SMT solvers.

  • Writes facts on the board. Merges equivalent terms.

  • Cooperating engines: congruence closure, E-matching, constraint propagation, guided case analysis.

  • Satellite theory solvers: cutsat (linear integer arithmetic), commutative rings (Gröbner), linarith, AC.

  • Native to dependent type theory. No translation to FOL.

  • Produces ordinary Lean proof terms. Kernel-checkable.

  • 5,000+ grind uses in Mathlib.

Lean Goal
Preprocessing
Internalization
E-graph
cutsat
rings
linarith
orders
ac

Lean

grind — Theory Combination

example [CommRing α] [NoNatZeroDivisors α] (a b c : α) (f : α Nat) : a + b + c = 3 a^2 + b^2 + c^2 = 5 a^3 + b^3 + c^3 = 7 f (a^4 + b^4) + f (9 - c^4) 1 := by grind

Three solvers meet at the E-graph:

  • Ring solver derives a^4 + b^4 = 9 - c^4.

  • Congruence closure lifts it to f (a^4 + b^4) = f (9 - c^4).

  • Linear integer arithmetic closes 2 * f (9 - c^4) ≠ 1.

The Nelson-Oppen playbook. Inside dependent type theory. No SMT translation layer.

Lean

grind — Typeclass-Parameterized Theory Solvers

Satellite solvers activate automatically when the type classes are present.

  • RingCommRing, CommSemiring, Field, IsCharP, NoNatZeroDivisors.

  • linarith — module over the integers. Preorders, partial, linear orders.

  • AC — any associative-commutative operator.

-- BitVec 8 is a CommRing of characteristic 256. -- No bitvector-specific theory needed. example (x : BitVec 8) : (x - 16) * (x + 16) = x^2 := by grind -- Bitwise Or is AC and idempotent example (x y w z: Nat) : x ||| z = w ||| x z ||| y ||| x ||| x = x ||| y ||| w := by grind
Lean

grind — Annotations and E-Matching

Library authors annotate theorems; grind instantiates them by E-matching — pattern matching modulo the E-graph.

  • [grind =] — use the LHS as the E-matching pattern.

  • [grind →] — forward reasoning: patterns from hypotheses.

  • [grind ←] — backward reasoning: patterns from the conclusion.

  • grind_pattern — custom multi-patterns.

  • Constraint system on patterns: guard, check, is_value, is_strict_value.

@[grind =] theorem fg {x} : f (g x) = x := by unfold f g; omega example {a b c} : f a = b a = g c b = c := by grind
Lean

grind — Interactive Mode

grind => exposes a domain-specific language for stepping through the solver's execution. You can mix grind steps with ordinary tactics.

example : (cos x + sin x)^2 = 2 * cos x * sin x + 1 := by grind => instantiate only [trig_identity] ring

Both humans and AI can control grind.

example : (cos x + sin x)^2 = 2 * cos x * sin x + 1 := by grind?

Extensible: Users can add new grind tactics and solvers.

Lean

grind — Diagnostics

example (as bs cs : Array α) (v : α) (i : Nat) (h₁ : i < as.size) (h₂ : bs = as.set i v) (h₅ : j < bs.size) (h₆ : j < as.size) : bs[j] = as[j] := by grind
Lean

Conclusion

grind is a new extensible tactic based on SMT techniques.

Grind reference manual

New features and performance improvements are in development.

We expect AI systems will use grind => interactive mode.

Maintaining formal proofs is as hard as writing them in the first place.

lean-lang.org

Thank You

IJCAR 2026, Lisbon | July 2026