TLA⁺ Semantics & Levels

Every Temporal Typing specification defines the standard TLA⁺ canonical formula from Lamport's Specifying Systems:

Spec ≡ Init ∧ □[Next]vars ∧ Fairness

where 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:

LevelNameAllowed ConstructsClauses
0ConstantConstants, constant operatorsAssume, Where on Constant
1StateLevel 0 + state/ghost variables, choose, enabledInit, Invariant, Requires, Where elsewhere, Pure, state_constraint
2ActionLevel 1 + prime, unchanged, resultAction, ActionInvariant, Ensures, action_constraint
3TemporalLevel 2 + always, eventually, leads_to, weak_fairness, strong_fairnessProperty, 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 DeclarationTLA⁺ Meaning
c: Constant[T]CONSTANT c
v: State[T], g: Ghost[T]VARIABLE v, VARIABLE g
Assume(p)ASSUME p
Init(p) + defaultsInit 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