logoalt Hacker News

rramadass • today at 10:19 AM • 2 replies • view on HN

Your boss was not quite right.

There is a "Correctness-by-Construction" approach to programming which allows one to severely restrict the state space of a program from the beginning such that every statement/block/function only operates on a much smaller "valid" set of program sub-states. This is using classical logic via predicates as explained by Hoare Triples, Dijkstra's wp-calculus, Morgan's refinement calculus and later Meyer's Design-by-Contract.

To do deductive verification statically, the basic idea is to group all computation paths (i.e. sequence of state transitions) over the entire program state space into a much smaller set of logical constraints (aka verification conditions) which is then handed off to a SAT/SMT solver to be proved/disproved.

An alternative is constructive logic using types and lambda calculus as pointed out by a sibling commentator.

There have been lots of systems which have been formally proved/verified to various extents/levels as can be seen in Industrial-Strength Formal Methods in Practice by Hinchey/Bowen and many other similar books.


Replies

aenis • today at 12:29 PM

I think what he likely meant was: its impossible to do formal verification of programs the way they are written and deployed.

- ignoring how programs are written, they are usually compiled and linked, which introduces states unknown to the original programmer,

- ignoring how they are compiled, they are executed in environments with variability, including temporal; I remember tracing a problem related to a longer trace on one of the paths of the PCB, and materially different outcomes depending on which trace the signal happen to travel on (it was a high-frequency P-I-D controller, but for whatever reason the microcontroller could transmit the same signal on one or the other path). The particular bug was traced with a oscilloscope, by a graybeard, not algebra.

The way I see it, in order to get verifiability to actual programs, one would need to cover the state space of the entire system - algo, compiled binaries, operating system, hardware, and the weather on the other side of the planet for a good measure.

I am not an expert in the area, in any way - just a regular software dude. Appreciate all the responses in this thread!

➕ show 1 reply
drutaTushar • today at 11:07 AM

I don't think only verification is enough for safe programs. How program behaves when error happens is probably more important than happy path logic. Programming is layers of abstraction on top several more - unless all of them are formally verified - program can be never be truly verified. Think of different hardware, software, time, timezone, os/drivers/shell/vm/container/language runtime versions etc.

➕ show 2 replies