A Tour of Temporal Typing Specifications & State · 1/6
Specifications & State · Page 1 of 6

A Specification Is a Class

A specification is a Python class — a Protocol, a @dataclass, a plain class, or a Generic.

  • State variables are fields annotated with State[T].
  • Class clauses are named keyword arguments to @spec(...), each taking a predicate lambda s: ... where s is the state.
  • Actions are methods whose return annotation carries Action(...).

When a method body is ..., the method is abstract: its Action predicate is the transition. Because @spec does not alter the class's type, Counter remains a normal Protocol that any matching Python class satisfies.

Try it: Change the guard in increment from s.x < 10 to s.x <= 10 and click Check. Watch the checker reach x = 11 and fail bounded.
Click Check (or press Shift+Enter) to run the front-end and check this specification. Switch to TLA⁺ to view its TLA⁺ meaning.
---- MODULE Counter ----
EXTENDS Integers
VARIABLE x

Init == x = 0
Increment == x < 10 /\ x' = x + 1
Reset == x' = 0
Next == Increment \/ Reset
Spec == Init /\ [][Next]_x

Bounded == 0 <= x /\ x <= 10
====