An unofficial, read-only Hacker News reader.

The need for a formally verifiable mainstream programming language (opens external site)

338 points by todsacerdoti 1 day ago | blainehansen.me | 312 comments on HN

View full thread · View on Hacker News

Comment thread (7)

  1. 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.
    Replies (3)
    1. > 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.

      Replies (1)
      1. 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.
    2. 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.

      See also my comment here - https://news.ycombinator.com/item?id=50664740

      Replies (1)
      1. 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.
        Replies (1)
        1. 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;

          Faulty Logic: Reasoning about Fault Tolerant Programs - http://www.cs.princeton.edu/~dpw/papers/faultylogic_esop2010...

    3. > How program behaves when error happens is probably more important than happy path logic.

      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.