News for hackers. Stuff that matters.
Re:Why Don't People Use Formal Methods? by pytester on Tuesday January 22, 2019 @04:10AM (#18967047)
I think it's worse than that.

I did a course on formal methods at university. The 'spec' ended up being a lot more complicated than the actual program.

I wasn't really confident afterwards that the "proved" software actually did work.

I think it's possibly a suitable method for building very low level code (e.g. sorting methods) where the spec is going to be exceptionally simple but it's effectiveness drops off quickly the higher up the stack you go.

Re:Why Don't People Use Formal Methods? by mpweiher on Tuesday January 22, 2019 @04:46AM (#18967180)
I had exactly the same experience. We did specification in Z, but the code that was supposed to be "proved" correct was a clearer reflection of what we wanted to do than the "spec".

So I actually had more confidence in the code than I did in the spec.

And I think this answers the question of the OP: people don't use formal methods because

(a) the vast majority of problems don't start out with a formal spec

(b) the gap between informal and formal is vastly more relevant than the one between different formalisms

(c) formal methods are significantly worse at bridging the formal/informal gap than most programming languages

And yes, when you have a sub-problem that is mostly formal, then it can make sense, particularly if there's a lot riding on it.

Re:Why Don't People Use Formal Methods? by brazzy on Tuesday January 22, 2019 @05:37AM (#18967341)
> And I think this answers the question of the OP

Do you realize that the OP is actually linking to an article explaining this (and a bunch of other aspects) in great detail?

Re:Why Don't People Use Formal Methods? by mpweiher on Tuesday January 22, 2019 @07:07AM (#18967672)
While it's a good article, I didn't see it covering this aspect, particularly (c).
Re:Why Don't People Use Formal Methods? by marcosdumay on Tuesday January 22, 2019 @09:16AM (#18968350)
That's a problem with specs, the most concise and complete way to write them is by writing your program. If it wasn't, people would just compile the specs, and program using those.

Now, go tell this to people that want to offshore development based on a spec... But that's a digression.

You don't prove correctness of an entire program against the entire spec. That's only possible with toy problems, even entirely proved programs (like secL4) only prove some point of view, never the entire spec. Some times in a large program you discover a property that is very important (like how to assembly some event set into data, lack of deadlocks in a distributed system, or lack of buffers overflow), you then go and prove those properties.

Re:Why Don't People Use Formal Methods? by mattmoss on Tuesday January 22, 2019 @10:51AM (#18969109)
> That's a problem with specs, the most concise and complete way to write them is by writing your program.

I've never dealt with formal specs/design, certainly nothing like those described here. Your comment (however in/accurate) strikes me as interesting and leads me to wonder...

What if we took the code and processed it to generate a "spec"? (I quote "spec" here b/c I wouldn't consider it a spec, but don't know what else to call it.) Basically, a document that explains verbosely what the written code does... hopefully in a way that is reasonably, humanly digestable.

Then we might get a doc that says, "Function add(...) accepts two integers/nulls and returns the sum." And Joe-coder looks and realizes it shouldn't accept nulls, goes back to the code, fixes the issue.

Re:Why Don't People Use Formal Methods? by johnmaguire2013 on Tuesday January 22, 2019 @11:14AM (#18969316)
This is essentially what static code analysis attempts to do. Unfortunately, there are many ways of writing programs that today's static code analysis cannot understand.
Re:Why Don't People Use Formal Methods? by philipodonnell on Tuesday January 22, 2019 @11:03AM (#18969215)
If there was a rule that functions could only return named variables (vs expressions that evaluate to a value that is returned) it would get closer to "this function accepts paramName1 and paramName2 and returns sumOfParams".
Re:Why Don't People Use Formal Methods? by jononor on Tuesday January 22, 2019 @06:43AM (#18967586)
Would the code have been as clean and clear if you did not make the formal spec beforehand?
Re:Why Don't People Use Formal Methods? by pytester on Tuesday January 22, 2019 @07:16AM (#18967719)
Yes