forked from cubicle-model-checker/cubicle
-
Notifications
You must be signed in to change notification settings - Fork 0
/
chandra_toueg.cub
498 lines (438 loc) · 14 KB
/
chandra_toueg.cub
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
(*************************************************************************)
(* Chandra-Toueg fault tolerence protocol *)
(*************************************************************************)
(* *)
(* Tushar Deepak Chandra and Sam Toueg. 1991. Time and message efficient *)
(* reliable broadcasts. In Proceedings of the 4th international workshop *)
(* on Distributed algorithms, J. van Leeuwen and N. Santoro *)
(* (Eds.). Springer-Verlag New York, Inc., New York, NY, USA, 289-303. *)
(* *)
(* Translated from MCMT version of *)
(* *)
(* Francesco Alberti, Silvio Ghilardi, Elena Pagani, Silvio Ranise, Gian *)
(* Paolo Rossi: Automated Support for the Design and Validation of Fault *)
(* Tolerant Parameterized Systems: a case study. ECEASST 35 (2010) *)
(*************************************************************************)
type round = R1 | R2 | R3 | R4 | R5 | R6 | R7
type prep = M2 | M1 | MValid
(* Round of the execution *)
var Round : round
(* estimate of the processes (true = m; false = undefined) *)
array Estimate[proc] : bool
(* state of the processes (true = decided; false = undecided) *)
array State[proc] : bool
(* who's the coordinator *)
array Coord[proc] : bool
(* who has already been coordinator *)
array ACoord [proc] : bool
(* processes that has done the operations of the round *)
array Done[proc] : bool
(* someone sent a request? *)
var Request : bool
(* decision value of the processes (as estimate)*)
array DecisionValue[proc] : bool
(* the process is faulty (as defined in send omission failure model) *)
array Faulty[proc] : bool
(* the process has received the estimate from the coordinator *)
array Received[proc] : bool
(* if nack[x] = true, process x received a negative ack *)
array Nack[proc] : bool
(* id of the coordinator who sent me an estimate *)
array Id[proc] : proc
array Id_valid[proc] : prep
(* id of the coordinator who sent the estimate saved in tmpEstimate *)
var MaxId : proc
var MaxId_valid : prep
(* temp. var used to send the estimate to the coordinator *)
var TmpEstimate : bool
(* used for the Lemma 2.2 of the paper *)
array ProcessReceivedEstimate[proc] : bool
(* initial configuration *)
init (x) {
Round = R1 && State[x] = False && Coord[x] = False &&
ACoord[x] = False && Done[x] = False && Received[x] = False &&
Nack[x] = False &&
(* Id[x] = -1 && MaxId = -2 && *)
Id_valid[x] = M1 && MaxId_valid = M2 &&
ProcessReceivedEstimate[x] = False
}
(*---------------- suggested invariants from mcmt --------------------*)
(* Exists only one Coordinator in the system *)
unsafe (x y) {
Coord[x] = True && Coord[y] = True
}
(* If 'c' is Coordinator, all other process with Id < c have
already been Coordinator *)
unsafe (x y) {
Coord[x] = True && ACoord[y] = False && y < x
}
(* A Coordinator can't have Id[] greater than his Identificator *)
unsafe(x) {
Coord[x] = True && Id_valid[x] = MValid && x < Id[x]
}
(* A process can't have Id[] greater than Coordinator's Identificator *)
unsafe (x y) {
Coord[x] = True && Id_valid[y] = MValid && x < Id[y]
}
(* In the first Round a process can't have Id[] equals to the
Coordinator's Identificator *)
unsafe (x y) {
Round = R1 && Coord[x] = True && Id_valid[y] = MValid && Id[y] = x
}
(* A correct process can't receive any Nack *)
unsafe (x) {
Faulty[x] = False && Nack[x] = True
}
(* Coordinators are elected in order by Identificator *)
unsafe (x y) {
Coord[x] = True && ACoord[y] = True && x < y
}
(*--------------------------------------------------------------------*)
(* LEMMA 2.1 *)
unsafe (x y z) {
State[x] = True && Received[x] = True && Coord[y] = True &&
State[z] = False && Faulty[z]= False && Estimate[y] <> Estimate[z]
}
(* LEMMA 2.2 *)
unsafe (x y) {
Round <> R1 && State[x] = False && Faulty[x] = False &&
ProcessReceivedEstimate[x] = True && Coord[y] = True &&
Estimate[x] <> Estimate[y]
}
(* LEMMA 2.3 *)
unsafe (x y) {
Coord[x] = True && Faulty[x] = False && Round = R6 &&
State[y] = False && Faulty[y] = False
}
(* AGREEMENT - complete *)
unsafe (x y) {
State[x] = True && Faulty[x] = False &&
State[y] = True && Faulty[y] = False &&
DecisionValue[x] <> DecisionValue[y]
}
(* 1) DecIded processes send Request to Coordinator if
their Id are greather than MaxId *)
transition t1_v (x y)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[y] = True &&
Id_valid[x] = MValid && MaxId_valid = MValid && MaxId < Id[x] }
{
Done[x] := True;
MaxId := Id[x];
TmpEstimate := Estimate[x];
}
transition t1_nv (x y)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[y] = True &&
Id_valid[x] = M1 && MaxId_valid = M2 }
{
Done[x] := True;
MaxId := Id[x];
MaxId_valid := Id_valid[x];
TmpEstimate := Estimate[x];
}
transition t1_nv2 (x y)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[y] = True &&
Id_valid[x] = MValid && MaxId_valid = M2 }
{
Done[x] := True;
MaxId := Id[x];
MaxId_valid := Id_valid[x];
TmpEstimate := Estimate[x];
}
transition t1_nv3 (x y)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[y] = True &&
Id_valid[x] = MValid && MaxId_valid = M1 }
{
Done[x] := True;
MaxId := Id[x];
MaxId_valid := Id_valid[x];
TmpEstimate := Estimate[x];
}
(* 2) UndecIded processes want to send a Request, but their Id
is less or equal than MaxId *)
transition t2_v (x y)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[y] = True &&
Id_valid[x] = MValid && MaxId_valid = MValid && Id[x] <= MaxId }
{
Done[x] := True;
}
transition t2_nv (x y)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[y] = True &&
Id_valid[x] = M1 && MaxId_valid = MValid }
{
Done[x] := True;
}
transition t2_nv2 (x y)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[y] = True &&
Id_valid[x] = M1 && MaxId_valid = M1 }
{
Done[x] := True;
}
(* 3) An undecIded Faulty process fails sending a Request *)
transition t3 (x y)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[y] = True && Faulty[x] = True }
{
Done[x] := True;
}
(* 4) An undecIded Coordinator (with Id > MaxId) sends
a Request (to himself) *)
transition t4 (x)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[x] = True &&
Id_valid[x] = MValid && MaxId_valid = MValid && MaxId < Id[x] }
{
Done[x] := True;
MaxId := Id[x];
TmpEstimate := Estimate[x];
}
transition t4_nv (x)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[x] = True &&
Id_valid[x] = M1 && MaxId_valid = M2 }
{
Done[x] := True;
MaxId := Id[x];
MaxId_valid := Id_valid[x];
TmpEstimate := Estimate[x];
}
transition t4_nv2 (x)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[x] = True &&
Id_valid[x] = MValid && MaxId_valid = M2 }
{
Done[x] := True;
MaxId := Id[x];
MaxId_valid := Id_valid[x];
TmpEstimate := Estimate[x];
}
transition t4_nv3 (x)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[x] = True &&
Id_valid[x] = MValid && MaxId_valid = M1 }
{
Done[x] := True;
MaxId := Id[x];
MaxId_valid := Id_valid[x];
TmpEstimate := Estimate[x];
}
(* 5) An undecIded Coordinator (with Id <= MaxId) doesn't
send a Request to himself *)
transition t5 (x)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[x] = True &&
Id_valid[x] = MValid && MaxId_valid = MValid && Id[x] <= MaxId }
{
Done[x] := True;
}
transition t5_nv (x)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[x] = True &&
Id_valid[x] = M1 && MaxId_valid = MValid }
{
Done[x] := True;
}
transition t5_nv2 (x)
requires { Round = R1 && Done[x] = False && State[x] = False &&
Coord[x] = True &&
Id_valid[x] = M1 && MaxId_valid = M1 }
{
Done[x] := True;
}
(* 6) DecIded processes do nothing *)
transition t6 (x)
requires { Round = R1 && Done[x] = False && State[x] = True }
{
Done[x] := True;
}
(* 7) If all processes have completed the 1st Round and the Coordinator
Received a Request (i.e. MaxId > -2), the Coordinator set his Estimate
to TmpEstimate value and all the processes go to 2nd Round *)
transition t7 (x)
requires { Round = R1 && MaxId_valid <> M2 &&
Done[x] = True && Coord[x] = True &&
forall_other j. Done[j] = True }
{
Round := R2;
Done[j] := case | _ : False;
Estimate[x] := TmpEstimate;
}
(* 8) ... otherwise (no Request have been Received by the Coordinator)
the Coordinator is dismissed. *)
transition t8 (x)
requires { Round = R1 && MaxId_valid = M2 &&
Done[x] = True && Coord[x] = True &&
forall_other j. Done[j] = True }
{
Coord[x] := False;
ACoord[x] := True;
}
(* 9) An undecIded process receives the Estimate from the Coordinator. *)
transition t9 (x y)
requires { Round = R2 && Done[x] = False &&
State[x] = False && Coord[y] = True }
{
Estimate[x] := Estimate[y];
Done[x] := True;
Received[x] := True;
Id[x] := y;
Id_valid[x] := MValid;
ProcessReceivedEstimate[x] := True;
}
(* 10) A Faulty Coordinator fails sending an Estimate *)
transition t10 (x y)
requires { Round = R2 && Done[x] = False && State[x] = False &&
Coord[y] = True && Faulty[y] = True }
{
Done[x] := True;
}
(* 11) If the Coordinator is undecIded sends an Estimate to himself *)
transition t11 (x)
requires { Round = R2 && Done[x] = False &&
State[x] = False && Coord[x] = True }
{
Done[x] := True;
Received[x] := True;
Id[x] := x;
Id_valid[x] := MValid;
ProcessReceivedEstimate[x] := True;
}
(* 12) DecIded processes do nothing *)
transition t12 (x)
requires { Round = R2 && Done[x] = False && State[x] = True }
{
Done[x] := True;
}
(* 13) Round 2 completed. System goes to Round 3. *)
transition t13 (x)
requires { Round = R2 && Done[x] = True && Coord[x] = True &&
forall_other j. Done[j] = True }
{
Round := R3;
Done[j] := case | _ : False;
}
(* 14) If an undecIded process dIdn't Received the Estimate sends a Nack to Coord *)
transition t14 (x y)
requires { Round = R3 && State[x] = False && Done[x] = False &&
Received[x] = False && Coord[y] = True }
{
Done[x] := True;
Nack[y] := True;
}
(* 15) An undecIded Faulty process that dIdn't Received the Estimate
fails sending the Nack to the Coordinator *)
transition t15 (x y)
requires { Round = R3 && State[x] = False && Done[x] = False &&
Received[x] = False && Coord[y] = True && Faulty[x] = True }
{
Done[x] := True;
}
(* 16) Af an undecIded process has Received the Estimate does nothing *)
transition t16 (x y)
requires { Round = R3 && State[x] = False && Done[x] = False &&
Received[x] = True && Coord[y] = True }
{
Done[x] := True;
}
(* 17) the Coordinator does nothing in this Round *)
transition t17 (x)
requires { Round = R3 && Done[x] = False && Coord[x] = True }
{
Done[x] := True;
}
(* 18) decIded processes do nothing in this Round *)
transition t18 (x y)
requires { Round = R3 && State[x] = True &&
Done[x] = False && Coord[y] = True }
{
Done[x] := True;
}
(* 19) When all the processes have Done, system goes to the 4th Round. *)
transition t19 (x)
requires { Round = R3 && Done[x] = True && Coord[x] = True &&
forall_other j. Done[j] = True }
{
Round := R4;
}
(* 20) If no Nacks have been Received, system goes to the 5th Round (if the Coordinator
Received one (or more) Nack, he is killed by the system) *)
transition t20 (x)
requires { Round = R4 && Coord[x] = False &&
forall_other j. Nack[j] = False }
{
Round := R5;
Done[j] := case | _ : False;
}
(* 21) Coordinator sends a decIde to an undecIded process *)
transition t21 (x y)
requires { Round = R5 && Done[x] = False &&
State[x] = False && Coord[y] = True }
{
State[x] := True;
Done[x] := True;
DecisionValue[x] := Estimate[x];
}
(* 22) A Faulty Coordinator fails sending the message *)
transition t22 (x y)
requires { Round = R5 && Done[x] = False && State[x] = False &&
Coord[y] = True && Faulty[y] = True }
{
Done[x] := True;
}
(* 23) A Faulty Coordinator sends a decIde to himself *)
transition t23 (x)
requires { Round = R5 && Done[x] = False &&
State[x] = False && Coord[x] = True }
{
State[x] := True;
Done[x] := True;
DecisionValue[x] := Estimate[x];
}
(* 24) Coordinator sends a decIde to decIded processes
(but they ignore this message) *)
transition t24 (x)
requires { Round = R5 && Done[x] = False && State[x] = True }
{
Done[x] := True;
}
(* 25) Round n. 5 completed. System goes to Round 6. *)
transition t25 (x)
requires { Round = R5 && Done[x] = True && Coord[x] = True &&
forall_other j. Done[j] = True }
{
Round := R6;
Done[j] := case | _ : False;
}
(* 26) Coordinator in office is dismissed. *)
transition t26 (x)
requires { Round = R6 && Coord[x] = True }
{
Round := R7;
Coord[x] := False;
ACoord[x] := True;
}
(* 27) There's no Coordinator! (maybe the Coordinator crashed) *)
transition t27 (x)
requires { Coord[x] = False && forall_other y. Coord[y] = False }
{
Round := R7;
}
(* 28) In this Round a new process is elected as Coordinator of the system.
Then the system goes to 1st Round. *)
transition t28 (x)
requires { Coord[x] = False && ACoord[x] = False && Round = R7 &&
forall_other y. (x <= y || y < x && ACoord[y] = True) }
{
Round := R1;
Coord[x] := True;
Received[j] := case | _ : False;
Done[j] := case | _ : False;
Nack[j] := case | _ : False;
MaxId_valid := M2;
}