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 + Syncvalue; compound values are shared behindArcs, so cloning is cheap.Ctx: the semantics of a run:IntMode(TLC’s 32-bit integers or arbitrary precision) andValueOrder(TLC’s intern order or dive’s canonical order). Defaults are dive’s;Ctx::tlcis--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 jsonandJsonSerialize. - ops
- Set algebra on finite sets, as TLC evaluates it.
- TLC’s value printing.
- tlc
- TLC’s checked comparison, equality and membership.
Structs§
- Atom
- An interned name. Cloning is a reference-count increment.
- Concrete
Subset Stream - 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. - Receiver
Domain - One evaluator’s nonreused receiver-construction namespace.
- Receiver
Failure - 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.
- Subset
Commit - An exclusively borrowed commit, validated before any caller acquires a lock.
Dropping it without committing leaves the original stream unchanged.
commitdoes not allocate, deallocate, build/drop a Value or invoke a callback. - Subset
Scratch - Reusable preparation storage containing integers only, never Value owners. A failed or cancelled preparation leaves the original stream untouched.
- Value
Error - A value-layer error: a class plus the exact message TLC prints for it.
Enums§
- Construction
Error - Failure while constructing a materialized graph value.
- Deferred
Kind - See
DeferredSet::kind. - Domain
Lookup - A conservative exact-domain lookup, without evaluating unknown keys.
- Error
Kind - 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.
- Name
Error - Why a typed value’s name tokens cannot be trusted in a given name table.
- Receiver
Method - 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.
- Value
Order - 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
CHOOSEpicks.
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§
- Deferred
Set - 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.
- SetElement
Stream - An owned incremental stream of set elements, with no complete output buffer.
See
Set::concrete_element_streamfor construction and a bounded example.