Five ways past Lean's leanchecker reported in three days after the Riemann certification; Lean removed the mode they used
On November 22, the day after the Lean FRO and the Mathlib Initiative certified Levent Alpöge's Lean proof of the Riemann Hypothesis, GitHub user babykalki filed two issues against leanchecker, the tool that re-checks the declarations stored in Lean's compiled .olean files. Both said they had been reported privately to the Lean FRO first. By the evening of November 24 there were five such reports in the leanprover/lean4 tracker, from three people, and in two of them a module that leanchecker accepts lets an ordinary lean run prove False with no axioms. One of those two, #16730 by Marius van der Wijden, now opens with a note from Lean developer Joachim Breitner: the affected component "is not part of the recommended and usual procedure to check proofs", and the bug "does not threaten the validity of Lean proofs checked that way, including Riemann Hypothesis and other high profile proofs."
I ran #16730's reproducer on Lean v4.36.0, the current stable release, to check both parts of that statement: that the older checker passes the forgery, and that the recommended path does not.
The five reports
| Issue | Filed (UTC) | What gets past the check | Status |
|---|---|---|---|
| #16674 | Nov 22, 19:00 | A planted <Module>.olean.server file is replayed instead of the module's own declarations |
closed Nov 25 |
| #16675 | Nov 22, 19:01 | An edited recursor stored under a different name is never compared with the kernel's | fixed by #16677, Nov 22 |
| #16688 | Nov 23, 09:58 | Forged inductive types, and entries named in their all list, are skipped by replay |
fixed by #16717, Nov 24 |
| #16730 | Nov 24, 17:38 | Two edited counts in a mutual inductive give an axiom-free proof of False |
closed Nov 24 |
| #16734 | Nov 24, 19:32 | An unchecked quotient entry gives an axiom-free proof of False |
closed Nov 24 |
All five concern the same code path: Kernel.Environment.replay, which takes declarations as Lean stored them and feeds them back to the kernel, and the .olean modes of leanchecker built on it. The reports that discuss it say the kernel's own checking is not in question. What they show is that replay trusted parts of what it was given. #16730 is the clearest example. In a mutual block of two inductive types, replay takes the parameter count from whichever member it reaches first and never compares the other member's stored numParams and numIndices with what the kernel generates. The kernel then uses the stored, edited count when it types a projection, so a field whose real type is false = false is typed as true = false.
To make the edited .olean, the reporter doesn't touch any bytes. Forge.lean calls Lean's private Kernel.Environment.add, which inserts a constant without checking it, through a hand-built name, and the stock compiler writes the result to disk.
Daniel J. Bernstein keeps a catalog of such reports, "False computer-checked proofs", which reached the Hacker News front page today. Its November 25 version counts 25 soundness bug reports for Lean. #16730 is the latest Lean entry; the other four reports from this week are not on it yet.
What I ran
I copied Forge.lean and Use.lean from the issue verbatim and ran them with the v4.36.0 toolchain (commit 611c117b):
lean Forge.lean -o Forge.olean
lean Use.lean -o Use.olean # tf : true = false
# 'boom' does not depend on any axioms
leanchecker Forge # exit 0
leanchecker Use # exit 0
leanchecker-paranoid Forge # exit 0
leanchecker-paranoid Use # exit 0
leanchecker --fresh Use # exit 1: 'tf' has type Bool, expected true = false
Then the other route, the one lake check and lake comparator use: export the proof to a text file and check the export.
leanexport Use -- boom > boom.export
leanchecker --from-export boom.export
# Lean default kernel rejects the solution: while replaying declaration 'PB2':
# (kernel) invalid occurrence of datatype 'PA2' being declared ...
leanchecker-paranoid --from-export boom.export # same rejection, exit 1
Both results match the table in the issue. The checker in its .olean mode, paranoid included, passes the forged module and the module that uses it. The export path rejects them: there, replay hands the edited parameter count to the kernel when it declares the mutual block, and the kernel refuses it.
How Lean responded
Lean's documentation draws this line. Its page on validating a Lean proof says the .olean checker "trusts that the .olean files are structurally correct" and is "prone to an attacker crafting invalid .olean files". For a possibly malicious proof, a category in which it explicitly puts "un-reviewed AI-generated proofs", it recommends comparator. That tool builds the proof in a sandbox, exports it, and has it checked outside the sandbox by several independently written kernels. All of them have to accept.
The code followed the documentation within a day of the first report. #16677 (merged November 22) rejects replay entries stored under a name that doesn't match their own. #16690 by Sebastian Ullrich (merged November 23) removes the .olean modes from leanchecker altogether, leaving only leanchecker --from-export. #16717 by Breitner (merged November 24) makes replay compare every stored inductive with the one the kernel generates. Its description ends with "Generated with Claude Code". These changes are on master and in nightlies. v4.37.0-rc1 came out on November 18, before any of them, so both released toolchains, v4.36.0 and v4.37.0-rc1, still ship the .olean modes. Asked in #16730 whether this deserved a point release, Breitner answered that with the comparator flow as the "really secure" check he was not sure it did.
Two points sit closer to the recommended path. #16734 notes that leanchecker --from-export, and so lake check, prints "accepts the solution" for an export containing a quotient record goal : False that the kernel never looked at; a theorem that uses goal is still rejected. Breitner answered 35 minutes after it was filed, and the issue was closed: Lean's kernel assumes the prelude's definitions are what the prelude says, which is "known and expected", and lake comparator "takes it into account". And in a comment on #16730, van der Wijden says that the nanoda checker shipped with the toolchain lacks a fix made upstream on November 7 for forged recursor rules, and that Lean master still pins the unfixed version. I did not test that. The only lean4 commit mentioning nanoda since November 20 that I found is #16671 on November 22, which points the bundled nanoda at a fork for a different kernel change. Comparator needs every kernel to accept, so a bug in one of them matters only if the others share it, which is why Lean runs several.
What this means for the Riemann proof
In our article on the certification I listed the checks on Andrew Sutherland's verification page. One of them, "leanchecker kernel replay of every module", 175,187 of 175,187, used the .olean replay that #16690 has now removed. On its own it now counts for less than it seemed to on November 21. The certification does not rest on it. Sutherland's page, last updated November 25, has Lean's default and paranoid kernels accepting the full export with leanchecker --from-export, nanoda and a con-leche build accepting it too, and lake comparator on Lean v4.36.0 returning "Your solution is okay!" after 122 hours 45 minutes. The original build ran without a sandbox, but a sandboxed rebuild reproduced the 61.6 GB export byte for byte. The export check is the one that rejected the #16730 forgery in my test.
None of the five reports was aimed at the Riemann proof, and none says anything is wrong with it. What they change is the weight of one line in its evidence: a pass from leanchecker on .olean files is evidence against honest mistakes, not against deliberately crafted files, which is how Lean's documentation describes it.
- lean4 #16730: leanchecker accepts an axiom-free proof of False via Expr.proj
- lean4 #16734: Soundness: an unchecked quotInfo entry gives an axiom-free proof of False
- lean4 #16688: Kernel.Environment.replay skips forged inductives
- lean4 #16675: leanchecker replay map does not check constNames against constant names (recursors)
- lean4 #16674: leanchecker replays a planted .olean.server sidecar
- lean4 PR #16690: reduce leanchecker to --from-export
- lean4 PR #16717: reject malformed inductive entries in Kernel.Environment.replay
- lean4 PR #16677: reject replay map entries stored under a different name
- Lean reference: Validating a Lean Proof
- D. J. Bernstein: False computer-checked proofs (version 20261125)
Comments
No comments yet. Be the first.