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 (10)

  1. I agree with you in part, as I have lightly alluded to in my article. There's a lot to love! Lean's typeclasses + inference, metaprogramming, custom notation, "X implemented as Y" support, and much more are fantastic.

    It's not clear to me, however, that the space is completely filled. I find it hard to imagine using Lean for software that deeply interacts with the OS or hardware, or even just "doesn't refcount". Am I unaware of progress in this area? In a similar vein, in terms of practical software success, I think we've seen the most with model checking, yet Lean is not particularly amenable to this. It remains to be seen whether tactics and proofs (+ some sort of repair) will beat out the incumbent.

    Replies (4)
    1. I really liked your article, and I haven't read or absorbed all of it yet but I agreed with your points on this topic.

      I think Lean could perhaps serve in most server application use cases (and many others - roughly any use case where you could use Haskell), and Aeneas or something like it could leverage Lean only for verification. https://lean-lang.org/use-cases/aeneas/

      Replies (1)
      1. Absolutely. Libraries like servant in Haskell, too, relied on extensions to the language (was it data kinds and GADTs?) to make for some very, very sleek abstractions. Lean comes with these language features, but in a single unified type system, and it has even more goodies!
        Replies (1)
        1. What was surprising to me is that (at least some) Lean code is easier to understand than the machinery behind Servant, since you are just using normal code to operate on types.
          Replies (1)
          1. This to me is the single most mindblowing part of Lean that has not been fully taken advantage of yet: that types themselves are first class and fully programmable in a way indistinct from normal code

            And it compounds with Lean's dependent type system and the ability for proofs to be "bundled" into said dependent types and then erase at elab time

    2. I'm doing Lean 4 certificates for Armv9 assembly. It's doable.

      Update: Google did something similar here: https://deepmind.google/blog/introducing-alphaproof-code/

    3. Great article BTW, I think it was incredibly detailed and well written

      > I find it hard to imagine using Lean for software that deeply interacts with the OS or hardware, or even just "doesn't refcount".

      This is true: my thought is that the path to using Lean for "practical software" looks like delegating a lot of stuff like I/O to Rust libs. Lean will soon be able to compile to LLVM IR instead of just C and IMO it makes more sense to think about how to fill the gaps with the smartest cross-lang approaches rather than to rebuild a lot of basic stuff as pure Lean

      Replies (1)
      1. Thank you for your kind words!

        > my thought is that the path to using Lean for "practical software" looks like delegating a lot of stuff like I/O to Rust libs. Lean will soon be able to compile to LLVM IR instead of just C and IMO it makes more sense to think about how to fill the gaps with the smartest cross-lang approaches rather than to rebuild a lot of basic stuff as pure Lean

        I think this is the sort of approach we should pursue to make progress towards verification as an industry. But every time I write low-level code, and have to think through complicated cases, I feel that it is there that I need the most help. That's when I dream of a tool that can meet me at my level of abstraction and help me lean on rigor and verification. This is part of why mainstream verifiable languages have been on my mind personally, and I admit this implicit bias may affect the focus of the article and original claims.

        Replies (1)
        1. Apologies if you've already heard of it, but have you ever looked into the metamath0 project, specifically metamath C[1]? It's not super active, but the design tries to allow for low-level programming (goto, structs, etc) while still allowing for the full MM0 proof environment to prove program properties.

          [1] https://digama0.github.io/mm0/thesis.pdf, page 67, and https://github.com/digama0/mm0/blob/master/mm0-rs/mmc.md

    4. I think one aspect that real software cares a lot more but hard to formally verify is performance. Basic big-O is in the realm of mathematics and doable, but important details like cache locality, SoA versus AoS, compiler-guaranteed tailcalls and compiler-guaranteed strength reduction are all aspects that need to be tackled before we can formally verify software.