-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmilSemanticsUtilityScript.sml
1953 lines (1775 loc) · 69.4 KB
/
milSemanticsUtilityScript.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 listTheory finite_mapTheory pred_setTheory cardinalTheory milTheory milUtilityTheory;
(* ==================================================== *)
(* General MIL semantics utility definitions and lemmas *)
(* ==================================================== *)
val _ = new_theory "milSemanticsUtility";
(* -------------------------------------- *)
(* MIL utility definitions and properties *)
(* -------------------------------------- *)
Definition obs_of_l:
obs_of_l (l_lb obs ac t) = obs
End
Definition name_of_l:
name_of_l (l_lb obs ac t) = t
End
Definition act_of_l:
act_of_l (l_lb obs ac t) = ac
End
Definition obs_visible:
(obs_visible obs_internal = F)
/\
(obs_visible (obs_dl v) = T)
/\
(obs_visible (obs_ds v) = T)
/\
(obs_visible (obs_il v) = T)
End
Definition name_mapped_in_State:
name_mapped_in_State (t:t) ((State_st I s C f):State) =
(t IN FDOM s)
End
Definition name_instr_in_State:
name_instr_in_State (t:t) ((State_st I s C f):State) =
(t IN bound_names_program I)
End
Definition max_name_in_State:
max_name_in_State ((State_st I s C f):State) =
(MAX_SET (bound_names_program I))
End
Definition Completed_t:
Completed_t (State_st I s C Fs) t =
(?i. i IN I /\ bound_name_instr i = t /\ Completed (State_st I s C Fs) i)
End
(* semantic condition for not getting instructions stuck *)
Definition names_o_implies_guard:
names_o_implies_guard (State_st I0 s0 C0 F0) =
(!t c mop t' c' mop' v v'. i_assign t c mop IN I0 ==>
t' IN names_o mop ==>
i_assign t' c' mop' IN I0 ==>
sem_expr c s0 = SOME v ==>
v <> val_false ==>
sem_expr c' s0 = SOME v' ==>
v' <> val_false)
End
Definition instr_guards_true:
instr_guards_true (State_st I0 s0 C0 F0) =
(!t c mop. i_assign t c mop IN I0 ==>
!t' c' mop'. t' IN names_e c ==>
i_assign t' c' mop' IN I0 ==>
c' = e_val val_true)
End
Definition executed_store_in:
executed_store_in (State_st I0 s0 C0 F0) r a v t t' t'' =
(i_assign t (e_val val_true) (o_internal (e_val a)) IN I0 /\ (* address *)
FLOOKUP s0 t = SOME a /\ (* completed internal *)
i_assign t' (e_val val_true) (o_internal (e_val v)) IN I0 /\ (* value *)
FLOOKUP s0 t' = SOME v /\ (* completed internal *)
i_assign t'' (e_val val_true) (o_store r t t') IN I0 /\ (* store value in r *)
FLOOKUP s0 t'' = SOME v (* executed r store *))
End
Definition completed_store_in:
(completed_store_in (State_st I0 s0 C0 F0) res_PC a v t t' t'' =
(executed_store_in (State_st I0 s0 C0 F0) res_PC a v t t' t'' /\ t'' IN F0))
/\
(completed_store_in st res_REG a v t t' t'' =
executed_store_in st res_REG a v t t' t'')
/\
(completed_store_in (State_st I0 s0 C0 F0) res_MEM a v t t' t'' =
(executed_store_in (State_st I0 s0 C0 F0) res_MEM a v t t' t'' /\ t'' IN C0))
End
(* FIXME: weaken claim about guards of t' and t''? *)
Definition initialized_resource_at_before:
(initialized_resource_at_before st res_PC a tmax =
(?t t' t'' v. completed_store_in st res_PC val_zero v t t' t'' /\ t'' < tmax))
/\
(initialized_resource_at_before st r a tmax =
(?t t' t'' v. completed_store_in st r a v t t' t'' /\ t'' < tmax))
End
(* FIXME: use t < tl? *)
Definition initialized_resource_in_set:
initialized_resource_in_set st r as =
(!a. a IN as ==> ?v t t' t''. completed_store_in st r a v t t' t'' /\
(!tl c ta. instr_in_State (i_assign tl c (o_load r ta)) st ==> t'' < tl))
End
Definition initialized_resource:
(initialized_resource st res_PC = initialized_resource_in_set st res_PC {val_zero})
/\
(initialized_resource st res_REG = initialized_resource_in_set st res_REG UNIV)
/\
(initialized_resource st res_MEM = initialized_resource_in_set st res_MEM UNIV)
End
Definition initialized_all_resources:
initialized_all_resources st = (!r. initialized_resource st r)
End
Definition state_program:
state_program (State_st I0 s0 C0 F0) = I0
End
Definition union_program_state:
union_program_state (State_st I0 s0 C0 F0) I1 =
State_st (I0 UNION I1) s0 C0 F0
End
Theorem initialized_all_resources_at_before:
!I0 s0 C0 F0 t c r ta a.
initialized_all_resources (State_st I0 s0 C0 F0) ==>
i_assign t c (o_load r ta) IN I0 ==>
initialized_resource_at_before (State_st I0 s0 C0 F0) r a t
Proof
rw [initialized_all_resources] >>
Q.PAT_X_ASSUM `!r. P` (STRIP_ASSUME_TAC o (Q.SPEC `r`)) >>
Cases_on `r` >>
fs [
initialized_resource,
initialized_resource_at_before,
completed_store_in,
executed_store_in,
initialized_resource_in_set,
instr_in_State
] >>
METIS_TAC []
QED
(* ------ *)
(* Values *)
(* ------ *)
Theorem UNIV_v_set_to_list_inv:
(UNIV:(v set)) = LIST_TO_SET (SET_TO_LIST (UNIV:(v set)))
Proof
`FINITE (UNIV:(v set))` by rw [WORD_FINITE] >>
rw [SET_TO_LIST_INV]
QED
Theorem UNIV_vv_FINITE:
FINITE (UNIV:(v # v) set)
Proof
rw [CROSS_UNIV,WORD_FINITE]
QED
(* argument line for that memory initialization does not necessarily make instruction set infinite *)
Theorem v_instr_FINITE[local]:
!I. (!i. i IN I ==> ?a t v. i = i_assign t (e_val val_true) (o_internal (e_val a))) /\
(!t t' c c' a. i_assign t c (o_internal (e_val a)) IN I /\ i_assign t' c' (o_internal (e_val a)) IN I ==> t = t') /\
(!i i'. i IN I ==> i' IN I ==> bound_name_instr i = bound_name_instr i' ==> i = i') ==>
FINITE I
Proof
rw [] >>
Q.ABBREV_TAC `f = (\i. case i of | i_assign _ _ (o_internal (e_val a)) => a | _ => val_zero)` >>
sg `FINITE (IMAGE f I')` >-
(`FINITE (UNIV:v set)` by rw [WORD_FINITE] >>
`(IMAGE f I') SUBSET (UNIV:v set)` by METIS_TAC [SUBSET_UNIV] >>
METIS_TAC [SUBSET_FINITE]) >>
`!x y. x IN I' /\ y IN I' ==> (f x = f y <=> x = y)` suffices_by METIS_TAC [FINITE_IMAGE_INJ'] >>
rw [] >>
`?a t. x = i_assign t (e_val val_true) (o_internal (e_val a))` by METIS_TAC [] >>
`?a t. y = i_assign t (e_val val_true) (o_internal (e_val a))` by METIS_TAC [] >>
rw [] >>
`a = a' ==> t = t'` by METIS_TAC [] >>
sg `t = t' ==> a = a'` >-
(rw [] >>
`i_assign t (e_val val_true) (o_internal (e_val a)) = i_assign t (e_val val_true) (o_internal (e_val a'))`
suffices_by fs [] >>
METIS_TAC [bound_name_instr]) >>
fs [Abbr `f`] >> METIS_TAC []
QED
Theorem v_set_FINITE:
!(as:v set). FINITE as
Proof
METIS_TAC [SUBSET_UNIV,WORD_FINITE,SUBSET_FINITE]
QED
Theorem vv_set_FINITE:
!(avs:(v # v) set). FINITE avs
Proof
METIS_TAC [SUBSET_UNIV,UNIV_vv_FINITE,SUBSET_FINITE]
QED
(* ---------------------------------------- *)
(* bound_names_program and bound_name_instr *)
(* ---------------------------------------- *)
Theorem bound_names_program_IMAGE:
!I. bound_names_program I = IMAGE bound_name_instr I
Proof
rw [bound_names_program,bound_name_instr,IMAGE_DEF] >>
fs [EXTENSION] >> rw [] >> EQ_TAC >> METIS_TAC []
QED
Theorem instr_in_bound_names_program:
!I t c mop. i_assign t c mop IN I ==>
t IN bound_names_program I
Proof
rw [bound_names_program] >>
Q.EXISTS_TAC `i_assign t c mop` >> rw [bound_name_instr]
QED
Theorem bound_names_program_in_instr:
!I t. t IN bound_names_program I ==>
?c mop. i_assign t c mop IN I
Proof
rw [bound_names_program] >>
Cases_on `i` >> rw [bound_name_instr] >>
Q.EXISTS_TAC `e` >> Q.EXISTS_TAC `o'` >> rw []
QED
Theorem bound_names_program_insert:
!t e mop I.
bound_names_program (i_assign t e mop INSERT I) =
t INSERT (bound_names_program I)
Proof
rw [bound_names_program] >> rw [INSERT_DEF] >>
rw [EXTENSION] >> EQ_TAC >> rw [] >| [
rw [bound_name_instr],
METIS_TAC [],
Q.EXISTS_TAC `i_assign t e mop` >> rw [bound_name_instr],
METIS_TAC []
]
QED
Theorem finite_bound_names_program:
!I. FINITE I ==>
FINITE (bound_names_program I)
Proof
HO_MATCH_MP_TAC FINITE_INDUCT >> rw [] >- rw [bound_names_program] >>
Cases_on `e` >> rw [bound_names_program_insert]
QED
Theorem bound_names_program_union:
!I I'.
bound_names_program (I UNION I') =
bound_names_program I UNION bound_names_program I'
Proof
rw [bound_names_program] >>
rw [EXTENSION] >> METIS_TAC []
QED
Theorem bound_names_program_SUBSET:
!I I'. I' SUBSET I ==>
bound_names_program I' SUBSET bound_names_program I
Proof
rw [bound_names_program, SUBSET_DEF] >>
Q.EXISTS_TAC `i` >> rw []
QED
Theorem store_in_flookup_eq:
!I s s' t t' c' r ta' tv'.
(!i. i IN I ==> !t''. t'' IN free_names_instr i ==> t'' < bound_name_instr i) ==>
i_assign t' c' (o_store r ta' tv') IN I ==>
(!t''. t'' IN FDOM s' ==> t'' >= t) ==>
t' < t ==>
FLOOKUP s ta' = FLOOKUP (FUNION s s') ta'
Proof
rw [] >>
`ta' IN free_names_instr (i_assign t' c' (o_store r ta' tv'))`
by rw [free_names_instr,names_o] >>
`ta' < t'` by METIS_TAC [bound_name_instr] >>
`~(ta' >= t)` by DECIDE_TAC >>
`~(ta' IN FDOM s')` by METIS_TAC [] >>
rw [FLOOKUP_FUNION] >> rw [FLOOKUP_DEF]
QED
Theorem load_t_in_flookup_eq:
!I s s' t c r ta.
(!i. i IN I ==> !t''. t'' IN free_names_instr i ==> t'' < bound_name_instr i) ==>
i_assign t c (o_load r ta) IN I ==>
(!t''. t'' IN FDOM s' ==> t'' >= t) ==>
FLOOKUP s ta = FLOOKUP (FUNION s s') ta
Proof
rw [] >>
`ta IN free_names_instr (i_assign t c (o_load r ta))` by rw [free_names_instr,names_o] >>
`ta < t` by METIS_TAC [bound_name_instr] >>
`~(ta >= t)` by DECIDE_TAC >>
`~(ta IN FDOM s')` by METIS_TAC [] >>
rw [FLOOKUP_FUNION] >> rw [FLOOKUP_DEF]
QED
Theorem store_t_in_flookup_eq:
!I s s' t c r ta tv.
(!i. i IN I ==> !t''. t'' IN free_names_instr i ==> t'' < bound_name_instr i) ==>
i_assign t c (o_store r ta tv) IN I ==>
(!t''. t'' IN FDOM s' ==> t'' >= t) ==>
FLOOKUP s ta = FLOOKUP (FUNION s s') ta
Proof
rw [] >>
`ta IN free_names_instr (i_assign t c (o_store r ta tv))` by rw [free_names_instr,names_o] >>
`ta < t` by METIS_TAC [bound_name_instr] >>
`~(ta >= t)` by DECIDE_TAC >>
`~(ta IN FDOM s')` by METIS_TAC [] >>
rw [FLOOKUP_FUNION] >> rw [FLOOKUP_DEF]
QED
(* ------------- *)
(* translate_val *)
(* ------------- *)
(* FIXME: need to validate that non-empty translate_val is possible *)
Theorem translate_val_correct:
!v t.
(FINITE (translate_val v t))
/\
(!i i'. i IN (translate_val v t) ==> i' IN (translate_val v t) ==>
bound_name_instr i = bound_name_instr i' ==> i = i')
/\
(!i. i IN (translate_val v t) ==> !t'. t' IN free_names_instr i ==>
t' < bound_name_instr i)
/\
(!i. i IN (translate_val v t) ==> !t'. t' IN names_instr i ==> t < t')
/\
(!i. i IN (translate_val v t) ==> !t'. t' IN free_names_instr i ==>
?i'. i' IN (translate_val v t) /\ bound_name_instr i' = t')
/\
(!t1 c1 mop1. i_assign t1 c1 mop1 IN (translate_val v t) ==>
!t2 c2 mop2. t2 IN names_e c1 ==>
i_assign t2 c2 mop2 IN (translate_val v t) ==> c2 = e_val val_true)
/\
(!t1 c1 mop1. i_assign t1 c1 mop1 IN (translate_val v t) ==>
!s v'. sem_expr c1 s = SOME v' ==> v' <> val_false ==>
!t2 c2 mop2 v''. t2 IN names_o mop1 ==>
i_assign t2 c2 mop2 IN (translate_val v t) ==>
sem_expr c2 s = SOME v'' ==> v'' <> val_false)
/\
(!t' c ta tv. i_assign t' c (o_store res_PC ta tv) IN (translate_val v t) ==>
i_assign ta (e_val val_true) (o_internal (e_val val_zero)) IN (translate_val v t))
/\
(!t' c ta. i_assign t' c (o_load res_PC ta) IN (translate_val v t) ==>
i_assign ta (e_val val_true) (o_internal (e_val val_zero)) IN (translate_val v t))
Proof
once_rewrite_tac [translate_val] >>
SELECT_ELIM_TAC >> fs [] >>
Q.EXISTS_TAC `\t v. {}` >> rw []
QED
Theorem translate_val_max_name_lt:
!I. FINITE I ==>
!i. i IN I ==> !i' v. i' IN translate_val v (MAX_SET (bound_names_program I)) ==>
bound_name_instr i < bound_name_instr i'
Proof
rw [] >>
`bound_name_instr i' IN names_instr i'` by rw [names_instr] >>
`MAX_SET (bound_names_program I') < bound_name_instr i'`
by METIS_TAC [translate_val_correct] >>
fs [] >>
`bound_name_instr i IN bound_names_program I'`
by (fs [bound_names_program] >> METIS_TAC [bound_name_instr]) >>
`bound_names_program I' <> {}`
by METIS_TAC [NOT_IN_EMPTY] >>
`bound_name_instr i <= MAX_SET (bound_names_program I')`
suffices_by DECIDE_TAC >>
`FINITE (bound_names_program I')`
suffices_by METIS_TAC [MAX_SET_DEF] >>
METIS_TAC [finite_bound_names_program]
QED
Theorem translate_val_max_name_lt_i_assign:
!I. FINITE I ==>
!t c mop. i_assign t c mop IN I ==>
!t' c' mop' v.
i_assign t' c' mop' IN translate_val v (MAX_SET (bound_names_program I)) ==>
t < t'
Proof
METIS_TAC [translate_val_max_name_lt,bound_name_instr]
QED
Theorem instr_not_in_I_translate_val_max_name:
!I t c c' mop mop' v. FINITE I ==>
~(i_assign t c mop IN I /\ i_assign t c' mop' IN translate_val v (MAX_SET (bound_names_program I)))
Proof
REPEAT STRIP_TAC >>
`t < t` suffices_by DECIDE_TAC >>
METIS_TAC [translate_val_max_name_lt_i_assign]
QED
Theorem instr_in_translate_val_name_not_in_program:
!I t c mop v. FINITE I ==>
i_assign t c mop IN translate_val v (MAX_SET (bound_names_program I)) ==>
~(t IN bound_names_program I)
Proof
rw [] >> once_rewrite_tac [bound_names_program] >> rw [] >>
Cases_on `i` >> rw [] >> fs [bound_name_instr] >>
METIS_TAC [instr_not_in_I_translate_val_max_name]
QED
Theorem instr_in_program_name_not_in_translate_val:
!I t c mop v. FINITE I ==> i_assign t c mop IN I ==>
~(t IN bound_names_program (translate_val v (MAX_SET (bound_names_program I))))
Proof
once_rewrite_tac [bound_names_program] >> rw [] >>
Cases_on `i` >> rw [] >> fs [bound_name_instr] >>
METIS_TAC [instr_not_in_I_translate_val_max_name]
QED
(* -------- *)
(* sem_expr *)
(* -------- *)
Theorem sem_expr_correct:
(!e s. ~(?v. sem_expr e s = SOME v) <=> ~(names_e e SUBSET FDOM s)) /\
(!e s s'. (!t. t IN names_e e ==> FLOOKUP s t = FLOOKUP s' t) ==>
sem_expr e s = sem_expr e s') /\
(!v s. sem_expr (e_val v) s = SOME v)
Proof
once_rewrite_tac [sem_expr] >>
SELECT_ELIM_TAC >> fs [] >>
Q.EXISTS_TAC
`\e s.
case e of
| e_val v => SOME v
| _ => if names_e e SUBSET FDOM s then SOME val_zero else NONE` >>
rw [] >-
(Cases_on `e` >> fs []) >-
(Cases_on `e` >> fs [names_e]) >-
(`names_e e <> {}` by METIS_TAC [EMPTY_SUBSET] >>
`?t. t IN names_e e /\ ~(t IN FDOM s') /\ t IN FDOM s`
by METIS_TAC [MEMBER_NOT_EMPTY,SUBSET_DEF] >>
`FLOOKUP s' t = NONE` by fs [FLOOKUP_DEF] >>
Cases_on `FLOOKUP s t` >- fs [FLOOKUP_DEF] >>
`FLOOKUP s t = FLOOKUP s' t` by METIS_TAC [] >>
fs []) >>
`names_e e <> {}` by METIS_TAC [EMPTY_SUBSET] >>
`?t. t IN names_e e /\ ~(t IN FDOM s) /\ t IN FDOM s'`
by METIS_TAC [MEMBER_NOT_EMPTY,SUBSET_DEF] >>
`FLOOKUP s t = NONE` by METIS_TAC [FLOOKUP_DEF] >>
Cases_on `FLOOKUP s' t` >- fs [FLOOKUP_DEF] >>
`FLOOKUP s t = FLOOKUP s' t` by METIS_TAC [] >>
fs []
QED
(* sanity checking sem_expr *)
Theorem sem_expr_no_names_eq[local]:
!e s s'. names_e e = {} ==> sem_expr e s = sem_expr e s'
Proof
rw [] >>
`!t. t IN names_e e ==> FLOOKUP s t = FLOOKUP s' t` by fs [] >>
METIS_TAC [sem_expr_correct]
QED
(* sanity checking sem_expr *)
Theorem sem_expr_deterministic[local]:
!e s s'.
(!t. t IN names_e e ==> ?v. FLOOKUP s t = SOME v /\ FLOOKUP s' t = SOME v) ==>
?v'. sem_expr e s = SOME v' /\ sem_expr e s' = SOME v'
Proof
rw [] >>
`!t v. FLOOKUP s t = SOME v ==> t IN FDOM s` by fs [FLOOKUP_DEF] >>
`!t. t IN names_e e ==> ?v. FLOOKUP s t = SOME v` by METIS_TAC [] >>
`names_e e SUBSET FDOM s` by METIS_TAC [SUBSET_DEF] >>
`?v'. sem_expr e s = SOME v'` by METIS_TAC [sem_expr_correct] >>
Q.EXISTS_TAC `v'` >> rw [] >>
METIS_TAC [sem_expr_correct]
QED
Theorem sem_expr_funion:
!s s' e v. sem_expr e s = SOME v ==>
sem_expr e (FUNION s s') = SOME v
Proof
rw [] >>
`names_e e SUBSET FDOM s`
by METIS_TAC [sem_expr_correct] >>
sg `!t. t IN names_e e ==> FLOOKUP s t = FLOOKUP (FUNION s s') t` >-
(rw [] >> `t IN FDOM s`
by METIS_TAC [SUBSET_DEF] >>
rw [FLOOKUP_FUNION] >>
Cases_on `FLOOKUP s t` >>
fs [FLOOKUP_DEF]) >>
METIS_TAC [sem_expr_correct]
QED
Theorem sem_expr_fupdate_none[local]:
!e s t v. sem_expr e (s |+ (t,v)) = NONE ==>
sem_expr e s = NONE
Proof
rw [] >>
`~(?v'. sem_expr e (s |+ (t,v)) = SOME v')`
by (Cases_on `sem_expr e (s |+ (t,v))` >> rw []) >>
`~(names_e e SUBSET (FDOM (s |+ (t,v))))`
by METIS_TAC [sem_expr_correct] >>
`?t'. t' IN names_e e /\ t' NOTIN FDOM (s |+ (t,v))`
by METIS_TAC [SUBSET_DEF] >>
`t' NOTIN FDOM s` by fs [FDOM_FUPDATE] >>
`~(names_e e SUBSET FDOM s)` by METIS_TAC [SUBSET_DEF] >>
`~(?v. sem_expr e s = SOME v)`
suffices_by (Cases_on `sem_expr e s` >> rw []) >>
METIS_TAC [sem_expr_correct]
QED
Theorem sem_expr_notin_names_fupdate_eq:
!e s t v. t NOTIN names_e e ==>
sem_expr e (s |+ (t,v)) = sem_expr e s
Proof
rw [] >>
`!t'. t' IN names_e e ==> FLOOKUP s t' = FLOOKUP (s |+ (t,v)) t'`
suffices_by METIS_TAC [sem_expr_correct] >>
rw [] >> Cases_on `t = t'` >> fs [] >>
fs [FLOOKUP_DEF,NOT_EQ_FAPPLY]
QED
Theorem sem_expr_notin_fdom_in_names[local]:
!e s t v. t NOTIN FDOM s ==> t IN names_e e ==>
sem_expr e s = NONE
Proof
rw [] >>
`~(names_e e SUBSET FDOM s)` by METIS_TAC [SUBSET_DEF] >>
`~(?v. sem_expr e s = SOME v)` by METIS_TAC [sem_expr_correct] >>
Cases_on `sem_expr e s` >> rw []
QED
(* FIXME: use sem_expr_funion to get rid of FDOM premise *)
Theorem sem_expr_notin_fdom_some_fupdate:
!e s t v v'. t NOTIN FDOM s ==> sem_expr e s = SOME v' ==>
sem_expr e (s |+ (t,v)) = SOME v'
Proof
rw [] >>
Cases_on `t IN names_e e` >-
(`sem_expr e s = NONE` suffices_by rw [] >>
METIS_TAC [sem_expr_notin_fdom_in_names]) >>
METIS_TAC [sem_expr_notin_names_fupdate_eq]
QED
Theorem store_in_sem_expr_eq:
!I s s' t t' c' mop.
(!i. i IN I ==> !t''. t'' IN free_names_instr i ==> t'' < bound_name_instr i) /\
(!t''. t'' IN FDOM s' ==> t'' >= t) /\
i_assign t' c' mop IN I /\
t' < t ==>
sem_expr c' s = sem_expr c' (FUNION s s')
Proof
rw [] >>
`!t''. t'' IN names_e c' ==> FLOOKUP s t'' = FLOOKUP (FUNION s s') t''`
suffices_by METIS_TAC [sem_expr_correct] >>
rw [FLOOKUP_FUNION] >>
Cases_on `FLOOKUP s t''` >> rw [] >>
Cases_on `FLOOKUP s' t''` >> rw [] >>
`t'' IN FDOM s'` by fs [FLOOKUP_DEF] >>
`t'' >= t` by METIS_TAC [] >>
`t'' IN free_names_instr (i_assign t' c' mop)`
by (Cases_on `mop` >> rw [free_names_instr]) >>
`t'' < bound_name_instr (i_assign t' c' mop)` by METIS_TAC [] >>
fs [bound_name_instr]
QED
Theorem sem_expr_FUPDATE_NOTIN3_EQ_SOME:
!s0 c t1 t2 t3 v1 v2 v3 v.
t1 NOTIN FDOM s0 ==>
t2 NOTIN FDOM s0 ==>
t3 NOTIN FDOM s0 ==>
sem_expr c s0 = SOME v ==>
sem_expr c (s0 |+ (t1,v1) |+ (t2,v2) |+ (t3,v3)) = SOME v
Proof
rw [] >>
`names_e c SUBSET FDOM s0` by METIS_TAC [sem_expr_correct] >>
`t1 NOTIN names_e c` by METIS_TAC [SUBSET_DEF] >>
`t2 NOTIN names_e c` by METIS_TAC [SUBSET_DEF] >>
`t3 NOTIN names_e c` by METIS_TAC [SUBSET_DEF] >>
rw [sem_expr_notin_names_fupdate_eq]
QED
Theorem sem_expr_funion_none:
!e s1 s2. sem_expr e (FUNION s1 s2) = NONE ==>
sem_expr e s1 = NONE
Proof
rw [] >>
Cases_on `sem_expr e s1` >> rw [] >>
`names_e e SUBSET FDOM s1` by METIS_TAC [sem_expr_correct] >>
`names_e e SUBSET FDOM (FUNION s1 s2)`
by (rw [FDOM_FUNION] >> rw [SUBSET_DEF] >> METIS_TAC [SUBSET_DEF]) >>
`?v. sem_expr e (FUNION s1 s2) = SOME v`
suffices_by fs [] >>
METIS_TAC [sem_expr_correct]
QED
(* ------- *)
(* addr_of *)
(* ------- *)
(* sanity checking addr_of *)
Theorem addr_of_empty[local]:
!t. addr_of {} t = NONE
Proof
rw [] >> fs [addr_of]
QED
(* sanity checking addr_of *)
Theorem addr_of_singleton_load[local]:
!t c r ta.
addr_of { (i_assign t c (o_load r ta)) } t = SOME (r,ta)
Proof
rw [] >> fs [addr_of] >> rw [] >- rw [EXTENSION] >>
`{(r',ta') | r' = r /\ ta' = ta} = {(r,ta)}`
suffices_by rw [CHOICE_SING] >>
rw [EXTENSION]
QED
(* sanity checking addr_of *)
Theorem addr_of_singleton_store[local]:
!t c r ta tv.
addr_of { (i_assign t c (o_store r ta tv)) } t = SOME (r,ta)
Proof
rw [] >> fs [addr_of] >> rw [] >- rw [EXTENSION] >>
`{(r',ta') | r' = r /\ ta' = ta} = {(r,ta)}`
suffices_by rw [CHOICE_SING] >>
rw [EXTENSION]
QED
Theorem addr_of_contains_unique_load:
!I. (!i i'. i IN I ==> i' IN I ==> bound_name_instr i = bound_name_instr i' ==> i = i') ==>
!t c r ta. i_assign t c (o_load r ta) IN I ==>
addr_of I t = SOME (r,ta)
Proof
rw [] >> fs [addr_of] >>
`{(r,ta) | (?c. i_assign t c (o_load r ta) IN I') \/
?c tv. i_assign t c (o_store r ta tv) IN I'} <> EMPTY`
by (rw [EXTENSION] >> METIS_TAC []) >>
rw [] >>
`!x. x IN {(r,ta) | (?c. i_assign t c (o_load r ta) IN I') \/
?c tv. i_assign t c (o_store r ta tv) IN I'} ==> x = (r,ta)`
suffices_by METIS_TAC [CHOICE_DEF] >>
rw [] >-
(`i_assign t c (o_load r ta) = i_assign t c' (o_load r' ta')`
suffices_by fs [] >>
METIS_TAC [bound_name_instr]) >>
`i_assign t c (o_load r ta) = i_assign t c' (o_store r' ta' tv)`
suffices_by fs [] >>
METIS_TAC [bound_name_instr]
QED
Theorem addr_of_contains_unique_store:
!I. (!i i'. i IN I ==> i' IN I ==> bound_name_instr i = bound_name_instr i' ==> i = i') ==>
!t c r ta tv. i_assign t c (o_store r ta tv) IN I ==>
addr_of I t = SOME (r,ta)
Proof
rw [] >> fs [addr_of] >>
`{(r,ta) | (?c. i_assign t c (o_load r ta) IN I') \/
?c tv. i_assign t c (o_store r ta tv) IN I'} <> EMPTY`
by (rw [EXTENSION] >> METIS_TAC []) >>
rw [] >>
`!x. x IN {(r,ta) | (?c. i_assign t c (o_load r ta) IN I') \/
?c tv. i_assign t c (o_store r ta tv) IN I'} ==>
x = (r,ta)`
suffices_by METIS_TAC [CHOICE_DEF] >>
rw [] >-
(`i_assign t c (o_store r ta tv) =
i_assign t c' (o_load r' ta')` suffices_by fs [] >>
METIS_TAC [bound_name_instr]) >>
`i_assign t c (o_store r ta tv) =
i_assign t c' (o_store r' ta' tv')` suffices_by fs [] >>
METIS_TAC [bound_name_instr]
QED
Theorem addr_of_no_t_none:
!I t. (!i. i IN I ==> bound_name_instr i <> t) ==>
addr_of I t = NONE
Proof
rw [] >> fs [addr_of] >> rw [EXTENSION] >>
METIS_TAC [bound_name_instr]
QED
Theorem addr_of_notin_bound_name_program_none:
!I t. t NOTIN bound_names_program I ==>
addr_of I t = NONE
Proof
rw [] >> fs [bound_names_program] >>
METIS_TAC [addr_of_no_t_none]
QED
Theorem addr_of_internal_none:
!I. (!i i'. i IN I ==> i' IN I ==> bound_name_instr i = bound_name_instr i' ==> i = i') ==>
!t c e. i_assign t c (o_internal e) IN I ==>
addr_of I t = NONE
Proof
rw [] >> fs [addr_of] >>
rw [EXTENSION] >> STRIP_TAC >-
(`i_assign t c (o_internal e) = i_assign t c' (o_load r ta)`
suffices_by rw [] >>
METIS_TAC [bound_name_instr]) >>
`i_assign t c (o_internal e) = i_assign t c' (o_store r ta tv)`
suffices_by rw [] >>
METIS_TAC [bound_name_instr]
QED
Theorem addr_of_some_exist_load_or_store:
!I t r ta. addr_of I t = SOME (r,ta) ==>
((?c. i_assign t c (o_load r ta) IN I) \/
(?c tv. i_assign t c (o_store r ta tv) IN I))
Proof
rw [] >> fs [addr_of] >>
`(r,ta) IN {(r,ta) |
(?c. i_assign t c (o_load r ta) IN I') \/
?c tv. i_assign t c (o_store r ta tv) IN I'}`
by METIS_TAC [CHOICE_DEF] >>
PAT_X_ASSUM ``P <> {}`` (fn thm => ALL_TAC) >>
fs [EXTENSION] >> METIS_TAC []
QED
Theorem addr_of_none_not_exist_load_or_store:
!I t. addr_of I t = NONE <=>
~(?c r ta. i_assign t c (o_load r ta) IN I) /\
~(?c r ta tv. i_assign t c (o_store r ta tv) IN I)
Proof
rw [] >> EQ_TAC >> rw [] >> fs [addr_of,EXTENSION]
QED
Theorem addr_of_union_I_eq:
!I I' t. (!t'. t' IN bound_names_program I' ==> t < t') ==>
addr_of I t = addr_of (I UNION I') t
Proof
rw [] >>
sg `!i. i IN I'' ==> bound_name_instr i <> t` >-
(rw [] >> Cases_on `i` >>
`n IN bound_names_program I''`
by (rw [bound_names_program] >> METIS_TAC [bound_name_instr]) >>
`t < n` by METIS_TAC [] >>
rw [bound_name_instr]) >>
PAT_X_ASSUM ``!t'. t' IN bound_names_program I'' ==> P`` (fn thm => ALL_TAC) >>
Cases_on `addr_of I' t` >> Cases_on `addr_of (I' UNION I'') t` >> rw [] >| [
Cases_on `x` >>
`(?c. i_assign t c (o_load q r) IN (I' UNION I'')) \/
(?c tv. i_assign t c (o_store q r tv) IN (I' UNION I''))`
by METIS_TAC [addr_of_some_exist_load_or_store] >-
(`i_assign t c (o_load q r) NOTIN I''`
by METIS_TAC [bound_name_instr] >>
`i_assign t c (o_load q r) IN I'` by fs [UNION_DEF] >>
METIS_TAC [addr_of_none_not_exist_load_or_store]) >>
`i_assign t c (o_store q r tv) NOTIN I''`
by METIS_TAC [bound_name_instr] >>
`i_assign t c (o_store q r tv) IN I'` by fs [UNION_DEF] >>
METIS_TAC [addr_of_none_not_exist_load_or_store],
Cases_on `x` >>
`(?c. i_assign t c (o_load q r) IN I') \/
(?c tv. i_assign t c (o_store q r tv) IN I')`
by METIS_TAC [addr_of_some_exist_load_or_store] >-
(`i_assign t c (o_load q r) IN (I' UNION I'')` by fs [UNION_DEF] >>
METIS_TAC [addr_of_none_not_exist_load_or_store]) >>
`i_assign t c (o_store q r tv) IN (I' UNION I'')` by fs [UNION_DEF] >>
METIS_TAC [addr_of_none_not_exist_load_or_store],
Cases_on `x` >> Cases_on `x'` >>
fs [addr_of] >>
`{(r,ta) |
(?c.
i_assign t c (o_load r ta) IN I' \/
i_assign t c (o_load r ta) IN I'') \/
?c tv.
i_assign t c (o_store r ta tv) IN I' \/
i_assign t c (o_store r ta tv) IN I''} =
{(r,ta) |
(?c. i_assign t c (o_load r ta) IN I') \/
?c tv. i_assign t c (o_store r ta tv) IN I'}`
suffices_by (rw [] >> fs []) >>
rw [EXTENSION] >> EQ_TAC >-
(rw [] >> METIS_TAC [bound_name_instr]) >>
METIS_TAC [bound_name_instr]
]
QED
Theorem addr_of_union_I_bn_eq[local]:
!I0 I1 s0 t.
(!i'. i' IN I1 ==> t < bound_name_instr i') ==>
addr_of (I0 UNION I1) t = addr_of I0 t
Proof
rw [] >>
`!t'. t' IN bound_names_program I1 ==> t < t'`
suffices_by METIS_TAC [addr_of_union_I_eq] >>
rw [] >>
fs [bound_names_program]
QED
Theorem addr_of_load_eq:
!I0 s0 C0 F0 t c r ta r' ta'.
(!i i'. i IN I0 ==> i' IN I0 ==> bound_name_instr i = bound_name_instr i' ==> i = i') ==>
i_assign t c (o_load r ta) IN I0 ==>
addr_of I0 t = SOME (r',ta') ==>
ta = ta' /\ r = r'
Proof
strip_tac >> strip_tac >> strip_tac >> strip_tac >> strip_tac >>
strip_tac >> strip_tac >> strip_tac >> strip_tac >> strip_tac >>
strip_tac >> strip_tac >> strip_tac >>
`(?c. i_assign t c (o_load r' ta') IN I0) \/
(?c tv. i_assign t c (o_store r' ta' tv) IN I0)` by METIS_TAC [addr_of_some_exist_load_or_store] >-
(`i_assign t c (o_load r ta) = i_assign t c' (o_load r' ta')` suffices_by fs [] >>
METIS_TAC [bound_name_instr]) >>
`i_assign t c (o_load r ta) = i_assign t c' (o_store r' ta' tv)` suffices_by fs [] >>
METIS_TAC [bound_name_instr]
QED
(* ------------------- *)
(* str_may and str_act *)
(* ------------------- *)
(* str_may sanity checking and consequences *)
Theorem in_str_may_store:
!I s C Fs t i. i IN str_may (State_st I s C Fs) t ==>
?t' c' r ta' tv'. i = i_assign t' c' (o_store r ta' tv')
Proof
rw [] >> fs [str_may]
QED
(* str_may sanity checking and consequences *)
Theorem in_str_may_load_or_store:
!I s C Fs t t' c' r ta' tv'.
i_assign t' c' (o_store r ta' tv') IN str_may (State_st I s C Fs) t ==>
(?c ta. i_assign t c (o_load r ta) IN I) \/
(?c ta tv. i_assign t c (o_store r ta tv) IN I)
Proof
rw [] >> fs [str_may] >>
METIS_TAC [addr_of_some_exist_load_or_store]
QED
Theorem str_may_union_I_F_eq:
!I0 I1 s0 C0 F0 F1 t.
(!i'. i' IN I1 ==> t < bound_name_instr i') ==>
str_may (State_st (I0 UNION I1) s0 C0 (F0 UNION F1)) t =
str_may (State_st I0 s0 C0 F0) t
Proof
rw [] >>
`addr_of (I0 UNION I1) t = addr_of I0 t` by METIS_TAC [addr_of_union_I_bn_eq] >>
fs [str_may] >> fs [EXTENSION] >> rw [] >> EQ_TAC >>
rw [] >> `t < t'` suffices_by DECIDE_TAC >> METIS_TAC [bound_name_instr]
QED
Theorem str_may_union_I_s_F_eq:
!I0 I1 s0 s1 C0 C1 F0 F1 t.
(!i. i IN I0 ==> !t'. t' IN free_names_instr i ==> t' < bound_name_instr i) ==>
(!i. i IN I1 ==> t < bound_name_instr i) ==>
(!t'. t' IN FDOM s1 ==> t' >= t) ==>
str_may (State_st (I0 UNION I1) (FUNION s0 s1) (C0 UNION C1) (F0 UNION F1)) t =
str_may (State_st I0 s0 C0 F0) t
Proof
rw [] >>
`addr_of (I0 UNION I1) t = addr_of I0 t` by METIS_TAC [addr_of_union_I_bn_eq] >>
fs [str_may] >> fs [EXTENSION] >> rw [] >> EQ_TAC >> rw [] >> fs [] >| [
`sem_expr c' s0 = SOME v` by METIS_TAC [store_in_sem_expr_eq] >>
`!t''. t'' IN FDOM s1 ==> t'' >= t'`
by (rw [] >> `t'' >= t` suffices_by DECIDE_TAC >> METIS_TAC []) >>
`FLOOKUP s0 ta' = FLOOKUP (FUNION s0 s1) ta'` by METIS_TAC [store_t_in_flookup_eq] >>
sg `FLOOKUP s0 ta = FLOOKUP (FUNION s0 s1) ta` >-
(`(?c. i_assign t c (o_load r ta) IN I0) \/ (?c tv. i_assign t c (o_store r ta tv) IN I0)`
by METIS_TAC [addr_of_some_exist_load_or_store] >-
METIS_TAC [load_t_in_flookup_eq] >>
METIS_TAC [store_t_in_flookup_eq]) >>
rw [],
`sem_expr c' s0 = SOME v` by METIS_TAC [store_in_sem_expr_eq] >>
`!t''. t'' IN FDOM s1 ==> t'' >= t'`
by (rw [] >> `t'' >= t` suffices_by DECIDE_TAC >> METIS_TAC []) >>
`FLOOKUP s0 ta' = FLOOKUP (FUNION s0 s1) ta'` by METIS_TAC [store_t_in_flookup_eq] >>
rw [],
`sem_expr c' s0 = SOME v` by METIS_TAC [store_in_sem_expr_eq] >>
`FLOOKUP s0 ta = NONE` by (Cases_on `FLOOKUP s0 ta` >> fs [FLOOKUP_FUNION]) >>
rw [],
`sem_expr c' s0 = NONE` by METIS_TAC [sem_expr_funion_none] >>
`!t''. t'' IN FDOM s1 ==> t'' >= t'`
by (rw [] >> `t'' >= t` suffices_by DECIDE_TAC >> METIS_TAC []) >>
`FLOOKUP s0 ta' = FLOOKUP (FUNION s0 s1) ta'` by METIS_TAC [store_t_in_flookup_eq] >>
sg `FLOOKUP s0 ta = FLOOKUP (FUNION s0 s1) ta` >-
(`(?c. i_assign t c (o_load r ta) IN I0) \/ (?c tv. i_assign t c (o_store r ta tv) IN I0)`
by METIS_TAC [addr_of_some_exist_load_or_store] >-
METIS_TAC [load_t_in_flookup_eq] >>
METIS_TAC [store_t_in_flookup_eq]) >>
rw [],
`sem_expr c' s0 = NONE` by METIS_TAC [sem_expr_funion_none] >>
`FLOOKUP s0 ta' = NONE` by (Cases_on `FLOOKUP s0 ta'` >> fs [FLOOKUP_FUNION]) >>
rw [],
`sem_expr c' s0 = NONE` by METIS_TAC [sem_expr_funion_none] >>
`FLOOKUP s0 ta = NONE` by (Cases_on `FLOOKUP s0 ta` >> fs [FLOOKUP_FUNION]) >>
rw [],
`t < t'` suffices_by DECIDE_TAC >>
METIS_TAC [bound_name_instr],
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`t < t'` by METIS_TAC [bound_name_instr] >>
`~(t < t')` by DECIDE_TAC,
`sem_expr c' (FUNION s0 s1) = SOME v` by rw [sem_expr_funion] >>
rw [FLOOKUP_FUNION],
`sem_expr c' (FUNION s0 s1) = SOME v` by rw [sem_expr_funion] >>
`!t''. t'' IN FDOM s1 ==> t'' >= t'`
by (rw [] >> `t'' >= t` suffices_by DECIDE_TAC >> METIS_TAC []) >>
`FLOOKUP s0 ta' = FLOOKUP (FUNION s0 s1) ta'` by METIS_TAC [store_t_in_flookup_eq] >>
`FLOOKUP (FUNION s0 s1) ta' = NONE` by fs [] >>
rw [],
`sem_expr c' (FUNION s0 s1) = SOME v` by rw [sem_expr_funion] >>
sg `FLOOKUP s0 ta = FLOOKUP (FUNION s0 s1) ta` >-
(`(?c. i_assign t c (o_load r ta) IN I0) \/ (?c tv. i_assign t c (o_store r ta tv) IN I0)`
by METIS_TAC [addr_of_some_exist_load_or_store] >-
METIS_TAC [load_t_in_flookup_eq] >>
METIS_TAC [store_t_in_flookup_eq]) >>
`FLOOKUP (FUNION s0 s1) ta = NONE` by fs [] >>
rw [],
`sem_expr c' (FUNION s0 s1) = NONE` by METIS_TAC [store_in_sem_expr_eq] >>
`!t''. t'' IN FDOM s1 ==> t'' >= t'`
by (rw [] >> `t'' >= t` suffices_by DECIDE_TAC >> METIS_TAC []) >>
`FLOOKUP s0 ta' = FLOOKUP (FUNION s0 s1) ta'` by METIS_TAC [store_t_in_flookup_eq] >>
sg `FLOOKUP s0 ta = FLOOKUP (FUNION s0 s1) ta` >-
(`(?c. i_assign t c (o_load r ta) IN I0) \/ (?c tv. i_assign t c (o_store r ta tv) IN I0)`
by METIS_TAC [addr_of_some_exist_load_or_store] >-
METIS_TAC [load_t_in_flookup_eq] >>
METIS_TAC [store_t_in_flookup_eq]) >>
`FLOOKUP (FUNION s0 s1) ta' = SOME v` by fs [] >>
`FLOOKUP (FUNION s0 s1) ta = SOME v` by fs [] >>
rw [],
`sem_expr c' (FUNION s0 s1) = NONE` by METIS_TAC [store_in_sem_expr_eq] >>
`!t''. t'' IN FDOM s1 ==> t'' >= t'`
by (rw [] >> `t'' >= t` suffices_by DECIDE_TAC >> METIS_TAC []) >>
`FLOOKUP s0 ta' = FLOOKUP (FUNION s0 s1) ta'` by METIS_TAC [store_t_in_flookup_eq] >>
`FLOOKUP (FUNION s0 s1) ta' = NONE` by fs [] >>
rw [],
`sem_expr c' (FUNION s0 s1) = NONE` by METIS_TAC [store_in_sem_expr_eq] >>
sg `FLOOKUP s0 ta = FLOOKUP (FUNION s0 s1) ta` >-
(`(?c. i_assign t c (o_load r ta) IN I0) \/ (?c tv. i_assign t c (o_store r ta tv) IN I0)`
by METIS_TAC [addr_of_some_exist_load_or_store] >-
METIS_TAC [load_t_in_flookup_eq] >>
METIS_TAC [store_t_in_flookup_eq]) >>
`FLOOKUP (FUNION s0 s1) ta = NONE` by fs [] >>
rw []
]
QED
(* sanity checking str_act *)
Theorem str_act_in_I:
!I s C Fs t i. i IN str_act (State_st I s C Fs) t ==> i IN I
Proof
rw [] >> fs [str_act,str_may]
QED
(* sanity checking str_may *)
Theorem str_may_in_I:
!I s C Fs t i. i IN str_may (State_st I s C Fs) t ==> i IN I
Proof
rw [] >> fs [str_may]