lean-miri: Formally Proving Rust Programs Free of Undefined Behavior
lean-miri is a port of Miri[1], Rust's checker for undefined behavior[2], to the Lean 4[3] proof assistant. It lets you state and prove safety properties of Rust programs under Miri's execution model. Where Miri checks individual concrete executions, Lean can quantify over all inputs, caller states, and nondeterministic choices, so function-level safety properties can be proved without building an executable test harness and under explicit assumptions. Because Miri already implements advanced traits and unsafe pointer operations, porting this mature interpreter is presented as a path to broad Rust support without designing a verifier around a restricted language subset.
The project aims to carry Miri's detailed model of undefined behavior into Lean, since safety depends not only on bounds checks but also on pointer provenance, aliasing, initialization, and concurrency, including the Tree Borrows[4] model. In the empty_function example, an empty function still initializes a call frame and returns to its caller; the example proves that call initialization and every finite execution prefix within the call report no undefined behavior under the declared caller and execution-profile conditions.
For every count and every input in the declared domain, the theorem establishes normal return, no interpreter errors, and no undefined behavior on any permitted finite prefix, with caller, resource, and metadata conditions explicit. Safe resource exhaustion is allowed, and normal return is not promised for every resource supply. The results concern interpreter safety under the declared conditions and do not establish formation from every Rust calling history or an additional guarantee about the returned Boolean. Architecturally, Rust programs are imported as data, the lean-miri interpreter provides the execution semantics used in safety proofs, Lean's kernel checks the proofs, and the compiler, exporter, and the correspondence between the interpreter and Rust remain trusted boundaries.
Read the original proofs-rs.github.ioDiscussion
Sources
-
proofs-rs.github.io
lean-miri: Formally Proving Rust Programs Free of Undefined Behavior


