Skip to main content

Machine

Struct Machine 

Source
pub struct Machine {
Show 15 fields pub heap: Heap, pub frame: Vec<Handle>, pub base: usize, pub s0: Vec<Handle>, pub s1: Vec<Handle>, pub assigned: usize, pub opts: Opts, pub memo: Memo, pub stats: EvalStats, pub warn: bool, pub warnings: Vec<(u16, u32)>, pub printed: Vec<String>, pub draw: Option<Box<dyn DrawStream>>, pub draws: u64, pub level: i64, /* private fields */
}
Expand description

One worker’s evaluation state.

Fields§

§heap: Heap

The value regions.

§frame: Vec<Handle>

The frame stack.

§base: usize

The base of the current frame.

§s0: Vec<Handle>

The current state (s0).

§s1: Vec<Handle>

The successor buffer (s1); Handle::EMPTY is unassigned.

§assigned: usize

Assigned variables in s1.

§opts: Opts

The strategy switches.

§memo: Memo

The memo tables.

§stats: EvalStats

Counters.

§warn: bool

Whether the all-assigned shortcut runs for successors (TLC’s TLCGlobals.warn; on in both profiles).

§warnings: Vec<(u16, u32)>

Warnings 2143 raised by the generator (UNCHANGED of a variable already assigned another value), once per variable and site (an ExprId index), in the order raised.

§printed: Vec<String>

What Print and PrintT printed, one line each, in evaluation order.

§draw: Option<Box<dyn DrawStream>>

The random stream draws come from: the startup stream or the expanded state’s (random.rs); None outside a search.

§draws: u64

How many draws were made, which the engine reads to refuse a draw in a check.

§level: i64

TLCGet("level"): 0 in Init, the expanded state’s level in the next-state relation and action checks, the checked state’s level in state checks (initial states are level 1). The engine sets it.

Implementations§

Source§

impl Machine

Source

pub fn without_debugger<T>( &mut self, operation: impl FnOnce(&mut Self) -> T, ) -> T

Runs nonproducer reconstruction without this machine’s debugger capability. The original capability is restored when the operation returns or unwinds, including on errors. The controller and its stopped snapshots are untouched.

Source§

impl Machine

Source

pub fn new(store: Arc<Store>, nvars: usize, opts: Opts, memo: Memo) -> Self

A machine over store for states of nvars variables.

Source

pub fn set_fuel(&mut self, units: u64)

Bounds optional speculative work. Exhaustion yields unsupported and cannot be interpreted as a model verdict or a run-budget stop.

machine.set_fuel(4096);
Source

pub const fn fuel_exhausted(&self) -> bool

Whether a bounded machine has spent all of its fuel (Machine::set_fuel), as the last charge that failed leaves it.

let _ = machine.fuel_exhausted();
Source

pub fn set_refuse_unrecorded_warnings(&mut self, enabled: bool)

Makes every site where the dive-eval evaluator prints a warning that this machine does not record in Machine::warnings fail as unsupported instead: an EXCEPT key outside the function’s domain (TLC warning 2144). An isolated optional machine sets it so that its caller can fall back to the dive-eval evaluator, which prints the warning. Ordinary machines keep TLC’s unchanged-function result.

machine.set_refuse_unrecorded_warnings(true);
Source

pub fn set_proven_materialized( &mut self, s0: &[Handle], s1: &[Handle], others: impl IntoIterator<Item = Handle>, )

Records handles the caller proved materialized in this machine’s store with Heap::proved_concrete or Heap::materialized_within: the rows s0 and s1 it is about to load, and others. It forgets the previous ones. Identity tests that require materialized operands (a SameVars subscript, set membership) then skip re-proving those exact handles. Only persistent compound handles are kept: persistent nodes never change, so the proof stays true. An isolated analysis machine passes the rows and constants it admitted before each evaluation.

Precondition, which this method does not check: every recorded handle satisfies Heap::materialized_within in this machine’s store. Recording any other handle (a lazy or symbolic set, say) makes membership binary-search a non-canonical node and can give a wrong answer. That walk has no depth limit, unlike the internal check it replaces, which declines values nested 64 deep; the skipped check would then have refused a value whose identity is nonetheless exact, so the recorded proof only answers more of the same questions.

machine.set_proven_materialized(row, &[], []);
Source

