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.
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.
> Think of different hardware, software, time, timezone, os/drivers/shell/vm/container/language runtime versions etc.
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.
It can definitely help if scope/runtime is limited. I myself have played with something similar : https://github.com/statelyai/xstate Modelling entire interaction as state machine so program always remains/lands in known states. IMO FSMs probably better suited as it has error modelling and handling inbuilt.
That is the wrong way to think about Formal Methods/Specification/Verification.
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.
Partially I agree. But when it comes to errors/not-happy path - I am talking about pesky issues, driver/hardware errors which can never be mapped to any "Type". There is a reason every statically-typed programming language has Root Error type. For eg. Java has `Throwable` with two subtypes - `Error` and `Exception`. A `RuntimeException` is type that does give handle to programmers and JVM guarantees that it will be thrown. But sometimes one has to catch root "Throwable" or "Error" types in order to prevent JVM crash. It will be tedius to have formal verification theorems referring to "Throwable" in order to be formally verifiable. I guess It can be done - only if languages like Lean are expressive enough - but only using LLMS, for humans it will be quite complex. IMO - not worth. It will be repeat of "elegant" functional programming languages failing to go mainstream.
My previous comments already pointed to Meyer's "Applying Design by Contract" paper which shows how to integrate exception handling with DbC. Here it is directly - https://news.ycombinator.com/item?id=48358691
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;
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!
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.
Which level do you mean? If you mean EALs, to my knowledge, even the highest level never meant to be verification of the implementation but verification of the design.
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 (2)
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...
- 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 (1)
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)