Expand description
dive-model: binding a specification to its TLC model configuration.
This is a port of TLC’s tlc2.tool.impl.SpecProcessor (tlaplus
94d0c50), with the parts of Spec and Tool that finish setting up a
model. bind takes the lowered specification and the parsed
configuration and does what TLC does before it checks the assumptions, in
TLC’s order:
- Literals (
processConstants): a numeral too big for--int=tlcor a decimal stops TLC first. - Names (
intern): the run’s name table is filled in TLC’s encounter order, so that strings and model values order and fingerprint as in TLC. - Constants and overrides (
processSpec): every root constant must be assigned (C = v) or substituted (C <- D);Op = vandOp <- Dreplace definitions;[M]entries replace definitions of moduleM. Errors carry TLC’s codes (Ec). - Constant definitions (
processConstantDefns): every zero-arity definition TLC’s level bound (level) finds constant is evaluated at start-up, module by module, and its value is used from then on.Printoutput appears here, as in TLC. - Roles (
processConfig): invariants, the behavior specification (INIT/NEXTorSPECIFICATION, split into initial predicates, the next-state relation and temporal formulas), properties (split into invariants, implied initial predicates, implied actions and temporal properties), constraints,VIEW. - Actions (
Tool.getActions): the next-state relation split into TLC’s actions, with their labels, asdive_eval::nextactions.
The result is a Model: an dive_eval::Evaluator with everything
bound, and every role as a Pred (an expression and the scope TLC
evaluates it in). Features dive does not check yet (liveness, SYMMETRY,
operators it does not implement) are listed in Model::unsupported;
the checker refuses such a model by name. Anything this stage cannot do
exactly is an ErrorKind::Unsupported error.
§Java overrides and loaded modules
Which Java implementation TLC uses for a standard operator depends on the
modules loaded: Integers’ methods replace Naturals’ when both are
loaded. The IR records the active override of every definition, computed
from the loaded modules (dive_ir::std_op). TLC’s -dumpTrace json
loads _JsonTrace, and with it Integers, without extending the root
module; dive_sema::Options::extra_root_extendees reproduces that for
oracle comparison (see DUMP_TRACE_JSON_MODULES).
§Example
use std::sync::Arc;
use dive_model::{bind, BindOptions};
let src = "---- MODULE M ----\nEXTENDS Naturals, TLC\nCONSTANT N\nVARIABLE x\n\
Max == Print(N, N * 2)\nInit == x = 0\nNext == x < Max /\\ x' = x + 1\n\
Inv == x <= Max\n====\n";
let analysis = dive_sema::analyze_source("M.tla", src, &dive_sema::Options::default());
let ir = Arc::new(dive_ir::lower(&analysis).unwrap());
let cfg = dive_config::parse("CONSTANT N = 3\nINIT Init\nNEXT Next\nINVARIANT Inv\n")
.into_config()
.unwrap();
let model = bind(ir, &cfg, &BindOptions::tlc()).unwrap();
// `Max` is evaluated once, at start-up, as TLC does.
assert_eq!(model.output, [dive_model::Message::Print("3 6".to_owned())]);
assert_eq!(model.invariants[0].name, "Inv");
assert_eq!(model.actions.len(), 1);
assert!(model.actions[0].label().starts_with("<Next line 7, col 9 to line 7, col"));Re-exports§
pub use symmetry::SymmetryLiveness;pub use symmetry::SymmetryLivenessResolution;
Modules§
- intern
- The run’s name table, fed in TLC’s encounter order.
- level
- TLC’s level bound (
SymbolNodeValueLookupProvider.getLevelBoundandgetLevelBoundAppl, tlaplus94d0c50). - symmetry
- Pure symmetry declaration preparation, bounded closure and safety keys.
Structs§
- Bind
Error - An error binding the model.
- Bind
Options - How the binding stage runs.
- Failure
- A failed binding: the error, and what TLC printed before it.
- Init
- An initial predicate (
getInitStateSpec). - Model
- A specification bound to its configuration.
- Named
- A role with the name TLC reports it under.
- Pred
- A predicate or expression TLC evaluates for a role, with the context it
is evaluated in: TLC’s
tlc2.tool.Action(pred,con). - Recipe
- Immutable inputs for reconstructing a model’s startup runtime.
- Settings
- The
-deadlockandCHECK_DEADLOCKoutcome and other run settings. - Unsupported
- A feature of the model that dive does not check yet. The checker refuses
the model as
unsupported, naming it.
Enums§
- Controlled
Bind Error - A controlled binding failed, preserving startup output and run ownership.
- Ec
- TLC’s message codes (
tlc2.output.EC) the binding stage reports. - Error
Kind - What kind of failure a
BindErroris. - Message
- Something TLC prints while it processes the model, in order.
- Unsupported
Kind - Why the model cannot yet receive a complete checking verdict.
Constants§
- DUMP_
TRACE_ JSON_ MODULES - The modules TLC’s
-dumpTrace json <file>loads in addition to the specification’s own (TLC.javaadds the_JsonTracepost-condition, andParameterizedSpecObjmakes SANY load_JsonTraceas if the root module extended it). Pass it asdive_sema::Options::extra_root_extendeesto reproduce the conformance harness’s TLC runs, which use-dumpTrace json: it changes which Java overrides are active (IntegersreplacesNaturals’ arithmetic) and the encounter order of names. TLC as users run it, and so--compat=tlc, does not load them. Oracle reproduction only, until the goldens are regenerated without-dumpTrace(issue #35). - HANOI_
BITS_ CLASS_ SHA256 - SHA-256 of the supported local
Bits.classfrom the pinned Examples Hanoi model. - TLC_
CDOT - TLC’s action composition counts its intermediate states as generated; the parallel engine’s per-source counts double as successor ordinals. Sequential BFS reason for TLC composition intermediate-state accounting. DFID and simulation ignore those intermediate states, as their TLC functors do.
Functions§
- bind
- Binds
irtocfgas TLC does (see the crate documentation). - bind_
controlled - Binds a fresh model with typed cooperative evaluator control.
- bind_
deferring_ constants - Binds
irtocfgfor Core: asbind, except that the pure constant-level definitions used only as values by the roles the core compiles are not evaluated at start-up. They are listed inModel::deferred_constants, for the core to evaluate when it compiles its plan; the model’s own evaluator evaluates them lazily wherever it needs them, with the same values. The root module’s pureASSUMEs are listed inModel::deferred_assumptions: the core evaluates them when it compiles its plan, andModel::check_assumptions_exceptchecks the others. With genuine temporal properties, the definitions those properties, the specification’s fairness and the configured properties reach are evaluated at start-up asbindevaluates them, for the dive-eval evaluator that checks them; the core keeps the others. - local_
java_ class_ digests - SHA-256 identities of adjacent local Java classes, sorted by module name.
- transformed_
randomness - Names an unsupported random interaction with VIEW or SYMMETRY, without evaluating source, binding constants or invoking a host callback.