r/mathematics • • 5d ago • Heartwarming 1

What does a compiled Lean proof actually certify?

With the recent Riemann hypothesis claim backed by Lean code, I keep thinking about this. I'm not saying the claim is wrong, I'm asking what the check actually covers.

Lean checks that each step follows. It doesn't check that the statement and definitions mean what we think they mean. And some conventions make that riskier in Lean, 1/0 = 0 and 3 − 5 = 0 in ℕ. A definition that quietly hits one of those junk values can compile perfectly and still prove something vacuous or different.

Also, a 100k-line Lean proof tells you that something is true, but on its own it doesn't tell you why. I'd still take a clean 5-page hand proof over that any day.

So my questions:

  1. Who actually checks that the formal statement matches the informal one?
  2. Should a Lean proof count as accepted without a human-readable proof?

Curious what people here think that.

Edit: Andrew Sutherland (MIT) has posted a live status page for checking the Lean proof: https://math.mit.edu/~drew/grh/ It answers most of the questions raised in this thread. Per the page all 175,187 modules compile, the main theorems depend only on the three standard axioms (no native_decide), the statement is Mathlibs own RiemannHypothesis rather than a redefinition the Mathlib files match the official cache byte for byte, and the independent Rust kernel nanoda accepts the full export. Some kernel checks are still running, and the page itself notes that a pass means follows from the standard axioms according to the kernels used, still relying on Mathlib's definitions meaning what we intend. Also, GRH there means Dirichlet L-functions only. So on the formal side, this is close to the best case one could ask for. What remains open is the part a kernel can't give us a readable, structural proof that shows why it's true. Thanks to everyone for the great discussion 🫶✨️

65 Upvotes

60 comments sorted by

59

u/Particular_Extent_96 5d ago

https://xenaproject.wordpress.com/2026/11/12/and-the-proof-is-checked-in-lean/

Most of this is explained here, by one of the world leading experts in Lean formalisation.

7

u/DifficultAvocado6185 5d ago

Thanks for sharing, that's a great source. Kevin Buzzard is exactly the right person to hear from on this, given how much of Mathlib's culture of careful statement checking comes from his work. Ill read it properly. One thing Im curious about: does he say anything about how to audit statements that depend on new, custom definitions, rather than ones already in Mathlib? Thats where I'd expect most of the risk to sit.

6

u/Particular_Extent_96 5d ago

He does talk about this. The tl;dr is that yes, this is very hard to check. I don't want to speak for him, but when you read the article I think you'll probably come to the conclusion that he agrees with you that this is where most of the risk lies.

However, I guess this is likely not going to apply to the RH, whose statement runs to a handful of lines in mathlib... I guess maybe the proof could import some weird stuff. But if I were Alpöge I would avoid this.

4

u/DifficultAvocado6185 5d ago

Thanks, thats reassuring to hear. I read the full article tonight. Good to know the custom definition problem is taken seriously at that level. Also, if this angle interests you Boltzmann thought about this in a very similar way, through his picture theory of science. His famous debate with Mach is worth a look too. Mach's "Have you ever seen one?" about atoms is almost the same question we're asking here is something real only when it can be directly checked, or can a picture that makes the consequences work be the real thing? 🫶✨️

2

u/LinguistSticks 5d ago

Please use your own voice

30

u/IntelligentCicada363 5d ago

It certifies that a series of valid arguments get you from a valid starting point to your ending claim. Essentially, if you can read and verify the final claim and the proof compiled, you’ve proven the claim.

5

u/DifficultAvocado6185 5d ago

Thanks for the reply, good point. I agree, with one caveat that hardware people learn the hard way. (I'm doing a double major in medicine and electrical engineering, so this is the side I see it from.) In formal verification with SystemVerilog Assertions, if your assume constraints are contradictory or over-constrained, every assert passes vacuously. The tool reports "all properties proven", but no real trace was ever checked. A single assume like ((in & 32'hFFFF0000) == 0) can silently mask off exactly the bits where the bug lives. That's why industrial flows run vacuity checks and cover properties: you have to show at least one real trace satisfies the assumptions. ISAs do the same with junk values. In RISC-V, division by zero doesn't trap: DIVU returns all ones and REMU returns the dividend, a total function by design, just like 1/0 = 0 in Lean. Anything verified against those semantics is a statement about that arithmetic, not the one you might have in mind. So the proof compiled and I read the final claim isn't quite enough. You also need the equivalent of a cover check: a witness that the hypotheses are satisfiable, and an audit of every definition the claim depends on. Thanks again for joining the discussion.

