Komputerowe rozwiązywanie problemów matematycznych · lecture

Lecture 3:
How does a computer
check a proof?

the Riemann hypothesis in Lean · Boolean algebra · five rules · a minimal kernel · tactics · the Robbins problem

kernel: checkingtactics: building and searching

Dr. Bartosz Naskręcki · Wydział Matematyki i Informatyki UAM · 06-S1MA03-P16780
winter semester 2026/27 · course taught in Polish — dates and rooms: Harmonogram (in Polish)

Lecture outline

I
A proof no one will read
the Riemann hypothesis in Lean · what exactly the computer checked
7 min
II
The theory and the five rules
Boolean algebra · a proof on paper · one step broken down into atoms · a proof is a tree
14 min
III
A minimal kernel
terms · the function conclusion · the environment · the kernel says “no”
15 min
IV
Tactics
pattern matching · rw · calc · proofs from beginning to end · a cheating tactic · Lean · Boole Lab
17 min
V
Why do we trust the kernel?
semantics · the soundness theorem with its proof · two holes · tests · what the kernel does not guarantee
18 min
VI
Search versus checking
our small solver · the Robbins problem · EQP (1996)
10 min
✓
Summary
what to remember, where to read more
3 min
checking: kernel, proof
building a proof: tactics, solver
🤿 deep dive: only announced in the lecture
Lecture 3 · outline
Part I

A proof
no one will read

the Riemann hypothesis in Lean · November 2026

November 20, 2026: the Riemann hypothesis in Lean

  • Levent Alpöge announces a proof of the Riemann hypothesis and of its analogue for Dirichlet $L$-functions, written with the help of the Claude model.
  • The proof is not a paper but a Lean archive (plus a four-page note).
  • No one will read it in full. So who checked that it is correct?
  • November 25: a condensed version of the same theorems — 112,827 lines of Lean.
Status at the end of November: the proof has been announced and checked by machine; mathematicians have not refereed it yet.
The archive of November 20
175,187Lean files
17,374,215lines
1,484,733declarations accepted by the independent kernel NanoDA (Rust)
61.6 GBfile with the proof exported for NanoDA
3axioms: propext, Classical.choice, Quot.sound

Sources: the note alpo.ge/remark.pdf · status of the checks and links to the logs: nasqret.github.io/riemann-rev · A. Sutherland’s logs: math.mit.edu/~drew/grh

Lecture 3 · Part I — A proof no one will read Open in the book →

What exactly did the computer check?

The statement — in the Mathlib library


def RiemannHypothesis : Prop :=
  ∀ (s : ℂ) (_ : riemannZeta s = 0)
    (_ : ¬∃ n : ℕ, s = -2 * (n + 1)) (_ : s ≠ 1),
    s.re = 1 / 2
      

Mathlib, file NumberTheory/LSeries/RiemannZeta.lean (line breaks ours). The proof is the constant riemannHypothesis of type RiemannHypothesis.

Three questions

  1. Is it the statement we mean? Comparison with the reference Challenge.lean (Comparator program): five theorems match.
  2. Does each step follow from the previous ones? The kernel checks this. Two independently written kernels, Lean’s and NanoDA, accepted the whole proof.
  3. What does the proof assume? #print axioms: only three standard axioms.
Today we will build our own kernel — for a much simpler theory, but with the same three questions.
Lecture 3 · Part I — A proof no one will read Open in the book →

The guiding question

What exactly does a computer do when it checks a proof — and why can we trust it?
proof search human, tactics, solver, AI — hard, can be wrong proof a tree built from a few rules kernel: checking a small program that searches for nothing ✓ accepted / ✗ rejected

Plan: theory → five rules → a kernel in Python (about 100 lines) → tactics → trust → search.

Lecture 3 · Part I — A proof no one will read
Part II

The theory and the five rules

Boolean algebra as an equational theory

Huntington’s eight axioms (1904)

for the sum +for the product *
H1x + y = y + xH2x * y = y * x
H3x + y * z = (x + y) * (x + z)H4x * (y + z) = x * y + x * z
H5x + 0 = xH6x * 1 = x
H7x + n(x) = 1H8x * n(x) = 0

$n(x)$ — the complement (this is how Robbins and the program EQP wrote it). Every axiom holds for all $x, y, z$. The columns are dual: swap $+ \leftrightarrow *$, $0 \leftrightarrow 1$.

