-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathcrep_to_loopProofScript.sml
3948 lines (3807 loc) · 130 KB
/
crep_to_loopProofScript.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
(*
Correctness proof for ---
*)
open preamble
crepSemTheory crepPropsTheory
loopLangTheory loopSemTheory loopPropsTheory
pan_commonTheory pan_commonPropsTheory
listRangeTheory rich_listTheory
loop_liveProofTheory crep_to_loopTheory
crep_arithProofTheory
val _ = new_theory "crep_to_loopProof";
val _ = set_grammar_ancestry
["listRange", "rich_list", "crepProps",
"loopProps", "pan_commonProps",
"loop_liveProof", "crep_to_loop"];
val _ = temp_delsimps ["fromAList_def", "domain_union",
"domain_inter", "domain_difference",
"domain_map", "sptree.map_def", "sptree.lookup_rwts",
"sptree.insert_notEmpty", "sptree.isEmpty_union"];
Theorem evaluate_nested_seq_append_first =
evaluate_nested_seq_cases |> CONJUNCT1
Theorem evaluate_none_nested_seq_append =
evaluate_nested_seq_cases |> CONJUNCT2 |> CONJUNCT1
Theorem evaluate_not_none_nested_seq_append =
evaluate_nested_seq_cases |> CONJUNCT2 |> CONJUNCT2
(* state relation *)
val s = ``(s:('a,'ffi) crepSem$state)``
Definition state_rel_def:
state_rel (s:('a,'ffi) crepSem$state) (t:('a,'ffi) loopSem$state) <=>
s.memaddrs = t.mdomain ∧
s.sh_memaddrs = t.sh_mdomain ∧
s.clock = t.clock ∧
s.be = t.be ∧
s.ffi = t.ffi ∧
s.base_addr = t.base_addr
End
(*
Loc encodes label of a function, e.g:
Loc n1 n2 represents the label n2
inside the function n1
*)
Definition wlab_wloc_def:
(wlab_wloc _ (Word w) = Word w) /\
(wlab_wloc funcs (Label fname) =
case FLOOKUP funcs fname of
| SOME (n, _) => Loc n 0
| NONE => Loc 0 0) (* impossible *)
End
Definition mem_rel_def:
mem_rel funcs smem tmem <=>
!ad. wlab_wloc funcs (smem ad) = tmem ad /\
!f. smem ad = Label f ==>
?n m. FLOOKUP funcs f = SOME (n, m)
End
Definition globals_rel_def:
globals_rel funcs sglobals tglobals <=>
!ad v. FLOOKUP sglobals ad = SOME v ==>
FLOOKUP tglobals ad = SOME (wlab_wloc funcs v) /\
!f. v = Label f ==>
?n m. FLOOKUP funcs f = SOME (n, m)
End
Definition distinct_funcs_def:
distinct_funcs fm <=>
!x y n m rm rm'. FLOOKUP fm x = SOME (n, rm) /\
FLOOKUP fm y = SOME (m, rm') /\ n = m ==> x = y
End
(* could have been stated differently *)
Definition ctxt_fc_def:
ctxt_fc c cvs ns args =
<|vars := FEMPTY |++ ZIP (ns, args);
funcs := cvs;
vmax := list_max args;
target := c
|>
End
Definition code_rel_def:
code_rel ctxt s_code t_code <=>
distinct_funcs ctxt.funcs /\
∀f ns prog.
FLOOKUP s_code f = SOME (ns, prog) ==>
?loc len. FLOOKUP ctxt.funcs f = SOME (loc, len) /\
LENGTH ns = len /\
let args = GENLIST I len;
nctxt = ctxt_fc ctxt.target ctxt.funcs ns args in
lookup loc t_code =
SOME (args,
ocompile nctxt (list_to_num_set args) prog)
End
Definition ctxt_max_def:
ctxt_max (n:num) fm <=>
!v m. FLOOKUP fm v = SOME m ==> m <= n
End
Definition distinct_vars_def:
distinct_vars fm <=>
(!x y n m. FLOOKUP fm x = SOME n /\
FLOOKUP fm y = SOME m /\ n = m ==> x = y)
End
Definition locals_rel_def:
locals_rel ctxt (l:sptree$num_set) (s_locals:num |-> 'a word_lab) t_locals <=>
distinct_vars ctxt.vars /\ ctxt_max ctxt.vmax ctxt.vars /\ domain l ⊆ domain t_locals /\
∀vname v.
FLOOKUP s_locals vname = SOME v ==>
∃n. FLOOKUP ctxt.vars vname = SOME n ∧ n ∈ domain l ∧
lookup n t_locals = SOME (wlab_wloc ctxt.funcs v) /\
!f. v = Label f ==>
?n m. FLOOKUP ctxt.funcs f = SOME (n, m)
End
val goal =
``λ(prog, s). ∀res s1 t ctxt l.
evaluate (prog,s) = (res,s1) ∧ res ≠ SOME Error ∧
state_rel s t ∧ mem_rel ctxt.funcs s.memory t.memory ∧
globals_rel ctxt.funcs s.globals t.globals ∧
code_rel ctxt s.code t.code ∧
locals_rel ctxt l s.locals t.locals ⇒
∃ck res1 t1. evaluate (compile ctxt l prog,
t with clock := t.clock + ck) = (res1,t1) /\
state_rel s1 t1 ∧ mem_rel ctxt.funcs s1.memory t1.memory ∧
globals_rel ctxt.funcs s1.globals t1.globals ∧
code_rel ctxt s1.code t1.code ∧
(res1 = case res of
NONE => NONE
| SOME Break => SOME Break
| SOME Continue => SOME Continue
| SOME (Return v) => SOME (Result (wlab_wloc ctxt.funcs v))
| SOME (Exception eid) => SOME (Exception (Word eid))
| SOME TimeOut => SOME TimeOut
| SOME (FinalFFI f) => SOME (FinalFFI f)
| SOME Error => SOME Error) ∧
(case res of
| NONE => locals_rel ctxt l s1.locals t1.locals
| SOME Break => locals_rel ctxt l s1.locals t1.locals
| SOME Continue => locals_rel ctxt l s1.locals t1.locals
| SOME (Return v) => (!f. v = Label f ==> f ∈ FDOM ctxt.funcs)
| SOME Error => F
| _ => T)``
local
val ind_thm = crepSemTheory.evaluate_ind
|> ISPEC goal
|> CONV_RULE (DEPTH_CONV PairRules.PBETA_CONV) |> REWRITE_RULE [];
fun list_dest_conj tm = if not (is_conj tm) then [tm] else let
val (c1,c2) = dest_conj tm in list_dest_conj c1 @ list_dest_conj c2 end
val ind_goals = ind_thm |> concl |> dest_imp |> fst |> list_dest_conj
in
fun get_goal s = first (can (find_term (can (match_term (Term [QUOTE s]))))) ind_goals
fun compile_prog_tm () = ind_thm |> concl |> rand
fun the_ind_thm () = ind_thm
end
Theorem state_rel_intro:
state_rel ^s (t:('a,'ffi) loopSem$state) <=>
s.memaddrs = t.mdomain ∧
s.sh_memaddrs = t.sh_mdomain ∧
s.clock = t.clock ∧
s.be = t.be ∧
s.ffi = t.ffi ∧
s.base_addr = t.base_addr
Proof
rw [state_rel_def]
QED
Theorem locals_rel_intro:
locals_rel ctxt l (s_locals:num |-> 'a word_lab) t_locals ==>
distinct_vars ctxt.vars /\ ctxt_max ctxt.vmax ctxt.vars /\ domain l ⊆ domain t_locals /\
∀vname v.
FLOOKUP s_locals vname = SOME v ==>
∃n. FLOOKUP ctxt.vars vname = SOME n ∧ n ∈ domain l ∧
lookup n t_locals = SOME (wlab_wloc ctxt.funcs v) /\
!f. v = Label f ==>
?n m. FLOOKUP ctxt.funcs f = SOME (n, m)
Proof
rw [locals_rel_def]
QED
Theorem code_rel_intro:
code_rel ctxt s_code t_code ==>
distinct_funcs ctxt.funcs /\
∀f ns prog.
FLOOKUP s_code f = SOME (ns, prog) ==>
?loc len. FLOOKUP ctxt.funcs f = SOME (loc, len) /\
LENGTH ns = len /\
let args = GENLIST I len;
nctxt = ctxt_fc ctxt.target ctxt.funcs ns args in
lookup loc t_code =
SOME (args,
ocompile nctxt (list_to_num_set args) prog)
Proof
rw [code_rel_def]
QED
Theorem mem_rel_intro:
mem_rel funcs smem tmem ==>
!ad. wlab_wloc funcs (smem ad) = tmem ad /\
!f. smem ad = Label f ==>
?n m. FLOOKUP funcs f = SOME (n, m)
Proof
rw [mem_rel_def] >>
metis_tac []
QED
Theorem globals_rel_intro:
globals_rel funcs sglobals tglobals ==>
!ad v. FLOOKUP sglobals ad = SOME v ==>
FLOOKUP tglobals ad = SOME (wlab_wloc funcs v) /\
!f. v = Label f ==>
?n m. FLOOKUP funcs f = SOME (n, m)
Proof
rw [globals_rel_def] >> metis_tac []
QED
Theorem state_rel_clock_add_zero:
!s t. state_rel s t ==>
?ck. state_rel s (t with clock := ck + t.clock)
Proof
rw [] >>
qexists_tac ‘0’ >>
fs [state_rel_def, state_component_equality]
QED
Theorem locals_rel_insert_gt_vmax:
!ct cset lcl lcl' n w.
locals_rel ct cset lcl lcl' /\ ct.vmax < n ==>
locals_rel ct cset lcl (insert n w lcl')
Proof
rw [] >>
fs [locals_rel_def, SUBSET_INSERT_RIGHT, AllCaseEqs(),
lookup_insert, ctxt_max_def] >>
rw [] >> rpt (res_tac >> fs [])
QED
Theorem locals_rel_cutset_prop:
!ct cset lcl lcl' cset' lcl''.
locals_rel ct cset lcl lcl' /\
locals_rel ct cset' lcl lcl'' /\
subspt cset cset' ==>
locals_rel ct cset lcl lcl''
Proof
rw [locals_rel_def]
>- metis_tac [subspt_domain, SUBSET_TRANS] >>
res_tac >> fs [] >> rveq >> fs []
QED
Theorem write_bytearray_mem_rel:
!nb funcs sm tm w dm be.
mem_rel funcs sm tm ==>
mem_rel funcs (write_bytearray w nb sm dm be)
(write_bytearray w nb tm dm be)
Proof
Induct >>
rw [panSemTheory.write_bytearray_def,
wordSemTheory.write_bytearray_def] >>
TOP_CASE_TAC >> fs []
>- (
‘mem_store_byte_aux (write_bytearray (w + 1w) nb tm dm be) dm be
w h = NONE’ suffices_by fs [] >>
fs [panSemTheory.mem_store_byte_def,
wordSemTheory.mem_store_byte_aux_def,
CaseEq "word_lab", CaseEq "option"]
>- (TOP_CASE_TAC >> fs []) >>
first_x_assum drule >>
disch_then (qspecl_then [‘w+1w’, ‘dm’, ‘be’] mp_tac) >>
strip_tac >> fs [] >>
last_x_assum kall_tac >>
fs [mem_rel_def] >>
first_x_assum (qspec_then ‘byte_align w’ mp_tac) >>
strip_tac >>
rfs [] >> pop_assum mp_tac >>
pop_assum (mp_tac o GSYM) >>
rw [] >> fs [wlab_wloc_def]) >>
fs [panSemTheory.mem_store_byte_def,
wordSemTheory.mem_store_byte_aux_def,
CaseEq "word_lab", CaseEq "option"] >>
rveq >>
first_x_assum drule >>
disch_then (qspecl_then [‘w+1w’, ‘dm’, ‘be’] mp_tac) >>
strip_tac >> fs [] >>
fs [mem_rel_def] >>
rw []
>- (
fs [APPLY_UPDATE_THM] >>
TOP_CASE_TAC >> fs []
>- (
first_x_assum (qspec_then ‘ad’ assume_tac) >>
rfs [] >> pop_assum (assume_tac o GSYM) >>
fs [] >>
fs [wlab_wloc_def] >>
fs [APPLY_UPDATE_THM]) >>
TOP_CASE_TAC >> fs [CaseEq "word_loc", CaseEq "option"]
>- (
first_x_assum (qspec_then ‘byte_align w’ assume_tac) >>
rfs [wlab_wloc_def]) >>
rveq >> fs [APPLY_UPDATE_THM]) >>
fs [APPLY_UPDATE_THM] >>
FULL_CASE_TAC >> fs [] >>
res_tac >> fs []
QED
(*
Theorem mem_rel_ctxt_vmax_preserve:
mem_rel (ctxt with vmax := m) s.memory t.memory ==>
mem_rel ctxt s.memory t.memory
Proof
rw [mem_rel_def] >>
fs [] >>
first_x_assum (qspec_then ‘ad’ assume_tac) >>
fs [] >>
cases_on ‘s.memory ad’ >>
cases_on ‘t.memory ad’ >>
fs [wlab_wloc_def]
QED
Theorem globals_rel_ctxt_vmax_preserve:
globals_rel (ctxt with vmax := m) s.globals t.globals ==>
globals_rel ctxt s.globals t.globals
Proof
rw [globals_rel_def] >>
fs [] >>
TRY (cases_on ‘v’) >>
fs [wlab_wloc_def] >>
res_tac >> fs [wlab_wloc_def]
QED
*)
Theorem evaluate_comb_seq:
!p s t q r.
loopSem$evaluate (p,s) = (NONE, t) /\ loopSem$evaluate (q,t) = (NONE,r) ==>
loopSem$evaluate (Seq p q,s) = (NONE,r)
Proof
rw [] >>
fs [evaluate_def]
QED
Theorem cut_sets_MAPi_Assign:
∀les cs offset.
cut_sets cs (nested_seq (MAPi (λn. Assign (n + offset)) les)) =
list_insert (GENLIST ($+ offset) (LENGTH les)) cs
Proof
Induct_on ‘les’ \\
rw[nested_seq_def,cut_sets_def,list_insert_def,o_DEF,GENLIST_CONS] \\
PURE_ONCE_REWRITE_TAC[DECIDE “∀n m. n + SUC m = m + SUC n”] \\
first_x_assum $ PURE_REWRITE_TAC o single \\
rpt (AP_THM_TAC ORELSE AP_TERM_TAC) \\
simp[FUN_EQ_THM]
QED
Theorem assigned_vars_MAPi_Assign:
∀les offset.
assigned_vars (nested_seq (MAPi (λn. Assign (n + offset)) les)) =
GENLIST ($+ offset) (LENGTH les)
Proof
Induct_on ‘les’ \\
rw[nested_seq_def,assigned_vars_def,o_DEF,GENLIST_CONS] \\
PURE_ONCE_REWRITE_TAC[DECIDE “∀n m. n + SUC m = m + SUC n”] \\
first_x_assum $ PURE_REWRITE_TAC o single \\
rpt (AP_THM_TAC ORELSE AP_TERM_TAC) \\
simp[FUN_EQ_THM]
QED
Theorem survives_MAPi_Assign:
∀n les offset.
survives n (nested_seq (MAPi (λn. Assign (n + offset)) les)) = T
Proof
Induct_on ‘les’ \\
rw[nested_seq_def,survives_def,o_DEF,GENLIST_CONS] \\
PURE_ONCE_REWRITE_TAC[DECIDE “∀n m. n + SUC m = m + SUC n”] \\
first_x_assum $ PURE_REWRITE_TAC o single \\
rpt (AP_THM_TAC ORELSE AP_TERM_TAC) \\
simp[FUN_EQ_THM]
QED
Theorem insert_insert_eq:
insert a b $ insert a b c = insert a b c
Proof
rw[Once insert_insert]
QED
Theorem list_insert_SNOC:
∀y l x.
list_insert (SNOC x y) l =
insert x () $ list_insert y l
Proof
Induct_on ‘y’ \\ rw[list_insert_def]
QED
Theorem compile_exps_alt:
compile_exps ctxt tmp l [] = ([],[],tmp,l) ∧
compile_exps ctxt tmp l (e::es) =
let
(p,le,tmp',l') = compile_exp ctxt tmp l e;
(p1,les,tmp'',l'') = compile_exps ctxt tmp' l' es
in
(p ++ p1,le::les,tmp'',l'')
Proof
rw[] \\ rw[Once compile_exp_def]
QED
Theorem list_insert_insert:
∀x xs l. insert x () $ list_insert xs l = list_insert xs $ insert x () l
Proof
Induct_on ‘xs’ \\ rw[list_insert_def] \\
rename1 ‘insert a () $ insert b () _’ \\
Cases_on ‘a = b’ \\ rw[insert_shadow,insert_swap]
QED
Theorem list_insert_append:
∀xs ys l. list_insert (xs ++ ys) l = list_insert xs $ list_insert ys l
Proof
Induct \\ rw[list_insert_def,list_insert_insert]
QED
Theorem compile_exp_out_rel_cases:
(!ct tmp l (e:'a crepLang$exp) p le ntmp nl.
compile_exp ct tmp l e = (p,le,ntmp, nl) ==>
comp_syntax_ok l (nested_seq p) /\ tmp <= ntmp /\ nl = cut_sets l (nested_seq p)) /\
(!ct tmp l (e:'a crepLang$exp list) p le ntmp nl.
compile_exps ct tmp l e = (p,le,ntmp, nl) ==>
comp_syntax_ok l (nested_seq p) /\ tmp <= ntmp /\ nl = cut_sets l (nested_seq p) /\
LENGTH le = LENGTH e)
Proof
ho_match_mp_tac compile_exp_ind >>
rpt conj_tac >> rpt gen_tac >> strip_tac >>
TRY (
fs [Once compile_exp_def] >> rveq >>
TRY (pairarg_tac >> fs [] >> rveq >> NO_TAC) >>
fs [nested_seq_def, comp_syntax_ok_def, cut_sets_def] >> NO_TAC)
>- (
rename [‘compile_exp _ _ _ (LoadByte e)’] >>
rpt gen_tac >> strip_tac >>
conj_asm1_tac
>- (
fs [compile_exp_def] >>
pairarg_tac >> fs [] >> rveq >> fs [] >>
match_mp_tac comp_syn_ok_nested_seq >>
fs [] >>
fs [nested_seq_def] >>
rpt (
match_mp_tac comp_syn_ok_seq2 >>
fs [comp_syntax_ok_def])) >>
fs [compile_exp_def] >>
pairarg_tac >> fs [] >> rveq >>
res_tac >> fs [] >>
imp_res_tac comp_syn_ok_nested_seq2 >>
last_x_assum assume_tac >>
qmatch_goalsub_abbrev_tac ‘p' ++ np’ >>
fs [cut_sets_nested_seq] >>
fs [Abbr ‘np’] >> pop_assum kall_tac >>
fs [nested_seq_def, cut_sets_def, Once insert_insert])
>- (
rename [‘compile_exp _ _ _ (Op _ _)’] >>
fs [Once compile_exp_def] >>
pairarg_tac >> fs [] >> rveq >>
cases_on ‘e’
>- fs [compile_exp_def] >>
fs [] >>
fs [Once compile_exp_def])
>- (
rename [‘compile_exp _ _ _ (Crepop _ _)’] >>
simp [Once compile_exp_def] >>
pairarg_tac >> fs [] >> rveq >>
rpt gen_tac >> disch_then strip_assume_tac >>
Cases_on ‘cop’ >>
gvs[DefnBase.one_line_ify NONE compile_crepop_def,ELIM_UNCURRY,AllCaseEqs()] >>
(conj_asm1_tac
>- (rpt (match_mp_tac comp_syn_ok_nested_seq >> conj_tac) >>
rw[] >>
simp[nested_seq_def,comp_syntax_ok_def]
>- (rpt $ pop_assum kall_tac >>
rename1 ‘comp_syntax_ok cs’ >>
qid_spec_tac ‘cs’ >>
qid_spec_tac ‘tmp'’ >>
Induct_on ‘les’ >> gvs[nested_seq_def,comp_syntax_ok_def] >>
simp[o_DEF] >>
rpt strip_tac >>
first_x_assum(qspec_then ‘SUC tmp'’ mp_tac) >>
rename1 ‘comp_syntax_ok css’ >>
disch_then(qspec_then ‘css’ mp_tac) >>
qmatch_goalsub_abbrev_tac ‘a1 ⇒ a2’ >>
‘a1 = a2’ suffices_by simp[] >>
unabbrev_all_tac >>
ntac 2 AP_TERM_TAC >>
match_mp_tac MAPi_CONG >>
rw[]) >>
simp[cut_sets_nested_seq,nested_seq_def,cut_sets_def,cut_sets_MAPi_Assign,
comp_syntax_ok_def] >>
simp[insert_swap] >>
conj_tac >> qexists_tac ‘[]’ >> simp[insert_swap,insert_shadow])) >>
rw[] >>
simp[cut_sets_nested_seq,nested_seq_def,cut_sets_def,cut_sets_MAPi_Assign] >>
simp[insert_insert_eq] >>
simp[Once insert_insert,SimpR “$=”,insert_insert_eq] >>
simp[insert_insert_eq,GSYM ADD1,GENLIST,list_insert_SNOC] >>
simp[insert_swap,insert_shadow] >>
rw[CONV_RULE (STRIP_QUANT_CONV $ LHS_CONV $ PURE_ONCE_REWRITE_CONV [ADD_SYM]) GENLIST_APPEND] \\
rw[list_insert_append,list_insert_insert,list_insert_def,insert_swap,ADD1])
>- (
rename [‘compile_exp _ _ _ (Cmp _ _ _)’] >>
rpt gen_tac >> strip_tac >>
fs [compile_exp_def] >>
pairarg_tac >> fs [] >>
pairarg_tac >> fs [] >> rveq >>
conj_tac
>- (
fs [prog_if_def] >>
match_mp_tac comp_syn_ok_nested_seq >>
conj_tac
>- (
match_mp_tac comp_syn_ok_nested_seq >>
fs []) >>
fs [list_insert_def, nested_seq_def, cut_sets_def] >>
fs [comp_syntax_ok_def] >>
fs [cut_sets_def] >>
rw [Once comp_syntax_ok_def, list_insert_def] >>
fs [cut_sets_nested_seq] >>
qmatch_goalsub_abbrev_tac ‘insert t2 _ (insert t1 _ cc)’ >>
qexists_tac ‘[t1;t2]’ >>
simp[] >>
Cases_on ‘t1 = t2’ >> simp[insert_swap,insert_shadow]) >>
res_tac >> fs [] >>
qmatch_goalsub_abbrev_tac ‘list_insert _ ll’ >>
fs [prog_if_def] >>
qmatch_goalsub_abbrev_tac ‘p' ++ p'' ++ np’ >>
‘comp_syntax_ok l (nested_seq (p' ++ p''))’ by (
match_mp_tac comp_syn_ok_nested_seq >>
fs []) >>
‘comp_syntax_ok (cut_sets l (nested_seq (p' ++ p''))) (nested_seq np)’ by (
fs [Abbr ‘np’, nested_seq_def] >>
ntac 3 (rw [Once comp_syntax_ok_def]) >>
rw [Once comp_syntax_ok_def, cut_sets_def, Abbr ‘l''’, list_insert_def] >>
fs [cut_sets_nested_seq,comp_syntax_ok_def] >>
qmatch_goalsub_abbrev_tac ‘insert t2 _ (insert t1 _ cc)’ >>
qexists_tac ‘[t1;t2]’ >>
simp[] >>
Cases_on ‘t1 = t2’ >> simp[insert_swap,insert_shadow]) >>
qpat_x_assum ‘comp_syntax_ok l (nested_seq (p' ++ p''))’ assume_tac >>
fs [cut_sets_nested_seq] >>
fs [Abbr ‘np’, nested_seq_def, cut_sets_def]) >>
rpt gen_tac >>
strip_tac >>
cases_on ‘e’ >> fs []
>- (
fs [compile_exp_def] >>
rveq >> fs [] >>
fs [nested_seq_def, Once comp_syntax_ok_def, every_prog_def, cut_sets_def]) >>
pop_assum mp_tac >>
once_rewrite_tac [compile_exp_def] >> fs [] >>
pairarg_tac >> fs [] >>
pairarg_tac >> fs [] >> rveq >>
cases_on ‘t’
>- (
fs [compile_exp_def] >>
strip_tac >> rveq >> fs []) >>
strip_tac >> fs [] >> rveq >>
conj_tac >- metis_tac [subspt_trans, comp_syn_ok_nested_seq] >>
fs [cut_sets_nested_seq]
QED
Theorem compile_exp_out_rel = compile_exp_out_rel_cases |> CONJUNCT1
Theorem compile_exps_out_rel = compile_exp_out_rel_cases |> CONJUNCT2
Theorem comp_exp_assigned_vars_tmp_bound_cases:
(!ct tmp l (e :α crepLang$exp) p le ntmp nl n.
compile_exp ct tmp l e = (p,le,ntmp,nl) /\ MEM n (assigned_vars (nested_seq p)) ==>
tmp <= n /\ n < ntmp) /\
(!ct tmp l (e :α crepLang$exp list) p le ntmp nl n.
compile_exps ct tmp l e = (p,le,ntmp,nl) /\ MEM n (assigned_vars (nested_seq p)) ==>
tmp <= n /\ n < ntmp)
Proof
ho_match_mp_tac compile_exp_ind >>
rpt conj_tac >> rpt gen_tac >> strip_tac >>
TRY (
fs [Once compile_exp_def] >> TRY (pairarg_tac >> fs []) >>
rveq >> fs [nested_seq_def, assigned_vars_def] >> NO_TAC)
>- (
rpt gen_tac >> strip_tac >>
fs [compile_exp_def] >> rveq >>
pairarg_tac >> fs [] >> rveq >>
drule compile_exp_out_rel >>
strip_tac >> fs [] >>
fs [assigned_vars_nested_seq_split]
>- (res_tac >> fs []) >>
fs [nested_seq_def, assigned_vars_def])
>- (
once_rewrite_tac [compile_exp_def] >> fs [] >> strip_tac >>
pairarg_tac >> fs [])
>- (
once_rewrite_tac [compile_exp_def] >> fs [DefnBase.one_line_ify NONE compile_crepop_def] >> strip_tac >>
PURE_TOP_CASE_TAC >> fs[] >>
pairarg_tac >> fs [] >>
‘tmp <= tmp'’ by metis_tac [compile_exp_out_rel_cases] >>
rw[] >>
gvs[assigned_vars_nested_seq_split,nested_seq_def,assigned_vars_def,assigned_vars_MAPi_Assign,
MEM_GENLIST] >>
res_tac >>
DECIDE_TAC
)
>- (
rpt gen_tac >> strip_tac >>
fs [compile_exp_def] >>
pairarg_tac >> fs [] >>
pairarg_tac >> fs [] >> rveq >>
fs [prog_if_def] >>
‘tmp <= tmp' /\ tmp' <= tmp''’ by metis_tac [compile_exp_out_rel_cases] >>
dxrule compile_exp_out_rel >>
dxrule compile_exp_out_rel >>
strip_tac >> fs [] >>
fs [assigned_vars_nested_seq_split]
>- (res_tac >> fs [])
>- (res_tac >> fs []) >>
fs [nested_seq_def] >>
fs [assigned_vars_seq_split, assigned_vars_def]) >>
rpt gen_tac >> strip_tac >>
pop_assum mp_tac >> fs [] >>
once_rewrite_tac [compile_exp_def] >>
cases_on ‘e’ >> fs []
>- (
fs [compile_exp_def] >> rveq >>
fs [nested_seq_def, assigned_vars_def]) >>
pop_assum mp_tac >>
once_rewrite_tac [compile_exp_def] >>
fs [] >>
pairarg_tac >> fs [] >>
pairarg_tac >> fs [] >>
strip_tac >> rveq >> fs [] >>
strip_tac >>
‘tmp <= tmp' /\ tmp' <= ntmp’ by metis_tac [compile_exp_out_rel_cases] >>
fs [assigned_vars_nested_seq_split] >>
res_tac >> fs []
QED
Theorem comp_exp_assigned_vars_tmp_bound = comp_exp_assigned_vars_tmp_bound_cases |> CONJUNCT1
Theorem comp_exps_assigned_vars_tmp_bound = comp_exp_assigned_vars_tmp_bound_cases |> CONJUNCT2
Theorem compile_exp_le_tmp_domain_cases:
(!ct tmp l (e:'a crepLang$exp) p le tmp' l' n.
ctxt_max ct.vmax ct.vars /\
compile_exp ct tmp l e = (p,le,tmp', l') /\ ct.vmax < tmp /\
(!n. MEM n (var_cexp e) ==> ?m. FLOOKUP ct.vars n = SOME m /\ m ∈ domain l) /\
MEM n (locals_touched le) ==> n < tmp' /\ n ∈ domain l') /\
(!ct tmp l (es:'a crepLang$exp list) p les tmp' l' n.
ctxt_max ct.vmax ct.vars /\
compile_exps ct tmp l es = (p,les,tmp', l') /\ ct.vmax < tmp /\
(!n. MEM n (FLAT (MAP var_cexp es)) ==> ?m. FLOOKUP ct.vars n = SOME m /\ m ∈ domain l) /\
MEM n (FLAT (MAP locals_touched les)) ==> n < tmp' /\ n ∈ domain l')
Proof
ho_match_mp_tac compile_exp_ind >>
rpt conj_tac >> rpt gen_tac >> strip_tac
>~ [‘Op bop es’] >-
(rpt gen_tac >>
strip_tac >>
qpat_x_assum ‘compile_exp _ _ _ _ = _’ mp_tac >>
once_rewrite_tac [compile_exp_def] >>
strip_tac >> fs [] >>
pairarg_tac >> fs [] >> rveq >>
fs [locals_touched_def, crepLangTheory.var_cexp_def, ETA_AX])
>~ [‘Crepop bop es’] >-
(rpt gen_tac >>
strip_tac >>
qpat_x_assum ‘compile_exp _ _ _ _ = _’ mp_tac >>
once_rewrite_tac [compile_exp_def] >>
strip_tac >> fs [DefnBase.one_line_ify NONE compile_crepop_def] >>
Cases_on ‘bop’ >>
rpt(pairarg_tac >> fs [] >> rveq) >>
fs [locals_touched_def, crepLangTheory.var_cexp_def, ETA_AX,AllCaseEqs()]
)
>~ [‘compile_exps’] >-
(rpt gen_tac >>
strip_tac >>
qpat_x_assum ‘compile_exps _ _ _ _ = _’ mp_tac >>
once_rewrite_tac [compile_exp_def] >>
cases_on ‘es’ >> fs [] >> rveq
>- (
strip_tac >> rveq >>
fs [MAP]) >>
strip_tac >>
pairarg_tac >> fs [] >>
pairarg_tac >> fs [] >> rveq >>
‘tmp <= tmp'' /\ tmp'' <= tmp' /\ l'' = cut_sets l (nested_seq p') /\
l' = cut_sets l'' (nested_seq p1)’ by
metis_tac [compile_exp_out_rel_cases] >>
fs [MAP]
>- (
res_tac >> fs [subspt_domain] >>
drule compile_exps_out_rel >>
strip_tac >>
drule cut_sets_union_domain_union >>
strip_tac >> fs []) >>
last_x_assum match_mp_tac >>
fs [] >>
rw [] >>
res_tac >> fs [subspt_domain] >>
drule compile_exp_out_rel >>
strip_tac >>
drule cut_sets_union_domain_union >>
strip_tac >> fs []) >>
fs [compile_exp_def] >>
TRY (pairarg_tac >> fs []) >> rveq >>
TRY (pairarg_tac >> fs []) >> rveq >>
fs [locals_touched_def, find_var_def, crepLangTheory.var_cexp_def,
ctxt_max_def, list_insert_def] >>
rfs [] >> rveq >> res_tac >> fs []
QED
Theorem compile_exp_le_tmp_domain = compile_exp_le_tmp_domain_cases |> CONJUNCT1
Theorem compile_exps_le_tmp_domain = compile_exp_le_tmp_domain_cases |> CONJUNCT2
Theorem comp_exp_preserves_eval:
∀s e v (t :('a, 'b) state) ctxt tmp l p le ntmp nl.
eval s e = SOME v /\
state_rel s t /\ mem_rel ctxt.funcs s.memory t.memory /\
globals_rel ctxt.funcs s.globals t.globals /\
code_rel ctxt s.code t.code /\
locals_rel ctxt l s.locals t.locals /\
compile_exp ctxt tmp l e = (p,le, ntmp, nl) /\
ctxt.vmax < tmp ==>
?ck st. evaluate (nested_seq p,t with clock := t.clock + ck) = (NONE,st) /\
eval st le = SOME (wlab_wloc ctxt.funcs v) /\
state_rel s st /\ mem_rel ctxt.funcs s.memory st.memory /\
globals_rel ctxt.funcs s.globals st.globals /\
code_rel ctxt s.code st.code /\
locals_rel ctxt nl s.locals st.locals
Proof
ho_match_mp_tac crepSemTheory.eval_ind >>
rpt conj_tac >> rpt gen_tac >> strip_tac
>~ [‘eval s $ Op bop es’] >-
(rename [‘eval s (Op op es)’] >>
rw [] >>
fs [Once compile_exp_def] >> fs [] >>
pairarg_tac >> fs [] >> rveq >>
fs [crepSemTheory.eval_def, CaseEq "option"] >> rveq >>
fs [loopSemTheory.eval_def, wlab_wloc_def] >>
qsuff_tac ‘∃ck st.
evaluate (nested_seq p,t with clock := ck + t.clock) = (NONE,st) ∧
the_words (MAP (λa. eval st a) les) =
SOME ((MAP (λw. case w of Word n => n | Label v1 => ARB) ws)) /\
state_rel s st ∧ mem_rel ctxt.funcs s.memory st.memory ∧
globals_rel ctxt.funcs s.globals st.globals ∧
code_rel ctxt s.code st.code ∧ locals_rel ctxt l' s.locals st.locals’
>- (
strip_tac >>
qexists_tac ‘ck’ >>
fs [wlab_wloc_def]) >>
qpat_x_assum ‘word_op _ _ = _’ kall_tac >>
rpt (pop_assum mp_tac) >>
MAP_EVERY qid_spec_tac [‘t’, ‘p’, ‘les’ , ‘tmp’, ‘l’,‘ws’, ‘es’] >>
Induct
>- (
rw [] >>
fs [OPT_MMAP_def] >> rveq >>
fs [compile_exp_def] >> rveq >>
fs [nested_seq_def, loopSemTheory.evaluate_def,
wordSemTheory.the_words_def, state_rel_clock_add_zero]) >>
rw [] >>
last_x_assum mp_tac >>
impl_tac >- metis_tac [] >>
strip_tac >> fs [] >>
qpat_x_assum ‘compile_exps _ _ _ (h::_) = _’ mp_tac >>
once_rewrite_tac [compile_exp_def] >>
fs [] >> pairarg_tac >> fs [] >>
pairarg_tac >> fs [] >>
strip_tac >> rveq >>
fs [OPT_MMAP_def] >> rveq >>
last_x_assum (qspec_then ‘h’ mp_tac) >>
fs [] >>
disch_then drule_all >>
strip_tac >> fs [] >> rveq >>
qmatch_asmsub_rename_tac ‘compile_exp _ _ _ h = (p,le,itmp,il)’ >>
qmatch_asmsub_rename_tac ‘compile_exps _ _ _ _ = (fp,les,ntmp,nl)’ >>
last_x_assum (qspecl_then
[‘t'’, ‘il’, ‘itmp’, ‘les’, ‘fp’, ‘st’] mp_tac) >>
fs [] >>
imp_res_tac compile_exp_out_rel >>
fs [] >>
strip_tac >> fs [] >>
qpat_x_assum ‘evaluate (nested_seq p, _) = _’ assume_tac >>
drule evaluate_add_clock_eq >>
fs [] >>
disch_then (qspec_then ‘ck'’ assume_tac) >>
drule evaluate_comb_seq >>
disch_then drule >>
fs [evaluate_nested_seq_comb_seq] >>
strip_tac >>
qexists_tac ‘ck + ck'’ >>
qexists_tac ‘st'’ >>
fs [] >>
cases_on ‘h'’ >> fs [] >>
fs [wordSemTheory.the_words_def] >>
‘eval st' le = eval st le’ suffices_by fs [wlab_wloc_def] >>
imp_res_tac compile_exps_out_rel >>
qpat_x_assum ‘evaluate (nested_seq fp, _) = _’ assume_tac >>
drule comp_syn_ok_upd_local_clock >>
disch_then drule >>
fs [] >> strip_tac >>
qpat_x_assum ‘evaluate (nested_seq p,_) = _’ mp_tac >>
once_rewrite_tac [ADD_ASSOC] >>
strip_tac >>
fs [wlab_wloc_def] >>
assume_tac nested_seq_pure_evaluation >>
pop_assum (qspecl_then [‘p’, ‘fp’, ‘t’, ‘st'’, ‘st with clock := ck' + st.clock’, ‘l’,
‘itmp’, ‘le’, ‘Word c’, ‘ck + ck'’, ‘0’] mp_tac) >>
fs [] >>
impl_tac
>- (
fs [eval_upd_clock_eq] >>
drule comp_exp_assigned_vars_tmp_bound >> fs [] >>
strip_tac >>
drule comp_exps_assigned_vars_tmp_bound >> fs [] >>
strip_tac >>
gen_tac >>
strip_tac >> fs [] >>
imp_res_tac locals_rel_intro >>
drule compile_exp_le_tmp_domain >>
disch_then (qspecl_then [‘tmp’, ‘l’, ‘h’, ‘p’, ‘le’,
‘itmp’, ‘cut_sets l (nested_seq p)’, ‘n’] mp_tac) >>
fs [] >>
impl_tac
>- (
rw [] >>
drule eval_some_var_cexp_local_lookup >>
disch_then drule >>
strip_tac >> res_tac >> fs []) >>
fs []) >>
fs [])
>~ [‘eval s $ Crepop bop es’] >-
(rw [] >>
fs [Once compile_exp_def] >> fs [] >>
pairarg_tac >> fs [] >> rveq >>
fs [crepSemTheory.eval_def, CaseEq "option"] >> rveq >>
fs [loopSemTheory.eval_def, wlab_wloc_def] >>
fs [wlab_wloc_def] >>
gvs[AllCaseEqs(),DefnBase.one_line_ify NONE crep_op_def,
DefnBase.one_line_ify NONE compile_crepop_def,MAP_EQ_CONS,
opt_mmap_eq_some,SF DNF_ss,
compile_exps_alt
] >>
rpt (pairarg_tac >> gvs[]) >>
gvs[AllCaseEqs()] >>
rpt $ qpat_x_assum ‘SOME _ = _’ $ assume_tac o GSYM >>
first_x_assum drule_all >> strip_tac >>
first_x_assum drule >> rpt $ disch_then drule >>
(impl_keep_tac
>- (imp_res_tac compile_exp_out_rel_cases >> DECIDE_TAC) >>
strip_tac >>
qexists_tac ‘ck + ck'’ >>
qpat_x_assum ‘evaluate _ = (NONE,_)’ mp_tac >>
drule loopPropsTheory.evaluate_add_clock_eq >>
disch_then(qspec_then ‘ck'’ mp_tac) >>
impl_tac >> simp[] >>
strip_tac >>
FULL_SIMP_TAC std_ss [GSYM APPEND_ASSOC] >>
drule_then (PURE_REWRITE_TAC o single) (cj 2 evaluate_nested_seq_cases) >>
strip_tac >>
drule_then (PURE_REWRITE_TAC o single) (cj 2 evaluate_nested_seq_cases) >>
drule_then drule nested_seq_pure_evaluation >>
disch_then $ drule_at $ Pos last >>
imp_res_tac compile_exp_out_rel_cases >> rveq >>
ntac 2 $ disch_then drule >>
simp[GSYM PULL_EXISTS] >>
impl_tac >-
(qexists_tac ‘tmp''’ (* generated name *) >>
rw[] >>
imp_res_tac comp_exp_assigned_vars_tmp_bound_cases >>
TRY DECIDE_TAC >>
MAP_FIRST match_mp_tac [cj 1 compile_exp_le_tmp_domain,
cj 2 compile_exp_le_tmp_domain] >>
imp_res_tac locals_rel_intro >>
first_x_assum $ irule_at $ Pos last >>
ntac 2 $ first_x_assum $ irule_at $ Pos hd >>
simp[] >>
rw[] >>
drule_all eval_some_var_cexp_local_lookup >>
metis_tac[]) >>
strip_tac >>
simp[evaluate_def,nested_seq_def,eval_def,loop_arith_def,set_var_def,lookup_insert] >>
rename1 ‘eval(st' with locals := insert tmp' (wlab_wloc ctxt.funcs (Word ww)) st'.locals) lee’ >>
‘∀w. eval (set_var tmp' (wlab_wloc ctxt.funcs w) st') lee
=
eval st' lee
’
by(strip_tac >>
match_mp_tac locals_touched_eq_eval_eq >>
simp[set_var_def] >>
imp_res_tac locals_rel_intro >>
drule compile_exp_le_tmp_domain >>
disch_then $ drule_then drule >>
simp[GSYM AND_IMP_INTRO,GSYM PULL_FORALL] >>
impl_tac
>- (rw[] >>
imp_res_tac eval_some_var_cexp_local_lookup >>
metis_tac[]) >>
rw[] >>
res_tac >>
rw[lookup_insert]) >>
gvs[set_var_def] >>
simp[set_var_def,wlab_wloc_def,lookup_insert,GSYM word_mul_def] >>
simp[word_mul_def] >>
conj_tac >- gvs[state_rel_def] >>
gvs[locals_rel_def,list_insert_def] >>
conj_tac
>- (drule_then match_mp_tac SUBSET_TRANS >>
rw[SUBSET_DEF]) >>
rw[] >>
res_tac >>
gvs[] >>
gvs[ctxt_max_def] >>
res_tac >>
rw[lookup_insert]))
>~ [‘Const w’] >-
(fs [crepSemTheory.eval_def, compile_exp_def] >> rveq >>
fs [nested_seq_def, evaluate_def, eval_def,
wlab_wloc_def, state_rel_clock_add_zero])
>~ [‘eval s (Var vname)’] >-
(fs [crepSemTheory.eval_def, compile_exp_def] >> rveq >>
fs [nested_seq_def, evaluate_def, find_var_def] >>
imp_res_tac locals_rel_intro >>
fs [eval_def, state_rel_clock_add_zero])
>~ [‘eval s (Label fname)’] >-
(fs [crepSemTheory.eval_def, compile_exp_def, CaseEq "option"] >>
rveq >>
qexists_tac ‘0’ >> fs [] >>
‘t with clock := t.clock = t’ by fs [state_component_equality] >>
fs [] >> pop_assum kall_tac >>
fs [nested_seq_def, evaluate_def, find_lab_def] >>
cases_on ‘v1’ >> rveq >>
imp_res_tac code_rel_intro >>
fs [eval_def, set_var_def, domain_lookup, wlab_wloc_def,
state_rel_def, locals_rel_def, SUBSET_INSERT_RIGHT] >>
rw [] >>
first_x_assum drule >> fs [] >>
strip_tac >> fs [] >>
fs [lookup_insert] >>
TOP_CASE_TAC >> fs [] >>
fs [ctxt_max_def] >>
first_x_assum drule >> fs [])
>~ [‘eval s (Load e)’] >-
(fs [crepSemTheory.eval_def] >>
TOP_CASE_TAC >> fs [] >>
TOP_CASE_TAC >> fs [] >>
rw [] >>
fs [compile_exp_def] >>
pairarg_tac >> fs [] >> rveq >>
last_x_assum drule_all >> fs [] >> rveq >>
strip_tac >> fs [] >>
qexists_tac ‘ck’ >> fs [] >>
fs [loopSemTheory.eval_def, wlab_wloc_def] >>
fs [crepSemTheory.mem_load_def, loopSemTheory.mem_load_def] >> rveq >>
imp_res_tac state_rel_intro >>
imp_res_tac mem_rel_intro >>
last_x_assum (qspec_then ‘c’ mp_tac) >> fs [])
>~ [‘eval s (LoadByte e)’] >-
(fs [crepSemTheory.eval_def] >>
TOP_CASE_TAC >> fs [] >>
TOP_CASE_TAC >> fs [] >>
TOP_CASE_TAC >> fs [] >>
rw [] >>
fs [compile_exp_def] >>
pairarg_tac >> fs [] >> rveq >>
last_x_assum drule_all >>
fs [] >> rveq >>
strip_tac >> fs [] >>
qexists_tac ‘ck’ >> fs [] >>
drule evaluate_none_nested_seq_append >>
disch_then (qspec_then
‘[Assign tmp' le'; LoadByte tmp' tmp']’ mp_tac) >>
strip_tac >> fs [] >>
pop_assum kall_tac >>
fs [nested_seq_def, loopSemTheory.evaluate_def] >>
fs [set_var_def, wlab_wloc_def] >>
fs [panSemTheory.mem_load_byte_def, CaseEq "word_lab",
wordSemTheory.mem_load_byte_aux_def] >>
imp_res_tac mem_rel_intro >>
last_x_assum (qspec_then ‘byte_align c’ (mp_tac o GSYM)) >>
strip_tac >> fs [] >>
last_x_assum (qspec_then ‘byte_align c’ (mp_tac o GSYM)) >>
strip_tac >> fs [wlab_wloc_def] >>
imp_res_tac state_rel_intro >>
fs [eval_def, state_rel_def] >>
imp_res_tac compile_exp_out_rel >>
fs [locals_rel_def, SUBSET_INSERT_RIGHT] >> rw [] >>