Formal Verification, Explained: How Machines Check Proofs Humans Can’t Read
A proof your computer can check, line by line, even when no human can read it — and why the two biggest AI wins this week both depended on it.
1 What it is
Formal verification is the strictest way we have to check that something is correct. Instead of testing a program or a mathematical argument on a handful of examples, you write down exactly what it must do — as a precise statement called a specification — and then you prove, step by step, that it does that for every possible input. A program called a proof assistant checks every step. If one step is wrong, the check fails. If the check passes, the rule holds for every input the system can ever receive, within the stated assumptions.
The difference from testing is the difference between sampling and covering. A test runs a program on inputs someone chose and watches what comes out. A proof covers every input at once. A calculator can confirm that seven plus zero equals seven. A proof assistant can check a proof that n plus zero equals n for every natural number n — not for a list of tested values, but for all of them, forever.
The tool at the center of this week’s news is Lean, an open-source programming language and proof assistant started in 2013 by Leonardo de Moura at Microsoft Research. The current version, Lean 4, is developed by the nonprofit Lean Focused Research Organization, and its community library, Mathlib, holds thousands of definitions and already-proved theorems that new proofs can build on. Lean is not an AI system, though AI tools can write Lean. It is not a calculator, because it proves general statements. And it is not like LaTeX, which only displays mathematics — Lean checks it.
2 How it works: the specify-prove-check loop
Every formally verified result runs the same four-step loop:
1. Specify — you translate the claim into Lean’s formal language. That means choosing types, definitions, variables and assumptions explicitly enough for a checker to process them. This is the step where human judgment lives: the specification says what “correct” means, and a mistaken specification can produce a proved implementation of the wrong requirement.
2. Prove — you construct the proof. In Lean, a proposition behaves like a type, and a proof is a value that inhabits that type — the idea known as the Curry–Howard correspondence. Proofs are usually built with tactics, commands that transform the current goal, apply a rule, or invoke a theorem already proved in Mathlib. The tactic’s output is not trusted just because the tactic ran: it has to be turned into a proof term the kernel can check.
3. Check — the kernel reads the finished proof term and verifies that it is well formed and that its type is exactly the theorem statement. It checks every application, substitution, definition, and logical rule. If a premise is missing or a type does not match, the kernel rejects the declaration. As the mathematician Thomas Hales put it, “Lean proofs should never be believed until they have been checked by the kernel.”
4. Reuse — once a proof is checked, it joins the library. Later proofs can cite it the way a paper cites a theorem, and anyone can re-check it independently. That is why the two big results this week were credible within a day: the checkers did not have to trust the authors, they could run the kernel themselves.
3 Testing vs proving
Testing is how most software is checked. You run it on many inputs — the ones you thought of, the ones a fuzzer generated, the ones your users hit in production — and you watch whether the outputs are right. It is fast, cheap, and catches most bugs. But it can only ever say “correct on the inputs we tried.” The input you did not try is exactly where the next bug lives, and for safety-critical code — an operating system, a compiler, a pacemaker — “probably fine” is not good enough.
Formal verification is the opposite bargain. You pay much more up front: writing a specification and a machine-checked proof is slow, expert work, and it can take years for a large system. In exchange you get a guarantee that covers every input the specification describes. The seL4 microkernel, proved functionally correct in 2009, is the famous example: in more than fifteen years of use since the proof, no functional correctness defects have been found in the verified code. The CompCert C compiler, proved correct in the Coq proof assistant, guarantees the compiled program behaves exactly as the source program does.
4 Why everyone’s building with it now
Two stories in today’s briefing are the same story. On November 20, Anthropic mathematician Levent Alpoge posted a proof of the Riemann hypothesis — the 167-year-old puzzle about prime numbers — built with Claude over six weeks and formalized in about 17 million lines of Lean code. By the next day, the Lean and Mathlib teams said they had full confidence it was correct. Not because they had read it. No human has read 17 million lines. Because they ran the kernel, and the kernel said yes.
Three days later, Google DeepMind and Google Quantum AI reported that teams of Gemini 4 agents had designed faster quantum algorithms — cutting the cost of simulating fusion by 11.8 times — with every result proved correct in Lean. The circuits act on thousands of logical qubits, far beyond what any classical computer can simulate and no quantum computer can yet run. The Lean proof is the only thing that has ever tested them. The team built a quantum programming library on Mathlib, with a formal logic for proving what a quantum program does, and the agents used Lean’s error messages to revise their work until the kernel accepted it.
The pattern is new, and it is why verification is having a moment. AI can now write proofs at a scale no human team could — millions of lines, in weeks — and the kernel is the part that makes that scale trustworthy. The human writes the specification, the machine writes the proof, and the tiny checker in the middle decides whether it counts. That division of labor is also spreading beyond mathematics: Amazon’s AWS teams use Lean to verify production systems, and the same idea is moving into compilers, cryptography, and chip design.
5 The honest part
First, a proof checks the formal statement, not what you meant. The kernel confirms that the proof follows from the definitions and assumptions you wrote down. It cannot confirm that those definitions say what you think they say. In the Riemann case, the check that mattered most was not the kernel accepting the proof — it was independent mathematicians confirming that the theorem in the code is actually the Riemann hypothesis as mathematics defines it. A proof of the wrong statement is still a proof.
Second, nobody understands these proofs, including their authors. Alpoge has said he does not yet understand all of the mathematics in his own proof and is trying to digest it alongside everyone else. That is strange and new: a proof that is verified but not understood. The honest summary is that machine checking answers “is every step valid?” and leaves “why is it true?” to humans, who may need years to catch up.
Third, verification is still slow and expensive. Writing a specification and a machine-checked proof takes expert time that most projects cannot afford, which is why it is used for operating-system kernels and compilers and not for your to-do app. AI is changing the cost of writing proofs, but not the cost of writing good specifications — and a bad specification, proved perfectly, is still a bad specification. Formal verification is the strongest assurance we have. It is not a substitute for deciding what is worth assuring.
Key terms
- Formal verification Mathematically proving that a program or argument meets a written specification for every possible input, with a computer checking every step of the proof.
- Proof assistant Software that lets you state a claim in a precise formal language, construct a proof, and have a small trusted checker verify it. Lean, Coq and Isabelle are the best known.
- Kernel The tiny core of a proof assistant that checks the finished proof, step by step. It is the one part that has to be trusted — everything else is verified by it.
- Specification The precise written statement of what a program or theorem must do. A proof shows the code matches the specification; it cannot show the specification is what you actually wanted.
- Tactic A command in a proof assistant that transforms the current goal — applying a rule, splitting it into smaller obligations, or invoking a theorem already proved.
- Mathlib Lean’s community library of mathematical definitions and already-proved theorems, written and reviewed by hundreds of contributors, that new proofs build on.
This lesson comes from today’s Daily Tech Briefing (Episode 43, November 24, 2026): Huang’s back, Nvidia’s 31.5% surge & the Riemann proof. Read the full briefing: Huang Is Back — Daily Tech Briefing.
Effortless Math, “Lean Theorem Prover: Lean 4 and Mathlib Explained” — Lean’s history, the kernel, tactics, Mathlib, and the 2026 headline proofs; Medium, “Lean: When Mathematical Proofs Become Executable” — propositions as types, the Curry–Howard correspondence, and what the kernel does and does not check; arXiv, “From Pen-and-Paper to Machine-Checked Proofs: Lean for System Identification” — the kernel as a small trusted checker, and the 2026 AI-written proofs; Primitive, “Machine-checked proofs: what they establish and what they don’t” — seL4’s 2009 proof and fifteen years without a correctness defect, CompCert, and the specification-can-be-wrong limit; EternaX, “What Is Formal Verification?” — the four-step workflow and Thomas Hales’s line on trusting only kernel-checked proofs; Science News, “Math’s holy grail, the Riemann hypothesis, appears solved with AI’s help” (November 2026) — the Alpoge proof, the 17 million lines of Lean, and the independent verification; Google DeepMind, “Finding faster quantum algorithms with agents and formal verification” (November 23, 2026) — the 11.8× fusion gain, the Lean library, and proofs as the only test for un-runnable circuits.