Skip to main content

Crate dive_eval

Crate dive_eval 

Source
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 Print output, 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, enabled and getActions (tlc2/tool/impl/Tool.java, ported from tlaplus at 94d0c50), rule by rule.

Structs§

CollectSink
The default sink: collects the output in order.
ContextError
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.
EvalError
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.
HostBinding
A complete host installation, including its operative callback policy.
HostBindingScope
Restores the complete preceding host installation on drop.
HostBindingStamp
A read-only installation snapshot, not a semantic proof or concurrency lease.
HostControlConflict
Another thread currently owns the evaluator’s host control scope.
HostControlScope
Restores the evaluator’s previous host control when dropped.
HostError
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 function f[x \in S] == e.
Model
The bindings evaluation needs beyond the IR: the run’s names and the constants. dive-model builds it from the configuration.
NamedState
A partial existential assignment keyed by canonical IR variable name.
Options
The evaluator’s options.
ProducerStability
A producer/atom closure checked without evaluation for one evaluator.
RunConfig
TLCGet("config"): the run’s settings, as TLC’s AbstractChecker.createConfig records them.
Scope
TLC’s Context of a role (see the module documentation). Cheap to clone.
SimulationLease
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).
TupleConcatSources
A checked own-call fact for the supplied source roots of one evaluator.
ValueMethodFailure
Receiver construction provenance retained by a value-method catch. Its fields can only be supplied by the evaluator’s actual receiver.

Enums§

ActionComposition
Whether and how A \cdot B (action composition) is evaluated.
AssumptionOutcome
The outcome of checking the assumptions, as TLC’s Tool.checkAssumptions reports it.
Comparisons
How = and \in treat values that TLC refuses to compare.
ConstBinding
What the configuration binds a constant to.
ContextErrorKind
Stable classifications for context admission failures.
Counter
A live counter of the model checker, as TLCGet reads it.
Ec
A TLC error code (tlc2.output.EC) that evaluation can raise.
ErrorClass
What kind of failure an EvalError is.
ExceptionKind
Actual evaluator exception constructor, retained across typed value transport. This is not evidence that diagnostic replay executed or reached this error.
ExplorationOrder
In which order the evaluator explores sets: the bound sets of \E and \A, set filters {x \in S : P}, set maps {e : x \in S}, function constructors and (in dive_eval::next) x' \in S.
NativeHooks
Whether native permission hooks execute for an installed host.
Profile
The two profiles: dive’s default and --compat=tlc.
SlotView
What a slot of a scope holds, as the binding stage needs to see it.
StateRef
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 by dive_ir::VarId, None where unassigned. Existential queries can instead retain hidden assignments by canonical name.
ValueMethod
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 of TLCGet("config") and TLCGet("stats").

Traits§

Host
The run hosting the evaluator: the model checker (or another driver).
HostControl
Optional run control, separate from specification-visible host operations.
PrintSink
Where Print and PrintT output goes.

Functions§

deferred_filter_normalization_operand
The operand visited by TLC’s SetPredValue.deepNormalize method.
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.