Lecture 3. How does a computer check a proof? Building a minimal kernel

3. Lecture 3. How does a computer check a proof? Building a minimal kernel#

Date and room: see Harmonogram (in Polish).

Lecture materials

  • Slides (reveal.js) — the S key opens the speaker notes, Esc the slide overview. Slides marked “🤿 deep dive” only announce a topic and point to the section Deep dives.

  • The kernel’s code — four files: kernel.py (the kernel), syntax.py (reading and printing terms and proofs), tactics.py (tactics and a small solver), boolean.py (the axioms and the first theorems). The Python 3.10+ standard library is all you need. The notebooks of this chapter import these files; to run a notebook on your computer, save them in the same folder as the notebook.

  • Boole Lab — a proof lab in the browser, modelled on Peano Lab: the same kernel, tactics written as in Lean, a library of theorems with full proofs (from idempotence to associativity, De Morgan’s laws and the Robbins equation), suggestions for the next step and export to Lean.

  • Boolean circuits — an applet for section 3.6: Sh1 as a circuit of six NAND gates, Veroff’s model M1, swapping the order of tests in a decision tree, a cycle of implications.

  • The kernel’s soundness proof in Lean — the theorem of the fourth section, checked by Lean’s kernel.

  • Lecture 1, §1.4 — a formal proof seen from the user’s side: Gauss’s formula in Peano Lab and in Lean.

What this lecture is about

On November 20, 2026 Levent Alpöge announced a proof of the Riemann hypothesis, written with the help of the artificial intelligence system Claude. The proof is not a paper: it is an archive of 175,187 files in the language of the Lean proof assistant, which no human will read in full. Two independently written checking programs accepted every step of it, but mathematicians have not refereed it yet. Hence the guiding question of the lecture: what exactly does a computer do when it “checks a proof”, and why can we trust it?

Instead of describing Lean from the outside, we build our own very small checking program, a kernel, for the simplest logic in which real mathematics can be done: equational logic. The theory is Boolean algebra with Huntington’s eight axioms, and proofs are chains of equalities, just as on paper. We break such a proof down into atoms, write a kernel that checks these atoms and tactics that build proofs for us. At the end we ask why the kernel can be trusted and compare searching for a proof with checking it: from the Robbins problem, solved in 1996 by the program EQP, to the proof of the Riemann hypothesis.

Quantifiers, functions and bound variables — everything that makes Lean’s kernel much larger than ours — we leave out on purpose. We return to them among the deep dives, in §3.5.

Outline

  1. Theorem, axioms, and five rules — what the computer checked in the proof of the Riemann hypothesis; Boolean algebra as an equational theory and its models; the proof of \(x + x = x\) on paper and one step broken down into atoms; the five rules of equational logic and their names in Lean; a proof as a tree.

  2. A minimal kernel — terms and substitution; the function that reads off the proved equation from a proof tree; the environment of axioms and theorems; proofs the kernel rejects; the analogue of the #print axioms command; the size of the kernel.

  3. Tactics: from pattern to proof — pattern matching, the tactics rw and calc; six theorems from beginning to end; a library of theorems; a tactic that cheats, and why the kernel catches it.

  4. Why we trust the kernel — the semantics of equations in algebras; the soundness theorem of the kernel with a full proof (three lemmas, induction on the tree, the environment invariant) and the reliability of the assumption list; two holes in the first version of the kernel that this proof exposed; the soundness proof checked by Lean; tests in models; what the kernel does not guarantee; search versus checking: a small solver, the Robbins problem and the program EQP, the proof of the Riemann hypothesis.

  5. Deep dives — the topics announced on the 🤿 slides: the Robbins problem in detail (Huntington’s axioms of 1933, Winker’s conditions, the EQP proof, small Robbins algebras counted by computer); de Bruijn indices; completeness and truth tables; associativity from Huntington’s axioms; real kernels.

  6. Other axioms, the median and Boolean derivatives — beyond the lecture, for the parts of the Boole Lab library added after it: a single axiom (DN1, Sh1) and finite models (Veroff’s model M1); median algebra; Boolean algebra as a ring; Boolean derivatives and the product rule; decision diagrams; cycles of implications; other axioms in the Boole Lab.

After this lecture you will be able to

  • point out, in a proof “on paper”, the axiom, the substitution and the context of every step, and write the step with the five rules of equational logic;

  • read the code of a small kernel, explain what each of its rules checks and justify why the kernel searches for nothing;

  • distinguish the kernel (small and trusted) from tactics and solvers (large and untrusted) and explain why an error in a tactic does not lead to a false theorem;

  • prove the soundness theorem of the kernel by induction on the proof tree, point out which checks in the code the proof relies on, and test the kernel in models;

  • explain what a machine check does not guarantee: the meaning of the statement, the truth of the axioms and the correctness of the program itself;

  • tell how the Robbins problem was solved and how the announced proof of the Riemann hypothesis was checked by machine.

How to work with this chapter

Every section is a Jupyter notebook, and all results come from executing the code when the book is built. The code of the kernel, the tactics and the axioms is in four files (link under “Lecture materials”). The notebooks show the most important parts of this code with the function inspect.getsource, so what you read is exactly the code that runs. Python 3.10 or newer is enough, with no additional libraries. Every section ends with exercises; the marks ★, ★★ and ★★★ mean the same as in the lab problem sets.