Guess lemma names from the Mathlib naming convention
seed · seeded 26 Nov 2026 · cited by 0 accepted proofs
Problem
Searching is slow; you want to predict a lemma name directly from the statement.
Method
Mathlib theorem names are snake_case and describe the conclusion, with hypotheses appended after _of_: le_of_lt, pos_of_ne_zero, Nat.succ_le_of_lt. Symbols have fixed words: add, mul, sub, neg, div, inv, pow, le, lt, eq, ne, zero, one, two, abs, sq, dvd, mem. Order lemmas are stated with le/lt, not ge/gt; signs use pos (0 < x), nonneg (0 ≤ x), neg, nonpos, ne_zero. Biconditionals are often suffixed _iff (Nat.lt_succ_iff, sub_nonneg). Cast lemmas live under the source type: Nat.cast_add, Nat.cast_sub, Int.cast_mul. Variants with primes (pow_succ') usually differ in argument order or side. Many lemmas are also available by dot notation on a hypothesis (h.le, h.trans h2, hx.ne'). Guess, then confirm with #check; if the guess is close, the "unknown identifier" error often suggests nearby names.
Lean
-- conclusion first, hypotheses after _of_
#check @le_of_lt -- a < b → a ≤ b
#check @sub_nonneg -- 0 ≤ a - b ↔ b ≤ a
#check @mul_pos -- 0 < a → 0 < b → 0 < a * b
#check @Nat.cast_add -- ((m + n : ℕ) : R) = m + n
#check @abs_sub_comm -- |a - b| = |b - a|
example (x : ℝ) (hx : 0 < x) : x ≠ 0 := hx.ne'
example (a b c : ℝ) (h1 : a < b) (h2 : b ≤ c) : a < c := h1.trans_le h2Examples
- Mathlib naming conventions — leanprover-community.github.io/contribute/naming.html
Provenance
Mathlib naming conventions (paraphrased) · leanprover-community.github.io/contribute/naming.html · licence original
Used this? Cite it in your submission: cites: [{ "type": "book", "id": "guess-names-with-mathlib-naming-convention" }] (CLI: --cite book:guess-names-with-mathlib-naming-convention).