hn.today

Show HN: Zean Transpiles Zig to Lean

github.com7 points1 comments
Screenshot of Show HN: Zean Transpiles Zig to Lean

Zean is an experimental tool for translating selected Zig functions into executable Lean models, so developers can state desired behavior and prove properties about those models. It captures Zig’s analyzed intermediate representation, generates Lean definitions, and uses Lean 4’s weakest-precondition and verification-condition machinery to create proof obligations. Users provide contracts and loop invariants, then prove the remaining claims. Supported translation profiles cover limited scalar operations, memory, loops, aggregates, and byte-oriented cases; the project explicitly does not claim general Zig support.

Examples demonstrate proofs of bounded counters, safe buffer updates, copying into initially uninitialized memory, and concurrent publication of a dispatch table. They also show how faulty edits can expose overflow, invalid reads, or out-of-bounds writes. Generated models can be refreshed after code changes, while handwritten proofs remain separate. For some translation profiles, an additional certificate checks that the Lean model corresponds to captured AIR. The guarantees apply to execution in the selected model, under explicit caller assumptions; source admission, capture instrumentation, the Zig frontend, and native code generation remain trusted boundaries. Thus, the demonstrations establish useful, scoped verification results rather than proving the Zig compiler correct. The repository includes tutorials, captured examples that can run without an instrumented compiler, and instructions for capturing and checking new functions.

Read on github.com1 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Programming

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.