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

Temporal Properties & Stuttering

An Invariant expresses safety: nothing bad ever happens. A Property expresses liveness: something good eventually happens.

Level-3 temporal primitives work inside Property:

  • always(p) — □p: p holds in every state of the behaviour.
  • eventually(p) — ◇p: p holds in some state of the behaviour.
  • leads_to(p, q) — p ~> q: whenever p holds, q eventually holds.

Now look at UnfairSemaphore on the right. It claims leads_to(s.available == 0, s.available > 0) — whenever the semaphore runs out of permits, a permit will eventually be released. Why does it FAIL?

Because in TLA⁺, □[Next]vars always permits stuttering: the system is allowed to stop taking steps forever! Without a Fairness assumption, the behaviour can reach available == 0 and simply sit there forever.

Try it: Click Check to see the stuttering lasso counterexample. On the next page we'll fix it with weak_fairness!
Click Check (or press Shift+Enter) to run the front-end and check this specification. Switch to TLA⁺ to view its TLA⁺ meaning.
---- MODULE UnfairSemaphore ----
EXTENDS Integers
CONSTANT capacity
VARIABLE available

ASSUME capacity > 0
Init == available = capacity
Acquire == available > 0 /\ available' = available - 1
Release == available < capacity /\ available' = available + 1
Next == Acquire \/ Release
Spec == Init /\ [][Next]_available  \* No fairness!

Progress == (available = 0) ~> (available > 0)
====