In-depth articles on technology shaping what comes next.

Verifying Riemann in Lean: Lessons for Engineers

A 17-million-line Lean proof of the Riemann Hypothesis passed multiple independent checkers. Here's what proof assistants teach working engineers.

A cathedral built from interlocking glowing geometric blocks, evoking a massive machine-checked proof.
A proof too large to read can still be a structure you can inspect — if you check the joints, not the whole wall.

The most audacious piece of software engineering shipped lately isn't a framework, a database, or an AI agent. It's a proof. Levent Alpöge released a Lean verification of the Riemann Hypothesis as a library of roughly seventeen million lines of code — and within about a day, a distributed crew of volunteers had compiled it, matched its final theorem against the canonical statement in Mathlib, and re-checked the exported proof with several independent kernels, two of which carry machine-checked arguments that they cannot accept a false proof.

Here's my contrarian claim, and I'll defend it and then walk parts of it back: this is the most important event in programming languages this decade, and it has almost nothing to do with number theory. The Riemann Hypothesis is nearly beside the point. What matters is that we now have a worked example, at genuine research scale, of a problem software engineers keep circling without ever committing to: how do you build an artifact so large that no human being can review it, yet so rigorously checked that strangers are willing to stake their professional reputation on it?

What Seventeen Million Lines of Lean Verification Actually Mean

Lean is built around an idea Nicolaas de Bruijn worked out in the late 1960s with Automath, one of the first systems for encoding mathematics in a machine-checkable form. The idea is now called the de Bruijn criterion: a proof assistant should produce proof objects that a small, independent checking program can verify on its own. The big, clever part of the system — the elaborator, the tactic engine, the automation that turns human-flavoured proof scripts into formal objects — is explicitly not trusted. It's a compiler, and like every compiler it's allowed to be buggy. Trust lives in the kernel, a small program that type-checks fully elaborated proof terms against the rules of the logic.

That architecture is exactly what makes a seventeen-million-line artifact meaningful. Nobody read that proof. Nobody could. It's on the order of a major operating system component, and it's mostly machine-generated and machine-shaped. But the verification workflow treats it the way a good build system treats a compiled binary: dozens of people compiled the library independently and reproduced the same raw proof export file, byte for byte. That's a hermetic, deterministic build producing a content-addressable artifact, and then the interesting part begins — because the artifact, not the source, is what the checkers consume.

A proof you cannot read can still be a proof you can trust. That inversion of ordinary code review is the entire story.

Software people should sit with that inversion for a moment. Our standard assurance mechanism is a human pulling up a diff and frowning at it. That scales to maybe a few thousand lines per reviewer per week before the frowning becomes theatre. The Lean community's answer is to move trust down the stack: trust a small kernel, trust the diversity of independent re-implementations of that kernel, and treat everything above — however many millions of lines — as data to be checked rather than prose to be reviewed. That's not a math trick. It's an engineering stance.

The Statement Problem: Proving the Right Theorem

The first thing the community checked wasn't the proof. It was the statement. This is the part that outsiders consistently underrate, and it's where formalization projects quietly die. A proof assistant will happily let you prove the wrong thing with total rigor — the logic doesn't care what you meant. The classic toy example is a verified sorting routine whose specification says the output is ordered but forgets to say it's a permutation of the input. The empty list is beautifully sorted. The proof goes through. The function is garbage.

So the certificate for this work rests on a fact that's easy to skim past: the statement RiemannHypothesis already lived in Mathlib, where it had been scrutinized by people who actually know both analytic number theory and Lean's encoding conventions — where the zeros are allowed to be, how the trivial zeros are excluded, what the function is even defined on. Then the community added a file isolating exactly that statement, importing nothing but Mathlib, and used two independent tools (comparator and con-leche --compare) to confirm that the theorem Alpöge's library proves is exactly that statement — not a near miss, not a definitional lookalike with a relaxed hypothesis quietly dropped. I've argued before that the specification-implementation gap is where bugs live, and formal mathematics is where that truth stops being a blog post and starts being a checklist item with dedicated tooling.

