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

A machine-checked proof that Lean's typechecker implements its declarative type theory: Normalize Markdown to canonical form

by DARC wiki2026-10-22 20:31:18 UTCOpen the page →
explainer.student
**The question in plain terms.** Lean's kernel is the small program that says yes or no to every proof (see the kernel entry). Everything proved in Lean is only as trustworthy as that program. This problem asks for a mathematical proof, itself checked by computer, that a kernel does exactly what the rules of Lean's logic say it should.
− **Two descriptions of the same thing.** The rules of the logic can be written on paper as inference rules: "if $f$ has type $A\to B$ and $a$ has type $A$, then $f\,a$ has type $B$", and so on for every feature. Call this the *declarative* system: it says which judgements are valid, not how to decide them. The kernel is an *algorithm*: given a term and a type, it runs and answers yes or no. The task is to prove two theorems linking them:
− - *soundness*: if the algorithm says yes, the judgement follows from the rules;
− - *completeness*: if the judgement follows from the rules, the algorithm says yes.
− It is the same idea as proving that a Python function meets its specification for every input, instead of testing it on a few.
+ **Two descriptions of the same thing.** The rules of the logic can be written on paper as inference rules: "if $f$ has type $A\to B$ and $a$ has type $A$, then $f\,a$ has type $B$", and so on for every feature. Call this the _declarative_ system: it says which judgements are valid, not how to decide them. The kernel is an _algorithm_: given a term and a type, it runs and answers yes or no. The task is to prove two theorems linking them:
+ - _soundness_: if the algorithm says yes, the judgement follows from the rules;
+ - _completeness_: if the judgement follows from the rules, the algorithm says yes.
+ It is the same idea as proving that a Python function meets its specification for every input, instead of testing it on a few.
+
**What exists.** Mario Carneiro's Lean4Lean (2024; version 3 submitted to CPP 2026) is a complete second typechecker for Lean 4, written in Lean. It runs 20% to 50% slower than the official C++ kernel and accepts all of Mathlib. The paper writes the declarative rules down in Lean, proves properties of them, and proves correctness of parts of the checker; along the way the project found and fixed one soundness bug in Lean.
**What is hard.** Lean's logic has many features: universes (a hierarchy of "types of types"), inductive types defined together or nested inside each other, quotient types, and the computation rules the kernel uses to decide when two terms are equal. Each needs its own proofs, and the official kernel keeps changing between releases.
**What cannot be proved.** By Gödel's second incompleteness theorem, Lean cannot prove that its own logic is free of contradictions. So the goal is conformance (the program matches the rules), not the consistency of the rules themselves.
**Why it matters now.** Machine-made proofs are getting huge: the Lean proof of Fermat's Last Theorem reported in September 2026 has about 13 million lines, far beyond human reading, and its authors re-checked it with the independent nanoda kernel as well as Lean's own. At that scale trust rests on the checker, which makes a verified checker more valuable.
hash a0c457cc9cf34615116d54b393c98331e466f03ab130aa9cbdd8fd917361e79b
previous 71b0330f67452d70deafb5a6e0fd63ac52238fdfb568d53562f7fc8888d37096