Expand description
dive-eval: the evaluator for expressions and actions over states.
It evaluates the IR (dive_ir) over dive-value values with
TLC’s semantics: TLC’s evaluation order, its laziness (operator arguments,
zero-arity LET definitions and instance substitutions are thunks forced
under TLC’s caching rule), its lazy sets and functions, CHOOSE in the
run’s value order, and TLC’s errors with TLC’s messages. Anything it does
not implement exactly is refused as ErrorClass::Unsupported, naming
the feature.
§Using it
A Model binds the IR’s constants (normally built by dive-model from
the configuration); an Evaluator evaluates definitions, expressions
and assumptions under Options:
use std::sync::Arc;
use dive_eval::{Evaluator, Model, Options, St};
use dive_sema::{Options as SemaOptions, analyze_source};
let src = "---- MODULE M ----\nEXTENDS Naturals\nTwice(n) == n + n\nX == Twice(21)\n====\n";
let ir = dive_ir::lower(&analyze_source("M.tla", src, &SemaOptions::default())).expect("lowers");
let x = ir.root_def("X").expect("defined");
let ev = Evaluator::new(Model::new(Arc::new(ir)), Options::tlc()).expect("valid context");
assert_eq!(ev.eval_def(x, &St::constant()).expect("evaluates"), 42.into());§How the successor generator plugs in
dive_eval::next ports TLC’s getInitStates, getNextStates,
getActions and enabled: it generates initial states and successors in
TLC’s order, duplicates included, evaluating the non-action parts of an
action through this interpreter against the partial successor it is
building, and uses EvalError for the error classes. ENABLED goes
through it too, for the checker and the trace validator alike.
Modules§
- capture
- Per-thread capture of
Printoutput, for a parallel checker that releases output in TLC’s sequential order. - inputs
- Explicit host categories and bounded, source-ordered external input replay.
- next
- The successor generator: ports of TLC’s
Tool.getInitStates,Tool.getNextStates,processUnchanged,enabledandgetActions(tlc2/tool/impl/Tool.java, ported from tlaplus at94d0c50), rule by rule.
Structs§
- Collect
Sink - The default sink: collects the output in order.
- Context
Error - A malformed public evaluator input. Numeric IDs are relative to the supplied IR; equal indices alone cannot establish which IR a caller obtained them from.
- Eval
Error - An evaluation error: its class, TLC’s code and message, and the node it was raised at.
- Evaluator
- An evaluator for one specification and model.
- Host
Binding - A complete host installation, including its operative callback policy.
- Host
Binding Scope - Restores the complete preceding host installation on drop.
- Host
Binding Stamp - A read-only installation snapshot, not a semantic proof or concurrency lease.
- Host
Control Conflict - Another thread currently owns the evaluator’s host control scope.
- Host
Control Scope - Restores the evaluator’s previous host control when dropped.
- Host
Error - An error raised by a host operation, with TLC’s code and message.
- Interrupted
- A cooperative interruption requested by the evaluator’s host.
- LazyFcn
- TLC’s
FcnLambdaValue:[x \in S |-> e]kept as a lambda, or a recursive functionf[x \in S] == e. - Model
- The bindings evaluation needs beyond the IR: the run’s names and the
constants.
dive-modelbuilds it from the configuration. - Named
State - A partial existential assignment keyed by canonical IR variable name.
- Options
- The evaluator’s options.
- Producer
Stability - A producer/atom closure checked without evaluation for one evaluator.
- RunConfig
TLCGet("config"): the run’s settings, as TLC’sAbstractChecker.createConfigrecords them.- Scope
- TLC’s
Contextof a role (see the module documentation). Cheap to clone. - Simulation
Lease - Exclusive simulation entry on a shared evaluator core. Dropping the lease permits the next simulation. The driver must restore its host before drop. Ordinary evaluator operations and host setters keep their existing behavior; callers must not mix foreign evaluator/host operations with an active simulation.
- St
- The states and control flags an expression is evaluated under: TLC’s
(s0, s1, control). - Tuple
Concat Sources - A checked own-call fact for the supplied source roots of one evaluator.
- Value
Method Failure - Receiver construction provenance retained by a value-method catch. Its fields can only be supplied by the evaluator’s actual receiver.
Enums§
- Action
Composition - Whether and how
A \cdot B(action composition) is evaluated. - Assumption
Outcome - The outcome of checking the assumptions, as TLC’s
Tool.checkAssumptionsreports it. - Comparisons
- How
=and\intreat values that TLC refuses to compare. - Const
Binding - What the configuration binds a constant to.
- Context
Error Kind - Stable classifications for context admission failures.
- Counter
- A live counter of the model checker, as
TLCGetreads it. - Ec
- A TLC error code (
tlc2.output.EC) that evaluation can raise. - Error
Class - What kind of failure an
EvalErroris. - Exception
Kind - Actual evaluator exception constructor, retained across typed value transport. This is not evidence that diagnostic replay executed or reached this error.
- Exploration
Order - In which order the evaluator explores sets: the bound sets of
\Eand\A, set filters{x \in S : P}, set maps{e : x \in S}, function constructors and (indive_eval::next)x' \in S. - Native
Hooks - Whether native permission hooks execute for an installed host.
- Profile
- The two profiles: dive’s default and
--compat=tlc. - Slot
View - What a slot of a scope holds, as the binding stage needs to see it.
- State
Ref - A state as the evaluator sees it: TLC’s
TLCState.Null(no state),TLCState.Empty(a state with no variable assigned), or the values of the root module’s variables bydive_ir::VarId,Nonewhere unassigned. Existential queries can instead retain hidden assignments by canonical name. - Value
Method - The value method that actually caught an evaluation failure.
Constants§
- DEFAULT_
MAX_ DEPTH - The default evaluation depth limit. Evaluation runs on the caller’s stack; callers that raise this must provide a correspondingly large stack.
- PRIMED_
LEVEL_ UNSUPPORTED - The refusal of a primed
TLCGet("level")(Host::successor_level). - RECOMMENDED_
STACK - The stack size evaluation needs at
DEFAULT_MAX_DEPTH, with room to spare, in an unoptimized build. Run evaluation on a thread with at least this much stack (workers run on threads with large stacks). - TLCGET_
NAMES - The names
TLCGetSet’s static initializer interns, in declaration order (tlc2/module/TLCGetSet.java:52-162). TLC loads the class when it creates its model checker (AbstractChecker.createConfig), after processing constant definitions and before checking assumptions; a driver that reproduces TLC’s name order interns them then (crate::Evaluator::intern_checker_names). They decide the order of the fields ofTLCGet("config")andTLCGet("stats").
Traits§
- Host
- The run hosting the evaluator: the model checker (or another driver).
- Host
Control - Optional run control, separate from specification-visible host operations.
- Print
Sink - Where
PrintandPrintToutput goes.
Functions§
- deferred_
filter_ normalization_ operand - The operand visited by TLC’s
SetPredValue.deepNormalizemethod. - validate_
ir - Admits a public IR arena without creating an evaluator, interning literals, evaluating expressions or invoking caller code. Uses the same structural authority as evaluator construction with empty constant/override bindings.
Type Aliases§
- Result
- Result alias for evaluation.