-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathPProperties.v
2931 lines (2713 loc) · 104 KB
/
PProperties.v
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
Require Import Kami.Syntax.
Require Import Kami.Properties.
Import ListNotations.
Require Import Coq.Sorting.Permutation.
Require Import Coq.Sorting.PermutEq.
Require Import RelationClasses Setoid Morphisms.
Require Import ZArith.
Lemma PSemAction_SemAction o k:
forall (a : ActionT type k) (readRegs newRegs : RegsT) (calls : MethsT) (fret : type k),
PSemAction o a readRegs newRegs calls fret ->
(exists (readRegs' newRegs' : RegsT) (calls' : MethsT),
readRegs [=] readRegs' /\
newRegs [=] newRegs' /\
calls [=] calls' /\
SemAction o a readRegs' newRegs' calls' fret).
Proof.
induction 1; dest.
- exists x, x0, ((meth, existT SignT s (evalExpr marg, mret))::x1).
repeat split; eauto.
+ rewrite <- H2; assumption.
+ econstructor 1; auto.
- exists x, x0, x1.
repeat split; eauto.
econstructor 2; assumption.
- exists (x2++x), (x3++x0), (x4++x1).
rewrite H1, H5 in HUReadRegs; rewrite H2, H6 in HUNewRegs; rewrite H3, H7 in HUCalls.
repeat split; auto.
+ constructor 3 with (readRegs := x2) (newRegs := x3) (readRegsCont := x) (newRegsCont := x0) (calls := x4) (callsCont := x1) (v := v); eauto.
* intro; specialize (HDisjRegs k0); rewrite <- H6, <- H2; assumption.
- exists x, x0, x1.
repeat split; auto.
econstructor 4; eauto.
- exists ((r, existT (fullType type) regT regV)::x), x0, x1.
repeat split; eauto.
+ rewrite <- H0; assumption.
+ econstructor 5; eauto.
- exists x, ((r, existT (fullType type) k (evalExpr e))::x0), x1.
repeat split; eauto.
+ rewrite <- H1; assumption.
+ econstructor 6; auto.
intro; specialize (HDisjRegs v); rewrite H1 in HDisjRegs; apply HDisjRegs.
- exists (x2++x), (x3++x0), (x4++x1).
rewrite H1, H5 in HUReadRegs; rewrite H2, H6 in HUNewRegs; rewrite H3, H7 in HUCalls.
repeat split; auto.
econstructor 7; auto.
+ intro; specialize (HDisjRegs k); rewrite H2, H6 in HDisjRegs; apply HDisjRegs.
+ apply H8.
+ assumption.
- exists (x2++x), (x3++x0), (x4++x1).
rewrite H1, H5 in HUReadRegs; rewrite H2, H6 in HUNewRegs; rewrite H3, H7 in HUCalls.
repeat split; auto.
econstructor 8; auto.
+ intro; specialize (HDisjRegs k); rewrite H2, H6 in HDisjRegs; apply HDisjRegs.
+ apply H8.
+ assumption.
- exists x, x0, x1.
repeat split; auto.
econstructor; eauto.
- exists nil, nil, nil.
repeat split; subst; auto.
econstructor; eauto.
Qed.
Lemma SemAction_PSemAction o k:
forall (a : ActionT type k) (readRegs newRegs : RegsT) (calls : MethsT) (fret : type k),
SemAction o a readRegs newRegs calls fret ->
PSemAction o a readRegs newRegs calls fret.
Proof.
induction 1; subst.
- econstructor 1; eauto.
- econstructor 2; eauto.
- econstructor 3; eauto.
- econstructor 4; eauto.
- econstructor 5; eauto.
- econstructor 6; eauto.
- econstructor 7; eauto.
- econstructor 8; eauto.
- econstructor 9; eauto.
- econstructor 10; eauto.
Qed.
Lemma key_in_split' : forall (A B C : Type)(l : list (A*B))(x : (A*C)),
In (fst x) (map fst l) ->
(exists (l1 l2 : list (A*B))(y : B), l = l1++(((fst x), y)::l2)).
Proof.
induction l; simpl; intros; auto.
- contradiction.
- destruct H.
+ exists nil, l; simpl.
destruct a, x; simpl in *; subst.
exists b; reflexivity.
+ specialize (IHl _ H).
dest.
exists (a::x0), x1.
simpl. exists x2.
rewrite H0; reflexivity.
Qed.
Lemma map_in_split A B (f : A -> B):
forall (l : list A)(x : A),
In (f x) (map f l) -> (exists (l1 l2 : list A), (map f l) = (map f l1)++((f x)::(map f l2))).
Proof.
induction l; simpl; intros; auto.
- contradiction.
- destruct H.
+ exists nil, l; simpl.
rewrite H; reflexivity.
+ specialize (IHl _ H).
dest.
exists (a::x0), x1.
simpl.
rewrite H0; reflexivity.
Qed.
Lemma getKindAttr_perm_eq (A B : Type)(P : B -> Type)(Q : B -> Type) :
forall (l1 : list (A * {x : B & P x}))(l2 : list (A * {x : B & Q x})),
getKindAttr l1 [=] getKindAttr l2 ->
(exists l2', l2 [=] l2' /\
getKindAttr l2' = getKindAttr l1).
Proof.
induction l1.
- intros.
exists nil.
repeat split; auto.
destruct l2;[reflexivity|specialize (Permutation_nil H);discriminate].
- simpl; intros.
assert (In (fst a, projT1 (snd a)) (getKindAttr l2));[rewrite <- H; left; reflexivity|].
rewrite in_map_iff in H0; dest.
specialize (in_split _ _ H1) as TMP; dest; subst.
rewrite map_app in H; simpl in H; rewrite H0 in H.
specialize (Permutation_cons_app_inv _ _ H) as TMP.
rewrite <- map_app in TMP.
specialize (IHl1 _ TMP); dest.
exists (x::x2); split.
rewrite <- H2; symmetry; apply Permutation_cons_app; reflexivity.
simpl; rewrite H3, H0; reflexivity.
Qed.
Lemma fst_produce_snd A B:
forall (l : list (A * B)) (a : A),
In a (map fst l) -> (exists (b : B), In (a, b) l).
Proof.
induction l; simpl; intros.
- inversion H.
- destruct a.
destruct H.
+ exists b.
inversion H; subst.
left; reflexivity.
+ specialize (IHl _ H); dest.
exists x.
right; assumption.
Qed.
Lemma key_perm_eq (A B C : Type):
forall (l : list (A*C))(l' : list (A*B)),
(map fst l) [=] (map fst l') ->
(exists l'',
l' [=] l'' /\
map fst l = map fst l'').
Proof.
induction l.
- intros.
apply Permutation_nil,map_eq_nil in H; subst;exists nil; split; auto.
- intros.
specialize (key_in_split' _ _ (Permutation_in _ H (in_eq _ _))) as TMP; dest.
rewrite H0 in H; simpl in H; rewrite map_app in H;simpl in H;apply Permutation_cons_app_inv in H.
rewrite <- map_app in H.
specialize (IHl _ H); dest.
exists ((fst a, x1)::x2); split.
+ rewrite H0, <- H1; symmetry; apply Permutation_middle.
+ simpl; rewrite H2; reflexivity.
Qed.
Section PSemAction_rewrites.
Variable (k : Kind) (a : ActionT type k) (fret : type k).
Lemma PSemAction_rewrite_state readRegs newRegs calls o1 o2:
(o1 [=] o2) ->
PSemAction o1 a readRegs newRegs calls fret ->
PSemAction o2 a readRegs newRegs calls fret.
Proof.
induction 2.
- econstructor 1; eauto.
- econstructor 2; eauto.
- econstructor 3; eauto.
- econstructor 4; eauto.
- econstructor 5; eauto.
rewrite <- H.
assumption.
- econstructor 6; eauto.
rewrite <- H.
assumption.
- econstructor 7; eauto.
- econstructor 8; eauto.
- econstructor 9; eauto.
- econstructor 10; eauto.
Qed.
Lemma PSemAction_rewrite_calls readRegs newRegs calls1 calls2 o:
(calls1 [=] calls2) ->
PSemAction o a readRegs newRegs calls1 fret ->
PSemAction o a readRegs newRegs calls2 fret.
Proof.
induction 2.
- econstructor 1; eauto.
rewrite <- H; assumption.
- econstructor 2; eauto.
- econstructor 3; eauto.
rewrite <- H; assumption.
- econstructor 4; eauto.
- econstructor 5; eauto.
- econstructor 6; eauto.
- econstructor 7; eauto.
rewrite <- H; assumption.
- econstructor 8; eauto.
rewrite <- H; assumption.
- econstructor 9; eauto.
- econstructor 10; eauto.
rewrite HCalls in H; apply (Permutation_nil H).
Qed.
Lemma SubList_refl A (l : list A) :
SubList l l.
Proof.
firstorder.
Qed.
Global Instance SubList_PreOrder A : PreOrder (@SubList A) | 10 := {
PreOrder_Reflexive := (@SubList_refl A);
PreOrder_Transitive := (@SubList_transitive A)}.
Lemma PSemAction_rewrite_readRegs readRegs1 readRegs2 newRegs calls o:
readRegs1 [=] readRegs2 ->
PSemAction o a readRegs1 newRegs calls fret ->
PSemAction o a readRegs2 newRegs calls fret.
Proof.
induction 2.
- econstructor 1; eauto.
- econstructor 2; eauto.
- econstructor 3; eauto.
rewrite <- H; assumption.
- econstructor 4; eauto.
- econstructor 5; eauto.
rewrite <- H; assumption.
- econstructor 6; eauto.
- econstructor 7; eauto.
rewrite <- H; assumption.
- econstructor 8; eauto.
rewrite <- H; assumption.
- econstructor 9; eauto.
- econstructor 10; eauto.
rewrite HReadRegs in H; apply (Permutation_nil H).
Qed.
Lemma PSemAction_rewrite_newRegs readRegs newRegs1 newRegs2 calls o:
newRegs1 [=] newRegs2 ->
PSemAction o a readRegs newRegs1 calls fret ->
PSemAction o a readRegs newRegs2 calls fret.
Proof.
induction 2.
- econstructor 1; eauto.
- econstructor 2; eauto.
- econstructor 3; eauto.
rewrite <- H; assumption.
- econstructor 4; eauto.
- econstructor 5; eauto.
- econstructor 6; eauto.
rewrite <- H; assumption.
- econstructor 7; eauto.
rewrite <- H; assumption.
- econstructor 8; eauto.
rewrite <- H; assumption.
- econstructor 9; eauto.
- econstructor 10; eauto.
rewrite HNewRegs in H; apply (Permutation_nil H).
Qed.
Global Instance PSemAction_rewrite' :
Proper (@Permutation (string * {x : FullKind & fullType type x}) ==>
@Permutation (string * {x : FullKind & fullType type x}) ==>
@Permutation (string * {x : FullKind & fullType type x}) ==>
@Permutation MethT ==>
iff) (fun w x y z => @PSemAction w k a x y z fret) |10.
Proof.
repeat red; subst; split; intros; eauto using PSemAction_rewrite_state, PSemAction_rewrite_calls, PSemAction_rewrite_readRegs, PSemAction_rewrite_newRegs.
apply Permutation_sym in H; apply Permutation_sym in H0;apply Permutation_sym in H1;apply Permutation_sym in H2.
eauto using PSemAction_rewrite_state, PSemAction_rewrite_calls, PSemAction_rewrite_readRegs, PSemAction_rewrite_newRegs.
Qed.
End PSemAction_rewrites.
Inductive FullLabel_perm : FullLabel -> FullLabel -> Prop :=
| FL_eq (u u' : RegsT) (cs cs' : MethsT) (rm rm' : RuleOrMeth): u [=] u' -> rm = rm' -> cs [=] cs' -> FullLabel_perm (u, (rm, cs)) (u', (rm', cs')).
Inductive List_FullLabel_perm : list FullLabel -> list FullLabel -> Prop :=
| LFL_eq_nil : List_FullLabel_perm nil nil
| LFL_eq_cons_1 (fl1 fl2 : FullLabel)(ls1 ls2 : list FullLabel): FullLabel_perm fl1 fl2 -> List_FullLabel_perm ls1 ls2 -> List_FullLabel_perm (fl1::ls1) (fl2::ls2)
| LFL_eq_cons_2 (fl1 fl2 fl3 fl4 : FullLabel)(ls1 ls2 : list FullLabel) : FullLabel_perm fl1 fl2 -> FullLabel_perm fl3 fl4 -> List_FullLabel_perm ls1 ls2 -> List_FullLabel_perm (fl1::fl3::ls1) (fl4::fl2::ls2)
| LFL_eq_trans ls1 ls2 ls3 : List_FullLabel_perm ls1 ls2 -> List_FullLabel_perm ls2 ls3 -> List_FullLabel_perm ls1 ls3.
Lemma FullLabel_perm_refl fl :
FullLabel_perm fl fl.
Proof.
destruct fl, p; constructor; auto.
Qed.
Lemma FullLabel_perm_sym fl fl' :
FullLabel_perm fl fl' -> FullLabel_perm fl' fl.
Proof.
induction 1; econstructor; eauto using Permutation_sym.
Qed.
Lemma FullLabel_perm_trans fl fl' fl'' :
FullLabel_perm fl fl' -> FullLabel_perm fl' fl'' -> FullLabel_perm fl fl''.
Proof.
induction 1; intro; inv H2; econstructor;eauto using Permutation_trans.
Qed.
Global Instance FullLabel_perm_Equivalence : Equivalence (@FullLabel_perm) | 10 :={
Equivalence_Reflexive := @FullLabel_perm_refl;
Equivalence_Symmetric := @FullLabel_perm_sym;
Equivalence_Transitive := @FullLabel_perm_trans}.
Lemma List_FullLabel_perm_refl ls :
List_FullLabel_perm ls ls.
Proof.
induction ls; econstructor; eauto using FullLabel_perm_refl.
Qed.
Lemma List_FullLabel_perm_sym ls ls':
List_FullLabel_perm ls ls' -> List_FullLabel_perm ls' ls.
Proof.
induction 1.
- econstructor.
- econstructor 2; eauto using FullLabel_perm_sym.
- econstructor 3; eauto using FullLabel_perm_sym.
- econstructor 4; eauto.
Qed.
Lemma List_FullLabel_perm_trans :
forall (ls ls' ls'' : list FullLabel),
List_FullLabel_perm ls ls' -> List_FullLabel_perm ls' ls'' -> List_FullLabel_perm ls ls''.
Proof.
exact LFL_eq_trans.
Qed.
Global Instance List_FullLabel_perm_Equivalence : Equivalence (@List_FullLabel_perm) | 10 :={
Equivalence_Reflexive := @List_FullLabel_perm_refl;
Equivalence_Symmetric := @List_FullLabel_perm_sym;
Equivalence_Transitive := @List_FullLabel_perm_trans}.
Lemma List_FullLabel_perm_in:
forall l l', List_FullLabel_perm l l' ->
forall a,
In a l ->
(exists x,
FullLabel_perm a x /\
In x l').
Proof.
induction 1.
- contradiction.
- intros; destruct H1.
+ subst.
exists fl2; repeat split;[|left]; auto.
+ specialize (IHList_FullLabel_perm _ H1); dest.
exists x; split;[|right]; auto.
- intros; destruct H2;[|destruct H2]; subst.
+ exists fl2; repeat split;[|right;left];auto.
+ exists fl4; repeat split;[|left];auto.
+ specialize (IHList_FullLabel_perm _ H2); dest.
exists x; split; [|right; right]; auto.
- intros; specialize (IHList_FullLabel_perm1 _ H1); dest.
specialize (IHList_FullLabel_perm2 _ H3); dest.
exists x0; repeat split; eauto using FullLabel_perm_trans.
Qed.
Lemma List_FullLabel_perm_getRleOrMeth l1 l2:
List_FullLabel_perm l1 l2 ->
(map getRleOrMeth l1) [=] (map getRleOrMeth l2).
Proof.
induction 1; eauto using Permutation_trans.
- inv H; simpl.
econstructor 2; eauto.
- inv H; inv H0; simpl.
rewrite perm_swap; repeat econstructor 2; eauto.
Qed.
Corollary List_FullLabel_perm_InExec_rewrite f l1 l2:
List_FullLabel_perm l1 l2 ->
InExec f l1 ->
InExec f l2.
Proof.
intros; apply List_FullLabel_perm_getRleOrMeth in H.
unfold InExec.
rewrite <- H; assumption.
Qed.
Global Instance List_FullLabel_perm_InExec_rewrite' f:
Proper (List_FullLabel_perm ==> iff) (@InExec f) |10.
Proof.
repeat red; intros; split; intros; eauto using List_FullLabel_perm_InExec_rewrite, List_FullLabel_perm_sym.
Qed.
Lemma Perm_rewrite_List_FullLabel_perm_l l1 l2:
l1 [=] l2 ->
forall l,
List_FullLabel_perm l1 l ->
List_FullLabel_perm l2 l.
Proof.
induction 1.
- intros; assumption.
- intros.
rewrite <- H0.
econstructor 2.
+ reflexivity.
+ eapply IHPermutation.
reflexivity.
- intros.
rewrite <- H.
econstructor 3; reflexivity.
- intros.
rewrite <- H1.
eapply IHPermutation2.
eapply IHPermutation1.
reflexivity.
Qed.
Corollary Perm_rewrite_List_FullLabel_perm l1 l2 l3 l4 :
l1 [=] l2 ->
l3 [=] l4 ->
List_FullLabel_perm l1 l3 ->
List_FullLabel_perm l2 l4.
Proof.
intros.
eauto using Perm_rewrite_List_FullLabel_perm_l, List_FullLabel_perm_sym.
Qed.
Global Instance Perm_rewrite_List_FullLabel_perm' :
Proper (@Permutation FullLabel ==> @Permutation FullLabel ==> iff) (@List_FullLabel_perm) |10.
Proof.
repeat red; split; intros; eauto using Perm_rewrite_List_FullLabel_perm, Permutation_sym.
Qed.
Section Permutation_filter.
Variable A : Type.
Variable f : A -> bool.
Lemma Permutation_filter l l':
l [=] l' -> filter f l [=] filter f l'.
Proof.
induction 1; auto.
- rewrite (filter_app _ (x::nil) l); rewrite (filter_app _ (x::nil) l').
rewrite IHPermutation; reflexivity.
- rewrite (filter_app _ (y::x::nil) l); rewrite (filter_app _ (x::y::nil) l).
apply Permutation_app_tail.
rewrite (filter_app _ (y::nil) (x::nil)); rewrite (filter_app _ (x::nil) (y::nil)).
rewrite (Permutation_app_comm); reflexivity.
- rewrite IHPermutation1; rewrite IHPermutation2; reflexivity.
Qed.
Global Instance Permutation_filter' :
Proper (@Permutation A ==> @Permutation A) (@filter A f) | 10.
Proof.
intro; eauto using Permutation_filter.
Qed.
End Permutation_filter.
Section SubList_rewrites.
Variable A : Type.
Lemma SubList_rewrite (l1 l2 l3 l4 : list A):
l1 [=] l3 -> l2 [=] l4 -> SubList l1 l2 -> SubList l3 l4.
Proof.
unfold SubList; intros.
rewrite <- H0.
apply (H1 x).
rewrite H.
assumption.
Qed.
Global Instance SubList_rewrite' :
Proper (@Permutation A ==> @Permutation A ==> iff) (@SubList A) | 10.
repeat red; intros; split; eauto using SubList_rewrite, Permutation_sym.
Qed.
End SubList_rewrites.
Lemma List_FullLabel_perm_InCall_rewrite f l1 l2:
List_FullLabel_perm l1 l2 ->
InCall f l1 ->
InCall f l2.
Proof.
induction 1; auto.
- assert (fl1::ls1 =[fl1]++ls1); auto; rewrite H1; clear H1.
assert (fl2::ls2 = [fl2]++ls2); auto; rewrite H1; clear H1.
repeat rewrite InCall_app_iff; intro.
destruct H1; auto.
left; unfold InCall in *; dest.
exists fl2; simpl; split; auto.
inv H; simpl in *.
destruct H1;[subst|contradiction].
rewrite <- H5; assumption.
- assert (fl1::fl3::ls1 = [fl1]++[fl3]++ls1); auto; rewrite H2; clear H2.
assert (fl4::fl2::ls2 = [fl4]++[fl2]++ls2); auto; rewrite H2; clear H2.
repeat rewrite InCall_app_iff; intro.
destruct H2;[|destruct H2; auto]; unfold InCall in *;dest.
+ right; left; exists fl2; simpl in *; split; auto.
destruct H2;[subst|contradiction].
inv H; simpl in *; rewrite <- H5; assumption.
+ left; exists fl4; simpl in *; split; auto.
destruct H2;[subst|contradiction].
inv H0; simpl in *; rewrite <- H5; assumption.
Qed.
Global Instance List_FullLabel_perm_InCall_rewrite' :
Proper (eq ==> @List_FullLabel_perm ==> iff) (@InCall) | 10.
Proof.
repeat red; intros; split; intro; subst; eauto using List_FullLabel_perm_InCall_rewrite, List_FullLabel_perm_sym.
Qed.
Lemma PSubsteps_Substeps m:
forall (o : RegsT)(l : list FullLabel),
PSubsteps m o l ->
(exists (o' : RegsT)(l' : list FullLabel),
o [=] o' /\
List_FullLabel_perm l l' /\
getKindAttr o' = getKindAttr (getRegisters m) /\
Substeps m o' l').
Proof.
induction 1.
- specialize (getKindAttr_perm_eq _ _ _ _ (Permutation_sym HRegs)) as TMP
; dest;exists x, nil; repeat split; auto; econstructor 1; eauto.
- dest; apply (PSemAction_rewrite_state H0) in HPAction; apply PSemAction_SemAction in HPAction; dest.
exists x, ((x2, (Rle rn, x3))::x0); repeat split; auto;[destruct l|].
+ apply Permutation_nil in HLabel; discriminate.
+ rewrite HLabel.
econstructor; eauto.
econstructor; eauto.
+ econstructor 2; eauto.
* rewrite H4 in HReadsGood; assumption.
* rewrite H5 in HUpdGood; assumption.
* intros;specialize (List_FullLabel_perm_in (List_FullLabel_perm_sym H1) _ H8) as TMP; dest;specialize (HDisjRegs _ H10);
intro; inversion H9; simpl; destruct (HDisjRegs k);[left|right];intro; apply H16.
-- rewrite <- H15; simpl.
rewrite <- H11; assumption.
-- rewrite H5; assumption.
* intros.
specialize (List_FullLabel_perm_in (List_FullLabel_perm_sym H1) _ H8) as TMP; dest;specialize (HNoRle _ H10);
inversion H9;rewrite <- H15 in HNoRle; simpl in *;rewrite H12;assumption.
- dest; apply (PSemAction_rewrite_state H0) in HPAction; apply PSemAction_SemAction in HPAction; dest.
exists x, ((x2, (Meth (fn, existT SignT (projT1 fb) (argV, retV)), x3))::x0); repeat split; auto;[destruct l|].
+ apply Permutation_nil in HLabel; discriminate.
+ rewrite HLabel.
econstructor; eauto.
econstructor; eauto.
+ econstructor 3; eauto.
* rewrite H4 in HReadsGood; assumption.
* rewrite H5 in HUpdGood; assumption.
* intros;specialize (List_FullLabel_perm_in (List_FullLabel_perm_sym H1) _ H8) as TMP; dest;specialize (HDisjRegs _ H10);
intro; inversion H9; simpl; destruct (HDisjRegs k);[left|right];intro; apply H16.
-- rewrite <- H15; simpl.
rewrite <- H11; assumption.
-- rewrite H5; assumption.
Qed.
Lemma Substeps_PSubsteps m:
forall (o : RegsT) (l : list FullLabel),
Substeps m o l -> PSubsteps m o l.
induction 1; subst.
- econstructor 1; rewrite HRegs; reflexivity.
- econstructor 2;[rewrite HRegs|apply HInRules| apply (SemAction_PSemAction HAction)| | | | | | ]; eauto.
- econstructor 3;[rewrite HRegs|apply HInMeths| apply (SemAction_PSemAction HAction)| | | | | ]; eauto.
Qed.
Lemma List_FullLabel_perm_nil l :
List_FullLabel_perm nil l ->
l = nil.
Proof.
intros; remember (@nil FullLabel) as m in H.
induction H; [eauto| | | eauto];discriminate.
Qed.
Lemma List_FullLabel_perm_len l1 l2 :
List_FullLabel_perm l1 l2 ->
length l1 = length l2.
Proof.
induction 1; simpl; eauto using eq_trans.
Qed.
Lemma List_FullLabel_perm_ind_bis :
forall (P : list FullLabel -> list FullLabel -> Prop),
P [] [] ->
(forall (x x' : FullLabel) (l l' : list FullLabel),FullLabel_perm x x' -> List_FullLabel_perm l l' -> P l l' -> P (x :: l) (x' :: l')) ->
(forall (x y x' y' : FullLabel) (l l' : list FullLabel), FullLabel_perm x x' -> FullLabel_perm y y' ->
List_FullLabel_perm l l' -> P l l' -> P (y :: x :: l) (x' :: y' :: l')) ->
(forall l l' l'' : list FullLabel, List_FullLabel_perm l l' -> P l l' -> List_FullLabel_perm l' l'' -> P l' l'' -> P l l'')
-> forall l l' : list FullLabel, List_FullLabel_perm l l' -> P l l'.
Proof.
intros P Hnil Hskip Hswap Htrans.
induction 1; auto.
eapply Htrans with ls2; auto.
Qed.
Lemma List_FullLabel_perm_Add a b l l' : FullLabel_perm a b -> List.Add a l l' -> List_FullLabel_perm (b::l) l'.
Proof.
induction 2; simpl.
- econstructor 2; eauto using FullLabel_perm_sym, List_FullLabel_perm_refl.
- eapply LFL_eq_trans with (x::b::l).
+ econstructor 3; eauto using FullLabel_perm_refl, List_FullLabel_perm_refl.
+ econstructor 2; eauto using FullLabel_perm_refl.
Qed.
Local Ltac FLInvAdd := repeat (match goal with
| H: List.Add ?x _ (_ :: _) |- _ => inversion H; clear H; subst
end).
Lemma List_FullLabel_perm_Add_inv l1 l2:
List_FullLabel_perm l1 l2 -> forall l1' l2' a b, FullLabel_perm a b -> List.Add a l1' l1 -> List.Add b l2' l2 ->
List_FullLabel_perm l1' l2'.
Proof.
revert l1 l2. refine (List_FullLabel_perm_ind_bis _ _ _ _ _).
inversion_clear 2.
- (* skip *)
intros x x' l1 l2 FL_E LFLE IH. intros. FLInvAdd; auto.
+ rewrite <- LFLE.
eapply List_FullLabel_perm_Add; rewrite <- FL_E in H; eauto using FullLabel_perm_trans, FullLabel_perm_sym.
+ rewrite LFLE.
symmetry; eapply List_FullLabel_perm_Add; rewrite H in FL_E; eauto using FullLabel_perm_trans, FullLabel_perm_sym.
+ econstructor 2; eauto.
- (* swap *)
intros x y x' y' l1 l2 FL_E1 FL_E2 PFLE IH. intros. FLInvAdd.
+ try econstructor; eauto using FullLabel_perm_trans, FullLabel_perm_sym.
+ try econstructor; eauto using FullLabel_perm_trans, FullLabel_perm_sym.
+ try econstructor; eauto using FullLabel_perm_trans, FullLabel_perm_sym.
rewrite <- PFLE.
eapply List_FullLabel_perm_Add; rewrite <- FL_E1 in H; eauto.
+ try econstructor; eauto using FullLabel_perm_trans, FullLabel_perm_sym.
+ try econstructor; eauto using FullLabel_perm_trans, FullLabel_perm_sym.
+ assert (y::x::l0 [=] x::y::l0);[constructor| rewrite H0].
econstructor 2; eauto.
rewrite <- PFLE.
eapply List_FullLabel_perm_Add;[rewrite FL_E2;apply H|];eauto.
+ try econstructor; eauto using FullLabel_perm_trans, FullLabel_perm_sym.
rewrite PFLE; symmetry; eapply List_FullLabel_perm_Add;[rewrite <-FL_E2; symmetry; apply H| assumption].
+ assert (x'::y'::l0 [=] y'::x'::l0);[constructor| rewrite H0].
econstructor 2; eauto.
symmetry; rewrite PFLE; eapply List_FullLabel_perm_Add;[symmetry; rewrite <- FL_E1; apply H| assumption].
+ econstructor 3; eauto.
- (* trans *)
intros l1 l l2 PE IH PE' IH' l1' l2' a b FL_E AD1 AD2.
assert (In a l1). rewrite (List.Add_in AD1); left; reflexivity.
specialize (List_FullLabel_perm_in PE _ H) as TMP; dest.
destruct (Add_inv _ _ H1) as (l', AD).
transitivity l'.
+ eapply IH;[apply H0| |];auto.
+ rewrite H0 in FL_E. eapply IH';[apply FL_E| |];auto.
Qed.
Lemma List_FullLabel_perm_cons_inv fl1 fl2 l1 l2:
FullLabel_perm fl1 fl2 ->
List_FullLabel_perm (fl1::l1) (fl2::l2) ->
List_FullLabel_perm l1 l2.
Proof.
intros; eapply List_FullLabel_perm_Add_inv; eauto using List.Add_head.
Qed.
Lemma List_FullLabel_perm_app l1 l2:
List_FullLabel_perm l1 l2 ->
forall l3 l4,
List_FullLabel_perm l3 l4 ->
List_FullLabel_perm (l1++l3) (l2++l4).
Proof.
induction 1; intros.
- repeat rewrite app_nil_r; assumption.
- repeat rewrite <- Permutation_middle; econstructor 2; eauto.
- repeat rewrite <- Permutation_middle; econstructor 3; eauto.
- eapply List_FullLabel_perm_trans; eauto.
apply IHList_FullLabel_perm2; reflexivity.
Qed.
Lemma PSubsteps_List_FullLabel_perm_rewrite m o l :
PSubsteps m o l ->
forall l',
List_FullLabel_perm l l' ->
PSubsteps m o l'.
Proof.
induction 1.
- intros; apply List_FullLabel_perm_nil in H; subst.
econstructor 1; eauto.
- intros; rewrite HLabel in *.
specialize (List_FullLabel_perm_in H0 (u, (Rle rn, cs)) (in_eq _ _)) as TMP; dest.
inversion H1; subst; apply (PSemAction_rewrite_newRegs H6) in HPAction;
apply (PSemAction_rewrite_calls H9) in HPAction; rewrite H6 in HUpdGood.
apply in_split in H2; dest.
assert (l' [=] (u', (Rle rn, cs'))::(x++x0)); subst.
+ symmetry; apply Permutation_cons_app; reflexivity.
+ econstructor 2; eauto;rewrite H3 in H0; apply List_FullLabel_perm_cons_inv in H0; auto; intros.
* specialize (List_FullLabel_perm_in (List_FullLabel_perm_sym H0) _ H2) as TMP; dest.
specialize (HDisjRegs _ H5).
intro; destruct (HDisjRegs k);[left|right];intro; apply H7; inv H4; simpl in *;[rewrite <- H10| rewrite H6]; assumption.
* specialize (List_FullLabel_perm_in (List_FullLabel_perm_sym H0) _ H2) as TMP; dest.
specialize (HNoRle _ H5).
inv H4; simpl in *; assumption.
- intros; rewrite HLabel in *.
specialize (List_FullLabel_perm_in H0 (u, (Meth (fn, existT SignT (projT1 fb) (argV, retV)), cs)) (in_eq _ _)) as TMP; dest.
inversion H1; subst; apply (PSemAction_rewrite_newRegs H6) in HPAction;
apply (PSemAction_rewrite_calls H9) in HPAction; rewrite H6 in HUpdGood.
apply in_split in H2; dest.
assert (l' [=] (u', (Meth (fn, existT SignT (projT1 fb) (argV, retV)), cs'))::(x++x0)); subst.
+ symmetry; apply Permutation_cons_app; reflexivity.
+ econstructor 3; eauto;rewrite H3 in H0; apply List_FullLabel_perm_cons_inv in H0; auto; intros.
* specialize (List_FullLabel_perm_in (List_FullLabel_perm_sym H0) _ H2) as TMP; dest.
specialize (HDisjRegs _ H5).
intro; destruct (HDisjRegs k);[left|right];intro; apply H7; inv H4; simpl in *;[rewrite <- H10| rewrite H6]; assumption.
Qed.
Global Instance PSubsteps_List_FullLabel_perm_rewrite' :
Proper (Logic.eq ==> Logic.eq ==> List_FullLabel_perm ==> iff) (@PSubsteps) | 10.
repeat red; intros; split; intros; subst; eauto using List_FullLabel_perm_sym, PSubsteps_List_FullLabel_perm_rewrite.
Qed.
Lemma List_FullLabel_perm_getRleOrMeth_perm l l' :
List_FullLabel_perm l l' ->
(map getRleOrMeth l) [=] (map getRleOrMeth l').
Proof.
induction 1; auto.
- inv H; simpl; apply perm_skip; assumption.
- inv H; inv H0; simpl.
rewrite perm_swap; repeat apply perm_skip; assumption.
- eauto using Permutation_trans.
Qed.
Lemma List_FullLabel_perm_getNumExecs_rewrite f l l' :
List_FullLabel_perm l l' ->
(getNumExecs f l = getNumExecs f l')%Z.
Proof.
unfold getNumExecs; intros;
rewrite (List_FullLabel_perm_getRleOrMeth_perm H); reflexivity.
Qed.
Lemma List_FullLabel_perm_getNumCalls_rewrite f l l' :
List_FullLabel_perm l l' ->
(getNumCalls f l = getNumCalls f l').
Proof.
induction 1; auto.
- inv H; unfold getNumCalls in *; simpl.
rewrite H3;repeat rewrite getNumFromCalls_app.
rewrite IHList_FullLabel_perm; reflexivity.
- inv H; inv H0; unfold getNumCalls in *; simpl.
repeat rewrite getNumFromCalls_app.
rewrite H4, H5, IHList_FullLabel_perm; ring.
- eauto using eq_trans.
Qed.
Global Instance ListFullLabel_perm_getNumExecs_rewrite' :
Proper (eq ==> List_FullLabel_perm ==> eq) (@getNumExecs) | 10.
Proof.
repeat red; intros; subst; eauto using List_FullLabel_perm_getNumExecs_rewrite.
Qed.
Global Instance ListFullLabel_perm_getNumCalls_rewrite' :
Proper (eq ==> List_FullLabel_perm ==> eq) (@getNumCalls) | 10.
Proof.
repeat red; intros; subst; eauto using List_FullLabel_perm_getNumCalls_rewrite.
Qed.
Lemma List_FullLabel_perm_WeakInclusion l l' :
List_FullLabel_perm l l' ->
WeakInclusion l l'.
Proof.
unfold WeakInclusion.
intros; split; intros.
- unfold getListFullLabel_diff;
rewrite (List_FullLabel_perm_getNumExecs_rewrite _ H),
(List_FullLabel_perm_getNumCalls_rewrite _ H); reflexivity.
- setoid_rewrite (List_FullLabel_perm_getRleOrMeth_perm H); assumption.
Qed.
Lemma MatchingExecCalls_Base_List_FullLabel_perm_rewrite m l l' :
List_FullLabel_perm l l' ->
MatchingExecCalls_Base l m ->
MatchingExecCalls_Base l' m.
Proof.
unfold MatchingExecCalls_Base.
intros; rewrite <-H; apply H0; auto.
Qed.
Lemma MatchingExecCalls_Concat_List_FullLabel_perm_rewrite_1 m l l' l'':
List_FullLabel_perm l l' ->
MatchingExecCalls_Concat l l'' m ->
MatchingExecCalls_Concat l' l'' m.
Proof.
unfold MatchingExecCalls_Concat; intros.
rewrite <-H; apply H0; auto.
rewrite H; assumption.
Qed.
Lemma MatchingExecCalls_Concat_List_FullLabel_perm_rewrite_2 m l l' l'':
List_FullLabel_perm l l' ->
MatchingExecCalls_Concat l'' l m ->
MatchingExecCalls_Concat l'' l' m.
Proof.
unfold MatchingExecCalls_Concat; intros.
rewrite <-H; apply H0; auto.
Qed.
Global Instance MatchingExecCalls_Base_List_FullLabel_perm_rewrite' :
Proper (List_FullLabel_perm ==> Logic.eq ==> iff) (@MatchingExecCalls_Base) | 10.
Proof.
repeat red; intros; split; intros; subst;
eauto using MatchingExecCalls_Base_List_FullLabel_perm_rewrite, List_FullLabel_perm_sym.
Qed.
Global Instance MatchingExecCalls_Concat_List_FullLabel_perm_rewrite' :
Proper (List_FullLabel_perm ==> List_FullLabel_perm ==> Logic.eq ==> iff) (@MatchingExecCalls_Concat) | 10.
Proof.
repeat red; intros; split; intros; subst;
eauto using MatchingExecCalls_Concat_List_FullLabel_perm_rewrite_1,
MatchingExecCalls_Concat_List_FullLabel_perm_rewrite_2, List_FullLabel_perm_sym.
Qed.
Lemma PStep_Step m o l:
PStep m o l ->
(exists o' l',
o [=] o' /\
getKindAttr o' = getKindAttr (getAllRegisters m) /\
List_FullLabel_perm l l' /\
Step m o' l').
Proof.
induction 1.
- apply PSubsteps_Substeps in HPSubsteps; dest.
exists x, x0.
repeat split; auto.
econstructor 1; auto.
rewrite <- H0; assumption.
- dest.
exists x, x0; repeat split; eauto.
econstructor 2; auto.
intros; unfold getListFullLabel_diff in *.
rewrite <-H2; apply HHidden; auto.
- dest.
exists (x1++x), (x2++x0).
repeat split.
+ rewrite HRegs, H5, H1; reflexivity.
+ simpl; repeat rewrite map_app; rewrite H2, H6; reflexivity.
+ rewrite HLabels.
eapply List_FullLabel_perm_app; eauto.
+ econstructor 3; eauto.
* rewrite <- H7; rewrite <- H3; assumption.
* rewrite <- H7; rewrite <- H3; assumption.
* intros.
apply (List_FullLabel_perm_in (List_FullLabel_perm_sym H7)) in H9;
apply (List_FullLabel_perm_in (List_FullLabel_perm_sym H3)) in H10; dest.
specialize (HNoRle _ _ H12 H11).
inv H9; inv H10; subst; simpl in *; assumption.
Qed.
Lemma Step_PStep m o l:
Step m o l ->
PStep m o l.
Proof.
induction 1; econstructor; subst;eauto.
- apply Substeps_PSubsteps; assumption.
Qed.
Inductive List_FullLabel_perm_Lists : (list (list FullLabel)) -> (list (list FullLabel)) -> Prop :=
|PermutationEquiv_nil : List_FullLabel_perm_Lists nil nil
|PermutationEquiv_cons ls ls' l l' : List_FullLabel_perm_Lists ls ls'
-> List_FullLabel_perm l l'
-> List_FullLabel_perm_Lists (l::ls) (l'::ls').
Lemma List_FullLabel_perm_Lists_refl l :
List_FullLabel_perm_Lists l l.
Proof.
induction l; econstructor; eauto.
reflexivity.
Qed.
Lemma List_FullLabel_perm_Lists_sym l l' :
List_FullLabel_perm_Lists l l' -> List_FullLabel_perm_Lists l' l.
Proof.
induction 1; econstructor; eauto using List_FullLabel_perm_sym.
Qed.
Lemma List_FullLabel_perm_Lists_trans l:
forall l' l'',
List_FullLabel_perm_Lists l l' ->
List_FullLabel_perm_Lists l' l'' ->
List_FullLabel_perm_Lists l l''.
Proof.
induction l; eauto; intros; inv H; inv H0.
- constructor.
- constructor.
+ eapply IHl; eauto.
+ rewrite H5; assumption.
Qed.
Lemma List_FullLabel_perm_Lists_len l l' :
List_FullLabel_perm_Lists l l' ->
length l = length l'.
Proof.
induction 1;[|simpl; rewrite IHList_FullLabel_perm_Lists]; reflexivity.
Qed.
Lemma List_FullLabel_perm_Lists_WeakInclusions l l' :
List_FullLabel_perm_Lists l l' ->
WeakInclusions l l'.
Proof.
induction 1.
- apply WeakInclusionsRefl.
- econstructor; eauto.
apply List_FullLabel_perm_WeakInclusion in H0; assumption.
Qed.
Lemma RegInit_generalized_list x:
forall o' l,
o' [=] x ->
map fst l = map fst x ->
(forall (o : string * {x : FullKind & fullType type x}) (r : string * {x : FullKind & option (ConstFullT x)}),
In o o' ->
In r l ->
fst o = fst r ->
exists pf : projT1 (snd o) = projT1 (snd r),
match projT2 (snd r) with
| Some x => match pf in (_ = Y) return (fullType type Y) with
| eq_refl => projT2 (snd o)
end = evalConstFullT x
| None => True
end) ->
Forall2
(fun (o'0 : string * {x : FullKind & fullType type x}) (r : string * {x0 : FullKind & option (ConstFullT x0)}) =>
fst o'0 = fst r /\
(exists pf : projT1 (snd o'0) = projT1 (snd r),
match projT2 (snd r) with
| Some x0 => match pf in (_ = Y) return (fullType type Y) with
| eq_refl => projT2 (snd o'0)
end = evalConstFullT x0
| None => True
end)) x l.
Proof.
induction x; intros; inv H0.
- apply map_eq_nil in H3; rewrite H3.
constructor.
- destruct l; inv H3.
constructor.
+ split; [symmetry; assumption|].
apply (H1 a p (Permutation_in _ (Permutation_sym H) (in_eq _ _)) (in_eq _ _) (eq_sym H2)).
+ eapply IHx; eauto.
intros.
eapply H1;[rewrite H | |]; try right; assumption.
Qed.
Lemma keys_establish_order (A B : Type):
forall (l : list (A*B)),
NoDup (map fst l) ->
forall (l' : list (A*B)),
l [=] l' ->
(map fst l = map fst l') ->
l = l'.
Proof.
induction l; eauto; intros.
- apply Permutation_nil in H0; rewrite H0; reflexivity.
- destruct l';[ symmetry in H0; apply Permutation_nil in H0; inv H0|].
simpl in *; inv H1; inv H.
specialize (Permutation_in _ H0 (in_eq _ _)) as T; destruct T.
+ subst.
apply Permutation_cons_inv in H0.
rewrite (IHl H6 _ H0 H4); reflexivity.
+ apply False_ind.
apply H5; rewrite H4.
apply (in_map fst) in H; assumption.
Qed.
Lemma List_FullLabel_perm_fst l l':
List_FullLabel_perm l l' ->
forall a,
In a (map fst l) ->
(exists a',
a [=] a' /\
In a' (map fst l')).
Proof.
induction 1; simpl; eauto; intros.
- destruct H1; subst.
+ inv H; simpl in *.
exists u'; split; eauto.
+ specialize (IHList_FullLabel_perm a H1); dest.
exists x; split; eauto.
- repeat destruct H2; subst.
+ inv H.
exists u'; split; eauto.
+ inv H0.
exists u'; split; eauto.
+ specialize (IHList_FullLabel_perm a H2); dest.
exists x; split; eauto.
- specialize (IHList_FullLabel_perm1 a H1); dest.
specialize (IHList_FullLabel_perm2 x H3); dest.
exists x0; split; eauto using Permutation_trans.
Qed.
Lemma Forall2_RegInit_keymatch x :