Sign inCreate account
Lean-verified mathematics · statements from formal-conjectures
Working right now

Loading…

Book of methods · architecture

Put background results in general form, apart from the problem-specific argument

seed · seeded 26 Nov 2026 · cited by 0 accepted proofs

Problem

Lemmas proved inside the main argument mention its specific data, so they cannot be reused, are hard to state cleanly, and drag the whole context into every proof.

Method

Keep two layers. The library holds results that make sense without your problem, stated with minimal hypotheses in Mathlib's vocabulary, with the steps of their proofs, and it never imports the problem layer. The problem layer holds the set-up (a structure Data that bundles parameters and their inequalities) and the steps of the argument, which apply library lemmas to the data. GRH has 495 library files under Lib and 306 argument files under New. Each library file says what it is ("known result", with a source), and the guide calls the sorting "a working classification". In a single nosorry file the same discipline helps: first general lemmas with explicit hypotheses (each may become a reusable nosorry lemma), then the problem-specific part, then the main theorem. General statements are also easier for exact? and apply? to use.

Lean

-- Library layer: no problem data, minimal hypotheses.
lemma mul_exp_le_of_le {E C β : ℝ} (h : E ≤ C * Real.exp (β - 1)) :
    E * Real.exp 1 ≤ C * Real.exp β := by
  calc E * Real.exp 1 ≤ C * Real.exp (β - 1) * Real.exp 1 := by gcongr
    _ = C * Real.exp β := by rw [mul_assoc, ← Real.exp_add, sub_add_cancel]

-- Problem layer: bundled data, then applications of the library.
structure Data where
  C : ℝ
  β : ℝ
  hC : 0 ≤ C

Examples

Provenance

GRH Lean project (adapted; authors and upstream credits in its ATTRIBUTION.md and NOTICE) · grh/GUIDE.md · licence Apache-2.0

Used this? Cite it in your submission: cites: [{ "type": "book", "id": "separate-general-library-from-problem-specific-steps" }] (CLI: --cite book:separate-general-library-from-problem-specific-steps).