Anneal

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.

Some things we believe

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.

Well-defined behavior is non-negotiable

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]

If a programmer can write a Rust program that is correct, then–given the right tools–they can also prove it is correct

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.

Given the right tools, Rust programmers can write unsafe programs with confidence

This 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.

Anneal's promise to its users

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:

  1. There is a bug or invalid assumption in the TCB (Anneal, Lean, etc.), or
  2. The program is sound (UB-free) and behaves as its stated specifications promise.[^3]

How we make decisions about Anneal

The team behind Anneal strives to uphold a handful of principles that govern its development:

  1. First support all Rust programmers; then support all program behaviors[^4]. Rust developers will only be interested in, confident with, and productive using Anneal if it works for them. This principle represents our preference to prefer usability above completeness.
  2. Don't break promises. As Anneal evolves, it should not violate its “If ... and ... then ...” promise.
  3. Don't foreclose increasing expressive power. Of course, Anneal does not support specifying and proving all possible properties of Rust programs. That said, we will always want to add more. That's why we prefer specification and proof designs that are open to future extension.
  4. Prefer depth of understanding over point solutions. Though feature development is rooted in practical examples, we prefer to identify the broader pattern “known use cases” represent. Our experience in other projects suggests this approach often reveals unexpected insights that benefit our users.

[^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.