-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmachine0.txt
More file actions
157 lines (140 loc) · 3.69 KB
/
machine0.txt
File metadata and controls
157 lines (140 loc) · 3.69 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
machine machine0 sees ctx0
variables user content chat active muted chatcontent owner
invariants
@inv1 user ⊆ USER
@inv2 content ⊆ CONTENT
@inv3 chat ∈ user ↔ user // chat sessions
@inv4 active ∈ user ⇸ user // active chat session
@inv5 muted ∈ user ↔ user // muted sessions
@inv6 active ⊆ chat // active chat sessions
@inv7 muted ⊆ chat // muted chat sessions
@inv8 chatcontent ∈ content ↔ chat // chat contents
@inv9 owner ∈ content → user
/* chat sessions
inv10 chatcontent ∈ // users' chat content */
events
event INITIALISATION
then
@init1 user ≔ ∅
@init2 content ≔ ∅
@init3 chat ≔ ∅
@init4 active ≔ ∅ // init7 chatcontent ≔ ∅
@init5 muted ≔ ∅
@init6 chatcontent ≔ ∅
@init7 owner ≔ ∅
end
event creat_chat_session // US-01
any u1 u2
where
@grd1 u1 ∈ user ∧ u2 ∈ user
@grd2 u1 ↦ u2 ∉ chat
then
@act1 chat ≔ chat ∪ {u1 ↦ u2}
end
event select_chat // US-02
any u1 u2
where
@grd1 u1 ∈ user ∧ u2 ∈ user
@grd2 u1 ↦ u2 ∈ chat
then
@act1 active ≔ active {u1 ↦ u2}
end
event chatting // US-03
any u1 u2 c
where
@grd1 u1 ∈ user ∧ u2 ∈ user
@grd2 u1 ↦ u2 ∈ chat
@grd3 u1 ↦ u2 ∉ muted
@grd4 u2 ↦ u1 ∉ muted
@grd5 u1 ↦ u2 ∈ active
@grd6 c ∈ CONTENT ∖ content
then
@act1 content ≔ content ∪ {c}
@act2 chat ≔ chat ∪ {u2 ↦ u1}
@act3 chatcontent ≔ chatcontent ∪ {c ↦ (u1 ↦ u2)} ∪ {c ↦ (u2 ↦ u1)}
@act4 owner ≔ owner ∪ {c ↦ u1}
end
event delete_content // US-04
any u1 u2 c
where
@grd1 u1 ∈ user ∧ u2 ∈ user // @grd2 u1 ↦ u2 ∈ chat // useless due to the next guard
@grd3 u1 ↦ u2 ∈ active
@grd4 c ∈ content
@grd5 (c ↦ (u1 ↦ u2)) ∈ chatcontent
then
@act1 chatcontent ≔ chatcontent ∖ {c ↦ (u1 ↦ u2)}
end
event clear_content // US-04
any u c
where
@grd1 u ∈ user
@grd2 c ∈ content
@grd3 c ↦ u ∈ owner
then
@act1 chatcontent ≔ {c} ⩤ chatcontent
@act2 owner ≔ owner ∖ {c ↦ u}
@act3 content ≔ content ∖ {c}
end
event delete_chat_session
// US-05
any u1 u2
where
@grd1 u1 ∈ user ∧ u2 ∈ user
@grd2 u1 ↦ u2 ∈ chat
@grd3 u1 ↦ u2 ∈ active
then
@act1 chatcontent ≔ chatcontent ⩥ {u1 ↦ u2}
@act2 active ≔ active ∖ {u1 ↦ u2}
@act3 muted ≔ muted ∖ {u1 ↦ u2}
@act4 chat ≔ chat ∖ {u1 ↦ u2}
end
event mute_chat
// US-06
any u1 u2
where
@grd1 u1 ∈ user ∧ u2 ∈ user
@grd2 u1 ↦ u2 ∈ chat
@grd3 u1 ↦ u2 ∉ muted
then
@act1 muted ≔ muted ∪ {u1 ↦ u2}
end
event unmute_chat
// US-07
any u1 u2
where
@grd1 u1 ∈ user ∧ u2 ∈ user
@grd2 u1 ↦ u2 ∈ chat
@grd3 u1 ↦ u2 ∈ muted
then
@act1 muted ≔ muted ∖ {u1 ↦ u2}
end
event broadcast
// US-08
any u ul c
where
@grd1 u ∈ user ∧ ul ∈ user ∧ c ∈ CONTENT ∖ content
@grd2 u ↦ ul ∈ chat
then
@act1 content ≔ content ∪ {c}
@act3 owner ≔ owner ∪ {c ↦ u}
@act2 chatcontent ≔ chatcontent ∪ {c ↦ (u ↦ ul)}
end
event forward
// US-09
any u ul c
where
@grd1 u ∈ user ∧ ul ∈ user ∧ c ∈ content
@grd2 u ↦ ul ∈ chat
then
@act1 chatcontent ≔ chatcontent ∪ {c ↦ (u ↦ ul)}
end
event unselect_chat
// US-10
any u1 u2
where
@grd1 u1 ∈ user ∧ u2 ∈ user
@grd3 u1 ↦ u2 ∈ active
then
@act1 active ≔ {u1} ⩤ active
end
end