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

Actions, Guards, and prime

Each action method has up to four clause kinds inside its Annotated[...] return type:

  • Requires(p) — the guard. The action is enabled only when every Requires holds.
  • Action(p) — the transition, relating before (s.x) and after (prime(s.x)).
  • Ensures(p) — postcondition on the step and return result.
  • Modifies("v", ...) — explicit frame restricting which variables may change.

Automatic frame rule: In TLA⁺ you must manually write UNCHANGED <<...>> for every variable an action leaves alone. In temporal-typing, an action changes only the variables in its frame (the ones named in Modifies, written by its body, or placed under prime(...)). Every other variable is implicitly unchanged — though you may still write unchanged(s.level) explicitly for emphasis.

Try it: Look at fill: it primes only s.level, so valve_open stays unchanged automatically. Change s.level < 5 to s.level <= 5 and click Check to violate within_capacity.
Click Check (or press Shift+Enter) to run the front-end and check this specification. Switch to TLA⁺ to view its TLA⁺ meaning.
---- MODULE WaterTank ----
EXTENDS Integers
VARIABLES level, valve_open

Init == level = 0 /\ valve_open = FALSE
OpenValve  == ~valve_open /\ valve_open' = TRUE /\ UNCHANGED level
CloseValve == valve_open /\ valve_open' = FALSE /\ UNCHANGED level
Fill       == valve_open /\ level < 5 /\ level' = level + 1 /\ UNCHANGED valve_open
Drain      == level > 0 /\ level' = level - 1 /\ UNCHANGED valve_open
Next == OpenValve \/ CloseValve \/ Fill \/ Drain
Spec == Init /\ [][Next]_<<level, valve_open>>

WithinCapacity == 0 <= level /\ level <= 5
====