Postmortem for Kernel Soundness Bug #14576

Posted by juhopitk 1 day ago

Counter161Comment62OpenOriginal

Comments

Comment by gr_norm 1 day ago

> The practical consequence: checking with an independent kernel still works, since it required two distinct bugs in two implementations, but users who rely on it need current versions of both.

Things like this aren't too surprising, given that even much simpler type checkers like Rust's have soundness issues occasionally. I think it's very important to view verified results not as an absolute and unbreakable guarantee, just an extraordinarily strong one where (1) the surface area for soundness issues has been painstakingly minimized and (2) any realized soundness issues are taken very seriously and fixed in short order.

Comment by rzmmm 1 day ago

The implementation of the kernel is relatively trivial, it's an intentional design choice.

Comment by Cantinflas 1 day ago

As claude would say, "relatively" is carrying a lot of weight in that frase. Definitely load-bearing — would not pass a quick smoke test.

Comment by UqWBcuFx6NV4r 1 day ago

but where’s the seam!?

Comment by 1 day ago

Comment by sieabahlpark 1 day ago

[dead]

Comment by stevefan1999 1 day ago

> much simpler type checkers like Rust's

Linear/Affine types aren't easy, although deep down it is about enforcing XOR.

Comment by why_only_15 1 day ago

To what degree can you say something like "if the kernel doesn't have metaprogramming [or some other set of features] it's fine". When were the last bugs with a reduced feature set?

Comment by esterna 1 day ago

Read the article. The elaborator (where metaprogramming is evaluated) is not part of the trusted computing base. The security model is that bad proof terms get rejected, not that they're never generated.

Comment by twotwotwo 1 day ago

This thread has some context. A proof-system researcher found some proof-system bugs and presented them a funny way:

https://leanprover.zulipchat.com/#narrow/channel/270676-lean...

A mathematically-inclined reviewer (or an LLM) can quickly identify that it's an exploit. (Two exploits; it's crafted to hit a bug in another proof checker, too.)

The post gestures at this, but a natural follow-up, beyond fixing specific bugs around this exploit, would be to task some security-oriented models with proving False in Lean, or with reviewing the code for potentially unsound steps, missing checks, or even useful 'hardening'. That's happening and bugfixes are landing as a result.

Comment by twotwotwo 1 day ago

I think this rates as too obvious to say among anyone remotely close to this, but worth noting there is a lot of distance between an exploit and any real confusion.

Proofs aren't generally machine-read-only. An exploit of a proof system kernel doesn't necessarily look like normal proof code. Exploits can be fragile: 'safe' tweaks break them. If an exploit used maliciously is found, the person sneaking it through wouldn't exactly be thanked for it. And the window for exploits overall seems to be shrinking: Lean/nanoda are easier to secure than, say, Chrome.

If someone wanted to deliberately sow confusion (my career advice is not to do that!) they would probably have better luck with a subtly wrong formalization or an informal proof. If they have prover kernel bugs, they should report them and get free T-shirts.

Still, it's cool to see how they're hardening Lean.

Comment by dafelst 1 day ago

Feels appropriate for bugs in a formal proof system:

> Beware of bugs in the above code; I have only proved it correct, not tried it.

-Knuth, 1977

Comment by michaelfm1211 1 day ago

Reminds me of this: https://mathoverflow.net/questions/513742/are-we-stuck-with-...

I know this is an implementation bug not a meta-theory bug, but I'd almost consider the fact soundness bugs are possible as a bug in the ideology, or at least a severe drawback. Stuff like this just wouldn't happen in Metamath. In a future where AI is autogenerating formalizations, why not have the AI use a harder but airtight system like Metamath?

Comment by derdi 1 day ago

Took me about 90 seconds to find a Metamath implementation bug that apparently allowed proving something that shouldn't be provable: https://github.com/metamath/metamath-exe/issues/184

Comment by xelxebar 1 day ago

That's with the original C verifier only. The actual database is cross-checked by 6 independent implementations. This is the whole point of Metamath: its kernel is so tiny that you can implement a verifier in a weekend.

Metamath isn't a silver bullet in the design space of formal proof tools, but I personally think it just about nails the metatheory we want. Maybe some explicit facility around definitions would be desireable.

Comment by LegionMammal978 1 day ago

