-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
4157 lines (3640 loc) · 492 KB
/
index.html
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link href="coqdoc.css" rel="stylesheet" type="text/css" />
<title>coq_hibou_label_equivalent_terms</title>
</head>
<body>
<div id="page">
<div id="header">
</div>
<div id="main">
<div class="code">
</div>
<div class="doc">
<a id="lab1"></a><h1 class="section">Coq Proof for the determination of equivalent interaction terms w.r.t. a denotational semantics</h1>
Erwan Mahe - 2021
<div class="paragraph"> </div>
We use Coq to:
<ul class="doclist">
<li> formally encode an Interaction Language for modelling the behavior of distributed systems
</li>
<li> define a formal semantics in denotational style on this language
</li>
<li> define an equivalence relation on interaction terms
</li>
<li> prove that equivalent interaction terms as defined by this relation have the same semantics
</li>
</ul>
<div class="paragraph"> </div>
This proof accompanies the manuscript of my thesis
<div class="paragraph"> </div>
The coq file itself is hosted on the following repository:
<ul class="doclist">
<li> <a href="https://github.com/erwanM974/coq_hibou_label_equivalent_terms">https://github.com/erwanM974/coq_hibou_label_equivalent_terms</a>
</li>
</ul>
<div class="paragraph"> </div>
<a id="lab2"></a><h2 class="section">Context</h2>
<div class="paragraph"> </div>
This formal semantics defines which are the behaviors that are specified by an interaction model
(akin to Message Sequence Charts or UML Sequence Diagrams).
Those behaviors are described by traces which are sequences of atomic actions that can be observed
on the interfaces of a distributed system's sub-systems.
Those atomic actions correspond to the occurence of communication events i.e. either the emission or the reception of
a given message on a given sub-system.
<div class="paragraph"> </div>
<a id="lab3"></a><h2 class="section">Dependencies</h2>
Below are listed the libraries required for this Coq proof.
<ul class="doclist">
<li> "Coq.Lists.List." provides utilities on lists. I use lists - among other things - to represent traces.
</li>
<li> "Coq.Vectors.Fin." provides a means to represent finite sets indexed by {1,...,n}.
</li>
<li> "Psatz." is required for using the "lia" tactic to solve simple arithemtic problems.
</li>
<li> "Coq.Program.Equality." is required for using the "dependent induction" tactic with "generalizing", allowing the generalisation of some variables of the problem in the induction hypothesis.
</li>
<li> "Coq.Init.Logic." for (among other things) the "not_eq_sym" theorem
</li>
<li> "Coq.Init.Nat.", "Coq.Arith.PeanoNat." and "Coq.Arith.Peano_dec." for the manipulation of natural integers and the use of some lemmas
</li>
</ul>
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Import</span> <span class="id" title="var">Coq.Lists.List</span>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="var">Coq.Vectors.Fin</span>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Import</span> <span class="id" title="var">Psatz</span>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Import</span> <span class="id" title="var">Coq.Program.Equality</span>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Import</span> <span class="id" title="var">Coq.Init.Logic</span>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Import</span> <span class="id" title="var">Coq.Init.Nat</span>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Import</span> <span class="id" title="var">Coq.Arith.PeanoNat</span>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Import</span> <span class="id" title="var">Coq.Arith.Peano_dec</span>.<br/>
<br/>
</div>
<div class="doc">
<a id="lab4"></a><h1 class="section">Preliminaries</h1>
<div class="paragraph"> </div>
This section is dedicated to enoncing some basic types and properties on which the remainder of the proof will be based.
<div class="paragraph"> </div>
<a id="lab5"></a><h2 class="section">Substitutions and eliminations of elements in lists</h2>
<div class="paragraph"> </div>
In the following, I define some functions to manipulate lists.
To do so, I use Fixpoints and as a result those functions are checked by Coq's termination checker.
<div class="paragraph"> </div>
<ul class="doclist">
<li> "list_replace_nth" replaces the "n-th" element of a list by another element
</li>
<li> "list_remove_nth" removes the "n-th" element of a list
</li>
</ul>
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">list_replace_nth</span> (<span class="id" title="var">A</span>:<span class="id" title="keyword">Type</span>) (<span class="id" title="var">n</span>:<span class="id" title="var">nat</span>) (<span class="id" title="var">l</span>:<span class="id" title="var">list</span> <span class="id" title="var">A</span>) (<span class="id" title="var">x</span>:<span class="id" title="var">A</span>) {<span class="id" title="keyword">struct</span> <span class="id" title="var">l</span>} : <span class="id" title="var">list</span> <span class="id" title="var">A</span> :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">n</span>, <span class="id" title="var">l</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">O</span>, <span class="id" title="var">e</span> :: <span class="id" title="var">l'</span> => <span class="id" title="var">x</span> :: <span class="id" title="var">l'</span><br/>
| <span class="id" title="var">O</span>, <span class="id" title="var">other</span> => <span class="id" title="var">nil</span><br/>
| <span class="id" title="var">S</span> <span class="id" title="var">m</span>, <span class="id" title="var">nil</span> => <span class="id" title="var">nil</span><br/>
| <span class="id" title="var">S</span> <span class="id" title="var">m</span>, <span class="id" title="var">e</span> :: <span class="id" title="var">l'</span> => <span class="id" title="var">e</span> :: (<span class="id" title="var">list_replace_nth</span> <span class="id" title="var">A</span> <span class="id" title="var">m</span> <span class="id" title="var">l'</span> <span class="id" title="var">x</span>)<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">list_remove_nth</span> (<span class="id" title="var">A</span>:<span class="id" title="keyword">Type</span>) (<span class="id" title="var">n</span>:<span class="id" title="var">nat</span>) (<span class="id" title="var">l</span>:<span class="id" title="var">list</span> <span class="id" title="var">A</span>) {<span class="id" title="keyword">struct</span> <span class="id" title="var">l</span>} : <span class="id" title="var">list</span> <span class="id" title="var">A</span> :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">n</span>, <span class="id" title="var">l</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">O</span>, <span class="id" title="var">e</span> :: <span class="id" title="var">l'</span> => <span class="id" title="var">l'</span><br/>
| <span class="id" title="var">O</span>, <span class="id" title="var">other</span> => <span class="id" title="var">nil</span><br/>
| <span class="id" title="var">S</span> <span class="id" title="var">m</span>, <span class="id" title="var">nil</span> => <span class="id" title="var">nil</span><br/>
| <span class="id" title="var">S</span> <span class="id" title="var">m</span>, <span class="id" title="var">e</span> :: <span class="id" title="var">l'</span> => <span class="id" title="var">e</span> :: (<span class="id" title="var">list_remove_nth</span> <span class="id" title="var">A</span> <span class="id" title="var">m</span> <span class="id" title="var">l'</span>)<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
<div class="paragraph"> </div>
<a id="lab6"></a><h2 class="section">Signature & Actions</h2>
<div class="paragraph"> </div>
The interaction language that I define depends on a signature that is composed of:
<ul class="doclist">
<li> a set of "lifelines" L, which elements represent the individual sub-systems that can be found in the disctributed system (or some groups of sub-systems via abstraction/refinement)
</li>
<li> a set of "messages" M, which elements represent the individual distinguishable messages that can be exchanged (via asynchronous communication) within (i.e. internally) or without (i.e externally) the distributed system
</li>
</ul>
<div class="paragraph"> </div>
Given that I consider finitely many such lifelines and messages, I use finite vectors from "Coq.Vectors.Fin."
to model those sets.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Parameter</span> <span class="id" title="var">LCard</span> : <span class="id" title="var">nat</span>.<br/>
<span class="id" title="keyword">Parameter</span> <span class="id" title="var">MCard</span> : <span class="id" title="var">nat</span>.<br/>
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">L</span> := <span class="id" title="var">Fin.t</span> (<span class="id" title="var">S</span> <span class="id" title="var">LCard</span>).<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">M</span> := <span class="id" title="var">Fin.t</span> (<span class="id" title="var">S</span> <span class="id" title="var">MCard</span>).<br/>
<br/>
</div>
<div class="doc">
To distinguish between emissions "a!m" and receptions "b?m" I encode the kind of action ({!,?}) with an inductive type "ActKind".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Inductive</span> <span class="id" title="var">ActKind</span> : <span class="id" title="keyword">Set</span> :=<br/>
|<span class="id" title="var">ak_snd</span>:<span class="id" title="var">ActKind</span><br/>
|<span class="id" title="var">ak_rcv</span>:<span class="id" title="var">ActKind</span>.<br/>
<br/>
</div>
<div class="doc">
I can now define actions with the "Action" type via a cartesian product of types L, ActKind and M.
<div class="paragraph"> </div>
A utility function "lifeline" returns, for any action, the lifeline on which it occurs.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">Action</span> :<span class="id" title="keyword">Set</span>:= <span class="id" title="var">L</span>*<span class="id" title="var">ActKind</span>*<span class="id" title="var">M</span>.<br/>
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">lifeline</span>: <span class="id" title="var">Action</span> -> <span class="id" title="var">L</span> :=<br/>
<span class="id" title="keyword">fun</span> '(<span class="id" title="var">_</span> <span class="id" title="keyword">as</span> <span class="id" title="var">l</span>,<span class="id" title="var">_</span>,<span class="id" title="var">_</span>) => <span class="id" title="var">l</span>.<br/>
<br/>
</div>
<div class="doc">
<a id="lab7"></a><h1 class="section">Trace Language (Semantic Domain)</h1>
<div class="paragraph"> </div>
This section is dedicated to the semantic domain of our interaction language i.e. the domain of definition of its semantics.
After defining this domain, I will study the properties of this domain,
notably how one can manipulate its elements through some operators and which are the properties of those operators.
<div class="paragraph"> </div>
As hinted at ealier, in this modelling framework:
<ul class="doclist">
<li> it is the expected behavior of distributed systems that is modelled
</li>
<li> this behavior is expressed in terms of accepted traces i.e. sequences of atomic actions that may be expressed
</li>
</ul>
<div class="paragraph"> </div>
The semantic domain is therefore the universe of traces.
<div class="paragraph"> </div>
The "Trace" type is formally defined below as that of lists of actions ("Action" type).
<div class="paragraph"> </div>
Functions "list_replace_nth" and "subs_remove" that were defined above to replace and remove elements in generic lists
are aliased and specialised for use in lists of traces as "subs_replace" and "subs_remove"
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">Trace</span> : <span class="id" title="keyword">Type</span> := <span class="id" title="var">list</span> <span class="id" title="var">Action</span>.<br/>
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">subs_replace</span> (<span class="id" title="var">n</span>:<span class="id" title="var">nat</span>) (<span class="id" title="var">subs</span>:<span class="id" title="var">list</span> <span class="id" title="var">Trace</span>) (<span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>) : <span class="id" title="var">list</span> <span class="id" title="var">Trace</span> <br/>
:= <span class="id" title="var">list_replace_nth</span> <span class="id" title="var">Trace</span> <span class="id" title="var">n</span> <span class="id" title="var">subs</span> <span class="id" title="var">t</span>.<br/>
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">subs_remove</span> (<span class="id" title="var">n</span>:<span class="id" title="var">nat</span>) (<span class="id" title="var">subs</span>:<span class="id" title="var">list</span> <span class="id" title="var">Trace</span>) : <span class="id" title="var">list</span> <span class="id" title="var">Trace</span> <br/>
:= <span class="id" title="var">list_remove_nth</span> <span class="id" title="var">Trace</span> <span class="id" title="var">n</span> <span class="id" title="var">subs</span>.<br/>
<br/>
</div>
<div class="doc">
<a id="lab8"></a><h2 class="section">Some consideration on the decidability of equalities</h2>
<div class="paragraph"> </div>
In the following I construct the decidability of the equality of traces in several steps:
<ul class="doclist">
<li> in "eq_or_not_eq_actkind" is proven the decidability of the equality for the "ActKind" type. It is immediate given the inductive nature of "ActKind"
</li>
<li> in "eq_or_not_eq_action" is proven the decidability of the equality for the "Action" type. It relies on that of its subtypes L, ActKind and M. We have proven the decidability property for ActKind juste before, and, for L and M, it is provided by the "eq_dec" Lemma from "Coq.Vectors.Fin.".
</li>
<li> finally, in "eq_or_not_eq_trace" it is proven for the "Trace" type
</li>
</ul>
<div class="paragraph"> </div>
This last proof relies on a custom induction principle defined and checked in the "double_trace_induction" Lemma.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">eq_or_not_eq_actkind</span> (<span class="id" title="var">x</span> <span class="id" title="var">y</span>:<span class="id" title="var">ActKind</span>) :<br/>
(<span class="id" title="var">x</span> = <span class="id" title="var">y</span>) \/ (<span class="id" title="var">x</span> <> <span class="id" title="var">y</span>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">induction</span> <span class="id" title="var">x</span>; <span class="id" title="tactic">induction</span> <span class="id" title="var">y</span>.<br/>
- <span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">discriminate</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">discriminate</span>.<br/>
- <span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">eq_or_not_eq_action</span> (<span class="id" title="var">x</span> <span class="id" title="var">y</span>:<span class="id" title="var">Action</span>) :<br/>
(<span class="id" title="var">x</span> = <span class="id" title="var">y</span>) \/ (<span class="id" title="var">x</span> <> <span class="id" title="var">y</span>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">x</span> ; <span class="id" title="tactic">destruct</span> <span class="id" title="var">y</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">p</span> ; <span class="id" title="tactic">destruct</span> <span class="id" title="var">p0</span>.<br/>
<span class="id" title="tactic">pose</span> <span class="id" title="var">proof</span> (<span class="id" title="var">Fin.eq_dec</span> <span class="id" title="var">m</span> <span class="id" title="var">m0</span>) <span class="id" title="keyword">as</span> <span class="id" title="var">Hm</span>.<br/>
<span class="id" title="tactic">pose</span> <span class="id" title="var">proof</span> (<span class="id" title="var">Fin.eq_dec</span> <span class="id" title="var">l</span> <span class="id" title="var">l0</span>) <span class="id" title="keyword">as</span> <span class="id" title="var">Hl</span>.<br/>
<span class="id" title="tactic">pose</span> <span class="id" title="var">proof</span> (<span class="id" title="var">eq_or_not_eq_actkind</span> <span class="id" title="var">a</span> <span class="id" title="var">a0</span>) <span class="id" title="keyword">as</span> <span class="id" title="var">Ha</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">Hm</span> ; <span class="id" title="tactic">destruct</span> <span class="id" title="var">Hl</span> ; <span class="id" title="tactic">destruct</span> <span class="id" title="var">Ha</span>.<br/>
- <span class="id" title="tactic">destruct</span> <span class="id" title="var">e</span> ; <span class="id" title="tactic">destruct</span> <span class="id" title="var">e0</span> ; <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">injection</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">intros</span>. <span class="id" title="var">contradiction</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">injection</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">intros</span>. <span class="id" title="var">contradiction</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">injection</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">intros</span>. <span class="id" title="var">contradiction</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">injection</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">intros</span>. <span class="id" title="var">contradiction</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">injection</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">intros</span>. <span class="id" title="var">contradiction</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">injection</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">intros</span>. <span class="id" title="var">contradiction</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">injection</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">intros</span>. <span class="id" title="var">contradiction</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">double_trace_induction</span> (<span class="id" title="var">P</span>: <span class="id" title="var">Trace</span> -> <span class="id" title="var">Trace</span> -> <span class="id" title="keyword">Prop</span>):<br/>
(<span class="id" title="var">P</span> <span class="id" title="var">nil</span> <span class="id" title="var">nil</span>)<br/>
-> (<span class="id" title="keyword">forall</span> <span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>, (<span class="id" title="var">t</span><><span class="id" title="var">nil</span>) -> ((<span class="id" title="var">P</span> <span class="id" title="var">t</span> <span class="id" title="var">nil</span>) /\ (<span class="id" title="var">P</span> <span class="id" title="var">nil</span> <span class="id" title="var">t</span>)) ) <br/>
-> (<span class="id" title="keyword">forall</span> (<span class="id" title="var">a1</span> <span class="id" title="var">a2</span>:<span class="id" title="var">Action</span>) (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span>:<span class="id" title="var">Trace</span>), <span class="id" title="var">P</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> -> <span class="id" title="var">P</span> (<span class="id" title="var">a1</span>::<span class="id" title="var">t1</span>) (<span class="id" title="var">a2</span>::<span class="id" title="var">t2</span>) ) -><br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span>:<span class="id" title="var">Trace</span>), <span class="id" title="var">P</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span>.<br/>
<span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">t1</span>.<br/>
- <span class="id" title="tactic">induction</span> <span class="id" title="var">t2</span>.<br/>
+ <span class="id" title="tactic">assumption</span>.<br/>
+ <span class="id" title="tactic">specialize</span> <span class="id" title="var">H0</span> <span class="id" title="keyword">with</span> (<span class="id" title="var">t</span>:=(<span class="id" title="var">a</span>::<span class="id" title="var">t2</span>)).<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">discriminate</span>.<br/>
- <span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">t2</span>.<br/>
+ <span class="id" title="tactic">specialize</span> <span class="id" title="var">H0</span> <span class="id" title="keyword">with</span> (<span class="id" title="var">t</span>:=(<span class="id" title="var">a</span>::<span class="id" title="var">t1</span>)).<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">discriminate</span>.<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">H1</span>. <span class="id" title="tactic">apply</span> <span class="id" title="var">IHt1</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">eq_or_not_eq_trace</span> (<span class="id" title="var">x</span> <span class="id" title="var">y</span>:<span class="id" title="var">Trace</span>) :<br/>
(<span class="id" title="var">x</span> = <span class="id" title="var">y</span>) \/ (<span class="id" title="var">x</span> <> <span class="id" title="var">y</span>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">pose</span> <span class="id" title="var">proof</span> <span class="id" title="var">double_trace_induction</span>.<br/>
<span class="id" title="tactic">specialize</span> <span class="id" title="var">H</span> <span class="id" title="keyword">with</span> (<span class="id" title="var">P</span>:= (<span class="id" title="keyword">fun</span> <span class="id" title="var">x</span> <span class="id" title="var">y</span>:<span class="id" title="var">Trace</span> => (<span class="id" title="var">x</span> = <span class="id" title="var">y</span>) \/ (<span class="id" title="var">x</span> <> <span class="id" title="var">y</span>))).<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">H</span>.<br/>
- <span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">intros</span>. <span class="id" title="tactic">split</span>.<br/>
+ <span class="id" title="tactic">right</span>. <span class="id" title="tactic">assumption</span>.<br/>
+ <span class="id" title="tactic">right</span>. <span class="id" title="tactic">apply</span> <span class="id" title="var">not_eq_sym</span>. <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">intros</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
+ <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">pose</span> <span class="id" title="var">proof</span> (<span class="id" title="var">eq_or_not_eq_action</span> <span class="id" title="var">a1</span> <span class="id" title="var">a2</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
* <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
* <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">inversion</span> <span class="id" title="var">H1</span>. <span class="id" title="var">contradiction</span>.<br/>
+ <span class="id" title="tactic">right</span>. <span class="id" title="tactic">intro</span>. <span class="id" title="tactic">inversion</span> <span class="id" title="var">H1</span>. <span class="id" title="var">contradiction</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
<a id="lab9"></a><h2 class="section">Some operators on traces and some of their algebraic properties</h2>
<div class="paragraph"> </div>
In the following let us focus on four operators on traces:
<ul class="doclist">
<li> the classical concatenation of lists "++" which is extended to traces:
<ul class="doclist">
<li> for any two traces t1 and t2, there is a single traces t such that t = t1 ++ t2
</li>
<li> this traces t is defined as the concatenation of t1 and t2 as a single contiguous list
</li>
</ul>
</li>
<li> an interleaving operator on traces
<ul class="doclist">
<li> for any two traces t1 and t2, there can exist may traces t such that (is_interleaving t1 t2 t)
</li>
<li> those traces correspond to potential interleavings of the actions from t1 and t2
</li>
<li> within such a t, one must find all the actions from t1 and all the actions from t2 in the order in which they are found in t1 and t2 respectively
</li>
<li> however actions from t1 can be put in any order w.r.t. the actions from t2
</li>
</ul>
</li>
<li> a weak sequencing operator on traces:
<ul class="doclist">
<li> for any two traces t1 and t2, there can exist may traces t such that (is_weak_seq t1 t2 t)
</li>
<li> weak sequencing allows some interleaving between the actions from t1 and t2
</li>
<li> however it is a more restrictive operator than interleaving given that it onlt allows some interleavings and not all
</li>
<li> the definition of what is allowed or not is reliant upon a conflict operator
</li>
<li> in a certain prefix of the trace t:
<ul class="doclist">
<li> actions from t1 can be added freely
</li>
<li> actions from t2 can only be added if they do not enter into conflict with the actions from t1 that are waiting to be added
</li>
</ul>
</li>
<li> the notion of conflict correspond to the fact, for two actions, to occur on the same lifeline
</li>
</ul>
</li>
<li> a special merge operator which merges an ordered list of traces into a single merged trace.
</li>
</ul>
I define this operator in such a way that is is configurable so as to act
as any of three different merge operators:
<ul class="doclist">
<li> the merging of traces using classical concatenation
</li>
<li> the merging of traces using the interleaving operator
</li>
<li> the merging of traces using the weak sequenceing operator
</li>
</ul>
<div class="paragraph"> </div>
In this section, those four operators will be defined (except for the concatenation which is already provided by Coq)
and some of their properties stated and proven.
<div class="paragraph"> </div>
<div class="paragraph"> </div>
<a id="lab10"></a><h3 class="section">Interleaving</h3>
<div class="paragraph"> </div>
I formalise the interleaving operator in Coq using an inductive predicate
"is_interleaving" such that
"(is_interleaving t1 t2 t)" states the membership of a given trace t
into the set of interleavings between traces t1 and t2.
<div class="paragraph"> </div>
This inductive predicate can be inferred inductively using four construction rules:
<ul class="doclist">
<li> "interleaving_nil_left" which states that for any trace t, t is an interleaving of the empty trace and t
</li>
<li> "interleaving_nil_right" which states that for any trace t, t is an interleaving of t and the empty trace
</li>
<li> "interleaving_cons_left" which states that for any interleaving t of traces t1 and t2, (a::t) is an interleaving of (a::t1) and t2
</li>
<li> "interleaving_cons_right" which states that for any interleaving t of traces t1 and t2, (a::t) is an interleaving of t1 and (a::t2)
</li>
</ul>
<div class="paragraph"> </div>
Those two last rules signify that, when constructing an interleaving, we can mix in actions from either traces in any order
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Inductive</span> <span class="id" title="var">is_interleaving</span> : <span class="id" title="var">Trace</span> -> <span class="id" title="var">Trace</span> -> <span class="id" title="var">Trace</span> -> <span class="id" title="keyword">Prop</span> :=<br/>
| <span class="id" title="var">interleaving_nil_left</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>), <br/>
(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">nil</span> <span class="id" title="var">t</span> <span class="id" title="var">t</span>)<br/>
| <span class="id" title="var">interleaving_nil_right</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>), <br/>
(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t</span> <span class="id" title="var">nil</span> <span class="id" title="var">t</span>)<br/>
| <span class="id" title="var">interleaving_cons_left</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">t</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span>:<span class="id" title="var">Trace</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>) -> (<span class="id" title="var">is_interleaving</span> (<span class="id" title="var">a</span>::<span class="id" title="var">t1</span>) <span class="id" title="var">t2</span> (<span class="id" title="var">a</span>::<span class="id" title="var">t</span>))<br/>
| <span class="id" title="var">interleaving_cons_right</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">t</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span>:<span class="id" title="var">Trace</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>) -> (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> (<span class="id" title="var">a</span>::<span class="id" title="var">t2</span>) (<span class="id" title="var">a</span>::<span class="id" title="var">t</span>)).<br/>
<br/>
</div>
<div class="doc">
Interesting properties of the "is_interleaving" that will be useful later on include:
<ul class="doclist">
<li> the guarantee of the existence of an interleaving t (at least one) for any traces t1 and t2 "is_interleaving_existence"
</li>
<li> "is_interleaving_nil_prop1", which states that if the empty trace is an interleaving of t1 and t2, then both t1 and t2 must be empty
</li>
<li> "is_interleaving_nil_prop2", which states that if t is an interleaving of the empty trace and t2, then t=t2
</li>
<li> "is_interleaving_nil_prop3", which states that if t is an interleaving of t1 and the empty trace, then t=t1
</li>
<li> "is_interleaving_split", which states that if a trace of the form (a::t) is an interleaving of traces t1 and t2 then the head action "a" can be found in:
<ul class="doclist">
<li> either t1, which implies the existence of trace t3 such that t1=a::t3 and (is_interleaving t3 t2 t)
</li>
<li> or t2, which implies the existence of trace t3 such that t2=a::t3 and (is_interleaving t1 t3 t)
</li>
</ul>
</li>
</ul>
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_interleaving_existence</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span>:<span class="id" title="var">Trace</span>) :<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>, <span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">t1</span>.<br/>
- <span class="id" title="tactic">exists</span> <span class="id" title="var">t2</span>. <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_left</span>.<br/>
- <span class="id" title="tactic">specialize</span> <span class="id" title="var">IHt1</span> <span class="id" title="keyword">with</span> (<span class="id" title="var">t2</span>:=<span class="id" title="var">t2</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">IHt1</span>.<br/>
<span class="id" title="tactic">exists</span> (<span class="id" title="var">a</span>::<span class="id" title="var">x</span>).<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_left</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_interleaving_nil_prop1</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span>: <span class="id" title="var">Trace</span>) :<br/>
(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">nil</span>)<br/>
-> ( (<span class="id" title="var">t1</span> = <span class="id" title="var">nil</span>) /\ (<span class="id" title="var">t2</span> = <span class="id" title="var">nil</span>) ).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">inversion</span> <span class="id" title="var">H</span> ; <span class="id" title="tactic">split</span> ; <span class="id" title="tactic">reflexivity</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_interleaving_nil_prop2</span> (<span class="id" title="var">t</span> <span class="id" title="var">t2</span>: <span class="id" title="var">Trace</span>) :<br/>
(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">nil</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>)<br/>
-> (<span class="id" title="var">t2</span> = <span class="id" title="var">t</span>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">H</span>.<br/>
- <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">assert</span> (<span class="id" title="var">t2</span>=<span class="id" title="var">t</span>).<br/>
{ <span class="id" title="tactic">apply</span> <span class="id" title="var">IHis_interleaving</span>.<br/>
<span class="id" title="tactic">trivial</span>.<br/>
}<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">reflexivity</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_interleaving_nil_prop3</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t</span>: <span class="id" title="var">Trace</span>) :<br/>
(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">nil</span> <span class="id" title="var">t</span>)<br/>
-> (<span class="id" title="var">t1</span> = <span class="id" title="var">t</span>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">H</span>.<br/>
- <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">assert</span> (<span class="id" title="var">t1</span>=<span class="id" title="var">t</span>).<br/>
{ <span class="id" title="tactic">apply</span> <span class="id" title="var">IHis_interleaving</span>.<br/>
<span class="id" title="tactic">trivial</span>.<br/>
}<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">reflexivity</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_interleaving_split</span> (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>) (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>) :<br/>
(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> (<span class="id" title="var">a</span> :: <span class="id" title="var">t</span>))<br/>
-> (<br/>
(<span class="id" title="tactic">exists</span> <span class="id" title="var">t3</span>:<span class="id" title="var">Trace</span>, (<span class="id" title="var">t2</span>=<span class="id" title="var">a</span>::<span class="id" title="var">t3</span>)/\(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t3</span> <span class="id" title="var">t</span>))<br/>
\/ (<span class="id" title="tactic">exists</span> <span class="id" title="var">t3</span>:<span class="id" title="var">Trace</span>, (<span class="id" title="var">t1</span>=<span class="id" title="var">a</span>::<span class="id" title="var">t3</span>)/\(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t3</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>))<br/>
).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span>.<br/>
<span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">H</span>.<br/>
- <span class="id" title="tactic">left</span>. <span class="id" title="tactic">exists</span> <span class="id" title="var">t</span>. <span class="id" title="tactic">split</span>.<br/>
+ <span class="id" title="tactic">reflexivity</span>.<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_left</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">exists</span> <span class="id" title="var">t</span>. <span class="id" title="tactic">split</span>.<br/>
+ <span class="id" title="tactic">reflexivity</span>.<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_right</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">exists</span> <span class="id" title="var">t1</span>. <span class="id" title="tactic">split</span>.<br/>
+ <span class="id" title="tactic">reflexivity</span>.<br/>
+ <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">left</span>. <span class="id" title="tactic">exists</span> <span class="id" title="var">t2</span>. <span class="id" title="tactic">split</span>.<br/>
+ <span class="id" title="tactic">reflexivity</span>.<br/>
+ <span class="id" title="tactic">assumption</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
Other interesting properties of the "is_interleaving" include:
<ul class="doclist">
<li> "is_interleaving_symmetry", which states that the operator is symmetric i.e. if t is an interleaving of t1 and t2 then it is also an interleaving of t2 and t1
</li>
<li> "is_interleaving_left_associativity", which states that if t is an interleaving of t1 and t2 and if t1 can be decomposed as an interleaving of t1A and t1B then t is an interleaving of t1A with a certain tm that is an interleaving of t1B and t2
</li>
<li> "is_interleaving_right_associativity", which states that if t is an interleaving of t1 and t2 and if t2 can be decomposed as an interleaving of t2A and t2B then t is an interleaving of a certain tm with t2B, with that certain tm an interleaving of t1 and t2A
</li>
</ul>
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_interleaving_symmetry</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>) :<br/>
(<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>) <-> (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t2</span> <span class="id" title="var">t1</span> <span class="id" title="var">t</span>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">split</span> ; <span class="id" title="tactic">intros</span>.<br/>
- <span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">t</span> <span class="id" title="var">generalizing</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span>.<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_nil_prop1</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_left</span>.<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_split</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
* <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">t3</span>,<span class="id" title="var">H</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_left</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">IHt</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
* <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">t3</span>,<span class="id" title="var">H</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_right</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">IHt</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">t</span> <span class="id" title="var">generalizing</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span>.<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_nil_prop1</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_left</span>.<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_split</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
* <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">t3</span>,<span class="id" title="var">H</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_left</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">IHt</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
* <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">t3</span>,<span class="id" title="var">H</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_right</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">IHt</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_interleaving_left_associativity</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t1A</span> <span class="id" title="var">t1B</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>) :<br/>
( (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1A</span> <span class="id" title="var">t1B</span> <span class="id" title="var">t1</span>) /\ (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>) )<br/>
-> (<span class="id" title="tactic">exists</span> <span class="id" title="var">tm</span>:<span class="id" title="var">Trace</span>, (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1B</span> <span class="id" title="var">t2</span> <span class="id" title="var">tm</span>) /\ (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1A</span> <span class="id" title="var">tm</span> <span class="id" title="var">t</span>) ).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">t</span> <span class="id" title="var">generalizing</span> <span class="id" title="var">t1</span> <span class="id" title="var">t1A</span> <span class="id" title="var">t1B</span> <span class="id" title="var">t2</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_nil_prop1</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H1</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_nil_prop1</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">nil</span>.<br/>
<span class="id" title="tactic">split</span> ; <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_left</span>.<br/>
- <span class="id" title="tactic">inversion</span> <span class="id" title="var">H0</span>.<br/>
+ <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H2</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H3</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H3</span>.<br/>
<span class="id" title="tactic">clear</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_nil_prop1</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">exists</span> (<span class="id" title="var">a</span>::<span class="id" title="var">t</span>).<br/>
<span class="id" title="tactic">split</span> ; <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_left</span>.<br/>
+ <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H1</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H3</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H3</span>.<br/>
<span class="id" title="tactic">clear</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">t1B</span>.<br/>
<span class="id" title="tactic">split</span>.<br/>
* <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_right</span>.<br/>
* <span class="id" title="tactic">assumption</span>.<br/>
+ <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H3</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H3</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H1</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H5</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H5</span>.<br/>
<span class="id" title="tactic">clear</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">inversion</span> <span class="id" title="var">H</span>.<br/>
{ <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H2</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">clear</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">exists</span> (<span class="id" title="var">a</span>::<span class="id" title="var">t</span>).<br/>
<span class="id" title="tactic">split</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_left</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_left</span>.<br/>
}<br/>
{ <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H2</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">clear</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">t2</span>.<br/>
<span class="id" title="tactic">split</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_nil_left</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_left</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
}<br/>
{ <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H2</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H5</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H5</span>.<br/>
<span class="id" title="tactic">specialize</span> <span class="id" title="var">IHt</span> <span class="id" title="keyword">with</span> (<span class="id" title="var">t1</span>:=<span class="id" title="var">t3</span>) (<span class="id" title="var">t1A</span>:=<span class="id" title="var">t1</span>) (<span class="id" title="var">t1B</span>:=<span class="id" title="var">t1B</span>) (<span class="id" title="var">t2</span>:=<span class="id" title="var">t2</span>).<br/>
<span class="id" title="tactic">assert</span> (<span class="id" title="tactic">exists</span> <span class="id" title="var">tm</span> : <span class="id" title="var">Trace</span>, <span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1B</span> <span class="id" title="var">t2</span> <span class="id" title="var">tm</span> /\ <span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">tm</span> <span class="id" title="var">t</span>).<br/>
{ <span class="id" title="tactic">apply</span> <span class="id" title="var">IHt</span> ; <span class="id" title="tactic">assumption</span>. }<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">tm</span>,<span class="id" title="var">H0</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">tm</span>.<br/>
<span class="id" title="tactic">split</span>.<br/>
- <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_left</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
}<br/>
{ <span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H1</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H5</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">specialize</span> <span class="id" title="var">IHt</span> <span class="id" title="keyword">with</span> (<span class="id" title="var">t1</span>:=<span class="id" title="var">t0</span>) (<span class="id" title="var">t1A</span>:=<span class="id" title="var">t1A</span>) (<span class="id" title="var">t1B</span>:=<span class="id" title="var">t4</span>) (<span class="id" title="var">t2</span>:=<span class="id" title="var">t2</span>).<br/>
<span class="id" title="tactic">assert</span> (<span class="id" title="tactic">exists</span> <span class="id" title="var">tm</span> : <span class="id" title="var">Trace</span>, <span class="id" title="var">is_interleaving</span> <span class="id" title="var">t4</span> <span class="id" title="var">t2</span> <span class="id" title="var">tm</span> /\ <span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1A</span> <span class="id" title="var">tm</span> <span class="id" title="var">t</span>).<br/>
{ <span class="id" title="tactic">apply</span> <span class="id" title="var">IHt</span> ; <span class="id" title="tactic">assumption</span>. }<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">tm</span>,<span class="id" title="var">H0</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">exists</span> (<span class="id" title="var">a</span>::<span class="id" title="var">tm</span>).<br/>
<span class="id" title="tactic">split</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_left</span>. <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_right</span>. <span class="id" title="tactic">assumption</span>.<br/>
}<br/>
+ <span class="id" title="tactic">destruct</span> <span class="id" title="var">H3</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H1</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H2</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H5</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H5</span>.<br/>
<span class="id" title="tactic">clear</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">specialize</span> <span class="id" title="var">IHt</span> <span class="id" title="keyword">with</span> (<span class="id" title="var">t1</span>:=<span class="id" title="var">t1</span>) (<span class="id" title="var">t1A</span>:=<span class="id" title="var">t1A</span>) (<span class="id" title="var">t1B</span>:=<span class="id" title="var">t1B</span>) (<span class="id" title="var">t2</span>:=<span class="id" title="var">t4</span>).<br/>
<span class="id" title="tactic">assert</span> (<span class="id" title="tactic">exists</span> <span class="id" title="var">tm</span> : <span class="id" title="var">Trace</span>, <span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1B</span> <span class="id" title="var">t4</span> <span class="id" title="var">tm</span> /\ <span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1A</span> <span class="id" title="var">tm</span> <span class="id" title="var">t</span>).<br/>
{ <span class="id" title="tactic">apply</span> <span class="id" title="var">IHt</span> ; <span class="id" title="tactic">assumption</span>. }<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">tm</span>,<span class="id" title="var">H0</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">exists</span> (<span class="id" title="var">a</span>::<span class="id" title="var">tm</span>).<br/>
<span class="id" title="tactic">split</span>.<br/>
{ <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_right</span>.<br/>
<span class="id" title="tactic">assumption</span>. }<br/>
{ <span class="id" title="tactic">apply</span> <span class="id" title="var">interleaving_cons_right</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
}<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_interleaving_right_associativity</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t2A</span> <span class="id" title="var">t2B</span> <span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>) :<br/>
( (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t2A</span> <span class="id" title="var">t2B</span> <span class="id" title="var">t2</span>) /\ (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>) )<br/>
-> (<span class="id" title="tactic">exists</span> <span class="id" title="var">tm</span>:<span class="id" title="var">Trace</span>, (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2A</span> <span class="id" title="var">tm</span>) /\ (<span class="id" title="var">is_interleaving</span> <span class="id" title="var">tm</span> <span class="id" title="var">t2B</span> <span class="id" title="var">t</span>) ).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H0</span>.<br/>
<span class="id" title="tactic">assert</span> (<span class="id" title="tactic">exists</span> <span class="id" title="var">tm</span> : <span class="id" title="var">Trace</span>, <span class="id" title="var">is_interleaving</span> <span class="id" title="var">t2A</span> <span class="id" title="var">t1</span> <span class="id" title="var">tm</span> /\ <span class="id" title="var">is_interleaving</span> <span class="id" title="var">t2B</span> <span class="id" title="var">tm</span> <span class="id" title="var">t</span>).<br/>
{ <span class="id" title="tactic">apply</span> (<span class="id" title="var">is_interleaving_left_associativity</span> <span class="id" title="var">t2</span> <span class="id" title="var">t2B</span> <span class="id" title="var">t2A</span> <span class="id" title="var">t1</span> <span class="id" title="var">t</span>).<br/>
<span class="id" title="tactic">split</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_symmetry</span>. <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">assumption</span>.<br/>
}<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">tm</span>,<span class="id" title="var">H1</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>.<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">tm</span>.<br/>
<span class="id" title="tactic">split</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_symmetry</span>. <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">is_interleaving_symmetry</span>. <span class="id" title="tactic">assumption</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
<a id="lab11"></a><h3 class="section">Weak Sequencing</h3>
<div class="paragraph"> </div>
As explained earlier, the weak sequencing operator on traces relies upon a notion of "conflict" between actions.
To encode it in code, I define the "no_conflict" inductive predicate such that (no_conflict t a)
states that there are not actions in t that occur on the same lifeline as action "a".
<div class="paragraph"> </div>
This predicate can be inferred inductively from the following two rules:
<ul class="doclist">
<li> "no_conflict_nil", which states that for any action "a", there can be no conflict between "a" and the empty trace
</li>
<li> "no_conflict_cons", which states that for any action "a" and trace (a'::t) which starts with action "a'" as its head, if "a" and "a'" occur on different lifelines and there is no conflict between "a" and "t" then there is no conflict between "a" and (a'::t)
</li>
</ul>
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Inductive</span> <span class="id" title="var">no_conflict</span> : <span class="id" title="var">Trace</span> -> <span class="id" title="var">Action</span> -> <span class="id" title="keyword">Prop</span> :=<br/>
| <span class="id" title="var">no_conflict_nil</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>), (<span class="id" title="var">no_conflict</span> <span class="id" title="var">nil</span> <span class="id" title="var">a</span>)<br/>
| <span class="id" title="var">no_conflict_cons</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">a</span> <span class="id" title="var">a'</span>:<span class="id" title="var">Action</span>) (<span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>),<br/>
(<br/>
(<span class="id" title="var">not</span> ((<span class="id" title="var">lifeline</span> <span class="id" title="var">a</span>) = (<span class="id" title="var">lifeline</span> <span class="id" title="var">a'</span>)))<br/>
/\ (<span class="id" title="var">no_conflict</span> <span class="id" title="var">t</span> <span class="id" title="var">a</span>)<br/>
) -> (<span class="id" title="var">no_conflict</span> (<span class="id" title="var">a'</span>::<span class="id" title="var">t</span>) <span class="id" title="var">a</span>).<br/>
<br/>
</div>
<div class="doc">
As for the interleaving, I formalise the weak sequencing operator in Coq using an inductive predicate
"is_weak_seq" such that
"(is_weak_seq t1 t2 t)" states the membership of a given trace t
into the set of weakly sequenced traces between traces t1 and t2.
<div class="paragraph"> </div>
This inductive predicate can be inferred inductively using four construction rules:
<ul class="doclist">
<li> "weak_seq_nil_left" which states that for any trace t, t is a weak sequence of the empty trace and t
</li>
<li> "weak_seq_nil_right" which states that for any trace t, t is a weak sequence of t and the empty trace
</li>
<li> "weak_seq_cons_left" which states that for any weak sequence t of traces t1 and t2, (a::t) is a weak sequence of (a::t1) and t2
</li>
<li> "weak_seq_cons_right" which states that for any weak sequence t of traces t1 and t2, if there is no conflict between "a" and t1 then (a::t) is a weak sequence of t1 and (a::t2)
</li>
</ul>
<div class="paragraph"> </div>
Those two last rules signify that, when constructing a weak sequence:
<ul class="doclist">
<li> we can freely add actions from the left-hand side trace t1
</li>
<li> but we only allow the addition of events from t2 if they are not preempted by the occurence of events from t1
</li>
</ul>
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Inductive</span> <span class="id" title="var">is_weak_seq</span> : <span class="id" title="var">Trace</span> -> <span class="id" title="var">Trace</span> -> <span class="id" title="var">Trace</span> -> <span class="id" title="keyword">Prop</span> :=<br/>
| <span class="id" title="var">weak_seq_nil_left</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>), <br/>
(<span class="id" title="var">is_weak_seq</span> <span class="id" title="var">nil</span> <span class="id" title="var">t</span> <span class="id" title="var">t</span>)<br/>
| <span class="id" title="var">weak_seq_nil_right</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>), <br/>
(<span class="id" title="var">is_weak_seq</span> <span class="id" title="var">t</span> <span class="id" title="var">nil</span> <span class="id" title="var">t</span>)<br/>
| <span class="id" title="var">weak_seq_cons_left</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">t</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span>:<span class="id" title="var">Trace</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
(<span class="id" title="var">is_weak_seq</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>) -> (<span class="id" title="var">is_weak_seq</span> (<span class="id" title="var">a</span>::<span class="id" title="var">t1</span>) <span class="id" title="var">t2</span> (<span class="id" title="var">a</span>::<span class="id" title="var">t</span>))<br/>
| <span class="id" title="var">weak_seq_cons_right</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">t</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span>:<span class="id" title="var">Trace</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
(<span class="id" title="var">is_weak_seq</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>)<br/>
-> (<span class="id" title="var">no_conflict</span> <span class="id" title="var">t1</span> <span class="id" title="var">a</span>) <br/>
-> (<span class="id" title="var">is_weak_seq</span> <span class="id" title="var">t1</span> (<span class="id" title="var">a</span>::<span class="id" title="var">t2</span>) (<span class="id" title="var">a</span>::<span class="id" title="var">t</span>)).<br/>
<br/>
</div>
<div class="doc">
In a similar fashion to what I did for the interleaving operator, I state and prove in the following some properties on the weak sequencing operator:
<ul class="doclist">
<li> the guarantee of the existence of a weak sequence t (at least one) for any traces t1 and t2 "is_weak_seq_existence"
</li>
<li> "is_weak_seq_nil_prop1", which states that if the empty trace is a weak sequence of t1 and t2, then both t1 and t2 must be empty
</li>
<li> "is_weak_seq_nil_prop2", which states that if t is a weak sequence of the empty trace and t2, then t=t2
</li>
<li> "is_weak_seq_nil_prop3", which states that if t is a weak sequence of t1 and the empty trace, then t=t1
</li>
<li> "is_weak_seq_split", which states that if (a :: t) is a weak sequence of t1 and t2, then either t1 starts with "a" or t2 starts with "a" and there is no conflict between t1 and "a"
</li>
</ul>
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_weak_seq_existence</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span>:<span class="id" title="var">Trace</span>) :<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>, <span class="id" title="var">is_weak_seq</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">t</span>.<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">t1</span>.<br/>
- <span class="id" title="tactic">exists</span> <span class="id" title="var">t2</span>. <span class="id" title="tactic">apply</span> <span class="id" title="var">weak_seq_nil_left</span>.<br/>
- <span class="id" title="tactic">specialize</span> <span class="id" title="var">IHt1</span> <span class="id" title="keyword">with</span> (<span class="id" title="var">t2</span>:=<span class="id" title="var">t2</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">IHt1</span>.<br/>
<span class="id" title="tactic">exists</span> (<span class="id" title="var">a</span>::<span class="id" title="var">x</span>).<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">weak_seq_cons_left</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_weak_seq_nil_prop1</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span>: <span class="id" title="var">Trace</span>) :<br/>
(<span class="id" title="var">is_weak_seq</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span> <span class="id" title="var">nil</span>)<br/>
-> ( (<span class="id" title="var">t1</span> = <span class="id" title="var">nil</span>) /\ (<span class="id" title="var">t2</span> = <span class="id" title="var">nil</span>) ).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">inversion</span> <span class="id" title="var">H</span> ; <span class="id" title="tactic">split</span> ; <span class="id" title="tactic">reflexivity</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">is_weak_seq_nil_prop2</span> (<span class="id" title="var">t1</span> <span class="id" title="var">t2</span>: <span class="id" title="var">Trace</span>) :<br/>
(<span class="id" title="var">is_weak_seq</span> <span class="id" title="var">nil</span> <span class="id" title="var">t1</span> <span class="id" title="var">t2</span>)<br/>
-> (<span class="id" title="var">t1</span> = <span class="id" title="var">t2</span>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">assert</span> (<span class="id" title="var">H0</span>:=<span class="id" title="var">H</span>).<br/>
<span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">H</span>.<br/>
- <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">assert</span> (<span class="id" title="var">t2</span>=<span class="id" title="var">t</span>).<br/>
{ <span class="id" title="tactic">apply</span> <span class="id" title="var">IHis_weak_seq</span>.<br/>
- <span class="id" title="tactic">trivial</span>.<br/>
- <span class="id" title="tactic">assumption</span>.<br/>
}<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">reflexivity</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>