TLA⁺ Semantics & Levels
Every Temporal Typing specification defines the standard TLA⁺ canonical formula from Lamport's Specifying Systems:
Spec ≡ Init ∧ □[Next]vars ∧ Fairnesswhere vars is the tuple of all State and Ghost variables, Next is the disjunction of every existentially-quantified action A∃ over its parameter domains, and Fairness is the conjunction of all Fairness clauses. Every Assume, Invariant, ActionInvariant, and Property is a claim checked against Spec.
The Four Expression Levels#
Every expression has a TLA⁺ level (0 through 3), and each clause enforces a maximum allowed level. Exceeding a clause's level is rejected statically as level-error:
| Level | Name | Allowed Constructs | Clauses |
|---|---|---|---|
| 0 | Constant | Constants, constant operators | Assume, Where on Constant |
| 1 | State | Level 0 + state/ghost variables, choose, enabled | Init, Invariant, Requires, Where elsewhere, Pure, state_constraint |
| 2 | Action | Level 1 + prime, unchanged, result | Action, ActionInvariant, Ensures, action_constraint |
| 3 | Temporal | Level 2 + always, eventually, leads_to, weak_fairness, strong_fairness | Property, Fairness |
Note that weak_fairness and strong_fairness are restricted to Fairness clauses only (using them in Property or elsewhere is misplaced-clause).
Declaration-to-TLA⁺ Mapping#
| Python Declaration | TLA⁺ Meaning |
|---|---|
c: Constant[T] | CONSTANT c |
v: State[T], g: Ghost[T] | VARIABLE v, VARIABLE g |
Assume(p) | ASSUME p |
Init(p) + defaults | Init conjunction |
Invariant(p) | □p |
ActionInvariant(p) | □[p]vars |
Property(p) | Temporal property p |
Fairness(p) | Fairness conjunct in Spec |
all(p(x) for x in S) / any(...) | ∀ x ∈ S : p(x) / ∃ x ∈ S : p(x) |
def m(self) -> Refines[A] | INSTANCE A WITH ... and C!Spec ⇒ Ā!Spec |