hax
hax translates a large subset of Rust into formal languages such as Lean, F* and Rocq, so that you can prove your code does what it should.
How it works
-
Write Rust, state what it should do
Contracts are ordinary Rust attributes from
hax_lib.#[hax_lib::requires(x < 16)] #[hax_lib::ensures(|res| res >= x)] pub fn square(x: u8) -> u8 { x * x } -
Extract to a proof assistant
One command translates the crate into Lean, F* or Rocq.
cargo hax into lean -
Prove it
The contract becomes a theorem about the extracted code.
@[spec] theorem square.spec.proof (x : Std.U8) : square.spec x := by unfold square.spec square hax_mvcgen all_goals grind [Nat.le_mul_self]
From the Lean tutorial.
News
-
Hax 0.4!
Announcing hax 0.4, a pivotal release
-
Software Verification in Lean
Cryspen is co-hosting a workshop on advancing software verification using the Lean proof assistant.
-
Formally Specifying and Testing the Rust Standard Library
Cryspen found and fixed bugs in the Rust SIMD libraries using formal specs
-
Helping Secure Signal's Post-Quantum Transition
Cryspen worked with Signal to formally analyze their new post-quantum ratchet
Community
Questions and discussion on Zulip, issues and contributions on GitHub.