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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
model,benchmark_id,name,domain,difficulty,sany_pass,tlc_pass,structural_score,tlc_tier,runtime_s,generated_spec
|
| 2 |
+
chattla:20b,BM001,Mutual Exclusion,scheduling,2,0,0,1.0,bronze,3.7,"---- MODULE MutualExclusion ----
|
| 3 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 4 |
+
CONSTANTS N
|
| 5 |
+
|
| 6 |
+
VARIABLES state, turn
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
od;
|
| 12 |
+
*)
|
| 13 |
+
|
| 14 |
+
Init ==
|
| 15 |
+
/\ state = [i \in 1..N |-> ""idle""]
|
| 16 |
+
/\ turn \in 1..N
|
| 17 |
+
|
| 18 |
+
Next ==
|
| 19 |
+
\E i \in 1..N :
|
| 20 |
+
/\ state[i] = ""idle""
|
| 21 |
+
/\ state[i] := ""trying""
|
| 22 |
+
/\ state[i] = ""trying""
|
| 23 |
+
/\ state[i] := ""critical""
|
| 24 |
+
/\ state[i] := ""idle""
|
| 25 |
+
/\ turn := (turn % N) + 1
|
| 26 |
+
|
| 27 |
+
Spec == Init /\ [][Next]_<<state, turn>>
|
| 28 |
+
|
| 29 |
+
TypeOK ==
|
| 30 |
+
/\ state \in [1..N -> {""idle"", ""trying"", ""critical""}]
|
| 31 |
+
/\ turn \in 1..N
|
| 32 |
+
|
| 33 |
+
===="
|
| 34 |
+
chattla:20b,BM002,Two-Phase Commit,transaction,3,0,0,1.0,bronze,10.77,"---- MODULE TwoPhaseCommit ----
|
| 35 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 36 |
+
|
| 37 |
+
CONSTANT N
|
| 38 |
+
|
| 39 |
+
VARIABLES participants, coordinator, messages
|
| 40 |
+
|
| 41 |
+
(* Participants are numbered 1..N *)
|
| 42 |
+
Participants == 1..N
|
| 43 |
+
|
| 44 |
+
(* Messages are tuples: [sender \in Participants, receiver \in Participants, type \in {""Prepare"", ""VoteYes"", ""VoteNo"", ""Commit"", ""Abort""}, content \in {"""", ""VoteYes"", ""VoteNo""}] *)
|
| 45 |
+
Message == [sender \in Participants, receiver \in Participants, type \in {""Prepare"", ""VoteYes"", ""VoteNo"", ""Commit"", ""Abort""}, content \in {"""", ""VoteYes"", ""VoteNo""}]
|
| 46 |
+
|
| 47 |
+
(* Initial state: all participants are in the ""Init"" state, coordinator is in ""Start"" state, no messages *)
|
| 48 |
+
Init == /\ participants = [i \in Participants |-> ""Init""]
|
| 49 |
+
/\ coordinator = ""Start""
|
| 50 |
+
/\ messages = {}
|
| 51 |
+
|
| 52 |
+
(* Coordinator sends Prepare to all participants *)
|
| 53 |
+
SendPrepare == /\ coordinator = ""Start""
|
| 54 |
+
/\ messages' = messages \cup { [sender |-> coordinator, receiver |-> i, type |-> ""Prepare"", content |-> """"] : i \in Participants }
|
| 55 |
+
/\ coordinator' = ""WaitingForVotes""
|
| 56 |
+
/\ participants' = participants
|
| 57 |
+
|
| 58 |
+
(* Participants receive Prepare and vote Yes *)
|
| 59 |
+
ReceivePrepareAndVoteYes == /\ coordinator = ""WaitingForVotes""
|
| 60 |
+
/\ \E msg \in messages : msg.type = ""Prepare"" /\ msg.receiver \in Participants /\ participants[msg.receiver] = ""Init""
|
| 61 |
+
/\ messages' = messages \ { msg }
|
| 62 |
+
/\ participants' = [participants EXCEPT ![msg.receiver] = ""VotedYes""]
|
| 63 |
+
/\ messages' = messages' \cup { [sender |-> msg.receiver, receiver |-> coordinator, type |-> ""VoteYes"", content |-> ""VoteYes""] }
|
| 64 |
+
|
| 65 |
+
(* Participants receive Prepare and vote No *)
|
| 66 |
+
ReceivePrepareAndVoteNo == /\ coordinator = ""WaitingForVotes""
|
| 67 |
+
/\ \E msg \in messages : msg.type = ""Prepare"" /\ msg.receiver \in Participants /\ participants[msg.receiver] = ""Init""
|
| 68 |
+
/\ messages' = messages \ { msg }
|
| 69 |
+
/\ participants' = [participants EXCEPT ![msg.receiver] = ""VotedNo""]
|
| 70 |
+
/\ messages' = messages' \cup { [sender |-> msg.receiver, receiver |-> coordinator, type |-> ""VoteNo"", content |-> ""VoteNo""] }
|
| 71 |
+
|
| 72 |
+
(* Coordinator receives all Yes votes and sends Commit *)
|
| 73 |
+
SendCommit == /\ coordinator = ""WaitingForVotes""
|
| 74 |
+
/\ \A i \in Participants : participants[i] = ""VotedYes""
|
| 75 |
+
/\ messages' = messages \cup { [sender |-> coordinator, receiver |-> i, type |-> ""Commit"", content |-> """"] : i \in Participants }
|
| 76 |
+
/\ coordinator' = ""Committed""
|
| 77 |
+
/\ participants' = participants
|
| 78 |
+
|
| 79 |
+
(* Coordinator receives any No vote and sends Abort *)
|
| 80 |
+
SendAbort == /\ coordinator = ""WaitingForVotes""
|
| 81 |
+
/\ \E i \in Participants : participants[i] = ""VotedNo""
|
| 82 |
+
/\ messages' = messages \cup { [sender |-> coordinator, receiver |-> i, type |-> ""Abort"", content |-> """"] : i \in Participants }
|
| 83 |
+
/\ coordinator' = ""Aborted""
|
| 84 |
+
/\ participants' = participants
|
| 85 |
+
|
| 86 |
+
(* Participants receive Commit and transition to Committed *)
|
| 87 |
+
ReceiveCommit == /\ coordinator \in {""Committed"", ""Aborted""}
|
| 88 |
+
/\ \E msg \in messages : msg.type = ""Commit"" /\ msg.receiver \in Participants /\ participants[msg.receiver] = ""VotedYes""
|
| 89 |
+
/\ messages' = messages \ { msg }
|
| 90 |
+
/\ participants' = [participants EXCEPT ![msg.receiver] = ""Committed""]
|
| 91 |
+
/\ coordinator' = coordinator
|
| 92 |
+
|
| 93 |
+
(* Participants receive Abort and transition to Aborted *)
|
| 94 |
+
ReceiveAbort == /\ coordinator \in {""Committed"", ""Aborted""}
|
| 95 |
+
/\ \E msg \in messages : msg.type = ""Abort"" /\ msg.receiver \in Participants /\ participants[msg.receiver] = ""VotedYes""
|
| 96 |
+
/\ messages' = messages \ { msg }
|
| 97 |
+
/\ participants' = [participants EXCEPT ![msg.receiver] = ""Aborted""]
|
| 98 |
+
/\ coordinator' = coordinator
|
| 99 |
+
|
| 100 |
+
(* Next-state relation *)
|
| 101 |
+
Next == SendPrepare \/ ReceivePrepareAndVoteYes \/ ReceivePrepareAndVoteNo \/ SendCommit \/ SendAbort \/ ReceiveCommit \/ ReceiveAbort
|
| 102 |
+
|
| 103 |
+
(* Type invariant *)
|
| 104 |
+
TypeOK == /\ participants \in [Participants -> {""Init"", ""VotedYes"", ""VotedNo"", ""Committed"", ""Aborted""}]
|
| 105 |
+
/\ coordinator \in {""Start"", ""WaitingForVotes"", ""Committed"", ""Aborted""}
|
| 106 |
+
/\ messages \subseteq Message
|
| 107 |
+
|
| 108 |
+
Spec == Init /\ [][Next]_<<participants, coordinator, messages>>
|
| 109 |
+
|
| 110 |
+
===="
|
| 111 |
+
chattla:20b,BM003,Dining Philosophers,scheduling,2,0,0,1.0,bronze,6.17,"---- MODULE DiningPhilosophers ----
|
| 112 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 113 |
+
|
| 114 |
+
CONSTANT N
|
| 115 |
+
|
| 116 |
+
VARIABLES forks, states
|
| 117 |
+
|
| 118 |
+
(* Forks: a set of fork indices {1, 2, ..., N} *)
|
| 119 |
+
Forks == {1, 2, ..., N}
|
| 120 |
+
|
| 121 |
+
(* States: a function from philosopher indices to {""thinking"", ""hungry"", ""eating""} *)
|
| 122 |
+
States == [i \in Forks |-> {""thinking"", ""hungry"", ""eating""}]
|
| 123 |
+
|
| 124 |
+
(* Initial state: all forks are free, all philosophers are thinking *)
|
| 125 |
+
Init == forks = Forks /\ states = [i \in Forks |-> ""thinking""]
|
| 126 |
+
|
| 127 |
+
(* Helper: determine the left and right fork indices for philosopher i *)
|
| 128 |
+
LeftFork(i) == IF i = 1 THEN N ELSE i - 1
|
| 129 |
+
RightFork(i) == IF i = N THEN 1 ELSE i + 1
|
| 130 |
+
|
| 131 |
+
(* Helper: check if philosopher i can eat (both adjacent forks are free) *)
|
| 132 |
+
CanEat(i) == LeftFork(i) \in forks /\ RightFork(i) \in forks
|
| 133 |
+
|
| 134 |
+
(* Action: philosopher i picks up forks and starts eating *)
|
| 135 |
+
TakeForks(i) ==
|
| 136 |
+
/\ states[i] = ""hungry""
|
| 137 |
+
/\ CanEat(i)
|
| 138 |
+
/\ forks' = forks \ {LeftFork(i), RightFork(i)}
|
| 139 |
+
/\ states' = [states EXCEPT ![i] = ""eating""]
|
| 140 |
+
|
| 141 |
+
(* Action: philosopher i puts down forks after eating *)
|
| 142 |
+
PutForks(i) ==
|
| 143 |
+
/\ states[i] = ""eating""
|
| 144 |
+
/\ forks' = forks \cup {LeftFork(i), RightFork(i)}
|
| 145 |
+
/\ states' = [states EXCEPT ![i] = ""thinking""]
|
| 146 |
+
|
| 147 |
+
(* Action: philosopher i becomes hungry *)
|
| 148 |
+
Hungry(i) ==
|
| 149 |
+
/\ states[i] = ""thinking""
|
| 150 |
+
/\ states' = [states EXCEPT ![i] = ""hungry""]
|
| 151 |
+
/\ forks' = forks
|
| 152 |
+
|
| 153 |
+
(* Next action: any philosopher can become hungry, or any philosopher who can eat can start eating, or any philosopher who is eating can put down forks *)
|
| 154 |
+
Next == \E i \in Forks :
|
| 155 |
+
(Hungry(i) \/ TakeForks(i) \/ PutForks(i))
|
| 156 |
+
|
| 157 |
+
(* Type invariant: forks is a subset of Forks, states is a function from Forks to {""thinking"", ""hungry"", ""eating""} *)
|
| 158 |
+
TypeOK ==
|
| 159 |
+
/\ forks \subseteq Forks
|
| 160 |
+
/\ states \in [Forks -> {""thinking"", ""hungry"", ""eating""}]
|
| 161 |
+
|
| 162 |
+
Spec == Init /\ [][Next]_<<forks, states>>
|
| 163 |
+
|
| 164 |
+
===="
|
| 165 |
+
chattla:20b,BM004,Lamport's Bakery Algorithm,consensus,3,1,0,1.0,silver,4.48,"---- MODULE Bakery ----
|
| 166 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 167 |
+
Max(S) == CHOOSE x \in S : \A y \in S : x >= y
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
CONSTANT N
|
| 171 |
+
|
| 172 |
+
VARIABLES num, flag
|
| 173 |
+
|
| 174 |
+
(* TypeOK ensures num is a sequence of N integers, flag is a sequence of N booleans *)
|
| 175 |
+
TypeOK == /\ num \in Seq(N)
|
| 176 |
+
/\ flag \in Seq(N)
|
| 177 |
+
|
| 178 |
+
(* Helper functions *)
|
| 179 |
+
Less(i, j) == /\ flag[i] /\ flag[j]
|
| 180 |
+
/\ (num[i] < num[j] \/ (num[i] = num[j] /\ i < j))
|
| 181 |
+
|
| 182 |
+
MaxNum == IF N = 0 THEN 0 ELSE Max(num)
|
| 183 |
+
|
| 184 |
+
(* Initialization: all flag false, all num 0 *)
|
| 185 |
+
Init == /\ flag = [i \in 1..N |-> FALSE]
|
| 186 |
+
/\ num = [i \in 1..N |-> 0]
|
| 187 |
+
|
| 188 |
+
(* Next action: process i can be in choosing or critical section *)
|
| 189 |
+
Next == \E i \in 1..N :
|
| 190 |
+
/\ flag' = [flag EXCEPT ![i] = TRUE]
|
| 191 |
+
/\ num' = [num EXCEPT ![i] = MaxNum + 1]
|
| 192 |
+
/\ flag' = [flag EXCEPT ![i] = FALSE]
|
| 193 |
+
/\ UNCHANGED <<num, flag>>
|
| 194 |
+
|
| 195 |
+
Spec == Init /\ [][Next]_<<num, flag>>
|
| 196 |
+
|
| 197 |
+
(* Mutual exclusion invariant: no two processes in critical section simultaneously *)
|
| 198 |
+
MutualExclusion == \A i, j \in 1..N : i /= j => ~ (flag[i] /\ flag[j] /\ Less(i, j))
|
| 199 |
+
|
| 200 |
+
===="
|
| 201 |
+
chattla:20b,BM005,Producer-Consumer Queue,storage,2,0,0,0.778,bronze,3.24,"---- MODULE BoundedFIFO ----
|
| 202 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 203 |
+
|
| 204 |
+
CONSTANT K
|
| 205 |
+
|
| 206 |
+
VARIABLES q, head, tail, size
|
| 207 |
+
|
| 208 |
+
vars == <<q, head, tail, size>>
|
| 209 |
+
|
| 210 |
+
Init == /\ q = [i \in 1..K |-> -> 0]
|
| 211 |
+
/\ head = 1
|
| 212 |
+
/\ tail = 1
|
| 213 |
+
/\ size = 0
|
| 214 |
+
|
| 215 |
+
Producer(x) == /\ size < K
|
| 216 |
+
/\ q[tail] = 0
|
| 217 |
+
/\ q' = [q EXCEPT ![tail] = x]
|
| 218 |
+
/\ tail' = IF tail = K THEN 1 ELSE tail + 1
|
| 219 |
+
/\ size' = size + 1
|
| 220 |
+
/\ UNCHANGED <<head, q>>
|
| 221 |
+
|
| 222 |
+
Consumer(y) == /\ size > 0
|
| 223 |
+
/\ y = q[head]
|
| 224 |
+
/\ q' = [q EXCEPT ![head] = 0]
|
| 225 |
+
/\ head' = IF head = K THEN 1 ELSE head + 1
|
| 226 |
+
/\ size' = size - 1
|
| 227 |
+
/\ UNCHANGED <<tail, q>>
|
| 228 |
+
|
| 229 |
+
Next == \E x \in Nat : Producer(x)
|
| 230 |
+
\/ \E y \in Nat : Consumer(y)
|
| 231 |
+
|
| 232 |
+
Spec == Init /\ [][Next]_vars
|
| 233 |
+
|
| 234 |
+
===="
|
| 235 |
+
chattla:20b,BM006,Raft Leader Election,consensus,4,0,0,1.0,bronze,4.07,"---- MODULE RaftLeaderElection ----
|
| 236 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 237 |
+
CONSTANTS Servers
|
| 238 |
+
|
| 239 |
+
VARIABLES currentTerm, votedFor, state
|
| 240 |
+
|
| 241 |
+
|
| 242 |
+
|
| 243 |
+
TypeOK == /\ currentTerm \in Nat
|
| 244 |
+
/\ votedFor \in {None} \cup Servers
|
| 245 |
+
/\ state \in {Follower, Candidate, Leader}
|
| 246 |
+
|
| 247 |
+
Init == /\ currentTerm = 0
|
| 248 |
+
/\ votedFor = None
|
| 249 |
+
/\ state = Follower
|
| 250 |
+
|
| 251 |
+
(* Candidate wins if it gets a majority of votes *)
|
| 252 |
+
MajorityWins == \E votes \in SUBSET Servers :
|
| 253 |
+
/\ Cardinality(votes) > Cardinality(Servers) \div 2
|
| 254 |
+
/\ \A s \in votes : s = Candidate
|
| 255 |
+
|
| 256 |
+
Next ==
|
| 257 |
+
(* Follower to Candidate transition *)
|
| 258 |
+
\/ /\ state = Follower
|
| 259 |
+
/\ currentTerm' = currentTerm + 1
|
| 260 |
+
/\ votedFor' = Candidate
|
| 261 |
+
/\ state' = Candidate
|
| 262 |
+
(* Candidate to Leader transition *)
|
| 263 |
+
\/ /\ state = Candidate
|
| 264 |
+
/\ MajorityWins
|
| 265 |
+
/\ state' = Leader
|
| 266 |
+
(* No state change *)
|
| 267 |
+
\/ /\ state' = state
|
| 268 |
+
/\ currentTerm' = currentTerm
|
| 269 |
+
/\ votedFor' = votedFor
|
| 270 |
+
|
| 271 |
+
Spec == Init /\ [][Next]_<<currentTerm, votedFor, state>>
|
| 272 |
+
|
| 273 |
+
===="
|
| 274 |
+
chattla:20b,BM007,Read-Write Lock,storage,2,1,0,1.0,silver,3.83,"---- MODULE ReadWriteLock ----
|
| 275 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 276 |
+
|
| 277 |
+
VARIABLES readers, writer_active
|
| 278 |
+
|
| 279 |
+
(* --algorithm ReadWriteLock
|
| 280 |
+
end ReadWriteLock *)
|
| 281 |
+
|
| 282 |
+
TypeOK ==
|
| 283 |
+
/\ readers \in Seq(Int)
|
| 284 |
+
/\ writer_active \in BOOLEAN
|
| 285 |
+
|
| 286 |
+
Init ==
|
| 287 |
+
/\ readers = <<>>
|
| 288 |
+
/\ writer_active = FALSE
|
| 289 |
+
|
| 290 |
+
Next ==
|
| 291 |
+
\/ /\ writer_active = FALSE
|
| 292 |
+
/\ writer_active' = TRUE
|
| 293 |
+
/\ readers' = readers
|
| 294 |
+
\/ /\ writer_active = FALSE
|
| 295 |
+
/\ Len(readers) > 0
|
| 296 |
+
/\ writer_active' = writer_active
|
| 297 |
+
/\ readers' = Tail(readers)
|
| 298 |
+
|
| 299 |
+
Spec == Init /\ [][Next]_<<readers, writer_active>>
|
| 300 |
+
|
| 301 |
+
===="
|
| 302 |
+
chattla:20b,BM008,Distributed Snapshot (Chandy-Lamport),networking,5,0,0,1.0,bronze,7.45,"---- MODULE DistributedSnapshot ----
|
| 303 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 304 |
+
|
| 305 |
+
CONSTANT N, Channels
|
| 306 |
+
|
| 307 |
+
VARIABLES state, channel, markerSent, markerReceived
|
| 308 |
+
|
| 309 |
+
(* State of each process: 0 = not recorded, 1 = recorded *)
|
| 310 |
+
State == [p \in 1..N |-> 0 |-> 1]
|
| 311 |
+
|
| 312 |
+
(* Channel state: sequence of messages *)
|
| 313 |
+
ChannelState == [c \in Channels |-> Seq]
|
| 314 |
+
|
| 315 |
+
(* MarkerSent: set of channels along which marker has been sent *)
|
| 316 |
+
MarkerSent == [c \in Channels |-> BOOLEAN]
|
| 317 |
+
|
| 318 |
+
(* MarkerReceived: set of channels along which marker has been received *)
|
| 319 |
+
MarkerReceived == [c \in Channels |-> BOOLEAN]
|
| 320 |
+
|
| 321 |
+
(* Initial state: no process has recorded state, channels empty, no markers sent/received *)
|
| 322 |
+
Init == /\ state = [p \in 1..N |-> 0]
|
| 323 |
+
/\ channel = [c \in Channels |-> <<>>]
|
| 324 |
+
/\ markerSent = [c \in Channels |-> FALSE]
|
| 325 |
+
/\ markerReceived = [c \in Channels |-> FALSE]
|
| 326 |
+
|
| 327 |
+
(* Next action: either send a regular message or send a marker *)
|
| 328 |
+
Next ==
|
| 329 |
+
\E p \in 1..N : \E q \in 1..N : \E c \in Channels :
|
| 330 |
+
/\ c = <<p, q>>
|
| 331 |
+
/\ \E msg \in 1..N :
|
| 332 |
+
/\ state[p] = 0
|
| 333 |
+
/\ channel' = [channel EXCEPT ![c] = Append(channel[c], msg)]
|
| 334 |
+
/\ UNCHANGED <<state, markerSent, markerReceived>>
|
| 335 |
+
\/ \E msg \in 1..N :
|
| 336 |
+
/\ state[p] = 1
|
| 337 |
+
/\ channel' = [channel EXCEPT ![c] = Append(channel[c], msg)]
|
| 338 |
+
/\ UNCHANGED <<state, markerSent, markerReceived>>
|
| 339 |
+
\/ /\ state[p] = 0
|
| 340 |
+
/\ channel' = channel
|
| 341 |
+
/\ markerSent' = [markerSent EXCEPT ![c] = TRUE]
|
| 342 |
+
/\ UNCHANGED <<state, markerReceived>>
|
| 343 |
+
|
| 344 |
+
(* Receive action: process a message from a channel *)
|
| 345 |
+
Receive ==
|
| 346 |
+
\E c \in Channels : \E p \in 1..N : \E q \in 1..N :
|
| 347 |
+
/\ c = <<p, q>>
|
| 348 |
+
/\ channel[c] /= <<>>
|
| 349 |
+
/\ msg = Head(channel[c])
|
| 350 |
+
/\ channel' = [channel EXCEPT ![c] = Tail(channel[c])]
|
| 351 |
+
/\ IF msg = 0 THEN
|
| 352 |
+
/\ state' = [state EXCEPT ![p] = 1]
|
| 353 |
+
/\ markerReceived' = [markerReceived EXCEPT ![c] = TRUE]
|
| 354 |
+
/\ UNCHANGED <<markerSent>>
|
| 355 |
+
|
| 356 |
+
/\ UNCHANGED <<state, markerSent, markerReceived>>
|
| 357 |
+
|
| 358 |
+
(* Next action: either send or receive *)
|
| 359 |
+
Next == Send \/ Receive
|
| 360 |
+
|
| 361 |
+
(* Specification *)
|
| 362 |
+
Spec == Init /\ [][Next]_<<state, channel, markerSent, markerReceived>>
|
| 363 |
+
|
| 364 |
+
(* Type invariant *)
|
| 365 |
+
TypeOK == /\ state \in State
|
| 366 |
+
/\ channel \in ChannelState
|
| 367 |
+
/\ markerSent \in [Channels |-> BOOLEAN]
|
| 368 |
+
/\ markerReceived \in [Channels |-> BOOLEAN]
|
| 369 |
+
|
| 370 |
+
===="
|
| 371 |
+
chattla:20b,BM009,Token Ring,networking,2,1,1,0.889,gold,1.95,"---- MODULE TokenRing ----
|
| 372 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 373 |
+
|
| 374 |
+
CONSTANT N
|
| 375 |
+
|
| 376 |
+
VARIABLE token
|
| 377 |
+
|
| 378 |
+
Init == token \in 1..N
|
| 379 |
+
|
| 380 |
+
Next == token' = IF token = N THEN 1 ELSE token + 1
|
| 381 |
+
|
| 382 |
+
Spec == Init /\ [][Next]_<<token>>
|
| 383 |
+
|
| 384 |
+
TypeOK == token \in 1..N
|
| 385 |
+
|
| 386 |
+
===="
|
| 387 |
+
chattla:20b,BM010,Simple Key-Value Store,storage,3,0,0,1.0,bronze,1.74,"---- MODULE KeyValueStore ----
|
| 388 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 389 |
+
|
| 390 |
+
CONSTANTS Keys, Values, NULL
|
| 391 |
+
|
| 392 |
+
VARIABLES store
|
| 393 |
+
|
| 394 |
+
Init == store = [k \in Keys |-> NULL]
|
| 395 |
+
|
| 396 |
+
Next == \E k \in Keys : \E v \in Values :
|
| 397 |
+
store' = [store EXCEPT ![k] = v]
|
| 398 |
+
|
| 399 |
+
Spec == Init /\ [][Next]_<<store>>
|
| 400 |
+
|
| 401 |
+
TypeOK == /\ store \in [Keys -> Values]
|
| 402 |
+
/\ Keys \in FiniteSets
|
| 403 |
+
/\ Values \in FiniteSets
|
| 404 |
+
|
| 405 |
+
===="
|
| 406 |
+
chattla:20b,BM011,Paxos Single-Decree,consensus,4,1,0,0.444,silver,44.62,"---- MODULE Paxos ----
|
| 407 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 408 |
+
|
| 409 |
+
CONSTANT N, M
|
| 410 |
+
|
| 411 |
+
VARIABLES ballot, promised, accepted, chosen
|
| 412 |
+
===="
|
| 413 |
+
chattla:20b,BM012,Bounded Retransmission Protocol,networking,3,0,0,0.778,bronze,8.06,"---- MODULE FileTransfer ----
|
| 414 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 415 |
+
|
| 416 |
+
CONSTANTS File, MAX_RETRIES
|
| 417 |
+
VARIABLES ackedChunks, lostChunks, retransCount, sentChunks, seqNum, state
|
| 418 |
+
|
| 419 |
+
/\ state \in {""idle"", ""sending"", ""waiting"", ""done"", ""failed""}
|
| 420 |
+
/\ seqNum \in 0..Len(File)
|
| 421 |
+
/\ retransCount \in 0..MAX_RETRIES
|
| 422 |
+
/\ sentChunks \in SUBSET 0..Len(File)
|
| 423 |
+
/\ ackedChunks \in SUBSET 0..Len(File)
|
| 424 |
+
/\ lostChunks \in SUBSET 0..Len(File)
|
| 425 |
+
|
| 426 |
+
Init ==
|
| 427 |
+
/\ state = ""idle""
|
| 428 |
+
/\ seqNum = 0
|
| 429 |
+
/\ retransCount = 0
|
| 430 |
+
/\ sentChunks = {}
|
| 431 |
+
/\ ackedChunks = {}
|
| 432 |
+
/\ lostChunks = {}
|
| 433 |
+
|
| 434 |
+
SendChunk ==
|
| 435 |
+
/\ state = ""idle""
|
| 436 |
+
/\ seqNum < Len(File)
|
| 437 |
+
/\ state' = ""sending""
|
| 438 |
+
/\ seqNum' = seqNum + 1
|
| 439 |
+
/\ retransCount' = 0
|
| 440 |
+
/\ sentChunks' = sentChunks \cup {seqNum}
|
| 441 |
+
/\ ackedChunks' = ackedChunks
|
| 442 |
+
/\ lostChunks' = lostChunks
|
| 443 |
+
|
| 444 |
+
ReceiveAck ==
|
| 445 |
+
/\ state = ""waiting""
|
| 446 |
+
/\ seqNum \in ackedChunks
|
| 447 |
+
/\ state' = ""idle""
|
| 448 |
+
/\ seqNum' = seqNum
|
| 449 |
+
/\ retransCount' = 0
|
| 450 |
+
/\ sentChunks' = sentChunks
|
| 451 |
+
/\ ackedChunks' = ackedChunks
|
| 452 |
+
/\ lostChunks' = lostChunks
|
| 453 |
+
|
| 454 |
+
Timeout ==
|
| 455 |
+
/\ state = ""waiting""
|
| 456 |
+
/\ retransCount < MAX_RETRIES
|
| 457 |
+
/\ state' = ""sending""
|
| 458 |
+
/\ retransCount' = retransCount + 1
|
| 459 |
+
/\ sentChunks' = sentChunks
|
| 460 |
+
/\ ackedChunks' = ackedChunks
|
| 461 |
+
/\ lostChunks' = lostChunks
|
| 462 |
+
|
| 463 |
+
GiveUp ==
|
| 464 |
+
/\ state = ""waiting""
|
| 465 |
+
/\ retransCount = MAX_RETRIES
|
| 466 |
+
/\ state' = ""failed""
|
| 467 |
+
/\ seqNum' = seqNum
|
| 468 |
+
/\ retransCount' = retransCount
|
| 469 |
+
/\ sentChunks' = sentChunks
|
| 470 |
+
/\ ackedChunks' = ackedChunks
|
| 471 |
+
/\ lostChunks' = lostChunks
|
| 472 |
+
|
| 473 |
+
Done ==
|
| 474 |
+
/\ state = ""idle""
|
| 475 |
+
/\ seqNum = Len(File)
|
| 476 |
+
/\ state' = ""done""
|
| 477 |
+
/\ seqNum' = seqNum
|
| 478 |
+
/\ retransCount' = retransCount
|
| 479 |
+
/\ sentChunks' = sentChunks
|
| 480 |
+
/\ ackedChunks' = ackedChunks
|
| 481 |
+
/\ lostChunks' = lostChunks
|
| 482 |
+
|
| 483 |
+
Next ==
|
| 484 |
+
\/ SendChunk
|
| 485 |
+
\/ ReceiveAck
|
| 486 |
+
\/ Timeout
|
| 487 |
+
\/ GiveUp
|
| 488 |
+
\/ Done
|
| 489 |
+
|
| 490 |
+
Spec == Init /\ [][Next]_<<state, seqNum, retransCount, sentChunks, ackedChunks, lostChunks>>
|
| 491 |
+
|
| 492 |
+
===="
|
| 493 |
+
chattla:20b,BM013,Transaction Isolation (Snapshot Isolation),transaction,4,0,0,1.0,bronze,8.42,"---- MODULE SnapshotIsolationDB ----
|
| 494 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 495 |
+
|
| 496 |
+
VARIABLES db, txns, nextTxId, v
|
| 497 |
+
|
| 498 |
+
|
| 499 |
+
txns = <<>>; (* sequence of transaction records *)
|
| 500 |
+
nextTxId = 1; (* next transaction ID *)
|
| 501 |
+
|
| 502 |
+
actions
|
| 503 |
+
BeginTx ==
|
| 504 |
+
/\ txns' = Append(txns, [id |-> nextTxId, status |-> ""active"", snapshot |-> db, writes |-> <<>>])
|
| 505 |
+
/\ nextTxId' = nextTxId + 1
|
| 506 |
+
/\ UNCHANGED db
|
| 507 |
+
|
| 508 |
+
Read(txId, idx) ==
|
| 509 |
+
/\ txId \in {t.id : t \in txns}
|
| 510 |
+
/\ idx \in 1..Len(db)
|
| 511 |
+
/\ \E t \in txns : t.id = txId /\ t.status = ""active""
|
| 512 |
+
/\ UNCHANGED db /\ UNCHANGED txns /\ UNCHANGED nextTxId
|
| 513 |
+
|
| 514 |
+
Write(txId, val) ==
|
| 515 |
+
/\ txId \in {t.id : t \in txns}
|
| 516 |
+
/\ \E t \in txns : t.id = txId /\ t.status = ""active""
|
| 517 |
+
/\ txns' = [txns EXCEPT ![txId] = [@ EXCEPT !writes = Append(@.writes, val)]]
|
| 518 |
+
/\ UNCHANGED db /\ UNCHANGED nextTxId
|
| 519 |
+
|
| 520 |
+
Commit(txId) ==
|
| 521 |
+
/\ txId \in {t.id : t \in txns}
|
| 522 |
+
/\ \E t \in txns : t.id = txId /\ t.status = ""active""
|
| 523 |
+
/\ \A t \in txns : t.id = txId =>
|
| 524 |
+
\A v \in t.writes : v \notin {v' : v' \in db}
|
| 525 |
+
/\ db' = Append(db, t.writes)
|
| 526 |
+
/\ txns' = [txns EXCEPT ![txId] = [@ EXCEPT !status = ""committed""]]
|
| 527 |
+
/\ UNCHANGED nextTxId
|
| 528 |
+
|
| 529 |
+
Abort(txId) ==
|
| 530 |
+
/\ txId \in {t.id : t \in txns}
|
| 531 |
+
/\ \E t \in txns : t.id = txId /\ t.status = ""active""
|
| 532 |
+
/\ txns' = [txns EXCEPT ![txId] = [@ EXCEPT !status = ""aborted""]]
|
| 533 |
+
/\ UNCHANGED db /\ UNCHANGED nextTxId
|
| 534 |
+
*)
|
| 535 |
+
|
| 536 |
+
TypeOK ==
|
| 537 |
+
/\ db \in Seq(Seq(Int))
|
| 538 |
+
/\ txns \in Seq([id: Int)), writes: Seq(Seq(Int))])
|
| 539 |
+
/\ nextTxId \in Nat
|
| 540 |
+
|
| 541 |
+
Init ==
|
| 542 |
+
/\ db = <<>>
|
| 543 |
+
/\ txns = <<>>
|
| 544 |
+
/\ nextTxId = 1
|
| 545 |
+
|
| 546 |
+
Next ==
|
| 547 |
+
BeginTx \/
|
| 548 |
+
\E txId, idx \in 1..Len(txns) : Read(txId, idx) \/
|
| 549 |
+
\E txId, val \in 1..Len(db) : Write(txId, val) \/
|
| 550 |
+
\E txId \in 1..Len(txns) : Commit(txId) \/
|
| 551 |
+
\E txId \in 1..Len(txns) : Abort(txId)
|
| 552 |
+
|
| 553 |
+
Spec == Init /\ [][Next]_<<db, txns, nextTxId>>
|
| 554 |
+
|
| 555 |
+
===="
|
| 556 |
+
chattla:20b,BM014,Clock Synchronisation,networking,3,0,0,0.444,bronze,44.69,"---- MODULE ClockSync ----
|
| 557 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 558 |
+
|
| 559 |
+
VARIABLES clocks, offsets
|
| 560 |
+
|
| 561 |
+
(* --algorithm ClockSync
|
| 562 |
+
|
| 563 |
+
(* --algorithm ClockSync
|
| 564 |
+
|
| 565 |
+
(* --algorithm ClockSync
|
| 566 |
+
|
| 567 |
+
(* --algorithm ClockSync
|
| 568 |
+
|
| 569 |
+
(* --algorithm ClockSync
|
| 570 |
+
|
| 571 |
+
(* --algorithm ClockSync
|
| 572 |
+
|
| 573 |
+
(* --algorithm ClockSync
|
| 574 |
+
|
| 575 |
+
(* --algorithm ClockSync
|
| 576 |
+
|
| 577 |
+
(* --algorithm ClockSync
|
| 578 |
+
|
| 579 |
+
(* --algorithm ClockSync
|
| 580 |
+
|
| 581 |
+
(* --algorithm ClockSync
|
| 582 |
+
|
| 583 |
+
(* --algorithm ClockSync
|
| 584 |
+
|
| 585 |
+
(* --algorithm ClockSync
|
| 586 |
+
|
| 587 |
+
(* --algorithm ClockSync
|
| 588 |
+
|
| 589 |
+
(* --algorithm ClockSync
|
| 590 |
+
|
| 591 |
+
(* --algorithm ClockSync
|
| 592 |
+
|
| 593 |
+
(* --algorithm ClockSync
|
| 594 |
+
|
| 595 |
+
(* --algorithm ClockSync
|
| 596 |
+
|
| 597 |
+
(* --algorithm ClockSync
|
| 598 |
+
|
| 599 |
+
(* --algorithm ClockSync
|
| 600 |
+
|
| 601 |
+
(* --algorithm ClockSync
|
| 602 |
+
|
| 603 |
+
(* --algorithm ClockSync
|
| 604 |
+
|
| 605 |
+
(* --algorithm ClockSync
|
| 606 |
+
|
| 607 |
+
(* --algorithm ClockSync
|
| 608 |
+
|
| 609 |
+
(* --algorithm ClockSync
|
| 610 |
+
|
| 611 |
+
(* --algorithm ClockSync
|
| 612 |
+
|
| 613 |
+
(* --algorithm ClockSync
|
| 614 |
+
|
| 615 |
+
(* --algorithm ClockSync
|
| 616 |
+
|
| 617 |
+
(* --algorithm ClockSync
|
| 618 |
+
|
| 619 |
+
(* --algorithm ClockSync
|
| 620 |
+
|
| 621 |
+
(* --algorithm ClockSync
|
| 622 |
+
|
| 623 |
+
(* --algorithm ClockSync
|
| 624 |
+
|
| 625 |
+
(* --algorithm ClockSync
|
| 626 |
+
|
| 627 |
+
(* --algorithm ClockSync
|
| 628 |
+
|
| 629 |
+
(* --algorithm ClockSync
|
| 630 |
+
|
| 631 |
+
(* --algorithm ClockSync
|
| 632 |
+
|
| 633 |
+
(* --algorithm ClockSync *)
|
| 634 |
+
===="
|
| 635 |
+
chattla:20b,BM015,Peterson's Algorithm,scheduling,2,0,0,0.778,bronze,2.95,"---- MODULE Peterson2 ----
|
| 636 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 637 |
+
|
| 638 |
+
VARIABLES flag, turn
|
| 639 |
+
|
| 640 |
+
|
| 641 |
+
|
| 642 |
+
TypeOK == /\ flag \in [1..2 -> BOOLEAN]
|
| 643 |
+
/\ turn \in 1..2
|
| 644 |
+
|
| 645 |
+
Spec == Init /\ [][Next]_<<flag, turn>>
|
| 646 |
+
|
| 647 |
+
===="
|
| 648 |
+
chattla:20b,BM016,Gossip Protocol,networking,3,0,0,1.0,bronze,1.69,"---- MODULE Gossip ----
|
| 649 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 650 |
+
|
| 651 |
+
VARIABLES known, infected
|
| 652 |
+
|
| 653 |
+
Init == /\ known = <<>> /\ infected = {}
|
| 654 |
+
|
| 655 |
+
Next == /\ \E i \in 1..N :
|
| 656 |
+
/\ known' = Append(known, i)
|
| 657 |
+
/\ infected' = infected \cup {i}
|
| 658 |
+
|
| 659 |
+
Spec == Init /\ [][Next]_<<known, infected>>
|
| 660 |
+
|
| 661 |
+
TypeOK == /\ known \subseteq 1..N
|
| 662 |
+
/\ infected \subseteq 1..N
|
| 663 |
+
|
| 664 |
+
===="
|
| 665 |
+
chattla:20b,BM017,Simple Allocator,storage,2,0,0,0.889,bronze,4.03,"---- MODULE MemoryAllocator ----
|
| 666 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 667 |
+
|
| 668 |
+
CONSTANTS N, Clients
|
| 669 |
+
|
| 670 |
+
Pages == 1..N
|
| 671 |
+
|
| 672 |
+
VARIABLE free, allocated
|
| 673 |
+
|
| 674 |
+
Init == /\ free = Pages
|
| 675 |
+
/\ allocated = [c \in Clients |-> {}]
|
| 676 |
+
|
| 677 |
+
Request(c) == /\ c \in Clients
|
| 678 |
+
/\ free /= {}
|
| 679 |
+
/\ c \notin DOMAIN allocated
|
| 680 |
+
\/ allocated[c] = {}
|
| 681 |
+
/\ c \in DOMAIN allocated
|
| 682 |
+
/\ allocated[c] = {}
|
| 683 |
+
/\ c \notin DOMAIN allocated
|
| 684 |
+
/\ allocated' = [allocated EXCEPT ![c] = {}]
|
| 685 |
+
/\ free' = free \ {CHOOSE p \in free : TRUE}
|
| 686 |
+
\/ /\ c \in DOMAIN allocated
|
| 687 |
+
/\ allocated' = [allocated EXCEPT ![c] = {}]
|
| 688 |
+
/\ free' = free \ {CHOOSE p \in free : TRUE}
|
| 689 |
+
/\ UNCHANGED <<>> (* placeholder for other variables *)
|
| 690 |
+
|
| 691 |
+
Release(c) == /\ c \in DOMAIN allocated
|
| 692 |
+
/\ allocated[c] /= {}
|
| 693 |
+
/\ allocated' = [allocated EXCEPT ![c] = {}]
|
| 694 |
+
/\ free' = free \cup allocated[c]
|
| 695 |
+
/\ UNCHANGED <<>> (* placeholder for other variables *)
|
| 696 |
+
|
| 697 |
+
Next == \E c \in Clients : Request(c) \/ Release(c)
|
| 698 |
+
|
| 699 |
+
Spec == Init /\ [][Next]_<<free, allocated>>
|
| 700 |
+
|
| 701 |
+
TypeOK == /\ free \subseteq Pages
|
| 702 |
+
/\ allocated \subseteq [Clients -> SUBSET Pages]
|
| 703 |
+
/\ \A c \in DOMAIN allocated : allocated[c] \subseteq Pages
|
| 704 |
+
|
| 705 |
+
===="
|
| 706 |
+
chattla:20b,BM018,Publish-Subscribe Broker,networking,3,0,0,1.0,bronze,3.91,"---- MODULE Broker ----
|
| 707 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 708 |
+
|
| 709 |
+
VARIABLES subscribers, messages, inbox
|
| 710 |
+
|
| 711 |
+
(* Type definitions *)
|
| 712 |
+
Topic == Int
|
| 713 |
+
Message == [topic: Topic, content: Int]
|
| 714 |
+
Subscriber == [id: Int, interests: SUBSET Topic, inbox: Seq Message]
|
| 715 |
+
|
| 716 |
+
(* State predicates *)
|
| 717 |
+
TypeOK ==
|
| 718 |
+
/\ subscribers \in SUBSET (SUBSET Topic)
|
| 719 |
+
/\ messages \in Seq Message
|
| 720 |
+
|
| 721 |
+
(* Initial state *)
|
| 722 |
+
Init ==
|
| 723 |
+
/\ subscribers = <<>>
|
| 724 |
+
/\ messages = <<>>
|
| 725 |
+
|
| 726 |
+
(* Action: Register a subscriber with interests *)
|
| 727 |
+
Register(sub, interests) ==
|
| 728 |
+
/\ sub \notin subscribers
|
| 729 |
+
/\ subscribers' = Append(subscribers, [id |-> sub, interests |-> interests, inbox |-> <<>>])
|
| 730 |
+
/\ UNCHANGED messages
|
| 731 |
+
|
| 732 |
+
(* Action: Post a message on a topic *)
|
| 733 |
+
Post(msg) ==
|
| 734 |
+
/\ msg \in messages
|
| 735 |
+
/\ messages' = Append(messages, msg)
|
| 736 |
+
/\ UNCHANGED subscribers
|
| 737 |
+
|
| 738 |
+
(* Action: Deliver messages to subscribers *)
|
| 739 |
+
Deliver ==
|
| 740 |
+
/\ \E sub \in subscribers:
|
| 741 |
+
/\ \E msg \in messages:
|
| 742 |
+
/\ msg.topic \in sub.interests
|
| 743 |
+
/\ sub.inbox' = Append(sub.inbox, msg)
|
| 744 |
+
/\ UNCHANGED messages
|
| 745 |
+
|
| 746 |
+
(* Next-state relation *)
|
| 747 |
+
Next ==
|
| 748 |
+
\E sub \in subscribers : \E interests \in SUBSET Topic :
|
| 749 |
+
Register(sub, interests)
|
| 750 |
+
\/ \E msg \in messages:
|
| 751 |
+
Post(msg)
|
| 752 |
+
\/ Deliver
|
| 753 |
+
|
| 754 |
+
(* Temporal specification *)
|
| 755 |
+
Spec == Init /\ [][Next]_<<subscribers, messages>>
|
| 756 |
+
|
| 757 |
+
===="
|
| 758 |
+
chattla:20b,BM019,Dekker's Algorithm,scheduling,3,1,1,1.0,gold,3.89,"---- MODULE Dekker ----
|
| 759 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 760 |
+
|
| 761 |
+
VARIABLES turn, wants
|
| 762 |
+
|
| 763 |
+
Init == /\ turn \in {0,1}
|
| 764 |
+
/\ wants = [i \in {0,1} |-> FALSE]
|
| 765 |
+
|
| 766 |
+
Next ==
|
| 767 |
+
\/ /\ wants[0] = FALSE
|
| 768 |
+
/\ wants[1] = FALSE
|
| 769 |
+
/\ turn' = turn
|
| 770 |
+
/\ wants' = wants
|
| 771 |
+
\/ /\ wants[0] = FALSE
|
| 772 |
+
/\ wants[1] = TRUE
|
| 773 |
+
/\ turn' = 1
|
| 774 |
+
/\ wants' = [wants EXCEPT ![1] = FALSE]
|
| 775 |
+
\/ /\ wants[0] = TRUE
|
| 776 |
+
/\ wants[1] = FALSE
|
| 777 |
+
/\ turn' = 0
|
| 778 |
+
/\ wants' = [wants EXCEPT ![0] = FALSE]
|
| 779 |
+
\/ /\ wants[0] = TRUE
|
| 780 |
+
/\ wants[1] = TRUE
|
| 781 |
+
/\ turn' = turn
|
| 782 |
+
/\ wants' = [wants EXCEPT ![turn] = FALSE]
|
| 783 |
+
|
| 784 |
+
Spec == Init /\ [][Next]_<<turn, wants>>
|
| 785 |
+
|
| 786 |
+
TypeOK == /\ turn \in {0,1}
|
| 787 |
+
/\ wants \in [ {0,1} -> BOOLEAN ]
|
| 788 |
+
|
| 789 |
+
===="
|
| 790 |
+
chattla:20b,BM020,Eventually Consistent Counter,storage,3,1,0,0.444,silver,44.8,"---- MODULE GCounter ----
|
| 791 |
+
EXTENDS Integers, Sequences, FiniteSets
|
| 792 |
+
|
| 793 |
+
VARIABLES counts
|
| 794 |
+
|
| 795 |
+
(* --algorithm GCounter
|
| 796 |
+
end
|
| 797 |
+
*)
|
| 798 |
+
|
| 799 |
+
(* --algorithm GCounter
|
| 800 |
+
end
|
| 801 |
+
*)
|
| 802 |
+
|
| 803 |
+
(* --algorithm GCounter
|
| 804 |
+
end
|
| 805 |
+
*)
|
| 806 |
+
|
| 807 |
+
(* --algorithm GCounter
|
| 808 |
+
end
|
| 809 |
+
*)
|
| 810 |
+
|
| 811 |
+
(* --algorithm GCounter
|
| 812 |
+
end
|
| 813 |
+
*)
|
| 814 |
+
|
| 815 |
+
(* --algorithm GCounter
|
| 816 |
+
end
|
| 817 |
+
*)
|
| 818 |
+
|
| 819 |
+
(* --algorithm GCounter
|
| 820 |
+
end
|
| 821 |
+
*)
|
| 822 |
+
|
| 823 |
+
(* --algorithm GCounter
|
| 824 |
+
end
|
| 825 |
+
*)
|
| 826 |
+
|
| 827 |
+
(* --algorithm GCounter
|
| 828 |
+
end
|
| 829 |
+
*)
|
| 830 |
+
|
| 831 |
+
(* --algorithm GCounter
|
| 832 |
+
end
|
| 833 |
+
*)
|
| 834 |
+
|
| 835 |
+
(* --algorithm GCounter
|
| 836 |
+
end
|
| 837 |
+
*)
|
| 838 |
+
|
| 839 |
+
(* --algorithm GCounter
|
| 840 |
+
end
|
| 841 |
+
*)
|
| 842 |
+
|
| 843 |
+
(* --algorithm GCounter
|
| 844 |
+
end
|
| 845 |
+
*)
|
| 846 |
+
|
| 847 |
+
(* --algorithm GCounter
|
| 848 |
+
end
|
| 849 |
+
*)
|
| 850 |
+
|
| 851 |
+
(* --algorithm GCounter
|
| 852 |
+
end
|
| 853 |
+
*)
|
| 854 |
+
|
| 855 |
+
(* --algorithm GCounter
|
| 856 |
+
end
|
| 857 |
+
*)
|
| 858 |
+
|
| 859 |
+
(* --algorithm GCounter
|
| 860 |
+
end
|
| 861 |
+
*)
|
| 862 |
+
|
| 863 |
+
(* --algorithm GCounter
|
| 864 |
+
end
|
| 865 |
+
*)
|
| 866 |
+
|
| 867 |
+
(* --algorithm GCounter
|
| 868 |
+
end
|
| 869 |
+
*)
|
| 870 |
+
|
| 871 |
+
(* --algorithm GCounter
|
| 872 |
+
end
|
| 873 |
+
*)
|
| 874 |
+
|
| 875 |
+
(* --algorithm GCounter
|
| 876 |
+
end
|
| 877 |
+
*)
|
| 878 |
+
|
| 879 |
+
(* --algorithm GCounter
|
| 880 |
+
end
|
| 881 |
+
*)
|
| 882 |
+
|
| 883 |
+
(* --algorithm GCounter
|
| 884 |
+
end
|
| 885 |
+
*)
|
| 886 |
+
|
| 887 |
+
(* --algorithm GCounter
|
| 888 |
+
end
|
| 889 |
+
*)
|
| 890 |
+
|
| 891 |
+
(* --algorithm GCounter
|
| 892 |
+
end
|
| 893 |
+
*)
|
| 894 |
+
|
| 895 |
+
(* --algorithm GCounter
|
| 896 |
+
end
|
| 897 |
+
*)
|
| 898 |
+
|
| 899 |
+
(* --algorithm GCounter
|
| 900 |
+
end
|
| 901 |
+
*)
|
| 902 |
+
|
| 903 |
+
(* --algorithm GCounter
|
| 904 |
+
end
|
| 905 |
+
*)
|
| 906 |
+
|
| 907 |
+
(* --algorithm GCounter
|
| 908 |
+
end
|
| 909 |
+
*)
|
| 910 |
+
|
| 911 |
+
(* --algorithm GCounter
|
| 912 |
+
end
|
| 913 |
+
*)
|
| 914 |
+
|
| 915 |
+
(* --algorithm GCounter
|
| 916 |
+
end
|
| 917 |
+
*)
|
| 918 |
+
|
| 919 |
+
(* --algorithm GCounter
|
| 920 |
+
end
|
| 921 |
+
*)
|
| 922 |
+
|
| 923 |
+
(* --algorithm GCounter
|
| 924 |
+
end
|
| 925 |
+
*)
|
| 926 |
+
|
| 927 |
+
(* --algorithm GCounter
|
| 928 |
+
end
|
| 929 |
+
*)
|
| 930 |
+
|
| 931 |
+
(* --algorithm GCounter
|
| 932 |
+
end
|
| 933 |
+
*)
|
| 934 |
+
|
| 935 |
+
(* --algorithm GCounter
|
| 936 |
+
end
|
| 937 |
+
*)
|
| 938 |
+
|
| 939 |
+
(* --algorithm GCounter
|
| 940 |
+
end
|
| 941 |
+
*)
|
| 942 |
+
|
| 943 |
+
(* --algorithm GCounter
|
| 944 |
+
end
|
| 945 |
+
*)
|
| 946 |
+
|
| 947 |
+
(* --algorithm GCounter
|
| 948 |
+
end
|
| 949 |
+
*)
|
| 950 |
+
|
| 951 |
+
(* --algorithm GCounter
|
| 952 |
+
end
|
| 953 |
+
*)
|
| 954 |
+
|
| 955 |
+
(* --algorithm GCounter
|
| 956 |
+
end
|
| 957 |
+
*)
|
| 958 |
+
|
| 959 |
+
(* --algorithm GCounter
|
| 960 |
+
end
|
| 961 |
+
*)
|
| 962 |
+
|
| 963 |
+
(* --algorithm GCounter
|
| 964 |
+
end
|
| 965 |
+
*)
|
| 966 |
+
|
| 967 |
+
(* --algorithm GCounter
|
| 968 |
+
end
|
| 969 |
+
*)
|
| 970 |
+
|
| 971 |
+
(* --algorithm GCounter
|
| 972 |
+
end
|
| 973 |
+
*)
|
| 974 |
+
|
| 975 |
+
(* --algorithm GCounter
|
| 976 |
+
end
|
| 977 |
+
*)
|
| 978 |
+
|
| 979 |
+
(* --algorithm GCounter
|
| 980 |
+
end
|
| 981 |
+
*)
|
| 982 |
+
|
| 983 |
+
(* --algorithm GCounter
|
| 984 |
+
end
|
| 985 |
+
*)
|
| 986 |
+
|
| 987 |
+
(* --algorithm GCounter
|
| 988 |
+
end
|
| 989 |
+
*)
|
| 990 |
+
|
| 991 |
+
(* --algorithm GCounter
|
| 992 |
+
end
|
| 993 |
+
*)
|
| 994 |
+
|
| 995 |
+
(* --algorithm GCounter
|
| 996 |
+
end
|
| 997 |
+
*)
|
| 998 |
+
|
| 999 |
+
(* --algorithm GCounter
|
| 1000 |
+
end
|
| 1001 |
+
*)
|
| 1002 |
+
|
| 1003 |
+
(* --algorithm GCounter
|
| 1004 |
+
end
|
| 1005 |
+
*)
|
| 1006 |
+
|
| 1007 |
+
(* --algorithm GCounter
|
| 1008 |
+
end
|
| 1009 |
+
*)
|
| 1010 |
+
|
| 1011 |
+
(* --algorithm GCounter
|
| 1012 |
+
end
|
| 1013 |
+
*)
|
| 1014 |
+
|
| 1015 |
+
(* --algorithm GCounter
|
| 1016 |
+
end
|
| 1017 |
+
*)
|
| 1018 |
+
|
| 1019 |
+
(* --algorithm GCounter
|
| 1020 |
+
end
|
| 1021 |
+
*)
|
| 1022 |
+
|
| 1023 |
+
(* --algorithm GCounter
|
| 1024 |
+
end
|
| 1025 |
+
*)
|
| 1026 |
+
|
| 1027 |
+
(* --algorithm GCounter
|
| 1028 |
+
end
|
| 1029 |
+
*)
|
| 1030 |
+
|
| 1031 |
+
(* --algorithm GCounter
|
| 1032 |
+
end
|
| 1033 |
+
*)
|
| 1034 |
+
|
| 1035 |
+
(* --algorithm GCounter
|
| 1036 |
+
end
|
| 1037 |
+
*)
|
| 1038 |
+
|
| 1039 |
+
(* --algorithm GCounter
|
| 1040 |
+
end
|
| 1041 |
+
*)
|
| 1042 |
+
|
| 1043 |
+
(* --algorithm GCounter
|
| 1044 |
+
end
|
| 1045 |
+
*)
|
| 1046 |
+
|
| 1047 |
+
(* --algorithm GCounter
|
| 1048 |
+
end
|
| 1049 |
+
*)
|
| 1050 |
+
|
| 1051 |
+
(* --algorithm GCounter
|
| 1052 |
+
end
|
| 1053 |
+
*)
|
| 1054 |
+
|
| 1055 |
+
(* --algorithm GCounter
|
| 1056 |
+
end
|
| 1057 |
+
*)
|
| 1058 |
+
|
| 1059 |
+
(* --algorithm GCounter
|
| 1060 |
+
end
|
| 1061 |
+
*)
|
| 1062 |
+
|
| 1063 |
+
(* --algorithm GCounter
|
| 1064 |
+
end
|
| 1065 |
+
*)
|
| 1066 |
+
|
| 1067 |
+
(* --algorithm GCounter
|
| 1068 |
+
end
|
| 1069 |
+
*)
|
| 1070 |
+
|
| 1071 |
+
(* --algorithm G *)
|
| 1072 |
+
===="
|