logoalt Hacker News

aenis • today at 6:53 AM • 7 replies • view on HN

30 years ago, my then boss, a PhD in industrial automation theory, told me formal verification of even simple systems is impossible due to the practically infinite number of states systems can occupy. I have been thinking about this a lot over the years, and I still think this is the case, even more so than before with the bloat that introduces insanely fuzzy edges to any state graph. I wonder if there is really any chance of this becoming a viable concept for systems more complex than a tic-tac-toe game.


Replies

rramadass • today at 10:19 AM

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.

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.

gf000 • today at 8:18 AM

I mean in most cases a mathematician is not going around and checking each and every case, why would software do that?

Formal verification a la cocq/Agda/lean works by constructive logic. (Disregard the middle paragraphs, I'm sure I'm not telling you anything new)

The type system is strong enough to encode various statements, even about variables (dependent type system, this is a valid type: a + b == b + a)

The only way to create an instance for this type is by proving the statement. The == type can only be created by trivially equal expressions, so it will accept a == a. So in the definition of the above you will go step by step, each step itself being accepted by the compiler, and at the end you get a proof and a compiling program, a bit similarly to how you would do it on paper.

So I guess it boils down to. Could a mathematician figure out some elegant proof for the system that somehow makes "checking each state" reduced to an easier statement? If yes, then formal verification can also do so. If no, then LLMs may be able to scale up what is feasibly provable, but there is no real alternative. Real world testing is just scratching the surface of the state space.

All in all, that's why it's paramount that systems are designed with complexity in mind. We can compose simple function into a simple function and have it explode in complexity, but it's also possible to choose good primitives that are easy to "mock out" (often both in practice and theory) and not significantly increase the whole system's complexity.

alexey-salmin • today at 7:48 AM

It's impossible to prove by brute-forcing the states of an arbitrary program, but it's possible on practice for programs that were built with verification in mind: pure functions wherever applicable, state invariants defined and verified for every stateful part. If you aren't able to prove a specific invariant at compile-time, you leave it as assertion which means you can still prove that either you get the correct output or an error, but never the wrong output or crash/vulnerability.

I think today it's actually more possible than ever. Writing programs in this way is hard and tedious but LLM can excel at that. I also think that a hybrid of Z3+LLM is orders of magnitude stronger than pure Z3. LLMs generated a formal proof of GRH, surely than can prove banking app correct.

The most vulnerable part that will remain will be the formalization of requirements. That's impossible to solve fully because you never know what the human had in mind exactly when he ordered the program to be written.

➕ show 1 reply
btilly • today at 7:51 AM

We're now able to do things like try to prove that no fuzz test with less than 32 MB of input will crash this program.

Formal verification of full behavior is impossible. But formal verification of important properties is within the reach of AI.

mahboi • today at 8:00 AM

Reminds me of pure functional languages. Sounds so nice, no icky state or side effects. Doesn't actually help for real problems.

➕ show 2 replies
Retr0id • today at 6:55 AM

It's possible to design with verifiability in mind (e.g. something like seL4)

anon-3988 • today at 9:08 AM

Haha no. I am sorry but we still have issues with null pointers. So lets not get ahead of ourselves and try to model the real world. People thinking "woe is me the world is so complicated lets keep using C" is bizarre.