News for hackers. Stuff that matters.
Re:Formal Verification Creates Hacker-Proof Code by simondedalus on Friday October 21, 2016 @12:45PM (#12761981)
Gödel proved that we will never get such a prover: https://en.wikipedia.org/wiki/G%C3%B6del%27s_incompleteness_...

Particularly, he proved that it is impossible for a formal system to prove its own consistency.

Re:Formal Verification Creates Hacker-Proof Code by informatimago on Friday October 21, 2016 @12:48PM (#12762019)
However, prover[p-1] can prove prover[p], modulo the bugs prover[p-1]. Then prover[p-2] can prove prover[p-1], modulo the bugs in prover[p-2]. If you can have prover[i-1] is simplier than prover[i], and prover[0] is so simple that any 5-years old can prove it's correct, then you win.
Re:Formal Verification Creates Hacker-Proof Code by JadeNB on Friday October 21, 2016 @01:12PM (#12762335)
> prover[0] is so simple that any 5-years old can prove it's correct

This seems like the perfect time to misquote Groucho Marx: "This is so simple a child of 5 could prove it. Somebody bring me a child of 5!"

Re:Formal Verification Creates Hacker-Proof Code by randallsquared on Friday October 21, 2016 @01:05PM (#12762258)
Something seems wrong about this. Could you not describe the combination of all provers as a formal system? Would this system then not run afoul of Goedel?
Re:Formal Verification Creates Hacker-Proof Code by crpatino on Friday October 21, 2016 @01:31PM (#12762549)
Theoretically, you are 100% correct.

In practice, it is still worthwhile to have N redundant independently developed provers to prove each other, and to benchmark against each other. This will help uncover subtle bugs that result from ordinary programming mistakes.

This will, however, not protect against deeper issues that are common to all N provers. e.g. Potential biases or mistaken assumptions in the formal verification comunity.

At the end of the day, it is an engineering decision. How much of the available resources are you willing to through at the practical problem of making your implementation approach asymptotically to the theoretical limits. The fact that those limits is indeed a peg or two below perfection is an independent issue.

Re:Formal Verification Creates Hacker-Proof Code by nickpsecurity on Friday October 21, 2016 @07:44PM (#12765918)
"In practice, it is still worthwhile to have N redundant independently developed provers to prove each other, and to benchmark against each other. This will help uncover subtle bugs that result from ordinary programming mistakes."

I strongly advise that to deal with both mistakes and subversion. Mutually-suspicious parties in various countries using different logics, compilers, hardware, etc. with a common, executable spec that's basically state machines or functions. That way they get same output from same input.

So, when I saw Milawa was verified first-order, I immediately looked for other verifications of first-order provers (found 1). Then the idea would be diverse implementations of executable parts of that stack with diverse reviews of logic combinations they did. Exhaustive testing done by each party. Even do implementations of key parts of TCB in other logics to check results. The prover with its code is trustworthy when everyone got the same results on same logics, code, shared tests, and individual tests. Plus have paper copies of the resulting text files with hashes stashed away somewhere in case a nation-state wants to throw money at countering diversity via hacking host systems. ;)

Then we rinse and repeat for more complex provers. The fun never stops in this game.

Re:Formal Verification Creates Hacker-Proof Code by vilhelm_s on Friday October 21, 2016 @09:00PM (#12766320)
The end result you get out is something like "if the prover n accepts the claim P, then prover 1 also accepts the claim P". In logical terms you can think of it as a relative consistency proof.

In practice, even much simpler theorems would already raise our confidence a lot. E.g., the inference rules of Coq can be stated in a couple of pages of text, but the kernel checker that you need to trust is 14k lines of OCaml. A proof that the checker actually correctly implements the inference rules would already catch the majority of the bugs that happen in practice. Because of Gödel we then can't hope for a proof in Coq that there is no way to use those inference rules to derive False, but that's less of a concern.

Re:Formal Verification Creates Hacker-Proof Code by lmkg on Friday October 21, 2016 @01:26PM (#12762499)
This approach can only describe formal systems that are finite combinations of such provers.
Re:Formal Verification Creates Hacker-Proof Code by nickpsecurity on Friday October 21, 2016 @01:14PM (#12762363)
Good thinking. That's exactly how they did it:

https://news.ycombinator.com/item?id=12762224

Re:Formal Verification Creates Hacker-Proof Code by JadeNB on Friday October 21, 2016 @01:11PM (#12762321)
> Gödel proved that we will never get such a prover

Not one that can handle Peano arithmetic—but there are plenty of interesting systems sub-Peano arithmetic. Presburger arithmetic (https://en.wikipedia.org/wiki/Presburger_arithmetic) is the one that springs to mind; I doubt that it's directly useful as a theorem prover, but it does show that interesting mathematics can be done in complete theories.

Re:Formal Verification Creates Hacker-Proof Code by acchow on Friday October 21, 2016 @06:18PM (#12765401)
Right, but the system we're interested in is normal computers, which is more powerful than arithmetic.
Re:Formal Verification Creates Hacker-Proof Code by JadeNB on Saturday October 22, 2016 @02:12PM (#12769821)
> Right, but the system we're interested in is normal computers, which is more powerful than arithmetic.

On the other hand, a theorem prover does not have to be able to prove everything about a system to be able to prove some useful things. One might also say "the system mathematicians are interested in is all of mathematics, which is more powerful than arithmetic", or, for that matter, "the system programmers are interested in is all of theoretical computation, which is (at least) Turing complete"—but sometimes it's useful intentionally to restrict our power. (I think of https://news.ycombinator.com/item?id=10567408 , for example.)

(If we're being very picky, then, as pfortuny points out (https://news.ycombinator.com/item?id=12762192), a computer, having only a finite address space, isn't even as powerful as ordinary arithmetic; but it's fair to guess that this isn't a useful kind of pickiness.)

Re:Formal Verification Creates Hacker-Proof Code by ZephyrP on Saturday October 22, 2016 @03:03AM (#12767608)
This is actually a common misconception perpetuated by zealous Scientific American reporters (and cognitive scientists :) . Many complete, consistent self-justifying axiom systems exist today. Formal verification schemes employing metamathematical logic also exist and can be both complete and consistent. Even MORE systems have been created that can verify their own semantic tableux exclusively (and by extension are consistent & decidable). Even still there are systems like Presburger Arithmetic, which can by proven decidable (although they cannot prove themselves)

On page 12 of the english translation (and possibly the original german), Godel addresses certain criteria for distinguishing a sufficiently powerful system (as well as recursively axiomitizable, etc).

I have personally written such a software verification scheme, and even have an inferior interaction mode for SMT solvers that can help you verify such schemes (it's in my profile & github).

There are also great books like the extremely cheesily-named graduate textbook: "Your Guide to Automated Reasoning", that examine this issue from every perspective imaginable.

Re:Formal Verification Creates Hacker-Proof Code by ahelwer on Friday October 21, 2016 @01:14PM (#12762360)
Honestly this objection always seemed very handwavey to me, especially given how much abuse the incompleteness theorems endure during extension beyond statements about the Natural numbers. Like, what exactly happens if you try to write a bootstrapped theorem prover? Does a deity descend from the heavens to unplug your keyboard? I'd be very interested in reading a paper or blog post documenting a practical attempt here.
Re:Formal Verification Creates Hacker-Proof Code by simondedalus on Friday October 21, 2016 @03:07PM (#12763582)
I don't mean to be rude, but this objection only seems handwave-y if you don't understand Gödel's proofs (common), or you have some refutation of them (obviously uncommon, but definitely interesting).

This is a good not-too-technical but not-condescending explanation https://www.amazon.com/G%C3%B6dels-Proof-Ernest-Nagel/dp/081... (it does get into the technical details; it just doesn't go line by line as you would if you wanted to recreate the proofs).

As long as you have the expressive power of Peano arithmetic (which all programming languages ought to, and definitely all proof systems ought to), you can find a Gödel sentence in the system and thus prove that it can't prove, of itself, "x is consistent".

It's worth looking into, if only for the enjoyment.

Re:Formal Verification Creates Hacker-Proof Code by ahelwer on Friday October 21, 2016 @06:47PM (#12765569)
It isn't at all obvious that "a theorem prover proving itself correct" and "an axiomatic system proving its own consistency" are the same thing, beyond both being in the category of things which refer to themselves in the domain of mathematical proofs. Software correctness isn't the same as consistency. A program is correct if it refines its specification, and an axiomatic system is consistent if it does not lead to contradiction. Before doing a deep dive into Gödel we need to firmly establish we're actually looking at the right problem.

Even if Gödel is shown to apply in the strict generalized theoretical sense, it might be irrelevant to practice. Theory and practice often differ enough for practice to be very useful; we easily prove halting for most programs we care about, compute solutions to average-case NP-Complete problems without a noticeable rise in CPU temp, and (as the other poster at this level said) write compression algorithms which work well on all relevant inputs. This is poor analogous reasoning, of course, but I include it because demonstration of universal practical pitfall would be very interesting in much the same way specific manifestations of availability loss in fault-tolerant consensus algorithms are interesting.

Really though, I am tired of the above exact exchange playing out in every thread I've seen here on formal verification. Someone raises the obvious concern of bugs in the theorem prover. Someone else raises the bootstrapping solution, cribbed from compilers. Someone else raises the Gödel objection; and there the conversation dies. Dig deeper.

Re:Formal Verification Creates Hacker-Proof Code by nickpsecurity on Friday October 21, 2016 @07:04PM (#12765674)
Good write-up. I hear you about the patterns of debate that prop up in these threads. My favorites are the ones where people show up with specific logics, techs, or R&D suggestions that others and I learn from. Such an approach might lead to people solving hard problems over time.

My favorite counter to the Godel thing, esp about termination, was sklogic showing how far from reality these concerns were by illustrating that a while loop counting down toward zero with "stop if zero" condition will guarantee a termination of any algorithm working piece-by-piece in inner loop so long as hardware functions. No magic math at all required to defeat the termination requirement in real-world. I added watchdog timers or even shelf-life of modern parts can do the same.

I did something similar when I was concerned about infinite loops or DOS attacks from malicious input. Just box it up in something I know will work with something checking up on it. Another was algorithm theory telling me QuickSort performed better but choose HeapSort if worst-case is a problem. A smarter programmer told me to just time average for QuickSort, run it with a watchdog, kill it on any instance it takes too long, and use HeapSort for that instance. Those are the kind of tips I appreciate about these terrible problems the theoretical side brings me. Hell, if only theory people would find, generalize, and expand on all the effective cheats in engineering instead of idealistic or abstract stuff. :)

Re:Formal Verification Creates Hacker-Proof Code by simondedalus on Friday October 21, 2016 @09:47PM (#12766558)
But doesn't the constant Gödel reference push people, exactly, to work toward effective cheats? Imagine if the people putting in effort to make real systems instead spent their time trying to create the self-verifying prover.
Re:Formal Verification Creates Hacker-Proof Code by nickpsecurity on Friday October 21, 2016 @10:18PM (#12766697)
No it distracts people by making them think some legend in math showed verification was provably a waste of time. The number that show up to keep saying it on reputable forums like this one leads to increased belief it's true via repetition effect. So, it's overall bad vs mentioning something relevant to practical verifications.

Plus, hardly anyone is making a self-verifying prover. Someone just asked about that. I tried what I hope is the proper response of simply linking to a self-verifying prover that succeeded in that goal up to first-order logic. So, that's already done with us just needing similar ones for checkers of HOL, Coq, ACL2, etc. Contrary to your implication, the Milawa techniques are based on and supporting some of most practical verification work to ever be done. So, one of few times someone totally ignored Godel in what non-experts would consider Godel's domain led to one of best results in formal methods.

We don't need Godel at all in these discussions. We just need to explain what formal methods are, their successes, their limitations, how to properly use them, and ideas for new projects.

Re:Formal Verification Creates Hacker-Proof Code by simondedalus on Friday October 21, 2016 @09:44PM (#12766548)
I understand the frustration, but the Gödel objection will always be raised as long as someone asks for a prover that can prove itself correct (read "proves false statements or fails to prove true statements," which just is consistency). To put a finer point on it, once you get how "an axiomatic system [can't prove] its own consistency," it actually is rather obvious that "a theorem prover [can't prove] itself correct." How would it? Without axioms or classical logic? What's it doing for the things that aren't it itself?

Notice though, Gödel's incompleteness didn't end formal logic (all the better for Gödel). I know we're in a public forum, but I would note that your "But what about the practical applications!?" is misplaced (though not poor analogous reasoning--I think you're hitting the nail on the head, honestly). Formal verification is not futile because of Gödel's proof. However, a self-verifying formal system is--which is a useful insight, especially for those interested in formal verification.

As an aside, I don't think you need to convince anyone that's actually recreated Gödel's proofs to approve of continued work on formally verified code. We would get excited about that stuff even if it weren't practical.

Re:Formal Verification Creates Hacker-Proof Code by hinkley on Friday October 21, 2016 @05:41PM (#12765119)
Have you ever written a compression algorithm?

You do know that Shannon proved that general purpose compression is impossible, right? Why bother if that 75% compression ratio is provably impossible?

Re:Formal Verification Creates Hacker-Proof Code by lmkg on Friday October 21, 2016 @01:29PM (#12762536)
The incompleteness theorem effectively states that some statements will require an infinite amount of time for this bootstrapping approach to work. The only deity involved is the finite-ness of the natural world.
Re:Formal Verification Creates Hacker-Proof Code by Houshalter on Friday October 21, 2016 @11:38PM (#12767019)
You don't need to prove that Peano arithmetic is consistent! You just need to prove that the theorem prover doesn't contain any bugs, i.e. that it correctly implements peano arithmetic. That's a much lower bar, and theorem provers have verified themselves in the past.
Re:Formal Verification Creates Hacker-Proof Code by pfortuny on Friday October 21, 2016 @01:00PM (#12762192)
Mmmhhhh.... Arithmetic in computers is bot infinite, so one might have a consistence theorem for "computers with arithmetic modulo 2^3000" for example.
Re:Formal Verification Creates Hacker-Proof Code by schoen on Friday October 21, 2016 @06:15PM (#12765383)
Your exponent is a bit too small, though; it should be 2^(number of bits of RAM), like 2^34359738368 for a computer with 4 GB RAM (plus a little bit for CPU registers).

Assuming that the computer programs under study aren't allowed to interact with a disk, of course. :-)

Re:Formal Verification Creates Hacker-Proof Code by aruggirello on Saturday October 22, 2016 @05:39AM (#12768021)
Or with the Internet :-D
Re:Formal Verification Creates Hacker-Proof Code by Senji on Friday October 21, 2016 @01:13PM (#12762353)
In the general case, we could just ignore general recurrsion and circular definitions or self refferencing functions. Then we win.
Re:Formal Verification Creates Hacker-Proof Code by simondedalus on Friday October 21, 2016 @10:05PM (#12766641)
The problem is that Gödel builds self-reference. It's not like Peano arithmetic has recursion or self-reference operators.

To put it another way, in order to disqualify self-reference, you would need to employ a higher order proof system--which gives the game away anyway.