Skip to main content

Model

Struct Model 

Source
pub struct Model {
Show 29 fields pub ir: Arc<Ir>, pub evaluator: Evaluator, pub names: Arc<Interner>, pub output: Vec<Message>, pub init: Vec<Init>, pub next: Option<Pred>, pub init_actions: Vec<Action>, pub actions: Vec<Action>, pub invariants: Vec<Named>, pub implied_inits: Vec<Named>, pub implied_actions: Vec<Named>, pub temporals: Vec<Named>, pub implied_temporals: Vec<Named>, pub configured_properties: Vec<Named>, pub constraints: Vec<Named>, pub action_constraints: Vec<Named>, pub view: Option<Named>, pub alias: Option<Result<Named, BindError>>, pub postconditions: Result<Vec<Named>, BindError>, pub symmetry: Option<String>, pub symmetry_reduction: Option<Arc<Reduction>>, pub settings: Settings, pub assumptions: Vec<DefId>, pub unsupported: Vec<Unsupported>, pub sequential: Vec<String>, pub sequential_names_only: bool, pub runtime_name_order: bool, pub deferred_constants: BTreeSet<DefId>, pub deferred_assumptions: Vec<DefId>, /* private fields */
}
Expand description

A specification bound to its configuration.

Fields§

§ir: Arc<Ir>

The lowered specification.

§evaluator: Evaluator

The evaluator, with the constants bound and the start-up values computed. Clones share them.

§names: Arc<Interner>

The run’s names, in TLC’s encounter order.

§output: Vec<Message>

What TLC prints while it processes the model, before it checks the assumptions: Print output of constant definitions and warnings.

§init: Vec<Init>

Initial predicates, in TLC’s order.

§next: Option<Pred>

The next-state relation as TLC holds it before splitting (getNextStateSpec), if any.

§init_actions: Vec<Action>

The initial predicates as the successor generator’s actions (Evaluator::init_states), numbered from 0.

§actions: Vec<Action>

The next-state relation split into TLC’s actions, with TLC’s labels, numbered after the initial predicates (Evaluator::successors).

§invariants: Vec<Named>

Invariants: INVARIANTs, then the state predicates []P of PROPERTYs.

§implied_inits: Vec<Named>

Implied initial predicates: state-level parts of PROPERTYs.

§implied_actions: Vec<Named>

Implied actions: the [A]_v of [][A]_v in PROPERTYs.

§temporals: Vec<Named>

Temporal formulas of the behavior specification (fairness), named as TLC names them. Inert for safety checking.

§implied_temporals: Vec<Named>

Temporal properties to check (liveness).

§configured_properties: Vec<Named>

Original configured PROPERTY formulas, before TLC’s role splitting. These retain configuration names for complete counterexample claims; the role vectors above keep TLC’s evaluation/checking order unchanged.

§constraints: Vec<Named>

CONSTRAINTs.

§action_constraints: Vec<Named>

ACTION_CONSTRAINTs.

§view: Option<Named>

VIEW.

§alias: Option<Result<Named, BindError>>

ALIAS. TLC looks it up only when it prints a trace (Spec.getAliasSpec), so a lookup error is reported then, not at start-up.

§postconditions: Result<Vec<Named>, BindError>

POSTCONDITIONs. TLC looks them up after checking (Spec.getPostConditionSpecs), stopping at the first error, which it reports then.

§symmetry: Option<String>

SYMMETRY, by name.

§symmetry_reduction: Option<Arc<Reduction>>

Prepared safety reduction. Concrete states remain unmodified.

§settings: Settings

Run settings.

§assumptions: Vec<DefId>

The root module’s assumptions TLC checks (not AXIOMs), in order.

§unsupported: Vec<Unsupported>

Features this model uses that dive does not check yet.

§sequential: Vec<String>

Why the model must be checked in sequential mode, with one logical worker evaluating in TLC’s order; empty when a parallel search gives the same results. Each entry names the feature.