Models

  • $\{0, 1\}$: $+$ is “or”, $*$ is “and”, $n(x) = 1 - x$
  • subsets of a set $X$: $\cup$, $\cap$, complement, $\emptyset$, $X$

An equational theory

  • axioms and theorems are equalities only (with an implicit “for all”); no $\exists$, $\Rightarrow$, $\neg$ — a proof is a chain of equalities
  • associativity is not among the axioms: it is a theorem (with a long proof) 🤿
Lecture 3 · Part II — The theory and the five rules Open in the book →

A proof on paper: $x + x = x$

stepjustification
x + x = (x + x) * 1H6
      = (x + x) * (x + n(x))H7
      = x + x * n(x)H3
      = x + 0H8
      = xH5

What really happens in each step?

  • substitution: in step 1, H6 for $x + x$ instead of $x$
  • context: in step 2, H7 acts inside the expression, to the right of $*$
  • direction: in step 3, H3 is read from right to left
  • chaining: five equalities give one — transitivity
On paper these operations are invisible. A computer needs each of them explicitly.
Lecture 3 · Part II — The theory and the five rules Open in the book →

One step broken down into atoms

Step 4: x + x * n(x) = x + 0

axiom H8 ∀x, x * n(x) = 0 ① substitution x := x x * n(x) = 0 ② context x + □ x + x * n(x) = x + 0 Lean-style notation congrArg (fun z => x + z) (H8 x)
  • Step 3 is H3 from the right: Eq.symm (H3 x x (n x)); step 1 is H6 for x + x: Eq.symm (H6 (x + x)).
Lecture 3 · Part II — The theory and the five rules Open in the book →

The five rules of equational logic

rulepremisesconclusionin Lean
Refl(t)—t = tEq.refl t (rfl)
Symm(p)p : a = bb = aEq.symm p
Trans(p, q)p : a = b, q : b = ca = cEq.trans p q
CongrArg(z, C, p)p : a = bC[z:=a] = C[z:=b]congrArg (fun z => C) p
Inst(H, t₁, …, tₖ)a fact H : ∀ x₁ … xₖ, l = rl[x:=t] = r[x:=t]H t₁ … tₖ
Every equality that is true in all Boolean algebras can be proved with these five rules (Birkhoff’s completeness theorem, 1935 🤿).
A fact H is an axiom or a previously proved theorem — this is how a library grows (Mathlib contains hundreds of thousands of them).
Lecture 3 · Part II — The theory and the five rules Open in the book →

A proof is a tree

stepproof of the step (Lean-style notation)
x + x = (x + x) * 1Eq.symm (H6 (x + x))
_ = (x + x) * (x + n(x))Eq.symm (congrArg (fun z => (x + x) * z) (H7 x))
_ = x + x * n(x)Eq.symm (H3 x x (n x))
_ = x + 0congrArg (fun z => x + z) (H8 x)
_ = xH5 x

We chain the steps with four Eq.trans — the whole tree has 14 nodes:


Eq.trans (Eq.trans (Eq.trans (Eq.trans (Eq.symm (H6 (x + x)))
  (Eq.symm (congrArg (fun z => (x + x) * z) (H7 x)))) (Eq.symm (H3 x x (n x))))
  (congrArg (fun z => x + z) (H8 x))) (H5 x)
  

Printed by our program (the function syntax.lean); the term from real Lean is in Part IV.

Lecture 3 · Part II — The theory and the five rules Open in the book →
Part III

A minimal kernel

about a hundred lines of Python that check every proof

Terms, proofs and substitution

kernel.py


# term: 'x' (a variable), '0' (a constant) or a tuple ('+', 'x', ('n', 'x'))

@dataclass(frozen=True)
class Trans:           # from  a = b  and  b = c  follows  a = c
    p: object
    q: object
# … likewise Refl, Symm, CongrArg, Inst

def subst(t, s):
    """Replaces at once the variables in the dict s (variable -> term)."""
    if isinstance(t, str):
        return s.get(t, t)
    return (t[0],) + tuple(subst(a, s) for a in t[1:])
      

>>> t = term("x + n(x)")
>>> t
('+', 'x', ('n', 'x'))
>>> show(subst(t, {"x": term("y * z")}))
'y * z + n(y * z)'
      
  • a proof is a tree of objects Refl, Symm, Trans, CongrArg, Inst
  • terms contain no $\forall$ and no $\lambda$ ⇒ substitution is just replacing letters (in Lean it is harder 🤿)