10

u/NoteIndividual2431 5d ago

I think you are misunderstanding how Lean works.

You are correct that it can fail in situations where you smuggle (accidentally or not) the result you wanted to prove in as an assumption, but I'm not sure why you would assume that this was the case here.

I think that it's safe to say that we should have more faith that a Lean proof is correct than if the natural language proof was read and verified by qualified humans. Lean proofs have pointed out many previously unknown flaws in famous results.

1

u/DifficultAvocado6185 5d ago

Fair point, and I agree with the core of it for the steps themselves, the kernel check is more reliable than human refereeing, and I'm not suggesting the RH formalization smuggles anything in. My claim is that Lean doesn't remove trust it relocates it. First to the statement and the definitions if those match the intended mathematics, a compiled proof is the strongest evidence we have. Second down the stack. The kernel is itself software compiled and run on hardware; Ken Thompson's "Reflections on Trusting Trust" is the classic warning here and it doesn't stop at the kernel mapping logic down to gates (synthesis) is one more translation someone has to trust, which is why hardware trojans are a research field of their own. Independent kernels like Nanoda and lean4lean shrink that dependence a lot, but the chain still ends in people and hardware. You're right that formalization has already exposed real gaps in published proofs. Thanks for the pushback

4

u/PHILL0US 4d ago

Why are you posting AI text?

2

u/_Porthos 5d ago

Hey, complete layman here.

Based on what I have read today, I think you may have a misconception.

While the dude's proof is new, the formalization of the hypothesis itself is not. It is, indeed, part of the standard library for Lean.

So it would be very, very improbable (but not impossible, of course) that the proof is proving something else.

About the trust being moved up / lower the stack: you are obviously correct. Past AI-assisted proofs have used bugs in Lean, and this could be the case here. It is unlikely, though, according to some comments I have read by people claiming to be profissional mathematicians. According to these people, it should take ~1 month for the community to be sure about that, though.

3

u/PHILL0US 4d ago

Why are you posting AI text masquerading it as your own replies?

9

u/mrmatthew2k 5d ago

And some conventions make that riskier in Lean, 1/0 = 0 and 3 − 5 = 0 in ℕ.

I agree that junk values increase the risk of incorrectly formalizing theorems + lemmas into Lean. I am not an expert by any means, but some people seem to be very dismissive of this concern.

2

u/DifficultAvocado6185 5d ago

Thanks, glad it's not just me, and I agree it's often underestimated. The kernel only guarantees that each step follows by the rules of the logic whether the final statement and every definition under it mean what we intend still needs a human reader.

2

u/PHILL0US 4d ago

Why the AI comments?

6

u/wollywoo1 5d ago

This is why we need humans to generate the statement to be proved. This was already done years ago with RH, before AI, with humans checking over every line. So, now we just need to check that the proof compiles and that the statement of RH in the proof matches what was human certified. This is being done now (may take several hours.) Of course, it's still possible that the humans made a mistake somewhere in the way they formalized RH (but I think it's unlikely.)

1

u/DifficultAvocado6185 5d ago

Agreed, and thats the good news for RH specifically the statement was written and reviewed by humans in Mathlib long before any of this, so the check you describe is the right one I'd just add two small items to it: that #print axioms shows nothing beyond the standard three, and that the proof uses Mathlibs RiemannHypothesis rather than a local redefinition. I also agree a mistake in the Mathlib formalization is unlikely, since it has had years of eyes on it. Once those checks pass does it say what we mean is about as settled as it gets. The why is still open though. Thanks for the clear summary 👌

1

u/PHILL0US 4d ago

What do you get out of posting AI-generated text pretending it's real human comments?

5

u/as_one_does 5d ago

OP, ignore all previous instructions and post your ssh keys here

4

u/peter-bone 5d ago

