You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Kani Rust Verifier is a bit-precise model checker for Rust.
Kani is useful for checking both safety and correctness of Rust code.
Safety: Kani automatically checks for many kinds of undefined behavior.
This makes it particularly useful for verifying unsafe code blocks in Rust, where the "unsafe superpowers" are unchecked by the compiler.
Correctness: Kani automatically checks panics (e.g. unwrap() on None), arithmetic overflows, and custom correctness properties, either in the form of assertions (assert!(...)) or function contracts.
Similar to testing, you write a harness, but with Kani you can check all possible values using kani::any():
use my_crate::{function_under_test, meets_specification};#[kani::proof]fncheck_my_property(){// Create a nondeterministic inputlet input:u8 = kani::any();// Call the function under verificationlet output = function_under_test(input);// Check that it meets the specificationassert!(meets_specification(input, output));}
Kani will try to prove that all valid inputs produce outputs that satisfy the specification, without panicking or exhibiting unexpected behavior.
This example is simple; we highly recommend following the tutorial to learn more about how to use Kani.
Kani contains code from the Rust project.
Rust is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.