Lecture 3 · Part III — A minimal kernel Open in the book →

The heart of the kernel: the function conclusion


def conclusion(self, d):
    """The equation (left, right) that the proof d justifies."""
    match d:
        case Refl(t):
            return self.term(t), t
        case Symm(p):
            a, b = self.conclusion(p)
            return b, a
        case Trans(p, q):
            a, b = self.conclusion(p)
            b2, c = self.conclusion(q)
            if b != b2:
                raise ProofError(f"Trans: middles {b!r} and {b2!r}")
            return a, c
    

        case CongrArg(z, C, p):
            if not self.is_var(z):
                raise ProofError(f"CongrArg: {z!r} is not a variable")
            self.term(C)
            a, b = self.conclusion(p)
            return subst(C, {z: a}), subst(C, {z: b})
        case Inst(name, args):
            if name not in self.facts:
                raise ProofError(f"unknown fact: {name}")
            variables, l, r = self.facts[name]
            if len(args) != len(variables):
                raise ProofError(f"{name}: wrong number of arguments")
            s = dict(zip(variables, map(self.term, args)))
            return subst(l, s), subst(r, s)
    raise ProofError(f"not a proof: {d!r}")
    
  • input: a proof tree; output: the equality it justifies; five cases — one per rule
  • the only comparison: the middle term in Trans
  • the kernel searches for nothing: it gets the axioms, substitutions and contexts in the tree
  • checking time: linear in the size of the tree (up to the size of the terms)
Lecture 3 · Part III — A minimal kernel Open in the book →

The environment: axioms and theorems


def axiom(self, name, variables, l, r):
    self._add(name, variables, l, r, {name})

def theorem(self, name, variables, l, r, proof):
    """Adds  ∀ variables, l = r  — only when the proof justifies it."""
    if self.conclusion(proof) != (l, r):
        raise ProofError(f"{name}: the proof justifies another equation")
    used = used_facts(proof)
    assumed = set().union(*(self.assumptions[n] for n in used))
    self._add(name, variables, l, r, assumed)
  

>>> B, proofs = theory_with_theorems()
>>> sorted(B.assumptions["add_idem"])  # #print axioms
['H3', 'H5', 'H6', 'H7', 'H8']
      
  • a theorem enters the environment only after it has been checked — it cannot refer to itself or to later theorems
  • the order is as in a Lean file: each declaration sees only the earlier ones
  • assumptions is our #print axioms: which axioms the proof really uses
  • a curiosity: $x + x = x$ needs neither commutativity (H1, H2) nor H4
Lecture 3 · Part III — A minimal kernel Open in the book →

The kernel says “no”


>>> B.theorem("idem", ["x"], *equation("x + x = x"),
...           Inst("H5", ("x",)))
kernel.ProofError: idem: the proof justifies another equation
>>> B.conclusion(Trans(Inst("H5", ("x",)), Inst("H6", ("x",))))
kernel.ProofError: Trans: middles 'x' and ('*', 'x', '1')
>>> B.conclusion(Inst("H9", ("x",)))
kernel.ProofError: unknown fact: H9
>>> B.conclusion(Inst("H7", ("x", "y")))
kernel.ProofError: H7: wrong number of arguments
    
  1. a proof of a different statement: H5 x proves x + 0 = x, not x + x = x
  2. a hole in the reasoning: x + 0 = x cannot be followed by x * 1 = x
  3. an invented axiom: there is no fact H9
  4. a misused axiom: H7 has one variable

We show the last line of the error message.

Lecture 3 · Part III — A minimal kernel Open in the book →
🤿deep dive

Bound variables: de Bruijn indices

In Lean, terms have bound variables: $\forall$, $\exists$, fun. Naive substitution changes the meaning:

(fun y => x + y)[x := y]  ≠  fun y => y + y

The free y has been “captured” by fun y.

in the deep dive

  • N. G. de Bruijn (1972): bound variables are replaced by numbers — fun y => x + y is λ. x + #0
  • substitution with shifting of indices
  • a kernel for the typed λ-calculus; Automath — the first system that checked whole books of mathematics
We do not have this problem: equational logic has no binders. That is why our kernel fits on one slide.
Lecture 3 · Part III — A minimal kernel 🤿 Further: in the book →
Part IV