Notice how unusual this discipline is by industry standards. When did you last see a team build a dedicated tool whose only job is to prove that the thing their system does is the thing the contract says? We write tests that sample the contract. We write type signatures that gesture at it. The Lean community built comparators that identify it. If you take one practice home from this whole affair, take that one: before you celebrate that the machine checked your proof, check that the machine is checking your claim.

Two near-identical brass keys under a magnifying glass, one fitting a keyhole and one subtly mismatched.
A proof of a nearly-right statement is like a key that differs by one tooth: impressive, and useless.

Kernel Trust and the Checker Ecosystem

Lean's official kernel is small, but 'small' isn't a security argument on its own — it's an invitation to re-implement. The verification leaned on that invitation hard. The exported proof was checked not just by Lean's kernel but by con-leche and con-ron, plus several third-party checkers written in different programming languages, all consuming the same inert export file. That word inert matters: the checkers never execute code from the proof sources, so a hypothetical malicious snippet hiding in seventeen million lines has no runtime in which to act. It's the difference between reviewing a document and executing an attachment.

The two heavy hitters deserve special mention, because con-leche and con-ron each come with a formal proof — relative to set theory — that they cannot accept a false proof. This closes the usual regress: yes, Lean's kernel could theoretically have a soundness bug, so check with another kernel; yes, that kernel could have one too; but when the checker's correctness argument is itself machine-checked against a different foundation, the attack surface collapses to 'a bug that survives across multiple implementations, multiple languages, and multiple foundational systems simultaneously'. Not impossible. Not something you plan around. I've written about how even Rust's borrow checker shipped a soundness hole, so I don't say 'trust the kernel' lightly. The answer was never one trusted component. It's a diverse population of checkers and a shared, portable proof format — N-version programming, which avionics has practiced for decades, finally applied to truth itself.

