1 unstable release

0.1.0-pre.1 Jun 18, 2024
0.1.0-alpha.1 Oct 7, 2024

#413 in Rust patterns

Download history 41/week @ 2024-08-01 103/week @ 2024-08-08 130/week @ 2024-08-15 84/week @ 2024-08-22 86/week @ 2024-08-29 325/week @ 2024-09-05 283/week @ 2024-09-12 302/week @ 2024-09-19 317/week @ 2024-09-26 638/week @ 2024-10-03 341/week @ 2024-10-10 493/week @ 2024-10-17 561/week @ 2024-10-24 661/week @ 2024-10-31 552/week @ 2024-11-07 373/week @ 2024-11-14

2,272 downloads per month
Used in 7 crates (3 directly)

Apache-2.0

19KB
326 lines

hax library

This crate contains helpers that can be used when writing Rust code that is proven through the hax toolchain.

⚠️ The code in this crate has no effect when compiled without the --cfg hax.

Examples:

fn sum(x: Vec<u32>, y: Vec<u32>) -> Vec<u32> {
  hax_lib::assume!(x.len() == y.len());
  hax_lib::assert!(hax_lib::forall(|i: usize| hax_lib::implies(i < x.len(), || x[i] < 4242)));
  hax_lib::debug_assert!(hax_lib::exists(|i: usize| hax_lib::implies(i < x.len(), || x[i] > 123)));
  x.into_iter().zip(y.into_iter()).map(|(x, y)| x + y).collect()
}

lib.rs:

Hax-specific helpers for Rust programs. Those helpers are usually no-ops when compiled normally but meaningful when compiled under hax.

Example:

fn sum(x: Vec<u32>, y: Vec<u32>) -> Vec<u32> {
  hax_lib::assume!(x.len() == y.len());
  hax_lib::assert!(hax_lib::forall(|i: usize| hax_lib::implies(i < x.len(), || x[i] < 4242)));
  hax_lib::debug_assert!(hax_lib::exists(|i: usize| hax_lib::implies(i < x.len(), || x[i] > 123)));
  x.into_iter().zip(y.into_iter()).map(|(x, y)| x + y).collect()
}

Dependencies

~395–760KB
~16K SLoC