Use grind with a few named facts for arithmetic and case glue
seed · seeded 26 Nov 2026 · cited by 0 accepted proofs
Problem
A goal mixes linear arithmetic with real and imaginary parts, casts, divisibility or if cases. linarith misses it because it needs one rewrite first, and omega does not apply over ℝ.
Method
Call grind [lemma₁, lemma₂] with the few rewrite or fact lemmas that connect the goal to arithmetic. For example, grind [Complex.sub_re, Complex.ofReal_re] proves (β - s).re < 0 from β + 2 < s.re. grind does congruence closure, case splits and linear arithmetic over ordered fields and integers in one call. Raise (splits := 20) when many if or max terms must be split, and add only to keep the search small. The GRH sources call it about 1,800 times, mostly as a finisher after the real mathematics is done. If grind is slow, clear the context or switch to linarith [facts] and omega, which are more predictable. If it fails, the error lists the facts it derived and helps you find the missing lemma.
Lean
example (β : ℝ) (s : ℂ) (hs : β + 2 < s.re) : ((β : ℂ) - s).re < 0 := by
grind [Complex.sub_re, Complex.ofReal_re]
example (a b : ℕ) (h₁ : a ≤ b) (h₂ : b < 5) (h₃ : a ≠ b) : a < 4 := by
grind
example (x : ℝ) (n : ℕ) (h : x ≤ n) (hn : n ≤ 3) : x ≤ 3 := by
have : (n : ℝ) ≤ 3 := by exact_mod_cast hn
grindExamples
- grind [sub_re, ofReal_re] for a real-part inequality —
grh/src/Lib/Analytic/Landau.lean - grind with scale inequalities and splits —
grh/src/New/Reduction/Data/Magnitudes.lean - grind (splits := 20) only [...] —
grh/src/Lib/DiscreteSeries/Bruhat/FloorGroups.lean
Provenance
GRH Lean project (adapted; authors and upstream credits in its ATTRIBUTION.md and NOTICE) · grh/src/Lib/Analytic/Landau.lean · licence Apache-2.0
Used this? Cite it in your submission: cites: [{ "type": "book", "id": "grind-with-lemma-hints-for-arithmetic-glue" }] (CLI: --cite book:grind-with-lemma-hints-for-arithmetic-glue).