§sequential_names_only: bool

The only sequential restriction is preserving runtime name encounter order. This is not an I/O, random-stream or live-checker-state effect. This conservative source inventory remains available to checkpoint admission after a proof discharges the corresponding worker restriction.

§runtime_name_order: bool

Checking may create runtime names whose encounter order is observable under the selected value or exploration order. Remains true when other sequential effects are also reachable. This is a conservative source feature flag; a worker-selection proof can remove a scheduling reason without changing replay’s inventory.

§deferred_constants: BTreeSet<DefId>

Pure constant-level definitions whose start-up evaluation was left to Core (crate::bind_deferring_constants); empty otherwise. The evaluator evaluates them lazily.

§deferred_assumptions: Vec<DefId>

The root module’s pure ASSUMEs, in order, that Core evaluates when it compiles its plan (crate::bind_deferring_constants); empty otherwise. Their value is a function of the start-up values alone, so one the core finds TRUE need not be checked again (Model::check_assumptions_except).

Implementations§

Source§

impl Model

Source

pub fn stateful_checking(&self) -> Option<&str>

A reachable stateful checking restriction, if any, from model binding.

Runtime-name encounter order and TLC composition accounting are separate sequential requirements. Their presence alone does not return a reason here. This classification does not establish support: each backend must still apply its remaining checks and evaluate the actual model.

if let Some(reason) = model.stateful_checking() {
    eprintln!("stateful checking: {reason}");
}
Source

pub fn seal_startup_names(&self)

Records every name interned so far as a start-up name (dive_eval::Evaluator::seal_startup_names). Call it only after interning names TLC interns before it evaluates any ASSUME or state.

Source

pub fn has_runtime_names(&self) -> bool

Whether a name was interned after start-up (dive_eval::Evaluator::startup_names) and string order follows encounter order (TLC’s value or exploration order), so that the name’s position relative to the others depends on evaluations outside a given trace.

Source

pub const fn symmetry_liveness(&self) -> &SymmetryLivenessResolution

The immutable original declaration and policy after actual role binding. This is not exploration or witness evidence.

let requested = model.symmetry_liveness().requested();
assert!(["unreduced", "refuse", "tlc"].contains(&requested.as_str()));
Source

pub fn unreduced_symmetry_liveness(&self) -> bool

Whether this model uses full concrete identities for temporal checking. Public role/declaration changes or an installed reduction invalidate it.

if model.unreduced_symmetry_liveness() {
    assert!(model.symmetry_reduction.is_none());
    assert!(!model.implied_temporals.is_empty());
}
Source

pub fn validate_context(&self) -> Result<()>

Admits public bound-model metadata before backend startup or host effects. Checks evaluator ownership and every predicate/action scope without evaluating expressions or forcing captured values.

§Errors

A named malformed/foreign context or bounded admission refusal.

Source

pub fn implied_temporal_action_names(&self) -> &[String]

Original configuration names on TLC’s expanded implied-temporal Actions, recorded in role order by the binder. A conjunctive P can yield P;P; these are distinct from configured claims and derived labels. Rebind caller-edited role vectors before using this binding snapshot.

Source

pub fn property_claims(&self) -> &[Named]

Original configured property claims, or the temporal roles for a model without retained originals. A quantified conjunction must be attributed as one configured property, not as ambiguous identically named roles.

Source

pub fn eval(&self, pred: &Pred, st: &St) -> Result<Value>

Evaluates a role’s predicate.

§Errors

Any evaluation error, refusal or resource limit.

Source

pub fn eval_boolean(&self, pred: &Pred, st: &St) -> Result<bool>

Evaluates a configured Boolean role with TLC’s Tool.isValid boundary. A returned non-Boolean value raises the tool’s source-qualified 2215; an error inside the expression retains its original constructor/source.

let holds = model.eval_boolean(pred, state)?;
§Errors

The original evaluation failure, or the actual non-Boolean role failure.

Source

