RC RANDOM CHAOS

Amazon's Verus brings mathematical proof to Rust — beyond memory safety

· via Hacker News

Original source

Developing provably correct Rust code with Verus

Hacker News →

Rust’s type system eliminates whole classes of bugs, but “safer” isn’t the same as “correct.” Rust will halt a program on an out-of-bounds access rather than let it corrupt memory, yet a genuinely correct program would never make that access at all — and the compiler can’t confirm your code computes the right answer or avoids leaking secrets. Verus, an open-source automated verifier Amazon has been developing, closes that gap by checking Rust code against a formal specification for every possible input, not just the handful a test suite happens to try.

What sets Verus apart from other verification tools is that specifications and proofs live directly in the Rust source using Rust-like syntax, expressed as annotations that ordinary compilers ignore. Developers write preconditions and postconditions (for a binary search, say, that the input is sorted and that a returned index actually points to the target), get source-level error messages when a proof fails, and typically see feedback in under a second — fast enough for an interactive edit loop with VS Code squiggles. That speed lets Verus scale to projects with thousands of lines of proof, and it makes the tool a good fit for AI agents, which can iterate on proofs quickly because the solver automates most of the low-level work.

The payoff extends into Rust’s harder corners. Verus can prove that “unsafe” blocks actually uphold the guarantees the compiler stops checking, and it can verify that concurrent code with custom locking schemes is not just safe but correct via lock invariants. Amazon says it has already used Verus on key primitives in the Nitro Isolation Engine, which enforces VM isolation for AWS, and other critical internal infrastructure. The usual caveat applies: the guarantees are only as trustworthy as Verus itself, the specifications, the runtime assumptions, and the compiler toolchain — components the team says it will address in future posts.

Read the full article

Continue reading at Hacker News →

This is an AI-generated summary. Read the original for the full story.