Skip to main content

Crate dive_value

Crate dive_value 

Source
Expand description

dive-value: TLA+ values with TLC’s canonical ordering, equality, printing and fingerprints; model values; lazy and enumerable sets.

The crate has no dependencies on other dive crates. The design records behind it are in the repository’s decision records.

§Overview

  • Value: an immutable, 16-byte, Send + Sync value; compound values are shared behind Arcs, so cloning is cheap.
  • Ctx: the semantics of a run: IntMode (TLC’s 32-bit integers or arbitrary precision) and ValueOrder (TLC’s intern order or dive’s canonical order). Defaults are dive’s; Ctx::tlc is --compat=tlc.
  • Interner: the run’s table of names (strings, model values, record fields).
  • tlc: TLC’s checked equality, comparison and membership, with TLC’s errors.
  • print: TLC’s value printing and pretty-printer.
  • fp64: TLC’s FP64 fingerprints.
  • json: TLC’s JSON form of values.
  • codec: compact, deterministic byte encodings of values for state storage.
use dive_value::{Ctx, Interner, Value, print::print_value, tlc};

let ctx = Ctx::tlc();
let names = Interner::new();
let s = Value::set(
    vec![Value::string(&names, "b"), Value::string(&names, "a")],
    ctx,
)?;
// TLC orders strings by intern order: "b" was interned first.
assert_eq!(print_value(&s, ctx)?, r#"{"b", "a"}"#);

// TLC refuses to compare an integer with a string.
let err = tlc::equals(&Value::from(1), &Value::string(&names, "a"), ctx).unwrap_err();
assert_eq!(err.message(), "Attempted to check equality of integer 1 with non-integer:\n\"a\"");

Modules§

codec
A compact, deterministic byte encoding of values.
fp64
Fingerprints: TLC’s FP64.
json
TLC’s JSON form of values, as written by -dumpTrace json and JsonSerialize.
ops
Set algebra on finite sets, as TLC evaluates it.
print
TLC’s value printing.
tlc
TLC’s checked comparison, equality and membership.

Structs§

Atom
An interned name. Cloning is a reference-count increment.
ConcreteSubsetStream
A concrete powerset stream retaining its original normalized base and order.
Ctx
The value semantics of one run. Cheap to copy; pass it to every operation that may compare, normalize, enumerate or print values.
Fcn
A finite function. Cloning is a reference-count increment.
Interner
The table of names for one run. Thread-safe; share it with an Arc.
ReceiverDomain
One evaluator’s nonreused receiver-construction namespace.
ReceiverFailure
A value-method catch with sealed receiver construction, recoverable only by the evaluator that constructed it. Text and an error code cannot create it.
Set
A set, enumerated or lazy. Cloning is a reference-count increment.
SubsetCommit
An exclusively borrowed commit, validated before any caller acquires a lock. Dropping it without committing leaves the original stream unchanged. commit does not allocate, deallocate, build/drop a Value or invoke a callback.
SubsetScratch
Reusable preparation storage containing integers only, never Value owners. A failed or cancelled preparation leaves the original stream untouched.
ValueError
A value-layer error: a class plus the exact message TLC prints for it.

Enums§

ConstructionError
Failure while constructing a materialized graph value.
DeferredKind
See DeferredSet::kind.
DomainLookup
A conservative exact-domain lookup, without evaluating unknown keys.
ErrorKind
The class of a value-layer error.
FcnKind
The shape of a function’s domain.
Int
An integer: inline when it fits in an i64, otherwise a shared big integer.
IntMode
How integers behave.
NameError
Why a typed value’s name tokens cannot be trusted in a given name table.
ReceiverMethod
The actual literal receiver method that caught a value-layer error.
SetKind
The kind of a set, as a plain enum for matching.
Value
A TLA+ value.
ValueOrder
How names (strings, model values and record field names) are ordered. The order of every other value is built from it, so this decides set order, printing order and which element CHOOSE picks.

Constants§

MAX_DEPTH
The deepest nesting the recursive algorithms accept: safe on a 2 MiB thread stack even in debug builds (measured margin: about 1.5x).
MAX_ENUMERATION
The most elements dive will materialize in one set.

Traits§

DeferredSet
The source of an evaluator-driven lazy set ({x \in S : P} or {e : x \in S}).

Functions§

checked_operation_depth
Current checked-operation nesting on this thread, without entering a level. This snapshot changes no depth policy and grants no authority to skip work.
quiet_operation_active
Whether this thread is normalizing a value without observable side effects.

Type Aliases§

Result
Result alias for value-layer operations.
SetElementStream
An owned incremental stream of set elements, with no complete output buffer. See Set::concrete_element_stream for construction and a bounded example.