News for hackers. Stuff that matters.
Re:The SeL4 Foundation: What and Why by h91wka on Tuesday April 07, 2020 @07:14AM (#22802168)
> Is it possible to have a programming language where the compiler does the formal verification?

Such compiler would require solving halting problem. Most problems related to search of formal proofs are undecidable.

Re:The SeL4 Foundation: What and Why by MaxBarraclough on Tuesday April 07, 2020 @07:22AM (#22802208)
This is true, but SPARK and ZZ do it anyway. Automatic deductive program-verification can work, but the halting problem means there will always be truths than cannot be automatically proved. This can still be good enough to get the job done.

In the case of SPARK, it's necessary to use timeouts on the prover. Ugly, sure enough, but real work can still be done with it.

https://docs.adacore.com/spark2014-docs/html/ug/en/tutorial....

Re:The SeL4 Foundation: What and Why by simiones on Tuesday April 07, 2020 @07:55AM (#22802361)
If we want to go to extremes, it's even worse than the halting problem. Godel's incompleteness theorem shows that, assuming your system is consistent, there are truths that don't have a proof at all, which is even worse than not being able to compute that proof.

Still, the only impact this has in practice is that it tells you languages or programming styles amenable to automatic verification must be very limited in their expresiveness/flexibility.

Re:The SeL4 Foundation: What and Why by MaxBarraclough on Tuesday April 07, 2020 @10:07AM (#22803306)
> the only impact this has in practice is that it tells you languages or programming styles amenable to automatic verification must be very limited in their expresiveness/flexibility.

This is a consequence of the state of current tooling, rather than an inescapable consequence of the relevant math.

A concrete example: the SPARK language is a subset of Ada, but with each release it gets less claustrophobic.

You can even go to the other end of the programming language spectrum, and use formal methods with functional programming languages. I don't think anyone develops real critical systems this way, but I believe it's an active area of research.

Re:The SeL4 Foundation: What and Why by pron on Tuesday April 07, 2020 @12:14PM (#22804534)
> This is a consequence of the state of current tooling, rather than an inescapable consequence of the relevant math.

It actually is an inescapable consequence except that it's far worse than limited languages: limiting languages doesn't help. In fact, langugage is kind of a red herring here. If a language has nothing more than boolean variables and non-recursive non-first-class subroutines, or, alternatively loops up to depth 2 -- it is already beyond our general verification power, as the cost of proving properties grows exponentially in the size of the program, and that kind of language is well below anything usable; usable languages require exponential space and super-exponential time even if they're completely decidable. It's important to remember that the problem isn't a binary distinction between decidable and undecidable. Almost all decidable problems are also impossible. They can take any length of time except infinite. In fact, undecidable problems are a very extreme and exceptional kind of impossible; most impossible computational problems are decidable.

See my post here for some results: https://pron.github.io/posts/correctness-and-complexity

Rather, what formal method do is try to get a certain mix of confidence, difficulty and scale so that they might be able to check some properties with some confidence in some cases. That is the best we can hope for, and what formal methods in industry use actually do. This is still a lot, but people should understand what the rules of the game are.

Re:The SeL4 Foundation: What and Why by wahern on Tuesday April 07, 2020 @04:41PM (#22807250)
> as the cost of proving properties grows exponentially in the size of the program

Exactly. And the solution is architectural modularization--implementing a solution as multiple components that can each be independently verified and then integrated in a verifiable manner. Microkernels are uniquely amenable to such an approach, regardless of language.

Which I think is the major reason why memory allocation in seL4, including memory for in-kernel runtime objects, is handled in user space, otherwise its tentacles would make kernel verification intractable. And it's not just that allocation is handled by a single user space daemon; it bleeds into the entire architecture. AFAIU, any request you make of the kernel must be accompanied by the necessary memory needed to satisfy the request. This also fits nicely into the capability model.

Re:The SeL4 Foundation: What and Why by pron on Tuesday April 07, 2020 @05:55PM (#22807897)
> Exactly. And the solution is architectural modularization--implementing a solution as multiple components that can each be independently verified and then integrated in a verifiable manner.

That doesn't matter. I mean, you might be able to prove some properties in this way just as you could in others, but it is not a "solution" by any means -- it might work in some cases for some properties with some barely acceptable scalability, and that's about it. The reason is that the cost of reasoning about n components is not even a computable function of n (the cost grows in the same way if you were trying to prove the property on a monolith). See the blog post I linked to for a result that proved this, and an example of a case where two components are easily analyzed yet their composition isn't.

The main direction in formal methods research to increase scalability in a viable way is to reduce soundness.

Re:The SeL4 Foundation: What and Why by wahern on Tuesday April 07, 2020 @07:28PM (#22808589)
You can't refactor any implementation (i.e. shuffle code) into components and magically make verification tractable. But there's more than one possible implementation to any particular functional problem, and some of those implementations might be tractable.

AFAIU Component-Based Software Engineering has been a bedrock principle of applied formal verification for decades. It's a process approach. If a functional problem is sufficiently complex it's necessary, if not always sufficient, as a practical matter to use a component architecture. And even if it's not sufficient, a solution where some components are formally verified is better than where none are. Circumscribing soundness isn't an alternative, it's complementary.

You're right, it's not by itself a "solution" in the sense of completely resolving the problem; it's a "solution" in the other meaning of that word--a means of dealing with a problem.

Re:The SeL4 Foundation: What and Why by pron on Tuesday April 07, 2020 @08:46PM (#22809059)
> AFAIU Component-Based Software Engineering has been a bedrock principle of applied formal verification for decades.

Yes, and still the only software verified using such techniques has been tiny (< 10KLOC) and required extraordinary simplification and tremendous effort by specialists. It's like saying that particle accelerators have been a bedrock principle of turning lead into gold. It "works" but not in any sense that makes it a repeatable, affordable practice. Moreover, the gap between the size of programs verifiable in this way and the size of a "normal" piece of business software has stayed pretty much constant over the past four decades -- 3 orders of magnitude.

> And even if it's not sufficient, a solution where some components are formally verified is better than where none are.

Better in what sense? Is it better to soundly verify one component or to use unsound methods on an entire system (even assuming similar costs, but often the latter is cheaper). Soundness is costly and is never a real requirement as a software system is a physical system, anyway; machines only perform machine instructions according to spec with some probability, and probability is all engineers can ever hope for. But sure, sometimes there are small components that are easy enough to verify with deductive proofs, making it the most affordable path to high confidence, although I'd say that's the rare exception rather than the rule.

> Circumscribing soundness isn't an alternative, it's complementary.

It allows you to use automated methods that don't require careful modularity.

Re:The SeL4 Foundation: What and Why by simiones on Tuesday April 07, 2020 @10:20AM (#22803421)
It depends on what kind of guarantees you want, and how much you rely on the language versus programming style. But I think there are fundamental reasons that would prevent you from doing development in full Common Lisp and expect a formal verifier to statically check your code for complex properties (such as halting, bounded memory), and expect it to never reject a correct program.

Even with functional languages, the stronger properties you want to check, the more restricted the program must be. For example, Idris can ensure your program halts, but it requires you to write your program in a specific way that can be checked for halting, you can't just take any halting program and expect it to pass the halting checks.

Similarly, Rust's borrow checker can verify if your program is free of data races and memory leaks, but you must write your program following specific patterns, even if you can produce data-race and memory leak-free programs in other ways as well (of course, there is the `unsafe` block in Rust exactly for this reason).

Of course, there will likely be more improvements as time goes on, but the halting problem puts a fundamental limit on how expressive a language can be while also being amenable to (computable) proof of certain complex properties.

Re:The SeL4 Foundation: What and Why by steveklabnik on Tuesday April 07, 2020 @01:10PM (#22805177)
(Rust does not prove the absence of memory leaks)
Re:The SeL4 Foundation: What and Why by fpoling on Tuesday April 07, 2020 @07:46AM (#22802333)
Strictly speaking real computers are finite state machines and are trivially decidable from the halting problem point of view. The problem is that it just takes long long time.
Re:The SeL4 Foundation: What and Why by h91wka on Tuesday April 07, 2020 @09:11AM (#22802853)
This argument has been risen and dismissed in this thread already, no need to repeat.
Re:The SeL4 Foundation: What and Why by seb314 on Tuesday April 07, 2020 @08:49AM (#22802672)
> Such compiler would require solving halting problem.

I don't think so. As long as false-negative results are acceptable. (i.e. it is ok if for some programs no proof if found even though they fulfill the specification)

Occasional false-negatives seem perfectly fine for real-world use.

Re:The SeL4 Foundation: What and Why by opnitro on Tuesday April 07, 2020 @08:59AM (#22802747)
In fact all major type systems work this way.
Re:The SeL4 Foundation: What and Why by curryhoward on Tuesday April 07, 2020 @09:01AM (#22802771)
Not if the human provides the proofs and the compiler merely checks them (like in Coq, for example).
Re:The SeL4 Foundation: What and Why by h91wka on Tuesday April 07, 2020 @09:16AM (#22802897)
I specifically mentioned in my post that problems related to _proof search_ are undecidable. Coq's tactics for proof search are unreliable. They rely on timeouts and tend to fail ("omega can't solve this system").

So you're not arguing with my post.

Re:The SeL4 Foundation: What and Why by curryhoward on Friday April 10, 2020 @04:36AM (#22831118)
The question you were answering was not talking about proof search. It was merely asking whether it was possible to do verification in the same language that the program is written in. And, contrary to your response, it is possible to do verification in the same language as the program is written in. Coq is an example of that.

Yes, proof search is undecidable. But that's not what we're talking about in this thread. seL4 isn't verified by proof search. The proofs were provided by humans (with limited automation).

Re:The SeL4 Foundation: What and Why by wolfgke on Tuesday April 07, 2020 @07:45AM (#22802319)
> Such compiler would require solving halting problem.

Wrong: Because of the finite memory instead of an unbounded tape (among other reasons), computers are strictly less expressive than Turing machines.

Re:The SeL4 Foundation: What and Why by h91wka on Tuesday April 07, 2020 @08:46AM (#22802649)
This technically correct comment would be actually useful, if it linked a fully automated prover, that is capable of proving any property of a program that fits in N bytes.

If you remove infinite tape, you go from undecidable to "just" exponentially complex.

Re:The SeL4 Foundation: What and Why by wolfgke on Tuesday April 07, 2020 @08:52AM (#22802692)
> If you remove infinite tape, you go from undecidable to "just" exponentially complex.

Which is a huge leap - we got from "impossible" to "possible in principle" and we now can do research how to make it even "sufficiently fast" for problems of practical relevance.

Re:The SeL4 Foundation: What and Why by h91wka on Tuesday April 07, 2020 @08:58AM (#22802743)
No. In CIC I can prove that, say, some property is valid for _any_ natural number. Your "memory is bounded" argument is invalid, as formal proofs can go beyond that.
Re:The SeL4 Foundation: What and Why by h91wka on Tuesday April 07, 2020 @08:53AM (#22802699)
...Also I think you don't realize that formal inductive proofs can easily reason about programs operating with unbounded memory.
Re:The SeL4 Foundation: What and Why by wolfgke on Tuesday April 07, 2020 @09:15AM (#22802887)
With formal inductive proofs, you can reason, but not decide.
Re:The SeL4 Foundation: What and Why by tzs on Tuesday April 07, 2020 @08:27AM (#22802535)
Does the proof that the halting problem is not solvable actually make use of the unboundedness of the tape?
Re:The SeL4 Foundation: What and Why by naasking on Tuesday April 07, 2020 @09:00AM (#22802755)
Standard proof is a diagonalization, which depends on infinite sequences.

That said, the Halting problem on physical computers is still of extremely high computational complexity, which can be just as high a barrier as incomputability.

Re:The SeL4 Foundation: What and Why by wolfgke on Tuesday April 07, 2020 @08:49AM (#22802673)
Of course it does (implicitly!).

Otherwise the number of possible states of the Turing machine T that we want to check whether it halts or not is finite and we just have to "simulate" the program and see whether it terminates or it reaches again a state that it was already in.

Re:The SeL4 Foundation: What and Why by marcosdumay on Tuesday April 07, 2020 @01:34PM (#22805454)
How would the "if this program halts then run forever, else halt" algorithm work on a real computer? I imagine it would fail with stack overflow.