An unofficial, read-only Hacker News reader.

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

343 points by todsacerdoti 2 days ago | blainehansen.me | 320 comments on HN

View full thread · View on Hacker News

Comment thread (3)

  1. You can quite easily implement static proofs for cases like the example in your second paragraph, using any language with a good enough type system.

    I vibe-coded a quick demo for that example (as I understand it), using Haskell because it makes such types easy and concise to prototype. Here it is: https://privatebin.net/?e19355429d608268#6vnv5LgavBnpM8NEfk7... (link will expire in a couple of days.)

    This uses phantom types (type parameters that aren't associated with values) like `Human` and `Agent`, as well as using GADTs, but that just makes for a clean/concise example - neither of those features are essential for something like this. You could implement it in say, Go or Java, it would just be a little noisier.

    It really isn't necessary to jump to Lean, and all the extra work that that entails (including linking to the actual code), to statically enforce such properties.

    This is an example of what Yaron Misky described around 2010 as "make illegal states unrepresentable", or really even what Robin Milner described in 1978 as "well-typed programs don't go wrong", although the latter assumes that "well-typed" means that the program's types match its specified constraints.

    Replies (1)
    1. Fair point, and thank you for the example! But I'm not only trying to guarantee types in one program. I'm trying to reason about a whole system with many actors and operations: a registry, a DNS root, chains of certificates (issued by the org's root or by another person, never by an agent, and not revoked), revocation, key replacement, delegation. The full catastrophe.

      The Lean theorem is that in the model, no sequence of operations, by anyone, ever yields a chain from an agent to a valid person. That's an induction over every possible history, which a type checker doesn't do.

      It's been invaluable for us. It lets us think in a structured way and explore scenarios without writing all the code. It found design flaws before any code existed, and it lets us prove that things must be possible, not only forbidden.

      I believe this kind of approach is going to be critical in security thinking (I think AWS's Cedar is doing more or less the same).

      Replies (1)
      1. I was going to add a comment about this possibility, but I didn't want to get carried away without knowing more.

        If you control the code for the systems you're talking about, then you can still use approaches like this if the communication between them involves cryptographically signed claims. So service 1 sends a request to service 2, with a signed claim that e.g. identifies the user as a human or agent, or whatever property you want to communicate - cert issued by an org's root, or whatever else has been validated by the source system. On the receiving end, you convert those claims back into their typed representations. This effectively allows static typing guarantees to be reliably extended across distinct services.

        But, it sounds like you might be describing something that this might not satisfy. In that case, I'd be interested to understand the details better - it seems to me that anything Lean can prove about a system ought to be encodable using techniques like these.

        > It lets us think in a structured way and explore scenarios without writing all the code. It found design flaws before any code existed, and it lets us prove that things must be possible, not only forbidden.

        Prototyping with code like the example I linked can provide these benefits as well, with much less effort imo. But, I may be missing something.