r/explainlikeimfive • u/entrailentree • 6d ago
Mathematics ELI5: Validity of Lean proofs
I don't know how Lean works. I sort of get that a "proof that compiles" means that it's true. But I'm confused about the degree the specification of the proof itself matters to this? As in, can a proof "assume" a patently false statement, or perhaps more realistically misspecify a statement, so that it compiles but does not in fact prove what you set out to prove? (Obviously, this question is due to the AI proofs, the sheer length of them, and thus also whether they could be "reward hacking"?)
238
Upvotes
308
u/faiface 6d ago edited 6d ago
Yes, exactly.
Lean is a programming language with which you can both specify and prove precise statements about abstract objects like those in mathematics. It's true that if a Lean program compiles, then it actually proves what it specified. (Unless there is a bug in the compiler, or the design of Lean. Both are possible, but currently people trust it.)
But, that does not mean that what it specifies is what you had in mind. For complicated problems, those specifications themselves can amount to many files with thousands of lines of specification. The whole thing only proves what you set out to prove if that specification actually matches what you intended.
On the bright side, the specification is basically always still much shorter than the proof. And if you verify that the specification in fact is what you intended, and it compiles, then yep, it's correct.
67
u/lemoinem 6d ago
Yes, that's why double checking the axioms used by the proof and the final statement is very important.
The proof basically lists a sequence of statements and the engine double check that it can go from each to the next using some of the allowed inference rules and/or axioms.
Usually the engine is very conservative and will require you to make only small verifiable jumps between statements.
My biggest concern would be "is there a bug in the engine". We've seen major security vulnerability in major languages runtime recently. A bug in a proof verification engine is not out of the question.
22
u/Head_Evening_5697 6d ago
Lean is simply a logic validator. I can write down assumptions, and some theorems that follow from that assumptions. If I make a logical error, Lean will complain.
Assume "If X is a hedgehog then X is blue"
Assume "If X is a Pan, and X is also a phone then X is a hedgehog"
Assume "If X is a Pan, and X is also a laptop then X is a phone"
Then I can write down a short Lean proof of the theorem "If X is a Pan, and X is also a laptop then X is blue" without additional assumptions.
Now, normal Lean proofs work in Mathlib, a set of assumptions we call "axioms" that basically encompass standard mathematics, as well as a bunch of already proven theorems. You know, ZFC (https://leanprover-community.github.io/mathlib4_docs/Mathlib/SetTheory/ZFC/Basic.html) and so on.
2
u/entrailentree 6d ago
I mean... math If anything is turtles all the way down, how else would you describe infinity (sure, at the limit you get eels, but that's just reality).
2
u/TheOneTrueTrench 6d ago
You're partially asking about obfuscation, which is how you can effectively hide behavior in code that appears to work one way, but actually works another way. I don't know the Lean language all that well or anything, but it is possible that it proves something other than what you might think it does through hidden "functionality". You intrinsically have to fully understand a program to actually know what it proves. If you don't fully understand it, then you just don't know what it actually proves.
You may be interested in the IOCCC, or International Obfuscated C Code Contest, which if memory serves sometimes had the goal of hiding behavior in innocent looking code.
(incidentally, my favorite entries are the best/worse abuse of the rules winners, they are often brilliant)
8
u/PANIC_EXCEPTION 6d ago edited 6d ago
Math is not turtles all the way down.* At some point, you have to establish some basic foundational rules that make sense intuitively enough to the point where you can assume they are true. Those are called axioms. For everyday life, those are the Zermelo-Fraenkel set theory axioms, or, even more simplified for natural numbers, the Peano axioms. The latter lets you do things like proof by induction. You define some things like the concept of 0, equality, and the ability to always add 1 to any natural number.
Everything in math is derived from your chosen set of axioms. As long as there is some path between ZF and your proposition, via valid logical steps, then your proof is valid in that system.
Suppose you're starting out with Theorem Y and trying to prove Theorem Z. Y depends on X. X depends on W. All the way back to your axioms A. If you know Theorem Y to be true as it's already been proved, you don't need to include the entire proof of Theorem Y, the proof from Y to Z suffices.
In this way, there is no way to start out with "false assumptions", as your proof is relative and has to start somewhere. If the premise itself is false, then the proof is immediately discarded.
Automated theorem proving systems formalize this into a way that a computer can check automatically. If it is not buggy, then the proof can be validated automatically by checking that truth flows down a dependency tree (that is, every single statement you made is valid, and its assumptions are also valid). However, a computer proof is not enough. Like any other science, peer review and human understanding is required for final acceptance.
*This is true in a deep sense. There is no one consistent set of axioms.
3
u/Sea_Ingenuity_5022 3d ago
lean tells you the assumptions it makes and the conclusion it proves. All mathematicians need to check is if the LEAN compiles, the assumptions are reasonable and the conclusion is indeed the thing they are trying to prove
4
u/ThatGenericName2 6d ago
Yep, once again we have an example of garbage in garbage out. If you didn’t formalize your assumptions/axioms/whatever else correctly, you can get a bad result.
No different than how proofs work in the first place; proofs that relies on bunk assumptions aren’t useful as proofs. If you mistranslate your assumptions into Lean then lean isn’t actually “proving” your proof either, it’s proving something else that you think is your proof.
2
u/InNoNeed 4d ago
I believe I can prove through adding numbers together that is it possible to go from 1 to 5
Step 0: 1 is a valid number
Step 1: 1 + 1 = 2 is a valid expression
Step 2: 2 + 1 = 3 is a valid expression
Step 3: 3 + 2 = 5 is a valid expression
Since everything I did to get from 1 to 5 was valid mathematical steps I know that it must be true.
Now, if we have a more complicated proof all we really care about is that every step is legal. If every step is legal then the whole proof is legal.
2
u/JarPicklez 4d ago
Yes, which is why most lean proofs use a standard set of axioms which are basically type theory + a few extra things.
The Riemann hypothesis proof used the formulation from those axioms that the mathematical community has accepted for years now
2
u/ruidh 6d ago
Yes, there can be an issue in translating a natural language proof into Lean which causes the proof to be incorrect.
1
u/davideogameman 5d ago
> As in, can a proof "assume" a patently false statement, or perhaps more realistically misspecify a statement, so that it compiles but does not in fact prove what you set out to prove?
yeah, it absolutely can.
The idea of lean is machine-checked formal logic. so if you want to write the statement, "every integer is either even or odd", well, that's not good enough - you have to write something more like "forall integers n, isOdd(n) or isEven(n)" and have definitions of isOdd and isEven, which will also depend on definitions of the integers... it ends up getting very pedantic, which is quite the point, but also a big part of the challenge. If you write down the wrong assumptions and proof goal, you might end up not being able to get anything, or you might end up proving something, but not actually corresponding to what you wanted to prove. This, I think, is really the main risk of formal methods. Historically, the other problem has been the elbow grease and expertise needed to keep going and making progress, but it turns out the best LLMs are pretty great at that compared to humans.
1
u/vishal340 5d ago
It compiles may not exactly mean that is proving exactly what it is supposed to. You can do some sinister things in lean. Since it is a language, you can define your own rules and even more bizarre, there is something called "sorry" statement which compiles the code without proof. There are other things which check for these sinister stuff. So of you are aware of these then it is safe. Unless bug in kernel of course
1
u/eternalityLP 5d ago
Yes. For a deduction to be true, it needs two things:
Lean can validate the first one, not the second one.