-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathnibridge.v
5390 lines (5308 loc) · 199 KB
/
nibridge.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 id_and_loc augmented mmemory mimperative language mlattice bridge types bijection Coq.Program.Tactics Arith Omega tactics low_equivalence nibridge_helper decision preservation List.
Require Import LibTactics InductionPrinciple Coq.Program.Equality Coq.Program.Basics.
Import FunctionalExtensionality.
Set Implicit Arguments.
Module NIBridge (L : Lattice) (M: Memory L).
Module NIBridgeHelper := NIBridgeHelper L M.
Import NIBridgeHelper Preserve LowEq B Aug Imp TDefs M T MemProp LatProp Lang L.
Theorem ni_bridge_num:
forall n ℓ, ni_bridge n ℓ.
Proof.
intros.
induction n using strongind.
{
(* n = 0 *)
unfold ni_bridge.
intros.
revert Σ1 Σ2 Σ1' Σ3 Σ3' H H0 H1 H2 H3 H4 H5 H6 H7 H8 H9 H10.
revert pc pc1' pc2'' pc_end.
revert φ Φ.
revert c' c2 c2' H11 H12.
revert m1 m2 s1 s2'' s1' w1' h1 h2 w1 w2''.
revert t t' t2 g2''.
revert ev1 ev2.
revert n2.
induction c; intros; subst.
(* Skip *)
{
invert_bridge_step_with_steps 0.
- invert_low_event_step.
invert_event_step.
+ invert_low_event.
+ invert_low_event.
- unfold is_stop_config, cmd_of in *; subst.
invert_high_event_step.
invert_event_step.
+ super_destruct; subst.
* invert_sem_step.
invert_taint_eq.
invert_taint_eq_cmd.
exists EmptyEvent 0 φ Φ s1 w1; exists Σ2.
_apply skip_bridge_properties in *.
super_destruct; subst.
splits*.
{ unfolds.
splits*. }
{ splits; eauto 2.
- unfolds.
intros.
splits.
+ intros.
eapply low_gc_trans_preserves_high; eauto 2.
eapply H2; eauto.
+ intros.
assert (high ℓ s2'' w1' loc).
{
eapply high_iff; reflexivity || eauto 2.
}
eapply H2; eauto.
- remember_simple (low_gc_trans_preserves_taint_eq H5 H7 H22).
rewrite <- (compose_id_right Φ).
eapply taint_eq_trans with (m' := s2'') (h' := w1').
+ repeat invert_wf_aux; eauto 2.
+ unfolds.
splits*.
+ unfold taint_eq in *; super_destruct'; subst.
splits*.
}
}
(* Stop *)
{
invert_bridge_step_with_steps 0.
- exfalso; eauto 2.
- unfold high_event_step in *.
super_destruct;
subst;
invert_event_step; exfalso; eauto using stop_takes_no_step.
}
(* Assign *)
{
invert_bridge_step_with_steps 0.
- invert_low_event_step.
invert_event_step.
+ assert (wellformed_aux Γ Σ1' ⟨ Stop, pc1', m2, h2, t2 ⟩ pc_end).
{
eapply preservation; eauto.
}
assert (wellformed_aux Γ Σ3' ⟨c2', pc2'', s2'', w2'', g2''⟩ pc_end) by eauto 2.
invert_taint_eq.
invert_taint_eq_cmd.
_apply assign_bridge_properties in *.
super_destruct; subst.
assert (wellformed_aux Γ Σ3' ⟨i ::= e, pc2'', s1', w2'', g2'' - 1⟩ pc_end) by eauto 2.
invert_sem_step.
rewrite_inj.
repeat invert_wf_aux.
assert ((i ::= e) <> Stop) by congruence.
assert ((i ::= e) <> TimeOut) by congruence.
do 4 specialize_gen.
do 2 invert_wt_cmd.
invert_lifted.
rewrite_inj.
invert_bridge_step_with_steps 0.
* invert_low_event_step.
invert_event_step.
invert_sem_step.
rewrite_inj.
match goal with
[H: S (?X - 1) = ?X |- _] => clear H
end.
destruct_prod_join_flowsto.
destruct ε as [ℓ' ι'].
invert_low_event.
assert (taint_eq_mem (inverse Φ) Γ s1' s1) by eauto 2 using taint_eq_mem_sym.
assert (exists v2, eval s1 e = Some v2 /\ val_taint_eq (inverse Φ) (SecType τ (ℓ', ι')) v1 v2) by eauto 2.
super_destruct; subst.
rename v2 into u.
destruct_prod_join_flowsto.
assert (val_low_eq ℓ (SecType τ (ℓ1, ι0)) v0 u φ)
by (invert_state_low_eq; eauto 3).
remember_simple (filter_bijection (low ℓ Γ Σ1' (extend_memory i v0 m1) h2) (low_dec ℓ Γ Σ1' (extend_memory i v0 m1) h2) φ).
remember_simple (filter_bijection
(high ℓ (extend_memory i u s1) w1)
(high_dec ℓ (extend_memory i u s1) w1) Φ).
super_destruct; subst.
rename ψ into Ψ.
rename ψ0 into ψ.
exists (AssignEvent ℓ1 i u).
exists 0.
exists ψ.
exists Ψ.
exists (extend_memory i u s1).
exists w1.
exists Σ2.
assert (state_low_eq ℓ ψ (m1 [i → v0]) h2
(s1 [i → u]) w1 Γ Σ1' Σ2).
{
eapply state_low_eq_extend_memory; intros; subst; eauto 2.
- intros; subst.
assert (exists loc, v0 = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits~.
intros.
eapply eval_low_implies_low_reach; eauto 3.
- intros; subst.
assert (exists loc, u = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits~.
intros.
eapply eval_low_implies_low_reach; eauto.
- subst; eauto 2.
- subst; eauto 2.
- eapply wf_tenv_extend.
+ eauto.
+ eauto.
+ intros; subst.
eauto 2.
+ intros; subst.
eauto 2.
}
assert (wf_bijection ℓ ψ Γ Σ1' (m1 [i → v0]) h2).
{
invert_low_event.
destruct ε0 as [ℓ_e ι_e].
eapply wf_bijection_extend_mem1; eauto 2.
- intros; subst; eauto 2.
- intros; subst.
assert (exists loc, v0 = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits~.
intros.
assert (wf_type bot (SecType (Array τ0 ℓ'0) (ℓ', ι'))) by eauto 2.
invert_wf_type.
assert (exists x, memory_lookup m1 x = Some (ValLoc loc) /\ e = Var x)
by eauto 2.
super_destruct; subst.
rewrite_inj.
do 2 invert_var_typing.
rewrite_inj.
assert (ℓ_e ⊑ ℓ1) by eauto 2.
eauto 3.
}
splits~.
{
eapply bridge_low_num.
splits~.
eauto.
}
{ invert_low_event.
constructor.
- splits*.
- intros _.
constructor.
repeat destruct_prod_join_flowsto.
repeat invert_state_low_eq.
invert_val_low_eq.
+ exfalso; eauto.
+ exfalso; eauto.
+ eauto.
+ assert (wf_type bot (SecType (Array τ0 ℓ_p) (ℓ1, ι0))) by eauto 2.
invert_wf_type.
assert (low ℓ Γ Σ1' (m1 [i → ValLoc l1]) h2 l1).
{
eapply LowReachable.
eauto 3.
}
eauto 3.
}
{
eapply TaintEqEventAssign.
- eauto.
- invert_val_taint_eq; eauto 3.
assert (left Φ loc' = Some loc) by (destruct Φ; eauto).
assert (high ℓ (s1 [i → ValLoc loc'])
w1 loc') by eauto 3.
assert (left Ψ loc' = Some loc) by eauto 2.
eauto.
}
assert (taint_eq ℓ Ψ Γ Σ2 Σ3' Stop Stop (s1 [i → u]) w1
(s1' [i → v1]) w2'').
{
assert (taint_eq ℓ (identity_bijection loc) Γ Σ3' Σ3' (i ::= e) (i ::= e) s1' w1' s1' w2'').
{
eauto 3 using low_gc_trans_preserves_taint_eq.
}
unfold taint_eq in *; super_destruct'; subst.
splits~.
- eapply taint_eq_mem_extend; eauto 4.
- eapply taint_eq_reach_extend_mem; eauto 2.
+ assert (taint_eq_reach (identity_bijection loc) s1' w1' s1' w2'')
by eauto 2.
rewrite <- (compose_id_right Φ).
eapply taint_eq_reach_trans; eauto.
+ rewrite <- (compose_id_right Φ).
eapply taint_eq_heap_trans; eauto 2.
+ eapply low_gc_trans_preserves_wf_taint_bijection with (pc := pc_end); eauto.
+ eauto 4.
+ intros; subst; eauto 2.
+ intros; subst; eauto 2.
- eapply taint_eq_heap_extend_mem.
+ eapply taint_eq_heap_trans; eauto 2.
+ eauto.
+ intros; subst; eauto 2.
+ intros; subst; eauto 2.
+ intros; subst.
assert (exists loc, u = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits; eauto 3.
+ intros; subst.
assert (exists loc, v1 = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits; eauto 3.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eapply low_gc_trans_preserves_wf_taint_bijection with (pc := pc_end); eauto 2.
+ rewrite -> compose_id_right.
eauto.
- eapply taint_eq_heap_size_trans; eauto 2.
- repeat invert_wf_aux.
eapply taint_eq_heap_domain_eq_extend_mem with (Φ := bijection.bijection_compose Φ (identity_bijection loc)); eauto 2.
+ eapply taint_eq_heap_domain_eq_trans; eauto 2.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eapply low_gc_trans_preserves_wf_taint_bijection
with (pc := pc_end); eauto.
+ eapply taint_eq_mem_trans; eauto 2.
+ eapply taint_eq_heap_trans; eauto 2.
+ eapply taint_eq_reach_trans; eauto 2.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eapply low_gc_trans_preserves_wf_taint_bijection
with (pc := pc_end); eauto.
+ intros; subst.
assert (exists loc, u = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits; eauto 3.
+ intros; subst; eauto 3.
+ intros; subst.
assert (exists loc, v1 = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits; eauto 3.
+ intros; subst; eauto 3.
+ rewrite -> compose_id_right.
eauto.
- eapply taint_eq_stenv_extend_mem; eauto 2.
}
splits.
{
eapply wf_bijection_extend_mem2; eauto 3.
- intros; subst.
eauto 2.
- intros; subst.
assert (exists loc, u = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits~.
destruct ε0 as [ℓ_e ι_e].
intros.
assert (wf_type bot (SecType (Array τ0 ℓ'0) (ℓ', ι'))) by eauto 2.
invert_wf_type.
assert (exists x, memory_lookup s1 x = Some (ValLoc loc) /\ e = Var x)
by eauto 2.
super_destruct; subst.
rewrite_inj.
do 2 invert_var_typing.
rewrite_inj.
assert (ℓ_e ⊑ ℓ1) by eauto 2.
eauto 3.
}
{
eapply wf_taint_bijection_extend_mem1; intros; subst; eauto 2.
}
{
invert_taint_eq.
eapply wf_taint_bijection_extend_mem2 with (m := s1) (h := w1) (Φ := Φ); eauto 2.
- rewrite <- (compose_id_right Φ).
eapply taint_eq_reach_trans.
+ eauto.
+ eapply gc_trans_preserves_taint_eq_reach; eauto.
- rewrite <- (compose_id_right Φ).
eapply taint_eq_heap_trans.
+ eapply gc_trans_preserves_taint_eq_reach; eauto 2.
+ eauto.
+ eauto.
+ eauto.
+ eapply low_gc_trans_preserves_taint_eq_heap; eauto 2.
+ eapply low_gc_trans_preserves_taint_eq_heap_domain_eq with (pc := pc_end); eauto 2.
- rewrite <- (compose_id_right Φ).
eapply taint_eq_heap_domain_eq_trans; eauto 2.
- eapply low_gc_trans_preserves_wf_taint_bijection with (pc := pc_end); eauto 2.
- intros; subst; eauto 3.
- intros; subst; eauto 3.
- eauto 4.
- intros; subst.
assert (exists loc, v1 = ValLoc loc) by eauto 3.
super_destruct'; subst.
eexists; splits; eauto 2.
}
{ eauto. }
* invert_high_event_step.
invert_event_step.
rewrite_inj.
invert_low_event.
assert (~ ℓ1 ⊑ ℓ) by eauto.
contradiction.
+ invert_low_event.
- invert_high_event_step.
unfold is_stop_config, cmd_of in *; subst.
invert_event_step.
+ assert (wellformed_aux Γ Σ1' ⟨ Stop, pc1', m2, h2, t2 ⟩ pc_end).
{
eapply preservation; eauto.
}
assert (wellformed_aux Γ Σ3' ⟨c2', pc2'', s2'', w2'', g2''⟩ pc_end) by eauto 2.
invert_taint_eq.
invert_taint_eq_cmd.
_apply assign_bridge_properties in *.
super_destruct; subst.
assert (wellformed_aux Γ Σ3' ⟨i ::= e, pc2'', s1', w2'', g2'' - 1⟩ pc_end) by eauto 2.
invert_sem_step.
rewrite_inj.
repeat invert_wf_aux.
assert ((i ::= e) <> Stop) by congruence.
assert ((i ::= e) <> TimeOut) by congruence.
do 4 specialize_gen.
do 2 invert_wt_cmd.
invert_lifted.
rewrite_inj.
invert_bridge_step_with_steps 0.
* invert_low_event_step.
invert_event_step.
rewrite_inj.
invert_low_event.
assert (~ ℓ1 ⊑ ℓ) by eauto.
contradiction.
* invert_high_event_step.
invert_event_step.
rewrite_inj.
assert (~ ℓ1 ⊑ ℓ) by eauto.
invert_sem_step.
rewrite_inj.
match goal with
[H: S (?X - 1) = ?X |- _] => clear H
end.
destruct_prod_join_flowsto.
destruct ε as [ℓ' ι'].
assert (taint_eq_mem (inverse Φ) Γ s1' s1) by eauto 2 using taint_eq_mem_sym.
assert (exists v2, eval s1 e = Some v2 /\ val_taint_eq (inverse Φ) (SecType τ (ℓ', ι')) v1 v2) by eauto 2.
super_destruct; subst.
rename v2 into u.
destruct_prod_join_flowsto.
assert (val_low_eq ℓ (SecType τ (ℓ1, ι0)) v0 u φ)
by (invert_state_low_eq; eauto 3).
remember_simple (filter_bijection (low ℓ Γ Σ1' (extend_memory i v0 m1) h2) (low_dec ℓ Γ Σ1' (extend_memory i v0 m1) h2) φ).
remember_simple (filter_bijection
(high ℓ (extend_memory i u s1) w1)
(high_dec ℓ (extend_memory i u s1) w1) Φ).
super_destruct; subst.
rename ψ into Ψ.
rename ψ0 into ψ.
exists (AssignEvent ℓ1 i u).
exists 0.
exists ψ.
exists Ψ.
exists (extend_memory i u s1).
exists w1.
exists Σ2.
assert (state_low_eq ℓ ψ (m1 [i → v0]) h2
(s1 [i → u]) w1 Γ Σ1' Σ2).
{
eapply state_low_eq_extend_memory; eauto 2.
- intros; subst.
assert (exists loc, v0 = ValLoc loc) by eauto.
super_destruct; subst.
exists loc.
splits~.
intros.
assert (~ ℓ1 ⊑ ℓ) by eauto.
contradiction.
- intros; subst.
assert (exists loc, u = ValLoc loc) by eauto.
super_destruct; subst.
exists loc.
splits~.
intros.
assert (~ ℓ1 ⊑ ℓ) by eauto.
contradiction.
- intros; subst; eauto 2.
- intros; subst; eauto 2.
- eapply wf_tenv_extend.
+ eauto.
+ eauto.
+ intros; subst.
eauto 2.
+ intros; subst.
eauto 2.
}
assert (wf_bijection ℓ ψ Γ Σ1' (m1 [i → v0]) h2).
{
eapply wf_bijection_extend_mem1; eauto 2.
- intros; subst; eauto 2.
- intros; subst.
assert (exists loc, v0 = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits~.
intro.
exfalso; eauto 3.
}
splits~.
{
eapply bridge_stop_num; eauto.
constructor.
- eapply EventSemStep; eauto.
- unfolds.
intro.
invert_low_event.
eauto.
}
{ unfolds.
splits~.
- invert_high_event.
splits; intros; invert_low_event; exfalso; eauto.
- intros; invert_low_event; exfalso; eauto.
}
{
eapply TaintEqEventAssign.
- eauto.
- invert_val_taint_eq; eauto 3.
assert (left Φ loc' = Some loc) by (destruct Φ; eauto).
assert (high ℓ (s1 [i → ValLoc loc'])
w1 loc') by eauto 3.
assert (left Ψ loc' = Some loc) by eauto 2.
eauto.
}
{
assert (taint_eq ℓ Ψ Γ Σ2 Σ3' Stop Stop (s1 [i → u]) w1
(s1' [i → v1]) w2'').
{
assert (taint_eq ℓ (identity_bijection loc) Γ Σ3' Σ3' (i ::= e) (i ::= e) s1' w1' s1' w2'').
{
eauto 3 using low_gc_trans_preserves_taint_eq.
}
unfold taint_eq in *; super_destruct'; subst.
splits~.
- eapply taint_eq_mem_extend; eauto 4.
- eapply taint_eq_reach_extend_mem; eauto 2.
+ assert (taint_eq_reach (identity_bijection loc) s1' w1' s1' w2'')
by eauto 2.
rewrite <- (compose_id_right Φ).
eapply taint_eq_reach_trans; eauto.
+ rewrite <- (compose_id_right Φ).
eapply taint_eq_heap_trans; eauto 2.
+ eapply low_gc_trans_preserves_wf_taint_bijection with (pc := pc_end); eauto.
+ eauto 4.
+ intros; subst; eauto 2.
+ intros; subst; eauto 2.
- eapply taint_eq_heap_extend_mem.
+ eapply taint_eq_heap_trans; eauto 2.
+ eauto.
+ intros; subst; eauto 2.
+ intros; subst; eauto 2.
+ intros; subst.
assert (exists loc, u = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits; eauto 3.
+ intros; subst.
assert (exists loc, v1 = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits; eauto 3.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eapply low_gc_trans_preserves_wf_taint_bijection with (pc := pc_end); eauto 2.
+ rewrite -> compose_id_right.
eauto.
- eapply taint_eq_heap_size_trans; eauto 2.
- repeat invert_wf_aux.
eapply taint_eq_heap_domain_eq_extend_mem with (Φ := bijection.bijection_compose Φ (identity_bijection loc)); eauto 2.
+ eapply taint_eq_heap_domain_eq_trans; eauto 2.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eapply low_gc_trans_preserves_wf_taint_bijection
with (pc := pc_end); eauto.
+ eapply taint_eq_mem_trans; eauto 2.
+ eapply taint_eq_heap_trans; eauto 2.
+ eapply taint_eq_reach_trans; eauto 2.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eauto.
+ rewrite -> compose_id_right.
eapply low_gc_trans_preserves_wf_taint_bijection
with (pc := pc_end); eauto.
+ intros; subst.
assert (exists loc, u = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits; eauto 3.
+ intros; subst; eauto 3.
+ intros; subst.
assert (exists loc, v1 = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits; eauto 3.
+ intros; subst; eauto 3.
+ rewrite -> compose_id_right.
eauto.
- eapply taint_eq_stenv_extend_mem; eauto 2.
}
splits.
{
eapply wf_bijection_extend_mem2; eauto 3.
- intros; subst; eauto 2.
- intros; subst.
assert (exists loc, u = ValLoc loc) by eauto 2.
super_destruct; subst.
exists loc.
splits~.
intro; exfalso; eauto 3.
}
{
eapply wf_taint_bijection_extend_mem1; intros; subst; eauto 2.
}
{
invert_taint_eq.
eapply wf_taint_bijection_extend_mem2 with (m := s1) (h := w1) (Φ := Φ); eauto 2.
- rewrite <- (compose_id_right Φ).
eapply taint_eq_reach_trans.
+ eauto.
+ eapply gc_trans_preserves_taint_eq_reach; eauto.
- rewrite <- (compose_id_right Φ).
eapply taint_eq_heap_trans.
+ eapply gc_trans_preserves_taint_eq_reach; eauto 2.
+ eauto.
+ eauto.
+ eauto.
+ eapply low_gc_trans_preserves_taint_eq_heap; eauto 2.
+ eapply low_gc_trans_preserves_taint_eq_heap_domain_eq with (pc := pc_end); eauto 2.
- rewrite <- (compose_id_right Φ).
eapply taint_eq_heap_domain_eq_trans; eauto 2.
- eapply low_gc_trans_preserves_wf_taint_bijection with (pc := pc_end); eauto 2.
- intros; subst; eauto 3.
- intros; subst; eauto 3.
- eauto 4.
- intros; subst.
assert (exists loc, v1 = ValLoc loc) by eauto 3.
super_destruct'; subst.
eexists; splits; eauto 2.
}
{ eauto. }
}
}
(* If *)
{
invert_bridge_step_with_steps 0.
- invert_low_event_step.
invert_event_step; invert_low_event.
- invert_high_event_step.
exfalso.
eauto 2.
}
(* While *)
{
invert_bridge_step_with_steps 0.
- invert_low_event_step.
invert_event_step; invert_low_event.
- invert_high_event_step.
unfold is_stop_config, cmd_of in *; subst.
invert_event_step.
* super_destruct; try invert_ends_with_backat.
subst.
invert_sem_step.
exists EmptyEvent 0 φ Φ s1 w1; exists Σ2.
assert (eval s1 e = Some (ValNum 0)).
{
repeat invert_wf_aux.
repeat specialize_gen.
invert_wt_cmd.
assert (ℓ0 ⊑ ℓ) by eauto 2.
assert (exists u, onvals (left φ) (ValNum 0) = Some u /\ eval s1 e = Some u)
by eauto 2.
super_destruct'; subst.
unfold onvals in *.
injects.
eauto.
}
invert_taint_eq.
invert_taint_eq_cmd.
assert (eval s1' e = Some (ValNum 0)).
{
repeat invert_wf_aux.
repeat specialize_gen.
invert_wt_cmd.
assert (exists v2,
eval s1' e = Some v2 /\ val_taint_eq Φ (SecType Int (ℓ0, ∘)) (ValNum 0) v2) by eauto 2.
super_destruct'; subst.
invert_val_taint_eq.
eauto.
}
splits; eauto 2.
{
_apply while_bridge_properties in *.
super_destruct; subst.
- eauto.
- congruence.
}
{
_apply while_bridge_properties in *.
super_destruct; subst.
- eauto.
- congruence.
}
{
splits*.
}
{
_apply while_bridge_properties in *.
super_destruct; subst.
- eauto.
- congruence.
}
splits; eauto 2.
{
_apply while_bridge_properties in *.
super_destruct; subst.
- eapply low_gc_trans_preserves_wf_taint_bijection; eauto.
- congruence.
}
{
_apply while_bridge_properties in *.
super_destruct; subst.
- remember_simple (low_gc_trans_preserves_taint_eq H5 H7 H26).
unfold taint_eq in *; super_destruct.
splits.
+ eauto.
+ eauto.
+ rewrite <- (compose_id_right Φ).
eapply taint_eq_reach_trans; eauto.
+ rewrite <- (compose_id_right Φ).
eapply taint_eq_heap_trans; eauto.
* repeat invert_wf_aux; eauto.
+ eapply taint_eq_heap_size_trans; eauto.
+ rewrite <- (compose_id_right Φ).
eapply taint_eq_heap_domain_eq_trans; eauto.
+ rewrite <- (compose_id_right Φ).
eapply taint_eq_stenv_trans; eauto.
- congruence.
}
}
(* Sequential composition *)
{
assert (H8' := H8).
match goal with
[H: context[bridge_step_num] |- _] => assert (H' := H); eapply about_seq_bridge_step in H; eauto 2
end.
match goal with
[H: (exists _, _ ) \/ (exists _, _ ) |- _] =>
destruct H; super_destruct'; try omega
end.
subst.
assert (c1 <> Stop).
{
intro; subst.
invert_wf_aux.
repeat specialize_gen.
invert_wt_cmd.
match goal with
[H: wt_aux _ _ Stop _ |- _] =>
inverts H
end.
}
assert (c2 <> Stop).
{
intro; subst.
invert_wf_aux.
repeat specialize_gen.
invert_wt_cmd.
match goal with
[H: wt_aux _ _ Stop _ |- _] =>
inverts H
end.
}
invert_taint_eq.
invert_taint_eq_cmd.
assert (exists pc'',
wellformed_aux Γ Σ1 ⟨ c1, pc, m1, h1, t ⟩ pc'') by eauto 2.
assert (exists pc'',
wellformed_aux Γ Σ2 ⟨ c1, pc, s1, w1, t ⟩ pc'') by eauto 2.
assert (exists pc'',
wellformed_aux Γ Σ3 ⟨ c1'0, pc, s1', w1', t' ⟩ pc'') by eauto 2.
super_destruct'; subst.
assert (taint_eq ℓ Φ Γ Σ2 Σ3 c1 c1'0 s1 w1 s1' w1').
{
unfolds.
splits*.
}
assert (wellformed_aux Γ Σ3' ⟨c2', pc2'', s2'', w2'', g2''⟩ pc_end) by eauto 2.
match goal with
[H: context[bridge_step_num] |- _] =>
eapply about_seq_bridge_step in H; eauto 2
end.
super_destruct; subst.
- assert (c1 <> TimeOut).
{
intro; subst.
repeat invert_wf_aux.
repeat specialize_gen.
match goal with
[H: wt_aux _ _ (TimeOut ;; _) _ |- _] =>
inverts H
end.
invert_wt_timeout.
}
assert (pc''1 = pc''0).
{
repeat invert_wf_aux.
repeat specialize_gen.
eapply deterministic_typing; eauto 2.
}
subst.
assert (c1' <> TimeOut).
{
intro; subst.
repeat specialize_gen.
subst.
assert (wellformed_aux Γ Σ1' ⟨TIMEOUT;; c2, pc1', m2, h2, t2⟩ pc_end) by eauto 2.
invert_wf_aux.
repeat specialize_gen.
invert_wt_cmd.
invert_wt_timeout.
}
assert (c1'0 <> Stop).
{
repeat invert_wf_aux.
repeat specialize_gen.
intro; subst.
invert_wt_cmd; invert_wt_stop.
}
assert (c1'0 <> TimeOut).
{
repeat invert_wf_aux.
repeat specialize_gen.
intro; subst.
invert_wt_cmd; invert_wt_timeout.
}
assert (c1'1 <> TimeOut).
{
intro; subst.
assert (TimeOut <> Stop) by congruence.
specialize_gen.
subst.
invert_wf_aux.
repeat specialize_gen.
invert_wt_cmd.
invert_wt_timeout.
}
assert (pc'' = pc''0).
{
repeat invert_wf_aux.
repeat specialize_gen.
remember_simple (taint_eq_cmd_implies_same_type H27 H50).
eauto 2.
}
subst.
remember_simple (IHc1 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ H35 H38 _ _ _ _ _ _ _ _ _ _ _ H H0 H1 H2 H18 H25 H26 H6 H7 H28 H9 H10).
super_destruct'; rewrite_inj; subst.
exists ev1' n1' ψ Ψ s2' w2'; exists Σ2'.
splits~.
+ destruct (eq_cmd_dec c1' Stop).
* subst.
match goal with
[H: _ = _ -> _ |- _] =>
specialize (H eq_refl); subst
end.
eapply bridge_step_seq_low_event_in_left_stop; eauto 2.
* match goal with
[H1: ?P -> _, H2: ?P |- _] =>
specialize (H1 H2); subst
end.
destruct (eq_cmd_dec c1' TimeOut).
{
subst.
assert (wellformed_aux Γ Σ1' ⟨TIMEOUT;; c2, pc1', m2, h2, t2⟩ pc_end).
{
eauto 2.
}
invert_wf_aux.
repeat specialize_gen.
invert_wt_cmd.
invert_wt_timeout.
}
{
eapply bridge_step_seq_low_event_in_left_nonstop; eauto 2.
}
+ splits; eauto 2.
invert_taint_eq.
unfolds.
splits; eauto 2.
destruct (eq_cmd_dec c1' Stop).
* subst.
repeat specialize_gen.
subst.
assert (c1'1 = Stop).
{
invert_taint_eq_cmd; eauto 2.
}
subst.
repeat specialize_gen.
subst.
eauto 2.
* assert (c1'1 <> Stop).
{
intro; subst.
invert_taint_eq_cmd.
eauto 2.
}
repeat specialize_gen.
subst.
eauto 2.
- assert (pc''2 = pc'') by (eapply wt_aux_soundness_bridge; eauto 2).
subst.
assert (c1 <> TimeOut).
{
intro; subst.
inverts H3.
repeat specialize_gen.
invert_wt_cmd.
invert_wt_timeout.
}
assert (pc''1 = pc''0).
{
repeat invert_wf_aux.
repeat specialize_gen.
eauto 2.
}
subst.
assert (c1'0 <> Stop).
{
repeat invert_wf_aux.
repeat specialize_gen.
intro; subst.
invert_wt_cmd.
invert_wt_stop.
}
assert (c1'0 <> TIMEOUT).
{
repeat invert_wf_aux.
repeat specialize_gen.
intro; subst.
invert_wt_cmd.
invert_wt_timeout.
}
assert (c1'0 <> TimeOut).
{
repeat invert_wf_aux.
repeat specialize_gen.
intro; subst.
invert_wt_cmd; invert_wt_timeout.
}
assert (pc'' = pc''0).
{
repeat invert_wf_aux.
repeat specialize_gen.
remember_simple (taint_eq_cmd_implies_same_type H27 H50).
eauto 2.
}
subst.
assert (c1' <> TimeOut).
{
intro; subst.
repeat specialize_gen.
subst.
assert (wellformed_aux Γ Σ1' ⟨TIMEOUT;; c2, pc1', m2, h2, t2⟩ pc_end) by eauto 2.
invert_wf_aux.
repeat specialize_gen.
invert_wt_cmd.
invert_wt_timeout.
}
assert (Stop <> TimeOut) by congruence.
remember_simple (IHc1 _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ H39 H40 _ _ _ _ _ _ _ _ _ _ _ H H0 H1 H2 H18 H25 H26 H6 H7 H28 H9 H33).
super_destruct'; rewrite_inj; subst.
assert (low_event ℓ ev1') by eauto 2.
assert (low_event ℓ ev').
{
eapply taint_eq_event_low_implies_low.
- eapply taint_eq_events_sym.
eauto.
- eauto.
}
contradiction.
}
(* At *)
{
invert_bridge_step_with_steps 0.
- invert_low_event_step.
invert_event_step; invert_low_event.
- unfold is_stop_config, cmd_of in *; subst.
invert_high_event_step.
invert_event_step.
+ invert_sem_step.
}
(* Back at *)
{
invert_taint_eq; invert_taint_eq_cmd.
assert (Σ3 = Σ3' /\
(exists t'', ev2 = RestoreEvent l t'') /\
taint_eq_mem (identity_bijection loc) Γ s1' s2'' /\
taint_eq_heap ℓ (identity_bijection loc) Σ3 Σ3' s1' w1' s2'' w2'' /\
taint_eq_reach (identity_bijection loc) s1' w1' s2'' w2'' /\
taint_eq_heap_size ℓ w1' w2'' /\
taint_eq_heap_domain_eq ℓ (identity_bijection loc) s1' s2'' w1' w2'' /\
wf_taint_bijection ℓ (inverse Φ) s2'' w2'').
{
remember_simple (backat_bridge_properties H5 H10).
super_destruct; subst.
- congruence.
- splits*.
+ repeat invert_wf_aux.
eapply taint_eq_mem_refl; eauto.
+ remember_simple (low_gc_or_inc_many_preserves_taint_eq H5 H7 H8).
unfold taint_eq in *; super_destruct'; subst.
eauto.
+ remember_simple (low_gc_or_inc_many_preserves_taint_eq H5 H7 H8).
unfold taint_eq in *; super_destruct'; subst.
eauto.
+ remember_simple (low_gc_or_inc_many_preserves_taint_eq H5 H7 H8).
unfold taint_eq in *; super_destruct'; subst.
eauto.
+ remember_simple (low_gc_or_inc_many_preserves_taint_eq H5 H7 H8).
unfold taint_eq in *; super_destruct'; subst.
eauto.
}