Skip to content

Commit 75969ee

Browse files
committed
Finished problem class 7
1 parent 6d791e0 commit 75969ee

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

PC07_HotelReception/c0.bucx

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
context c0
2+
sets
3+
GUEST
4+
ROOM
5+
end

PC07_HotelReception/m0.bumx

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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

PC07_HotelReception/m1.bumx

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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

0 commit comments

Comments
 (0)