-
Notifications
You must be signed in to change notification settings - Fork 0
/
SodaMachinePublish.tla
63 lines (42 loc) · 1.39 KB
/
SodaMachinePublish.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
------------------------- MODULE SodaMachinePublish -------------------------
EXTENDS Integers, Sequences, TLC
VARIABLES IHaveSoda, sodaMachine, IWantSoda, Money
vars == <<IHaveSoda, sodaMachine, IWantSoda, Money>>
IHaveMoney == Money > 0
SodaMachineHasSoda == sodaMachine > 0
PutMoneyInMachine ==
/\ IWantSoda
/\ IHaveMoney
/\ SodaMachineHasSoda
/\ Money' = Money - 1
/\ IHaveSoda' = TRUE
/\ sodaMachine' = sodaMachine - 1
/\ IWantSoda' = FALSE
DrinkSoda ==
/\ IHaveSoda
/\ IHaveSoda' = FALSE
/\ IWantSoda' = TRUE
/\ UNCHANGED <<Money, sodaMachine>>
NothingHappens ==
/\ Money = 0 \/ sodaMachine = 0
/\ UNCHANGED vars
Init ==
/\ IHaveSoda = FALSE
/\ IWantSoda = TRUE
/\ sodaMachine \in 4..7
/\ Money \in 2..10
Next ==
\/ DrinkSoda
\/ PutMoneyInMachine
\/ NothingHappens
Spec == Init /\ [][Next]_vars /\ WF_vars(Next)
TypeInvariant ==
/\ Money >= 0
/\ sodaMachine >= 0
/\ IWantSoda \in {TRUE, FALSE}
/\ IHaveSoda \in {TRUE, FALSE}
IEventuallyGetSoda == [](IHaveMoney /\ SodaMachineHasSoda => <>IHaveSoda) \* Always, I Have Money implies eventually I Have Soda
=============================================================================
\* Modification History
\* Last modified Fri Dec 17 13:09:21 MST 2021 by jeremy
\* Created Sun Nov 14 15:37:46 MST 2021 by jeremy