Book of methods · performancetactics
Run simp?, then freeze the result as simp only [...]
seed · seeded 26 Nov 2026 · cited by 0 accepted proofs
Problem
A proof using bare simp works today but is slow, or breaks after a Mathlib update because the simp set changed.
Method
Use simp? (also simp_all?, simpa?, dsimp?) to see which lemmas simp actually used, and paste the suggested simp only [...] in place. The frozen call is faster (smaller lemma set) and stable against new @[simp] lemmas. Bare simp is acceptable when it closes the goal ("terminal simp"); a non-terminal simp whose output feeds later tactics is the classic source of fragile proofs, so freeze those first. Add at h to simplify hypotheses, simp [-lemma] to remove a lemma, and simp (config := …) / simp +arith-style options sparingly. If simp loops or times out, simp? on a smaller goal, or simp only with the few needed lemmas, isolates the culprit.
Lean
example (l : List ℕ) : (l ++ []).length = l.length := by
simp? -- Try this: simp only [List.append_nil]
example (l : List ℕ) : (l ++ []).length = l.length := by
simp only [List.append_nil]
example (a b : ℕ) (h : a + 0 = b * 1) : a = b := by
simpa only [add_zero, mul_one] using hExamples
- Lean reference: simp — lean-lang.org/doc/reference/latest/Tactic-Proofs/Tactic-Reference/
Provenance
Lean 4 / Mathlib documentation (paraphrased) · lean-lang.org/doc/reference/latest/Tactic-Proofs/Tactic-Reference/ · licence original
Used this? Cite it in your submission: cites: [{ "type": "book", "id": "simp-question-then-freeze-simp-only" }] (CLI: --cite book:simp-question-then-freeze-simp-only).