A Tour of Temporal Typing Liveness & Fairness · 1/5
Liveness & Fairness · Page 1 of 5

Model Values & Parameterized Actions

Concurrent and distributed systems involve multiple processes, nodes, or clients. Subclass ModelValue to declare opaque, distinct identities (TLA⁺ model values):

class Proc(ModelValue):
    pass

An action with parameters like def acquire(self, p: Proc) is existentially quantified in Next: a step may take acquire(p) for any p in the model's domain for Proc.

Inside predicates, Python's all(...) and any(...) over finite sets are TLA⁺'s ∀ and ∃. You can also check whether an action is enabled in the current state with enabled(s.acquire(p)) — a Level-1 expression, so it is legal inside an Invariant like never_stuck!

Try it: Click Check to verify all 8 states of the 2-process mutex. Notice how s.waiting | {p} and s.waiting - {p} use ordinary Python frozenset operators.
Click Check (or press Shift+Enter) to run the front-end and check this specification. Switch to TLA⁺ to view its TLA⁺ meaning.
---- MODULE MutexSafety ----
CONSTANT procs
VARIABLES holder, waiting

ASSUME procs # {}
Init == holder = NULL /\ waiting = {}
Request(p) == p \notin waiting /\ holder # p /\ waiting' = waiting \cup {p} /\ UNCHANGED holder
Acquire(p) == p \in waiting /\ holder = NULL /\ holder' = p /\ waiting' = waiting \ {p}
Release(p) == holder = p /\ holder' = NULL /\ UNCHANGED waiting
Next == \E p \in procs : Request(p) \/ Acquire(p) \/ Release(p)

NeverStuck == \E p \in procs : ENABLED Request(p) \/ ENABLED Acquire(p) \/ ENABLED Release(p)
====