As it happens, the Python verifier mmverify.py has an even simpler soundness bug [0], and so far I've reviewed two independent AI-written verifiers that have replicated that bug, since they apparently really like to copy the strategy from mmverify.py. A sound verifier isn't too difficult to write in terms of architecture (I just wrote one myself for differential testing [1]), but it requires some close attention to the details.

That is to say, the Swiss-cheese approach definitely lends authority, but individual implementations are unfortunately not as foolproof as they're made out to be.

[0] https://github.com/david-a-wheeler/mmverify.py/issues/30

[1] https://github.com/LegionMammal978/mm-verifier-tests/blob/ma...

Comment by i2talics 1 day ago

Why does the original C verifier have bugs if its supposedly so easy to implement a verifier?

Comment by poizan42 1 day ago

Nothing more complex than Hello world is easy to implement in C without risking mistakes in checking boundary conditions if you are not really careful.

Comment by xelxebar 1 day ago

Ease of implementation means we get more, independent verifiers rather than trusting any particular one.

Comment by alethic 1 day ago

The utility of autoformalization is not actually in confirming the correctness of human-checked results. Mathematicians have a pretty good peer review process. I'm not actually aware offhand of any mathematical results that were accepted and later found to be incorrect -- though I'm sure cases exist, it's astoundingly rare.

The mathematics community's motivation for formalizing problems like Maryna Viazovska's sphere packing results in Lean weren't because the results were in doubt -- she won a Fields Medal for it, it's an extremely examined proof -- but because formalizing those results would lead to a lot of interesting and useful mathematical objects needing to be formalized as a prerequisite, which could then be merged into Lean's Mathlib and become useful for anyone working with Lean, particularly students. Having a library of idiomatic proofs available in a formal system capable of checking your work is Really Cool! Working in a proof assistant is a great way to develop mathematical maturity, especially for people who might not have an undergraduate education available to them.

