Models & Front-End API

Model configuration classes from temporal_typing and the shared static front-end API in temporal_typing.frontend.

Model Declarations#

Model(spec, *, constants={}, domains={}, actions=None, invariants=None, properties=None, state_constraint=None, action_constraint=None, check_deadlock=True)#

Frozen dataclass describing a finite model-checking configuration for a specification class or contract function.

ParameterTypeDescription
spectype | CallableSpecification class decorated with @spec or a contract function.
constantsMapping[str, Any]Concrete values for Constant fields, by name.
domainsMapping[Any, Iterable[Any]]Finite collections keyed by type (class, alias, or TypeVar).
actions / invariants / propertiesSequence[str] | NoneOptional clause-name filters (None checks all; () checks none).
state_constraint / action_constraintCallable[..., bool] | NonePredicates bounding reachable states or steps.
check_deadlockboolWhether deadlock states fail checking (default True).

class ModelValue(name: str)#

Base class for opaque, symmetric TLA⁺ model values. Subclass it to declare a distinct sort (e.g., class Proc(ModelValue): pass). Values compare equal only to identical sort + name.

python
class Proc(ModelValue):
    pass

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

class Symmetry(frozenset[T])#

TLA⁺: SYMMETRY Permutations(S)

A frozenset of ModelValues declaring permutation symmetry for state-space reduction. Dropped with symmetry-dropped warning when checking temporal properties or refinement.

Shared Front-End (temporal_typing.frontend)#

temporal_typing.frontend.load(paths: Iterable[PathArg], roots: Iterable[PathArg] = ()) -> Program#

Reads Python files and directories statically without importing or executing them, resolves local imports, merges MRO inheritance, infers action frames, resolves domains, and collects all diagnostics.

python
from temporal_typing.frontend import load

program = load(["examples/"])
for model in program.models:
    if program.errors_of(model):
        print("ERROR:", model.name, program.errors_of(model))
    else:
        print("READY:", model.name)

class Program(specs, contracts, models, diagnostics)#

Immutable IR returned by load(). Properties .errors and .warnings filter diagnostics globally; .diagnostics_of(model) and .errors_of(model) return diagnostics scoped to what a specific model reads.

Front-End CLI#

bash
python -m temporal_typing [--root DIR] [--json] [-q] PATH ...

# Options:
#   --root DIR   Additional import search directory
#   --json       Emit structured JSON (specs, contracts, models, diagnostics)
#   -q, --quiet  Print diagnostics only (exit 0 on 0 errors, 1 on any error)