Tactics

programs that build proofs — and can make mistakes

A tactic: a program that builds a tree

goal x + x * n(x) = x + 0 tactic rw("H8") proof tree congrArg (fun z => x + z) (H8 x) kernel ✓ / ✗
  • a tactic may search, guess and make mistakes — its result is checked by the kernel anyway
  • anyone can add tactics; there is one kernel, and it is small
  • the idea comes from Robin Milner’s LCF system (the 1970s); in Lean a tactic builds a proof term, and the kernel checks it
Lecture 3 · Part IV — Tactics Open in the book →

Pattern matching


def match_pattern(pattern, t, free, s):
    """A substitution s of the variables in `free` with pattern[s] == t."""
    if isinstance(pattern, str) and pattern in free:
        if pattern in s:
            return s if s[pattern] == t else None
        return {**s, pattern: t}
    if isinstance(pattern, str) or isinstance(t, str):
        return s if pattern == t else None
    if pattern[0] != t[0] or len(pattern) != len(t):
        return None
    for a, b in zip(pattern[1:], t[1:]):
        s = match_pattern(a, b, free, s)
        if s is None:
            return None
    return s
    

In x + x * n(x), can we see the left-hand side of H3, x + y * z?


>>> match_pattern(term("x + y * z"),
...               term("x + x * n(x)"),
...               ("x", "y", "z"), {})
{'x': 'x', 'y': 'x', 'z': ('n', 'x')}
      
  • pattern variables may take any term, but the same variable always takes the same term
  • this is search — that is why it lives in a tactic, not in the kernel
Lecture 3 · Part IV — Tactics Open in the book →

The tactic rw: match, cut out the context, rewrite

  1. match: find a subterm of the goal that matches the left-hand side of the fact
  2. cut out the context: replace this subterm with a hole z — wherever it occurs
  3. rewrite: the new goal is the context with the right-hand side of the fact in the hole
  4. close: if both sides are equal — Refl
  5. assemble the tree: CongrArg + Inst (+ Trans, Symm)

>>> goal = equation("x + x * n(x) = x + 0")
>>> new, compose = rewrite(B, goal, "H8")
>>> show_equation(new)
'x + 0 = x + 0'
>>> lean(compose(Refl(new[0])))
'congrArg (fun z => x + z) (H8 x)'
    
rw in Lean works the same way: it cuts out a “motive” fun z => … and assembles the proof from congrArg and Eq.mpr.
Lecture 3 · Part IV — Tactics Open in the book →

From start to finish: $x + x = x$


prove(B, "add_idem", "x + x = x", calc(
    "x + x",
    ("(x + x) * 1",          rw("H6")),
    ("(x + x) * (x + n(x))", rw("H7")),
    ("x + x * n(x)",         rw("H3")),
    ("x + 0",                rw("H8")),
    ("x",                    rw("H5"))))
    
  • calc: a chain of equalities, each step proved by its own tactic; Trans chains them all together
  • step 1: the pattern x * 1 is not on the left but on the right — rw rewrites (x + x) * 1 back into x + x and closes the goal
  • prove: the tactic builds the tree, the kernel checks it and adds the theorem
  • result: the tree from the previous part — 14 nodes
Lean has the same tools: a calc chain in which every step is closed by the tactic rw — the proof looks almost identical.
Lecture 3 · Part IV — Tactics Open in the book →

The same proof in Lean

lean/Lecture03.lean · Lean 4.33.1


theorem add_idem (x : α) : x + x = x :=
  calc x + x = (x + x) * 1 := by rw [H6]
    _ = (x + x) * (x + n x) := by rw [H7]
    _ = x + x * n x := by rw [H3]
    _ = x + 0 := by rw [H8]
    _ = x := by rw [H5]
      

#print axioms add_idem


'add_idem' does not depend on any axioms
      
  • H1–H8 are fields of the class HuntingtonAlgebra, that is, hypotheses of the theorem, not axioms of Lean
  • the same steps: calc and rw with one axiom

#print add_idem — the term that Lean’s kernel checks


