Unofficial Hacker News companion — get notified on comment replies, and more.

So you want to build a mainstream formally verifiable language (opens external site)

119 points by mpweiher 2 days ago | danilafe.com | 82 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (5)

  1. The article addresses this - there are two different models and they have different pros and cons - probably there is not a single model that is best for every use case. Lean - used alone - would be the intrinsic model. Lean, or another formal language, bridged to a programming language (like the Aeneas project with Rust https://lean-lang.org/use-cases/aeneas/) would be the extrinsic.

    I haven't gotten far enough into this to really speak knowledgeably about this, but my intuition suggests that the intrinsic model has some significant advantages - specifically it encourages/forces you to model all your invariants in a dependent type system in the first place, and then you can prove things about the interaction of those invariants in a higher abstraction layer that is continuously checked as the program evolves.

    A language without a dependent type system is significantly constrained in the invariants it can prove in its type system alone - perhaps there are properties you'd have to prove with (pure) unit tests to supplement the type system, and this further constrains design.

    Replies (1)
    1. > A language without a dependent type system is significantly constrained in the invariants it can prove in its type system alone

      I mean, no? Sure, you can't prove that some user function doesn't make a syscall that under the hood allocates on page, for example, but you can certainly derive invariants (like safety guarantees) based on stdlib usage, and report if a stray syscall or ffi occurs for manual review. You could also maintain a list of "cleared" syscalls/ffis that the prover should just ignore moving forward.

      As for other things, you're going to have to annotate your software in general. Be that in comments, some sort of metadata tag, even some in-tree manifest file. For example rust does not encode "this is a database call" in its type system. So if you want to instrument your code to verify that no consistency errors can occur (for example, not wrapping a read-modify-write in a transaction) you can't just do it by analyzing the language, you'll have to write your "own plugin". That's why having access to the IR (versus the asm) is better, because you have access to metadata that gets chucked out the window when it goes to asm.

      Replies (1)
      1. > For example rust does not encode "this is a database call" in its type system.

        Right, and some languages - like Lean - can do that.

        Replies (1)
        1. I'm not convinced that having a theorem prover be a PL is a good thing. Its like the old laser disc+vhs combo. Not good because if one side breaks down you have to go get it repaired and you dont have the other side either. Right tool for right job.
          Replies (1)
          1. What does "breaking down" in your analogy look like here in the case of Lean?

            Lean's kernel/checkers are modular so you can interchange them or rely on multiple ones for further correctness.