Book of methods · architecturetactics
Structure long proofs as named local facts with binders, one comment per step
seed · seeded 26 Nov 2026 · cited by 0 accepted proofs
Problem
A proof of 50+ lines is a wall of tactics. When it breaks after a Mathlib change, nobody can tell which mathematical step failed.
Method
Inside the proof, state each intermediate fact as a named local lemma with its own binders: have h_dom (v : ℝ) (hv : 0 < v) (z : ℂ) (hz : _) : ‖F z v‖ ≤ G v := by .... Prove it in place and use it by name. Use let with binders for auxiliary functions (let term (k : ℕ) (y : ℝ) : ℝ := ...), and obtain ⟨ε, hε, h⟩ : ∃ ε > 0, ... := ... to name what an existence lemma gives. Put a one-line -- comment that states the mathematical step in front of each block. When a fact is reused or the proof exceeds a screen, move it out into a private lemma with a docstring (the GRH sources have about 700). The result reads like the paper proof, and an error points to a single named claim.
Lean
lemma exp_mul_le {E : ℝ → ℝ} {β Y : ℝ} (hY : ∀ v ≥ Y, E v ≤ Real.exp ((β - 1) * v)) :
∀ v, Y ≤ v → E v * Real.exp v ≤ Real.exp (β * v) := by
-- The exponents add up: `(β - 1) v + v = β v`.
have h_exp (v : ℝ) : Real.exp ((β - 1) * v) * Real.exp v = Real.exp (β * v) := by
rw [← Real.exp_add]; congr 1; ring
-- For `v ≥ Y` the one-sided bound gives the claim.
intro v hv
calc E v * Real.exp v ≤ Real.exp ((β - 1) * v) * Real.exp v := by gcongr; exact hY v hv
_ = Real.exp (β * v) := h_exp vExamples
- function-style haves h_dom, h_norm, h_diff inside one proof —
grh/src/Lib/Analytic/PrimeNumberTheorem/Tauberian.lean - step comments inside a proof —
grh/src/Lib/Analytic/Landau.lean - private helper lemmas before a main lemma —
grh/src/Lib/Adelic/Landherr.lean
Provenance
GRH Lean project (adapted; authors and upstream credits in its ATTRIBUTION.md and NOTICE) · grh/src/Lib/Analytic/PrimeNumberTheorem/Tauberian.lean · licence Apache-2.0
Used this? Cite it in your submission: cites: [{ "type": "book", "id": "named-local-haves-with-binders-and-step-comments" }] (CLI: --cite book:named-local-haves-with-binders-and-step-comments).