Models, Domains & Symmetry

A Model is the Python equivalent of a TLC .cfg file: it binds constants and gives finite domains to the types a specification or contract quantifies over.

python
from temporal_typing import Model, Symmetry

PROCS = frozenset({Proc("p1"), Proc("p2"), Proc("p3")})

full_model = Model(Mutex, constants={"procs": PROCS}, domains={Proc: PROCS})
safety_model = Model(Mutex, constants={"procs": Symmetry(PROCS)}, domains={Proc: PROCS}, properties=())
bounded_model = Model(Counter, state_constraint=lambda s: s.x < 5)

Model Configuration Fields#

FieldDefaultMeaning
specrequiredThe specification class or contract function to check.
constants{}Mapping from Constant field name to concrete value (falls back to class-level defaults).
domains{}Mapping from type (class, alias, or TypeVar) to a finite collection (range, frozenset, list).
actionsNoneSequence of action names included in Next (all when None).
invariantsNoneSequence of Invariant / ActionInvariant names to check (all when None).
propertiesNoneSequence of Property names to check (all when None; pass () to skip liveness).
state_constraintNoneLevel-1 predicate bounding exploration (CONSTRAINT).
action_constraintNoneLevel-2 predicate bounding explored steps (ACTION_CONSTRAINT).
check_deadlockTrueWhether a reachable state with zero enabled actions is FAIL deadlock. Set False for terminating protocols.

Domain Resolution Order#

domains is always keyed by type (never by parameter name). When resolving a parameter's type, the front-end checks in strict priority order:

  1. An exact entry for the type as written, alias included (e.g. Positive).
  2. For Optional[T] / T | None: the domain of T plus None.
  3. Inherently finite types: bool, Literal[...], and Enum need no entry.
  4. The underlying base type under any Where clauses (e.g. int for Positive), then narrowed by every Where predicate.
No invented domains

A checker never guesses a domain (such as silently picking range(-5, 5) for int). Any quantified parameter without a resolved domain is an immediate ERROR [missing-domain]; an empty domain after Where narrowing is ERROR [vacuous].

Symmetry Reduction#

Wrapping a set of ModelValues in Symmetry(S) tells the checker that permutations of S are behaviourally equivalent (TLA⁺ SYMMETRY Permutations(S)), dramatically shrinking the state space (e.g., 160 states → 49 states in Two-Phase Commit).

Symmetry and liveness

Symmetry reduction is unsound for temporal properties and refinement because permuting states can hide unfair cycles. If a model uses Symmetry while checking any Property or Refines, the checker drops symmetry and emits WARN [symmetry-dropped]. Define a separate safety_model = Model(..., constants={...Symmetry(...)}, properties=()) to combine fast symmetric safety checks with full liveness checks.