151 points · by panic · 8y ago · 58 comments
I hope to live to see the day when lots of commercial software will be written with formal proofs and zero tests. It may just be that we don't have the right tools at this point. If theorem provers could figure out details for themselves for the most part and the programmer has to only specify a few key invariants and rough sketches of the hypotheses and the end guarantees then I cannot begin to imagine how much more productive programming can become.
Because only a vanishingly rare amount of the incorrectness in compiled C programs comes from a bug in the compiler.
Also, some code coaxes a desired behavior out of the object code while bending the rules of the language.
The compiler being proven over correct code (i.e. free of any undefined behaviors) is useless in that situation, unless the prover actually works with an extended language definition (specific to that compiler) which defines those behaviors.
True.
What I meant to say, but didn't, is, why aren't more people working on ensuring that this provability bubbles up from the compiler to the program itself. I come across a lot of work in specialized areas on this topic but haven't seen anyone have a go integrating formal proofs and a widely used programming language. At the moment this looks like a pipe dream because of the obvious objection (and I hope this disappears "soon") that currently it is too cumbersome to have to prove your programs, let alone write them in the first place.
There cannot be a formally logical explication of code for even "common sense problems", like, say, how to safely drive a car. It doesn't exist because it's probably impossible but it's at least not feasible. Instead we use sampling of real world data to train models to solve this problem. This is the story of Data over Logic.
A complete formal specification of simpler programs or program components -- say banking systems or specific controllers in the car -- are not only possible and feasible but actually used in practice. A good number (I don't know if it's the majority or not) of avionics programs are formally specified and verified (although normally using model checkers rather than proofs). Having said that, different kinds of software can benefit from formal methods to different degrees. I'd say that if you can write tests for it, then you can write at least partial specs for it, too, but whether or not doing so is worth it varies by circumstance (in the cases I've used formal methods recently, it was not for more correctness but actually because it was cheaper than tests).
Also, we must separate formal specification from formal proof. Formal specification means writing what the program must or must not do in some precise formal language. Formal proof is one of many forms of verifying that specification. It provides the most confidence, but it is also by far the most expensive. Most programs can benefit greatly from formal specifications but can settle for weaker, but far cheaper, forms of verifying them.
Utter nonsense. Formal proofs are specious because you can't do a formal proof of problems that are so ill-defined, we don't even have algorithms that solve them in enough cases to be road-safe yet? If you restrict your focus to software that actually exists, almost all of it is amenable to formal modeling.
Have you read anything about CompCert C or Coq?
Not exactly, but if we look at it that way, how is it wrong?
I write buggy software; what do you write?
With the approach I take to writing software, the methods by which I flush out my bugs find compiler issues also in the same stroke.
If I didn't write buggy software, I could ditch testing, right?
Except, oops, not without a proven toolchain.
Why people don't seem to worry as much about self-driving cars boggles the mind. One hopes the loss of human life would be as concerning as the loss of money. I think the issue is partly technological. As Leroy says, formal methods for certifying machine learning-produced models are pretty undeveloped whereas cryptocurrency protocols are 'traditional', 'algorithmic' programs and so more amenable to analysis with existing verification tools. I also think it is partly cultural in that machine learning practitioners seem often to be less aware of formal methods and the possibility of verifying software.
The real reason is that the solution to this problem isn't valuable to most people that have the resources to pay for a solution. Most bugs aren't caused by issues in the C compiler.
There are many technically challenging, interesting problems that face a similar predicament. The people who solve them will generally find some way to tie them back to reality.
I think the most taught languages are still Java and python by far.
I really liked this language though, it's very elegant and concise to write cs-related algorithms, and to do symbolic manipulation.
I never understood this. OCaml is a world-class language, if the French threw the weight of their education system behind it, mandated it as the language for government IT work to build a critical mass, they would have a killer advantage. But I guess the demise of Le Minitel has made them afraid of home-grown technologies, it is a huge missed opportunity.
It's the same as if the British government had had the foresight to back the Acorn ecosystem. We would be 15-20 years ahead of where we are now. An Archimedes on every desktop...
I remember my thought when i was taught oCaml : we had to recode ocaml type inference, in ocaml. The teacher was really satisfied in the end , saying things like « that’s good ! Now you see, type inference is like a theorem proof ». It took me ten years to understand what i did this day, and what my teacher meant.
When i was a student, i wanted to program videogames ( like many cs student i suppose), so all this research and very theoretical concerns were very very remote from my interest. Ocaml was a weird thing that had very little to do with my future everyday job.
And now i start to look at F# for web development, thinking that the whole stuff is just beautiful.
Not everyone might be familiar with the name
Since 2012 most students learn Python, which is a shame IMHO. Learning OCaml will make you a better programmer for the rest of your life, while learning Python doesn't teach you much about programming.
(In fact it's another way around : I learned basic at 10, assembly at 14, pascal at 16 then I learned Scheme (continuations, tunks, parallelism, etc) at 22 at university and realized "now I understand what I've been doing the last 10 years)
I once tried to teach Python to biologists. It's also enlightening - many people don't "get" programming of any kind (except perhaps spreadsheets ;-).
If you already get it, then of course a different paradigm will shine new light.