Lean – Architecture, Meaning and Trust

Joachim Breitner

Lean FRO

Mathematics Colloquium · Universität Freiburg · November 17, 2026

What is Lean?

/-- A prime is a number larger than 1 with only trivial divisors -/ def IsPrime (n : Nat) := 1 < n ∧ ∀ k, 1 < k → k < n → ¬ k ∣ n /-- Every number larger than 1 has a prime factor -/ theorem exists_prime_factor : ∀ n, 1 < n → ∃ k, IsPrime k ∧ k ∣ n := by intro n h1 -- Either `n` is prime... by_cases hprime : IsPrime n · grind [Nat.dvd_refl] -- ... or it has a non-trivial divisor with a prime factor · obtain ⟨k, _⟩ : ∃ k, 1 < k ∧ k < n ∧ k ∣ n := by simp_all [IsPrime] obtain ⟨p, _, _⟩ := exists_prime_factor k (by grind) grind [Nat.dvd_trans] /-- The factorial, defined recursively, with custom notation -/ def factorial : Nat → Nat | 0 => 1 | n+1 => (n + 1) * factorial n notation:10000 n "!" => factorial n /-- The factorial is always positive -/ theorem factorial_pos : ∀ n, 0 < n ! := by intro n; induction n <;> grind [factorial] /-- ... and divided by its constituent factors -/ theorem dvd_factorial : ∀ n, ∀ k ≤ n, 0 < k → k ∣ n ! := by intro n; induction n <;> grind [Nat.dvd_mul_right, Nat.dvd_mul_left_of_dvd, factorial] /-- We show that we find arbitrary large (and thus infinitely many) prime numbers, by picking an arbitrary number `n` and showing that `n! + 1` has a prime factor larger than `n` -/ theorem InfinitudeOfPrimes : ∀ n, ∃ p > n, IsPrime p := by intro n have : 1 < n ! + 1 := by grind [factorial_pos] obtain ⟨p, hp, _⟩ := exists_prime_factor (n ! + 1) this suffices ¬p ≤ n by grind intro (_ : p ≤ n) have : 1 < p := hp.1 have : p ∣ n ! := dvd_factorial n p ‹p ≤ n› (by grind) have := Nat.dvd_sub ‹p ∣ n ! + 1› ‹p ∣ n !› grind [Nat.add_sub_cancel_left, Nat.dvd_one]

Why Lean?

Correctness theorem primes : ∀ n, ∃ p > n, IsPrime p ✓ No goals Assistance exact? Try this: exact Nat.dvd_refl n Early feedback simp [factorial] unsolved goals ⊢ 0 < n ! Refactoring - def IsPrime … + def Nat.Prime … Nat.Prime Search _*(_+_) = _*_+_*_ Nat.mul_add : x*(y+z) = x*y+x*z Consistent definitions Nat.Prime Collaboration at scale 750+ Mathlib contributors 2.4M+ lines Trust bottleneck Coauthor Student AI Lean ✓

History of Lean

2026 ⋯ 2013 2015 2017 2019 2020 2021 2022 2023 2024 2025 Jul Aug Sep Oct Nov LEAN MATHEMATICS AI Lean Leonardo de Moura, MSR Lean 3, Mathlib Lean 4 Lean FRO Mathlib in Lean 4 Liquid Tensor Experiment Scholze · Commelin (Freiburg) PFR Tao et al. FLT project Buzzard AlphaProof IMO silver Aristotle IMO gold Strong PNT Math Inc FLT Anthropic · 13M+ lines Navier–Stokes OpenAI; Buckmaster–Alpöge openai/math OpenAI · 721 papers, ~42% in Lean CFSG Axiom · 43.1M lines Stacks Axiom

Scale of Lean Formalizations

Scale of Lean formalizations: total Lean lines, log scale, June 2025 to October 24, 2026

What does Lean mean?

LEAN SET THEORY Nat α → β ∀ (x : α), β x fun (x : α) ↦ t def c : α := v inductive T …

The Architecture of Lean

Lean Parser Macros Elaborator Type classes Unifier Tactics simp grind Metaprograms Language server Infoview Compiler Lake … Kernel < 10k LOC ≈ 700k LOC proof export Comparator leanchecker C++ nanoda Rust lean4lean Lean con-leche Lean · verified con-ron Rust · verified con-agua x86 · verified

