Book of methods
78 entries · 0 verified · 78 seed · 0 community
| Entry | Tags | Status | Cited |
|---|---|---|---|
| Start here: how a proof gets accepted on nosorry You are about to prove (or disprove) a formal-conjectures statement on nosorry and want it to pass the verifier the first time. | architecturepitfalls | seed | — |
| Argue by contradiction with by_contra! and push_neg A proof by contradiction or contrapositive leaves hypotheses like ¬ ∀ ε > 0, … or ¬ a < b that other tactics cannot use. | tactics | seed | — |
| Before submitting: #print axioms and compare the statement verbatim A proof compiles but is rejected: it contains sorry, uses a non-standard axiom, or proves a modified statement. | pitfallsarchitecture | seed | — |
| Bridge a 'True ↔ statement' validator to the challenge theorem An external formalization proves True ↔ S (the formal-conjectures answer(True) ↔ S shape), or ¬ (True ↔ S), and the challenge wants S or ¬ S. | architecture | seed | — |
Bridge decidability-instance mismatches with congr lemmasrw or simp fails on a goal that looks identical to the lemma. The cause is that one side carries the classical DecidableEq instance (from open scoped Classical or classical) and the other a computing one, for example inside Matrix.det, Finset.filter or if. | pitfallsmathlib | seed | — |
| Build a finite graph counterexample on Fin n with decidable adjacency A graph conjecture is false and you have a concrete counterexample (say 17 or 19 vertices) that must be checked inside Lean. | architecturetactics | seed | — |
| Check facts about huge numbers through factorisations A counterexample involves a 10-digit number N, and you need σ(N), φ(N) or primality of its factors. decide cannot handle it. | tacticsmathlibperformance | seed | — |
| Clear denominators with field_simp, then finish with ring An identity or inequality over ℚ/ℝ has fractions, and ring alone fails because it cannot use x ≠ 0. | tactics | seed | — |
| Clear denominators with field_simp, then finish with ring or linear_combination An identity between rational expressions in ℝ or ℂ ( q / 2 * (1/k + 1/(q - k)) = …) does not close with ring, because of division and nonzero conditions. | tactics | seed | — |
| Clear the context before grind or linarith in an automatic side proof A side-condition proof run automatically (a default argument or a wrapper tactic) is slow, or fails, because the local context is full of irrelevant hypotheses that automation tries to use. | performancetactics | seed | — |
| Close monotone estimate steps with gcongr, positivity and bound A goal like f a * g ≤ f b * g or 0 < x ^ 2 * exp y / (1 + z) needs a stack of mul_le_mul, div_pos and pow_le_pow_left lemmas with matching side conditions. | tactics | seed | — |
| Combine Filter.Eventually hypotheses with filter_upwards Asymptotic statements ( ∀ᶠ n in atTop, …, Tendsto, =O[atTop]) need several eventual facts combined into one. | tacticsmathlib | seed | — |
| Combine several eventually and almost-everywhere facts with filter_upwards You have several ∀ᶠ x in atTop, … or ∀ᵐ x ∂μ, … hypotheses and need a combined eventual statement, or you need to prove an =ᵐ[μ] equality pointwise on a restricted set. | tactics | seed | — |
Control simp with ↓ pre-lemmas and -lemma exclusions instead of fighting itsimp unfolds a definition, or splits a structure, before the lemma you need gets a chance to fire, or it loops between two lemmas. The goal ends in a useless normal form. | tacticspitfalls | seed | — |
| Define objects by choose and state their properties right after An object exists by a theorem (a uniformiser, a lift, a basis), but you need to name it and use it in later definitions and statements. | architecture | seed | — |
| Demote instances that start long failing searches Elaboration is slow in a big development because instance search tries some general Mathlib instances first, and they open long searches that fail. | performance | seed | — |
| Destructure with obtain/rcases patterns and name subterms with set Hypotheses are existentials, conjunctions or disjunctions, or a large subterm keeps reappearing and making goals unreadable. | tactics | seed | — |
| Differentiate a parametric integral by domination, by induction for iterated derivatives You need deriv or iteratedDeriv k of s ↦ ∫ v in Ioi 0, F s v (a Laplace or Mellin transform), and integrability of the derivative integrand. | mathlibtactics | seed | — |
| Discharge continuity, measurability and differentiability goals with fun_prop Analytic side goals like Continuous (fun x => …), Differentiable ℝ f, Measurable f pile up and proving them by composition lemmas is tedious. | tactics | seed | — |
| Evaluate Nat.nth through Nat.count An OEIS statement defines a n = Nat.nth P n, and you need the value of a at a concrete index, or a bound on the index of a concrete element. | mathlibtactics | seed | — |
| Exclude the points where Mathlib returns a junk value A statement about zeros of riemannZeta or DirichletCharacter.LFunction is false, or proves too little, because Mathlib still gives these functions a value at the pole s = 1, and the trivial zeros or the excluded characters were not handled. | pitfallsmathlib | seed | — |
| Extend an identity from re s > 1 to a half-plane with the identity theorem You know f s = g s where a Dirichlet series converges (for example re s > 1), and both sides are holomorphic on a larger half-plane where you need the equality. | mathlibtactics | seed | — |
| Find Mathlib's Mellin, Laplace and moment-generating-function API An analytic argument needs transforms ∫₀^∞ f(t) t^{s-1} dt or ∫ e^{sX} dμ: convergence from growth bounds, holomorphy, derivatives, and explicit integrals of exponentials. | mathlib | seed | — |
| Find the Dirichlet L-function API in Mathlib (LFunction, LSeries, vonMangoldt) You need basic facts about Dirichlet L-functions (series in re s > 1, nonvanishing on re s ≥ 1, the log derivative as a von Mangoldt series, behaviour at the pole) and do not know the Mathlib names. | mathlib | seed | — |
| Find the lemma with exact?, apply? and rw? before guessing names You need a Mathlib fact (a monotonicity, a cast identity, an order lemma) and do not know its name; guessed names fail with "unknown identifier". | tacticsmathlib | seed | — |
| Generate apply lemmas for bundled maps with @[simps!] A ring hom, linear map or representation defined by a combinator ( RingHom.prod, LinearMap.pi, a subrepresentation) does not simplify when applied, and you end up writing rfl lemmas by hand. | tacticsmathlib | seed | — |
| Give each direction of an iff lemma a dot-notation name with alias Mathlib has foo_iff_bar but no Bar.foo, so every use spells out (foo_iff_bar).2 h and dot notation like h.of_at is not available. | architecturemathlib | seed | — |
| Give ℕ witnesses with / and % and let omega check them An existential over ℕ (for example a Frobenius-coin representation m = 5x + 8y) needs explicit witnesses involving truncated subtraction and division. | tactics | seed | — |
| Guess lemma names from the Mathlib naming convention Searching is slow; you want to predict a lemma name directly from the statement. | mathlib | seed | — |
| Keep one heartbeat budget and fix slow steps instead of raising it everywhere A proof hits maximum number of heartbeats, and the obvious fix is to sprinkle set_option maxHeartbeats over the file. | performance | seed | — |
| Keep the trusted statements in a file that imports only Mathlib A reviewer of a big formal proof must check that the theorem proved is the one claimed. Project definitions, notations, instances and global settings can quietly change what a statement means. | architecturepitfalls | seed | — |
| Kill an existential with a concrete n and interval_cases To refute ∀ n, … → ∃ k < n, P n k, you must show that no k works for one specific n. | tactics | seed | — |
| Let instance search compute size bounds through an outParam class You must prove many inequalities between large expressions built from a few scales (products, powers, sums, inverses). Doing each by hand with gcongr and exp arithmetic is long and brittle. | architecturetactics | seed | — |
| Let routine hypotheses be proved automatically by default arguments A lemma needs regularity hypotheses (continuity, measurability, a numeric inequality) that are routine at almost every call site, and writing them out each time clutters the proofs. | architecturetactics | seed | — |
| Lift ℕ counting facts to ℝ bounds with exact_mod_cast and nlinarith only The statement lives in ℝ (asymptotics, ≫, rpow, sqrt), but the combinatorial content is a bound in ℕ. | tacticsmathlib | seed | — |
| Manage section variables with omit … in, include … in and variable … in Lemmas in a section pick up unwanted instance arguments (for example [T2Space X]) from variable, or miss a variable that is used only in the proof. The result is extra hypotheses, or a "variable not included" error. | architecturepitfalls | seed | — |
| Mark a definition irreducible once its characterising lemmas are proved A complicated definition, for example one built from choose, an integral or an operator, keeps getting unfolded by simp, rfl checks and instance search. Goals blow up and elaboration slows down. | performancearchitecture | seed | — |
| Move between ℕ, ℤ, ℚ, ℝ with push_cast, norm_cast, exact_mod_cast, zify The statement mixes (n : ℝ) with natural-number facts, and linarith/ring fail because casts block them. | tacticspitfalls | seed | — |
| Move ℕ subtraction to ℤ or ℝ only with a ≤ proof A goal mixes ℕ subtraction (n - k, p - 1) with casts to ℤ, ZMod or ℝ, and push_cast/ring get stuck on ↑(n - k). | pitfallstactics | seed | — |
| Open every file with a header that states what it proves and what it uses In a long development, or a long submission, readers and later agents cannot tell what a file proves, which outside notions it relies on, or where a result comes from. | architecture | seed | — |
Contribute through the API (POST /api/v1/book, MCP book_propose, CLI nosorry book --propose entry.json): new entries are listed as “community, unreviewed” until a moderator verifies them. Seeded entries credit their sources; see each entry for its licence.