pub struct Command<'m> { /* private fields */ }Expand description
A run or check with its scope.
Implementations§
Source§impl<'m> Command<'m>
impl<'m> Command<'m>
Sourcepub fn with_step_label(
self,
name: impl Into<String>,
vars: Vec<Variable>,
ranges: Vec<Expr>,
formula: Formula,
) -> Command<'m>
pub fn with_step_label( self, name: impl Into<String>, vars: Vec<Variable>, ranges: Vec<Expr>, formula: Formula, ) -> Command<'m>
Registers a named step predicate scoped to this command alone (B12).
Sourcepub fn shrink(self, yes: bool) -> Command<'m>
pub fn shrink(self, yes: bool) -> Command<'m>
Enables or disables shrinking of found instances or counterexamples
(W13). Defaults to true for check and false for run.
Sourcepub fn by_induction(self, k: usize) -> Command<'m>
pub fn by_induction(self, k: usize) -> Command<'m>
Proves a check of always P for any number of steps within the scope
using k-induction (k >= 1, N9). If the inductive step fails from a
possibly unreachable state, falls back to bounded trace checking with a
note in the result.
Sourcepub fn using_invariant(self, invariant: Formula) -> Command<'m>
pub fn using_invariant(self, invariant: Formula) -> Command<'m>
Adds a helper invariant Q (for by induction ... using Q, N9) that is
proved jointly with the target promise so that a false helper can never
produce a false proof.
Sourcepub fn expect(self, expect: u64) -> Command<'m>
pub fn expect(self, expect: u64) -> Command<'m>
Records the command’s expected outcome (0 for no instance/counterexample,
1 for an instance/counterexample).
Sourcepub fn with_warning(self, warning: Error) -> Command<'m>
pub fn with_warning(self, warning: Error) -> Command<'m>
Attaches a non-fatal warning to this command’s report.
Sourcepub fn with_fact(self, name: impl Into<String>, f: Formula) -> Command<'m>
pub fn with_fact(self, name: impl Into<String>, f: Formula) -> Command<'m>
Adds a command-specific fact (used, for example, for seq/Int bounds).
Sourcepub fn named(self, name: &str) -> Command<'m>
pub fn named(self, name: &str) -> Command<'m>
The command’s name, used in its result and story.
Sourcepub fn facts(&self) -> Formula
pub fn facts(&self) -> Formula
The facts of this command: the model’s, and for each set that extends
another and has a scope, that it has at most (or exactly) that many
atoms, stated as Alloy’s BoundsComputer.size states it at 59ba203
(LOGIC.md 12.9).
Sourcepub fn scope(self, k: usize) -> Command<'m>
pub fn scope(self, k: usize) -> Command<'m>
At most k atoms in every top-level set without its own scope.
Sourcepub fn bitwidth(self, w: u32) -> Command<'m>
pub fn bitwidth(self, w: u32) -> Command<'m>
Integers of w bits (LOGIC.md 16.1); 4 by default, as in Alloy.
Sourcepub fn witnessed_by(&self, trace: &Trace) -> Result<bool, Vec<Error>>
pub fn witnessed_by(&self, trace: &Trace) -> Result<bool, Vec<Error>>
Whether a trace shows what this command looks for: for check, the
facts hold and the assertion fails; for run, the facts and the
formula hold. The agent suite replays an agent’s answer so (DESIGN.md
section 9.8). A static instance is a trace of one state.
Sourcepub fn with_error(self, e: Error) -> Command<'m>
pub fn with_error(self, e: Error) -> Command<'m>
The same command with an error of its own, reported when it runs.
Sourcepub fn budget(self, budget: Budget) -> Command<'m>
pub fn budget(self, budget: Budget) -> Command<'m>
Another budget for each solve, keeping the other options.
Sourcepub fn slicing(self, on: bool) -> Command<'m>
pub fn slicing(self, on: bool) -> Command<'m>
Slicing on or off (DESIGN.md section 7.9); on by default.
Sourcepub fn options(self, options: Options) -> Command<'m>
pub fn options(self, options: Options) -> Command<'m>
Search options: symmetry breaking and the budget.
Sourcepub fn bounds(&self) -> Result<Bounds, Vec<Error>>
pub fn bounds(&self) -> Result<Bounds, Vec<Error>>
The bounds the scopes give (LOGIC.md 12.9).
Errors: model.no_scope, model.not_a_set.
Sourcepub fn formula(&self) -> &Formula
pub fn formula(&self) -> &Formula
The command’s target formula (predicate for run, assertion for check).
Sourcepub fn solve(&self) -> Result<Outcome, Vec<Error>>
pub fn solve(&self) -> Result<Outcome, Vec<Error>>
Runs the command with the default solver.
Errors: those of Command::bounds, then every error of the
formulas.
Sourcepub fn iter_instances(&self) -> Result<InstanceIter, Vec<Error>>
pub fn iter_instances(&self) -> Result<InstanceIter, Vec<Error>>
Returns an iterator over every instance (or trace) of this command up to
symmetry breaking within its scope (N16, R13). Each item is refereed by
elinvar-logic before being yielded.
Errors: those of Command::bounds, then every error of the formulas.
Sourcepub fn prove_by_induction(
&self,
k: usize,
) -> Result<Option<Outcome>, Vec<Error>>
pub fn prove_by_induction( &self, k: usize, ) -> Result<Option<Outcome>, Vec<Error>>
Attempts a k-induction proof without falling back to bounded trace
checking or counterexample shrinking when induction does not close (W23).
Returns:
Ok(Some(out))when induction proved the assertion (Verdict::Proved), found the model vacuous (Verdict::Vacuous), or ran out of budget (Verdict::Unknown);Ok(None)when the base case or inductive step failed to close.
use elinvar_engine::{Model, Verdict};
let mut m = Model::new();
let item = m.set("Item");
let kept = m.changing_subset("kept", &item);
m.fact(kept.no());
m.fact(kept.is_in(&kept.prime()).always());
let out = m
.check(&kept.is_in(&kept.prime()).always())
.scope(2)
.prove_by_induction(1)
.unwrap()
.unwrap();
assert_eq!(out.verdict, Verdict::Proved);pub fn solve_with<S, F>(&self, make_solver: F) -> Result<Outcome, Vec<Error>>
Sourcepub fn explain_holds(&self) -> Result<Option<HoldsCore>, Vec<Error>>
pub fn explain_holds(&self) -> Result<Option<HoldsCore>, Vec<Error>>
Explains why a check command holds (or is vacuous) within its scope
by extracting a minimal unsatisfiable core of the model’s named rules
(REQUIREMENTS.md section 8). Returns Ok(None) if a counterexample
exists, if this is a run command, or if the budget runs out.
When the rules alone are unsatisfiable (vacuous), explains why the
rules contradict each other without conjoining !assertion.
Source§impl Command<'_>
impl Command<'_>
Sourcepub fn report(&self) -> Report
pub fn report(&self) -> Report
Runs the command with the default solver and returns its result, errors included as data.
Sourcepub fn report_with<S, F>(&self, make_solver: F) -> Report
pub fn report_with<S, F>(&self, make_solver: F) -> Report
Runs the command and shrinks any counterexample using a solver built
by make_solver (R9, DESIGN.md section 7.4). Every instance or trace
returned is still refereed by elinvar-logic.
Sourcepub fn report_explained(&self) -> Report
pub fn report_explained(&self) -> Report
Runs the command and, when a check concludes holds, proved, or
vacuous, or a run finds no instance, also extracts the minimal
unsatisfiable core of named rules that established it (REQUIREMENTS.md
section 8, B13, B14). The command’s conflict budget covers both the
solve and the core extraction.
Sourcepub fn assert_holds(&self)
pub fn assert_holds(&self)
Runs the check and returns if it holds; otherwise panics with the story as the message (LOGIC.md 14.4, R26).