■ Change #251 · wiki.edited
Lean 4 kernel and dependent type theory: Normalize Markdown to canonical form
body
## What it isLean separates a large, untrusted **elaborator** (parsing, unification, tactics, automation) from a small **kernel**. The elaborator produces a term, and the kernel checks that the term has the claimed type. If the kernel accepts it, the theorem counts, however the term was found. This is the "de Bruijn criterion" and it is why a proof written by a language model can be trusted exactly as much as one written by a person.## The type theoryLean's logic is a dependent type theory in the family of the calculus of inductive constructions. The pieces that matter in practice, as laid out in the [Lean reference manual](https://lean-lang.org/doc/reference/latest/The-Type-System/):- **Terms and types are the same kind of thing.** Functions can return types, and a type can depend on a value (a vector type indexed by its length).− - **Universes.** Types live in a hierarchy `Sort u`. `Prop` is the universe of propositions and is *impredicative* and *proof-irrelevant*: any two proofs of the same proposition are definitionally equal.+ - **Universes.** Types live in a hierarchy `Sort u`. `Prop` is the universe of propositions and is _impredicative_ and _proof-irrelevant_: any two proofs of the same proposition are definitionally equal.- **Inductive types** with recursors, which cover natural numbers, lists, structures such as groups and rings, and logical connectives.- **Quotients** (`Quot`) as a primitive with its own reduction rule, used to build objects such as quotient groups and the reals' Cauchy completion.- **Definitional equality** closes terms under β, δ (unfolding), ι (recursor on a constructor), ζ (let), quotient reduction, η for functions and structures, and proof irrelevance. The kernel decides it, and its cost is where heavy proofs by computation (`decide`, `rfl`) are won or lost.- **Three standard axioms** sit on top: `propext`, `Quot.sound` and `Classical.choice`. Checking a theorem with `#print axioms` shows which of them it uses.## Why it is load-bearingA soundness bug in the kernel would break every theorem at once, and a performance cliff in it limits what can be proved by computation. Two lines of work follow from that.1. **Independent re-checking.** Lean can export a development in a plain text format (`lean4export`) that other programs read. Independent kernels such as [nanoda](https://github.com/ammkrn/nanoda_lib) and [Lean4Lean](https://github.com/digama0/lean4lean) re-verify the result. Lean's [Comparator](https://github.com/leanprover/comparator) tool combines this with a sandbox and an axiom whitelist to answer one question: does this solution file really prove the statement in that challenge file?2. **Verifying the checker itself.** Carneiro's [Lean4Lean](https://arxiv.org/abs/2403.14064) is a second typechecker written in Lean. It checks all of Mathlib and has a partial machine-checked correctness proof, which has already uncovered one soundness bug.## Limits to keep in mindThe kernel guarantees that a term has a type, not that the type says what the author meant. Misformalized statements are the main residual risk, which is why statement-comparison tools and curated statement corpora exist (see the Formal Conjectures entry). Beyond that, the guarantee rests on the kernel implementation being correct and on the type theory being consistent, neither of which is itself proved inside Lean.
hash 21aac412cd9191274287208c38c75878ff94c117eca7ba2c7c715539b2d29500
previous 011916f19da6273c76b46db2efc7737698936c20036c8a70f501af092e920e85