-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
1982 lines (1683 loc) · 252 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_multi_trace_analysis</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">A small-step approach to multitrace checking against interactions</h1>
Erwan Mahe - 2020
<div class="paragraph"> </div>
We use Coq to prove the correctness of an oracle algorithm with regards to a formal semantics.
<div class="paragraph"> </div>
This proof accompanies the publication of a paper, currently available on Arxiv:
<ul class="doclist">
<li> <a href="https://arxiv.org/abs/2009.01777">https://arxiv.org/abs/2009.01777</a>
</li>
</ul>
<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_multi_trace_analysis">https://github.com/erwanM974/coq_hibou_label_multi_trace_analysis</a>
</li>
</ul>
<div class="paragraph"> </div>
A prototype tool, which implements and extends upon
the multi-trace analysis algorithm presented here is available on the following repository:
<ul class="doclist">
<li> <a href="https://github.com/erwanM974/hibou_label">https://github.com/erwanM974/hibou_label</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.
In the absence of a global clock, the observations of those atomic actions cannot be ordered globally. As such we rather have multi-traces i.e. sets of traces, each describing the behavior of a given sub-system.
<div class="paragraph"> </div>
We define the semantics of interactions in terms of traces and of multi-traces.
<div class="paragraph"> </div>
We then introduce an algorithm to solve the membership problem for multi-traces i.e. able to determine whether or not a given multi-trace belongs to the semantics of a given interaction.
<div class="paragraph"> </div>
<a id="lab3"></a><h2 class="section">Dependencies</h2>
Below are listed the libraries required for this Coq proof.
<div class="paragraph"> </div>
<ul class="doclist">
<li> "List" provides utilities on lists. We 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> "Coq.Vectors.VectorDef." provides a Type used to represent lists of fixed size (vectors). We use vectors to define multitraces as fixed sized lists of traces.
</li>
<li> "Coq.Bool.Bool." is used to handle booleans.
</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>
</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">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="var">Coq.Vectors.VectorDef</span>.<br/>
<span class="id" title="keyword">Require</span> <span class="id" title="keyword">Import</span> <span class="id" title="var">Coq.Bool.Bool</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/>
<br/>
</div>
<div class="doc">
<div class="paragraph"> </div>
<a id="lab4"></a><h1 class="section">Preliminaries</h1>
In the following, we introduce some basic types and functions that will allow us to manipulate concepts in the domain of the observation of distributed system executions.
<a id="lab5"></a><h2 class="section">Signature & Actions</h2>
The set of lifelines L is defined as a finite set of (any integer) cardinal Lcard indexed by
{1,...,LCard} using the Vectors.Fin library.
</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">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/>
<br/>
</div>
<div class="doc">
The set M of messages is defined in the same manner.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Parameter</span> <span class="id" title="var">MCard</span> : <span class="id" title="var">nat</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" we 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">
Below is defined the equality relation for the type "ActKind".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">eq_actkind</span> (<span class="id" title="var">ak1</span> : <span class="id" title="var">ActKind</span>) (<span class="id" title="var">ak2</span> : <span class="id" title="var">ActKind</span>) : <span class="id" title="var">bool</span> := <br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">ak1</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">ak_snd</span> => <br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">ak2</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">ak_snd</span> => <span class="id" title="var">true</span><br/>
| <span class="id" title="var">ak_rcv</span> => <span class="id" title="var">false</span><br/>
<span class="id" title="keyword">end</span><br/>
| <span class="id" title="var">ak_rcv</span> =><br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">ak2</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">ak_snd</span> => <span class="id" title="var">false</span><br/>
| <span class="id" title="var">ak_rcv</span> => <span class="id" title="var">true</span><br/>
<span class="id" title="keyword">end</span><br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
We can now define actions with the "Action" type. Below are also define the equality relation on this type and a utility function "lifeline" returning, 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">eq_action</span> (<span class="id" title="var">action1</span> : <span class="id" title="var">Action</span>) (<span class="id" title="var">action2</span> : <span class="id" title="var">Action</span>) : <span class="id" title="var">bool</span> :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">action1</span> <span class="id" title="keyword">with</span><br/>
| (<span class="id" title="var">_</span> <span class="id" title="keyword">as</span> <span class="id" title="var">l1</span>, <span class="id" title="var">_</span> <span class="id" title="keyword">as</span> <span class="id" title="var">ak1</span>, <span class="id" title="var">_</span> <span class="id" title="keyword">as</span> <span class="id" title="var">m1</span>) => <br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">action2</span> <span class="id" title="keyword">with</span><br/>
| (<span class="id" title="var">_</span> <span class="id" title="keyword">as</span> <span class="id" title="var">l2</span>, <span class="id" title="var">_</span> <span class="id" title="keyword">as</span> <span class="id" title="var">ak2</span>, <span class="id" title="var">_</span> <span class="id" title="keyword">as</span> <span class="id" title="var">m2</span>) => <br/>
<span class="id" title="var">andb</span> (<span class="id" title="var">Fin.eqb</span> <span class="id" title="var">l1</span> <span class="id" title="var">l2</span>) <br/>
(<span class="id" title="var">andb</span> (<span class="id" title="var">eq_actkind</span> <span class="id" title="var">ak1</span> <span class="id" title="var">ak2</span>) (<span class="id" title="var">Fin.eqb</span> <span class="id" title="var">m1</span> <span class="id" title="var">m2</span>) )<br/>
<span class="id" title="keyword">end</span><br/>
<span class="id" title="keyword">end</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="lab6"></a><h2 class="section">Trace & Multi-Trace Language</h2>
The "Trace" type can then be defined as that of lists of actions ("Action" type).
</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/>
</div>
<div class="doc">
The "MultiTrace" type is then defined as the type of vectors of traces ("Trace" type) of fixed size "LCard" (cardinal of L).
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">MultiTrace</span> : <span class="id" title="keyword">Type</span> := (<span class="id" title="var">VectorDef.t</span> <span class="id" title="var">Trace</span> (<span class="id" title="var">S</span> <span class="id" title="var">LCard</span>)).<br/>
<br/>
</div>
<div class="doc">
Below is defined the length "multitrace_sum_len" of a multitrace as the sum of the lengths of its component traces.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">util_trace_lens</span> (<span class="id" title="var">n</span>:<span class="id" title="var">nat</span>) (<span class="id" title="var">t</span>:<span class="id" title="var">Trace</span>): <span class="id" title="var">nat</span> :=<br/>
(<span class="id" title="var">length</span> <span class="id" title="var">t</span>).<br/>
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">multitrace_sum_len</span> (<span class="id" title="var">mu</span>:<span class="id" title="var">MultiTrace</span>) : <span class="id" title="var">nat</span> :=<br/>
<span class="id" title="var">VectorDef.fold_left</span> <span class="id" title="var">util_trace_lens</span> 0 <span class="id" title="var">mu</span>.<br/>
<br/>
</div>
<div class="doc">
The empty multitrace "empty_multitrace" (vector of "LCard" empty traces) is defined below.
For any integer "n" we define a list of "n" times the empty trace.
Then "empty_multitrace" simply is the conversion to a vector of this list with "n=LCard".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">empty_trace_list</span> (<span class="id" title="var">n</span>:<span class="id" title="var">nat</span>) : <span class="id" title="var">list</span> <span class="id" title="var">Trace</span> :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">n</span> <span class="id" title="keyword">with</span><br/>
| 0 => <span class="id" title="var">nil</span><br/>
| <span class="id" title="var">S</span> <span class="id" title="var">n'</span> => (<span class="id" title="var">nil</span>) :: (<span class="id" title="var">empty_trace_list</span> <span class="id" title="var">n'</span>)<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
<span class="id" title="keyword">Program Definition</span> <span class="id" title="var">empty_multitrace</span> : <span class="id" title="var">MultiTrace</span> :=<br/>
(<span class="id" title="var">VectorDef.of_list</span> (<span class="id" title="var">empty_trace_list</span> (<span class="id" title="var">S</span> <span class="id" title="var">LCard</span>)) ).<br/>
<span class="id" title="keyword">Next</span> <span class="id" title="keyword">Obligation</span>.<br/>
<span class="id" title="tactic">induction</span> <span class="id" title="var">LCard</span>.<br/>
- <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">rewrite</span> <span class="id" title="var">IHn</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
Below is defined the concatenation operator "left_append_action_on_multitrace", which, for a given multitrace and action, appends the action to the correct component trace of the multitrace i.e. the one corresponding to the lifeline on which the action occurs.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Definition</span> <span class="id" title="var">left_append_action_on_multitrace</span> (<span class="id" title="var">mu</span> : <span class="id" title="var">MultiTrace</span>) <br/>
(<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>) <br/>
: <span class="id" title="var">MultiTrace</span> :=<br/>
<span class="id" title="var">VectorDef.replace</span> <span class="id" title="var">mu</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a</span>) ( <span class="id" title="var">a</span>:: (<span class="id" title="var">VectorDef.nth</span> <span class="id" title="var">mu</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a</span>) ) ).<br/>
<br/>
</div>
<div class="doc">
"left_append_mu_increase_sum_len" is a Lemma stating that when we append an action to a multitrace using our concatenation operator "left_append_action_on_multitrace", it increases its length "multitrace_sum_len" by 1.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">left_append_mu_increase_sum_len</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">mu</span>:<span class="id" title="var">MultiTrace</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
(<span class="id" title="var">multitrace_sum_len</span> (<span class="id" title="var">left_append_action_on_multitrace</span> <span class="id" title="var">mu</span> <span class="id" title="var">a</span>)) <br/>
= (1 + (<span class="id" title="var">multitrace_sum_len</span> <span class="id" title="var">mu</span>)).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">mu</span> <span class="id" title="var">a</span>.<br/>
<span class="id" title="tactic">unfold</span> <span class="id" title="var">left_append_action_on_multitrace</span>.<br/>
<span class="id" title="var">remember</span> (<span class="id" title="var">VectorDef.nth</span> <span class="id" title="var">mu</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a</span>)) <span class="id" title="keyword">as</span> <span class="id" title="var">t0</span>.<br/>
<span class="id" title="tactic">pose</span> <span class="id" title="var">proof</span> (<span class="id" title="var">replace_on_mu_length</span> <span class="id" title="var">mu</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a</span>) (<span class="id" title="var">a</span> :: <span class="id" title="var">t0</span>) <span class="id" title="var">t0</span>).<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Heqt0</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">H</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Heqt0</span>.<br/>
<span class="id" title="tactic">rewrite</span> <span class="id" title="var">Heqt0</span>.<br/>
<span class="id" title="tactic">simpl</span>. <span class="id" title="var">lia</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
"multitrace_cases" is a Lemma stating that a multitrace is either empty or can be obtained by appending an action to the left of another multitrace using the "left_append_action_on_multitrace" concatenation operator.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">multitrace_cases</span> :<br/>
<span class="id" title="keyword">forall</span> <span class="id" title="var">mu</span>:<span class="id" title="var">MultiTrace</span>,<br/>
(<span class="id" title="var">mu</span>=<span class="id" title="var">empty_multitrace</span>)<br/>
\/ ( <span class="id" title="tactic">exists</span> (<span class="id" title="var">mu'</span>:<span class="id" title="var">MultiTrace</span>) <br/>
(<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>), <br/>
<span class="id" title="var">mu</span> = (<span class="id" title="var">left_append_action_on_multitrace</span> <span class="id" title="var">mu'</span> <span class="id" title="var">a</span>)<br/>
).<br/>
<br/>
</div>
<div class="doc">
"empty_mu_length" and "empty_mu_length_equiv" are Lemmas respectively stating that:
<ul class="doclist">
<li> the length if the empty multitrace "empty_multitrace" is 0
</li>
<li> for any multitrace, if its length is 0 then it is equal to the empty multitrace "empty_multitrace"
</li>
</ul>
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">empty_mu_length</span> :<br/>
(<span class="id" title="var">multitrace_sum_len</span> <span class="id" title="var">empty_multitrace</span> = 0).<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">empty_mu_length_equiv</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">mu</span>:<span class="id" title="var">MultiTrace</span>),<br/>
(<span class="id" title="var">multitrace_sum_len</span> <span class="id" title="var">mu</span> = 0) <-> (<span class="id" title="var">mu</span> = <span class="id" title="var">empty_multitrace</span>).<br/>
<br/>
</div>
<div class="doc">
"left_append_on_mu_cannot_be_nil" is a Lemma stating that a multitrace obtained using the concatenation operator "left_append_action_on_multitrace" cannot be the empty multitrace "empty_multitrace".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">left_append_on_mu_cannot_be_nil</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">mu</span>:<span class="id" title="var">MultiTrace</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
~ (<span class="id" title="var">left_append_action_on_multitrace</span> <span class="id" title="var">mu</span> <span class="id" title="var">a</span> = <span class="id" title="var">empty_multitrace</span>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">mu</span> <span class="id" title="var">a</span>.<br/>
<span class="id" title="tactic">assert</span> ( <span class="id" title="var">multitrace_sum_len</span> (<span class="id" title="var">left_append_action_on_multitrace</span> <span class="id" title="var">mu</span> <span class="id" title="var">a</span>) <br/>
<> <span class="id" title="var">multitrace_sum_len</span> <span class="id" title="var">empty_multitrace</span><br/>
).<br/>
{ <span class="id" title="tactic">rewrite</span> (<span class="id" title="var">left_append_mu_increase_sum_len</span> <span class="id" title="var">mu</span> <span class="id" title="var">a</span>).<br/>
<span class="id" title="tactic">rewrite</span> <span class="id" title="var">empty_mu_length</span>.<br/>
<span class="id" title="var">lia</span>.<br/>
}<br/>
<span class="id" title="tactic">intro</span>. <span class="id" title="tactic">rewrite</span> <span class="id" title="var">H0</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="var">contradiction</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
"left_append_action_on_multitrace_injective" states the injectivity of the "left_append_action_on_multitrace" concatenation operator.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">left_append_action_on_multitrace_injective</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">mu</span> <span class="id" title="var">mu'</span>:<span class="id" title="var">MultiTrace</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
( (<span class="id" title="var">left_append_action_on_multitrace</span> <span class="id" title="var">mu</span> <span class="id" title="var">a</span>) <br/>
= (<span class="id" title="var">left_append_action_on_multitrace</span> <span class="id" title="var">mu'</span> <span class="id" title="var">a</span>)<br/>
)<br/>
-> (<span class="id" title="var">mu</span>=<span class="id" title="var">mu'</span>).<br/>
<br/>
</div>
<div class="doc">
<a id="lab7"></a><h2 class="section">Projecting traces into multitraces</h2>
We define the "project_as_multitrace" function, which projects a globally collected trace into a corresponding locally collected multitrace.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">project_as_multitrace</span> (<span class="id" title="var">t</span> : <span class="id" title="var">Trace</span>) : <span class="id" title="var">MultiTrace</span> :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">t</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">nil</span> => <span class="id" title="var">empty_multitrace</span><br/>
| <span class="id" title="var">a</span> :: <span class="id" title="var">t'</span> => <span class="id" title="var">left_append_action_on_multitrace</span> (<span class="id" title="var">project_as_multitrace</span> <span class="id" title="var">t'</span>) <span class="id" title="var">a</span><br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
"only_nil_project_to_empty" is a Lemma stating that the only multitrace that can be projected to obtain the empty trace is the empty multitrace.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">only_nil_project_to_empty</span> :<br/>
<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">project_as_multitrace</span> <span class="id" title="var">t</span> = <span class="id" title="var">empty_multitrace</span>) -> (<span class="id" title="var">t</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">t</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>.<br/>
- <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">simpl</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">pose</span> <span class="id" title="var">proof</span> (<span class="id" title="var">left_append_on_mu_cannot_be_nil</span> (<span class="id" title="var">project_as_multitrace</span> <span class="id" title="var">t</span>) <span class="id" title="var">a</span>) <span class="id" title="keyword">as</span> <span class="id" title="var">Hnil</span>.<br/>
<span class="id" title="tactic">rewrite</span> <span class="id" title="var">H</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Hnil</span>.<br/>
<span class="id" title="var">contradiction</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
"always_exist_projection" is a Lemma stating that any multitrace can be obtained by the projection of a trace.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">always_exist_projection</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">mu</span>:<span class="id" title="var">MultiTrace</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">project_as_multitrace</span> <span class="id" title="var">t</span>)=<span class="id" title="var">mu</span>).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">mu</span>.<br/>
<span class="id" title="var">remember</span> (<span class="id" title="var">multitrace_sum_len</span> <span class="id" title="var">mu</span>) <span class="id" title="keyword">as</span> <span class="id" title="var">n</span>.<br/>
<span class="id" title="tactic">dependent</span> <span class="id" title="tactic">induction</span> <span class="id" title="var">n</span> <span class="id" title="var">generalizing</span> <span class="id" title="var">mu</span>.<br/>
- <span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Heqn</span>.<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">empty_mu_length_equiv</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Heqn</span>.<br/>
<span class="id" title="tactic">symmetry</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Heqn</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">Heqn</span>.<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">nil</span>. <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">pose</span> <span class="id" title="var">proof</span> (<span class="id" title="var">multitrace_cases</span> <span class="id" title="var">mu</span>) <span class="id" title="keyword">as</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">apply</span> <span class="id" title="var">empty_mu_length_equiv</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">rewrite</span> <span class="id" title="var">H</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Heqn</span>.<br/>
<span class="id" title="tactic">discriminate</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">mu'</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">a</span>,<span class="id" title="var">H</span>).<br/>
<span class="id" title="tactic">specialize</span> <span class="id" title="var">IHn</span> <span class="id" title="keyword">with</span> (<span class="id" title="var">mu</span>:=<span class="id" title="var">mu'</span>).<br/>
<span class="id" title="tactic">assert</span> (<span class="id" title="var">n</span> = <span class="id" title="var">multitrace_sum_len</span> <span class="id" title="var">mu'</span>) <span class="id" title="keyword">as</span> <span class="id" title="var">Hlen</span>.<br/>
{ <span class="id" title="tactic">pose</span> <span class="id" title="var">proof</span> (<span class="id" title="var">left_append_mu_increase_sum_len</span> <span class="id" title="var">mu'</span> <span class="id" title="var">a</span>) <span class="id" title="keyword">as</span> <span class="id" title="var">Hinc</span>.<br/>
<span class="id" title="tactic">rewrite</span> <- <span class="id" title="var">H</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Hinc</span>.<br/>
<span class="id" title="tactic">rewrite</span> <- <span class="id" title="var">Heqn</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Hinc</span>.<br/>
<span class="id" title="var">lia</span>.<br/>
}<br/>
<span class="id" title="tactic">apply</span> <span class="id" title="var">IHn</span> <span class="id" title="tactic">in</span> <span class="id" title="var">Hlen</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">Hlen</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">t</span>,<span class="id" title="var">Hproj</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">simpl</span>.<br/>
<span class="id" title="tactic">rewrite</span> <span class="id" title="var">Hproj</span>.<br/>
<span class="id" title="tactic">symmetry</span>.<br/>
<span class="id" title="tactic">assumption</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
"length_1_projection" is a Lemma stating that if the projection of a trace "t" is of the form "act.empty_multitrace" where "." is the concatenation operator "left_append_action_on_multitrace", then "t" must be the trace "act::nil" i.e. "<span class="inlinecode"><span class="id" title="var">act</span></span>".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">length_1_projection</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">a</span>:<span class="id" title="var">Action</span>),<br/>
(<span class="id" title="var">left_append_action_on_multitrace</span> <span class="id" title="var">empty_multitrace</span> <span class="id" title="var">a</span> = <span class="id" title="var">project_as_multitrace</span> <span class="id" title="var">t</span>)<br/>
-> (<span class="id" title="var">t</span> = <span class="id" title="var">a</span> :: <span class="id" title="var">nil</span>).<br/>
<br/>
</div>
<div class="doc">
"projection_injective" is a Lemma stating the injectivity of the "project_as_multitrace" function.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">projection_injective</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>),<br/>
(<span class="id" title="var">project_as_multitrace</span> <span class="id" title="var">t1</span> = <span class="id" title="var">project_as_multitrace</span> <span class="id" title="var">t2</span>) <br/>
-> (<span class="id" title="var">t1</span>=<span class="id" title="var">t2</span>).<br/>
<br/>
<br/>
</div>
<div class="doc">
<a id="lab8"></a><h1 class="section">Interaction Language</h1>
We now introduce formally aspects of our interaction modelling language.
<a id="lab9"></a><h2 class="section">Syntax</h2>
We first introduce an enumerated (inductive) type "LoopKind" to enumerate the different kinds of loops our formalism specify.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Inductive</span> <span class="id" title="var">LoopKind</span> : <span class="id" title="keyword">Set</span> :=<br/>
|<span class="id" title="var">lstrict</span>:<span class="id" title="var">LoopKind</span><br/>
|<span class="id" title="var">lseq</span>:<span class="id" title="var">LoopKind</span><br/>
|<span class="id" title="var">lpar</span>:<span class="id" title="var">LoopKind</span>.<br/>
<br/>
</div>
<div class="doc">
We then define our "Interaction" type, that inductively define interaction terms.
From basic building blocks which can either be the empty interaction "interaction_empty" or actions (of type "Action"), we then use different operators to construct more complex interaction terms.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Inductive</span> <span class="id" title="var">Interaction</span> : <span class="id" title="keyword">Set</span> := <br/>
<span class="id" title="var">interaction_empty</span>:<span class="id" title="var">Interaction</span> <br/>
|<span class="id" title="var">interaction_act</span>:<span class="id" title="var">Action</span>-><span class="id" title="var">Interaction</span><br/>
|<span class="id" title="var">interaction_strict</span>:<span class="id" title="var">Interaction</span>-><span class="id" title="var">Interaction</span>-><span class="id" title="var">Interaction</span><br/>
|<span class="id" title="var">interaction_seq</span>:<span class="id" title="var">Interaction</span>-><span class="id" title="var">Interaction</span>-><span class="id" title="var">Interaction</span><br/>
|<span class="id" title="var">interaction_par</span>:<span class="id" title="var">Interaction</span>-><span class="id" title="var">Interaction</span>-><span class="id" title="var">Interaction</span><br/>
|<span class="id" title="var">interaction_alt</span>:<span class="id" title="var">Interaction</span>-><span class="id" title="var">Interaction</span>-><span class="id" title="var">Interaction</span><br/>
|<span class="id" title="var">interaction_loop</span>:<span class="id" title="var">LoopKind</span>-><span class="id" title="var">Interaction</span>-><span class="id" title="var">Interaction</span>.<br/>
<br/>
<br/>
</div>
<div class="doc">
<a id="lab10"></a><h2 class="section">Static analysis of interaction terms</h2>
The "express_empty" function can statically determine (based on a static analyse of the interaction term) whether or not a given interaction can accept/express the empty trace i.e. if it can allow the empty execution (nothing happens).
As can be seen, we used a "Fixpoint" to define "express_empty", and it returns a computational-logic "bool" value (as opposed to an intuitionistic-logic "Prop").
This therefore guarantees the deterministic character of "express_empty" and its termination in finite time (static function).
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">express_empty</span> (<span class="id" title="var">i</span> : <span class="id" title="var">Interaction</span>) : <span class="id" title="var">bool</span> :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">i</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">interaction_empty</span> => <span class="id" title="var">true</span><br/>
| (<span class="id" title="var">interaction_act</span> <span class="id" title="var">a</span>) => <span class="id" title="var">false</span><br/>
| (<span class="id" title="var">interaction_loop</span> <span class="id" title="var">lk</span> <span class="id" title="var">i1</span>) => <span class="id" title="var">true</span><br/>
| (<span class="id" title="var">interaction_alt</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">orb</span> (<span class="id" title="var">express_empty</span> <span class="id" title="var">i1</span>) (<span class="id" title="var">express_empty</span> <span class="id" title="var">i2</span>)<br/>
| (<span class="id" title="var">interaction_par</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">andb</span> (<span class="id" title="var">express_empty</span> <span class="id" title="var">i1</span>) (<span class="id" title="var">express_empty</span> <span class="id" title="var">i2</span>)<br/>
| (<span class="id" title="var">interaction_strict</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">andb</span> (<span class="id" title="var">express_empty</span> <span class="id" title="var">i1</span>) (<span class="id" title="var">express_empty</span> <span class="id" title="var">i2</span>)<br/>
| (<span class="id" title="var">interaction_seq</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">andb</span> (<span class="id" title="var">express_empty</span> <span class="id" title="var">i1</span>) (<span class="id" title="var">express_empty</span> <span class="id" title="var">i2</span>)<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
Likewise, we define in the same manner the "avoids" function, which can statically determine whether or not a given interaction accepts execution that do not involve any action of a given lifeline (i.e. it "avoids" the lifeline).
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">avoids</span><br/>
(<span class="id" title="var">i</span> : <span class="id" title="var">Interaction</span>) <br/>
(<span class="id" title="var">l</span> : <span class="id" title="var">L</span>) <br/>
: <span class="id" title="var">bool</span> :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">i</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">interaction_empty</span> => <span class="id" title="var">true</span><br/>
| (<span class="id" title="var">interaction_act</span> <span class="id" title="var">a</span>) => <span class="id" title="var">negb</span> (<span class="id" title="var">Fin.eqb</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a</span>) <span class="id" title="var">l</span>)<br/>
| (<span class="id" title="var">interaction_loop</span> <span class="id" title="var">lk</span> <span class="id" title="var">i1</span>) => <span class="id" title="var">true</span><br/>
| (<span class="id" title="var">interaction_alt</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">orb</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) (<span class="id" title="var">avoids</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span>)<br/>
| (<span class="id" title="var">interaction_par</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">andb</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) (<span class="id" title="var">avoids</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span>)<br/>
| (<span class="id" title="var">interaction_strict</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">andb</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) (<span class="id" title="var">avoids</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span>)<br/>
| (<span class="id" title="var">interaction_seq</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">andb</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) (<span class="id" title="var">avoids</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span>)<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
From a given interaction "i" and lifeline "l" such that "avoids(i,l)=true", the "prune" function computes statically (the return type "Interaction" is a deterministic inductive type) an interaction which accepts exactly all executions of "i" that do not involve the lifeline "l".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">prune</span> <br/>
(<span class="id" title="var">i</span> : <span class="id" title="var">Interaction</span>) <br/>
(<span class="id" title="var">l</span> : <span class="id" title="var">L</span>)<br/>
: <span class="id" title="var">Interaction</span> :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">i</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">interaction_empty</span> => <span class="id" title="var">interaction_empty</span><br/>
| (<span class="id" title="var">interaction_act</span> <span class="id" title="var">a</span>) => (<span class="id" title="var">interaction_act</span> <span class="id" title="var">a</span>)<br/>
| (<span class="id" title="var">interaction_loop</span> <span class="id" title="var">lk</span> <span class="id" title="var">i1</span>) => <span class="id" title="keyword">match</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">true</span> => <span class="id" title="var">interaction_loop</span> <span class="id" title="var">lk</span> (<span class="id" title="var">prune</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>)<br/>
| <span class="id" title="var">false</span> => <span class="id" title="var">interaction_empty</span><br/>
<span class="id" title="keyword">end</span><br/>
| (<span class="id" title="var">interaction_alt</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="keyword">match</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) <span class="id" title="keyword">with</span> <br/>
| <span class="id" title="var">true</span> => <span class="id" title="keyword">match</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span>) <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">true</span> => <span class="id" title="var">interaction_alt</span> <br/>
(<span class="id" title="var">prune</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) <br/>
(<span class="id" title="var">prune</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span>)<br/>
| <span class="id" title="var">false</span> => <span class="id" title="var">prune</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span><br/>
<span class="id" title="keyword">end</span> <br/>
| <span class="id" title="var">false</span> => <span class="id" title="var">prune</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span><br/>
<span class="id" title="keyword">end</span><br/>
| (<span class="id" title="var">interaction_par</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">interaction_par</span> (<span class="id" title="var">prune</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) (<span class="id" title="var">prune</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span>)<br/>
| (<span class="id" title="var">interaction_strict</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">interaction_strict</span> (<span class="id" title="var">prune</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) (<span class="id" title="var">prune</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span>)<br/>
| (<span class="id" title="var">interaction_seq</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="var">interaction_seq</span> (<span class="id" title="var">prune</span> <span class="id" title="var">i1</span> <span class="id" title="var">l</span>) (<span class="id" title="var">prune</span> <span class="id" title="var">i2</span> <span class="id" title="var">l</span>)<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
<br/>
</div>
<div class="doc">
<a id="lab11"></a><h2 class="section">Managing positions with the Dewey Decimal Notation</h2>
Interaction terms have a structure which is that of a binary tree. Indeed, operators used to construct interactions have an arity of at most 2. As a result, we can navigate within interaction terms using a position system in {1,2}^* akin to that of the Dewey Decimal Notation.
We define the "Position" inductive type which form words on {1,2}^*, with "epsilon" being the empty position.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Inductive</span> <span class="id" title="var">Position</span> : <span class="id" title="keyword">Set</span> :=<br/>
|<span class="id" title="var">epsilon</span>:<span class="id" title="var">Position</span><br/>
|<span class="id" title="tactic">left</span>:<span class="id" title="var">Position</span>-><span class="id" title="var">Position</span><br/>
|<span class="id" title="tactic">right</span>:<span class="id" title="var">Position</span>-><span class="id" title="var">Position</span>.<br/>
<br/>
</div>
<div class="doc">
For practical reasons, that will be made clear in the following, we define a "left_front" operator which, for any list of "Position*Action" tuples, returns a similar list where every position from the original list have been shifted to the left.
It can simply be explained by the notation <tt>"left.[(p1,a1),...,(p2,a2)] = [(left p1,a1),...,(left p2,a2)]"</tt>.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">left_front</span> (<span class="id" title="var">e1</span> : <span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)) : <span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>) :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">e1</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">nil</span> => <span class="id" title="var">nil</span><br/>
| (<span class="id" title="var">p</span>,<span class="id" title="var">a</span>) :: <span class="id" title="var">tail</span> => (<span class="id" title="tactic">left</span> <span class="id" title="var">p</span>,<span class="id" title="var">a</span>) :: <span class="id" title="var">left_front</span> <span class="id" title="var">tail</span><br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
"left_front_ex" is a Lemma stating a simple characterization of "left_front" which is that, for a given list "fr" of tuples "Position*Action", for any couple "(p,a)" in "left_front(fr)", there exists a corresponding couple "(p1,a)" in "fr" such that "p=left p1".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">left_front_ex</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">fr</span>:<span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)) (<span class="id" title="var">p</span>:<span class="id" title="var">Position</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
( <span class="id" title="var">In</span> (<span class="id" title="var">p</span>,<span class="id" title="var">a</span>) (<span class="id" title="var">left_front</span> <span class="id" title="var">fr</span>) )<br/>
-> ( <span class="id" title="tactic">exists</span> (<span class="id" title="var">p1</span>:<span class="id" title="var">Position</span>), (<span class="id" title="var">p</span> = <span class="id" title="tactic">left</span> <span class="id" title="var">p1</span>) /\ (<span class="id" title="var">In</span> (<span class="id" title="var">p1</span>,<span class="id" title="var">a</span>) <span class="id" title="var">fr</span> ) ).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">fr</span> <span class="id" title="var">p</span> <span class="id" title="var">a</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">induction</span> <span class="id" title="var">fr</span>.<br/>
- <span class="id" title="tactic">simpl</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="var">contradiction</span>.<br/>
- <span class="id" title="tactic">destruct</span> <span class="id" title="var">a0</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">p'</span>,<span class="id" title="var">a'</span>).<br/>
<span class="id" title="tactic">simpl</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">exists</span> <span class="id" title="var">p'</span>.<br/>
<span class="id" title="tactic">simpl</span>.<br/>
<span class="id" title="tactic">split</span>.<br/>
* <span class="id" title="tactic">inversion</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
* <span class="id" title="tactic">left</span>. <span class="id" title="tactic">inversion</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</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> <span class="id" title="keyword">as</span> (<span class="id" title="var">p1</span>,<span class="id" title="var">H</span>).<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">p1</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">HA</span>,<span class="id" title="var">HB</span>).<br/>
<span class="id" title="tactic">split</span>.<br/>
* <span class="id" title="tactic">assumption</span>.<br/>
* <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">right</span>. <span class="id" title="tactic">assumption</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
"left_front_ex2" is a Lemma stating another simple characterization of "left_front".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">left_front_ex2</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">fr</span>:<span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)) (<span class="id" title="var">p1</span>:<span class="id" title="var">Position</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
( <span class="id" title="var">In</span> (<span class="id" title="tactic">left</span> <span class="id" title="var">p1</span>,<span class="id" title="var">a</span>) (<span class="id" title="var">left_front</span> <span class="id" title="var">fr</span>) )<br/>
<-> ( <span class="id" title="var">In</span> (<span class="id" title="var">p1</span>,<span class="id" title="var">a</span>) <span class="id" title="var">fr</span> ).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">fr</span> <span class="id" title="var">p1</span> <span class="id" title="var">a</span>.<br/>
<span class="id" title="tactic">split</span> ; <span class="id" title="tactic">intros</span> <span class="id" title="var">H</span>.<br/>
- <span class="id" title="tactic">induction</span> <span class="id" title="var">fr</span>.<br/>
+ <span class="id" title="tactic">simpl</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="var">contradiction</span>.<br/>
+ <span class="id" title="tactic">destruct</span> <span class="id" title="var">a0</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">p0</span>,<span class="id" title="var">a0</span>). <span class="id" title="tactic">simpl</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">inversion</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
* <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">right</span>. <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</span>. <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">induction</span> <span class="id" title="var">fr</span>.<br/>
+ <span class="id" title="tactic">simpl</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="var">contradiction</span>.<br/>
+ <span class="id" title="tactic">destruct</span> <span class="id" title="var">a0</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">p0</span>,<span class="id" title="var">a0</span>). <span class="id" title="tactic">simpl</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">inversion</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
* <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">right</span>. <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</span>. <span class="id" title="tactic">assumption</span>.<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
After "left_front", we define the symmetric "right_front" operator and the corresponding lemmas "right_front_ex" and "right_front_ex2". As their proofs are identical to that of "left_front_ex" and "left_front_ex2", we hide them in this document.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">right_front</span> (<span class="id" title="var">e2</span> : <span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)) : <span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>) :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">e2</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">nil</span> => <span class="id" title="var">nil</span><br/>
| (<span class="id" title="var">p</span>,<span class="id" title="var">a</span>) :: <span class="id" title="var">tail</span> => (<span class="id" title="tactic">right</span> <span class="id" title="var">p</span>,<span class="id" title="var">a</span>) :: <span class="id" title="var">right_front</span> <span class="id" title="var">tail</span><br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">right_front_ex</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">fr</span>:<span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)) (<span class="id" title="var">p</span>:<span class="id" title="var">Position</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
( <span class="id" title="var">In</span> (<span class="id" title="var">p</span>,<span class="id" title="var">a</span>) (<span class="id" title="var">right_front</span> <span class="id" title="var">fr</span>) )<br/>
-> ( <span class="id" title="tactic">exists</span> (<span class="id" title="var">p2</span>:<span class="id" title="var">Position</span>), (<span class="id" title="var">p</span> = <span class="id" title="tactic">right</span> <span class="id" title="var">p2</span>) /\ (<span class="id" title="var">In</span> (<span class="id" title="var">p2</span>,<span class="id" title="var">a</span>) <span class="id" title="var">fr</span> ) ).<br/>
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">right_front_ex2</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">fr</span>:<span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)) (<span class="id" title="var">p2</span>:<span class="id" title="var">Position</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
( <span class="id" title="var">In</span> (<span class="id" title="tactic">right</span> <span class="id" title="var">p2</span>,<span class="id" title="var">a</span>) (<span class="id" title="var">right_front</span> <span class="id" title="var">fr</span>) )<br/>
<-> ( <span class="id" title="var">In</span> (<span class="id" title="var">p2</span>,<span class="id" title="var">a</span>) <span class="id" title="var">fr</span> ).<br/>
<br/>
</div>
<div class="doc">
We now define a filter function "filterfront_on_avoid", which, for any interaction "i" and list "fr" of "Position*Action" tuples returns the sublist of "fr" such that each element "(p,a)" verifies "avoids(i,lifeline(a))=true".
"filterfront_on_avoid" therefore filters elements of "fr", keeping only those of which the action "a" is s.t. "avoids(i,lifeline(a))=true".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">filterfront_on_avoid</span> (<span class="id" title="var">i</span> : <span class="id" title="var">Interaction</span>) (<span class="id" title="var">fr</span> : <span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)) <br/>
: <span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)<br/>
:=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">fr</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">nil</span> => <span class="id" title="var">nil</span><br/>
| (<span class="id" title="var">p</span>,<span class="id" title="var">a</span>) :: <span class="id" title="var">fr'</span> => <span class="id" title="keyword">if</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a</span>)) <br/>
<span class="id" title="keyword">then</span> (<span class="id" title="var">p</span>,<span class="id" title="var">a</span>) :: (<span class="id" title="var">filterfront_on_avoid</span> <span class="id" title="var">i</span> <span class="id" title="var">fr'</span>)<br/>
<span class="id" title="keyword">else</span> (<span class="id" title="var">filterfront_on_avoid</span> <span class="id" title="var">i</span> <span class="id" title="var">fr'</span>)<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
"filterfront_on_avoid_ex" and "filterfront_on_avoid_ex2" are lemmas stating two characterization of "filterfront_on_avoid" in combination with "right_front".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Lemma</span> <span class="id" title="var">filterfront_on_avoid_ex</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">i</span>:<span class="id" title="var">Interaction</span>) <br/>
(<span class="id" title="var">fr</span>:<span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)) <br/>
(<span class="id" title="var">p</span>:<span class="id" title="var">Position</span>) <br/>
(<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
( <span class="id" title="var">In</span> (<span class="id" title="var">p</span>, <span class="id" title="var">a</span>) (<span class="id" title="var">filterfront_on_avoid</span> <span class="id" title="var">i</span> (<span class="id" title="var">right_front</span> <span class="id" title="var">fr</span>)) )<br/>
-> ( <span class="id" title="tactic">exists</span> (<span class="id" title="var">p2</span>:<span class="id" title="var">Position</span>), <br/>
(<span class="id" title="var">is_true</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a</span>))) <br/>
/\ (<span class="id" title="var">p</span> = <span class="id" title="tactic">right</span> <span class="id" title="var">p2</span>) /\ (<span class="id" title="var">In</span> (<span class="id" title="var">p2</span>,<span class="id" title="var">a</span>) <span class="id" title="var">fr</span> ) <br/>
).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">i</span> <span class="id" title="var">fr</span> <span class="id" title="var">p</span> <span class="id" title="var">a</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="tactic">induction</span> <span class="id" title="var">fr</span>.<br/>
- <span class="id" title="tactic">simpl</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="var">contradiction</span>.<br/>
- <span class="id" title="tactic">destruct</span> <span class="id" title="var">a0</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">p'</span>,<span class="id" title="var">a'</span>).<br/>
<span class="id" title="tactic">simpl</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="var">remember</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a'</span>)) <span class="id" title="keyword">as</span> <span class="id" title="var">Hav</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">Hav</span>.<br/>
+ <span class="id" title="tactic">simpl</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">inversion</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">H2</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</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">p'</span>.<br/>
<span class="id" title="tactic">simpl</span>.<br/>
<span class="id" title="tactic">split</span>. { <span class="id" title="tactic">rewrite</span> <- <span class="id" title="var">HeqHav</span>. <span class="id" title="tactic">reflexivity</span>. }<br/>
{ <span class="id" title="tactic">split</span>. { <span class="id" title="tactic">reflexivity</span>. } {<span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>. } }<br/>
* <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</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="keyword">as</span> (<span class="id" title="var">p2</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">HA</span>,<span class="id" title="var">HB</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">HB</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">HB</span>,<span class="id" title="var">HC</span>).<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">p2</span>.<br/>
<span class="id" title="tactic">split</span>.<br/>
{ <span class="id" title="tactic">assumption</span>. } <br/>
{ <span class="id" title="tactic">split</span>. { <span class="id" title="tactic">assumption</span>. } { <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">right</span>. <span class="id" title="tactic">assumption</span>. } }<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</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="keyword">as</span> (<span class="id" title="var">p2</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">HA</span>,<span class="id" title="var">HB</span>).<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">HB</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">HB</span>,<span class="id" title="var">HC</span>).<br/>
<span class="id" title="tactic">exists</span> <span class="id" title="var">p2</span>.<br/>
<span class="id" title="tactic">split</span>.<br/>
{ <span class="id" title="tactic">assumption</span>. } <br/>
{ <span class="id" title="tactic">split</span>. { <span class="id" title="tactic">assumption</span>. } { <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">right</span>. <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">filterfront_on_avoid_ex2</span> :<br/>
<span class="id" title="keyword">forall</span> (<span class="id" title="var">i</span>:<span class="id" title="var">Interaction</span>) <br/>
(<span class="id" title="var">fr</span>:<span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>)) <br/>
(<span class="id" title="var">p2</span>:<span class="id" title="var">Position</span>) <br/>
(<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>),<br/>
( <span class="id" title="var">In</span> (<span class="id" title="tactic">right</span> <span class="id" title="var">p2</span>, <span class="id" title="var">a</span>) (<span class="id" title="var">filterfront_on_avoid</span> <span class="id" title="var">i</span> (<span class="id" title="var">right_front</span> <span class="id" title="var">fr</span>)) )<br/>
<-> ( (<span class="id" title="var">In</span> (<span class="id" title="var">p2</span>,<span class="id" title="var">a</span>) <span class="id" title="var">fr</span>) /\ (<span class="id" title="var">is_true</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a</span>))) ).<br/>
<span class="id" title="keyword">Proof</span>.<br/>
<span class="id" title="tactic">intros</span> <span class="id" title="var">i</span> <span class="id" title="var">fr</span> <span class="id" title="var">p2</span> <span class="id" title="var">a</span>.<br/>
<span class="id" title="tactic">split</span> ; <span class="id" title="tactic">intros</span> <span class="id" title="var">H</span>.<br/>
- <span class="id" title="tactic">induction</span> <span class="id" title="var">fr</span>.<br/>
+ <span class="id" title="tactic">simpl</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>. <span class="id" title="var">contradiction</span>.<br/>
+ <span class="id" title="tactic">destruct</span> <span class="id" title="var">a0</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">p0</span>,<span class="id" title="var">a0</span>). <span class="id" title="tactic">simpl</span> <span class="id" title="tactic">in</span> <span class="id" title="var">H</span>.<br/>
<span class="id" title="var">remember</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a0</span>)) <span class="id" title="keyword">as</span> <span class="id" title="var">Hav</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">Hav</span>.<br/>
{ <span class="id" title="tactic">simpl</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">inversion</span> <span class="id" title="var">H</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H1</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">split</span>.<br/>
+ <span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
+ <span class="id" title="tactic">unfold</span> <span class="id" title="var">is_true</span>. <span class="id" title="tactic">symmetry</span>. <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">split</span>.<br/>
+ <span class="id" title="tactic">right</span>. <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</span>. <span class="id" title="tactic">assumption</span>.<br/>
+ <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</span>. <span class="id" title="tactic">assumption</span>.<br/>
}<br/>
{ <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">split</span>.<br/>
- <span class="id" title="tactic">right</span>. <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</span>. <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</span>. <span class="id" title="tactic">assumption</span>.<br/>
}<br/>
- <span class="id" title="tactic">induction</span> <span class="id" title="var">fr</span>.<br/>
+ <span class="id" title="tactic">simpl</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> <span class="id" title="keyword">as</span> (<span class="id" title="var">HA</span>,<span class="id" title="var">HB</span>). <span class="id" title="var">contradiction</span>.<br/>
+ <span class="id" title="tactic">destruct</span> <span class="id" title="var">a0</span> <span class="id" title="keyword">as</span> (<span class="id" title="var">p0</span>,<span class="id" title="var">a0</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">HA</span>,<span class="id" title="var">HB</span>).<br/>
<span class="id" title="tactic">simpl</span> <span class="id" title="tactic">in</span> <span class="id" title="var">HA</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">HA</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">H1</span>. <span class="id" title="tactic">destruct</span> <span class="id" title="var">H2</span>.<br/>
<span class="id" title="tactic">simpl</span>.<br/>
<span class="id" title="var">remember</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a0</span>)) <span class="id" title="keyword">as</span> <span class="id" title="var">Hav</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">Hav</span>.<br/>
- <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">left</span>. <span class="id" title="tactic">reflexivity</span>.<br/>
- <span class="id" title="tactic">unfold</span> <span class="id" title="var">is_true</span> <span class="id" title="tactic">in</span> <span class="id" title="var">HB</span>. <span class="id" title="tactic">discriminate</span>.<br/>
}<br/>
{ <span class="id" title="tactic">simpl</span>.<br/>
<span class="id" title="var">remember</span> (<span class="id" title="var">avoids</span> <span class="id" title="var">i</span> (<span class="id" title="var">lifeline</span> <span class="id" title="var">a0</span>)) <span class="id" title="keyword">as</span> <span class="id" title="var">Hav</span>.<br/>
<span class="id" title="tactic">destruct</span> <span class="id" title="var">Hav</span>.<br/>
- <span class="id" title="tactic">simpl</span>. <span class="id" title="tactic">right</span>. <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</span>. <span class="id" title="tactic">split</span>; <span class="id" title="tactic">assumption</span>.<br/>
- <span class="id" title="tactic">apply</span> <span class="id" title="var">IHfr</span>. <span class="id" title="tactic">split</span> ; <span class="id" title="tactic">assumption</span>.<br/>
}<br/>
<span class="id" title="keyword">Qed</span>.<br/>
<br/>
</div>
<div class="doc">
<a id="lab12"></a><h2 class="section">Identification & Execution of immediately executable actions</h2>
The manipulation of lists of "Position*Action" tuples in the previous section now allows us to define the notion of "frontier".
For any interaction "i", "frontier i" is the list of "Position*Action" tuples "(p,a)" s.t. "a" is an immediately executable action of "i" and is to be found at position "p" within "i".
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Fixpoint</span> <span class="id" title="var">frontier</span> (<span class="id" title="var">i</span> : <span class="id" title="var">Interaction</span>) : <span class="id" title="var">list</span> (<span class="id" title="var">Position</span>*<span class="id" title="var">Action</span>) :=<br/>
<span class="id" title="keyword">match</span> <span class="id" title="var">i</span> <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">interaction_empty</span> => <span class="id" title="var">nil</span><br/>
| (<span class="id" title="var">interaction_act</span> <span class="id" title="var">a</span>) => (<span class="id" title="var">epsilon</span>,<span class="id" title="var">a</span>) :: <span class="id" title="var">nil</span><br/>
| (<span class="id" title="var">interaction_loop</span> <span class="id" title="var">lk</span> <span class="id" title="var">i1</span>) => <span class="id" title="var">left_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i1</span>)<br/>
| (<span class="id" title="var">interaction_alt</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => (<span class="id" title="var">left_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i1</span>)) ++<br/>
(<span class="id" title="var">right_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i2</span>))<br/>
| (<span class="id" title="var">interaction_par</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => (<span class="id" title="var">left_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i1</span>)) ++<br/>
(<span class="id" title="var">right_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i2</span>))<br/>
| (<span class="id" title="var">interaction_strict</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => <span class="id" title="keyword">match</span> (<span class="id" title="var">express_empty</span> <span class="id" title="var">i1</span>) <span class="id" title="keyword">with</span><br/>
| <span class="id" title="var">true</span> => (<span class="id" title="var">left_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i1</span>)) ++<br/>
(<span class="id" title="var">right_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i2</span>))<br/>
| <span class="id" title="var">false</span> => <span class="id" title="var">left_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i1</span>)<br/>
<span class="id" title="keyword">end</span><br/>
| (<span class="id" title="var">interaction_seq</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) => (<span class="id" title="var">left_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i1</span>)) ++<br/>
(<span class="id" title="var">filterfront_on_avoid</span> <span class="id" title="var">i1</span> (<span class="id" title="var">right_front</span> (<span class="id" title="var">frontier</span> <span class="id" title="var">i2</span>)))<br/>
<span class="id" title="keyword">end</span>.<br/>
<br/>
</div>
<div class="doc">
Any frontier element "(p,a)" of an interaction "i" can then be used to compute a next interaction "i'" s.t. "i'" exactly accepts all the continuations of executions of "i" that start with the execution of action "a" at position "p".
In the paper version, we defined a constructive execution function.
Here, we define an inductive proposition "is_next_of" s.t. "is_next_of i p a i'" states that "i'" is obtained by the execution of "a" at position "p" in "i".
The fact that we have defined "is_next_of" as an inductive proposition instead of as a Fixpoint do not imply properties of:
<ul class="doclist">
<li> existence (i.e. s.t. there exists such an interaction "i'" for frontier elements "(p,a)")
</li>
<li> and unicity (i.e. s.t. if "is_next_of i p a ia" and "is_next_of i p a ib" then we must have "ia=ib")
</li>
</ul>
To counter that, we will introduce and prove existence and unicity theorems.
</div>
<div class="code">
<br/>
<span class="id" title="keyword">Inductive</span> <span class="id" title="var">is_next_of</span> : <span class="id" title="var">Interaction</span> -> <span class="id" title="var">Position</span> -> <span class="id" title="var">Action</span> -> <span class="id" title="var">Interaction</span> -> <span class="id" title="keyword">Prop</span> :=<br/>
|<span class="id" title="var">execute_at_leaf</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">is_next_of</span> (<span class="id" title="var">interaction_act</span> <span class="id" title="var">a</span>) <span class="id" title="var">epsilon</span> <span class="id" title="var">a</span> <span class="id" title="var">interaction_empty</span>)<br/>
|<span class="id" title="var">execute_left_alt</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">p1</span>:<span class="id" title="var">Position</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>) (<span class="id" title="var">i1</span> <span class="id" title="var">i2</span> <span class="id" title="var">i1'</span> : <span class="id" title="var">Interaction</span>),<br/>
(<span class="id" title="var">is_next_of</span> <span class="id" title="var">i1</span> <span class="id" title="var">p1</span> <span class="id" title="var">a</span> <span class="id" title="var">i1'</span>) <br/>
-> (<span class="id" title="var">is_next_of</span> (<span class="id" title="var">interaction_alt</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) (<span class="id" title="tactic">left</span> <span class="id" title="var">p1</span>) <span class="id" title="var">a</span> <span class="id" title="var">i1'</span>)<br/>
|<span class="id" title="var">execute_right_alt</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">p2</span>:<span class="id" title="var">Position</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>) (<span class="id" title="var">i1</span> <span class="id" title="var">i2</span> <span class="id" title="var">i2'</span> : <span class="id" title="var">Interaction</span>),<br/>
(<span class="id" title="var">is_next_of</span> <span class="id" title="var">i2</span> <span class="id" title="var">p2</span> <span class="id" title="var">a</span> <span class="id" title="var">i2'</span>) <br/>
-> (<span class="id" title="var">is_next_of</span> (<span class="id" title="var">interaction_alt</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) (<span class="id" title="tactic">right</span> <span class="id" title="var">p2</span>) <span class="id" title="var">a</span> <span class="id" title="var">i2'</span>)<br/>
|<span class="id" title="var">execute_left_par</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">p1</span>:<span class="id" title="var">Position</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>) (<span class="id" title="var">i1</span> <span class="id" title="var">i2</span> <span class="id" title="var">i1'</span> : <span class="id" title="var">Interaction</span>),<br/>
(<span class="id" title="var">is_next_of</span> <span class="id" title="var">i1</span> <span class="id" title="var">p1</span> <span class="id" title="var">a</span> <span class="id" title="var">i1'</span>) <br/>
-> (<span class="id" title="var">is_next_of</span> <br/>
(<span class="id" title="var">interaction_par</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>)<br/>
(<span class="id" title="tactic">left</span> <span class="id" title="var">p1</span>)<br/>
<span class="id" title="var">a</span> <br/>
(<span class="id" title="var">interaction_par</span> <span class="id" title="var">i1'</span> <span class="id" title="var">i2</span>)<br/>
)<br/>
|<span class="id" title="var">execute_right_par</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">p2</span>:<span class="id" title="var">Position</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>) (<span class="id" title="var">i1</span> <span class="id" title="var">i2</span> <span class="id" title="var">i2'</span> : <span class="id" title="var">Interaction</span>),<br/>
(<span class="id" title="var">is_next_of</span> <span class="id" title="var">i2</span> <span class="id" title="var">p2</span> <span class="id" title="var">a</span> <span class="id" title="var">i2'</span>) <br/>
-> (<span class="id" title="var">is_next_of</span> <br/>
(<span class="id" title="var">interaction_par</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2</span>) <br/>
(<span class="id" title="tactic">right</span> <span class="id" title="var">p2</span>)<br/>
<span class="id" title="var">a</span> <br/>
(<span class="id" title="var">interaction_par</span> <span class="id" title="var">i1</span> <span class="id" title="var">i2'</span>)<br/>
)<br/>
|<span class="id" title="var">execute_loop_strict</span> : <span class="id" title="keyword">forall</span> (<span class="id" title="var">p1</span>:<span class="id" title="var">Position</span>) (<span class="id" title="var">a</span>:<span class="id" title="var">Action</span>) (<span class="id" title="var">i1</span> <span class="id" title="var">i1'</span>:<span class="id" title="var">Interaction</span>),<br/>
(<span class="id" title="var">is_next_of</span> <span class="id" title="var">i1</span> <span class="id" title="var">p1</span> <span class="id" title="var">a</span> <span class="id" title="var">i1'</span>) <br/>
-> (<span class="id" title="var">is_next_of</span> <br/>
(<span class="id" title="var">interaction_loop</span> <span class="id" title="var">lstrict</span> <span class="id" title="var">i1</span>) <br/>
(<span class="id" title="tactic">left</span> <span class="id" title="var">p1</span>)<br/>
<span class="id" title="var">a</span><br/>
(<span class="id" title="var">interaction_strict</span> <span class="id" title="var">i1'</span> (<span class="id" title="var">interaction_loop</span> <span class="id" title="var">lstrict</span> <span class="id" title="var">i1</span>))<br/>