pub fn set_work_control(&mut self, control: Option<Arc<dyn WorkControl>>)

Installs the optional caller-owned cooperative work checkpoint. Ordinary machines have no checkpoint and unbounded fuel.

machine.set_work_control(None);
Source

pub fn set_debugger(&mut self, observer: Option<Arc<dyn Observer>>)

Installs explicit producer observation. Fresh replay/analysis machines remain unobserved unless a caller separately installs this capability.

Source

pub fn with_deferred_reclamation<T>( &mut self, work: impl FnOnce(&mut Self) -> T, ) -> T

Keeps generator continuation transients alive during one eager batch.

Internal rollback calls are deferred only inside work; normal rollback behavior resumes before this method returns. The caller must retain any required values after their semantic demands, clear transient receivers, then roll back its enclosing batch mark. This does not persist or normalize values and must not wrap a whole search or repeated iterations.

let mark = machine.heap.mark();
machine.with_deferred_reclamation(|_machine| ());
machine.heap.rollback(mark);
Source

pub fn deny_checker_access(&mut self)

Disables TLCGet/TLCSet in finite modes without a live checker context. Access refuses when reached; an untaken branch remains unevaluated.

Source

pub fn allow_finite_level(&mut self)

Keeps TLCGet("level") available in a finite mode whose driver sets Machine::level the way TLC does for that mode. Register reads and writes still refuse.

Source

pub fn set_output_limits(&mut self, events: usize, bytes: usize)

Bounds retained Print events and UTF-8 bytes for a finite mode. The ordinary checker leaves this unset. Rendering occurs before admission.

Source

pub const fn output_failure(&self) -> Option<&'static str>

The first output-admission limit reached by this machine.

Source

pub fn enter(&mut self, size: u32) -> usize

Enters a frame of size slots for a role, returning the old base.

Source

pub fn leave(&mut self, old: usize)

Leaves the frame entered by Machine::enter.

Source

pub fn thunk_mark(&self) -> usize

The point from which Machine::thunks_released considers the thunk slots forced to a transient. Take it with the Heap::mark that a later rollback frees to.

Source

pub fn thunks_released(&mut self, since: usize) -> bool

Whether no thunk slot still in the frame holds a transient forced since since, so that a rollback to the heap mark taken with it frees no value a live slot holds. A slot forced in a frame that has since been left is gone: entering a frame fills fresh slots with Handle::EMPTY. Forgets the positions of slots that have left the frame; a true result forgets every position recorded since since.

Source

pub fn eval_bool(&mut self, code: &Code, p: P) -> Result<bool, Error>

Evaluates a node to a boolean.

§Errors

Evaluation errors, or a non-boolean result.

Source

pub fn eval_norm(&mut self, code: &Code, p: P) -> Result<Handle, Error>

Evaluates a node and normalizes the result.

§Errors

Evaluation errors.

Source

pub fn eval(&mut self, code: &Code, p: P) -> Result<Handle, Error>

Evaluates a node.

§Errors

Evaluation errors, refusals and resource limits.

Source

pub fn member(&mut self, x: Handle, set: Handle) -> Result<bool, Error>

Whether x (normalized) is in set.

§Errors

set is not a set, or membership is undefined.

Source

pub fn apply(&mut self, f: Handle, a: Handle) -> Result<Handle, Error>

f[a].

§Errors

a is not in the domain of f.

Source§

impl Machine

Source

pub fn clear_buffer(&mut self)

Clears the successor buffer.

Source

pub fn run_action( &mut self, code: &Code, g: G, sink: &mut dyn Sink, ) -> Result<(), Error>

Runs one action (or initial predicate) from self.s0, emitting every successor into sink. The caller has entered the action’s frame.

§Errors

Evaluation errors, refusals, and the sink’s stop.

Source

pub fn run_action_generation( &mut self, code: &Code, g: G, sink: &mut dyn Sink, choose: &mut dyn FnMut(u64) -> u64, ) -> Result<(), Error>

Runs actual Next traversal with bounded randomized disjunction and existential ordering. The sink stops after its first admitted complete row; continuing searches remaining alternatives. choose(n) must return a value below the positive n. Ordinary predicate/ENABLED evaluation never inherits these operational choices.

§Errors

The ordinary generation errors, unsupported indexed domains or an out-of-range caller index.

Trait Implementations§

Source§

impl Debug for Machine

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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