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

Weak Fairness

A Fairness clause tells the checker what we assume about the scheduler.

weak_fairness(s.release()) — TLA⁺'s WFvars(release) — says: if release() stays continuously enabled, it must eventually happen.

Notice the syntax: inside Fairness (and enabled), actions are written like method calls on s — s.release(). You can optionally pass on=e to specify a different TLA⁺ subscript (WFe(A)), defaulting to all state and ghost variables.

When available == 0, acquire() is disabled and release() stays continuously enabled until it fires. So weak fairness on release() eliminates the stuttering loop and makes progress hold!

Try it: Click Check to verify progress passes. Then comment out the fair=Fairness(...) line and check again to watch the stuttering counterexample return!
Click Check (or press Shift+Enter) to run the front-end and check this specification. Switch to TLA⁺ to view its TLA⁺ meaning.
---- MODULE FairSemaphore ----
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 /\ WF_available(Release)

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