-
Notifications
You must be signed in to change notification settings - Fork 0
/
TicTac.tla
48 lines (37 loc) · 1005 Bytes
/
TicTac.tla
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
--------------------------------- MODULE TicTac ---------------------------------
EXTENDS Naturals, Integers, TLC
Abs(x) == IF x > 0 THEN x ELSE -x
VARIABLE clockValue, nTick, nTack, action
vars == <<action, clockValue, nTick, nTack>>
Init ==
/\ clockValue = 0
/\ nTick = 0
/\ nTack = 0
/\ action \in {"Tick", "Tack"}
TypeInv ==
/\ clockValue >= 0
/\ nTick \in Nat
/\ nTack \in Nat
/\ action \in {"Tick", "Tack"}
/\ Abs(nTick - nTack) <= 1
Tick ==
/\ action = "Tack"
/\ clockValue' = clockValue + 1
/\ nTick' = nTick + 1
/\ action' = "Tick"
/\ UNCHANGED nTack
Tack ==
/\ action = "Tick"
/\ clockValue' = clockValue + 1
/\ nTack' = nTack + 1
/\ action' = "Tack"
/\ UNCHANGED nTick
ResetClock ==
/\ clockValue' = 0
/\ UNCHANGED <<action, nTick, nTack>>
Next ==
\/ Tick
\/ Tack
\/ ResetClock
Spec == Init /\ [][Next]_vars
===============================================================================