Repository navigation
Expand file tree
/
Copy pathPOPL24_JayantiTarjanUF.tla
More file actions
4968 lines (4870 loc) · 190 KB
/
Copy pathPOPL24_JayantiTarjanUF.tla
File metadata and controls
4968 lines (4870 loc) · 190 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
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 POPL24_JayantiTarjanUF -----------------------
(****************************************************************************
Authors: Prasad Jayanti, Siddhartha Jayanti, Uğur Y. Yavuz, Lizzie Hernández Videa
Date: 2023-10-07
This is the TLA+ specification of Jayanti-Tarjan concurrent union-find
algorithm [Jayanti & Tarjan, 2016; Jayanti & Tarjan, 2021] with any-try splitting
(a generalized version of two-try splitting described in the 2021 paper);
and its proof of linearizability in TLAPS, using the tracking technique as
described in our work "A Universal, Sound, and Complete Forward Reasoning Technique for
Machine-Verified Proofs of Linearizability", to appear in POPL 2024.
Specficially, it corresponds to the partial tracker described in
the Appendix.
[Jayanti & Tarjan, 2016]
Siddhartha V. Jayanti & Robert E. Tarjan, 2016.
"A Randomized Concurrent Algorithm for Disjoint Set Union."
In Proceedings of the 2016 ACM Symposium on Principles of Distributed Computing (PODC '16).
Association for Computing Machinery, New York, NY, USA, 75–82. https://doi.org/10.1145/2933057.2933108
[Jayanti & Tarjan, 2021]
Siddhartha V. Jayanti & Robert E. Tarjan, 2021.
"Concurrent disjoint set union."
Distrib. Comput. 34, 413–436 (2021). https://doi.org/10.1007/s00446-020-00388-x
FILE OUTLINE:
- Lines 89-110: Preliminary definitions
- Lines 110-372: Specification
- Lines 372-511: Type-correctness and proof of type-correctness
- Lines 511-801: Remaining invariants and related lemmas
- Lines 801-4727: Proof of inductive invariance
- Lines 4727-4731: Proof of linearizability (immediate from the proof above)
- Lines 4731-4963: Proof of strong linearizability
TYPE:
- Find(x) returns the maximum element in element x’s part of the partition.
Invokable by any process.
- Union(x, y) merges the parts of the partition containing x and y if they
are different. Invokable by any process.
CONSTANTS:
- N: the number of nodes.
MODEL VALUES:
- ACK ('ack' in the paper) is a special value that is used to indicate
an operation has been completed.
- BOT (\bot in the paper) is akin to a null value.
- ProcSet is the set of all processes.
SHARED VARIABLES:
- Par[1..N] is an array of "parent pointers".
LOCAL VARIABLES:
- For each process p: x_p, y_p, u_p, v_p, a_p, b_p are local variables.
ALGORITHM:
- F1: Find(x):
--------
u <- x
F2: a <- Par[u]
if (u = a) goto F6
F3: b <- Par[a]
F4: CAS(Par[u], a, b); goto F2 or F5
F5: u <- a; goto F2
F6: return u
- U1: Union(x, y):
------------
u <- x; v <- y
U2: if (u = v) goto U11
else if (u > v): if (v = CAS(Par[u], u, v)): goto U11
else if (u < v): if (u = CAS(Par[v], v, u)): goto U11
U3: a <- Par[u]; if (u = a) goto U7
U4: b <- Par[a]
U5: CAS(Par[u], a, b); goto U3 or U6
U6: u <- a; goto U3
U7: a <- Par[v]; if (v = a) goto U2
U8: b <- Par[a]
U9: CAS(Par[v], a, b); goto U7 or U10
U10: v <- a; goto U7
U11: return ACK
Note: Each line has at most 1 shared memory instruction.
****************************************************************************)
EXTENDS Integers, FiniteSetTheorems, TLAPS
CONSTANTS ProcSet, N, NIL, ACK
VARIABLES Par, x, y, u, v, a, b, pc, M \* M is the meta-configuration.
vars == <<Par, x, y, u, v, a, b, pc>>
augs == <<M>>
allvars == <<Par, x, y, u, v, a, b, pc, M>>
\* A few useful definitions.
InvocationLines == {"F1", "U1"}
Lines == {"F1", "F2", "F3", "F4", "F5", "F6",
"U1", "U2", "U3", "U4", "U5", "U6", "U7", "U8", "U9", "U10", "U11"}
NodeSet == 1..N
PowerSetNodes == SUBSET NodeSet
States == [NodeSet -> PowerSetNodes]
Rets == [ProcSet -> NodeSet \cup {NIL} \cup {ACK}]
AtomConfigs == [sigma: States, f: Rets] \* Set of all structures t, with t.State \in States and t.f \in Rets
\* Max operator
Max(S) == CHOOSE X \in S : \A Y \in S : Y <= X
\* SPECIFICATION
\* The initial predicate.
\* Notes:
\* - The meta-configuration M contains atomic configurations C = (C.sigma, C.f),
\* where C.f is a triple (op, arg, res). In the TLA+ specification, we use
\* (sigma, f) = (C.sigma, C.f.res) as the atomic configuration; as op and arg
\* are uniquely determined by pc, i, and v.
\* * Alternatively, one can keep these fields in the meta-configuration and
\* prove an invariant that, for a process p, the value of pc[p] imposes a
\* unique value for C.f.op[p], and the value of the variables passed in as
\* arguments, does so for C.f.arg[p], for all configurations C in M. Since
\* this increases proof overhead, we opt for this simplification.
InitVars == /\ Par = [z \in NodeSet |-> z]
/\ x \in [ProcSet -> NodeSet]
/\ y \in [ProcSet -> NodeSet]
/\ u \in [ProcSet -> NodeSet]
/\ v \in [ProcSet -> NodeSet]
/\ a \in [ProcSet -> NodeSet]
/\ b \in [ProcSet -> NodeSet]
/\ pc \in [ProcSet -> InvocationLines]
sigmaInit == [z \in NodeSet |-> {z}]
fInit == [p \in ProcSet |-> NIL]
InitAug == M = {[sigma |-> sigmaInit, f |-> fInit]}
Init == InitVars /\ InitAug
\* Line F1 | Find(x): u <- x
LineF1(p) == /\ pc[p] = "F1"
/\ \E xnew \in NodeSet:
/\ x' = [x EXCEPT ![p] = xnew]
/\ u' = [u EXCEPT ![p] = xnew]
/\ pc' = [pc EXCEPT ![p] = "F2"]
/\ UNCHANGED <<Par, y, v, a, b>>
\* No updates to the meta-configuration.
AugF1(p) == M' = M
F1(p) == LineF1(p) /\ AugF1(p)
\* Line F2 | a <- Par[u]; if (u = a) goto F6
LineF2(p) == /\ pc[p] = "F2"
/\ a' = [a EXCEPT ![p] = Par[u[p]]]
/\ IF Par[u[p]] = u[p] \* a'[p]
THEN pc' = [pc EXCEPT ![p] = "F6"]
ELSE pc' = [pc EXCEPT ![p] = "F3"]
/\ UNCHANGED <<Par, x, y, u, v, b>>
\* Update the meta-configuration: linearize p if going to F6.
AugF2(p) == IF Par[u[p]] = u[p]
THEN M' = {t \in AtomConfigs : \E told \in M : /\ told.f[p] = NIL
/\ t.sigma = told.sigma
/\ t.f = [told.f EXCEPT ![p] = Max(told.sigma[x[p]])]}
ELSE M' = M
F2(p) == LineF2(p) /\ AugF2(p)
\* Line F3 | b <- Par[a]
LineF3(p) == /\ pc[p] = "F3"
/\ b' = [b EXCEPT ![p] = Par[a[p]]]
/\ pc' = [pc EXCEPT ![p] = "F4"]
/\ UNCHANGED <<Par, x, y, u, v, a>>
\* No updates to the meta-configuration.
AugF3(p) == M' = M
F3(p) == LineF3(p) /\ AugF3(p)
\* Line F4 | CAS(Par[u], a, b); goto F2 or F5
LineF4(p) == /\ pc[p] = "F4"
/\ IF Par[u[p]] = a[p]
THEN Par' = [Par EXCEPT ![u[p]] = b[p]]
ELSE Par' = Par
/\ \/ pc' = [pc EXCEPT ![p] = "F5"]
\/ pc' = [pc EXCEPT ![p] = "F2"]
/\ UNCHANGED <<x, y, u, v, a, b>>
\* No updates to the meta-configuration.
AugF4(p) == M' = M
F4(p) == LineF4(p) /\ AugF4(p)
\* Line F5 | u <- a; goto F2
LineF5(p) == /\ pc[p] = "F5"
/\ u' = [u EXCEPT ![p] = a[p]]
/\ pc' = [pc EXCEPT ![p] = "F2"]
/\ UNCHANGED <<Par, x, y, v, a, b>>
\* No updates to the meta-configuration.
AugF5(p) == M' = M
F5(p) == LineF5(p) /\ AugF5(p)
\* Line F6 | return u
LineF6(p) == /\ pc[p] = "F6"
/\ \E line \in InvocationLines : pc' = [pc EXCEPT ![p] = line]
/\ UNCHANGED <<Par, x, y, u, v, a, b>>
\* Update the meta-configuration: filter out configurations that don't match
\* the return value of p's operation, and reset the return value to BOT.
AugF6(p) == M' = {t \in AtomConfigs : \E told \in M : /\ told.f[p] = u[p]
/\ t.sigma = told.sigma
/\ t.f = [told.f EXCEPT ![p] = NIL]}
F6(p) == LineF6(p) /\ AugF6(p)
\* Line U1 | Union(x, y): u <- x; v <- y
LineU1(p) == /\ pc[p] = "U1"
/\ \E xnew \in NodeSet:
/\ x' = [x EXCEPT ![p] = xnew]
/\ u' = [u EXCEPT ![p] = xnew]
/\ \E ynew \in NodeSet:
/\ y' = [y EXCEPT ![p] = ynew]
/\ v' = [v EXCEPT ![p] = ynew]
/\ pc' = [pc EXCEPT ![p] = "U2"]
/\ UNCHANGED <<Par, a, b>>
\* No updates to the meta-configuration.
AugU1(p) == M' = M
U1(p) == LineU1(p) /\ AugU1(p)
\* Line U2 | if (u = v) goto U11; ...
LineU2(p) == /\ pc[p] = "U2"
/\ CASE u[p] = v[p] -> (/\ pc' = [pc EXCEPT ![p] = "U11"]
/\ UNCHANGED <<Par, x, y, u, v, a, b>>)
[] u[p] < v[p] -> (IF Par[u[p]] = u[p]
THEN /\ Par' = [Par EXCEPT ![u[p]] = v[p]]
/\ pc' = [pc EXCEPT ![p] = "U11"]
/\ UNCHANGED <<x, y, u, v, a, b>>
ELSE /\ Par' = Par
/\ pc' = [pc EXCEPT ![p] = "U3"]
/\ UNCHANGED <<x, y, u, v, a, b>>)
[] OTHER -> (IF Par[v[p]] = v[p]
THEN /\ Par' = [Par EXCEPT ![v[p]] = u[p]]
/\ pc' = [pc EXCEPT ![p] = "U11"]
/\ UNCHANGED <<x, y, u, v, a, b>>
ELSE /\ Par' = Par
/\ pc' = [pc EXCEPT ![p] = "U3"]
/\ UNCHANGED <<x, y, u, v, a, b>>)
\* Update the meta-configuration: linearize p if going to U11.
\* This should also update the state; by updating the map from nodes to their parts,
\* to reflect the union of the parts of u and v.
AugU2(p) == IF u[p] = v[p]
THEN M' = {t \in AtomConfigs : \E told \in M: /\ told.f[p] = NIL
/\ t.sigma = told.sigma
/\ t.f = [told.f EXCEPT ![p] = ACK]
}
ELSE IF (u[p] < v[p] /\ Par[u[p]] = u[p]) \/ (u[p] > v[p] /\ Par[v[p]] = v[p])
THEN M' = {t \in AtomConfigs : \E told \in M: /\ told.f[p] = NIL
/\ \A z \in NodeSet:
(z \in told.sigma[x[p]] \cup told.sigma[y[p]])
=> (t.sigma[z] = told.sigma[x[p]] \cup told.sigma[y[p]])
/\ \A z \in NodeSet:
(z \notin told.sigma[x[p]] \cup told.sigma[y[p]])
=> (t.sigma[z] = told.sigma[z])
/\ t.f = [told.f EXCEPT ![p] = ACK]}
ELSE M' = M
U2(p) == LineU2(p) /\ AugU2(p)
\* Line U3 | a <- Par[u]; if (u = a) goto U7
LineU3(p) == /\ pc[p] = "U3"
/\ a' = [a EXCEPT ![p] = Par[u[p]]]
/\ IF Par[u[p]] = u[p] \* a'[p]
THEN pc' = [pc EXCEPT ![p] = "U7"]
ELSE pc' = [pc EXCEPT ![p] = "U4"]
/\ UNCHANGED <<Par, x, y, u, v, b>>
\* No updates to the meta-configuration.
AugU3(p) == M' = M
U3(p) == LineU3(p) /\ AugU3(p)
\* Line U4 | b <- Par[a]
LineU4(p) == /\ pc[p] = "U4"
/\ b' = [b EXCEPT ![p] = Par[a[p]]]
/\ pc' = [pc EXCEPT ![p] = "U5"]
/\ UNCHANGED <<Par, x, y, u, v, a>>
\* No updates to the meta-configuration.
AugU4(p) == M' = M
U4(p) == LineU4(p) /\ AugU4(p)
\* Line U5 | CAS(Par[u], a, b); goto U3 or U6
LineU5(p) == /\ pc[p] = "U5"
/\ IF Par[u[p]] = a[p]
THEN Par' = [Par EXCEPT ![u[p]] = b[p]]
ELSE Par' = Par
/\ \/ pc' = [pc EXCEPT ![p] = "U6"]
\/ pc' = [pc EXCEPT ![p] = "U3"]
/\ UNCHANGED <<x, y, u, v, a, b>>
\* No updates to the meta-configuration.
AugU5(p) == M' = M
U5(p) == LineU5(p) /\ AugU5(p)
\* Line U6 | u <- a; goto U3
LineU6(p) == /\ pc[p] = "U6"
/\ u' = [u EXCEPT ![p] = a[p]]
/\ pc' = [pc EXCEPT ![p] = "U3"]
/\ UNCHANGED <<Par, x, y, v, a, b>>
\* No updates to the meta-configuration.
AugU6(p) == M' = M
U6(p) == LineU6(p) /\ AugU6(p)
\* Line U7 | a <- Par[v]; if (v = a) goto U2
LineU7(p) == /\ pc[p] = "U7"
/\ a' = [a EXCEPT ![p] = Par[v[p]]]
/\ IF Par[v[p]] = v[p] \* a'[p]
THEN pc' = [pc EXCEPT ![p] = "U2"]
ELSE pc' = [pc EXCEPT ![p] = "U8"]
/\ UNCHANGED <<Par, x, y, u, v, b>>
\* No updates to the meta-configuration.
AugU7(p) == M' = M
U7(p) == LineU7(p) /\ AugU7(p)
\* Line U8 | b <- Par[a]
LineU8(p) == /\ pc[p] = "U8"
/\ b' = [b EXCEPT ![p] = Par[a[p]]]
/\ pc' = [pc EXCEPT ![p] = "U9"]
/\ UNCHANGED <<Par, x, y, u, v, a>>
\* No updates to the meta-configuration.
AugU8(p) == M' = M
U8(p) == LineU8(p) /\ AugU8(p)
\* Line U9 | CAS(Par[v], a, b); goto U7 or U10
LineU9(p) == /\ pc[p] = "U9"
/\ IF Par[v[p]] = a[p]
THEN Par' = [Par EXCEPT ![v[p]] = b[p]]
ELSE Par' = Par
/\ \/ pc' = [pc EXCEPT ![p] = "U10"]
\/ pc' = [pc EXCEPT ![p] = "U7"]
/\ UNCHANGED <<x, y, u, v, a, b>>
\* No updates to the meta-configuration.
AugU9(p) == M' = M
U9(p) == LineU9(p) /\ AugU9(p)
\* Line U10 | v <- a; goto U7
LineU10(p) == /\ pc[p] = "U10"
/\ v' = [v EXCEPT ![p] = a[p]]
/\ pc' = [pc EXCEPT ![p] = "U7"]
/\ UNCHANGED <<Par, x, y, u, a, b>>
\* No updates to the meta-configuration.
AugU10(p) == M' = M
U10(p) == LineU10(p) /\ AugU10(p)
\* Line U11 | return ACK
LineU11(p) == /\ pc[p] = "U11"
/\ \E line \in InvocationLines : pc' = [pc EXCEPT ![p] = line]
/\ UNCHANGED <<Par, x, y, u, v, a, b>>
\* Update the meta-configuration: filter out configurations that don't match
\* the return value of p's operation, and reset the return value to BOT.
AugU11(p) == M' = {t \in AtomConfigs : \E told \in M : /\ told.f[p] = ACK
/\ t.sigma = told.sigma
/\ t.f = [told.f EXCEPT ![p] = NIL]}
U11(p) == LineU11(p) /\ AugU11(p)
\* The next-state relation.
Step(p) == \/ F1(p)
\/ F2(p)
\/ F3(p)
\/ F4(p)
\/ F5(p)
\/ F6(p)
\/ U1(p)
\/ U2(p)
\/ U3(p)
\/ U4(p)
\/ U5(p)
\/ U6(p)
\/ U7(p)
\/ U8(p)
\/ U9(p)
\/ U10(p)
\/ U11(p)
Next == \E p \in ProcSet : Step(p)
\* The specification.
Spec == Init /\ [][Next]_allvars
\* TYPE CORRECTNESS
\* Type correctness invariants for each variable
ValidPar == Par \in [NodeSet -> NodeSet]
Validx == x \in [ProcSet -> NodeSet]
Validy == y \in [ProcSet -> NodeSet]
Validu == u \in [ProcSet -> NodeSet]
Validv == v \in [ProcSet -> NodeSet]
Valida == a \in [ProcSet -> NodeSet]
Validb == b \in [ProcSet -> NodeSet]
Validpc == pc \in [ProcSet -> Lines]
ValidP == M \in SUBSET AtomConfigs
\* Overall type-correctness invariant
TypeOK == /\ ValidPar
/\ Validx
/\ Validy
/\ Validu
/\ Validv
/\ Valida
/\ Validb
/\ Validpc
/\ ValidP
\* Proof of type-correctness
LEMMA InitTypeSafety == Init => TypeOK
<1> USE DEF Init, InitVars, NodeSet
<1> SUFFICES ASSUME Init
PROVE TypeOK
OBVIOUS
<1>1. ValidPar
BY DEF ValidPar
<1>2. Validx
BY DEF Validx
<1>3. Validy
BY DEF Validy
<1>4. Validu
BY DEF Validu
<1>5. Validv
BY DEF Validv
<1>6. Valida
BY DEF Valida
<1>7. Validb
BY DEF Validb
<1>8. Validpc
BY DEF Validpc, InvocationLines, Lines
<1>9. ValidP
BY DEF ValidP, InitAug, sigmaInit, fInit, AtomConfigs, States, Rets, PowerSetNodes
<1>10. QED
BY <1>1, <1>2, <1>3, <1>4, <1>5, <1>6, <1>7, <1>8, <1>9 DEF TypeOK
LEMMA NextTypeSafety == TypeOK /\ [Next]_allvars => TypeOK'
<1> USE DEF TypeOK, ValidPar, Validx, Validy, Validu, Validv, Valida, Validb,
Validpc, ValidP, Next, allvars, Step, NodeSet, Lines
<1> SUFFICES ASSUME TypeOK,
[Next]_allvars
PROVE TypeOK'
OBVIOUS
<1>1. ASSUME NEW p \in ProcSet,
F1(p)
PROVE TypeOK'
BY <1>1 DEF F1, LineF1, AugF1
<1>2. ASSUME NEW p \in ProcSet,
F2(p)
PROVE TypeOK'
BY <1>2 DEF F2, LineF2, AugF2
<1>3. ASSUME NEW p \in ProcSet,
F3(p)
PROVE TypeOK'
BY <1>3 DEF F3, LineF3, AugF3
<1>4. ASSUME NEW p \in ProcSet,
F4(p)
PROVE TypeOK'
BY <1>4 DEF F4, LineF4, AugF4
<1>5. ASSUME NEW p \in ProcSet,
F5(p)
PROVE TypeOK'
BY <1>5 DEF F5, LineF5, AugF5
<1>6. ASSUME NEW p \in ProcSet,
F6(p)
PROVE TypeOK'
BY <1>6 DEF F6, LineF6, AugF6, InvocationLines
<1>7. ASSUME NEW p \in ProcSet,
U1(p)
PROVE TypeOK'
BY <1>7 DEF U1, LineU1, AugU1
<1>8. ASSUME NEW p \in ProcSet,
U2(p)
PROVE TypeOK'
BY <1>8 DEF U2, LineU2, AugU2
<1>9. ASSUME NEW p \in ProcSet,
U3(p)
PROVE TypeOK'
BY <1>9 DEF U3, LineU3, AugU3
<1>10. ASSUME NEW p \in ProcSet,
U4(p)
PROVE TypeOK'
BY <1>10 DEF U4, LineU4, AugU4
<1>11. ASSUME NEW p \in ProcSet,
U5(p)
PROVE TypeOK'
BY <1>11 DEF U5, LineU5, AugU5, InvocationLines
<1>12. ASSUME NEW p \in ProcSet,
U6(p)
PROVE TypeOK'
BY <1>12 DEF U6, LineU6, AugU6
<1>13. ASSUME NEW p \in ProcSet,
U7(p)
PROVE TypeOK'
BY <1>13 DEF U7, LineU7, AugU7
<1>14. ASSUME NEW p \in ProcSet,
U8(p)
PROVE TypeOK'
BY <1>14 DEF U8, LineU8, AugU8
<1>15. ASSUME NEW p \in ProcSet,
U9(p)
PROVE TypeOK'
BY <1>15 DEF U9, LineU9, AugU9
<1>16. ASSUME NEW p \in ProcSet,
U10(p)
PROVE TypeOK'
BY <1>16 DEF U10, LineU10, AugU10
<1>17. ASSUME NEW p \in ProcSet,
U11(p)
PROVE TypeOK'
BY <1>17 DEF U11, LineU11, AugU11, InvocationLines
<1>18. CASE UNCHANGED allvars
BY <1>18
<1>19. QED
BY <1>1, <1>2, <1>3, <1>4, <1>5, <1>6, <1>7, <1>8, <1>9,
<1>10, <1>11, <1>12, <1>13, <1>14, <1>15, <1>16, <1>17, <1>18 DEF Step, Next
THEOREM TypeSafety == Spec => []TypeOK
<1> SUFFICES ASSUME Spec
PROVE []TypeOK
OBVIOUS
<1> QED
BY PTL, InitTypeSafety, NextTypeSafety DEF Spec
\* REMAINING INVARIANTS
\* Non-line specific invariants
\* I_UF1 in the Appendix
ParPointsUp == \A z \in NodeSet: Par[z] >= z
\* I_UF2 in the Appendix
SigmaIsPartition1 == \A z \in NodeSet: \A t \in M:
z \in t.sigma[z]
\* I_UF3 in the Appendix
SigmaIsPartition2 == \A w, z \in NodeSet: \A t \in M:
(w \in t.sigma[z]) => (t.sigma[w] = t.sigma[z])
\* I_UF4 in the Appendix
SigmaIsCoarse == \A w,z \in NodeSet: \A t \in M:
(Par[w] = z) => (t.sigma[w] = t.sigma[z])
\* I_UF5 in the Appendix
SigmaIsFine == \A w,z \in NodeSet: \A t \in M:
(w # z /\ Par[w] = w /\ Par[z] = z) => (t.sigma[w] # t.sigma[z])
\* Lemmas regarding non-line specific invariants
\* Assumptions regarding model values
\* N is a strictly positive natural number
ASSUME NisNat == /\ N \in Nat
/\ N >= 1
\* ACK, NIL are distinct non-node values
ASSUME AckNilDef == /\ ACK \notin NodeSet
/\ NIL \notin NodeSet
/\ ACK # NIL
\* Mathematical fact needed for upcoming lemmas
LEMMA MaxIntegers ==
ASSUME NEW S \in SUBSET Int, S # {}, IsFiniteSet(S)
PROVE /\ Max(S) \in S
/\ \A Y \in S : Y <= Max(S)
<1>. DEFINE Pred(T) == T \in SUBSET Int /\ T # {} => \E X \in T : \A Y \in T : Y <= X
<1>1. Pred({})
OBVIOUS
<1>2. ASSUME NEW T, NEW X, Pred(T), X \notin T
PROVE Pred(T \cup {X})
<2>. HAVE T \cup {X} \in SUBSET Int
<2>1. CASE \A Y \in T : Y <= X
BY <2>1, Isa
<2>2. CASE \E Y \in T : ~(Y <= X)
<3> T # {}
BY <2>2
<3>1. PICK Y \in T : \A z \in T : z <= Y
BY <1>2
<3>2. X <= Y
BY <2>2, <3>1
<3> QED
BY <3>1, <3>2
<2> QED
BY <2>1, <2>2
<1> HIDE DEF Pred
<1>3. Pred(S)
BY <1>1, <1>2, FS_Induction, IsaM("blast")
<1> QED
BY <1>3, Zenon DEF Max, Pred
LEMMA MaxIsRoot == ASSUME TypeOK,
ParPointsUp,
SigmaIsPartition1,
SigmaIsPartition2,
SigmaIsCoarse,
SigmaIsFine,
NEW w \in NodeSet,
NEW t \in M,
(w = Par[w])
PROVE Max(t.sigma[w]) = Par[Max(t.sigma[w])]
<1> USE NisNat DEF TypeOK, ValidPar, ValidP, AtomConfigs, States, PowerSetNodes, NodeSet
<1>1. DEFINE z == Max(t.sigma[w])
<1>2. t.sigma[w] \in SUBSET NodeSet
OBVIOUS
<1>3. IsFiniteSet(t.sigma[w])
BY NisNat, <1>2, FS_Subset, FS_Interval
<1>4. t.sigma[w] # {}
BY DEF SigmaIsPartition1
<1>5. z \in t.sigma[w]
BY <1>3, <1>4, MaxIntegers
<1>6. Par[z] >= z
BY <1>5 DEF ParPointsUp
<1>7. t.sigma[w] = t.sigma[z]
BY <1>5 DEF SigmaIsPartition2
<1>8. Par[z] \in NodeSet
BY <1>5, <1>7 DEF SigmaIsCoarse, SigmaIsPartition1
<1>9. Par[z] \in t.sigma[z]
BY <1>5, <1>7 DEF SigmaIsPartition1, SigmaIsCoarse
<1>10. Par[z] = z
BY <1>6, <1>7, <1>8, <1>9 DEF Max, SigmaIsCoarse
<1> QED
BY <1>10
LEMMA UniqueRoot == ASSUME TypeOK,
SigmaIsPartition2,
SigmaIsFine,
NEW t \in M,
NEW w \in NodeSet,
NEW z \in NodeSet,
(w = Par[w] /\ z = Par[z] /\ z \in t.sigma[w])
PROVE w = z
<1> USE NisNat DEF TypeOK, ValidPar, ValidP, AtomConfigs, States, PowerSetNodes, NodeSet
<1> QED
BY DEF SigmaIsPartition2, SigmaIsFine
LEMMA RootIsMax == ASSUME TypeOK,
ParPointsUp,
SigmaIsPartition1,
SigmaIsPartition2,
SigmaIsCoarse,
SigmaIsFine,
NEW w \in NodeSet,
NEW t \in M,
(w = Par[w])
PROVE Max(t.sigma[w]) = w
<1> USE NisNat DEF TypeOK, ValidPar, ValidP, AtomConfigs, States, PowerSetNodes, NodeSet
<1>1. DEFINE z == Max(t.sigma[w])
<1>2. (w = Par[w] /\ Par[z] = z)
BY MaxIsRoot
<1>3. IsFiniteSet(t.sigma[w])
BY NisNat, <1>2, FS_Subset, FS_Interval
<1>4. t.sigma[w] # {}
BY DEF SigmaIsPartition1
<1>5. z \in t.sigma[w]
BY <1>3, <1>4, MaxIntegers
<1>6. (w = Par[w] /\ Par[z] = z /\ z \in t.sigma[w])
BY <1>2, <1>5
<1> QED
BY <1>6, UniqueRoot
\* Invariants for Find
\* I_{1, 7} in the paper, as it pertains to F1
InvF1 == \A p \in ProcSet : \A t \in M :
(pc[p] = "F1") => (t.f[p] = NIL)
\* I_2
InvF2 == \A p \in ProcSet : \A t \in M :
(pc[p] = "F2") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.f[p] = NIL)
\* I_3 as it pertains to atomic configurations
InvF3 == \A p \in ProcSet : \A t \in M :
(pc[p] = "F3") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[a[p]] = t.sigma[x[p]]
/\ t.f[p] = NIL)
\* I_{4, 5} as it pertains to atomic configurations and F4
InvF4 == \A p \in ProcSet : \A t \in M :
(pc[p] = "F4") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[a[p]] = t.sigma[x[p]]
/\ t.sigma[b[p]] = t.sigma[x[p]]
/\ t.f[p] = NIL)
\* I_{4, 5} as it pertains to atomic configurations and F5
InvF5 == \A p \in ProcSet : \A t \in M :
(pc[p] = "F5") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[a[p]] = t.sigma[x[p]]
/\ t.sigma[b[p]] = t.sigma[x[p]]
/\ t.f[p] = NIL)
\* I_6
InvF6 == \A p \in ProcSet : \A t \in M :
(pc[p] = "F6") => (t.f[p] = u[p])
\* I_3 and I_{4, 5} as it pertains to a, b and u
InvFEx == \A p \in ProcSet : /\ (pc[p] = "F3" => a[p] >= u[p])
/\ (pc[p] = "F4" => (b[p] >= a[p] /\ a[p] >= u[p]))
/\ (pc[p] = "F5" => (b[p] >= a[p] /\ a[p] >= u[p]))
\* Invariants for Unite
\* I_{1, 7} in the paper, as it pertains to U1
InvU1 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U1") => (t.f[p] = NIL)
\* I_{8, 9, 13} as it pertains to U2
InvU2 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U2") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[v[p]] = t.sigma[y[p]]
/\ t.f[p] = NIL)
\* I_{8, 9, 13} as it pertains to U3
InvU3 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U3") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[v[p]] = t.sigma[y[p]]
/\ t.f[p] = NIL)
\* I_10 as it pertains to atomic configurations
InvU4 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U4") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[a[p]] = t.sigma[x[p]]
/\ t.sigma[v[p]] = t.sigma[y[p]]
/\ t.f[p] = NIL)
\* I_{11, 12} as it pertains to atomic configurations and U5
InvU5 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U5") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[a[p]] = t.sigma[x[p]]
/\ t.sigma[b[p]] = t.sigma[x[p]]
/\ t.sigma[v[p]] = t.sigma[y[p]]
/\ t.f[p] = NIL)
\* I_{11, 12} as it pertains to atomic configurations and U6
InvU6 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U6") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[a[p]] = t.sigma[x[p]]
/\ t.sigma[b[p]] = t.sigma[x[p]]
/\ t.sigma[v[p]] = t.sigma[y[p]]
/\ t.f[p] = NIL)
\* I_{8, 9, 13} as it pertains to U7
InvU7 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U7") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[v[p]] = t.sigma[y[p]]
/\ t.f[p] = NIL)
\* I_14 as it pertains to atomic configurations
InvU8 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U8") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[v[p]] = t.sigma[y[p]]
/\ t.sigma[a[p]] = t.sigma[y[p]]
/\ t.f[p] = NIL)
\* I_{15, 16} as it pertains to atomic configurations and U9
InvU9 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U9") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[v[p]] = t.sigma[y[p]]
/\ t.sigma[a[p]] = t.sigma[y[p]]
/\ t.sigma[b[p]] = t.sigma[y[p]]
/\ t.f[p] = NIL)
\* I_{15, 16} as it pertains to atomic configurations and U10
InvU10 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U10") => (/\ t.sigma[u[p]] = t.sigma[x[p]]
/\ t.sigma[v[p]] = t.sigma[y[p]]
/\ t.sigma[a[p]] = t.sigma[y[p]]
/\ t.sigma[b[p]] = t.sigma[y[p]]
/\ t.f[p] = NIL)
\* I_17
InvU11 == \A p \in ProcSet : \A t \in M :
(pc[p] = "U11") => (t.f[p] = ACK)
\* I_10, I_{11, 12}, I_14, I_{15, 16}
InvUEx == \A p \in ProcSet : /\ (pc[p] = "U4" => a[p] >= u[p])
/\ (pc[p] = "U5" => (b[p] >= a[p] /\ a[p] >= u[p]))
/\ (pc[p] = "U6" => (b[p] >= a[p] /\ a[p] >= u[p]))
/\ (pc[p] = "U8" => a[p] >= v[p])
/\ (pc[p] = "U9" => (b[p] >= a[p] /\ a[p] >= v[p]))
/\ (pc[p] = "U10" => (b[p] >= a[p] /\ a[p] >= v[p]))
\* Linearizability
Linearizable == M # {}
\* Inductive invariant
I == /\ TypeOK
/\ ParPointsUp
/\ SigmaIsPartition1
/\ SigmaIsPartition2
/\ SigmaIsCoarse
/\ SigmaIsFine
/\ InvF1
/\ InvF2
/\ InvF3
/\ InvF4
/\ InvF5
/\ InvF6
/\ InvFEx
/\ InvU1
/\ InvU2
/\ InvU3
/\ InvU4
/\ InvU5
/\ InvU6
/\ InvU7
/\ InvU8
/\ InvU9
/\ InvU10
/\ InvU11
/\ InvUEx
/\ Linearizable
\* Proof of inductive invariant
\* Show that I holds in the initial state
LEMMA InitI == Init => I
<1> USE DEF Init, InitVars, InitAug
<1> SUFFICES ASSUME Init
PROVE I
OBVIOUS
<1>1. TypeOK
BY InitTypeSafety
<1>2. ParPointsUp
BY NisNat DEF ParPointsUp, NodeSet
<1>3. SigmaIsPartition1
BY DEF SigmaIsPartition1, sigmaInit
<1>4. SigmaIsPartition2
BY DEF SigmaIsPartition2, sigmaInit
<1>5. SigmaIsCoarse
BY DEF SigmaIsCoarse, sigmaInit
<1>6. SigmaIsFine
BY DEF SigmaIsFine, sigmaInit
<1>7. InvF1
BY DEF InvF1, fInit, InvocationLines, Lines
<1>8. InvF2
BY DEF InvF2, InvocationLines
<1>9. InvF3
BY DEF InvF3, InvocationLines
<1>10. InvF4
BY DEF InvF4, InvocationLines
<1>11. InvF5
BY DEF InvF5, InvocationLines
<1>12. InvF6
BY DEF InvF6, InvocationLines
<1>13. InvU1
BY DEF InvU1, fInit, InvocationLines, Lines
<1>14. InvU2
BY DEF InvU2, InvocationLines
<1>15. InvU3
BY DEF InvU3, InvocationLines
<1>16. InvU4
BY DEF InvU4, InvocationLines
<1>17. InvU5
BY DEF InvU5, InvocationLines
<1>18. InvU6
BY DEF InvU6, InvocationLines
<1>19. InvU7
BY DEF InvU7, InvocationLines
<1>20. InvU8
BY DEF InvU8, InvocationLines
<1>21. InvU9
BY DEF InvU9, InvocationLines
<1>22. InvU10
BY DEF InvU10, InvocationLines
<1>23. InvU11
BY DEF InvU11, InvocationLines
<1>24. Linearizable
BY DEF Linearizable, sigmaInit, fInit
<1>25. InvFEx
BY DEF InvFEx, InvocationLines, Lines
<1>26. InvUEx
BY DEF InvUEx, InvocationLines, Lines
<1> QED
BY <1>1, <1>10, <1>11, <1>12, <1>13, <1>14, <1>15, <1>16, <1>17, <1>18,
<1>19, <1>2, <1>20, <1>21, <1>22, <1>23, <1>24, <1>3, <1>4, <1>5,
<1>6, <1>7, <1>8, <1>9, <1>25, <1>26 DEF I
LEMMA NextI == I /\ [Next]_allvars => I'
<1> USE DEF I
<1> SUFFICES ASSUME I, [Next]_allvars
PROVE I'
OBVIOUS
<1>1. ASSUME NEW p \in ProcSet,
F1(p)
PROVE I'
<2> USE <1>1 DEF F1, LineF1, AugF1
<2>1. TypeOK'
BY NextTypeSafety
<2>2. ParPointsUp'
BY DEF ParPointsUp
<2>3. SigmaIsPartition1'
BY DEF SigmaIsPartition1
<2>4. SigmaIsPartition2'
BY DEF SigmaIsPartition2
<2>5. SigmaIsCoarse'
BY DEF SigmaIsCoarse
<2>6. SigmaIsFine'
BY DEF SigmaIsFine
<2>7. InvF1'
BY DEF InvF1
<2>8. InvF2'
BY DEF InvF1, InvF2, TypeOK, Validx, Validu
<2>9. InvF3'
BY DEF InvF3
<2>10. InvF4'
BY DEF InvF4
<2>11. InvF5'
BY DEF InvF5
<2>12. InvF6'
BY DEF InvF6
<2>13. InvU1'
BY DEF InvU1
<2>14. InvU2'
BY DEF InvU2
<2>15. InvU3'
BY DEF InvU3
<2>16. InvU4'
BY DEF InvU4
<2>17. InvU5'
BY DEF InvU5
<2>18. InvU6'
BY DEF InvU6
<2>19. InvU7'
BY DEF InvU7
<2>20. InvU8'
BY DEF InvU8
<2>21. InvU9'
BY DEF InvU9
<2>22. InvU10'
BY DEF InvU10
<2>23. InvU11'
BY DEF InvU11
<2>24. Linearizable'
BY DEF Linearizable
<2>25. InvFEx'
BY DEF InvFEx
<2>26. InvUEx'
BY DEF InvUEx
<2> QED
BY <2>1, <2>10, <2>11, <2>12, <2>13, <2>14, <2>15, <2>16,
<2>17, <2>18, <2>19, <2>2, <2>20, <2>21, <2>22, <2>23,
<2>24, <2>3, <2>4, <2>5, <2>6, <2>7, <2>8, <2>9, <2>25, <2>26 DEF I
<1>2. ASSUME NEW p \in ProcSet,
F2(p)
PROVE I'
<2> USE <1>2 DEF F2, LineF2, AugF2
<2>1. TypeOK'
BY NextTypeSafety
<2>2. ParPointsUp'
BY DEF ParPointsUp
<2>3. SigmaIsPartition1'
<3> USE DEF SigmaIsPartition1
<3> SUFFICES ASSUME NEW z \in NodeSet',
NEW t \in M'
PROVE (z \in t.sigma[z])'
OBVIOUS
<3>1. CASE Par[u[p]] = u[p]
<4>1. \E told \in M : /\ told.f[p] = NIL
/\ t.sigma = told.sigma
/\ t.f = [told.f EXCEPT ![p] = Max(told.sigma[x[p]])]
BY <3>1
<4> QED
BY <3>1, <4>1
<3>2. CASE Par[u[p]] # u[p]
BY <3>2
<3> QED
BY <3>1, <3>2
<2>4. SigmaIsPartition2'
<3> USE DEF SigmaIsPartition2
<3> SUFFICES ASSUME NEW w \in NodeSet', NEW z \in NodeSet',
NEW t \in M',
(w \in t.sigma[z])'
PROVE (t.sigma[w] = t.sigma[z])'
OBVIOUS
<3>1. CASE Par[u[p]] = u[p]
<4>1. \E told \in M : /\ told.f[p] = NIL
/\ t.sigma = told.sigma
/\ t.f = [told.f EXCEPT ![p] = Max(told.sigma[x[p]])]
BY <3>1
<4> QED
BY <3>1, <4>1
<3>2. CASE Par[u[p]] # u[p]
BY <3>2
<3> QED
BY <3>1, <3>2
<2>5. SigmaIsCoarse'
<3> USE DEF SigmaIsCoarse
<3> SUFFICES ASSUME NEW w \in NodeSet', NEW z \in NodeSet',
NEW t \in M',
(Par[w] = z)'
PROVE (t.sigma[w] = t.sigma[z])'
OBVIOUS
<3>1. CASE Par[u[p]] = u[p]
<4>1. \E told \in M : /\ told.f[p] = NIL
/\ t.sigma = told.sigma
/\ t.f = [told.f EXCEPT ![p] = Max(told.sigma[x[p]])]
BY <3>1
<4> QED
BY <3>1, <4>1
<3>2. CASE Par[u[p]] # u[p]
BY <3>2
<3> QED
BY <3>1, <3>2
<2>6. SigmaIsFine'
<3> USE DEF SigmaIsFine
<3> SUFFICES ASSUME NEW w \in NodeSet', NEW z \in NodeSet',
NEW t \in M',
(w # z /\ Par[w] = w /\ Par[z] = z)'
PROVE (t.sigma[w] # t.sigma[z])'
OBVIOUS
<3>1. CASE Par[u[p]] = u[p]
<4>1. \E told \in M : /\ told.f[p] = NIL