Show HN: Talos – 用于 Lean 的开源 WASM 解释器
Show HN: Talos – Open-source WASM interpreter for Lean

原始链接: https://github.com/cajal-technologies/talos

Talos 是一个用 Lean 4 编写的实验性 WebAssembly 解释器,被设计为一个连接执行与形式化验证的“机械守护者”。通过在评估和证明中使用统一的代码库,Talos 消除了同步独立规范的需求。 Talos 优先考虑推理清晰度而非执行速度,为 WebAssembly 提供了功能完备且可执行的语义。它利用最弱前置条件 (WP) 演算,使开发者能够以结构化、组合式的方式陈述并证明有关程序行为的定理,例如正确性和等价性。 该项目组织为一个模块化的单一代码库(monorepo),包含: * **解释器 (Interpreter):** 核心 Wasm AST、语义和 WP 策略层。 * **代码库 (CodeLib):** 包含提升引理和验证辅助工具的库。 * **程序 (Programs):** 存放具体验证任务的存储库。 Talos 目前专注于与高级语言(如 Rust 或 C)编译最相关的 Wasm 特性。尽管仍处于积极开发阶段,它提供了一个通过从后置条件反向推导来验证软件的强大框架。该项目基于 GNU AGPLv3 许可证发布,并需要 Lean 4 和 `wasm-tools` 环境。

对不起。
相关文章

原文

Lean Telegram

Talos is a WebAssembly interpreter written in Lean 4, named after the bronze giant of Greek mythology who guarded Crete — a mechanical guardian, built to enforce rules.

The same definitions that execute a Wasm program are the ones you reason about. There is no separate spec interpreter to keep in sync: evaluation and proof share a single codebase.

Work in progress. Talos is under active development. APIs and proof interfaces may change.

The goal is a feature-complete, executable semantics for WebAssembly that doubles as a formal object. You can:

  • Run programs on concrete inputs.
  • State and prove theorems about their behavior — correctness against a spec, equivalence between programs, properties that hold for all inputs — using Lean's proof tooling.

The interpreter is deliberately optimized for clarity of reasoning over execution speed. Talos aims for full Wasm coverage, but the immediate focus is on the subset of features that arise naturally from non-optimized, higher-level source code (Rust, C, etc.) — the semantics that actually matter when you want to verify what a program does, not how fast it does it.

Proof is the north star. Performance work belongs behind a separately proven-equivalent implementation.

Proofs in Talos are built on weakest precondition (WP) calculus — a predicate transformer semantics that lets you reason backwards from postconditions to the preconditions that guarantee them. This gives structured, compositional proofs for loops, branches, and function calls without re-unfolding the interpreter at every step.

Run a .wat module:

cd interpreter
lake exe runner samples/factorial.wat fact 5

Output: 120

Run with a fuel cap (default 1 000 000 steps):

lake exe runner --fuel 10000 samples/factorial.wat fact 5

See interpreter/samples/factorial.wat for a minimal example module.

Prove something about it:

interpreter/Interpreter/Wasm/Examples/Factorial.lean shows a complete correctness proof using the WP tactic layer.

Three Lake packages in a monorepo, forming a strict dependency chain:

Package Path Purpose
Interpreter interpreter/ Wasm AST, semantics, WP tactic layer
CodeLib codelib/ Lifting lemmas and program-reasoning helpers
Programs programs/ Concrete Rust-to-Wasm verification tasks

Depend on the interpreter only (Wasm semantics + WP calculus):

# lakefile.toml
[[require]]
name = "WasmInterpreterLean"
scope = "your-org"           # if published, or use path/git
path = "path/to/repo/interpreter"

Depend on CodeLib (adds lifting lemmas and reasoning helpers on top):

[[require]]
name = "CodeLib"
path = "path/to/repo/codelib"

Code that imports CodeLib never needs to import the interpreter directly — CodeLib re-exports the parts of the interpreter that downstream proofs need.

just build   # builds interpreter → codelib → programs in order

Or build a single package:

cd interpreter && lake build
cd codelib     && lake build
cd programs    && lake build

Dependencies:

  • Lean 4 — toolchain pinned in interpreter/lean-toolchain, fetched automatically by elan.
  • wasm-tools — needed to decode .wasm binaries and to run the Wasm testsuite. brew install wasm-tools or cargo install wasm-tools.

Running the Wasm testsuite

Filter to a specific file by name:

See CONTRIBUTING.md.

GNU Affero General Public License v3.0 — see LICENSE.

联系我们 contact @ memedata.com