import Mathlib
-- The statement, maintained and vetted in Mathlib, that the
-- new library proves. Anybody can inspect what the words mean.
#check RiemannHypothesis
-- A trivial kernel-checked proof. The kernel reduces 2 + 2 to 4
-- and accepts rfl; no tactic code runs at check time.
theorem two_add_two : 2 + 2 = 4 := rfl
-- Ask the kernel what this proof's trust base actually is:
#print axioms two_add_two
-- reports that the proof depends on no axioms at all
-- Had someone snuck in `sorry` (Lean's escape hatch) or a custom
-- axiom, this is where it shows up: as `sorryAx` or worse, in
-- the dependency list of the final theorem.

That last mechanism is the audit trail most systems lack. #print axioms asks the kernel, after the fact, what assumptions a proof actually rests on. Every cheat in Lean — sorry, a user-declared axiom, a misused unsafe — leaves a fingerprint in that list. Imagine if your build could answer 'what did you assume?' with the same precision: this service assumes the clock is monotonic, this one assumes TLS 1.3, this one assumes the queue delivers at least once. Most of our systems carry exactly these assumptions. Almost none of them can enumerate them on request.

Mathlib-Scale Dependency Management

One line in the community's statement is pure dependency-management poetry: the codebase depends directly only on Mathlib. No vendored forks, no private branches of the standard library, no patches held out of tree. Seventeen million lines of research mathematics sit on a single, shared, continuously integrated upstream. That only works because Mathlib operates less like a package repository and more like a standards body with CI — aggressive review, a shared cache so contributors don't rebuild the universe on every pull, and a culture where upstreaming your definitions is the default rather than a favor you do the community.

And that ordering — statement first, proof second — is the part engineering teams get backwards. The definition of the Riemann Hypothesis was merged, reviewed, and hardened in the shared library before the proof arrived. When the seventeen-million-line payload landed, there was no argument about what it claimed; the claim was already infrastructure. Compare with how most large codebases absorb a huge contribution: the interfaces are defined by the contribution itself, review happens under time pressure, and by the time anyone notices the contract drifted, three other teams depend on the drifted version. Mathlib's discipline — canonize the vocabulary in public, then let work build on it — is exactly what a healthy platform team does with its internal APIs. The difference is they actually do it.

Robotic arms moving identical wax-sealed crates along conveyor belts in a vast automated warehouse.
One shared upstream, every consumer rebuilding the identical artifact — dependency management as a public utility.

Where the Contrarian Claim Breaks Down

Now the walkback, because the claim deserves honest stress-testing. The independent checkers are not as independent as the rhetoric suggests. They share a metatheory, several share design lineage, and checker authors talk to each other; diversity of programming language is not diversity of logic. There's precedent for slippage, too: a fabricated refutation of the Collatz conjecture once made it past one of these independent checkers before anyone caught it. The honest formulation of the confidence argument is the one a careful observer offered: for the proof to be wrong, a single bug would have to affect both the checkers' internal consistency proofs and this particular proof, across every implementation. Vanishingly small. But 'vanishingly small' is a probability, and the community's statement says 'full confidence', which is a sociology.

There's also a human load-bearing wall that the four published criteria don't mention. By all accounts this proof was produced with heavy AI assistance, with Alpöge steering — decomposing the problem, recognizing dead ends, knowing which lemmas smelled wrong. That human expertise is doing real epistemic work, and the certificate as written doesn't rest on it at all, which bothers me. I've covered the split between LLM conjecture generation and mechanical proof-checking before, and this is that split at maximum stakes: the machine proposed at unprecedented scale, the machine checked at unprecedented scale, and a rare human sat at the junction making the whole thing legible. Removing that human from the official story makes the story cleaner and less true.

Engineering Lessons for Machine-Checked Software

  • Keep the trusted computing base tiny and boring. Every line of code you must trust is a liability; every line you merely check is data.
  • Export to an inert, portable format. Verification should run on a document, not on a live process that can execute surprises.
  • Verify the claim, not just the argument. Build the comparator. Prove your artifact matches the contract before you celebrate the proof.
  • Diversify your checkers for real. Different languages help; different foundations help more; one checker with a consistency proof is worth two that copy each other's homework.
  • Make builds reproducible and artifacts content-addressable. 'Dozens of people reproduced the same export file' is a sentence any release pipeline should aspire to.
  • Canonize shared vocabulary upstream before the big contribution lands. Definitions first, heroics second.
  • Enumerate your assumptions mechanically. If your system can't answer 'what do you depend on?' you don't know what you shipped.

Underneath the list is one idea: tests sample a space, proofs exhaust it, and the interesting middle ground — property-based testing, model checking, symbolic execution — is the industry slowly, reluctantly crawling from the first camp toward the second. Nobody is asking you to formalize your CRUD app. But the boundary of what 'must be machine-checked' keeps moving: cryptographic primitives, consensus protocols, smart contracts, flight software, kernel eBPF verifiers. Each of those communities has had its 'we should really be doing this the Lean way' moment, usually right after an expensive incident. The Riemann verification is a demonstration that the tooling, the culture, and the checker ecosystem can hold the weight of something genuinely enormous. The excuse cupboard is bare.

A Hundred Years of Trying

As a languages person, I can't help seeing this as the payoff of a very old bet. Hilbert put the Riemann Hypothesis on his list in 1900. De Bruijn started Automath in 1967. Robin Milner built ML in the 1970s specifically as a metalanguage for writing proof tactics — the entire ML family tree, which runs through OCaml and Haskell and into Rust's type system, descends from tooling for machine-checked proof. The QED manifesto in the 1990s asked why all of mathematics wasn't formalized yet and mostly got shrugs. Then the Four Colour Theorem went into Coq, then the Feit–Thompson theorem, then the Liquid Tensor Experiment proved that modern research mathematics — not just classics — could survive contact with a kernel. Each of those was called a stunt by somebody. Each one trained the community and hardened the library that the next one stood on.

So: is my opening claim right? Partly. The mathematicians got a theorem, and by morning they were already asking the better question — what does the proof teach, which is a thing seventeen million checked lines do not automatically do. The engineers got something rarer: a blueprint, validated under maximum scrutiny, for constructing artifacts too large for any human to read and staking a community's name on them anyway. The next time someone in a design review tells you that real verification doesn't scale, you'll know exactly which build log to point them at.