Threat models

Honest attempt Malicious attempt a2 + b2 = c2 a b c a2 + b2 ≠ c2 a b c

Attacks and defenses

ATTACK DEFENSE Wrong definitions or statement Human review, Formal Conjectures Swapped statement Comparator Malicious (meta)code Sandboxes Kernel implementation bug Code review, verified implementation Kernel compiler or runtime bug Multiple kernels Lean’s type theory inconsistent Relative consistency proof Set theory inconsistent 🤷

Comparator

Challenge.lean theorem t : P := sorry Solution.lean theorem t : P := ⋯ 🧑‍🏫 🤖 SANDBOX Comparator Same statement Solution valid leanchecker nanoda lean4lean con-leche con-ron

A Lean checker is a type checker

def f : T := t theorem thm : P := p inductive I where | c : A → I All names defined Declarations acyclic Positivity …

The Lean A simple type system

Typing rules (selection)

The standard path to consistency is hard

IN THEORY IN PRACTICE AFTER lean4#14977 Weakening, substitution Transitive ≡ Acc, quotients of Prop ∀-injectivity ? open conjecture (actively worked on) Subject reduction since ≡ is not transitive Normalization propext + proof irrelevance Canonicity axioms block reduction Consistency ? not via this path -- p : Prop, h : p, q : Quot r (r a relation on p)Quot.lift f H q ≡ Quot.lift f H (Quot.mk r h) ≡ f hQuot.lift f H q ≢ f h @id α (@id β e) : α -- checks ⇝ @id α e -- does not check theorem tautext {A B : Prop} (a : A) (b : B) : A = B := propext ⟨fun _ => b, fun _ => a⟩def T : Prop := ∀ A : Prop, A → Adef δ (z : T) : T := z (T → T) id zdef ω : T := fun A a => cast (tautext id a) δdef Ω : T := δ ω -- Ω ⇝ ω (T → T) id ω ⇝ δ ω ⇝ … Eq.rec (motive := fun _ _ => Nat) 5 (propext ⟨fun _ => rfl, fun _ => trivial⟩ : True = (0 = 0)) : Nat

A direct path to consistency: syntax-driven interpretation

🤔

A direct path to consistency: syntax-driven interpretation (cont.)

Preservation, take 1

Well-denoted terms

Preservation, take 2

Preservation up to a point

The certification tax

Sorts and universes

Inductive types

inductive List (α : Type u) where | nil : List α | cons : α → List α → List α inductive Tree where | node : List Tree → Tree

The consistency theorem of con-leche

class SetTheory (V : Type u) where Mem : V → V → Prop upair : V → V → V sUnion : V → V power : V → V mem_power : ∀ {z x : V}, Mem z (power x) ↔ ∀ w, Mem w z → Mem w x image : (V → V) → V → V univChain : Nat → V -- … more laws theorem model_exists (V : Type w) [SetTheory V] (pins : List NatOpPinSet) (maxNatSize : Nat) (ds : Array Declaration) (env : Env) (accepted : checkDecls .verified pins maxNatSize ds = .ok env) : Nonempty (Model V env) theorem main_no_False (V : Type w) [SetTheory V] {file : String} {fs : FS} {b : ByteArray} (hb : fs.file file = some b) (hF : jsonWithTheoremFalse [b]) : ¬ ModelIO.CanGive (Driver.runArgs ["--", file]) fs 0

Thank You

Joachim Breitner · joachim-breitner.de

Further reading

Mathematics Colloquium · Universität Freiburg · November 17, 2026

The con-leche family of checkers

con-leche in Lean con-ron in Rust con-agua in x86 assembly WHAT RUNS Set-theoretic model assumed: ZF + ω universes Relational view inductive rules Pure checker fueled Cached checker memo tables Lean compiler & runtime incl. bignums soundness bridge refinement Lean twin Rust’s data structures Lean model of the Rust generated by Aeneas Rust code Rust compiler & runtime refinement Aeneas translation refinement L code small low-level language x86 assembly Assembler + linker, C harness verified compiler Kraken x86 semantics refinement proved in Lean trusted

Why is the point not the empty set?