-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dice.tla
67 lines (51 loc) · 1.55 KB
/
Dice.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
-------------------------------- MODULE Dice --------------------------------
EXTENDS Naturals, TLC
(* --algorithm Dice
variables
state \in { "steady", "rolling" },
current \in 1..6;
begin
Roll:
if state = "steady" then
A: state := "rolling";
end if;
B: state := "steady";
with result \in 1..6 do
current := result;
print current;
end with;
end algorithm *)
\* BEGIN TRANSLATION (chksum(pcal) = "58e5b60" /\ chksum(tla) = "684d86a5")
VARIABLES state, current, pc
vars == << state, current, pc >>
Init == (* Global variables *)
/\ state \in { "steady", "rolling" }
/\ current \in 1..6
/\ pc = "Roll"
Roll == /\ pc = "Roll"
/\ IF state = "steady"
THEN /\ pc' = "A"
ELSE /\ pc' = "B"
/\ UNCHANGED << state, current >>
A == /\ pc = "A"
/\ state' = "rolling"
/\ pc' = "B"
/\ UNCHANGED current
B == /\ pc = "B"
/\ state' = "steady"
/\ \E result \in 1..6:
/\ current' = result
/\ PrintT(current')
/\ pc' = "Done"
(* Allow infinite stuttering to prevent deadlock on termination. *)
Terminating == pc = "Done" /\ UNCHANGED vars
Next == Roll \/ A \/ B
\/ Terminating
Spec == Init /\ [][Next]_vars
Termination == <>(pc = "Done")
\* END TRANSLATION
CurrentInRange == current \in 1..6
=============================================================================
\* Modification History
\* Last modified Mon Jun 14 17:43:08 CEST 2021 by mts
\* Created Mon Jun 14 15:17:25 CEST 2021 by mts