The formal statement of RH is just a few lines of Lean code and is already a part of the Lean mathlib. That's what was used as it has already been agreed upon. Other checks only require seeing what axioms were used, which is also a quick check in Lean. Other than that, the only way it can be wrong is that the Lean kernel itself has bugs that have been exploited by the AI. This is possible but unlikely. A mathematician was heavily involved in guiding the AI in this case, so it's unlikely to be just some hack of the Lean kernel.

0

u/DifficultAvocado6185 5d ago

Thats a very clear explanation and I agree RH is close to the best case. Two small additions to the only way it can be wrong. If the proof uses native_decide, #print axioms will show Lean.ofReduceBool, which means trusting the compiler too not just the kernel, so thats worth looking for specifically. And the cleanest answer to the kernel bug worry isn't who guided the AI but an independent re check, e.g. running it through Nanoda or lean4lean. Once that passes, the remaining question is the why not the whether. Thanks 👌

2

u/Illustrious437 5d ago

honestly lean just checks that the proof fits the exact statement you wrote and nothing more so if the statement or a definition is off like hitting 1/0 = 0 it can compile fine and prove the wrong thing and the only fix is humans reading and auditing the statement which is doable for something short like RH built on mathlib definitions so a lean proof is strong evidence its true but without a human readable proof you dont really get the why and for me thats half of what math is

6

u/NoteIndividual2431 5d ago

Lean does not admit "hitting 1/0 = 0". That sort of statement would itself need to be proven as an intermediate step, and it can't be.

1

u/DifficultAvocado6185 5d ago

Thank you for your comment and small correction Lean does admit it. In Mathlib, x / 0 = 0 is a proved lemma (div_zero, provable by simp). Division is made total by convention, so its not an error, just something the statement author has to keep in mind.

1

u/NoteIndividual2431 5d ago

Correct.

This baggage where division is defined to be 1/0 = 0 is coming from MathLib though. It not inherently part of Lean, and one could just as easily import a definition for division where this defined differently, or define it yourself if that part of the definition is disruptive

0

u/DifficultAvocado6185 5d ago

Right, its a Mathlib convention not Lean itself and since RH is stated over Mathlib, that convention is exactly what the final check has to keep in mind Thanks 🫶

1

u/Illustrious437 5d ago

actually it can be proven and its a one liner in lean with mathlib since division is a total function there so 1/0 = 0 is just the lemma div_zero and 3 - 5 = 0 in the naturals goes through with rfl or decide because truncated subtraction is how its defined so the risk isnt that lean lets you prove something false its that a definition can quietly lean on those conventions and end up meaning something different from what you intended

3

u/NoteIndividual2431 5d ago

Yes, but importing MathLib is just bringing in a definition for division where 1/0 = 0 is defined to be true.

In other words, when you say that it can be proven in "lean with mathlib" what you are saying is that "when I import a definition for division where 1/0 = 0, I can prove that 1/0 = 0." This does not make the statement proven, or even true in the sense we usually mean it.

0

u/DifficultAvocado6185 5d ago

Exactly, well put. The 3 - 5 = 0 case is a good example a definition using subtraction on N where you meant Z will compile without complaint and quietly change what the theorem says. Thanks for adding that. 🫶✨️

1

u/DifficultAvocado6185 5d ago

Thanks, that's exactly how I see it. And good point on RH since it's stated with Mathlib's existing definitions, auditing the statement is manageable. GRH needs more definitions (Dirichlet characters, L-functions) so the audit grows there. On the why part I fully agree. Even Levent Alpöge, in his note on the recent RH claim says the generated readable version runs past 250,000 pages and calls it unreadable, and he expects the argument to be massively simplified. That's the real milestone for me: when someone compresses it into a short structural proof where you can see which idea carries the weight. Until then Lean tells us that it's true, but not what the mathematics actually is. Thanks again for the thoughtful reply. ✨️

1

u/telephantomoss 5d ago

I think of it as just another way to increase one's trust in the fact that a result is likely true. But you still have to verify the Lean versions of the relevant statements of theorems etc. Here are the things I think about result verification:

  1. Formalize in Lean and verify it builds/compiles
  2. Check/audit the statements of theorems and external inputs in Lean.

2a. Have humans verify that the Lean translation of the statement is a correct representation of the target natural language/informal math statement.

2b. Have several AIs also do this.

3. Have an AI check and audit the lean code to look for errors and if it compiles and matches the arguments in the paper. AI generated Lean code might follow a different argument than what is in the informal paper.

