Skip to main content

Command

Struct Command 

Source
pub struct Command<'m> { /* private fields */ }
Expand description

A run or check with its scope.

Implementations§

Source§

impl<'m> Command<'m>

Source

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).

Source

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.

Source

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.

Source

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.

Source

pub fn expect(self, expect: u64) -> Command<'m>

Records the command’s expected outcome (0 for no instance/counterexample, 1 for an instance/counterexample).

Source

pub fn with_warning(self, warning: Error) -> Command<'m>

Attaches a non-fatal warning to this command’s report.

Source

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).

Source

pub fn named(self, name: &str) -> Command<'m>

The command’s name, used in its result and story.

Source

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).

Source

pub fn scope(self, k: usize) -> Command<'m>

At most k atoms in every top-level set without its own scope.

Source

pub fn scope_of(self, set: &Expr, k: usize) -> Command<'m>

At most k atoms in set.

Source

pub fn exactly(self, set: &Expr, k: usize) -> Command<'m>

Exactly k atoms in set.

Source

pub fn bitwidth(self, w: u32) -> Command<'m>

Integers of w bits (LOGIC.md 16.1); 4 by default, as in Alloy.

Source

pub fn steps(self, n: usize) -> Command<'m>

At most n states in a trace (LOGIC.md 13.4).

Source

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.

Source

pub fn with_error(self, e: Error) -> Command<'m>

The same command with an error of its own, reported when it runs.

Source

pub fn budget(self, budget: Budget) -> Command<'m>

Another budget for each solve, keeping the other options.

Source

pub fn slicing(self, on: bool) -> Command<'m>

Slicing on or off (DESIGN.md section 7.9); on by default.

Source

pub fn options(self, options: Options) -> Command<'m>

Search options: symmetry breaking and the budget.

Source

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.

Source

pub fn formula(&self) -> &Formula

The command’s target formula (predicate for run, assertion for check).

Source

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.

Source

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.

Source

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);
Source

pub fn solve_with<S, F>(&self, make_solver: F) -> Result<Outcome, Vec<Error>>
where S: Solver + 'static, F: FnMut() -> S,

Source

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<'_>

Source

pub fn report(&self) -> Report

Runs the command with the default solver and returns its result, errors included as data.

Source

pub fn report_with<S, F>(&self, make_solver: F) -> Report
where S: Solver + 'static, F: FnMut() -> S,

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.

Source

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.

Source

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).

Trait Implementations§

Source§

impl<'m> Clone for Command<'m>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'m> Debug for Command<'m>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'m> Forget for Command<'m>

§

impl<'m> Freeze for Command<'m>

§

impl<'m> Move for Command<'m>

§

impl<'m> RefUnwindSafe for Command<'m>

§

impl<'m> Send for Command<'m>
where &'m Model: Send, Arc<FormulaNode>: Send, RawVecInner: Send, Arc<ExprNode>: Send, &'static str: Send, Arc<Declared>: Send,

§

impl<'m> Sync for Command<'m>
where RawVecInner: Sync, Arc<Declared>: Sync, Arc<FormulaNode>: Sync, Arc<ExprNode>: Sync, NodeRef<Owned, String, Vec<Formula>, LeafOrInternal>: Sync, BoxRaw<(String, Vec<Formula>)>: Sync,

§

impl<'m> Unpin for Command<'m>
where &'m Model: Unpin, Arc<FormulaNode>: Unpin, *const u8 is !null: Unpin, Arc<ExprNode>: Unpin, &'static str: Unpin, Arc<Declared>: Unpin,

§

impl<'m> UnsafeUnpin for Command<'m>

§

impl<'m> UnwindSafe for Command<'m>
where &'m Model: UnwindSafe, Arc<FormulaNode>: UnwindSafe, RawVecInner: UnwindSafe, Arc<ExprNode>: UnwindSafe, &'static str: UnwindSafe, Arc<Declared>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.