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

Initial States & Defaults

The initial-state predicate Init is the conjunction of two sources:

  1. Every Init(lambda s: ...) clause in @spec.
  2. Every class-level or dataclass default on a State / Ghost field (e.g., target: State[int] = 20 means s.target == 20).

__init__ is ordinary Python and does not take part in Init. A state variable with no default and no Init clause mentioning it is a static error (no-init).

An Init clause may allow several starting values — for example s.current in range(18, 23) — causing the checker to explore from every matching initial state. Note: if a field has both a default and an Init clause, both are conjoined; remove = 20 on current if you want all 5 starting temperatures to be explored independently!

Try it: Notice current has both = 20 and s.current in range(18, 23) — so only current = 20 starts! Remove = 20 on current to explore all 5 initial states (18..22). Then remove = 20 on target too and see ERROR [no-init].
Click Check (or press Shift+Enter) to run the front-end and check this specification. Switch to TLA⁺ to view its TLA⁺ meaning.
---- MODULE Thermostat ----
EXTENDS Integers
VARIABLES target, current

Init == target = 20 /\ current = 20 /\ current \in 18..22
Warm == current < target /\ current' = current + 1 /\ UNCHANGED target
Cool == current > target /\ current' = current - 1 /\ UNCHANGED target
Next == Warm \/ Cool
Spec == Init /\ [][Next]_<<target, current>>

Comfortable == 18 <= current /\ current <= 22
====