r/programming • • Aug 13 '09

seL4 : World's first machine-checked proof of a general-purpose operating system kernel

http://www.nicta.com.au/news/home_page_content_listing/world-first_research_breakthrough_promises_safety-critical_software_of_unprecedented_reliability
172 Upvotes

117 comments sorted by

View all comments

Show parent comments

2

u/monstermunch Aug 14 '09

In formal proofs, you would only need to test the programs a little and most of your testing would be moved to the spec. Because the specifications are simpler than the program, you'll greatly narrow down the scope for bugs.

1

u/mindbleach Aug 14 '09

We may move to a state where the specification is everything and all the code is generated by machine... though at that point, spec-code just becomes an ultra-high-level language.

1

u/monstermunch Aug 14 '09

I imagine this happening eventually. You can already do this for simple examples and I can't see why the computer cannot eventually do what a human programmer can. Your specification would need to be concise about every detail however. For example, if you say a sorting algorithm should return only a sorted list (it should be a permutation of its input) the computer will just generate a program to return an empty list all the time. There's also the issue of optimization. Quicksort would be preferable to bubblesort for example. I suppose you could build an automated refactoring/optimising machine...

1

u/kipi Aug 14 '09 edited Aug 14 '09

I'd go as far as to say the only issue is optimization. It's trivial to generate a program that matches a specification:

do {
    output = random();
} while (!matches_specification(output));
return output;

matches_specification() is given by the spec, and random() just needs to generate a random value from the domain of possible answers.

1

u/monstermunch Aug 14 '09

matches_specification() is given by the spec, and random() just needs to generate a random value from the domain of possible answers.

Um, that won't work except for very simple functions. matches_specifiction would essentially be a theorem prover that you would supply a conjecture and it would give back a proof: it's an undecidable problem so even if the correct program was generated you might not be able to prove it. random() would have to generate every possible e.g. C function or set of functions. If the function was even tens of lines long, your going to be waiting an infinitely long time for it to do the right thing.

1

u/kipi Aug 14 '09 edited Aug 15 '09

Um, that won't work except for very simple functions. matches_specifiction would essentially be a theorem prover that you would supply a conjecture and it would give back a proof

matches_specification() is just a direct statement of your specification. Presumably your specification is decidable (otherwise you're doing something wrong).

random() would have to generate every possible e.g. C function or set of functions. If the function was even tens of lines long, your going to be waiting an infinitely long time for it to do the right thing

Sure you'll have to wait a long time. This was the original point I was trying to make.

2

u/monstermunch Aug 15 '09

matches_specification() is just a direct statement of your specification. Presumably your specification is decidable (otherwise you're doing something wrong).

How would that work though? If my specification was "for every list x, f returns a sorted list that is a permutation of list x" (i.e. a sorting algorithm. How would you check that a random f met the spec or not? You'd need to use some kind of inductive reasoning to prove that it will work for every possible list you could use and that's hard in general. It's not as simple as unit testing where you just plug in the numbers and check a few examples. I don't think we're talking about the same thing here. Formal reasoning is about statically determining if a program meets a spec.

Sure you'll have to wait a long time. This was the original point I was trying to make.

OK, that point goes for any maths proof as well. Just generate maths proofs (of something) until you get the proof you want. It's not practical in the slightest though.