69
43
As a software engineer, I write a lot of code for industrial products. Relatively complicated stuff with classes, threads, some design efforts, but also some compromises for performance. I do a lot of testing, and I am tired of testing, so I got interested in formal proof tools, such as Coq, Isabelle... Could I use one of these to formally prove that my code is bug-free and be done with it? - but each time I check out one of these tools, I walk away unconvinced that they are usable for everyday software engineering. Now, that could only be me, and I am looking for pointers/opinions/ideas about that :-)
Specifically, I get the impression that to make one of these tools work for me would require a huge investment to properly define to the prover the objects, methods... of the program under consideration. I then wonder if the prover wouldn't just run out of steam given the size of everything it would have to deal with. Or maybe I would have to get rid of side-effects (those prover tools seem to do really well with declarative languages), and I wonder if that would result in "proven code" that could not be used because it would not be fast or small enough. Also, I don't have the luxury of changing the language I work with, it needs to be Java or C++: I can't tell my boss I'm going to code in OXXXml from now on, because it's the only language in which I can prove the correctness of the code...
Could someone with more experience of formal proof tools comment? Again - I would LOVE to use a formal prover tool, I think they are great, but I have the impression they are in an ivory tower that I can't reach from the lowly ditch of Java/C++... (PS: I also LOVE Haskell, OCaml... don't get the wrong idea: I am a fan of declarative languages and formal proof, I am just trying to see how I could realistically make that useful to software engineering)
Update: Since this is fairly broad, let's try the following more specific questions: 1) are there examples of using provers to prove correctness of industrial Java/C++ programs? 2) Would Coq be suitable for that task? 3) If Coq is suitable, should I write the program in Coq first, then generate C++/Java from Coq? 4) Could this approach handle threading and performance optimizations?
I would also suggest at looking at Eric Hehner's 'A Practical Theory of Programming', which he offers online for free. (http://www.cs.toronto.edu/~hehner/aPToP/) His theory doesn't have a proof assistant to my knowledge, but for software development I believe it has a greater potential since you could refine a program as you prove its correctness.
– Francesco Gramano – 2016-09-27T17:59:16.2733I get and appreciate your problem, but I don't understand what this question is after (as an SE post). Discussion? Experience? Neither is suitable for SE. The "Whatever can I do?" tone makes me feel this is too broad a question, too. – Raphael – 2013-08-17T12:13:26.597
3I see... I agree this question was not formulated clearly. So, let's say: 1) are there examples of using provers to prove correctness of industrial Java/C++ programs? 2) Would Coq be suitable for that task? 3) If Coq is suitable, should I write the program in Coq first, then have Coq generate C++/Java from that? 4) Could this approach cope with threading and performance optimizations? – Frank – 2013-08-17T15:03:22.947
2So that's four questions, then. 1) is probably better off on [programmers.SE] since you are unlikely to run into (many) industry professionals here. 2) tastes somewhat subjective, but we may have people here that can offer an objective perspective. 3) is, as far as I can tell, completely subjective. 4) Is a nice questions for this site. In summary: please separate your questions, go to [programmers.SE] with the first and think hard on whether you can expect an objective (!) answer here (!) before posting 2). – Raphael – 2013-08-18T10:57:08.040
1IMHO, 3 is not necessarily subjective: I do not know if it is possible/efficient to generate code from Coq. I would like to know if someone has done it/can share their experience. 2) IMHO is a little bit of the same. It would be great to get feedback, for example that Coq is not suited for that, but Krakatoa is (maybe) :-) – Frank – 2013-08-18T14:52:36.017
10You're describing the dream of formal verification, but we're very far from being there. AFAIK, program verification is a non-routine task, and only applies to very simple programs. That said, I think that this question is spot-on for the site, and I would appreciate someone from the area admitting the limits of their field, explaining the state-of-the-art and the limitations (perhaps by linking to some survey). – Yuval Filmus – 2013-08-19T00:27:04.747
9The trouble with verifying C++ programs is that C++ is not a well-defined language. I do not think large-scale verification is possible until many parts of software systems (OS, libraries, programming languages) actually get redesigned to support verification. As is well known, you cannot just dump 200000 lines of code on someone and say "verify!". You need to verify and write code together, and you need to adapt your programming habits to the fact that you're also verifying. – Andrej Bauer – 2013-08-21T11:13:56.723
1
some tiein to this TCS question, "how to create mission critical software"
– vzn – 2013-08-22T15:45:34.167