ɛ∞ɜɛ∞ɜ

Learn · Lasm · Start here · 2026-11-02

AI-generated. Written by AI (Claude) from the Lasm repository and published automatically. Source · Report a mistake

What Lasm is and how it's tested

What Lasm is

Lasm compiles Lean 4 to WebAssembly. Lean is a functional programming language and a proof assistant. You write an app in Lean, prove what matters about it, and run the compiled program on Node.js, Bun, Deno, Cloudflare Workers, Vercel, Netlify, Deno Deploy, Supabase, AWS Lambda, Azure Functions, Google Cloud Functions, Fastly Compute, WASI runtimes and the browser.

npm create @lasm@latest my-app -- --template hono
cd my-app && npm install && npm run dev

The README has the full platform table, with how each platform is tested and the version that added it.

How it's tested

The question that matters for a compiler is whether the compiled program does what the Lean program means. TESTING.md describes each layer of testing, what it can catch, and what it can't. The main ones follow.

Black box first

The strongest tests use Lasm only the way a user does. That means the packed or published @lasm/cli, the templates lasm init writes, and what the output does: a program's stdout, stderr and exit status, a server's HTTP responses, and a browser app's DOM. A test like that survives refactoring. It also can't be satisfied by the implementation's own assumptions.

Differential testing against upstream Lean

For compiled Lean, there is an oracle: upstream Lean itself. A generator writes random, well-typed Lean programs. They cover big numbers at the 2³² and 2⁶⁴ boundaries, fixed-width integers, floats, Unicode strings, lists, arrays, hash maps, recursion, do-notation with state and exceptions, tasks and files. Each program is built twice:

Stdout, stderr and the exit status must match exactly. Every divergence is shrunk to a small program and kept as a regression test. Since PR #36, the same programs are also checked three more ways:

On every pull request this is three seeded program pairs, 525 cases. Every night it is a 60-minute campaign in each build profile (differential.yml).

Differential testing has found real bugs. Each one is written up:

Target equivalence

One server (the fetch template), built for Node, Deno, Bun, wasi-http and Workers, must answer a recorded set of requests the same way on every target: the same status, headers and body bytes. This found a request path that routed differently on different platforms. Its fix comes with a theorem (new in 0.3.9).

Model checking the host bridge

On Node, Lean threads and JavaScript talk through shared memory. A Lean model of that protocol is checked over every interleaving up to its bounds. Schedule fuzzing then perturbs the real JavaScript, and the operations it records are checked against the model (PR #37). This work found a real hang.

The scenario matrix

The templates, built for their --targets on Linux, macOS and Windows, from a packed or published package, never from the source checkout. Each platform is served by its own local tooling: workerd through wrangler dev, Viceroy for Fastly Compute, AWS's Lambda images, wasmtime, Spin, and the others. CI never deploys to a real cloud account, so "tested" means the platform's local tooling, not production.

Proofs and real apps

Lean theorems are checked in CI with #print axioms, so a sorry can't hide. Conduit runs RealWorld's official suites on every platform (Conduit on 18 platforms).

Upstream's own tests

Lean's own test suite runs through the installed package, nightly and before each release.

What testing can't show

Each layer in TESTING.md lists its blind spots. For example, differential testing can't catch a bug that native Lean and Lasm share. Target equivalence can't catch behaviour its requests don't exercise. And no layer tests a real cloud account.

Start

Sources

More from Learn LasmAbout Lasm