Expand description
vers3 — Explicit-State Model Checking Library
§Quick start
use vers3::{TransitionSystem, invariant, rule, search::Bfs};
// 1. Define your state (Clone + Hash + Eq + Display = State automatically).
#[derive(Clone, Hash, PartialEq, Eq, Debug)]
struct Counter(u32);
vers3::display_via_debug!(Counter);
// 2. Build a transition system: guarded rules plus safety invariants.
let mut ts = TransitionSystem::new();
ts.add_rule(rule(
"increment",
|_: &Counter| true,
|s: &mut Counter| {
s.0 = (s.0 + 1) % 4; // wrap around: the state space is finite
true
},
));
ts.add_property(invariant("bounded", |s: &Counter| s.0 < 4));
// 3. Run BFS (ts is consumed, preventing reuse with stale property state).
let result = Bfs::new().run(vec![Counter(0)], ts);
match &result {
Ok(stats) => println!("No violations. {stats}"),
Err(cex) => vers3::report::print_counterexample(cex),
}Re-exports§
pub use ts::CheckerError;pub use ts::InvariantFn;pub use ts::Property;pub use ts::Rule;pub use ts::RuleError;pub use ts::RuleFn;pub use ts::State;pub use ts::Stepping;pub use ts::TransitionSysSimulation;pub use ts::TransitionSystem;pub use ts::Unknown;pub use ts::Unknowns;pub use ts::error_if;pub use ts::invariant;pub use ts::rule;pub use ts::rule_try;pub use types::ArraySet;pub use types::StateHash;pub use types::combine_hash;
Modules§
- properties
- Reusable property library.
- report
- Report generation.
- search
- Search algorithms: BFS over the state space.
- ts
- Transition system: states, rules, properties, and the core step function.
- types
- Core data structures for state representation and storage.
- util
- Utility functions.
Macros§
- display_
via_ debug - Implement
std::fmt::Displayfor a type by delegating to itsstd::fmt::Debugimpl.