-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPDieHard.tla
54 lines (48 loc) · 1.74 KB
/
PDieHard.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
------------------------------ MODULE PDieHard ------------------------------
EXTENDS Integers
Min(m, n) == IF m < n THEN m ELSE n
(***************************************************************************
--algorithm DieHard {
variables big = 0, small = 0;
{ while (TRUE)
either big := 5 \* fill the big jug
or small := 3 \* fill the small jug
or big := 0 \* empty the big jug
or small := 0 \* empty the small jug
or \* pour from small to big
with (poured = Min (big - small, 5) - big)
{ big := big + poured;
small := small - poured; }
or \* pour from big to small
with (poured = Min (small - big, 3) - small)
{ big := big - poured;
small := small + poured; }
}
}
***************************************************************************)
\* BEGIN TRANSLATION
VARIABLES big, small
vars == << big, small >>
Init == (* Global variables *)
/\ big = 0
/\ small = 0
Next == \/ /\ big' = 5
/\ small' = small
\/ /\ small' = 3
/\ big' = big
\/ /\ big' = 0
/\ small' = small
\/ /\ small' = 0
/\ big' = big
\/ /\ LET poured == Min (big - small, 5) - big IN
/\ big' = big + poured
/\ small' = small - poured
\/ /\ LET poured == Min (small - big, 3) - small IN
/\ big' = big - poured
/\ small' = small + poured
Spec == Init /\ [][Next]_vars
\* END TRANSLATION
=============================================================================
\* Modification History
\* Last modified Wed Jul 06 17:27:23 PDT 2016 by durant
\* Created Mon Jul 04 20:55:39 PDT 2016 by durant