1 unstable release

0.1.0-pre.1 Jun 18, 2024

#587 in Rust patterns

Download history 148/week @ 2024-06-17 2/week @ 2024-06-24 6/week @ 2024-07-01 6/week @ 2024-07-15 230/week @ 2024-07-22 31/week @ 2024-07-29 95/week @ 2024-08-05 61/week @ 2024-08-12 174/week @ 2024-08-19 70/week @ 2024-08-26

400 downloads per month
Used in 6 crates (2 directly)

Apache-2.0

18KB
303 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

~400–770KB
~16K SLoC