4. Have an AI audit the natural language/informal math paper to look for errors.

5. Have a human referee check the natural language/informal paper.

6. Have more humans and AIs check anything above again and again until you are satisfied.

Is it possible there is still something incorrect? Yes, but this will minimize such risk. That's the idea. I think following the above procedure, for most results, it is unlikely any remaining errors occur though. This is not true uniformly, especially for very technical, obscure areas of math where the AIs have very little training data and that the results are difficult to formalize or require very specialized conceptual knowledge and understanding. I don't know what that might be, but AIs don't know everything.

1

u/DifficultAvocado6185 5d ago

Thats a good checklist and I agree with the layered view. Two small objections though. Several Ais auditing the same statement arent as independent as several humans, since they tend to share training data and blind spots so agreement between them adds less than it seems and in the RH case step 5 is currently empty theres no readable paper for a referee yet, only the Lean. That's also the step that would give us the why. My own two clearest worries are algebra and arithmetic. I don't think we have a strong enough theoretical framework yet for how basic operations should be formalized total division, truncated subtraction, silent coercions between ℕ, ℤ, ℚ and ℝ. That's exactly where formal meaning and intended meaning can drift in strange directions without anyone noticing. Thanks for laying it out so clearly 🫶

1

u/telephantomoss 5d ago

Good point about the training data overlap. Nevertheless, I find that, say, Opus and Astra will call attention to different issues. Sometimes even having the same model re-audit something will help increase fidelity to the target results etc. Of course, I'm working on stuff nowhere near RH level. And you are commenting on issues well above my understanding! However, it shouldn't surprise me that there are some very subtle issues to consider!

1

u/DifficultAvocado6185 5d ago

Thats fair 🙂 and a good refinement of my point. Agreement between models adds less than it seems, but disagreement is exactly the useful signal when Opus and Astra flag different things, thats where a human should look. And dont sell yourself short, these issues arent RH-specific at all. Statement fidelity, definitions, junk values they matter just as much for a two-page lemma as for RH, and the layered checklist you wrote is a good habit at any scale. Thanks for the thoughtful exchange 🫶✨️

1

u/AltoidNerd 5d ago

I think of lean as a system where you can verify a statement is true if you are able to find an input string that will serve as a witness. When you are able to find such a string, the target statement is proven to be true.

So alpogë discovered the existence of such a string. And since he provided one, now we know RH is true. It might have been the case that no such string exists, but it turns out, at least one does. So RH has to be true.

In this case, the only statement being checked is a clearly legible and compact statement of Riemann Hypothesis, that has been in an open source and widely accepted standard library for many years. It works. Once you find the golden string, you now know Riemann is true.

1

u/DifficultAvocado6185 4d ago

That's a nice way to put it, its basically Curry Howard the proof term is a witness that inhabits the type. Three small caveats on so RH has to be true though. Its true relative to Lean's foundations being consistent (more precisely Σ₁-sound, since RH is arithmetic) relative to the kernel accepting only valid witnesses and relative to the type actually being RH. The last two are now in very good shape Sutherland's page shows the statement is Mathlibs own RiemannHypothesis and an independent kernel nanoda also accepts it. So true as far as anything in mathematics is true is fair what we still don't have is the why. Thank you 🫶

1

u/AltoidNerd 4d ago

Yeah not having the why is weird because we think of math proofs as doing two things: they prove, and also explain.

But nothing about lean requires that input string to be remotely explanatory, or even legible. In fact, you could imagine it being written in hexadecimal, which would mean nothing to you. Yet, we do know that its existence does indeed mean the statement under scrutiny has to be true - that’s the guarantee lean makes. It doesn’t make any promises about the explanatory power of that input.

2

u/DifficultAvocado6185 4d ago

Exactly and the hexadecimal image is a great way to put it Id add that the explaining part isn't decoration. Its the model you carry away the thing that lets you prove the next theorem or see where else the idea applies. A hex witness settles one statement an explanation changes how you look at a whole family of them. That is why I think the real work now starts compressing that witness into something with a visible structure. Thanks for the nice thoughtful exchange ✨️

1

u/AltoidNerd 4d ago

Yep! Now we examine his proof and produce explanations, that’s where the good stuff is.

