-
Notifications
You must be signed in to change notification settings - Fork 0
/
milMetaScript.sml
2819 lines (2623 loc) · 115 KB
/
milMetaScript.sml
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
open HolKernel boolLib Parse bossLib wordsTheory finite_mapTheory pred_setTheory ottTheory milUtilityTheory milTheory milSemanticsUtilityTheory milTracesTheory;
(* ===================================== *)
(* MIL semantics definitions and results *)
(* ===================================== *)
val _ = new_theory "milMeta";
(* --------------------- *)
(* Auxiliary definitions *)
(* --------------------- *)
Definition well_formed_state:
well_formed_state ((State_st I s C Fs):State) =
((FINITE I)
/\
((C UNION Fs) SUBSET (FDOM s))
/\
((FDOM s) SUBSET (bound_names_program I))
/\
(!i. i IN I ==> !t. t IN free_names_instr i ==> t < bound_name_instr i)
/\
(!i i'. i IN I ==> i' IN I ==> bound_name_instr i = bound_name_instr i' ==> i = i')
/\
(!i. i IN I ==> !t. t IN free_names_instr i ==> ?i'. i' IN I /\ bound_name_instr i' = t)
/\
(!t. t IN C ==> ?t1 t2 c. i_assign t c (o_store res_MEM t1 t2) IN I)
/\
(!t. t IN Fs ==> ?t1 t2 c. i_assign t c (o_store res_PC t1 t2) IN I)
/\
(!t c v r t1 t2. i_assign t c (o_store r t1 t2) IN I ==> FLOOKUP s t = SOME v ==>
map_down s t1 /\ FLOOKUP s t2 = SOME v)
/\
(!t c mop. i_assign t c mop IN I ==> map_down s t ==>
?v'. sem_expr c s = SOME v' /\ v' <> val_false)
/\
(!t c ta tv. i_assign t c (o_store res_PC ta tv) IN I ==>
i_assign ta (e_val val_true) (o_internal (e_val val_zero)) IN I)
/\
(!t c mop. i_assign t c mop IN I ==>
!t' c' mop'. t' IN names_e c ==> i_assign t' c' mop' IN I ==> c' = e_val val_true)
/\
(!t c mop. i_assign t c mop IN I ==> !s' v. sem_expr c s' = SOME v ==> v <> val_false ==>
!t' c' mop' v'. t' IN names_o mop ==> i_assign t' c' mop' IN I ==>
sem_expr c' s' = SOME v' ==> v' <> val_false)
/\
(!t c e v. i_assign t c (o_internal e) IN I ==> FLOOKUP s t = SOME v ==>
sem_instr (i_assign t c (o_internal e)) (State_st I s C Fs) = SOME (v,obs_internal))
/\
(!t c ta. i_assign t c (o_load res_PC ta) IN I ==>
i_assign ta (e_val val_true) (o_internal (e_val val_zero)) IN I)
/\
(!t. t IN C ==> bound_names_program (str_may (State_st I s C Fs) t) SUBSET C)
/\
(!t. t IN Fs ==> bound_names_program (str_may (State_st I s C Fs) t) SUBSET Fs))
End
(* NOTE: consider adding this to well-formedness:
((!t c e v. i_assign t c (o_load r ta) IN I ==> FLOOKUP s t = SOME v ==>
?obs. sem_instr (i_assign t c (o_load r ta)) (State_st I s C Fs) = SOME (v,obs))
*)
Definition well_formed_initialized_state:
well_formed_initialized_state st =
(well_formed_state st /\ initialized_all_resources st)
End
(* ----------------------- *)
(* Well-formedness helpers *)
(* ----------------------- *)
Theorem wfs_FINITE:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==> FINITE I0
Proof
rw [well_formed_state]
QED
Theorem wfs_C_F_SUBSET_FDOM:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==> C0 UNION F0 SUBSET FDOM s0
Proof
rw [well_formed_state]
QED
Theorem wfs_C_SUBSET_FDOM:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==> C0 SUBSET FDOM s0
Proof
rw [well_formed_state,UNION_DEF]
QED
Theorem wfs_F_SUBSET_FDOM:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==> F0 SUBSET FDOM s0
Proof
rw [well_formed_state,UNION_DEF]
QED
Theorem wfs_FDOM_SUBSET_bound_names:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==> FDOM s0 SUBSET bound_names_program I0
Proof
rw [well_formed_state]
QED
Theorem wfs_free_names_lt_bound:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!i. i IN I0 ==> !t. t IN free_names_instr i ==> t < bound_name_instr i
Proof
rw [well_formed_state]
QED
Theorem wfs_unique_instr_names:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!i i'. i IN I0 ==> i' IN I0 ==> bound_name_instr i = bound_name_instr i' ==> i = i'
Proof
rw [well_formed_state]
QED
Theorem wfs_free_names_instr_exists:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!i. i IN I0 ==> !t. t IN free_names_instr i ==> ?i'. i' IN I0 /\ bound_name_instr i' = t
Proof
rw [well_formed_state]
QED
Theorem wfs_C_exists_store_mem:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!t. t IN C0 ==> ?t1 t2 c. i_assign t c (o_store res_MEM t1 t2) IN I0
Proof
rw [well_formed_state]
QED
Theorem wfs_F_exists_store_pc:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!t. t IN F0 ==> ?t1 t2 c. i_assign t c (o_store res_PC t1 t2) IN I0
Proof
rw [well_formed_state]
QED
Theorem wfs_store_flookup:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!t c v r ta tv. i_assign t c (o_store r ta tv) IN I0 ==> FLOOKUP s0 t = SOME v ==>
map_down s0 ta /\ FLOOKUP s0 tv = SOME v
Proof
rw [well_formed_state]
QED
Theorem wfs_flookup_condition_not_false:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!t c mop v. i_assign t c mop IN I0 ==>
FLOOKUP s0 t = SOME v ==>
?v'. sem_expr c s0 = SOME v' /\ v' <> val_false
Proof
rw [well_formed_state] >>
METIS_TAC [map_down]
QED
Theorem wfs_store_pc_instr_zero:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!t c ta tv. i_assign t c (o_store res_PC ta tv) IN I0 ==>
i_assign ta (e_val val_true) (o_internal (e_val val_zero)) IN I0
Proof
rw [well_formed_state]
QED
Theorem wfs_internal_flookup_sem_instr:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!t c e v. i_assign t c (o_internal e) IN I0 ==> FLOOKUP s0 t = SOME v ==>
sem_instr (i_assign t c (o_internal e)) (State_st I0 s0 C0 F0) = SOME (v,obs_internal)
Proof
rw [well_formed_state]
QED
Theorem wfs_instr_guards_true:
!State. well_formed_state State ==> instr_guards_true State
Proof
Cases_on `State` >> rename1 `State_st I0 s0 C0 F0` >>
rw [well_formed_state,instr_guards_true] >>
METIS_TAC [bound_name_instr]
QED
Theorem wfs_names_o_implies_guard:
!State. well_formed_state State ==> names_o_implies_guard State
Proof
Cases_on `State` >> rename1 `State_st I0 s0 C0 F0` >>
rw [well_formed_state,names_o_implies_guard] >>
METIS_TAC [bound_name_instr]
QED
Theorem wfs_names_o_implies_guard_all_maps:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!t c mop. i_assign t c mop IN I0 ==>
!s' v. sem_expr c s' = SOME v ==> v <> val_false ==>
!t' c' mop' v'. t' IN names_o mop ==> i_assign t' c' mop' IN I0 ==>
sem_expr c' s' = SOME v' ==> v' <> val_false
Proof
rw [well_formed_state]
QED
Theorem wfs_load_pc_instr_zero:
!I0 s0 C0 F0. well_formed_state (State_st I0 s0 C0 F0) ==>
!t c ta. i_assign t c (o_load res_PC ta) IN I0 ==>
i_assign ta (e_val val_true) (o_internal (e_val val_zero)) IN I0
Proof
rw [well_formed_state]
QED
Theorem wfs_C_str_may:
!I s C Fs. well_formed_state (State_st I s C Fs) ==>
!t. t IN C ==>
bound_names_program (str_may (State_st I s C Fs) t) SUBSET C
Proof
rw [well_formed_state]
QED
Theorem wfs_F_str_may:
!I s C Fs. well_formed_state (State_st I s C Fs) ==>
!t. t IN Fs ==>
bound_names_program (str_may (State_st I s C Fs) t) SUBSET Fs
Proof
rw [well_formed_state]
QED
(* ----------------------- *)
(* Well-formedness results *)
(* ----------------------- *)
Theorem well_formed_in_C_in_s:
!I s C Fs t. well_formed_state (State_st I s C Fs) ==>
t IN C ==>
t IN FDOM s
Proof
METIS_TAC [SUBSET_DEF,wfs_C_SUBSET_FDOM]
QED
Theorem well_formed_in_F_in_s:
!I s C Fs t. well_formed_state (State_st I s C Fs) ==>
t IN Fs ==>
t IN FDOM s
Proof
METIS_TAC [SUBSET_DEF,wfs_F_SUBSET_FDOM]
QED
(* Lemma 1 *)
Theorem well_formed_CF_empty:
!I s C Fs. well_formed_state (State_st I s C Fs) ==>
C INTER Fs = {}
Proof
rw [] >>
`~?x. x IN (C INTER Fs)` suffices_by METIS_TAC [MEMBER_NOT_EMPTY] >>
rw [INTER_DEF] >>
Cases_on `x IN C` >> rw [] >>
Cases_on `x IN Fs` >> rw [] >>
`?t1 t2 c. i_assign x c (o_store res_MEM t1 t2) IN I'`
by METIS_TAC [wfs_C_exists_store_mem] >>
`?t1 t2 c. i_assign x c (o_store res_PC t1 t2) IN I'`
by METIS_TAC [wfs_F_exists_store_pc] >>
`i_assign x c (o_store res_MEM t1 t2) <> i_assign x c' (o_store res_PC t1' t2')`
by rw [res_distinct] >>
METIS_TAC [bound_name_instr,wfs_unique_instr_names]
QED
Theorem initialized_resource_load_str_may_nonempty_non_pc[local]:
!I0 s0 C0 F0 r t c a t1. r <> res_PC ==>
well_formed_state (State_st I0 s0 C0 F0) ==>
initialized_resource_at_before (State_st I0 s0 C0 F0) r a t ==>
FLOOKUP s0 t1 = SOME a ==>
i_assign t c (o_load r t1) IN I0 ==>
str_may (State_st I0 s0 C0 F0) t <> {}
Proof
rw [] >>
`addr_of I0 t = SOME (r,t1)`
by METIS_TAC [addr_of_contains_unique_load,wfs_unique_instr_names] >>
`?i. i IN str_may (State_st I0 s0 C0 F0) t`
suffices_by METIS_TAC [MEMBER_NOT_EMPTY] >>
Cases_on `r` >>
fs [
str_may,
initialized_resource_at_before,
completed_store_in,
executed_store_in
] >-
(Q.EXISTS_TAC `i_assign t''' (e_val val_true) (o_store res_REG t' t'')` >>
rw [] >> fs [sem_expr_correct,val_false,val_true]) >>
Q.EXISTS_TAC `i_assign t''' (e_val val_true) (o_store res_MEM t' t'')` >>
rw [] >> fs [sem_expr_correct,val_false,val_true]
QED
Theorem initialized_resource_load_str_may_nonempty_pc[local]:
!I0 s0 C0 F0 t c a t1.
well_formed_state (State_st I0 s0 C0 F0) ==>
initialized_resource_at_before (State_st I0 s0 C0 F0) res_PC a t ==>
FLOOKUP s0 t1 = SOME val_zero ==>
i_assign t c (o_load res_PC t1) IN I0 ==>
str_may (State_st I0 s0 C0 F0) t <> {}
Proof
rw [] >>
`addr_of I0 t = SOME (res_PC,t1)`
by METIS_TAC [addr_of_contains_unique_load,wfs_unique_instr_names] >>
`?i. i IN str_may (State_st I0 s0 C0 F0) t`
suffices_by METIS_TAC [MEMBER_NOT_EMPTY] >>
fs [
str_may,
initialized_resource_at_before,
completed_store_in,
executed_store_in
] >>
Q.EXISTS_TAC `i_assign t''' (e_val val_true) (o_store res_PC t' t'')` >>
rw [] >> fs [sem_expr_correct,val_false,val_true]
QED
Theorem in_str_may_completed_then_executed[local]:
!I0 s0 C0 F0 t t' c mop.
well_formed_state (State_st I0 s0 C0 F0) ==>
Completed (State_st I0 s0 C0 F0) (i_assign t' c mop) ==>
i_assign t' c mop IN str_may (State_st I0 s0 C0 F0) t ==>
t' IN FDOM s0
Proof
rw [] >>
`?r ta tv. i_assign t' c mop = i_assign t' c (o_store r ta tv)` by fs [str_may] >>
rw [] >>
`t' IN C0 ==> t' IN FDOM s0` by METIS_TAC [wfs_C_SUBSET_FDOM,SUBSET_DEF] >>
`t' IN F0 ==> t' IN FDOM s0` by METIS_TAC [wfs_F_SUBSET_FDOM,SUBSET_DEF] >>
Cases_on `r` >> fs [Completed,str_may] >> fs [] >> METIS_TAC []
QED
Theorem completed_before_in_str_act_same[local]:
!I0 s0 C0 F0 t ta r i i'.
well_formed_state (State_st I0 s0 C0 F0) ==>
addr_of I0 t = SOME (r,ta) ==>
ta IN FDOM s0 ==>
(!i0. i0 IN str_may (State_st I0 s0 C0 F0) t ==> Completed (State_st I0 s0 C0 F0) i0) ==>
i IN str_act (State_st I0 s0 C0 F0) t ==>
i' IN str_act (State_st I0 s0 C0 F0) t ==>
i = i'
Proof
rw [] >>
fs [str_act] >>
`SOME (r,ta) = SOME (r',ta'')` by METIS_TAC [] >>
`SOME (r,ta) = SOME (r'',ta'''')` by METIS_TAC [] >>
`t' < t` by fs [str_may] >>
`t'' < t` by fs [str_may] >>
`i IN I0` by fs [str_may] >>
`i' IN I0` by fs [str_may] >>
`Completed (State_st I0 s0 C0 F0) i` by (fs [] >> METIS_TAC []) >>
`Completed (State_st I0 s0 C0 F0) i'` by (fs [] >> METIS_TAC []) >>
`t' IN FDOM s0` by METIS_TAC [in_str_may_completed_then_executed] >>
`?v. FLOOKUP s0 t' = SOME v` by fs [flookup_thm] >>
`t'' IN FDOM s0` by METIS_TAC [in_str_may_completed_then_executed] >>
`?v. FLOOKUP s0 t'' = SOME v` by fs [flookup_thm] >>
`?v. sem_expr c' s0 = SOME v /\ v <> val_false` by METIS_TAC [wfs_flookup_condition_not_false] >>
`?v. sem_expr c'' s0 = SOME v /\ v <> val_false` by METIS_TAC [wfs_flookup_condition_not_false] >>
`i = i'` suffices_by fs [] >>
`t' = t''` suffices_by METIS_TAC [wfs_unique_instr_names,bound_name_instr] >>
fs [] >> rw [] >>
`?v. FLOOKUP s0 ta' = SOME v` by METIS_TAC [wfs_store_flookup,map_down] >>
`?v. FLOOKUP s0 ta''' = SOME v` by METIS_TAC [wfs_store_flookup,map_down] >>
Cases_on `t' > t''` >-
(Q.PAT_ASSUM `!i''. P` (STRIP_ASSUME_TAC o (Q.SPEC `i_assign t' c' (o_store r ta' tv')`)) >>
fs [] >- METIS_TAC [] >>
`FLOOKUP s0 ta = SOME v''''` suffices_by METIS_TAC [] >>
Q.PAT_X_ASSUM `X IN str_may (State_st I0 s0 C0 F0) t` (fn thm => ALL_TAC) >>
fs [str_may] >> METIS_TAC [flookup_thm]) >>
Cases_on `t' = t''` >> fs [] >>
`t'' > t'` by DECIDE_TAC >>
Q.PAT_X_ASSUM `!i''. P` (fn thm => ALL_TAC) >>
Q.PAT_ASSUM `!i''. P` (STRIP_ASSUME_TAC o (Q.SPEC `i_assign t'' c'' (o_store r ta''' tv'')`)) >>
fs [] >- METIS_TAC [] >>
`FLOOKUP s0 ta = SOME v'''''` suffices_by METIS_TAC [] >>
fs [str_may] >> METIS_TAC [flookup_thm]
QED
Theorem initialized_resource_completed_before_load_str_act_singleton_non_pc[local]:
!I0 s0 C0 F0 r t c a t1. r <> res_PC ==>
well_formed_state (State_st I0 s0 C0 F0) ==>
initialized_resource_at_before (State_st I0 s0 C0 F0) r a t ==>
FLOOKUP s0 t1 = SOME a ==>
i_assign t c (o_load r t1) IN I0 ==>
(!i0. i0 IN str_may (State_st I0 s0 C0 F0) t ==> Completed (State_st I0 s0 C0 F0) i0) ==>
SING (str_act (State_st I0 s0 C0 F0) t)
Proof
rw [] >>
`str_may (State_st I0 s0 C0 F0) t <> {}`
by METIS_TAC [initialized_resource_load_str_may_nonempty_non_pc] >>
`addr_of I0 t = SOME (r,t1)`
by METIS_TAC [addr_of_contains_unique_load,wfs_unique_instr_names] >>
Cases_on `str_act (State_st I0 s0 C0 F0) t = {}` >-
METIS_TAC [str_act_empty_str_may_empty_or_I_infinite,wfs_FINITE] >>
`?i. i IN str_act (State_st I0 s0 C0 F0) t` by METIS_TAC [MEMBER_NOT_EMPTY] >>
`t1 IN FDOM s0` by fs [flookup_thm] >>
`!i'. i' IN str_act (State_st I0 s0 C0 F0) t ==> i' = i`
by METIS_TAC [completed_before_in_str_act_same] >>
rw [SING_DEF] >> Q.EXISTS_TAC `i` >>
METIS_TAC [UNIQUE_MEMBER_SING]
QED
(* FIXME: only meaningful to have t1 IN FDOM s0? *)
Theorem initialized_resource_completed_before_load_str_act_singleton_pc[local]:
!I0 s0 C0 F0 t c a t1.
well_formed_state (State_st I0 s0 C0 F0) ==>
initialized_resource_at_before (State_st I0 s0 C0 F0) res_PC a t ==>
FLOOKUP s0 t1 = SOME val_zero ==>
i_assign t c (o_load res_PC t1) IN I0 ==>
(!i0. i0 IN str_may (State_st I0 s0 C0 F0) t ==> Completed (State_st I0 s0 C0 F0) i0) ==>
SING (str_act (State_st I0 s0 C0 F0) t)
Proof
rw [] >>
`str_may (State_st I0 s0 C0 F0) t <> {}`
by METIS_TAC [initialized_resource_load_str_may_nonempty_pc] >>
`addr_of I0 t = SOME (res_PC,t1)`
by METIS_TAC [addr_of_contains_unique_load,wfs_unique_instr_names] >>
Cases_on `str_act (State_st I0 s0 C0 F0) t = {}` >-
METIS_TAC [str_act_empty_str_may_empty_or_I_infinite,wfs_FINITE] >>
`?i. i IN str_act (State_st I0 s0 C0 F0) t` by METIS_TAC [MEMBER_NOT_EMPTY] >>
`t1 IN FDOM s0` by fs [flookup_thm] >>
`!i'. i' IN str_act (State_st I0 s0 C0 F0) t ==> i' = i`
by METIS_TAC [completed_before_in_str_act_same] >>
rw [SING_DEF] >> Q.EXISTS_TAC `i` >>
METIS_TAC [UNIQUE_MEMBER_SING]
QED
(* --------------------------- *)
(* MIL out-of-order metatheory *)
(* --------------------------- *)
(* Lemma 2 *)
Theorem well_formed_OoO_transition_well_formed:
step_invariant out_of_order_step well_formed_state
Proof
rw [step_invariant,out_of_order_step_cases] >| [
fs [well_formed_state] >> fs [] >> rw [] >| [
fs [INSERT_DEF,SUBSET_DEF],
fs [INSERT_DEF,SUBSET_DEF],
rw [bound_names_program] >>
Q.EXISTS_TAC `i_assign t c op` >> rw [bound_name_instr],
METIS_TAC [],
rw [map_down] >>
fs [map_up,map_down] >>
Cases_on `t = t'` >-
(rw [] >>
`i_assign t c op = i_assign t c' (o_store r t1 t2)`
by METIS_TAC [bound_name_instr] >>
Cases_on `op` >> rw [] >>
fs [sem_instr] >>
Cases_on `FLOOKUP s'' n0` >> fs [] >>
Cases_on `FLOOKUP s'' n` >> fs [] >> rw [] >>
`t <> n` by METIS_TAC [] >>
Q.EXISTS_TAC `x'` >> rw [FLOOKUP_UPDATE]) >>
`FLOOKUP s'' t' = SOME v''`
by METIS_TAC [FLOOKUP_UPDATE] >>
rw [FLOOKUP_UPDATE] >>
METIS_TAC [],
fs [map_up,map_down] >>
Cases_on `t = t'` >-
(fs [FLOOKUP_UPDATE] >> rw [] >>
`i_assign t c op = i_assign t c' (o_store r t1 t2)`
by METIS_TAC [bound_name_instr] >>
Cases_on `op` >> rw [] >> fs [sem_instr] >>
Cases_on `FLOOKUP s'' n0` >> fs [] >>
Cases_on `FLOOKUP s'' n` >> fs [] >> rw []) >>
fs [FLOOKUP_UPDATE] >>
Cases_on `t' = t1` >> rw [] >>
METIS_TAC [],
fs [map_up,map_down] >>
`t NOTIN FDOM s''` by fs [FLOOKUP_DEF] >>
Cases_on `t = t'` >-
(rw [] >>
`i_assign t c op = i_assign t c' mop`
by METIS_TAC [bound_name_instr] >>
rw [] >>
METIS_TAC [sem_expr_notin_fdom_some_fupdate]) >>
`FLOOKUP s'' t' = SOME v''` by fs [FLOOKUP_DEF,NOT_EQ_FAPPLY] >>
METIS_TAC [sem_expr_notin_fdom_some_fupdate],
METIS_TAC [],
METIS_TAC [],
METIS_TAC [],
fs [map_up,map_down] >>
`t NOTIN FDOM s''` by fs [FLOOKUP_DEF] >>
Cases_on `t = t'` >-
(rw [] >>
`v = v''` by fs [FLOOKUP_DEF] >>
rw [] >>
`i_assign t c op = i_assign t c' (o_internal e)`
by METIS_TAC [bound_name_instr] >>
rw [] >>
`obs = obs_internal`
suffices_by METIS_TAC [sem_instr_internal_notin_fdom_fupdate_eq_some] >>
fs [sem_instr] >>
Cases_on `sem_expr e s''` >> fs []) >>
`FLOOKUP s'' t' = SOME v''` by fs [FLOOKUP_DEF,NOT_EQ_FAPPLY] >>
`sem_instr (i_assign t' c' (o_internal e)) (State_st I' s'' C F') = SOME (v'',obs_internal)`
by METIS_TAC [] >>
METIS_TAC [sem_instr_internal_notin_fdom_fupdate_eq_some],
METIS_TAC [],
fs [map_up,map_down] >>
`t NOTIN FDOM s''` by fs [FLOOKUP_DEF] >>
`bound_names_program (str_may (State_st I' (s'' |+ (t,v)) C F') t') SUBSET
bound_names_program (str_may (State_st I' s'' C F') t')`
suffices_by METIS_TAC [SUBSET_TRANS] >>
`str_may (State_st I' (s'' |+ (t,v)) C F') t' SUBSET str_may (State_st I' s'' C F') t'`
suffices_by METIS_TAC [bound_names_program_SUBSET] >>
rw [fupdate_in_str_may],
fs [map_up,map_down] >>
`t NOTIN FDOM s''` by fs [FLOOKUP_DEF] >>
`bound_names_program (str_may (State_st I' (s'' |+ (t,v)) C F') t') SUBSET
bound_names_program (str_may (State_st I' s'' C F') t')`
suffices_by METIS_TAC [SUBSET_TRANS] >>
`str_may (State_st I' (s'' |+ (t,v)) C F') t' SUBSET str_may (State_st I' s'' C F') t'`
suffices_by METIS_TAC [bound_names_program_SUBSET] >>
rw [fupdate_in_str_may]
],
fs [well_formed_state] >> fs [] >> rw [] >| [
fs[map_down,FLOOKUP_DEF],
METIS_TAC [],
METIS_TAC [],
METIS_TAC [],
fs [map_down] >> METIS_TAC [],
METIS_TAC [],
METIS_TAC [],
METIS_TAC [],
METIS_TAC [],
METIS_TAC [],
`sem_instr (i_assign t' c' (o_internal e)) (State_st I' s'' C F') = SOME (v',obs_internal)`
by METIS_TAC [] >>
fs [sem_instr],
METIS_TAC [],
`str_may (State_st I' s'' (C UNION {t}) F') t' = str_may (State_st I' s'' C F') t'`
by rw [str_may_unaffected_C_F] >>
fs [SUBSET_DEF] >>
METIS_TAC [],
`str_may (State_st I' s'' (C UNION {t}) F') t = str_may (State_st I' s'' C F') t`
by rw [str_may_unaffected_C_F] >>
fs [SUBSET_DEF] >>
METIS_TAC [],
`str_may (State_st I' s'' (C UNION {t}) F') t' = str_may (State_st I' s'' C F') t'`
by rw [str_may_unaffected_C_F] >>
fs [SUBSET_DEF] >>
METIS_TAC []
],
`t IN FDOM s''` by fs [FLOOKUP_DEF] >>
sg `t IN bound_names_program I'` >-
(fs [bound_names_program] >>
Q.EXISTS_TAC `i_assign t c (o_store res_PC t1 t2)` >>
rw [bound_name_instr]) >>
fs [well_formed_state] >> fs [] >> rw [] >| [
rw [translate_val_correct],
rw [bound_names_program_union] >>
rw [SUBSET_DEF] >>
METIS_TAC [SUBSET_DEF],
METIS_TAC [],
METIS_TAC [translate_val_correct],
METIS_TAC [],
Cases_on `i` >> rw [] >> Cases_on `i'` >> fs [bound_name_instr] >>
METIS_TAC [instr_not_in_I_translate_val_max_name],
Cases_on `i` >> rw [] >> Cases_on `i'` >> fs [bound_name_instr] >>
METIS_TAC [instr_not_in_I_translate_val_max_name],
METIS_TAC [translate_val_correct],
METIS_TAC [],
METIS_TAC [translate_val_correct],
METIS_TAC [],
METIS_TAC [],
METIS_TAC [],
METIS_TAC [],
METIS_TAC [],
rw [map_down] >>
`t' IN FDOM s''` by fs [FLOOKUP_DEF] >>
`t' IN bound_names_program I'` by fs [SUBSET_DEF] >>
METIS_TAC [instr_in_translate_val_name_not_in_program],
`t' IN FDOM s''` by fs [FLOOKUP_DEF] >>
`t' IN bound_names_program I'` by fs [SUBSET_DEF] >>
METIS_TAC [instr_in_translate_val_name_not_in_program],
METIS_TAC [],
`t' IN FDOM s''` by fs [map_down,FLOOKUP_DEF] >>
`t' IN bound_names_program I'` by fs [SUBSET_DEF] >>
METIS_TAC [instr_in_translate_val_name_not_in_program],
METIS_TAC [],
METIS_TAC [translate_val_correct],
METIS_TAC [],
`t'' IN free_names_instr (i_assign t' c' mop)`
by rw [free_names_instr] >>
`t'' < t'` by METIS_TAC [bound_name_instr,wfs_free_names_lt_bound] >>
`t'' IN names_instr (i_assign t' c' mop)` by rw [names_instr] >>
`t' < t''` suffices_by fs [] >>
METIS_TAC [translate_val_max_name_lt,bound_name_instr],
`t'' IN free_names_instr (i_assign t' c' mop)` by rw [free_names_instr] >>
`?i. i IN translate_val v (MAX_SET (bound_names_program I')) /\ bound_name_instr i = t''`
by METIS_TAC [translate_val_correct] >>
`t'' < bound_name_instr i` suffices_by fs [bound_name_instr] >>
METIS_TAC [translate_val_max_name_lt,bound_name_instr],
METIS_TAC [translate_val_correct],
METIS_TAC [],
`t'' IN free_names_instr (i_assign t' c' mop)` by rw [free_names_instr] >>
`t'' < t'` by METIS_TAC [bound_name_instr,wfs_free_names_lt_bound] >>
`t'' IN names_instr (i_assign t' c' mop)` by rw [names_instr] >>
`t' < t''` suffices_by fs [] >>
METIS_TAC [translate_val_max_name_lt,bound_name_instr],
`t'' IN free_names_instr (i_assign t' c' mop)` by rw [free_names_instr] >>
`?i. i IN translate_val v (MAX_SET (bound_names_program I')) /\ bound_name_instr i = t''`
by METIS_TAC [translate_val_correct,bound_name_instr] >>
`t'' < bound_name_instr i` suffices_by rw [] >>
METIS_TAC [translate_val_max_name_lt,bound_name_instr],
METIS_TAC [translate_val_correct],
`sem_instr (i_assign t' c' (o_internal e)) (State_st I' s'' C F') = SOME (v',obs_internal)`
by METIS_TAC [] >>
fs [sem_instr],
`t' IN FDOM s''` by fs [FLOOKUP_DEF] >>
`t' IN bound_names_program I'` by fs [SUBSET_DEF] >>
METIS_TAC [instr_in_translate_val_name_not_in_program],
METIS_TAC [],
METIS_TAC [translate_val_correct],
`t' IN FDOM s''` by fs [SUBSET_DEF] >>
`?i. i IN I' /\ bound_name_instr i = t'` by METIS_TAC [bound_names_program,bound_name_instr] >>
Cases_on `i` >> fs [bound_name_instr] >> rw [] >> rename1 `i_assign t' c' mop' IN I'` >>
`str_may (State_st (I' UNION translate_val v (MAX_SET (bound_names_program I'))) s'' C (F' UNION {t})) t' SUBSET
str_may (State_st I' s'' C F') t'`
suffices_by METIS_TAC [bound_names_program_SUBSET,SUBSET_TRANS] >>
`!i. i IN translate_val v (MAX_SET (bound_names_program I')) ==> t' < bound_name_instr i`
suffices_by rw [str_may_union_I_F_eq,SUBSET_DEF] >>
METIS_TAC [translate_val_max_name_lt,bound_name_instr],
`t' IN FDOM s''` by fs [SUBSET_DEF] >>
`?i. i IN I' /\ bound_name_instr i = t'` by METIS_TAC [bound_names_program,bound_name_instr] >>
Cases_on `i` >> fs [bound_name_instr] >> rw [] >> rename1 `i_assign t' c' mop' IN I'` >>
`bound_names_program (str_may
(State_st (I' UNION translate_val v (MAX_SET (bound_names_program I'))) s'' C (F' UNION {t})) t') SUBSET F'`
suffices_by rw [SUBSET_DEF] >>
`str_may (State_st (I' UNION translate_val v (MAX_SET (bound_names_program I'))) s'' C (F' UNION {t})) t' SUBSET
str_may (State_st I' s'' C F') t'`
suffices_by METIS_TAC [bound_names_program_SUBSET,SUBSET_TRANS] >>
`!i. i IN translate_val v (MAX_SET (bound_names_program I')) ==> t' < bound_name_instr i`
suffices_by rw [str_may_union_I_F_eq,SUBSET_DEF] >>
METIS_TAC [translate_val_max_name_lt,bound_name_instr],
`bound_names_program (str_may
(State_st (I' UNION translate_val v (MAX_SET (bound_names_program I'))) s'' C (F' UNION {t})) t) SUBSET F'`
suffices_by rw [SUBSET_DEF] >>
`str_may (State_st (I' UNION translate_val v (MAX_SET (bound_names_program I'))) s'' C (F' UNION {t})) t SUBSET
str_may (State_st I' s'' C F') t`
suffices_by METIS_TAC [bound_names_program_SUBSET,SUBSET_TRANS] >>
`!i. i IN translate_val v (MAX_SET (bound_names_program I')) ==> t < bound_name_instr i`
suffices_by rw [str_may_union_I_F_eq,SUBSET_DEF] >>
METIS_TAC [translate_val_max_name_lt,bound_name_instr]
]
]
QED
Theorem well_formed_OoO_LTC_invariant:
LTC_invariant out_of_order_step well_formed_state
Proof
METIS_TAC [well_formed_OoO_transition_well_formed,step_invariant_LTC_invariant]
QED
Theorem step_execution_mid_OoO_well_formed_state:
!e e' S1 l1 S2 S3 l2 S4. well_formed_state S1 ==>
step_execution out_of_order_step ((S1,l1,S2)::e' ++ (S3,l2,S4)::e) ==>
well_formed_state S4
Proof
METIS_TAC [step_execution_mid_LTC_invariant,well_formed_OoO_LTC_invariant]
QED
Theorem step_execution_mid_FST_OoO_well_formed_state:
!e e' S1 l1 S2 S3 l2 S4. well_formed_state S1 ==>
step_execution out_of_order_step ((S1,l1,S2)::e' ++ (S3,l2,S4)::e) ==>
well_formed_state S3
Proof
METIS_TAC [step_execution_mid_FST_LTC_invariant,well_formed_OoO_LTC_invariant]
QED
Theorem initialized_all_resources_OoO_step_invariant:
!I0 s0 C0 F0 l st. FINITE I0 ==>
initialized_all_resources (State_st I0 s0 C0 F0) ==>
out_of_order_step (State_st I0 s0 C0 F0) l st ==>
initialized_all_resources st
Proof
rw [step_invariant,out_of_order_step_cases] >| [
fs [initialized_all_resources] >> rw [] >>
Q.PAT_X_ASSUM `!r. P` (STRIP_ASSUME_TAC o (Q.SPEC `r`)) >>
Cases_on `r` >>
fs [
initialized_resource,
initialized_resource_in_set,
completed_store_in,
executed_store_in,
instr_in_State
] >> rw [] >| [
fs [map_up,map_down] >>
Q.EXISTS_TAC `v''` >>
Q.EXISTS_TAC `t'` >> Q.EXISTS_TAC `t''` >> Q.EXISTS_TAC `t'''` >>
`t <> t'` by METIS_TAC [] >>
`t <> t''` by METIS_TAC [] >>
`t <> t'''` by METIS_TAC [] >>
fs [FLOOKUP_DEF,NOT_EQ_FAPPLY] >> METIS_TAC [],
fs [map_up,map_down] >>
Q.PAT_X_ASSUM `!a. P` (STRIP_ASSUME_TAC o (Q.SPEC `a`)) >>
Q.EXISTS_TAC `v''` >>
Q.EXISTS_TAC `t'` >> Q.EXISTS_TAC `t''` >> Q.EXISTS_TAC `t'''` >>
`t <> t'` by METIS_TAC [] >>
`t <> t''` by METIS_TAC [] >>
`t <> t'''` by METIS_TAC [] >>
fs [FLOOKUP_DEF,NOT_EQ_FAPPLY] >> METIS_TAC [],
fs [map_up,map_down] >>
Q.PAT_X_ASSUM `!a. P` (STRIP_ASSUME_TAC o (Q.SPEC `a`)) >>
Q.EXISTS_TAC `v''` >>
Q.EXISTS_TAC `t'` >> Q.EXISTS_TAC `t''` >> Q.EXISTS_TAC `t'''` >>
`t <> t'` by METIS_TAC [] >>
`t <> t''` by METIS_TAC [] >>
`t <> t'''` by METIS_TAC [] >>
fs [FLOOKUP_DEF,NOT_EQ_FAPPLY] >> METIS_TAC []
],
fs [initialized_all_resources] >> rw [] >>
Q.PAT_X_ASSUM `!r. P` (STRIP_ASSUME_TAC o (Q.SPEC `r`)) >>
Cases_on `r` >>
fs [
initialized_resource,
initialized_resource_in_set,
completed_store_in,
executed_store_in,
instr_in_State
] >> rw [] >>
fs [map_down] >>
METIS_TAC [],
fs [initialized_all_resources] >> rw [] >>
Q.PAT_X_ASSUM `!r. P` (STRIP_ASSUME_TAC o (Q.SPEC `r`)) >>
Cases_on `r` >>
fs [
initialized_resource,
initialized_resource_in_set,
completed_store_in,
executed_store_in,
instr_in_State
] >> rw [] >| [
Q.EXISTS_TAC `v'` >>
Q.EXISTS_TAC `t'` >> Q.EXISTS_TAC `t''` >> Q.EXISTS_TAC `t'''` >>
rw [] >- METIS_TAC [] >>
`bound_name_instr (i_assign t''' (e_val val_true) (o_store res_PC t' t'')) <
bound_name_instr (i_assign tl c' (o_load res_PC ta))` suffices_by fs [bound_name_instr] >>
METIS_TAC [translate_val_max_name_lt],
Q.PAT_X_ASSUM `!a. P` (STRIP_ASSUME_TAC o (Q.SPEC `a`)) >>
Q.EXISTS_TAC `v'` >>
Q.EXISTS_TAC `t'` >> Q.EXISTS_TAC `t''` >> Q.EXISTS_TAC `t'''` >>
rw [] >- METIS_TAC [] >>
`bound_name_instr (i_assign t''' (e_val val_true) (o_store res_REG t' t'')) <
bound_name_instr (i_assign tl c' (o_load res_REG ta))` suffices_by fs [bound_name_instr] >>
METIS_TAC [translate_val_max_name_lt],
Q.PAT_X_ASSUM `!a. P` (STRIP_ASSUME_TAC o (Q.SPEC `a`)) >>
Q.EXISTS_TAC `v'` >>
Q.EXISTS_TAC `t'` >> Q.EXISTS_TAC `t''` >> Q.EXISTS_TAC `t'''` >>
rw [] >- METIS_TAC [] >>
`bound_name_instr (i_assign t''' (e_val val_true) (o_store res_MEM t' t'')) <
bound_name_instr (i_assign tl c' (o_load res_MEM ta))` suffices_by fs [bound_name_instr] >>
METIS_TAC [translate_val_max_name_lt]
]
]
QED
Theorem well_formed_initialized_state_OoO_step_invariant:
step_invariant out_of_order_step well_formed_initialized_state
Proof
rw [step_invariant] >>
Cases_on `s` >> rename1 `State_st I0 s0 C0 F0` >>
fs [well_formed_initialized_state] >>
`FINITE I0` by METIS_TAC [wfs_FINITE] >>
METIS_TAC [
well_formed_OoO_transition_well_formed,
initialized_all_resources_OoO_step_invariant,
step_invariant
]
QED
Theorem well_formed_initialized_OoO_LTC_invariant:
LTC_invariant out_of_order_step well_formed_initialized_state
Proof
METIS_TAC [
well_formed_initialized_state_OoO_step_invariant,
step_invariant_LTC_invariant
]
QED
Theorem step_execution_mid_OoO_well_formed_initialized_state:
!e e' S1 l1 S2 S3 l2 S4. well_formed_initialized_state S1 ==>
step_execution out_of_order_step ((S1,l1,S2)::e' ++ (S3,l2,S4)::e) ==>
well_formed_initialized_state S4
Proof
METIS_TAC [
step_execution_mid_LTC_invariant,
well_formed_initialized_OoO_LTC_invariant
]
QED
Theorem step_execution_mid_FST_OoO_well_formed_initialized_state:
!e e' S1 l1 S2 S3 l2 S4. well_formed_initialized_state S1 ==>
step_execution out_of_order_step ((S1,l1,S2)::e' ++ (S3,l2,S4)::e) ==>
well_formed_initialized_state S3
Proof
METIS_TAC [
step_execution_mid_FST_LTC_invariant,
well_formed_initialized_OoO_LTC_invariant
]
QED
Theorem initialized_resource_at_before_OoO_step_invariant:
!I0 s0 C0 F0 l State a r tmax. FINITE I0 ==>
initialized_resource_at_before (State_st I0 s0 C0 F0) r a tmax ==>
out_of_order_step (State_st I0 s0 C0 F0) l State ==>
initialized_resource_at_before State r a tmax
Proof
rw [step_invariant,out_of_order_step_cases] >| [
Cases_on `r` >>
fs [
initialized_resource_at_before,
completed_store_in,
executed_store_in
] >>
rw [] >>
fs [map_up,map_down] >>
Q.EXISTS_TAC `t'` >> Q.EXISTS_TAC `t''` >> Q.EXISTS_TAC `t'''` >>
Q.EXISTS_TAC `v''` >>
`t <> t'` by METIS_TAC [] >>
`t <> t''` by METIS_TAC [] >>
`t <> t'''` by METIS_TAC [] >>
fs [FLOOKUP_DEF,NOT_EQ_FAPPLY],
Cases_on `r` >>
fs [
initialized_resource_at_before,
completed_store_in,
executed_store_in
] >>
rw [] >> fs [map_down] >> METIS_TAC [],
Cases_on `r` >>
fs [
initialized_resource_at_before,
completed_store_in,
executed_store_in
] >>
rw [] >>
Q.EXISTS_TAC `t'` >> Q.EXISTS_TAC `t''` >> Q.EXISTS_TAC `t'''` >>
Q.EXISTS_TAC `v'` >> rw []
]
QED
(* Lemma 3, part 1 *)
Theorem OoO_exe_transition_same_I[local]:
!I s C Fs obs t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs act_exe t) (State_st I' s' C' Fs') ==>
I' = I
Proof
rw [out_of_order_step_cases]
QED
(* Lemma 3, part 2 *)
Theorem OoO_exe_transition_not_obs_ds[local]:
!I s C Fs obs t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs act_exe t) (State_st I' s' C' Fs') ==>
!v. obs <> obs_ds v
Proof
rw [out_of_order_step_cases] >>
METIS_TAC [sem_instr_not_obs_ds]
QED
(* Lemma 3, part 3 *)
(* always a load *)
Theorem OoO_exe_transition_not_obs_il[local]:
!I s C Fs obs t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs act_exe t) (State_st I' s' C' Fs') ==>
!v. obs <> obs_il v
Proof
rw [out_of_order_step_cases] >>
METIS_TAC [sem_instr_not_obs_il]
QED
(* Lemma 3, part 4 *)
Theorem OoO_exe_transition_t_not_in_dom_s[local]:
!I s C Fs obs t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs act_exe t) (State_st I' s' C' Fs') ==>
t NOTIN FDOM s
Proof
rw [out_of_order_step_cases] >> fs[map_up,map_down] >>
Cases_on `FLOOKUP s t` >> fs [FLOOKUP_DEF]
QED
(* Lemma 3, part 5 *)
Theorem OoO_exe_transition_CF_equal[local]:
!I s C Fs obs t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs act_exe t) (State_st I' s' C' Fs') ==>
C' = C /\ Fs' = Fs
Proof
rw [out_of_order_step_cases]
QED
(* Lemma 3, part 6 *)
Theorem OoO_exe_transition_t_exists_v_update[local]:
!I s C Fs obs t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs act_exe t) (State_st I' s' C' Fs') ==>
?v. s' = (FUPDATE s (t,v))
Proof
rw [out_of_order_step_cases] >>
Q.EXISTS_TAC `v` >> rw []
QED
(* Lemma 3 *)
Theorem OoO_exe_transition_results:
!I s C Fs obs t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs act_exe t) (State_st I' s' C' Fs') ==>
(I' = I) /\
(!v. obs <> obs_ds v) /\
(!v. obs <> obs_il v) /\
(t NOTIN (FDOM s)) /\
(C' = C /\ Fs' = Fs) /\
(?v. s' = (FUPDATE s (t,v)))
Proof
PROVE_TAC [
OoO_exe_transition_same_I,
OoO_exe_transition_not_obs_ds,
OoO_exe_transition_not_obs_il,
OoO_exe_transition_t_not_in_dom_s,
OoO_exe_transition_CF_equal,
OoO_exe_transition_t_exists_v_update
]
QED
(* Lemma 4 *)
Theorem OoO_transition_s_neq_then_exe:
!I s C Fs obs a t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs a t) (State_st I' s' C' Fs') ==>
s <> s' ==>
a = act_exe
Proof
rw [out_of_order_step_cases]
QED
(* Lemma 5, part 1 *)
Theorem OoO_ftc_transition_I_eq[local]:
!I s C Fs obs I'' t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs (act_ftc I'') t) (State_st I' s' C' Fs') ==>
I' = I UNION I''
Proof
rw [out_of_order_step_cases]
QED
(* Lemma 5, part 2 *)
Theorem OoO_ftc_transition_s_C_eq[local]:
!I s C Fs obs I'' t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs (act_ftc I'') t) (State_st I' s' C' Fs') ==>
s' = s /\ C' = C
Proof
rw [out_of_order_step_cases]
QED
(* Lemma 5, part 3 *)
Theorem OoO_ftc_transition_F_union_t[local]:
!I s C Fs obs I'' t I' s' C' Fs'.
out_of_order_step (State_st I s C Fs) (l_lb obs (act_ftc I'') t) (State_st I' s' C' Fs') ==>
Fs' = Fs UNION {t}
Proof
rw [out_of_order_step_cases]
QED
(* Lemma 5a *)
Theorem OoO_ftc_transition_t_not_in_I:
!I s C Fs obs I'' t I' s' C' Fs'.
FINITE I ==>
out_of_order_step (State_st I s C Fs) (l_lb obs (act_ftc I'') t) (State_st I' s' C' Fs') ==>
t NOTIN (bound_names_program I'')
Proof
rw [out_of_order_step_cases] >>
METIS_TAC [instr_in_program_name_not_in_translate_val]
QED
(* Lemma 5b *)
Theorem OoO_ftc_transition_obs_il:
!I s C Fs obs I'' t I' s' C' Fs' v.
out_of_order_step (State_st I s C Fs) (l_lb obs (act_ftc I'') t) (State_st I' s' C' Fs') ==>
FLOOKUP s t = SOME v ==>
obs = obs_il v
Proof
rw [out_of_order_step_cases] >> fs []
QED