Skip to content
DARC
■ Change #41 · wiki.edited

Lean 4 & Mathlib: Normalize Markdown to canonical form

by DARC wiki2026-10-22 20:31:01 UTCOpen the page →
body
## What it is
**Lean 4** is a dependently-typed functional language and interactive theorem prover. **Mathlib** is a single, unified, community-maintained library covering algebra, analysis, topology, number theory and more.
## Why it is foundational
− A machine-checked proof removes a whole class of doubt. Because Mathlib is *one* coherent library, new results can reuse everything beneath them, which makes it a shared substrate rather than a collection of isolated proofs.
+ A machine-checked proof removes a whole class of doubt. Because Mathlib is _one_ coherent library, new results can reuse everything beneath them, which makes it a shared substrate rather than a collection of isolated proofs.
## What to understand first
- Tactics vs. term-mode proofs
- Typeclass hierarchy (how `Ring`, `Field`, `NormedSpace` relate)
− - Why naming conventions are strict: discoverability *is* the library
+ - Why naming conventions are strict: discoverability _is_ the library
explainer.student
− **Lean 4** is both a functional programming language and an *interactive theorem prover*. In Lean, a theorem is a type, and a proof is a program of that type. This is the *propositions-as-types* idea: the statement 'for every natural number $n$, $n + 0 = n$' is a type, and any term that inhabits it is a proof. The Lean *kernel* is a small piece of trusted code that type-checks every term. If the kernel accepts it, the theorem is established, however clever or messy the proof-writing process was.
+ **Lean 4** is both a functional programming language and an _interactive theorem prover_. In Lean, a theorem is a type, and a proof is a program of that type. This is the _propositions-as-types_ idea: the statement 'for every natural number $n$, $n + 0 = n$' is a type, and any term that inhabits it is a proof. The Lean _kernel_ is a small piece of trusted code that type-checks every term. If the kernel accepts it, the theorem is established, however clever or messy the proof-writing process was.
− You rarely write proof terms by hand. Instead you use **tactics**: short commands such as `intro`, `rw` (rewrite using an equation), `simp` (simplify), `linarith` (solve linear inequalities) and `ring` (prove polynomial identities). Tactics build the underlying term for you, and the kernel checks the result. The alternative is *term mode*, where you write the term directly. Tactics are usually faster for people; term mode is more compact when it works.
+ You rarely write proof terms by hand. Instead you use **tactics**: short commands such as `intro`, `rw` (rewrite using an equation), `simp` (simplify), `linarith` (solve linear inequalities) and `ring` (prove polynomial identities). Tactics build the underlying term for you, and the kernel checks the result. The alternative is _term mode_, where you write the term directly. Tactics are usually faster for people; term mode is more compact when it works.
− **Mathlib** is the community library on top of Lean. Its main design choice is that it is *one* library with one set of definitions. A group, a ring or a metric space is defined once, and everything else reuses it. This works because of the **typeclass** system: a statement such as 'in any `Field`, every nonzero element has an inverse' is proved once, and Lean automatically finds it whenever you work in a field such as the real numbers. The hierarchy (`Ring`, `Field`, `NormedSpace`, ...) is organised so that more specialised structures inherit the results of more general ones.
+ **Mathlib** is the community library on top of Lean. Its main design choice is that it is _one_ library with one set of definitions. A group, a ring or a metric space is defined once, and everything else reuses it. This works because of the **typeclass** system: a statement such as 'in any `Field`, every nonzero element has an inverse' is proved once, and Lean automatically finds it whenever you work in a field such as the real numbers. The hierarchy (`Ring`, `Field`, `NormedSpace`, ...) is organised so that more specialised structures inherit the results of more general ones.
− Because the library must stay coherent, naming is strict. Lemma names follow conventions (for example, a name describes the shape of the statement), so that people and tools can *guess* what a lemma is called. In a library with hundreds of thousands of facts, discoverability is the difference between a usable library and a pile.
+ Because the library must stay coherent, naming is strict. Lemma names follow conventions (for example, a name describes the shape of the statement), so that people and tools can _guess_ what a lemma is called. In a library with hundreds of thousands of facts, discoverability is the difference between a usable library and a pile.
Formalization is not free. A paper proof that takes five lines may take hundreds in Lean, because every 'clearly' has to be spelled out. Some areas are well covered; others lack basic definitions. Large projects (for example formalizing the proof of Fermat's Last Theorem) are partly about adding missing infrastructure to Mathlib.
− What Lean does *not* check is whether your formal statement says what you meant. If you define a concept slightly wrongly, you can prove a true but irrelevant theorem. Careful definitions, and reading the formal statement by a human, remain essential.
+ What Lean does _not_ check is whether your formal statement says what you meant. If you define a concept slightly wrongly, you can prove a true but irrelevant theorem. Careful definitions, and reading the formal statement by a human, remain essential.
hash 75ce41960e58cb00cc6aa6f2cfbaeacf6a092e31949f131c806ff430159557fe
previous 22a3fdc7a4dddb7ef579fcceb1dd91b2d8da73138c792d321d57c923a6f10b78