kani README

The project's README from github.com/model-checking/kani. As one markdown file: README.md.

Kani regression Nightly: CBMC Latest

The Kani Rust Verifier is a bit-precise model checker for Rust.

Kani is useful for checking both safety and correctness of Rust code.

Installation

To install the latest version of Kani (Rust 1.58+; Linux or Mac), run:

cargo install --locked kani-verifier
cargo kani setup

See the installation guide for more details.

How to use Kani

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]
fn check_my_property() {
   // Create a nondeterministic input
   let input: u8 = kani::any();

   // Call the function under verification
   let output = function_under_test(input);

   // Check that it meets the specification
   assert!(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.

GitHub Action

Use Kani in your CI with model-checking/kani-github-action@VERSION. See the GitHub Action section in the Kani book for details.

Citing Kani

If you use Kani in your research, please cite our ASE 2026 paper.

ACM Reference Format:

Rémi Delmas, Zyad Hassan, Qinheping Hu, Rahul Kumar, Felipe R. Monteiro, Thanh Nguyen, Adrián Palacios, Celina Val, Michael Tautschnig, Justus Adam, Daniel Schwartz-Narbonne, and Carolyn Zech. 2026. Kani: A Model Checker for Rust. In Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering (ASE '26), October 12–16, 2026, Munich, Germany. ACM, New York, NY, USA, 13 pages. https://doi.org/10.1145/3832783.3834499

BibTeX:

@inproceedings{kani-ase-2026,
  author    = {Delmas, R{\'e}mi and Hassan, Zyad and Hu, Qinheping and Kumar, Rahul and
               Monteiro, Felipe R. and Nguyen, Thanh and Palacios, Adri{\'a}n and
               Val, Celina and Tautschnig, Michael and Adam, Justus and
               Schwartz-Narbonne, Daniel and Zech, Carolyn},
  title     = {{Kani}: A Model Checker for {Rust}},
  year      = {2026},
  publisher = {Association for Computing Machinery},
  address   = {New York, NY, USA},
  url       = {https://doi.org/10.1145/3832783.3834499},
  doi       = {10.1145/3832783.3834499},
  booktitle = {Proceedings of the 41st IEEE/ACM International Conference on Automated Software Engineering},
  numpages  = {13},
  location  = {Munich, Germany},
  series    = {ASE '26}
}

The same citation is available in machine-readable form in CITATION.cff, which powers GitHub's Cite this repository button.

Security

See SECURITY for more information.

Contributing

If you are interested in contributing to Kani, please take a look at the developer documentation.

License

Kani

Kani is distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.

Rust

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.

See the Rust repository for details.

kani (model-checking/kani)

Searching Database…

3.5K ·GitHub
这是干什么的?Kani 是一个针对 Rust 程序的位精确模型检查器:它不像测试套件那样抽样尝试各种输入,而是证明你的代码不存在某些缺陷和未定义行为。
它是加到我项目里的库,还是一个独立的工具?是一个独立的命令行工具:你的程序保持原样,只需添加一些看起来像测试的 harness 函数,Kani 就会在开发阶段或 CI 中对它们进行验证。
它能在 Windows 上运行吗?官方安装说明只提到了 Linux 和 Mac——README 里没有提到 Windows,所以请计划在一台类 Unix 的机器或 CI 上运行它。
安装好之后,我应该从哪里入手?README 强烈推荐通过官方教程来学习 Kani,而 Kani book 是完整的文档,其中包括关于用于 CI 的 GitHub Action 的章节。
为什么 Kani 对 unsafe 代码特别有用?Rust 编译器不会检查 unsafe 块内的各种保证,而 Kani 能自动检查多种未定义行为——恰恰是这些 unsafe 超能力未经验证的地方。
Kani 是研究项目,还是可用于生产环境的工具?两者都是:它提供了用于真实 CI 场景的官方 GitHub Action,团队同时也在发布相关研究——学术用户被要求引用 Kani 发表在 ASE 2026 上的论文。
What are similar projects?rust-clippy, perch, openqodex, knip, rector, fallow, golangci-lint, bashka
Size
36.8 MB
Stars
3.5K
Age
5y
Commits · 90 Days