Show HN: Zean Transpiles Zig to Lean github.com · 6 points · 1 comments · HN thr...
HN Best 200 @best
Show HN: Zean Transpiles Zig to Lean github.com · 6 points · 1 comments · HN thread
TL;DR Zean is an open-source project that translates Zig functions, captured from the Zig compiler's analyzed intermediate representation (AIR), into executable Lean 4 program models. Users write contracts and proofs in separate Lean files, and a reusable verification library generates memory-safety proof obligations that must be discharged. The project is an early release, was largely written with AI assistance, and comes from formal verification work on oksolc, a Solidity compiler written in Zig.
- Zean captures Zig AIR and emits Lean program definitions; the model is incomplete and translation is limited to supported operations.
- Memory-safety obligations are generated with Lean 4.35's Std.WP and vcgen; users supply contracts and loop invariants and discharge the rest.
- Tutorials cover a byte counter (proving it returns min(x+1, 255)), a buffer update that changes exactly one element, a loop-based copy, and a standard-library replaceScalar specialization.
- Ten translation profiles (scalar, memory, loops, aggregate, word-bytes, calls, recursive-calls, etc.) describe admitted AIR, not general Zig support.
- Trust boundaries remain explicit: source admission, the Zig frontend, capture instrumentation and the native backend are trusted, so model proofs do not establish whole-compiler correctness.
- Capture requires an instrumented Zig compiler built from a pinned Zig release; the examples run with an ordinary Zig install, and the project targets Zig 0.17.1 with Lean v4.35.0.
Discussion The thread is very short, with a single comment from the project's main author rather than an open discussion. The author explains the motivation: they are betting on Zig because its relative simplicity suits AI agents writing code, and they argue that Rust's memory-safety bugs make Zig a more tractable target for Lean proofs. They also note that Zig's tooling makes it practical to iterate with agents first and add Zean-based verification once the code stabilizes, and that writing whole projects in Lean is hard because the toolchain is immature. The mood is informational and promotional; no outside commenters have weighed in.
- Zig's simplicity makes it a better target for AI-written, verifiable code (a few): The author argues that AI agents produce code more reliably in simpler languages, and that Zig's simplicity makes proving properties in Lean more feasible than in Rust, which has had its own memory-safety bugs.
- Verify in Lean only after code stabilizes, using Zig tooling for iteration (a few): The author suggests building and iterating on software with Zig's strong tooling first, then applying Zean to verify it once the design settles, since writing whole projects directly in Lean is difficult.
#Zig #Lean4 #formalVerification #theoremProving #AIAssistedCoding #compilers