theorem add_idem : ∀ {α : Type} [inst : HuntingtonAlgebra α] (x : α), x + x = x :=
fun {α} [HuntingtonAlgebra α] x =>
  trans
    (trans
      (trans
        (trans (Eq.mpr (id (congrArg (fun _a => x + x = _a) (H6 (x + x)))) (Eq.refl (x + x)))
          (Eq.mpr (id (congrArg (fun _a => (x + x) * 1 = (x + x) * _a) (H7 x))) (Eq.refl ((x + x) * 1))))
        (Eq.mpr (id (congrArg (fun _a => (x + x) * (x + n x) = _a) (H3 x x (n x)))) (Eq.refl ((x + x) * (x + n x)))))
      (Eq.mpr (id (congrArg (fun _a => x + _a = x + 0) (H8 x))) (Eq.refl (x + 0))))
    (Eq.mpr (id (congrArg (fun _a => _a = x) (H5 x))) (Eq.refl x))
  
The same leaves as in our tree: H6 (x + x), H7 x, H3 x x (n x), H8 x, H5 x. The context is congrArg with the function fun _a => …, and Eq.mpr transfers the proof to the goal.
Lecture 3 · Part IV — Tactics Open in the book →

The library grows

theoremequalitycalc stepstree nodesaxioms (as in #print axioms)
add_idemx + x = x514H3 H5 H6 H7 H8
mul_idemx * x = x514H4 H5 H6 H7 H8
add_onex + 1 = 1616H2 H3 H6 H7
mul_zerox * 0 = 0616H1 H4 H5 H8
absorbx + x * y = x514H1 H2 H3 H4 H6 H7
compl_compln(n(x)) = x932H1 H2 H4 H6 H7 H8
  • absorb uses the theorem add_one as if it were an axiom: one Inst node instead of its whole proof
  • we count axioms transitively — via add_one we also get H2, H3 and H7
  • involution $n(n(x)) = x$: 9 steps on paper, 32 nodes in the tree
Lecture 3 · Part IV — Tactics Open in the book →

The cheating tactic


>>> def cheat():                 # “I will prove anything”
...     def tactic(kernel, goal):
...         return Refl(goal[0])  # proof: left = left
...     return tactic
...
>>> prove(B, "bogus", "x + y = x", cheat())
kernel.ProofError: bogus: the proof justifies another equation
    
  • a bug in a tactic ends in an error message, never in a false theorem
  • that is why tactics — and the language models that choose them — need not be trusted
  • in Lean the counterpart of a “hole” is sorry: it works, but #print axioms shows sorryAx
Lecture 3 · Part IV — Tactics Open in the book →

Boole Lab: try it yourself


bl> bl prove idem : x + x = x
  ⊢ x + x = x
bl> hint
  ● rw [← H6 (x + x)]   solver: proof in 5 steps   (x + x) * 1 = x
  ● rw [← H5 (x + x)]   grows   x + x + 0 = x
bl> rw [← H6 (x + x), ← H7 x, ← H3, H8, H5]
  ✓ no goals — type qed and the kernel checks the whole proof
bl> qed
✓ the kernel accepted idem : x + x = x
  proof tree: 14 nodes · assumptions (like #print axioms): H3, H5, H6, H7, H8
    
  • the same kernel (kernel.py) in the browser, modelled on Peano Lab; qed hands the tree to the kernel
  • tactics written as in Lean; Lean 4.33.1 also compiles the scripts of the whole library
  • the library: 98 theorems with full proofs — associativity, De Morgan’s laws, the Robbins equation…
  • suggestions: the next tactic (TAB), coloured lemma matches, a small solver
Lecture 3 · Part IV — Tactics Open Boole Lab → Open in the book →
Part V

Why do we trust the kernel?

a soundness proof · tests · what the kernel does not guarantee

When is an equation true?

An algebra $A$: a set $|A|$, operations $+^A, \cdot^A, n^A$, constants $0^A, 1^A$.
A valuation $v$: variables $\to |A|$.
The value of a term: $[\![x]\!]_v = v(x)$ and
$\quad[\![f(t_1, \dots, t_k)]\!]_v = f^A([\![t_1]\!]_v, \dots, [\![t_k]\!]_v)$
$l = r$ holds in $A$ $\iff [\![l]\!]_v = [\![r]\!]_v$ for every $v$.
  • $\mathrm{Mod}(H)$ — the algebras in which the facts in $H$ hold; Boolean algebras are $\mathrm{Mod}(\mathrm{H1}, \dots, \mathrm{H8})$
  • a substitution $\sigma$ changes only variables: a constant is a symbol with no arguments, $0\sigma = 0$
Substitution lemma. $[\![t\sigma]\!]_v = [\![t]\!]_{v^\sigma}$, where $v^\sigma(x) = [\![\sigma(x)]\!]_v$.
Proof: induction on the term $t$ (a variable; $f(t_1, \dots, t_k)$, constants included).
  • context: if $[\![a]\!]_v = [\![b]\!]_v$, then $[\![C[z{:=}a]]\!]_v = [\![C[z{:=}b]]\!]_v$ — both are $[\![C]\!]$ under the same valuation
  • instances: if $l = r$ holds in $A$, then so does $l\sigma = r\sigma$: $[\![l\sigma]\!]_v = [\![l]\!]_{v^\sigma} = [\![r]\!]_{v^\sigma} = [\![r\sigma]\!]_v$
  • this is where “only variables” is needed: the dictionary {"0": "y"} is not a substitution
Lecture 3 · Part V — Why do we trust the kernel? Open in the book →

The soundness theorem for the kernel

Theorem. Suppose every fact $G$ of the environment has variables that really are variables and holds in every algebra in $\mathrm{Mod}(\mathrm{ax}(G))$. If conclusion(d) $= (s, t)$, then $s = t$ holds in every algebra in $\mathrm{Mod}(\mathrm{ax}(d))$ — in particular in every Boolean algebra.

Proof: induction on the tree $d$; fix $A \in \mathrm{Mod}(\mathrm{ax}(d))$ and a valuation $v$.

nodethe kernel checkedwhy $[\![s]\!]_v = [\![t]\!]_v$
Refl(t)$t$ is a term$[\![t]\!]_v = [\![t]\!]_v$
Symm(p)the conclusion of $p$ is $(a, b)$by the induction hypothesis $[\![a]\!]_v = [\![b]\!]_v$
Trans(p, q)the middles are the same term $b$$[\![a]\!]_v = [\![b]\!]_v = [\![c]\!]_v$
CongrArg(z, C, p)$z$ is a variable, $C$ a termthe context lemma
Inst(G, args)$G$ is in the environment; its variables are variables$G$ holds in $A$ (as $\mathrm{ax}(G) \subseteq \mathrm{ax}(d)$) + the instance lemma
Corollary (induction on the calls to axiom / theorem): the assumption about the environment always holds — for theorems too, since the kernel adds them only after checking. And the list assumptions, our #print axioms, is reliable.
Lecture 3 · Part V — Why do we trust the kernel? Open in the book →

A careful proof exposed two holes

hole 1 — the Inst case

the true x * 0 = 0 with the constant 0 declared as a variable


old kernel:  Inst("zly", ("x", "y")) ⊢ x * y = y
new kernel:  rejects — bad: ('x', '0') are not all variables
      

$x \cdot y = y$ fails in $\{0, 1\}$ for $x = 0$, $y = 1$

hole 2 — the Trans case

a subclass of str whose == always says “yes” glues x = x to 0 = 0


old kernel:  accepts x = 0
new kernel:  rejects — not a term: 'x'
      

the fix in kernel.py


def is_var(self, x):
    return type(x) is str and x.isidentifier() and x not in self.signature

# in _add: the variables of a fact must be variables
if not all(map(self.is_var, variables)):   # a constant is no variable
    raise ProofError(f"{name}: {variables!r} are not all variables")
  
The tests in models did not catch this: random proofs never declare constants as variables. A soundness proof goes through every case.
Lecture 3 · Part V — Why do we trust the kernel? Open in the book →

Tests: does the kernel accept only the truth?

model: subsets of a set as bit masks

  • $+$ is |, $*$ is &, $n(x)$ is the complement, $0$ and $1$ are the empty set and the whole set
  • the 6 theorems of the library: true in the algebras of subsets of a 1-, 2- and 3-element set, under all valuations
  • a falsehood shows up at once: $x + y = x$ already fails in $\{0, 1\}$ ($x = 0$, $y = 1$)

5000 random proof trees

kernelacceptedof which false
ours32410
without checking the middle term in Trans50001219

We check truth in the algebra of subsets of a 2-element set. Our kernel rejected 1759 trees.

Tests do not replace a soundness proof, but they catch typos: removing a single condition from the kernel shows up immediately.
Lecture 3 · Part V — Why do we trust the kernel? Open in the book →

What the kernel does not guarantee

riskin our kernelin the proof of the Riemann hypothesis
the statement means something different from what we think (definitions, notation)we read the axioms and the theorem; the parser is outside the kernelcomparison with the reference file Challenge.lean (Comparator); definitions from Mathlib
additional assumptionsassumptions#print axioms: propext, Classical.choice, Quot.sound
a bug in the kernel, the compiler, the hardwarea soundness proof (half a page) and teststwo independently written kernels: Lean’s (C++) and NanoDA (Rust); checks repeated on different computers
understanding: why is it true?—here the kernel will not help: mathematicians have to read and referee the proof
The kernel answers one question: does this statement follow from these axioms? The rest must be checked by people.
Lecture 3 · Part V — Why do we trust the kernel? Open in the book →
🤿deep dive

The soundness proof checked in Lean

lean/KernelSoundness.lean · Lean 4.33.1


theorem soundness {α : Type} (A : Algebra α) (Γ : Env) (hΓ : Model A Γ)
    (d : Proof) {l r : Term} (h : check Γ d = some (l, r)) : Holds A l r
  

'soundness' does not depend on any axioms
'relative_soundness' does not depend on any axioms
'invariant' does not depend on any axioms
  
  • our kernel rewritten in Lean: terms, substitution, the five rules, check instead of conclusion
  • the theorem from this lecture and the environment invariant — checked by Lean’s kernel
  • both holes are impossible there: a variable and a constant are different constructors, and the comparison of the middles returns a proof
Lecture 3 · Part V — Why do we trust the kernel? 🤿 Further: in the book →
🤿deep dive

Completeness, truth tables and associativity

  • soundness (already shown): the kernel accepts only equalities true in every Boolean algebra
  • completeness (G. Birkhoff, 1935): every such equality can be proved with the five rules
  • for Boolean algebras a truth table in $\{0, 1\}$ is enough — but a table is not a proof tree; the tree still has to be built

in the deep dive

  • the proof of Birkhoff’s theorem
  • a tactic that builds a proof tree from a truth table (normal form)
  • associativity $x + (y + z) = (x + y) + z$ from the axioms H1–H8: a theorem with a long proof
Lecture 3 · Part V — Why do we trust the kernel? 🤿 Further: in the book →
🤿deep dive

Real kernels

  • in Lean a theorem is a type, and a proof is a term of this type; the kernel checks the type of the term
  • there are more rules: bound variables, dependent types, inductive types, equality “up to computation” (unfolding definitions)
  • the principle is the same as ours: the kernel searches for nothing

in the deep dive

  • Lean’s kernel (C++) and independent implementations: NanoDA (Rust), lean4lean (Lean)
  • exporting a proof to a file and checking it with another program
  • Automath, Peano Lab and Lean: how a proof becomes a term
Lecture 3 · Part V — Why do we trust the kernel? 🤿 Further: in the book →
Part VI

Search versus checking

our small solver · the Robbins problem · EQP (1996)

Our small solver: breadth-first search

  • from both sides of the equality at once: all single rewrites with H1–H8, in both directions
  • terms no larger than a fixed size limit (number of nodes)
  • when the two searches meet, we have a chain of equalities, and from it a tree for the kernel
  • the solver need not be trusted: its proof is checked by the kernel
equalitylimitterms examinedresult
x + x = x8135proof: 17 nodes
x * x = x892proof: 17 nodes
x + 1 = 18401proof: 20 nodes
n(n(x)) = x11369,932no proof (about 88 s)
n(n(x)) = x12296,766proof: 32 nodes (about 44 s)

Times from the instructor’s laptop, measured while preparing the lecture. Checking each of these proofs with the kernel: under 0.1 ms.

Search grows exponentially, checking — linearly. A human knows a 9-step proof of involution; the solver needs hundreds of thousands of attempts.
Lecture 3 · Part VI — Search versus checking Open in the book →

The Robbins problem

  • E. Huntington (1933): Boolean algebra is described by three equations (with the operations $+$ and $n$):
    x + y = y + x, (x + y) + z = x + (y + z),
    n(n(x) + y) + n(n(x) + n(y)) = x
  • H. Robbins (soon afterwards): can the last one be replaced by the equation
    n(n(x + y) + n(x + n(y))) = x?
  • more than 60 years without an answer
October 10, 1996: the program EQP (W. McCune, Argonne National Laboratory) proves that every Robbins algebra satisfies the second Winker condition: n(C + D) = n(C) for some C, D. By Winker’s lemma: every Robbins algebra is a Boolean algebra.
  • the successful search: about 8 days on an RS/6000 processor, about 30 MB of memory

W. McCune, Solution of the Robbins Problem, J. Automated Reasoning 19(3), 263–276 (1997) · www.cs.unm.edu/~mccune/papers/robbins

Lecture 3 · Part VI — Search versus checking Open in the book →

EQP searched. Who checked?

searchesproofchecks
1996EQP (about 8 days)EQP could not write out a proof object, so its proof guided the program OtterOtter’s proof object was checked by a separate proof checker
2010—A. Mann’s proof (2003) formalized in Isabelle (M. Wampler-Doty, Archive of Formal Proofs)Isabelle’s kernel
2026L. Alpöge with the Claude modela Lean archive: 175,187 filesLean’s kernel and NanoDA
todayour solver, our tacticsa tree built from five rulesour kernel (about 100 lines)
The same division of roles: search may be huge, clever and fallible — checking must be small, simple and independent.

Sources: McCune’s page · AFP: Robbins Conjecture · riemann-rev

Lecture 3 · Part VI — Search versus checking Open in the book →
🤿deep dive

The Robbins problem: the proof’s structure

  • the question (1930s): do commutativity, associativity and the Robbins equation n(n(x + y) + n(x + n(y))) = x imply the Huntington equation?
  • S. Winker (1980s, by hand): one pair of elements with C + D = C or with n(C + D) = n(C) is enough
  • EQP (October 10, 1996, about 8 days): such a pair always exists: C = n(n(x) + x) + x + x + x, D = n(n(x) + x) + x
  • who checked: Otter’s proof object (built from EQP’s hints) — a separate simple program; later Mizar (2001), Isabelle (2010), Lean 4 (2026)

in the deep dive

  • history: Huntington, Robbins, Tarski, Winker, McCune
  • all Robbins algebras with up to 9 elements: they exist only for 1, 2, 4 and 8 elements and are Boolean algebras; there is no finite counterexample
  • why every finite Robbins algebra is a Boolean algebra: it always has an idempotent element
  • a step of an Otter proof written with the five rules of our kernel
Lecture 3 · Part VI — Search versus checking 🤿 Further: in the book →

Summary

✓A formal proof is a tree built from a few rules. The kernel computes which equality the tree justifies and compares it with the theorem.
✓Five rules: Refl, Symm, Trans, CongrArg, Inst — in Lean Eq.refl, Eq.symm, Eq.trans, congrArg and applying a theorem. Our kernel has about a hundred lines and searches for nothing.
●Tactics (rw, calc, solver) build trees: pattern matching, context, rewriting. They can make mistakes — the kernel checks anyway.
✓Trust: the soundness proof (induction on the tree + the substitution lemma) exposed two holes, now fixed; Lean checked the proof. Plus tests, independent kernels, #print axioms.
●Search is hard, checking is easy: EQP searched for 8 days (1996), our solver — through hundreds of thousands of terms; the kernel checks in a fraction of a millisecond.
✗The kernel does not tell us whether the statement means what we want, nor why it is true — that is still the work of mathematicians.
Lecture 3 · summary Chapter in the book →

Thank you!

Date and topic of the next lecture: Harmonogram (in Polish) on the course website.

Book — Lecture 3
1. Theorem, axioms, and five rules
2. A minimal kernel
3. Tactics: from pattern to proof
4. Why we trust the kernel
5. 🤿 Deep dives: the Robbins problem and more
Code from the lecture
jadro/ — the kernel, tactics, a library of theorems (pure Python)
Boole Lab — a proof lab in the browser
KernelSoundness.lean — the soundness proof in Lean
Book — Lecture 1
4. Computation, verification, proof (Peano Lab, Lean)
Sources
riemann-rev — a map of the proof of the Riemann hypothesis and the status of the checks
L. Alpöge, note of November 20, 2026
W. McCune: Robbins Algebras Are Boolean
Archive of Formal Proofs: Robbins Conjecture
🤿 Deep dives — in section 5: the Robbins problem · de Bruijn indices · completeness and truth tables · associativity · real kernels

ESC slide overview · S speaker notes · ? keyboard shortcuts