(Unfortunately in the sphere packing case, the research group working on it made the mistake of trusting one of the various "AI for Math" slop companies, who promptly rugpulled them: https://arxiv.org/html/2603.03684v3)

So the short answer is "it depends on what you want". Lean is an eminently usable system for humans and LLMs alike; Metamath is uh. Not. But yes, Metamath seems to have a more trustable kernel wrt. the independent verifiers, so if that's all you're after it would be a better pick. But... there's only so many bugs Lean's kernel can have. At some point, they'll all be found.

Comment by senderista 1 day ago

> I'm not actually aware offhand of any mathematical results that were accepted and later found to be incorrect

https://mathoverflow.net/questions/35468/widely-accepted-mat...

Comment by jojomodding 1 day ago

Yes, in particular the slides by Kevin Buzzard (linked in there or here: https://www.andrew.cmu.edu/user/avigad/meetings/fomm2020/sli... ) are funny and educational on that matter.

Comment by alethic 23 hours ago

(I should note that there is also utility in confirming the correctness of results that are too complex to be adequately verified by humans. The recent result that NF is consistent wrt. ZFC, among others (Peter Scholze's Liquid Tensors project) are examples of this. But that's distinct from "autoformalization" as commonly applied.)

Comment by vatsachak 1 day ago

And everyone who's been into this stuff for a while has had their prediction come through.

If AI is water, Lean is the pipe and collatz is a clog on one end, then surely we'll find the cracks.

Comment by Gehinnn 1 day ago

Has there ever been a bug that allowed to prove a previously unproven statement, without allowing the user to prove "false" by exploiting the bug directly?

If every bug-exploiting proof would make it easy to prove false, putting a bounty on proving false could increase trust in the validity of verified but obscure Lean proofs.

Comment by estherney 1 day ago

We want Lean4 (or any other deduction system that we use, for that matter) to be correct, i.e. "what is a true statement" and "what is a derivable statement" should be the same.

"every statement that can be derived also holds" is the difficult part to show, and something we refer to as soundness. For some fancy logics, it's not even possible to show, hence the discovered Kernel Soundness Bug in Lean!

"every statement that holds can also be derived", a notion known as completeness, is often a trivial property; in practice, we use refutation completeness instead, i.e. "every statement that doesn't hold can derive false". A bug that would allow a user to prove/derive a previously unproven statement would fall under this category of "completeness bug".

However, such completeness bugs immediately show up in testing. Generally, deduction systems have two kinds of rules: a handful of rules that are enough to establish (refutation) completeness, and then a few extra rules to optimize inference. Because so few rules are needed for completeness, lots of test cases will break if one of the rules break.

--

I'm not actually sure how the completeness situation looks like for proper provers like Lean. It's my graduate student's hubris to assume completeness remains easy to show for more advanced systems than the Superposition calculus ;)

Comment by cyphar 1 day ago

Don't Godel's incompleteness theorems mean that completeness is a property you don't want in a prover (as it means the prover must then be inconsistent and this unsuable) and consistency is a property of the prover you cannot prove using the prover itself?

Comment by logicallee 1 day ago

>"what is a true statement" and "what is a derivable statement" should be the same.

you mention completeness in the rest of your comment, so I'm not sure how you aren't aware of this, but the famous incompleteness theorem says that for a consistent set of axioms there will always be true statements you can't prove.[1]

[1] https://en.wikipedia.org/wiki/Gödel%27s_incompleteness_theor...

Comment by chowells 1 day ago

That's not what it says. It says that as long as the logic is rich enough (first-order isn't enough) and consistent there are statements where neither the statement nor its negation is provable. You may choose to create a new logic by adding either the statement or its negation as an additional axiom, and it will (obviously?) remain consistent.

Truth is some sort of value judgment that is outside the scope of formal systems. And looking at how bizarre Gödel statements are, it's unclear if there's any particular justification for declaring them to be true or false.

Comment by nextaccountic 1 day ago

The type theory of Lean is certainly rich enough though

Comment by j16sdiz 1 day ago

err... There are always more ---> you can't make it "compete" by adding finite number of axioms

Comment by cyphar 1 day ago

You can make it complete, it just won't be consistent.

In fact there is a simple way to do it -- add contradictory axioms and then you can use the principle of explosion to prove any statement as true. Is such a system inconsistent and thus useless? Yes, but it is complete.

Comment by logicallee 1 day ago

The second paragraph of my link talks specifically about truth:

>The first incompleteness theorem states that no consistent system of axioms whose theorems can be listed by an effective procedure (i.e. an algorithm) is capable of proving all truths about the arithmetic of natural numbers. For any such consistent formal system, there will always be statements about natural numbers that are true, but that are unprovable within the system.

Comment by markasoftware 1 day ago

A correctness bug in a proof checker by definition means that you can prove false.

Comment by Smaug123 1 day ago

Not necessarily. For example, perhaps my ZFC first-order-logic theorem checker implicitly accidentally contains the continuum hypothesis as an axiom. This isn't inconsistent but it is a correctness bug.

(For that matter, another correctness bug is "the checker rejects all proofs". You can't prove false if you can't prove anything.)

Comment by markasoftware 1 day ago

good point, I didn't think about these cases.

Comment by Gehinnn 1 day ago

But how obvious would that be in the proof? Especially when you don't know if the proven statement is not true/implies false. Afaik all past problematic Lean bugs clearly implied false. But could it be that a bug is used in a way that this is absolutely not clear?

For example, the bug could allow proving a=b if the hashes of the terms equal. And the only (hypothetically) known hash collision that could be used to exploit this might not lead to an obvious contradiction.

Comment by markasoftware 1 day ago

Let a and b be as you describe (hash collision), and suppose that collisions are extremely rare. We have a theorem that a=b => a+1=b+1. But in this case, a=b according to our hash-equality, but a+1!=b+1, which contradicts the theorem we've already proved.

for real problems with my statement, see your sibling comment.

Comment by tibbar 1 day ago

Reward hacking will continue to be a problem. For sufficiently astonishing AI-created results, we must remember to ask if AI has not instead found it easier to elaborately fool us.

Comment by remywang 1 day ago

Isn’t a disproof of the Collatz conjecture easy to check as it should just be a counterexample? Or is the proof not constructive?

Comment by cperciva 1 day ago

A counterexample of the form "X cycles to X after N steps" is easy to check. A counterexample of the form "starting with X we keep going up forever" is hard to check in finite time.

Comment by IsTom 1 day ago

And still that requires X to not be particularly large. It could conceivably be in ballpark of BB(40).

Comment by AnimalMuppet 1 day ago

You, sir, have a very different definition of "not particularly large" than I do!

Comment by Sharlin 1 day ago

To be fair, BB(40) is smaller than almost all positive integers.

Comment by db48x 1 day ago

It’s practically zero, in fact.

Comment by jonathrg 1 day ago

This feels like saying there are probably hundreds of stars in the universe

Comment by jojomodding 1 day ago

No, Lean allows non-constructive proofs so a proof could be like "if the Riemann hypothesis is true the counterexample is 42 otherwise it is the first nontrivial zero" or something like this, and then you don't get a fully closed counterexample.

Comment by derdi 1 day ago

This was never about the Collatz conjecture itself. If I understand the original discussion correctly (as of a few days ago, not sure if new stuff has come to light), everybody agreed that that framing was just a flashy gimmick. And some Lean maintainers were unhappy about it, since this framing just added noise to the reproducer; they would have preferred a simple proof of False. Nobody ever thought that the disproof might be real.

Comment by paulddraper 1 day ago

This had nothing to do with Collatz and everything to do with a Lean bug.

The proof was not actually a proof at all, because it was unsound (despite Lean admitting the proof).

Comment by juhopitk 1 day ago

"A soundness bug in the Lean kernel (#14576) was reported and fixed during the week of July 27. [...] On July 25, Ramana Kumar published a repository containing a sorry-free "disproof" of the Collatz conjecture, produced with AI assistance. It is not a valid proof because it exploits a bug in the kernel's handling of nested inductive types. On July 28, Kiran Gopinathan reduced it to a small proof of False and opened issue #14576."

Comment by de_aztec 1 day ago

So essentially: One cannot trust the code produced by an LLM, even if the code is a formal proof passing the verifier.

Comment by layer8 1 day ago

Trust in formal reasoning is necessarily always conditional. You have to start somewhere. The good thing about verified formal proofs is that the only way they can be in error is if the verifier is faulty. This drastically limits the possible reasons for error.

(In practice, there’s also the possible error that the proved formal statement means something different than what you thought it meant.)

Comment by fancy_pantser 1 day ago

One can only trust a verifier as far as they can trust anything made out of software.

Comment by xelxebar 1 day ago

I would expect proofs that exploit kernel bugs to look fishy, so someone reading the proof could catch the smell.

That said, I'm sure there's also room for underhanded Lean programming as well, which would be even more interesting.

Comment by AnimalMuppet 1 day ago

It has nothing to do with LLMs. One cannot trust the proof of anything if one cannot trust the verifier.

Comment by jkwang 1 day ago

[dead]

Comment by Sui_Kate 1 day ago

[flagged]

Comment by as1297 1 day ago

[flagged]

Comment by aseipp 1 day ago

The relevant kernel code isn't written by Claude though. According to git blame, 95% of the code in inductive.cpp is 5+ years old, with only ~3 hunks (totaling less than 30 lines) coming within the last 12 months including this fix. The Lean kernel in general does not seem to change very much, e.g. the last two years are very sparse in terms of activity with relatively contained changes when I examine the history (especially so when contrasted with the pace of the rest of the project).

Beyond that it looks like a pretty simple oversight. Coq and Isabelle have also had 'prove False' bugs, it isn't the end of the world. Stuff like this happens.

Comment by Jweb_Guru 1 day ago

Yeah people don't seem to get that the whole point of having a tightly checked kernel is so you don't have to care so much about the rest of it. Tactic heavy proofs have been "slop" long before LLMs got involved, and they lean heavily on the kernel rejecting nonsense.

Comment by adw 1 day ago

What is the error rate of human programmers? Anyone who tells you that either human or A.I. code is magically exempt from issues is selling you something.

Comment by Zsfe510asG 1 day ago

There are humans who make very few mistakes. The presence of Claude in a project however tells you something about the attitude of the project:

- Probably too close to corporations.

- Does not care about slop.

We have seen many projects that adopted AI under corporate pressure circle the drain. Often the corporations themselves backpedaled after some months.

Comment by muglug 1 day ago

> We have seen many projects that adopted AI under corporate pressure circle the drain.

Which?

> Often the corporations themselves backpedaled after some months.

Which

Comment by daishi55 1 day ago

> There are humans who make very few mistakes

Mmm there are humans who think they make very few mistakes. Ones who actually make few mistakes, not sure about that one. Could be a mistake that they catch themselves very quickly, but I just don’t think humans are very good at generating 100% reliable output on the first try anywhere close to most of the time.

Comment by msdz 1 day ago

Why can’t your two criteria be applied to projects with human contributors without further due diligence?

Comment by josh-wrale 1 day ago

Claude can produce code that is professionally reviewed and found to be correct.

Comment by Ar-Curunir 1 day ago

Do you have any evidence that the bugs were due to LLM code? Or are you just speculating baselessly