Skip to content
DAH

Lean 4 kernel and dependent type theory

The small trusted core of Lean: a dependent type theory with inductive types, quotients and proof irrelevance, plus the external checkers that re-verify its output.

On this page15 sections
Why other work relies on it

Every Lean proof, from Mathlib to AI-generated certificates, is accepted or rejected by this core, so the trust in all formal mathematics built on Lean reduces to trust in it.

The tiny referee inside Lean that checks every proof, whoever or whatever wrote it.

  1. 1Untrusted tools produce a proof term
  2. 2Kernel checks it against few rules
  3. 3Independent kernels re-check the export
  4. 4Only the statement must be read by humans

What a proof checker does. In a maths course a proof is a chain of steps that a reader checks by eye. A proof assistant such as Lean checks the chain with a program instead. You type definitions and theorems in a programming language, and Lean refuses anything it cannot verify.

Statements are types. Lean is built on type theory. Every object has a type, just as in Python 3 is an int and "hi" is a str. The twist is that a mathematical statement is also a type, and a proof of it is a value of that type. A proof of "for every natural number nn, n+0=nn + 0 = n" is a function: give it any n and it returns evidence that n + 0 = n. Checking the proof means checking that the value really has that type, the same job a type checker does for a program.

The kernel. Lean has two parts. The large elaborator turns what you type into a fully explicit term, using search, guesses and automation. The small kernel then checks the finished term against a short list of rules. Only the kernel has to be trusted: if the automation made a mistake, the kernel rejects the result. This is why a proof found by an AI model can be trusted exactly as much as one written by a person.

What the rules cover. A type may depend on a value: "vectors of length nn" is a type that depends on the number nn. Data such as the natural numbers are built from constructors (0 and "one more than"), and the kernel can compute with them, so 2 + 2 = 4 is checked by evaluation. Statements live in a special type called Prop, where any two proofs of the same statement count as equal. On top of the rules sit three standard axioms, one of them the axiom of choice; the command #print axioms lists the ones a theorem uses.

Checking the checker. The kernel is a program of a few thousand lines of C++, so it could have a bug. There are two defences. First, Lean can export a finished development to a plain text file that independent kernels read again: nanoda (written in Rust) and Lean4Lean (written in Lean). If they all accept, one bug is unlikely to explain it. Second, because Lean4Lean is written in Lean, theorems about its correctness can be proved in Lean, and parts of that proof exist.

The limit. A checker confirms that the proof matches the statement as written. It cannot tell you that the statement says what the author meant. And by Gödel's second incompleteness theorem the system cannot prove that its own logic is free of contradictions, so a small amount of trust always remains.

Go deeper

The full technical text.

What it is

Lean 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 theory

Lean'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:

  • 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.
  • 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-bearing

A 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 and Lean4Lean re-verify the result. Lean's 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 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 mind

The 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.

Words on this page (7)
Words on this page
kernel
The small trusted program in Lean that decides whether a proof term has the claimed type.
dependent type theory
A logic where types can depend on values, so statements and programs live in one language.
proof irrelevance
The rule that any two proofs of the same proposition are treated as equal.
inductive type
A type defined by its constructors, such as the natural numbers, with a matching recursion rule.
definitional equality
Equality that the checker can see by pure computation, with no proof needed.
axiom
A statement accepted without proof; Lean uses only three standard ones for ordinary mathematics.
Gödel's second incompleteness theorem
A strong enough system cannot prove its own consistency.
New to this? Read first (3)
New to this? Read first

Understanding map

map of the whole wiki →

What to read before Lean 4 kernel and dependent type theory (left), and what builds on it: entries that depend on it and its open problems (right). Every box links to its page.

  1. Start with
  2. Then

Open problems & questions

Progress timeline

  1. Sep 4, 2026
    A 13-million-line certificate is accepted by the kernel

    Anthropic reports a Lean proof of Fermat's Last Theorem that uses only the three standard axioms; Comparator matched its statement to Mathlib's, and the repository reports that the independent nanoda kernel accepted an export of all 1,052,234 declarations.

    source
  2. Sep 14, 2025
    Lean4Lean version 3 submitted to CPP 2026

    Version 3 of the paper (14 September 2025, submitted to CPP 2026) reports correctness proofs for parts of the kernel and one soundness bug found and fixed through the project.

    source
  3. Sep 14, 2025
    Version 3, submitted to CPP 2026
    Related to: A machine-checked proof that Lean's typechecker implements its declarative type theory

    Version 3 of the paper; the abstract still describes the kernel correctness result as covering parts of the kernel.

    source
  4. Mar 21, 2024
    Lean4Lean preprint

    Carneiro posts the first complete external Lean 4 typechecker written in Lean, about 20% to 50% slower than the C++ kernel and able to check all of Mathlib.

    source
  5. Mar 21, 2024
    Lean4Lean preprint
    Related to: A machine-checked proof that Lean's typechecker implements its declarative type theory

    An external typechecker for Lean in Lean checks all of Mathlib and verifies parts of the kernel.

    source