-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhanoi.tla
56 lines (45 loc) · 1.56 KB
/
hanoi.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
------------------------------- MODULE hanoi -------------------------------
EXTENDS TLC, Sequences, Integers
(* --algorithm hanoi
variables tower = <<<<1, 2, 3, 4>>, <<>>, <<>>>>,
define
D == DOMAIN tower
end define;
begin
while TRUE do
assert tower[3] /= <<1, 2, 3, 4>>;
with from \in {x \in D : tower[x] /= <<>>},
to \in {
y \in D :
\/ tower[y] = <<>>
\/ Head(tower[from]) < Head(tower[y])
}
do
tower[from] := Tail(tower[from]) ||
tower[to] := <<Head(tower[from])>> \o tower[to];
end with;
end while;
end algorithm; *)
\* BEGIN TRANSLATION
VARIABLE tower
(* define statement *)
D == DOMAIN tower
vars == << tower >>
Init == (* Global variables *)
/\ tower = <<<<1, 2, 3, 4>>, <<>>, <<>>>>
Next == /\ Assert(tower[3] /= <<1, 2, 3, 4>>,
"Failure of assertion at line 14, column 3.")
/\ \E from \in {x \in D : tower[x] /= <<>>}:
\E to \in {
y \in D :
\/ tower[y] = <<>>
\/ Head(tower[from]) < Head(tower[y])
}:
tower' = [tower EXCEPT ![from] = Tail(tower[from]),
![to] = <<Head(tower[from])>> \o tower[to]]
Spec == Init /\ [][Next]_vars
\* END TRANSLATION
=============================================================================
\* Modification History
\* Last modified Sat Jan 19 20:34:31 CST 2019 by bilibili
\* Created Sat Jan 19 20:32:35 CST 2019 by bilibili