tools-creusot-init
Prepare an existing Cargo project to use Creusot formal verification
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-12
- Stars
- ★ 3
- Forks
- 4
01 前言 Front Matter
- name
- tools-creusot-init
- description
- Prepare an existing Cargo project to use Creusot formal verification
- argument-hint
- <project-directory> (e.g. components/extent-manager)
03 SKILL.md 正文
This skill takes a cargo project directory and configures it for Creusot verification.
Input
The user must provide the target project directory as an argument (e.g. /tools-init-creusot components/dispatch-map).
If no argument is provided, show the hint and stop.
Prerequisites
- Creusot must already be installed (
cargo creusot versionshould succeed) - If not installed, inform the user to run the
tools-install-creusotskill first, then stop
Steps
-
Verify the target directory contains a
Cargo.toml. If not, inform the user and stop. -
Check that Creusot is installed by running
cargo creusot version. If it fails, tell the user to run/tools-install-creusotfirst and stop. -
Modify
Cargo.toml:- Add
creusot-std = "0.12.0-dev"under[dependencies](if not already present) - Add a
[patch.crates-io]section pointing to the local creusot-std (use a relative path from the project to the certus repo'stools/creusot/creusot/creusot-std, or use~notation for shell expansion):
Compute the correct relative path from the target project directory to[patch.crates-io] creusot-std = { path = "<relative-path-to>/tools/creusot/creusot/creusot-std" }certus/tools/creusot/creusot/creusot-std. - Add the
cfg(creusot)lint configuration under[lints.rust]:[lints.rust] unexpected_cfgs = { level = "warn", check-cfg = ['cfg(creusot)'] } - If the project is inside another workspace but should be standalone, add an empty
[workspace]table
- Add
-
Create
why3find.jsonin the project root (if not already present):{ "fast": 0.2, "time": 1, "depth": 6, "packages": [ "creusot" ], "provers": [ "alt-ergo", "z3", "cvc5", "cvc4" ], "tactics": [ "compute_specified", "split_vc" ], "drivers": [], "warnoff": [ "unused_variable", "axiom_abstract" ] } -
Add
use creusot_std::prelude::*;tosrc/lib.rsorsrc/main.rs(if not already present). If the file has existing functions, add a commented example showing how to annotate:// Example Creusot annotations: // #[requires(precondition)] // #[ensures(postcondition)] // pub fn verified_function(...) { ... } -
Run
cargo cleanto remove any stale build artifacts that would block Creusot's translation pass. -
Verify the setup works by running:
export PATH="$HOME/.local/share/creusot/bin:$PATH" cargo creusot --only comaThis should compile without errors. If there are no annotated functions yet, it will produce no
.comafiles — that's expected. -
Report success and tell the user:
- Add
#[requires(...)]and#[ensures(...)]annotations to functions they want to verify - Run
cargo creusotto build and prove - Run
why3find prove verif/<crate_name>_rlib/*.comato prove individual files - Reference
certus/tools/creusot/creusot-test-example/src/lib.rsfor annotation examples
- Add
Notes
- Always run
cargo cleanbefore the firstcargo creusotif the project was previously built with plaincargo build - The
[patch.crates-io]section assumes Creusot was cloned tocertus/tools/creusot/creusotper the install skill - If the project uses
edition = "2024", it works with Creusot's required nightly toolchain
04 同仓库更多 Skills
tools-spin-sync
Synchronize Spin/Promela models with current source code and re-verify
tools-spin-model
Create a new Spin/Promela formal verification model for a system property
tools-creusot-install
Install the Creusot Rust verification tool
tools-creusot-init
Prepare an existing Cargo project to use Creusot formal verification
tools-creusot-coq-install
Add Coq 8.20 as an additional prover to an existing Creusot installation, for verification conditions that SMT solvers cannot discharge
tools-creusot-annotate-interfaces
Formally verify a component's properties with Creusot and annotate its interface definitions