A Tour of Temporal Typing Specifications & State · 5/6
Specifications & State · Page 5 of 6

Constants, Assumptions & Levels

A Constant[T] field is fixed by the Model and never changes during execution. An Assume(lambda s: ...) clause checks that the constants supplied to a model make sense before exploring any states.

Every expression in TLA⁺ has a level, and each clause enforces its maximum level:

LevelMay useClauses
0 Constantconstants onlyAssume, Where on Constant
1 State+ variables, enabledInit, Invariant, Requires, Pure
2 Action+ prime, unchanged, resultAction, ActionInvariant, Ensures
3 Temporal+ always, eventually, leads_to, fairnessProperty, Fairness

Using an expression above its clause's level — such as prime(s.used) inside an Invariant — is rejected statically as level-error.

Try it: Change constants={"limit": 3} to {"limit": 0} to trigger FAIL assumption positive_limit. Then try putting prime(s.used) inside within_limit to trigger ERROR [level-error]!
Click Check (or press Shift+Enter) to run the front-end and check this specification. Switch to TLA⁺ to view its TLA⁺ meaning.
---- MODULE RateLimiter ----
EXTENDS Integers
CONSTANT limit
VARIABLE used

ASSUME limit > 0

Init == used = 0
Allow == used < limit /\ used' = used + 1
ResetWindow == used' = 0
Next == Allow \/ ResetWindow
Spec == Init /\ [][Next]_used

WithinLimit == 0 <= used /\ used <= limit
====