Zean: Write Zig, prove it in Lean okcontract.com · 8 points · 0 comments · HN th...

@best

Zean: Write Zig, prove it in Lean okcontract.com · 8 points · 0 comments · HN thread

TL;DR Zean is an open-source toolkit (Zig + Lean) that translates supported Zig functions, captured from Zig's AIR, into executable Lean models so their memory contracts and other properties can be stated and proven. The first release includes a copy loop example with proofs of access safety, initialization, and copy results under explicit caller preconditions, plus deliberately false claims that must fail. The project is Apache 2.0 on GitHub and the post frames it as an alternative workflow to Rust for memory-safety-critical components.

  • Zean translates supported Zig functions from Zig's analyzed intermediate representation (AIR) into executable Lean program definitions; specifications and proofs live in separate handwritten modules.
  • The copy loop example assumes the source has enough initialized words, the destination has enough writable storage, and the ranges are disjoint; under these assumptions it proves no invalid or uninitialized accesses, correct copying on success, and preservation of memory outside the destination.
  • Modeled allocation exhaustion is an explicit permitted failure; termination is treated as a separate property and is not proven.
  • The post motivates the work with Microsoft FORGE Lab's November 9 report on memory-safety bugs in Rust's standard library, where unsafe code beneath safe APIs could trigger undefined behavior.
  • The first release is restricted: it supports selected AIR fragments with explicit target and layout constraints, and the authors say it is not yet complete.
  • Trust boundaries remain: the capture pipeline, Zig frontend, and native backend are not verified, so the proofs do not establish correctness of the final binary or the whole compiler.

Discussion No comments had been posted at the time of this snapshot, so there is no discussion to summarize.

#Zig #Lean #formalVerification #memorySafety #systemsProgramming