-
Notifications
You must be signed in to change notification settings - Fork 1
/
Propagation.tla
1297 lines (1176 loc) · 60.5 KB
/
Propagation.tla
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
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-------------------------- MODULE Propagation --------------------------
EXTENDS Integers, TLAPS, TLC
CONSTANTS Replicas, Values, Coordinators
VARIABLES
msgs, \* The set of messages that have been delivered.
knowVal, \* val[x] is true is a replica x knows a value
allKnowVal, \* allKnowVal[a] is TRUE if replica knows that all
\*other replicas know the value
cordVal, \* cordVal[a] value ervery coordinator is trying to propagate
safeStateAttained, \* safeStateAttained[x] is true if an agent x knows that
\* the required state of knowledge has been attained
state_time \* time of the system state
vars == <<msgs, knowVal, allKnowVal, state_time>>
None == CHOOSE v : v \notin Values
(***************************************************************************)
(*Time *)
(***************************************************************************)
\* for now, representing time with natural numbers such as t_0, t_1, t_2,...
\* since using no other property but existence and greater than
\* time is discrete logical time
Time == Nat
(***************************************************************************)
(* Some temporal properties *)
(***************************************************************************)
\* If a message has been delivered from all replicas at different times,
\* there will be a time when the system state will have that message from
\* all replicas at a lower time
temporalProperty1 ==
(
(\A r \in Replicas : \E t \in Time : (state_time' = t)
/\ (\E m \in msgs' : (m.rep = r)))
=> (\E T \in Time : state_time' = T
/\ (\A r \in Replicas :
\E t \in Time : (T > t)
/\ (state_time' = t)
/\ (\E m \in msgs' : (m.rep = r))))
)
\* For all coordinators, there is a time when no messages have been sent to or from it
temporalProperty2 ==
\A c \in Coordinators:
(\E t \in Time : state_time = t
/\ (~(\E m \in msgs : m.cord = c)))
\*if a new state X exist at a time t, then X is the current state at a time t2>t
temporalProperty3 ==
(
\A t \in Time:
\A c \in Coordinators:
(( state_time' = t
/\ \E v \in Values :
\E m \in msgs' : m.type = "1a"
/\ m.cord = c
/\ m.val = v)
=>
(\E t2 \in Time:
t2>t
/\ state_time = t2
/\ \E v \in Values :
\E m \in msgs : m.type = "1a"
/\ m.cord = c
/\ m.val = v))
)
/\(
\A t \in Time:
\A c \in Coordinators:
(state_time' = t
/\ \A r \in Replicas :
\E m \in msgs' : m.type = "1b"
/\ m.cord = c
/\ m.rep = r)
=>
(\E t2 \in Time:
t2>t
/\ state_time = t2
/\ \A r \in Replicas :
\E m \in msgs : m.type = "1b"
/\ m.cord = c
/\ m.rep = r)
)
/\(
\A t \in Time:
\A c \in Coordinators:
(state_time' = t
/\ \E m \in msgs' : m.cord = c
/\ m.type = "2a")
=>
(\E t2 \in Time:
t2>t
/\ state_time = t2
/\ \E m \in msgs : m.cord = c
/\ m.type = "2a")
)
/\(
\A t \in Time:
\A c \in Coordinators:
(state_time' = t
/\ \A r \in Replicas :
\E m \in msgs' : m.type = "2b"
/\ m.cord = c
/\ m.rep = r)
=>
(\E t2 \in Time:
t2>t
/\ state_time = t2
/\ \A r \in Replicas :
\E m \in msgs : m.type = "2b"
/\ m.cord = c
/\ m.rep = r)
)
temporalProperties == temporalProperty1
/\ temporalProperty2
/\ temporalProperty3
(***************************************************************************)
(*Predicates for message sending and delivery *)
(* NOTE *)
(* *)
(* A message is added to msgs once delivered *)
(* Only the msgs is accessible by agents *)
(***************************************************************************)
\*A message that is eventually Delivered is added to msgs
\* A single msgs variable also asserts that if a message is delivered,
\* it is delivered to all acceptors at the same time.
Deliver(m,t) == (m.dTime = t) /\ (state_time' = t) /\ (msgs' = msgs \cup {m})
\*A message that is sent may or may not be delivered (May get lost)
Send(m,t) ==
\/ \E t2 \in Time : (t2 > t) /\ Deliver(m,t2)
\/ \A t2 \in Time : ~ Deliver(m,t2 )
(***************************************************************************)
(* Phase 1a: A coordinator sends a "1a" message to all replicas *)
(***************************************************************************)
Phase1a(c,t ) ==
/\ \E t2 \in Time : (t2 >= t
/\ (state_time' = t2)
/\ Send([type |-> "1a", cord |-> c ,
val |-> cordVal[c]], t2))
/\ UNCHANGED <<msgs, knowVal, allKnowVal>>
(***************************************************************************)
(* Phase 1b: If areplica receives a "1a" message, it replies with a "1b" *)
(* message and commits the value *)
(***************************************************************************)
Phase1b_learn(r) ==
knowVal' = [knowVal EXCEPT ![r] = TRUE]
Phase1b(r,m,t) ==
/\ (state_time' = t)
/\ Send([type |-> "1b", cord |-> m.cord, rep |-> r], t)
(***************************************************************************)
(* Phase 2a: If the coordinator receives "1b" messages from all replicas *)
(* it sends a "2a" message to all replicas *)
(***************************************************************************)
Phase2a(c,t) ==
/\ (state_time' = t)
/\ Send([type |-> "2a", cord |-> c], t)
(***************************************************************************)
(* Phase 2b: If areplica receives a "2a" message from a coordinator *)
(* it knows that all other replicas have also committed thesame value *)
(***************************************************************************)
Phase2b_learn(r) ==
allKnowVal' = [allKnowVal EXCEPT ![r] = TRUE]
Phase2b(r,m,t) ==
/\ (state_time' = t)
/\ Send([type |-> "2b", cord |-> m.cord, rep |-> r], t)
(***************************************************************************)
(* Learning: If 2b messages for all replica are delivered to a coordinator *)
(* then the coodinator knows that the `^$E^2_{G}\phi$ ^' has been attained *)
(***************************************************************************)
Phase2c_learn(c) ==
safeStateAttained' = [safeStateAttained EXCEPT ![c] = TRUE]
(***************************************************************************)
(* The type of possible messages *)
(***************************************************************************)
Messages == [type : {"1a"}, cord : Coordinators, val : Values]
\cup [type : {"1b"}, cord : Coordinators, rep : Replicas]
\cup [type : {"2a"}, cord : Coordinators]
\cup [type : {"2b"}, cord : Coordinators, rep : Replicas]
(***************************************************************************)
(* The following section specifies rules and predicates that define *)
(* availability and the behaviour of available agents *)
(***************************************************************************)
\*Available
Available(x,t) == TRUE \/ FALSE
\*Always Available
Always_available(x) == \A t \in Time : Available(x,t)
(***************************************************************************)
(*Rules for Masters *)
(***************************************************************************)
Rule_1a_msg(c) ==
(~(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c))
<=> ( \E t \in Time : Phase1a(c,t))
Rule_2a_msg(c) ==
(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c)
<=> (\E t \in Time : Phase2a(c,t))
Rule_2c_learn(c) ==
(\A r \in Replicas : (\E m \in msgs : m.type = "2b" /\ m.rep = r /\ m.cord = c))
<=> (Phase2c_learn(c))
(***************************************************************************)
(*Rules for Replicas *)
(***************************************************************************)
Rule_1b_msg(r) ==
\A c \in Coordinators :
(
(\E m \in msgs : \E v \in Values: m.type = "1a"
/\ m.cord = c
/\ m.val = v)
=> (\E m \in msgs : \E v \in Values: m.type = "1a"
/\ m.cord = c
/\ m.val = v
/\ \E t \in Time : Phase1b(r,m,t))
)
Rule_1b_learn(r) ==
(Phase1b_learn(r) <=> (\E t \in Time : \E m \in msgs :
Send([type |-> "1b", cord |-> m.cord, rep |-> r], t)))
/\ (Phase1b_learn(r) <=> (\E c \in Coordinators: \E m \in msgs : m.type = "1a" /\ m.cord = c))
Rule_2b_msg(r) ==
\A c \in Coordinators :
(
(\E m \in msgs : m.type = "2a" /\ m.cord = c)
=> (\E m \in msgs : m.type = "2a" /\ m.cord = c
/\ (\E t \in Time : Phase2b(r,m,t)) )
)
Rule_2b_learn(r) ==
(Phase2b_learn(r) <=> (\E t \in Time : \E m \in msgs :
Send([type |-> "2b", cord |-> m.cord, rep |-> r], t)))
/\ (Phase2b_learn(r) <=> (\E c \in Coordinators: \E m \in msgs : m.type = "2a" /\ m.cord = c))
(***************************************************************************)
(*Non-Byzantine behavior of agents *)
(***************************************************************************)
\*A coordinator's expected behavior
Coordinator_behavior ==
(\A c \in Coordinators :
(\E t \in Time : Available(c,t)) => /\ Rule_1a_msg(c)
/\ Rule_2a_msg(c)
/\ Rule_2c_learn(c) )
\*A replica's expected behavior
Replica_behavior ==
(\A r \in Replicas :
(\E t \in Time : Available(r,t)) => /\ Rule_1b_msg(r)
/\ Rule_1b_learn(r)
/\ Rule_2b_msg(r)
/\ Rule_2b_learn(r))
(***************************************************************************)
(*The following section specifies assumptions for proving progress *)
(***************************************************************************)
\*All replicas are always available
allReplicasAlwaysAvailable == \A r \in Replicas : Always_available(r)
\* A coordinator is always available
existsCoordinatorAlwaysAvailable == \E c \in Coordinators : Always_available(c)
\* The set of replicas is non-empty
aNonEmptyReplicas == \E r \in Replicas : Always_available(r)
aDelivery ==
\* 1a msg
/\ \A c \in Coordinators : \A v \in Values : \A t \in Time :
Send([type |-> "1a", cord |-> c, val |-> v], t) <=>
\E t2 \in Time : (t2 > t) /\ Deliver([type |-> "1a", cord |-> c,
val |-> v],t2)
\* 1b msg Deliver([type |-> "1b", cord |-> m.cord, val |-> m.val, rep |-> r]
/\ \A r \in Replicas : \A m \in msgs : \A t \in Time :
Send([type |-> "1b", cord |-> m.cord, rep |-> r],t) <=>
\E t2 \in Time : (t2 > t) /\ Deliver ([type |-> "1b",
cord |-> m.cord,
rep |-> r],t2)
/\ \* 2a msg Deliver([type |-> "2a", cord |-> c], t2)
\A c \in Coordinators : \A t \in Time :
Send([type |-> "2a", cord |-> c], t)
<=> \E t2 \in Time : (t2 > t) /\ Deliver([type |-> "2a", cord |-> c], t2)
/\ \* 2b message Send([type |-> "2b", cord |-> m.cord, rep |-> r]
\A r \in Replicas : \A m \in msgs : \A t \in Time :
Send([type |-> "2b", cord |-> m.cord, rep |-> r],t) <=>
\E t2 \in Time : (t2 > t) /\ Deliver ([type |-> "2b",
cord |-> m.cord,
rep |-> r],t2)
\* All messages which have been delivered have been sent
aDeliveryImpliesSent ==
(
\A r \in Replicas:
(
(\E m \in msgs : (m.type = "2b" /\ m.rep = r))
=> (\E m \in msgs : \E t \in Time : state_time' = t /\ Available(r,t) /\ Send([type |-> "2b", cord |-> m.cord, rep |-> r],t))
)
)
/\ (
\A c \in Coordinators:
(
(\E m \in msgs : (m.type = "2a" /\ m.cord = c))
=> (\E t2 \in Time : state_time' = t2 /\ Available(c,t2) /\ Send([type |-> "2a", cord |-> c],t2))
)
)
/\ (
\A r \in Replicas:
(
(\E m \in msgs : (m.type = "1b" /\ m.rep = r))
=> (\E m \in msgs : \E t \in Time : state_time' = t /\ Available(r,t) /\ Send([type |-> "1b", cord |-> m.cord, rep |-> r],t))
)
)
aAvailability == allReplicasAlwaysAvailable
/\ existsCoordinatorAlwaysAvailable
aBehavior == Coordinator_behavior
/\ Replica_behavior
\*The type invariant which assumes that all variables are always of the correct type
aTypeOk == msgs \in SUBSET Messages
/\ cordVal \in [Coordinators -> Values]
/\ temporalProperties
pAssumptions == aAvailability
/\ aDelivery
\* /\ aDeliveryImpliesSent
/\ aNonEmptyReplicas
/\ aBehavior
/\ aTypeOk
sAssumptions == allReplicasAlwaysAvailable
/\ aDeliveryImpliesSent
/\ aBehavior
/\ aTypeOk
-----------------------------------------------------------------------------
(***************************************************************************)
(*The proof *)
(***************************************************************************)
\* Lemma - if a coordinator is available, 1a messages from it will be eventually
\* delivered if it has not received 1b messsages from all replicas
LEMMA Lemma1 ==
\A c \in Coordinators :
(
(\E t \in Time : Available(c,t)
/\ state_time = t
/\ (~(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c)))
/\ pAssumptions
=>
(\E t \in Time :
/\ state_time' = t
/\ (\E m \in msgs' : \E v \in Values : m.cord = c /\ m.type = "1a" /\ m.val = v))
)
<1> SUFFICES ASSUME NEW c \in Coordinators, pAssumptions,
(\E t \in Time : Available(c,t)
/\ state_time = t
/\ (~(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c)))
PROVE
(\E t \in Time :
/\ state_time' = t
/\ (\E m \in msgs' : \E v \in Values : m.cord = c /\ m.type = "1a" /\ m.val = v))
OBVIOUS
<1>1. (\E t \in Time : Available(c,t)
/\ state_time = t
/\ (~(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c)))
OBVIOUS
<1>2. aBehavior /\ aDelivery /\ aTypeOk
BY DEF pAssumptions
<1>3. Coordinator_behavior
BY <1>2 DEF aBehavior
<1>4. (\E t \in Time : Available(c,t)
/\ state_time = t
/\ (~(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c))
/\ Rule_1a_msg(c) )
BY <1>1, <1>3 DEF Coordinator_behavior
<1>5. (\E t \in Time : Available(c,t)
/\ state_time = t
/\ (~(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c))
/\ Rule_1a_msg(c)
/\ ( \E t2 \in Time : Phase1a(c,t2)))
BY <1>4 DEF Rule_1a_msg
<1>6. (\E t \in Time : Available(c,t)
/\ state_time = t
/\ (~(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c))
/\ Rule_1a_msg(c)
/\ ( \E t2 \in Time : Send([type |-> "1a", cord |-> c ,
val |-> cordVal[c]], t2)))
BY <1>5 DEF Phase1a
<1>6a. cordVal[c] \in Values
BY <1>2 DEF aTypeOk
<1>7. ( \E t2 \in Time : Deliver([type |-> "1a", cord |-> c , val |-> cordVal[c]], t2))
BY <1>6, <1>6a, <1>2 DEF aDelivery
<1>8. ( \E t2 \in Time : (state_time' = t2)
/\ (msgs' = msgs \cup {[type |-> "1a", cord |-> c , val |-> cordVal[c]]}) )
BY <1>7 DEF Deliver
<1>9. ( \E t2 \in Time : (state_time' = t2)
/\ \E v \in Values : ([type |-> "1a", cord |-> c , val |-> v] \in msgs') )
BY <1>8, <1>6a
<1>10. ( \E t2 \in Time : (state_time' = t2)
/\ \E v \in Values : \E m \in msgs' : m.type = "1a" /\ m.cord = c /\ m.val = v )
BY <1>9
<1>200. QED
BY <1>10
\* Lemma - If 1a messages from a coordinator have been delivered, eventually
\* 1b messages for P from all replicas will be delivered
LEMMA Lemma2 ==
\A c \in Coordinators :
(
( \E t2 \in Time : state_time = t2
/\ \E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v)
/\ pAssumptions
=>
( \E t2 \in Time : state_time' = t2
/\ \A r \in Replicas : \E m \in msgs' : m.type = "1b" /\ m.cord = c /\ m.rep = r)
)
<1> SUFFICES ASSUME NEW c \in Coordinators, pAssumptions,
(\E t2 \in Time : state_time = t2
/\ \E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v)
PROVE (\E t2 \in Time : state_time' = t2
/\ \A r \in Replicas : \E m \in msgs' : m.type = "1b" /\ m.cord = c /\ m.rep = r)
OBVIOUS
<1>1. (\E t2 \in Time : state_time = t2
/\ \E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v)
OBVIOUS
<1>2. aBehavior /\ aDelivery /\ aTypeOk /\ aAvailability
BY DEF pAssumptions
<1>3. Coordinator_behavior
BY <1>2 DEF aBehavior
<1>4. \A r \in Replicas : Always_available(r)
BY <1>2 DEF aAvailability, allReplicasAlwaysAvailable
<1>5. (\E t2 \in Time : state_time = t2
/\ (\E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v)
/\ (\A r \in Replicas : Available(r,t2)))
BY <1>4, <1>1 DEF Always_available
<1>5a. (\A r \in Replicas :
(\E t \in Time : Available(r,t)) => /\ Rule_1b_msg(r)
/\ Rule_2b_msg(r) )
BY <1>2 DEF aBehavior, Replica_behavior
<1>6. (\E t2 \in Time : state_time = t2
/\ (\E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v)
/\ \A r \in Replicas : Available(r,t2))
BY <1>5
<1>7.\A r \in Replicas : \E t2 \in Time :
state_time = t2
/\ Available(r,t2)
/\ (\E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v)
BY <1>6
<1>8.\A r \in Replicas : \E t2 \in Time :
state_time = t2
/\ Rule_1b_msg(r)
/\ (\E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v)
BY <1>7, <1>5a
<1>9.\A r \in Replicas : \E t2 \in Time :
state_time = t2
/\ \E m \in msgs : (\E v \in Values : m.type = "1a" /\ m.cord = c /\ m.val = v)
/\ Rule_1b_msg(r)
BY <1>8
<1>10.\A r \in Replicas :
/\ \E m \in msgs : (\E v \in Values : m.type = "1a" /\ m.cord = c /\ m.val = v)
/\ \E t \in Time : Phase1b(r,m,t)
BY <1>9 DEF Rule_1b_msg
<1>11.\A r \in Replicas :
/\ \E m \in msgs : (m.type = "1a" /\ m.cord = c)
/\ \E t \in Time : Send([type |-> "1b", cord |-> m.cord, rep |-> r], t)
BY <1>10 DEF Phase1b
<1>12.\A r \in Replicas :
/\ \E m \in msgs : m.type = "1a" /\ m.cord = c
/\ \E t \in Time : Deliver([type |-> "1b", cord |-> m.cord, rep |-> r], t)
BY <1>11, <1>2 DEF aDelivery
<1>13.\A r \in Replicas :
/\ \E m \in msgs : m.type = "1a" /\ m.cord = c
/\ \E t \in Time : state_time' = t
/\ msgs' = msgs \cup {[type |-> "1b", cord |-> m.cord, rep |-> r]}
BY <1>12 DEF Deliver
<1>13a.\A r \in Replicas :
/\ \E m \in msgs : m.type = "1a" /\ m.cord = c
/\ \E t \in Time : state_time' = t
/\ msgs' = msgs \cup {[type |-> "1b", cord |-> c, rep |-> r]}
BY <1>13
<1>14.\A r \in Replicas :
/\ \E m \in msgs : m.type = "1a" /\ m.cord = c
/\ \E t \in Time : state_time' = t
/\ [type |-> "1b", cord |-> c, rep |-> r] \in msgs'
BY <1>13
<1>15.\A r \in Replicas :
/\ \E t \in Time : state_time' = t
/\ \E m \in msgs' : m.type = "1b" /\ m.cord = c /\ m.rep = r
BY <1>14
<1>16. \E t \in Time : state_time' = t
/\ \A r \in Replicas : \E m \in msgs' : m.type = "1b" /\ m.cord = c /\ m.rep = r
BY <1>2, <1>15 DEF aTypeOk, temporalProperties, temporalProperty1
<1>200. QED
BY <1>16
\* Lemma - If 1b messages from all replicas have been delivered for a coordinator
\* which is available, eventually 2a messages from it will be delivered
LEMMA Lemma3 ==
\A c \in Coordinators :
(
(\E t \in Time : Available(c,t)
/\ state_time = t
/\ ((\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord=c)))
/\ pAssumptions
=>
(\E t \in Time :
state_time' = t
/\ (\E m \in msgs' : m.cord = c /\ m.type = "2a"))
)
<1> SUFFICES ASSUME NEW c \in Coordinators, pAssumptions,
(\E t \in Time : Available(c,t)
/\ state_time = t
/\ ((\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord=c)))
PROVE (\E t \in Time :
state_time' = t
/\ (\E m \in msgs' : m.cord = c /\ m.type = "2a"))
OBVIOUS
<1>1. (\E t \in Time : Available(c,t)
/\ state_time = t
/\ ((\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord=c)))
OBVIOUS
<1>2. aBehavior /\ aDelivery /\ aTypeOk /\ aAvailability
BY DEF pAssumptions
<1>3. Coordinator_behavior
BY <1>2 DEF aBehavior
<1>4. (\E t \in Time : Available(c,t)
/\ state_time = t
/\ Rule_2a_msg(c)
/\ ((\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord=c)))
BY <1>1, <1>2 DEF aBehavior, Coordinator_behavior
<1>5. \E t \in Time :
state_time = t
/\ Rule_2a_msg(c)
/\ (\E t2 \in Time : Phase2a(c,t2))
BY <1>4 DEF Rule_2a_msg
<1>6. (\E t2 \in Time : Send([type |-> "2a", cord |-> c], t2))
BY <1>5 DEF Phase2a
<1>7. (\E t2 \in Time : Deliver([type |-> "2a", cord |-> c], t2))
BY <1>6, <1>2 DEF aDelivery
<1>8. (\E t2 \in Time : state_time' = t2 /\ msgs' = msgs \cup{[type |-> "2a", cord |-> c]})
BY <1>7 DEF Deliver
<1>9. (\E t2 \in Time : state_time' = t2 /\ [type |-> "2a", cord |-> c] \in msgs')
BY <1>8
<1>10. (\E t \in Time :
state_time' = t
/\ (\E m \in msgs' : m.cord = c /\ m.type = "2a"))
BY <1>9
<1>200. QED
BY <1>10
\* Lemma - If 2a messages from a coordinator have been delivered, eventually
\* 2b messages for P from all replicas will be delivered
LEMMA Lemma4 ==
\A c \in Coordinators :
(
( \E t2 \in Time : state_time = t2
/\ \E m \in msgs : m.type = "2a" /\ m.cord = c)
/\ pAssumptions
=>
( \E t2 \in Time : state_time' = t2
/\ \A r \in Replicas : \E m \in msgs' : m.type = "2b" /\ m.cord = c /\ m.rep = r)
)
<1> SUFFICES ASSUME NEW c \in Coordinators, pAssumptions,
( \E t2 \in Time : state_time = t2
/\ \E m \in msgs : m.type = "2a" /\ m.cord = c)
PROVE
( \E t2 \in Time : state_time' = t2
/\ \A r \in Replicas : \E m \in msgs' : m.type = "2b" /\ m.cord = c /\ m.rep = r)
OBVIOUS
<1>1. (\E t2 \in Time : state_time = t2
/\ \E m \in msgs : m.type = "2a" /\ m.cord = c)
OBVIOUS
<1>2. aBehavior /\ aDelivery /\ aTypeOk /\ aAvailability
BY DEF pAssumptions
<1>3. Coordinator_behavior
BY <1>2 DEF aBehavior
<1>4. \A r \in Replicas : Always_available(r)
BY <1>2 DEF aAvailability, allReplicasAlwaysAvailable
<1>5. (\E t2 \in Time : state_time = t2
/\ (\E m \in msgs : m.type = "2a" /\ m.cord = c)
/\ (\A r \in Replicas : Available(r,t2)))
BY <1>4, <1>1 DEF Always_available
<1>5a. (\A r \in Replicas :
(\E t \in Time : Available(r,t)) => /\ Rule_1b_msg(r)
/\ Rule_2b_msg(r) )
BY <1>2 DEF aBehavior, Replica_behavior
<1>6. (\E t2 \in Time : state_time = t2
/\ (\E m \in msgs : m.type = "2a" /\ m.cord = c )
/\ \A r \in Replicas : Available(r,t2))
BY <1>5
<1>7.\A r \in Replicas : \E t2 \in Time :
state_time = t2
/\ Available(r,t2)
/\ (\E m \in msgs : m.type = "2a" /\ m.cord = c )
BY <1>6
<1>8.\A r \in Replicas : \E t2 \in Time :
state_time = t2
/\ Rule_2b_msg(r)
/\ (\E m \in msgs : m.type = "2a" /\ m.cord = c)
BY <1>7, <1>5a
<1>9.\A r \in Replicas : \E t2 \in Time :
state_time = t2
/\ \E m \in msgs : ( m.type = "2a" /\ m.cord = c )
/\ Rule_2b_msg(r)
BY <1>8
<1>10.\A r \in Replicas :
/\ \E m \in msgs : ( m.type = "2a" /\ m.cord = c )
/\ \E t \in Time : Phase2b(r,m,t)
BY <1>9 DEF Rule_2b_msg
<1>11.\A r \in Replicas :
/\ \E m \in msgs : m.type = "2a" /\ m.cord = c
/\ \E t \in Time : Send([type |-> "2b", cord |-> m.cord, rep |-> r], t)
BY <1>10 DEF Phase2b
<1>12.\A r \in Replicas :
/\ \E m \in msgs : m.type = "2a" /\ m.cord = c
/\ \E t \in Time : Deliver([type |-> "2b", cord |-> m.cord, rep |-> r], t)
BY <1>11, <1>2 DEF aDelivery
<1>13.\A r \in Replicas :
/\ \E m \in msgs : m.type = "2a" /\ m.cord = c
/\ \E t \in Time : state_time' = t
/\ msgs' = msgs \cup {[type |-> "2b", cord |-> m.cord, rep |-> r]}
BY <1>12 DEF Deliver
<1>13a.\A r \in Replicas :
/\ \E m \in msgs : m.type = "2a" /\ m.cord = c
/\ \E t \in Time : state_time' = t
/\ msgs' = msgs \cup {[type |-> "2b", cord |-> c, rep |-> r]}
BY <1>13
<1>14.\A r \in Replicas :
/\ \E m \in msgs : m.type = "2a" /\ m.cord = c
/\ \E t \in Time : state_time' = t
/\ [type |-> "2b", cord |-> c, rep |-> r] \in msgs'
BY <1>13
<1>15.\A r \in Replicas :
/\ \E t \in Time : state_time' = t
/\ \E m \in msgs' : m.type = "2b" /\ m.cord = c /\ m.rep = r
BY <1>14
<1>16. \E t \in Time : state_time' = t
/\ \A r \in Replicas : \E m \in msgs' : m.type = "2b" /\ m.cord = c /\ m.rep = r
BY <1>2, <1>15 DEF aTypeOk, temporalProperties, temporalProperty1
<1>200. QED
BY <1>16
(***************************************************************************)
(*The intermediate states *)
(***************************************************************************)
\* after a coordinator has sent 1a msgs
msgsPost1a(c) ==
Always_available(c)
/\ \E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v
\* after a coordinator has received 1b messages from all replicas
msgsPost1b(c) ==
Always_available(c)
/\ \A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.cord = c /\ m.rep = r
\* after a coordinator has sent 2a msgs
msgsPost2a(c) ==
Always_available(c)
/\ \E m \in msgs : m.cord = c /\ m.type = "2a"
\* after a coordinator has received 2b messages from all replicas
msgsPost2b(c) ==
Always_available(c)
/\ \A r \in Replicas : \E m \in msgs : m.type = "2b" /\ m.cord = c /\ m.rep = r
----------------------------------------------------------------------------
\* Eventually, there will be 1a messages from a coordinator
LEMMA Lemma5 ==
pAssumptions =>
\E c \in Coordinators:
\E t \in Time: state_time = t
/\ msgsPost1a(c)
<1> SUFFICES ASSUME pAssumptions
PROVE \E c \in Coordinators:
\E t \in Time: state_time = t
/\msgsPost1a(c)
OBVIOUS
<1>1. aAvailability /\ aTypeOk /\ aNonEmptyReplicas
BY DEF pAssumptions
<1>2. existsCoordinatorAlwaysAvailable
BY <1>1 DEF aAvailability
<1>3. \E c \in Coordinators : Always_available(c)
BY <1>2 DEF existsCoordinatorAlwaysAvailable
<1>4. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ (~(\E m \in msgs : m.cord = c)))
BY <1>3, <1>1 DEF aTypeOk, temporalProperties, temporalProperty2
<1>5. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ Available(c,t)
/\ (~(\E m \in msgs : m.cord = c)))
BY <1>4 DEF Always_available
<1>5a. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ Available(c,t)
/\ \E r \in Replicas : Always_available(r)
/\ (~(\E m \in msgs : m.cord = c)))
BY <1>5, <1>1 DEF aNonEmptyReplicas
<1>5b. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ Available(c,t)
/\ (\E r \in Replicas : Always_available(r))
/\ (\E r \in Replicas : ~(\E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c)))
BY <1>5a
<1>5c. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ Available(c,t)
/\ (\E r \in Replicas : Always_available(r))
/\ (~(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c)))
BY <1>5b
<1>5d. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : Available(c,t)
/\ state_time = t
/\ (~(\A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.rep = r /\ m.cord = c)))
BY <1>5c
<1>6. \E t \in Time : \E c \in Coordinators : Always_available(c)
/\ state_time' = t
/\ \E v \in Values : \E m \in msgs' : m.type = "1a" /\ m.cord = c /\ m.val = v
BY <1>5d, Lemma1
<1>7. \E t \in Time : \E c \in Coordinators :
\E t2 \in Time: state_time = t2
/\ Always_available(c)
/\ \E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v
BY <1>6, <1>1 DEF aTypeOk, temporalProperties, temporalProperty3
<1>8. \E t \in Time : \E c \in Coordinators : state_time = t
/\ msgsPost1a(c)
BY <1>7 DEF msgsPost1a
<1>200. QED
BY <1>8
LEMMA Lemma6 ==
pAssumptions =>
\E c \in Coordinators:
\E t \in Time: state_time = t
/\ msgsPost1b(c)
<1> SUFFICES ASSUME pAssumptions
PROVE \E c \in Coordinators:
\E t \in Time: state_time = t
/\msgsPost1b(c)
OBVIOUS
<1>1. aAvailability /\ aTypeOk /\ aNonEmptyReplicas
BY DEF pAssumptions
<1>4. \E c \in Coordinators:
\E t \in Time: state_time = t
/\msgsPost1a(c)
BY Lemma5
<1>5. \E c \in Coordinators :
/\ \E t \in Time : state_time = t
/\ Always_available(c)
/\ \E v \in Values : \E m \in msgs : m.type = "1a" /\ m.cord = c /\ m.val = v
BY <1>4 DEF msgsPost1a
<1>5a. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time' = t
/\ \A r \in Replicas : \E m \in msgs' : m.type = "1b" /\ m.cord = c /\ m.rep = r)
BY <1>5, Lemma2
<1>6. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ \A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.cord = c /\ m.rep = r)
BY <1>5a, <1>1 DEF aTypeOk, temporalProperties, temporalProperty3
<1>8. \E t \in Time : \E c \in Coordinators : state_time = t
/\ msgsPost1b(c)
BY <1>6 DEF msgsPost1b
<1>200. QED
BY <1>8
LEMMA Lemma7 ==
pAssumptions =>
\E c \in Coordinators:
\E t \in Time: state_time = t
/\ msgsPost2a(c)
<1> SUFFICES ASSUME pAssumptions
PROVE \E c \in Coordinators:
\E t \in Time: state_time = t
/\msgsPost2a(c)
OBVIOUS
<1>1. aAvailability /\ aTypeOk /\ aNonEmptyReplicas
BY DEF pAssumptions
<1>4. \E c \in Coordinators:
\E t \in Time: state_time = t
/\msgsPost1b(c)
BY Lemma6
<1>5. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ \A r \in Replicas : \E m \in msgs : m.type = "1b" /\ m.cord = c /\ m.rep = r)
BY <1>4 DEF msgsPost1b
<1>6. \E c \in Coordinators : Always_available(c)
/\ \E t \in Time : state_time' = t
/\ \E m \in msgs' : m.cord = c /\ m.type = "2a"
BY <1>5, Lemma3 DEF Always_available
<1>7. \E t \in Time : \E c \in Coordinators : Always_available(c)
/\ state_time = t
/\ \E m \in msgs : m.cord = c /\ m.type = "2a"
BY <1>6, <1>1 DEF aTypeOk, temporalProperties, temporalProperty3
<1>8. \E t \in Time : \E c \in Coordinators : state_time = t
/\ msgsPost2a(c)
BY <1>7 DEF msgsPost2a
<1>200. QED
BY <1>8
LEMMA Lemma8 ==
pAssumptions =>
\E c \in Coordinators:
\E t \in Time: state_time = t
/\ msgsPost2b(c)
<1> SUFFICES ASSUME pAssumptions
PROVE \E c \in Coordinators:
\E t \in Time: state_time = t
/\msgsPost2b(c)
OBVIOUS
<1>1. aAvailability /\ aTypeOk /\ aNonEmptyReplicas
BY DEF pAssumptions
<1>4. \E c \in Coordinators:
\E t \in Time: state_time = t
/\msgsPost2a(c)
BY Lemma7
<1>5. \E c \in Coordinators :
/\ \E t \in Time : state_time = t
/\ Always_available(c)
/\ \E m \in msgs : m.type = "2a" /\ m.cord = c
BY <1>4 DEF msgsPost2a
<1>5a. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time' = t
/\ \A r \in Replicas : \E m \in msgs' : m.type = "2b" /\ m.cord = c /\ m.rep = r)
BY <1>5, Lemma4
<1>6. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ \A r \in Replicas : \E m \in msgs : m.type = "2b" /\ m.cord = c /\ m.rep = r)
BY <1>5a, <1>1 DEF aTypeOk, temporalProperties, temporalProperty3
<1>8. \E t \in Time : \E c \in Coordinators : state_time = t
/\ msgsPost2b(c)
BY <1>6 DEF msgsPost2b
<1>200. QED
BY <1>8
\* Progress Theorem - Eventually a coordinator knows that `^$E^2_{G}\phi$ ^'
\* has been attained
THEOREM Theorem1 ==
pAssumptions =>
(\E t \in Time : \E c \in Coordinators : state_time = t /\ safeStateAttained' = [safeStateAttained EXCEPT ![c] = TRUE])
<1> SUFFICES ASSUME pAssumptions
PROVE (\E t \in Time : \E c \in Coordinators : state_time = t /\ safeStateAttained' = [safeStateAttained EXCEPT ![c] = TRUE])
OBVIOUS
<1>1. \E t \in Time : \E c \in Coordinators : state_time = t
/\ msgsPost2b(c)
BY Lemma8
<1>2. \E c \in Coordinators :
/\ (\E t \in Time : state_time = t
/\ Always_available(c)
/\ \A r \in Replicas : \E m \in msgs : m.type = "2b" /\ m.cord = c /\ m.rep = r)
BY <1>1 DEF msgsPost2b
<1>3. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ Available(c,t)
/\ \A r \in Replicas : \E m \in msgs : m.type = "2b" /\ m.cord = c /\ m.rep = r)
BY <1>2 DEF Always_available
<1>4. aBehavior
BY DEF pAssumptions
<1>5. Coordinator_behavior
BY <1>4 DEF aBehavior
<1>6. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ Rule_2c_learn(c)
/\ \A r \in Replicas : \E m \in msgs : m.type = "2b" /\ m.cord = c /\ m.rep = r)
BY <1>3, <1>5 DEF Coordinator_behavior
<1>7. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ Rule_2c_learn(c)
/\ Available(c,t)
/\ (\A r \in Replicas : \E m \in msgs : m.type = "2b" /\ m.cord = c /\ m.rep = r))
BY <1>6 DEF Always_available
<1>8. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ Rule_2c_learn(c)
/\ Available(c,t)
/\ (Phase2c_learn(c))
/\ (\A r \in Replicas : \E m \in msgs : m.type = "2b" /\ m.cord = c /\ m.rep = r))
BY <1>7 DEF Rule_2c_learn
<1>9. \E c \in Coordinators : Always_available(c)
/\ (\E t \in Time : state_time = t
/\ (safeStateAttained' = [safeStateAttained EXCEPT ![c] = TRUE]) )
BY <1>8 DEF Phase2c_learn
<1>10. \E t2 \in Time : \E c \in Coordinators :
((state_time = t2 /\ safeStateAttained' = [safeStateAttained EXCEPT ![c] = TRUE]) )
BY <1>9
<1>200 QED
BY <1>10
\* Safety Lemma1 - A Coordinator will not learn `^$E^2_{G}\phi$ ^' if there
\* is at least one replica which does not know `^$E_{G}\phi$ ^'
THEOREM Lemma9 ==
sAssumptions =>
(
\A t \in Time : \A c \in Coordinators :
(( state_time = t
/\ Available(c,t)
/\ safeStateAttained' = [safeStateAttained EXCEPT ![c] = TRUE])
=>
(\A r \in Replicas : allKnowVal' = [allKnowVal EXCEPT ![r] = TRUE]))
)
<1> SUFFICES ASSUME sAssumptions,
NEW t \in Time, NEW c \in Coordinators,
( state_time = t
/\ Available(c,t)
/\ safeStateAttained' = [safeStateAttained EXCEPT ![c] = TRUE])
PROVE (\A r \in Replicas : allKnowVal' = [allKnowVal EXCEPT ![r] = TRUE])
OBVIOUS
<1>1.( state_time = t
/\ Available(c,t)
/\ safeStateAttained'= [safeStateAttained EXCEPT ![c] = TRUE])
OBVIOUS
<1>2. aBehavior /\ allReplicasAlwaysAvailable
BY DEF sAssumptions
<1>3. state_time = t
/\ Available(c,t)
/\ Phase2c_learn(c)
BY <1>1, <1>2 DEF aBehavior, Coordinator_behavior, Rule_2c_learn, Phase2c_learn
<1>3a. Available(c,t) => ((\A r \in Replicas : (\E m \in msgs : m.type = "2b" /\ m.rep = r /\ m.cord = c)) <=> Phase2c_learn(c) )
BY <1>2 DEF aBehavior, Coordinator_behavior, Rule_2c_learn
<1>4.
state_time = t
/\ Available(c,t)
/\ Phase2c_learn(c)
/\ (\A r \in Replicas : (\E m \in msgs : m.type = "2b" /\ m.rep = r /\ m.cord = c))
BY <1>1, <1>2 DEF aBehavior, Coordinator_behavior, Rule_2c_learn, Phase2c_learn
<1>5. (\A r \in Replicas : (\E m \in msgs : m.type = "2b" /\ m.rep = r /\ m.cord = c))
BY <1>4
<1>5a1. \A r \in Replicas : (\E m \in msgs : m.type = "2b" /\ m.rep = r )
BY <1>5