Anneal is a verification framework for proving the correctness of Rust programs in Lean 4. It emphasizes proof that programs do not exhibit undefined behavior (i.e., programs are “UB-free”), and empowers developers to assert and prove other properties they consider to be part of program correctness without obliging Rust developers to learn Lean 4.
Rust developers deserve programs that are correct. As the Rust aphorism goes, if it compiles, it works. Anneal is built to extend this aphorism beyond safe Rust (to unsafe Rust) and beyond memory safety (to other safety or correctness properties). Anneal's approach to this extension is built on several hypotheses about Rust development.
Almost nothing can be proven about programs that may exhibit UB.[^1] Although Anneal may support ways of disabling other obligations, UB-freedom is a feature that is always on.[^2]
Every programmer has a theory of why they think their program is correct; that theory is the reason they wrote it in the first place! Anneal aims to build on developers' existing Rust intuitions: rather than replacing or modifying rustc, Anneal verifies programs alongside standard compilation, surfacing unsatisfied proof obligations in clear, Rust-oriented diagnostics that explain why a program fails to uphold a stated property.
unsafe programs with confidenceThis claim is a corollary of the above two hypotheses. If Anneal rejects programs that may exhibit UB with clear, actionable diagnostics explaining how to fix the problem, then Rust developers should be just as confident and productive using Anneal to verify unsafe Rust as they are using rustc to write safe Rust.
One of Anneal‘s outputs is a TCB audit log, a list of code and assumptions Anneal trusts (including itself) to compile your code and prove it correct. Anneal’s promise is this:
If the code in your TCB audit log is correct, its assumptions are valid, and Anneal emits no errors, then your code is sound and satisfies any stated specifications.
Here, sound means that your program's behavior is well-defined (UB-free)—a baseline guarantee defined by Anneal itself and always on, even when you write no specifications of your own. Stated specifications are any additional developer-defined properties you ask Anneal to prove about your code.
This commitment means that if you write code that Anneal cannot reason about, verification fails closed (returning a non-zero exit status rather than silently skipping constructs it cannot model). Anneal will never “fail open.” It also means that if Anneal emits no errors, then either:
The team behind Anneal strives to uphold a handful of principles that govern its development:
[^1]: One might expect that useful properties can be proven about the behavior of such programs during the window before UB is triggered, but unfortunately the definition of UB and methods applied by compilers is even worse: compilers that perform aggressive optimizations under the assumption that UB cannot occur may disrupt the behavior of a program before the offending instruction is executed. This means that, if a particular execution exhibits UB, the semantics of the entire execution is not well-defined.
[^2]: Anneal may support development-only options that bypass UB checks or turn them into warnings, but such features will clearly label the results and TCB log as tainted or irreparably untrustworthy.
[^3]: While Anneal defines and checks baseline soundness (UB-freedom) automatically, stated specifications (including any stated preconditions) are only as strong as what is written: behaving “as its stated specifications promise” is not guaranteed to mean “as the programmer expects” in the face of weak specifications or user error that misconstrued developer-defined requirements.
[^4]: It is a non-goal for Anneal to support all Rust programs. Technically, Anneal aims to support all program behaviors: there may be certain dark corners of rust operational semantics or ways of combining rust features that Anneal never intends to support. In such cases, though, Anneal should give actionable guidance on strategies that can achieve the same behavior by different (and less risky) means.