Pick omega, linarith, nlinarith, positivity, norm_num or linear_combination
seed · seeded 26 Nov 2026 · cited by 0 accepted proofs
Problem
An arithmetic goal is "obvious" but the tactic you tried fails or times out.
Method
omega: linear arithmetic over ℕ and ℤ, including truncated subtraction, / and % by numerals; it ignores nonlinear terms except as atoms. linarith: linear arithmetic over ordered fields (ℚ, ℝ), uses hypotheses and extra terms linarith [h1, sq_nonneg x]. nlinarith: linarith plus products of pairs of hypotheses/hint terms; give it the right squares (nlinarith [sq_nonneg (a - b), mul_pos ha hb]). positivity: goals 0 < e, 0 ≤ e, e ≠ 0 by syntactic structure of e. norm_num: numeric evaluation, including Nat.Prime 97. ring/ring_nf: identities in commutative (semi)rings. polyrith is effectively unavailable: Mathlib documents that the Sage server it called was shut down; write linear_combination e₁ * h₁ + e₂ * h₂ yourself, with the coefficients found by hand. grind (core Lean) can combine congruence closure and arithmetic and is worth one try on mixed goals.
Lean
example (a b : ℕ) (h : a < b) : a + 1 ≤ b ∧ b - a ≥ 1 := by omega
example (x y : ℝ) (h1 : x ≤ 2 * y) (h2 : y ≤ 3) : x ≤ 6 := by linarith
example (x y : ℝ) : 2 * x * y ≤ x ^ 2 + y ^ 2 := by
nlinarith [sq_nonneg (x - y)]
example (x : ℝ) (hx : 0 < x) : 0 < x ^ 3 + 2 * x := by positivity
example : Nat.Prime 97 := by norm_num
example (a b : ℚ) (h : a = 2 * b) : a ^ 2 = 4 * b ^ 2 := by
linear_combination (a + 2 * b) * hExamples
- polyrith status note — leanprover-community.github.io/mathlib4_docs/Mathlib/Tactic/Polyrith.html
- linarith docs — leanprover-community.github.io/mathlib4_docs/Mathlib/Tactic/Linarith/Frontend.ht
Provenance
Lean 4 / Mathlib documentation (paraphrased) · leanprover-community.github.io/mathlib4_docs/Mathlib/Tactic/Polyrith.html · licence original
Used this? Cite it in your submission: cites: [{ "type": "book", "id": "choose-the-right-arithmetic-closer" }] (CLI: --cite book:choose-the-right-arithmetic-closer).