Tactics in Lean 4 are metaprograms that transform the current proof state — a collection of hypotheses and a goal — into zero or more simpler subgoals. Rather than constructing a complete proof term by hand, you enter tactic mode with theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/leanprover-community/mathlib4/llms.txt
Use this file to discover all available pages before exploring further.
by keyword and issue a sequence of commands that incrementally discharge obligations. Mathlib ships hundreds of tactics covering arithmetic decision procedures, simplification engines, general-purpose proof search, and structural decomposition tools, making it possible to prove substantial mathematical results with concise, readable proof scripts.
Importing Tactics
The simplest way to access all of Mathlib’s tactics is a single import at the top of your file:Tactic Mode vs Term Mode
Lean 4 supports two styles of proof writing. In term mode, you construct a proof term directly using function application, pattern matching, and anonymous constructors. In tactic mode, opened withby, you describe how to build that term step by step.
Experimentation Keywords
Lean 4 provides several commands useful for exploration:hint tactic (available after import Mathlib) suggests which tactics might close the current goal:
Tactic Taxonomy
Mathlib tactics fall into four broad categories. Each has its own documentation page.Arithmetic
Decision procedures for numeric goals:
linarith, nlinarith, omega, norm_num, ring, ring_nf, abel, field_simp.Simplification
Term rewriting and normalization:
simp, simp_rw, simp_all, norm_cast, push_cast, push_neg, gcongr.Automation
General proof search and property provers:
decide, native_decide, tauto, aesop, positivity, fun_prop, continuity, measurability.Structural
Proof structure and decomposition:
ext, use, obtain, rcases, induction, constructor, apply, exact, refine, by_contra, wlog, tfae_have.Quick-Reference Tactic Grid
The table below lists the most-used tactics with a one-line description.| Tactic | What it does |
|---|---|
linarith | Proves linear arithmetic goals over ordered rings |
nlinarith | Extends linarith to basic nonlinear arithmetic |
omega | Decision procedure for ℕ/ℤ linear arithmetic, handles % and / |
norm_num | Normalizes and proves numeric expressions (primes, fractions, etc.) |
ring | Proves equalities in commutative (semi)rings |
abel | Proves equalities in additive commutative groups/monoids |
field_simp | Clears denominators in field expressions |
simp | Rewrites using @[simp]-tagged lemmas |
simp_rw | Like simp only but rewrites under binders |
norm_cast | Normalizes numeric coercions (ℕ → ℤ → ℚ → ℝ) |
push_neg | Pushes ¬ through quantifiers and connectives |
gcongr | Applies congruence lemmas for inequality goals |
decide | Evaluates decidable propositions by kernel reduction |
native_decide | Like decide but compiles to native code |
aesop | General proof search via forward/backward chaining + simp |
positivity | Proves 0 ≤ e, 0 < e, or e ≠ 0 |
fun_prop | Proves function properties (continuity, measurability, etc.) |
ext | Applies extensionality lemmas tagged @[ext] |
use | Provides witnesses for existential goals |
obtain / rcases | Destructures hypotheses by pattern matching |
induction | Induction on an inductive type |
by_contra | Introduces ¬ goal and switches to proving False |
wlog | Reduces goal to a canonical case |
The ? Variants
Many Mathlib tactics have a ? variant that, on success, prints a more explicit version of the call it used. This is invaluable for learning and for making proofs more robust:
Using
linarith? or simp? in finished proofs can slow down compilation. Replace the ? call with the printed suggestion once you are happy with the proof.Further Reading
- Arithmetic Tactics —
linarith,ring,norm_num,omega,abel,field_simp - Simplification Tactics —
simp,simp_rw,norm_cast,push_neg,gcongr - Automation Tactics —
aesop,positivity,fun_prop,decide - Structural Tactics —
ext,use,obtain,induction,wlog,tfae_have