File tree 3 files changed +85
-0
lines changed
3 files changed +85
-0
lines changed Original file line number Diff line number Diff line change
1
+ context c0
2
+ sets
3
+ GUEST
4
+ ROOM
5
+ end
Original file line number Diff line number Diff line change
1
+ machine m0
2
+ sees c0
3
+ variables
4
+ allocations
5
+ invariants
6
+ @typeof-allocations: allocations ∈ ROOM ⤔ GUEST
7
+ events
8
+
9
+ event INITIALISATION
10
+ then
11
+ @init-allocations: allocations ≔ ∅
12
+ end
13
+
14
+ event CheckIn
15
+ any
16
+ g
17
+ r
18
+ where
19
+ @is-guest: g ∈ GUEST
20
+ @is-room: r ∈ ROOM
21
+ @guest-is-not-checked-in: g ∉ ran(allocations)
22
+ @room-is-free: r ∉ dom(allocations)
23
+ then
24
+ @allocate-room: allocations(r) ≔ g
25
+ end
26
+
27
+ event CheckOut
28
+ any
29
+ g
30
+ where
31
+ @guest-is-checked-in: g ∈ ran(allocations)
32
+ then
33
+ @allocate-room: allocations ≔ allocations ⩥ {g}
34
+ end
35
+
36
+ end
Original file line number Diff line number Diff line change
1
+ machine m1
2
+ refines m0
3
+ sees c0
4
+ variables
5
+ allocations
6
+ rooms
7
+ invariants
8
+ @typeof-rooms: rooms ⊆ ROOM
9
+ @typeof-allocations: allocations ∈ rooms ⤔ GUEST
10
+ events
11
+ event INITIALISATION extends INITIALISATION
12
+ then
13
+ @init-rooms: rooms ≔ ∅
14
+ end
15
+
16
+ event CheckIn extends CheckIn
17
+ where
18
+ @is-registered-room: r ∈ rooms
19
+ end
20
+
21
+ event CheckOut extends CheckOut
22
+ end
23
+
24
+ event AddRoom
25
+ any
26
+ r
27
+ where
28
+ @is-room: r ∈ ROOM
29
+ @is-not-registered: r ∉ rooms
30
+ then
31
+ @add-room: rooms ≔ rooms ∪ {r}
32
+ end
33
+
34
+ event RemoveRoom
35
+ any
36
+ r
37
+ where
38
+ @is-registered-room: r ∈ rooms
39
+ @is-not-occupied: r ∉ dom(allocations)
40
+ then
41
+ @remove-room: rooms ≔ rooms ∖ {r}
42
+ end
43
+
44
+ end
You can’t perform that action at this time.
0 commit comments