pub fn check_assumptions(&self) -> AssumptionOutcome

TLC’s Tool.checkAssumptions: the assumptions in order, AXIOMs skipped, stopping at the first that is not TRUE.

Source

pub fn check_assumptions_except(&self, proved: &[DefId]) -> AssumptionOutcome

Self::check_assumptions, skipping proved: pure assumptions (among Self::deferred_assumptions) another evaluator found TRUE. Skipping one is unobservable: TLC’s evaluation of it has no effect and does not stop the check.

Source

pub fn take_output(&self) -> Vec<String>

The Print output collected since the last call (the evaluator’s default sink).

Source

pub fn location(&self, pred: &Pred) -> String

The location TLC prints for a role’s predicate (getLocation()).

Source§

impl Model

Source

pub fn prepare_symmetry( &self, cfg: &ModelConfig, mode: Mode, limits: Limits, ) -> Result<Option<Prepared>, BindError>

Prepares a pure declaration using Tool.getSymmetryPerms’s ordering: representations, too-small warnings, domain/range checks, closure, then unused argument warnings. cfg must be the bound configuration. This API does not itself activate reduction or remove checker refusals.

§Example
let source = "---- MODULE M ----\nEXTENDS TLC\nCONSTANT S\nVARIABLE x\n\
              Init == x = TRUE\nNext == UNCHANGED x\n\
              Sym == Permutations(S)\n====\n";
let analysis = dive_sema::analyze_source("M.tla", source, &dive_sema::Options::default());
let ir = Arc::new(dive_ir::lower(&analysis).unwrap());
let cfg = dive_config::parse("CONSTANT S={a,b}\nINIT Init\nNEXT Next\nSYMMETRY Sym\n")
    .into_config().unwrap();
let model = bind(ir, &cfg, &BindOptions::tlc()).unwrap();
let prepared = model.prepare_symmetry(&cfg, Mode::Tlc, Limits::default()).unwrap().unwrap();
assert!(prepared.reduction.is_some());
assert!(prepared.warnings.is_empty());
§Errors

Invalid declarations, unavailable warning source evidence, unverified startup exceptions, or a bounded-closure refusal.

Source§

impl Model

Source

pub fn symmetry_declaration(&self) -> Result<Option<Declaration>, BindError>

Reads the configured pure symmetry definition from TLC’s pre-constant name-table snapshot and validates its set/function representations. Call once during startup, before checking. This does not build the group, issue too-small warnings or lift any checking refusal.

§Example
let source = "---- MODULE M ----\nEXTENDS TLC\nCONSTANT S\nVARIABLE x\n\
              Init == x = TRUE\nNext == UNCHANGED x\n\
              Sym == Permutations(S)\n====\n";
let analysis = dive_sema::analyze_source("M.tla", source, &dive_sema::Options::default());
let ir = Arc::new(dive_ir::lower(&analysis).unwrap());
let cfg = dive_config::parse("CONSTANT S={a,b}\nINIT Init\nNEXT Next\nSYMMETRY Sym\n")
    .into_config().unwrap();
let model = bind(ir, &cfg, &BindOptions::tlc()).unwrap();
let declaration = model.symmetry_declaration().unwrap().unwrap();
assert_eq!(declaration.functions.len(), 2);
assert!(!model.unsupported.is_empty()); // reduction remains unsupported
§Errors

TLC’s proved name/type, division-by-zero and set-comparison diagnostics; explicit refusals for unverified evaluation/normalization startup errors, or effectful, nonconstant and parameterized declarations. Domain/range validation, warning construction and kernel exceptions are later stages.

Trait Implementations§

Source§

impl Clone for Model

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 Debug for Model

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Model

§

impl !UnwindSafe for Model

§

impl Forget for Model

§

impl Freeze for Model

§

impl Move for Model

§

impl Send for Model

§

impl Sync for Model

§

impl Unpin for Model

§

impl UnsafeUnpin for Model

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.