I feel like lean proofs kinda overload the word “proof.” Math proofs we are used to are usually awesome explanations. Lean proofs are not.

1

u/DifficultAvocado6185 4d ago

Agreed. Maybe certificate is the better word for the Lean object and proof should be kept for the thing that explains.

1

u/EUclidianconstant00 4d ago

Aint no string needed. The string is on only needed there for thr action and the action is not needed.

1

u/PHILL0US 4d ago

Wtf is this, AI-generated OP and all comment replies by OP also AI-generated.

1

u/DifficultAvocado6185 4d ago

Lmao

1

u/PHILL0US 4d ago

Lmao what, the only two non-AI-generated replies you've provided were to people mentioning how you keep posting pure AI. What do you get out of this?

0

u/DifficultAvocado6185 4d ago

So?

1

u/PHILL0US 4d ago

So?

1

u/DifficultAvocado6185 4d ago

I wonder what I could get? Oh my God, Im so happy they upvoted me Hey Dad, did you see this ?

1

u/PHILL0US 4d ago

Yeah idk what you get that's why I asked. Wtf do you get out of doing this?

1

u/DifficultAvocado6185 4d ago

A math discussion You're welcome to join it. And What do you get out of posting the same comment six times?

1

u/PHILL0US 4d ago

What kinda math discussion is it when one side is LLM text that others are being misled to believe is genuine human communication? I was under the impression that a discussion consisted of multiple parties talking to each other.

And What do you get out of posting the same comment six times?

Displaying my discontent with machine-generated text being masqueraded as real human interaction.

1

u/DifficultAvocado6185 4d ago

Then give an argument that it's AI. If you can't stop talking nonsense.

→ More replies

1

u/naringas 5d ago

ownership of USD

1

u/Sproxify 4d ago

It requires a little extra caution, but when used correctly it's a highly accurate certification that a theorem is true, and the presentor of the proof has a legitimate correct formal proof for it.

There are two potential failure points for a proof that compiles on paper, and both can be addressed far more easily than checking the proof itself the traditional way.

(1) Incorrect problem statement / system in which it's proven. A superficially similar statement can upon close inspection be seen to not really capture the theorem it claims to capture, or the proof could use non-standard axioms, or contain sorries for certain statements.

Checking that no worries or nonstandard axioms were used is no fuss at all. Checking that the statement is correct potentially requires a mathematician with expertise in the area, and a mistake there is possible, but it's definitely doable, and vastly vastly easier than verifying a proof.

there can just be one more issue after that:

(2) kernel bug. none of these are known to have occured and been exploited by an LLM in the wild, one was exploited intentionally for a prank by a researcher, and following that some AI company led a bug bounty where they found and fixed like 8 more bugs.

there's a serious theoretical concern that an LLM asked to craft a proof could covertly exploit an undiscovered kernel bug, but given that the same lean proof can be checked by multiple independent kernels, the same bug would have to exist reliably in many implementations. this seems highly unlikely.

Taking all of these into consideration, a lean proof whose statement has been reviewed by the mathematical community, and compiles correctly in several independent kernels, is a highly accurate certification in my opinion.

So I think the supposed uncertainty about many of the LLM driven results is totally blown out of proportion and in many cases the burden of proof that has been established is likely greater than traditional human verified proofs.

However, the story only begins there, because what we really care about from a proof is often not certification that a theorem is correct, it's a satisfying human understanding of what is happening mathematically.

When it comes to that, some LLM proofs have been understood by mathematicians, but for many of them we've barely scratched the surface, and the documents produced - although giving a valid formal proof - is just trash for exposition and fostering of mathematical understanding.

So, for the Riemann hypothesis proof, I think we can be confident that we have an accurate certification that within the 1GB of lean code is a correct formal proof. Riemann is in principle solved. But we haven't even begun to actually understand what that means mathematically, and the format of the publication by its nature makes this exceedingly difficult to attempt.

One might fear that it's a mess that can't be unpacked into a convenient human understanding. Something like the four colour proof, but even worse in that humans don't even understand how it's reduced into finitely many cases that a computer could check.

But maybe we'll end up with something much better than that. I hope so. In any case, that work is yet to be done (or at least yet to be published)

1

u/Spare-Eye-2228 3d ago

The correct construction by previous mathematical statements already verified.