-
Notifications
You must be signed in to change notification settings - Fork 0
/
carwheel.tla
87 lines (72 loc) · 1.89 KB
/
carwheel.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
------------------------------ MODULE carwheel ------------------------------
\* We have 5 tires each with 20k miles left. How long a car run with these tires ?
EXTENDS Integers
VARIABLES TireA, TireB, TireC, TireD, TireS, Run
TypeOK ==
/\ TireA \in 0..20
/\ TireB \in 0..20
/\ TireC \in 0..20
/\ TireD \in 0..20
/\ TireS \in 0..20
/\ Run \in 0..30
Init ==
/\ TireA = 20
/\ TireB = 20
/\ TireC = 20
/\ TireD = 20
/\ TireS = 20
/\ Run = 30
SpareA ==
/\ TireA' = TireA
/\ TireB' = TireB - 1
/\ TireC' = TireC - 1
/\ TireD' = TireD - 1
/\ TireS' = TireS - 1
/\ Run' = Run - 1
SpareB ==
/\ TireA' = TireA - 1
/\ TireB' = TireB
/\ TireC' = TireC - 1
/\ TireD' = TireD - 1
/\ TireS' = TireS - 1
/\ Run' = Run - 1
SpareC ==
/\ TireA' = TireA - 1
/\ TireB' = TireB - 1
/\ TireC' = TireC
/\ TireD' = TireD - 1
/\ TireS' = TireS - 1
/\ Run' = Run - 1
SpareD ==
/\ TireA' = TireA - 1
/\ TireB' = TireB - 1
/\ TireC' = TireC - 1
/\ TireD' = TireD
/\ TireS' = TireS - 1
/\ Run' = Run - 1
SpareS ==
/\ TireA' = TireA - 1
/\ TireB' = TireB - 1
/\ TireC' = TireC - 1
/\ TireD' = TireD - 1
/\ TireS' = TireS
/\ Run' = Run - 1
Next ==
\/ SpareA
\/ SpareB
\/ SpareC
\/ SpareD
\/ SpareS
ABCD == (TireA > 0 /\ TireB > 0 /\ TireC > 0 /\ TireD > 0)
BCDS == (TireS > 0 /\ TireB > 0 /\ TireC > 0 /\ TireD > 0)
ACDS == (TireA > 0 /\ TireS > 0 /\ TireC > 0 /\ TireD > 0)
ABDS == (TireA > 0 /\ TireB > 0 /\ TireS > 0 /\ TireD > 0)
ABCS == (TireA > 0 /\ TireB > 0 /\ TireC > 0 /\ TireS > 0)
MaxRun == Run > 5
RunCar ==
\/ ABCD
\/ BCDS
\/ ACDS
\/ ABDS
\/ ABCS
=============================================================================