Show HN: Talos – Open-source WASM interpreter for Lean

github.com

60 points by mfornet 23 hours ago

At Cajal (YC W26) we’re excited to share Talos (https://github.com/cajal-technologies/talos), an open source framework for formal verification of WebAssembly modules in Lean.

AI is now writing tons of the code that gets pushed to production. As code generation gets cheaper, verification becomes the bottleneck. We believe in a future where every piece of software comes with a mathematical proof that it does what its author intended - in doing so, eliminating many classes of exploits. Talos is part of the foundation for that.

Talos provides a Wasm interpreter optimized for reasoning at the binary level, together with a weakest-precondition calculus layer for proving properties about programs. Because we reason directly about WebAssembly, any language with a Wasm backend is in scope: Rust, C++, Go, C, Swift, Kotlin, Zig, C#, and many more.

To make this possible, we use Lean: a programming language and theorem prover that lets you both write software and mathematically prove that it's correct - all in one system. That's what lets Talos double as both an executable interpreter and the formal object Lean reasons about. Lean also integrates with modern AI proving tools, discharging goals automatically via both proof search and direct evaluation.

To see Talos in action check out a proof for Stein's GCD algorithm, implemented in the popular Rust crate num-integer: https://github.com/cajal-technologies/talos/blob/main/progra....

Our roadmap:

- Full Wasm coverage by first passing the official W3C testsuite, then later verifying against SpecTec (formal Wasm spec) - Arbitrary crate verification - any Rust crate that compiles to Wasm should be in scope - Building our proof library codelib, to make verifying increasingly complex programs tractable

We would love to hear the community’s feedback on Talos and comments on the state of formal verification right now. Contributions are also welcome!

jacobjwalters 2 hours ago

What is the program logic used here? The num_integer verification example seems to be hardcoding addresses in the spec; what if I want to reason about larger programs that dynamically allocate, where the addresses may not be known statically? How can I make sure these do not overlap? And since this is a shallow embedding into lean, what’s the approach for verifying properties of non-terminating programs?

  • mfornet 6 minutes ago

    > what if I want to reason about larger programs that dynamically allocate, where the addresses may not be known statically? How can I make sure these do not overlap?

    We are actively working on this, as it is a pre-condition :P to reason about the simplest of useful programs. The idea is to develop an API around separation logic that allows you to reason about logic that manipulate non-overlapping regions of memory.

    It won't be relevant if address are not known statically since API theorems will be parametrized over non-relevant constants such as addresses, function indices, etc...

    > And since this is a shallow embedding into lean, what’s the approach for verifying properties of non-terminating programs?

    To use the interpreter there is the concept of fuel, which we explicitly hide from the reasoning layer. Using fuel you can write statements of the form, this function returns out of fuel for any value of fuel passed to the interpreter, which is equivalent to prove that your program doesn't terminate.

sohex 26 minutes ago

Do people just not even search their proposed name anymore?

lukerj00 21 hours ago

I’m on the Cajal team - not OP, but happy to answer questions.

The core bet is that Wasm is a good verification target (close to compiled artifacts, many languages target it), and Lean is the right place to do verification.

Super interested in hearing from people working with Lean, compilers or other Wasm verification frameworks (eg Iris-Wasm).

  • kdavis 6 hours ago

    What other verification targets did you consider?

    • mfornet 1 minute ago

      Initially we considered formalizing rust code, aeneas is a very promising project that would unlock a lot of features right way by transpiling to lean. However, we didn't want to lock ourselves to rust, so we decided to use a lower level target such that we could verify code from "any" language.

      We considered LLVM-IR, and RISC-V.

      Ultimately WASM felt like the right decisions. More importantly WASM spec is very well done in details, and it is written with formal verification in mind early on, and there are are plans from to include Lean as one of the targets for generating the spec automatically from SpecTec. Once this exist, we will formalize that our interpreter is correct under the definition generated from the official Wasm-Lean-Spec so we remove it from the Trusted-Base going forward.

quietusmuris 19 hours ago

Interesting. Do I have to write specs in Lean against the Wasm semantics or can you annotate Rust directly?

CurryFurry 3 hours ago

For "Lean"? LeaRn? Lean Manufacturing? Stupid one-word techbro product names.

  • johnsonjo 51 minutes ago

    Lean is a programming language [1]

    > Lean is an open-source programming language and proof assistant that enables correct, maintainable, and formally verified code

    [1]: https://lean-lang.org/