pub struct ModelChecker {
pub states: Vec<Vec<f64>>,
pub transitions: Vec<(StateIdx, StateIdx)>,
}Expand description
A simple explicit-state model checker.
States are represented as Vecf64(e.g., phase-space coordinates). Transitions are labeled pairs(from, to)`.
Fields§
§states: Vec<Vec<f64>>All states in the model.
transitions: Vec<(StateIdx, StateIdx)>Transitions as (from_idx, to_idx) pairs.
Implementations§
Source§impl ModelChecker
impl ModelChecker
Sourcepub fn new(
states: Vec<Vec<f64>>,
transitions: Vec<(StateIdx, StateIdx)>,
) -> Self
pub fn new( states: Vec<Vec<f64>>, transitions: Vec<(StateIdx, StateIdx)>, ) -> Self
Create a new model checker from a set of states and transitions.
Sourcepub fn reachable_states(&self, start_idx: StateIdx) -> HashSet<StateIdx>
pub fn reachable_states(&self, start_idx: StateIdx) -> HashSet<StateIdx>
Return all states reachable from start_idx via BFS.
Sourcepub fn satisfies_invariant<F>(&self, start_idx: StateIdx, invariant: F) -> bool
pub fn satisfies_invariant<F>(&self, start_idx: StateIdx, invariant: F) -> bool
Check whether all reachable states from start_idx satisfy invariant.
Sourcepub fn find_counterexample<F>(
&self,
start_idx: StateIdx,
invariant: F,
) -> Option<StateIdx>
pub fn find_counterexample<F>( &self, start_idx: StateIdx, invariant: F, ) -> Option<StateIdx>
Find a counterexample state (as index) that violates invariant.
Returns None if all reachable states satisfy the invariant.
Sourcepub fn shortest_path(
&self,
start_idx: StateIdx,
target_idx: StateIdx,
) -> Option<Vec<StateIdx>>
pub fn shortest_path( &self, start_idx: StateIdx, target_idx: StateIdx, ) -> Option<Vec<StateIdx>>
Return the shortest path (as a sequence of state indices) from
start_idx to target_idx, or None if unreachable.
Sourcepub fn reachable_count(&self, start_idx: StateIdx) -> usize
pub fn reachable_count(&self, start_idx: StateIdx) -> usize
Count the number of reachable states from start_idx.
Trait Implementations§
Source§impl Clone for ModelChecker
impl Clone for ModelChecker
Source§fn clone(&self) -> ModelChecker
fn clone(&self) -> ModelChecker
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ModelChecker
impl RefUnwindSafe for ModelChecker
impl Send for ModelChecker
impl Sync for ModelChecker
impl Unpin for ModelChecker
impl UnsafeUnpin for ModelChecker
impl UnwindSafe for ModelChecker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.