The need for a formally verifiable mainstream programming language (opens external site)
View full thread · View on Hacker News
To get push notifications on iPhone or iPad, add Hack and Chat to your Home Screen: tap Share → Add to Home Screen, then open the installed app and enable push in Settings.
View full thread · View on Hacker News
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 (2)
Replies (3)
The original comment was about industrial automation and in that environment a lot of those issues are not that relevant. Unless we're talking really big systems, a lot of it is very well specified controllers which run without shell/VM/container/runtime. They just talk to some fancy general GUI on a different chip/board to load the data/config. But the state space of a lot of actual practical hardware doing the work is not that complex. Bare metal, careful io timing, state transitions and some control loops gets you very very far.
To be clear, there are bigger, complicated systems, but simpler devices with a clock, PID loop and I2C outnumber them by likely a few orders of magnitude - we can start there.
Replies (1)
Verification is not about "happy path logic" but all computation paths (happy, error, cross-layer etc.) over the entire state space of a "system".
The system can include everything from hardware circuits all the way to distributed applications if needed. Across layers/components it works by composition of contracts where a higher-layer guarantees based on its lower layer's contract guarantees. The book i listed gives examples.
See also my comment here - https://news.ycombinator.com/item?id=50664740
Replies (1)
Replies (1)
Basically, you have to keep your module internals "pure", distinguish between domain exceptions (i.e. checked) vs. environmental runtime exceptions (i.e. unchecked) and push all "impure" operations to the boundary of the module.
Also see the following paper which shows how to formally model hardware faults;
Faulty Logic: Reasoning about Fault Tolerant Programs - http://www.cs.princeton.edu/~dpw/papers/faultylogic_esop2010...
WTH is "happy path logic"? Formal verification's main feature and selling point is the guarantied safety of absolutely all paths, the happy path stuff is what testing does, you're confusing these quite hard.
> Programming is layers of abstraction on top several more - unless all of them are formally verified - program can be never be truly verified.
Yes, all of them are formally verified, the bots doing the verification get neither bored nor tired.
> Think of different hardware, software, time, timezone, os/drivers/shell/vm/container/language runtime versions etc.
I don't have to think about these, the bots handle them one by one, mainly by porting re-wrting in a manner that allows formal verification. There is a formally verified OS - even verified by hand long time ago - nowadays it's a lot easier.
- 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!
Replies (2)
It depends upon what all parts of a "system" you want to encompass under "formal verification". There is nothing preventing you from verifying everything from hardware all the way to user-facing software or only certain layers in the chain.
As an analogy, the FIPS/Common Criteria security standards have multiple levels of certification going from simple signed binary blob to a complete hardware and software lockdown system.
You can do the exact same thing with formal verification of your system if needed. LLMs have made this possible if driven properly.
Replies (1)
He meant wrong, nowadays you just ask an LLM to re-write with proofs and redeploy.
> I remember tracing a problem related to a longer trace on one of the paths of the PCB... but for whatever reason the microcontroller could transmit the same signal on one or the other path
It's not clear what the issue was there but there are two possibilities (1) a software bug - only the pin connected to the short path should've been used by the program - easily caught by formal verification. (2) Analog/board design problem - these are resolved by proper safety margins and their state space is quite small - AI can redo the hardware with proper guarantees too.
> 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
No need to be scared, all of these are easily handled separately.
> and the weather on the other side of the planet for a good measure.
Formal verification provides proofs for any weather, on any side of any planet in the galaxy. It can even design systems that are solar-weather and star-weather proofed... if you can afford to actually implement them. Let me stop here, I don't want to scare you even more with stories about what some stars, even distant ones, can do to our planet. Yeah, life's tough.