A Tour of Temporal Typing Code, Contracts & Types · 1/6
Code, Contracts & Types · Page 1 of 6

Code as Its Own Specification

You do not have to write every transition twice. Give a method a real Python body and Action() with no predicate, and the checker uses the Python body itself as the transition.

Everything inside the body keeps its exact Python semantics: floor division (//), negative indexing, short-circuiting and/or, and mutation of state attributes. An assert statement inside an action body is verified across every reachable state — a failing assert is reported as FAIL assertion, and a raise on a reachable path fails too.

Try it: Remove Requires(lambda s: s.x > 0), from decrement and click Check. From the initial state x = 0, decrement() immediately hits assert self.x >= 0 and fails with an assertion trace!
Click Check (or press Shift+Enter) to run the front-end and check this specification. Switch to TLA⁺ to view its TLA⁺ meaning.
---- MODULE Counter ----
EXTENDS Integers
VARIABLE x

Init == x = 0
Increment == x < 5 /\ x' = x + 1
Decrement == x > 0 /\ x' = x - 1 /\ Assert(x' >= 0)
Next == Increment \/ Decrement
Spec == Init /\ [][Next]_x

Bounded == 0 <= x /\ x <= 5
====