-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmilExecutableUtilityScript.sml
2152 lines (1994 loc) · 74.7 KB
/
milExecutableUtilityScript.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 wordsLib optionTheory wordsTheory pred_setTheory listTheory rich_listTheory finite_mapTheory relationTheory sortingTheory ottTheory milUtilityTheory milTheory milSemanticsUtilityTheory milTracesTheory milMetaTheory milStoreTheory;
(* ========================================== *)
(* MIL semantics executable utility functions *)
(* ========================================== *)
val _ = new_theory "milExecutableUtility";
(* --------------------- *)
(* Auxiliary definitions *)
(* --------------------- *)
Definition FIND_instr:
(FIND_instr t ([]:i list) : i option = NONE)
/\
(FIND_instr t (i::il) = if bound_name_instr i = t then SOME i else FIND_instr t il)
End
Definition FILTER_instr:
FILTER_instr t (l:i list) : i list =
FILTER ($= t o bound_name_instr) l
End
Definition NO_DUPLICATE:
NO_DUPLICATE (i:'a) (l:'a list) = (MEM i l ==> UNIQUE i l)
End
Definition NO_DUPLICATES:
NO_DUPLICATES (l:i list) = ALL_DISTINCT (MAP bound_name_instr l)
End
Definition NO_DUPLICATES_ALT:
NO_DUPLICATES_ALT (l:i list) = (!t. NO_DUPLICATE t (MAP bound_name_instr l))
End
Definition NONCONT_SUBLIST:
(NONCONT_SUBLIST l [] = T)
/\
(NONCONT_SUBLIST [] (h::t) = F)
/\
(NONCONT_SUBLIST (h1::t1) (h2::t2) =
((h1 = h2 /\ NONCONT_SUBLIST t1 t2) \/ (NONCONT_SUBLIST t1 (h2::t2))))
End
Definition MEM_bound_name_instr_unique:
MEM_bound_name_instr_unique l =
(!i i'. MEM i l ==> MEM i' l ==>
bound_name_instr i = bound_name_instr i' ==>
i = i')
End
(* ------------------------------- *)
(* Concrete datatypes and mappings *)
(* ------------------------------- *)
Datatype:
State_list = State_st_list (i list) s (t list) (t list)
End
(* convert State_st_list to State_st *)
Definition state_list_to_state:
state_list_to_state (State_st_list l s c fs) =
State_st (LIST_TO_SET l) s (LIST_TO_SET c) (LIST_TO_SET fs)
End
Datatype:
act_list = act_exe_list | act_cmt_list v v | act_ftc_list (i list)
End
Definition act_list_to_act:
(act_list_to_act act_exe_list = act_exe)
/\
(act_list_to_act (act_cmt_list a v) = act_cmt a v)
/\
(act_list_to_act (act_ftc_list l) = act_ftc (LIST_TO_SET l))
End
Datatype:
ll = ll_lb obs act_list t
End
Definition ll_to_l:
ll_to_l (ll_lb (obs:obs) (al:act_list) (t:t)) = l_lb obs (act_list_to_act al) t
End
Definition State_st_list_ok:
State_st_list_ok (State_st_list l s cs fs) = NO_DUPLICATES l
End
Definition State_st_list_well_formed_ok:
State_st_list_well_formed_ok (State_st_list l s c fs) =
(NO_DUPLICATES l /\ well_formed_state (state_list_to_state (State_st_list l s c fs)))
End
Definition instr_in_State_list:
instr_in_State_list i (State_st_list l s cs fs) = MEM i l
End
(* ------------------------------------ *)
(* Executable semantic helper functions *)
(* ------------------------------------ *)
Definition addr_of_list:
addr_of_list (il:i list) (t:t) : (res # t) option =
case FIND_instr t il of
| SOME (i_assign t' c (o_load r ta)) => SOME (r,ta)
| SOME (i_assign t' c (o_store r ta tv)) => SOME (r,ta)
| _ => NONE
End
(* find the certain store operations *)
Definition str_may_list_find:
(str_may_list_find (f:e -> (t |-> v) -> v option) ([]:i list) (s:(t |-> v)) (t:t) (r:res) (ta:t): i list = [])
/\
(str_may_list_find f ((i_assign t' c' (o_internal e))::ls) s t r ta = str_may_list_find f ls s t r ta)
/\
(str_may_list_find f ((i_assign t' c' (o_load r' ta'))::ls) s t r ta = str_may_list_find f ls s t r ta)
/\
(str_may_list_find f ((i_assign t' c' (o_store r' ta' tv'))::ls) s t r ta =
case FLOOKUP s ta' of
| NONE =>
if (t' >= t) \/ (r' <> r) then
str_may_list_find f ls s t r ta
else
(case f c' s of
| NONE => i_assign t' c' (o_store r' ta' tv')::str_may_list_find f ls s t r ta
| SOME v =>
if v <> val_false then
i_assign t' c' (o_store r' ta' tv')::str_may_list_find f ls s t r ta
else
str_may_list_find f ls s t r ta)
| SOME v1 =>
case FLOOKUP s ta of
| NONE =>
if (t' >= t) \/ (r' <> r) then
str_may_list_find f ls s t r ta
else
(case f c' s of
| NONE => i_assign t' c' (o_store r' ta' tv')::str_may_list_find f ls s t r ta
| SOME v =>
if v <> val_false then
i_assign t' c' (o_store r' ta' tv')::str_may_list_find f ls s t r ta
else
str_may_list_find f ls s t r ta)
| SOME v2 =>
if (t' >= t) \/ (r' <> r) \/ (v1 <> v2) then
str_may_list_find f ls s t r ta
else
(case f c' s of
| NONE => i_assign t' c' (o_store r' ta' tv')::str_may_list_find f ls s t r ta
| SOME v =>
if v <> val_false then
i_assign t' c' (o_store r' ta' tv')::str_may_list_find f ls s t r ta
else
str_may_list_find f ls s t r ta))
End
Definition str_may_list:
str_may_list (f: e -> (t |-> v) -> v option) ((State_st_list l s cs fs):State_list) (t:t) : i list =
case addr_of_list l t of
| SOME (r,ta) => str_may_list_find f l s t r ta
| NONE => []
End
Definition str_act_list_cond:
(str_act_list_cond (f:e -> (t |-> v) -> v option) ([]:i list) (s:(t |-> v)) (t':t) (r':res) (ta':t) (ta:t): i list = [])
/\
(str_act_list_cond f ((i_assign t'' c'' (o_internal e))::ls) s t' r' ta' ta = str_act_list_cond f ls s t' r' ta' ta)
/\
(str_act_list_cond f ((i_assign t'' c'' (o_load r'' ta''))::ls) s t' r' ta' ta = str_act_list_cond f ls s t' r' ta' ta)
/\
(str_act_list_cond f ((i_assign t'' c'' (o_store r'' ta'' tv''))::ls) s t' r' ta' ta =
case f c'' s of
| NONE => str_act_list_cond f ls s t' r' ta' ta
| SOME fv =>
case FLOOKUP s ta'' of
| SOME v1 =>
(case FLOOKUP s ta' of
| SOME v2 =>
(case FLOOKUP s ta of
| SOME v3 =>
if (t'' > t') /\ (r'' = r') /\ (fv <> val_false) /\ (v1 = v2 \/ v1 = v3) then
(i_assign t'' c'' (o_store r'' ta'' tv''))::(str_act_list_cond f ls s t' r' ta' ta)
else
str_act_list_cond f ls s t' r' ta' ta
| NONE =>
if (t'' > t') /\ (r'' = r') /\ (fv <> val_false) /\ (v1 = v2) then
(i_assign t'' c'' (o_store r'' ta'' tv''))::(str_act_list_cond f ls s t' r' ta' ta)
else
str_act_list_cond f ls s t' r' ta' ta)
| NONE =>
(case FLOOKUP s ta of
| SOME v3 =>
if (t'' > t') /\ (r'' = r') /\ (fv <> val_false) /\ (v1 = v3) then
(i_assign t'' c'' (o_store r'' ta'' tv''))::(str_act_list_cond f ls s t' r' ta' ta)
else
str_act_list_cond f ls s t' r' ta' ta
| NONE => str_act_list_cond f ls s t' r' ta' ta))
| NONE => str_act_list_cond f ls s t' r' ta' ta)
End
Definition str_act_list_find:
(str_act_list_find (f:e -> (t |-> v) -> v option) ([]:i list) (s:(t |-> v)) (r:res) (ta:t) (l1:i list): i list = [])
/\
(str_act_list_find f ((i_assign t' c' (o_internal e))::ls) s r ta l1 = str_act_list_find f ls s r ta l1)
/\
(str_act_list_find f ((i_assign t' c' (o_load r' ta'))::ls) s r ta l1 = str_act_list_find f ls s r ta l1)
/\
(str_act_list_find f ((i_assign t' c' (o_store r' ta' tv'))::ls) s r ta l1 =
case str_act_list_cond f l1 s t' r' ta' ta of
| [] =>
if r' <> r then str_act_list_find f ls s r ta l1
else i_assign t' c' (o_store r' ta' tv')::str_act_list_find f ls s r ta l1
| _ => str_act_list_find f ls s r ta l1)
End
Definition str_act_list:
str_act_list (f:e -> (t |-> v) -> v option) ((State_st_list l s fs cs):State_list) (t:t) : i list =
case addr_of_list l t of
| NONE => []
| SOME (r,ta) =>
let l' = str_may_list f (State_st_list l s fs cs) t in
str_act_list_find f l' s r ta l'
End
Definition bound_names_program_list:
bound_names_program_list (il:i list) : t list =
MAP bound_name_instr il
End
Definition state_program_list:
state_program_list (State_st_list il s0 cl fl) = il
End
Definition append_program_state_list:
append_program_state_list (State_st_list il s0 cl fl) il' =
State_st_list (il ++ il') s0 cl fl
End
Definition sem_instr_exe:
(sem_instr_exe (f: e -> (t |-> v) -> v option) ((i_assign t c (o_internal e)):i)
((State_st_list l s cs fs):State_list) : (v # obs) option =
case f e s of
| NONE => NONE
| SOME v => SOME (v, obs_internal))
/\
(sem_instr_exe f (i_assign t c (o_store r ta tv)) (State_st_list l s cs fs) =
case FLOOKUP s tv of
| NONE => NONE
| SOME v =>
(case FLOOKUP s ta of
| NONE => NONE
| SOME a => SOME (v, obs_internal)))
/\
(sem_instr_exe f (i_assign t c (o_load res_MEM ta)) (State_st_list l s cs fs) =
case bound_names_program_list (str_act_list f (State_st_list l s cs fs) t) of
| [] => NONE
| [ts] =>
(case FLOOKUP s ta of
| NONE => NONE
| SOME a =>
(case FLOOKUP s ts of
| NONE => NONE
| SOME v =>
if MEM ts cs then
SOME (v, obs_dl a)
else
SOME (v, obs_internal)))
| _::_::_ => NONE)
/\
(sem_instr_exe f (i_assign t c (o_load r ta)) (State_st_list l s cs fs) =
case bound_names_program_list (str_act_list f (State_st_list l s cs fs) t) of
| [] => NONE
| [ts] =>
(case FLOOKUP s ta of
| NONE => NONE
| SOME a =>
(case FLOOKUP s ts of
| NONE => NONE
| SOME v => SOME (v, obs_internal)))
| _::_::_ => NONE)
End
Definition name_le:
name_le (t1:t) (t2:t) = (t1 <= t2)
End
Definition bound_name_instr_le:
bound_name_instr_le i1 i2 = (name_le (bound_name_instr i1) (bound_name_instr i2))
End
Definition max_bound_name_list:
max_bound_name_list (l:i list) =
FOLDL (\t i. if name_le t (bound_name_instr i) then (bound_name_instr i) else t) 0 l
End
Definition max_name_in_state_list:
max_name_in_state_list (State_st_list il s0 cl fl) =
(max_bound_name_list il)
End
Definition Completed_list:
(Completed_list f_sem (State_st_list l s c' fs) (i_assign t c (o_store res_MEM t1 t2)) =
(f_sem c s = SOME val_false \/ MEM t c'))
/\
(Completed_list f_sem (State_st_list l s c' fs) (i_assign t c (o_store res_PC t1 t2)) =
(f_sem c s = SOME val_false \/ MEM t fs))
/\
(Completed_list f_sem (State_st_list l s c' fs) (i_assign t c op) =
(f_sem c s = SOME val_false \/ FLOOKUP s t <> NONE))
End
Definition Completed_list_up_to:
Completed_list_up_to f (State_st_list l s cs fs) k =
!i. MEM i (TAKE k l) ==> Completed_list f (State_st_list l s cs fs) i
End
Definition names_e_list:
(names_e_list (e_val v) = [])
/\
(names_e_list (e_name t) = [t])
/\
(names_e_list (e_and e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_or e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_xor e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_add e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_sub e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_mul e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_div e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_sdiv e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_mod e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_smod e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_lsl e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_lsr e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_asr e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_eq e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_neq e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_lt e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_slt e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_le e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_sle e1 e2) = names_e_list e1 ++ names_e_list e2)
/\
(names_e_list (e_comp e) = names_e_list e)
/\
(names_e_list (e_not e) = names_e_list e)
End
Definition sort_instr_bound_name:
sort_bound_name_instr = QSORT bound_name_instr_le
End
Definition translate_val_set_to_list:
translate_val_set_to_list v t = SET_TO_LIST (translate_val v t)
End
Definition translate_val_list:
translate_val_list = @(f : v -> t -> i list). !(v:v) (t:t).
(LIST_TO_SET (f v t) = translate_val v t)
/\
(NO_DUPLICATES (f v t))
End
Definition translate_val_list_SORTED:
translate_val_list_SORTED =
(!v t. SORTED bound_name_instr_le (translate_val_list v t))
End
(* additional executable funcions for str_may/act_addr and str_may/act_opt
* str_may/act_addr: the input has the value of address ta.
* str_may/act_opt: the input has the value option of address ta (NONE / SOME a).
*)
Definition str_may_addr_list_find:
(str_may_addr_list_find (f:e -> (t |-> v) -> v option) ([]:i list) (s:(t |-> v)) (t:t) (r:res) (vop:v option): i list = [])
/\
(str_may_addr_list_find f ((i_assign t' c' (o_internal e))::ls) s t r vop = str_may_addr_list_find f ls s t r vop)
/\
(str_may_addr_list_find f ((i_assign t' c' (o_load r' ta'))::ls) s t r vop = str_may_addr_list_find f ls s t r vop)
/\
(str_may_addr_list_find f ((i_assign t' c' (o_store r' ta' tv'))::ls) s t r vop =
case FLOOKUP s ta' of
| NONE =>
if (t' >= t) \/ (r' <> r) then
str_may_addr_list_find f ls s t r vop
else
(case f c' s of
| NONE => i_assign t' c' (o_store r' ta' tv')::str_may_addr_list_find f ls s t r vop
| SOME v =>
if v <> val_false then
i_assign t' c' (o_store r' ta' tv')::str_may_addr_list_find f ls s t r vop
else
str_may_addr_list_find f ls s t r vop)
| SOME v1 =>
case vop of
| NONE =>
if (t' >= t) \/ (r' <> r) then
str_may_addr_list_find f ls s t r vop
else
(case f c' s of
| NONE => i_assign t' c' (o_store r' ta' tv')::str_may_addr_list_find f ls s t r vop
| SOME v =>
if v <> val_false then
i_assign t' c' (o_store r' ta' tv')::str_may_addr_list_find f ls s t r vop
else
str_may_addr_list_find f ls s t r vop)
| SOME v2 =>
if (t' >= t) \/ (r' <> r) \/ (v1 <> v2) then
str_may_addr_list_find f ls s t r vop
else
(case f c' s of
| NONE => i_assign t' c' (o_store r' ta' tv')::str_may_addr_list_find f ls s t r vop
| SOME v =>
if v <> val_false then
i_assign t' c' (o_store r' ta' tv')::str_may_addr_list_find f ls s t r vop
else
str_may_addr_list_find f ls s t r vop))
End
Definition str_may_addr_list:
str_may_addr_list (f: e -> (t |-> v) -> v option) ((State_st_list l s cs fs):State_list) (t:t) (r:res) (a:v): i list =
str_may_addr_list_find f l s t r (SOME a)
End
Definition str_may_opt_list:
str_may_opt_list (f:e -> (t |-> v) -> v option) ((State_st_list l s cs fs):State_list) (t:t) (r:res) (aop:v option): i list =
str_may_addr_list_find f l s t r aop
End
Definition str_act_addr_list_cond:
(str_act_addr_list_cond (f:e -> (t |-> v) -> v option) ([]:i list) (s:(t |-> v)) (t':t) (r':res) (ta':t) (aop:v option): i list = [])
/\
(str_act_addr_list_cond f ((i_assign t'' c'' (o_internal e))::ls) s t' r' ta' aop = str_act_addr_list_cond f ls s t' r' ta' aop)
/\
(str_act_addr_list_cond f ((i_assign t'' c'' (o_load r'' ta''))::ls) s t' r' ta' aop = str_act_addr_list_cond f ls s t' r' ta' aop)
/\
(str_act_addr_list_cond f ((i_assign t'' c'' (o_store r'' ta'' tv''))::ls) s t' r' ta' aop =
case f c'' s of
| NONE => str_act_addr_list_cond f ls s t' r' ta' aop
| SOME fv =>
case FLOOKUP s ta'' of
| SOME v1 =>
(case FLOOKUP s ta' of
| SOME v2 =>
(case aop of
| SOME v3 =>
if (t'' > t') /\ (r'' = r') /\ (fv <> val_false) /\ (v1 = v3) then
(i_assign t'' c'' (o_store r'' ta'' tv''))::(str_act_addr_list_cond f ls s t' r' ta' aop)
else
str_act_addr_list_cond f ls s t' r' ta' aop
| NONE =>
if (t'' > t') /\ (r'' = r') /\ (fv <> val_false) /\ (v1 = v2) then
(i_assign t'' c'' (o_store r'' ta'' tv''))::(str_act_addr_list_cond f ls s t' r' ta' aop)
else
str_act_addr_list_cond f ls s t' r' ta' aop)
| NONE =>
(case aop of
| SOME v3 =>
if (t'' > t') /\ (r'' = r') /\ (fv <> val_false) /\ (v1 = v3) then
(i_assign t'' c'' (o_store r'' ta'' tv''))::(str_act_addr_list_cond f ls s t' r' ta' aop)
else
str_act_addr_list_cond f ls s t' r' ta' aop
| NONE => str_act_addr_list_cond f ls s t' r' ta' aop))
| NONE => str_act_addr_list_cond f ls s t' r' ta' aop)
End
Definition str_act_addr_list_find:
(str_act_addr_list_find (f:e -> (t |-> v) -> v option) ([]:i list) (s:(t |-> v)) (r:res) (aop:v option) (l1:i list): i list = [])
/\
(str_act_addr_list_find f ((i_assign t' c' (o_internal e))::ls) s r aop l1 = str_act_addr_list_find f ls s r aop l1)
/\
(str_act_addr_list_find f ((i_assign t' c' (o_load r' ta'))::ls) s r aop l1 = str_act_addr_list_find f ls s r aop l1)
/\
(str_act_addr_list_find f ((i_assign t' c' (o_store r' ta' tv'))::ls) s r aop l1 =
case str_act_addr_list_cond f l1 s t' r' ta' aop of
| [] =>
if r' <> r then str_act_addr_list_find f ls s r aop l1
else i_assign t' c' (o_store r' ta' tv')::str_act_addr_list_find f ls s r aop l1
| _ => str_act_addr_list_find f ls s r aop l1)
End
Definition str_act_addr_list:
str_act_addr_list (f:e -> (t |-> v) -> v option) ((State_st_list l s fs cs):State_list) (t:t) (r:res) (a:v) : i list =
let l' = str_may_addr_list f (State_st_list l s fs cs) t r a in
str_act_addr_list_find f l' s r (SOME a) l'
End
Definition str_act_opt_list:
str_act_opt_list (f:e -> (t |-> v) -> v option) ((State_st_list l s fs cs):State_list) (t:t) (r:res) (aop:v option) : i list =
let l' = str_may_opt_list f (State_st_list l s fs cs) t r aop in
str_act_addr_list_find f l' s r aop l'
End
(* --------------------------------------- *)
(* Properties of general helper functions *)
(* --------------------------------------- *)
Theorem OPTION_MAP_INDEX_FIND_eq[local]:
!P l n m. OPTION_MAP SND (INDEX_FIND n P l) = OPTION_MAP SND (INDEX_FIND m P l)
Proof
strip_tac >> Induct_on `l` >> rw [OPTION_MAP_DEF,INDEX_FIND_def]
QED
Theorem FIND_instr_eq_FIND[local]:
!il t. FIND_instr t il = FIND (\i. bound_name_instr i = t) il
Proof
Induct_on `il` >>
rw [FIND_instr,FIND_def,OPTION_MAP_DEF,INDEX_FIND_def,OPTION_MAP_INDEX_FIND_eq]
QED
Theorem FIND_instr_eq_NONE:
!t l. FIND_instr t l = NONE <=> ~MEM t (MAP bound_name_instr l)
Proof
Induct_on `l` >> rw [FIND_instr]
QED
Theorem FIND_instr_eq_SOME:
!t l i. FIND_instr t l = SOME i ==> bound_name_instr i = t /\ MEM i l
Proof
Induct_on `l` >> rw [FIND_instr] >> METIS_TAC []
QED
(* Cannot eval NO_DUPLICATES since cannot eval UNIQUE. *)
Theorem MEM_SINGLE[local]:
!l a b. (l = [a]) /\ (MEM b l) ==> b = a
Proof
SIMP_TAC list_ss []
QED
Theorem NO_DUPLICATES_ALT_bound_name_instr:
!l i i'. NO_DUPLICATES_ALT l ==>
MEM i l ==> MEM i' l ==>
bound_name_instr i = bound_name_instr i' ==>
i = i'
Proof
rw [NO_DUPLICATES_ALT] >>
`UNIQUE (bound_name_instr i) (MAP bound_name_instr l)` by METIS_TAC [MEM_MAP,NO_DUPLICATE] >>
`UNIQUE (bound_name_instr i') (MAP bound_name_instr l)` by METIS_TAC [MEM_MAP,NO_DUPLICATE] >>
`MEM (bound_name_instr i') (MAP bound_name_instr l)` by METIS_TAC [MEM_MAP] >>
`MEM (bound_name_instr i) (MAP bound_name_instr l)` by METIS_TAC [MEM_MAP] >>
fs [UNIQUE_FILTER,FILTER_MAP] >>
`[x0] = [x0']` by METIS_TAC [] >> rw [] >>
`MEM i' (FILTER ($= (bound_name_instr i') o bound_name_instr) l)` by rw [MEM_FILTER] >>
`MEM i (FILTER ($= (bound_name_instr i) o bound_name_instr) l)` by rw [MEM_FILTER] >>
METIS_TAC [MEM_SINGLE]
QED
Theorem NO_DUPLICATES_bound_name_instr:
!l i i'. NO_DUPLICATES l ==>
MEM i l ==> MEM i' l ==>
bound_name_instr i = bound_name_instr i' ==>
i = i'
Proof
rw [NO_DUPLICATES] >>
`MEM (bound_name_instr i) (MAP bound_name_instr l)` by METIS_TAC [MEM_MAP] >>
`MEM (bound_name_instr i') (MAP bound_name_instr l)` by METIS_TAC [MEM_MAP] >>
`FILTER ($= (bound_name_instr i)) (MAP bound_name_instr l) = [bound_name_instr i]` by fs [ALL_DISTINCT_FILTER] >>
`FILTER ($= (bound_name_instr i')) (MAP bound_name_instr l) = [bound_name_instr i']` by fs [ALL_DISTINCT_FILTER] >>
fs [FILTER_MAP] >>
`[x0] = [x0']` by METIS_TAC [] >> rw [] >>
`MEM i' (FILTER ($= (bound_name_instr i') o bound_name_instr) l)` by rw [MEM_FILTER] >>
`MEM i (FILTER ($= (bound_name_instr i) o bound_name_instr) l)` by rw [MEM_FILTER] >>
METIS_TAC [MEM_SINGLE]
QED
Theorem UNIQUE_FILTER_instr:
!l t. UNIQUE t (MAP (bound_name_instr) l) ==>
?c mop. FILTER_instr t l = [i_assign t c mop]
Proof
GEN_TAC >>
rw [FILTER_instr] >>
`FILTER ($= t) (MAP bound_name_instr l) = [t]` by METIS_TAC [UNIQUE_FILTER] >>
FULL_SIMP_TAC list_ss [FILTER_MAP] >>
Cases_on `x0` >>
EXISTS_TAC ``e:e`` >>
EXISTS_TAC ``o':op`` >>
rw [bound_name_instr]
QED
Theorem FILTER_instr_MEM:
!l t i. FILTER_instr t l = [i] ==> MEM i l
Proof
rw [FILTER_instr] >>
`MEM i (FILTER ($= t o bound_name_instr) l)` by rw [] >>
fs [MEM_FILTER]
QED
Theorem not_MEM_notin:
!l t. ~MEM t (MAP bound_name_instr l) ==>
(!i. i IN (LIST_TO_SET l) ==> bound_name_instr i <> t)
Proof
rw [MEM_MAP] >> METIS_TAC []
QED
Theorem not_MEM_FILTER_t_NIL:
!l t. ~MEM t (MAP bound_name_instr l) ==>
FILTER_instr t l = []
Proof
rw [FILTER_instr, MEM_MAP] >>
`!y. MEM y l ==> bound_name_instr y <> t` by METIS_TAC [] >>
`!y. MEM y l ==> ~(($= t o bound_name_instr) y)` by fs [] >>
METIS_TAC [NULL_FILTER, NULL_EQ]
QED
(* theorems for NONCONT_SUBLIST *)
Theorem NONCONT_SUBLIST_MEM:
!l l' x.
NONCONT_SUBLIST l l' ==>
MEM x l' ==>
MEM x l
Proof
Induct_on `l'` >>
Induct_on `l` >>
rw [NONCONT_SUBLIST] >>
fs [] >>
METIS_TAC []
QED
Theorem NONCONT_SUBLIST_APPEND:
!l1 l2 l.
NONCONT_SUBLIST l (l1 ++ l2) ==>
(NONCONT_SUBLIST l l1) /\ (NONCONT_SUBLIST l l2)
Proof
Induct_on `l2` >>
Induct_on `l1` >>
Induct_on `l` >>
rw [NONCONT_SUBLIST] >>
`h'::(l1++h''::l2) = h'::l1 ++ h''::l2` by fs [] >>
METIS_TAC []
QED
Theorem NONCONT_SUBLIST_MEM_single:
!l x.
MEM x l ==>
NONCONT_SUBLIST l [x]
Proof
rw [MEM_SPLIT] >>
Induct_on `l1` >>
rw [NONCONT_SUBLIST]
QED
Theorem NONCONT_SUBLIST_not_MEM[local]:
!l1 l2 h t.
NONCONT_SUBLIST (l1 ++ l2) (h::t) ==>
~MEM h l1 ==>
NONCONT_SUBLIST l2 (h::t)
Proof
rw [] >>
Induct_on `l1` >>
rw [NONCONT_SUBLIST] >>
fs []
QED
Theorem NONCONT_SUBLIST_two_x[local]:
!l1 l2 l1' l2' x.
NONCONT_SUBLIST (l1 ++ [x] ++ l2) (x::l1' ++ x::l2') ==>
(NONCONT_SUBLIST l1 [x]) \/ (NONCONT_SUBLIST l2 [x])
Proof
REVERSE (Cases_on `l1` >> rw [NONCONT_SUBLIST]) >-
(Cases_on `NONCONT_SUBLIST t [x]` >> rw [] >>
`~ MEM x t` by METIS_TAC [NONCONT_SUBLIST_MEM_single] >>
`t ++ [x] ++ l2 = t ++ ([x] ++ l2)` by rw [] >>
`NONCONT_SUBLIST ([x] ++ l2) (x::(l1' ++ x::l2'))` by METIS_TAC [NONCONT_SUBLIST_not_MEM] >>
fs [NONCONT_SUBLIST] >>
`x::(l1' ++ x::l2') = (x::l1') ++ (x::l2')` by rw [] >>
`NONCONT_SUBLIST l2 (x::l2')` by METIS_TAC [NONCONT_SUBLIST_APPEND] >>
`x::l2' = [x] ++ l2'` by rw [] >>
METIS_TAC [NONCONT_SUBLIST_APPEND]) >>
`x::(l1' ++ x::l2') = (x::l1') ++ (x::l2')` by rw [] >>
`NONCONT_SUBLIST l2 (x::l2')` by METIS_TAC [NONCONT_SUBLIST_APPEND] >>
`x::l2' = [x] ++ l2'` by rw [] >>
METIS_TAC [NONCONT_SUBLIST_APPEND]
QED
Theorem NONCONT_SUBLIST_FILTER_MEM:
!l l' x P.
NONCONT_SUBLIST l l' ==>
MEM x l' ==>
FILTER P l = [x] ==>
FILTER P l' = [x]
Proof
rw [FILTER_EQ_CONS, FILTER_EQ_NIL, EVERY_MEM] >>
`?l1' l2'. l' = l1' ++ [x] ++ l2' /\ ~ (MEM x l1')` by METIS_TAC [MEM_SPLIT_APPEND_first] >>
Q.EXISTS_TAC `l1'` >>
Q.EXISTS_TAC `l2'` >>
rw [] >>
`MEM x' (l1 ++ [x] ++ l2)` by METIS_TAC [MEM_APPEND, NONCONT_SUBLIST_MEM] >>
fs [MEM_APPEND] >-
(METIS_TAC []) >>
`?l1'' l2''. l2' = l1'' ++ x::l2''` by METIS_TAC [MEM_SPLIT] >>
rw [] >>
`l1' ++ [x] ++ (l1''++x::l2'') = l1' ++ (x::l1'' ++ x::l2'')` by rw [] >>
`NONCONT_SUBLIST (l1 ++ [x] ++ l2) (x::l1'' ++ x::l2'')` by METIS_TAC [NONCONT_SUBLIST_APPEND] >>
`NONCONT_SUBLIST l1 [x] \/ NONCONT_SUBLIST l2 [x]` by METIS_TAC [NONCONT_SUBLIST_two_x] >>
`MEM x [x]` by rw [] >>
METIS_TAC [NONCONT_SUBLIST_MEM]
QED
Theorem NO_DUPLICATES_ALT_NONCONT_SUBLIST:
!l l'.
NO_DUPLICATES_ALT l ==>
NONCONT_SUBLIST l l' ==>
NO_DUPLICATES_ALT l'
Proof
rw [NO_DUPLICATES_ALT, NO_DUPLICATE, MEM_MAP] >>
`MEM y l` by METIS_TAC [NONCONT_SUBLIST_MEM] >>
`?t. t = bound_name_instr y` by rw [bound_name_instr] >>
`UNIQUE t (MAP bound_name_instr l)` by METIS_TAC [] >>
fs [UNIQUE_FILTER, FILTER_MAP] >>
`MEM y (FILTER ($= (bound_name_instr x0) o bound_name_instr) l)` by fs [MEM_FILTER] >>
`x0 = y` by METIS_TAC [MEM_SINGLE] >>
METIS_TAC [NONCONT_SUBLIST_FILTER_MEM]
QED
Theorem NO_DUPLICATES_NONCONT_SUBLIST:
!l l'.
NO_DUPLICATES l ==>
NONCONT_SUBLIST l l' ==>
NO_DUPLICATES l'
Proof
rw [NO_DUPLICATES,ALL_DISTINCT_FILTER,MEM_MAP] >>
`MEM y l` by METIS_TAC [NONCONT_SUBLIST_MEM] >>
`?t. t = bound_name_instr y` by rw [bound_name_instr] >>
`FILTER ($=t) (MAP bound_name_instr l) = [t]` by METIS_TAC [] >>
fs [FILTER_MAP] >>
`MEM y (FILTER ($= (bound_name_instr x0) o bound_name_instr) l)` by fs [MEM_FILTER] >>
`x0 = y` by METIS_TAC [MEM_SINGLE] >>
METIS_TAC [NONCONT_SUBLIST_FILTER_MEM]
QED
Theorem NONCONT_SUBLIST_h_t:
!h t l.
NONCONT_SUBLIST t l ==>
NONCONT_SUBLIST (h::t) l
Proof
Cases_on `l` >>
rw [NONCONT_SUBLIST]
QED
Theorem NONCONT_SUBLIST_third:
!l1 l2 l3.
NONCONT_SUBLIST l1 l2 ==>
NONCONT_SUBLIST l2 l3 ==>
NONCONT_SUBLIST l1 l3
Proof
Induct_on `l3` >>
Induct_on `l2` >>
Induct_on `l1` >>
fs [NONCONT_SUBLIST] >>
rw [] >>
METIS_TAC []
QED
Theorem NO_DUPLICATES_ALT_FIND_instr:
!l t i.
(NO_DUPLICATES_ALT l) ==>
(MEM i l) ==>
(bound_name_instr i = t) ==>
FIND_instr t l = SOME i
Proof
rw [] >>
Cases_on `FIND_instr (bound_name_instr i) l` >-
METIS_TAC [FIND_instr_eq_NONE,MEM_MAP,NO_DUPLICATES_ALT_bound_name_instr] >>
METIS_TAC [FIND_instr_eq_SOME,NO_DUPLICATES_ALT_bound_name_instr]
QED
Theorem UNIQUE_APP_MEM:
!l l' a. UNIQUE a (l ++ l') ==>
~MEM a l' ==>
MEM a l
Proof
Induct_on `l` >> rw [UNIQUE_DEF] >> fs [] >>
Cases_on `a = h` >> rw [] >>
Cases_on `L1` >> fs [] >> rw [] >>
`UNIQUE a (l ++ l')` by METIS_TAC [UNIQUE_DEF] >>
METIS_TAC []
QED
Theorem UNIQUE_MEM_APP:
!l l' a. UNIQUE a (l ++ l') ==>
MEM a l ==>
~MEM a l'
Proof
Induct_on `l` >> rw [UNIQUE_DEF] >> fs [] >-
(Cases_on `L1` >> fs [] >> rw [] >>
strip_tac >>
METIS_TAC [MEM_APPEND]) >>
Cases_on `a = h` >> rw [] >-
(Cases_on `L1` >> fs [] >> rw [] >>
METIS_TAC [MEM_APPEND]) >>
Cases_on `L1` >> fs [] >> rw [] >>
`UNIQUE a (l ++ l')` by METIS_TAC [UNIQUE_DEF] >>
METIS_TAC []
QED
Theorem transitive_name_le:
transitive name_le
Proof
rw [transitive_def,name_le]
QED
Theorem antisymmetric_name_le:
antisymmetric name_le
Proof
rw [antisymmetric_def,name_le]
QED
Theorem total_name_le:
total name_le
Proof
rw [total_def,name_le]
QED
Theorem transitive_bound_name_instr_le:
transitive bound_name_instr_le
Proof
rw [transitive_def,bound_name_instr_le] >>
METIS_TAC [transitive_name_le,transitive_def]
QED
Theorem total_bound_name_instr_le:
total bound_name_instr_le
Proof
rw [total_def,bound_name_instr_le] >> METIS_TAC [total_name_le,total_def]
QED
Theorem sort_bound_name_instr_SORTED:
!l. SORTED bound_name_instr_le (sort_bound_name_instr l)
Proof
rw [
sort_instr_bound_name,
QSORT_SORTED,
transitive_bound_name_instr_le,
total_bound_name_instr_le
]
QED
Theorem ALL_DISTINCT_MAP_NO_DUPLICATES_ALT:
!l. ALL_DISTINCT (MAP bound_name_instr l) <=> NO_DUPLICATES_ALT l
Proof
strip_tac >> EQ_TAC >-
(Induct_on `l` >> rw [ALL_DISTINCT,NO_DUPLICATES_ALT,NO_DUPLICATE] >-
(rw [UNIQUE_DEF] >>
Q.EXISTS_TAC `[]` >>
Q.EXISTS_TAC `MAP bound_name_instr l` >>
fs []) >>
Cases_on `h` >> rename1 `i_assign t' c mop` >>
fs [bound_name_instr] >>
Cases_on `t = t'` >> rw [] >- METIS_TAC [] >>
fs [NO_DUPLICATES_ALT,NO_DUPLICATE] >>
`UNIQUE t (MAP bound_name_instr l)` by METIS_TAC [] >>
`?l1 l2. MAP bound_name_instr l = l1 ++ t::l2` by METIS_TAC [MEM_SPLIT] >>
rw [UNIQUE_DEF] >>
Q.EXISTS_TAC `t'::l1` >>
Q.EXISTS_TAC `l2` >>
fs [] >>
`l1 ++ [t] ++ l2 = l1 ++ t::l2` by fs [] >>
`MEM t (t::l2)` by rw [] >>
`MEM t (l1 ++ [t])` by rw [] >>
METIS_TAC [UNIQUE_MEM_APP]) >>
Induct_on `l` >> rw [ALL_DISTINCT,NO_DUPLICATES_ALT,NO_DUPLICATE] >-
(Cases_on `h` >> rename1 `i_assign t c mop` >>
fs [bound_name_instr] >>
strip_tac >>
`UNIQUE t (t::MAP bound_name_instr l)` by METIS_TAC [] >>
fs [UNIQUE_DEF] >>
Cases_on `L1` >> fs [] >> rw [] >>
METIS_TAC []) >>
Cases_on `h` >> rename1 `i_assign t c mop` >>
fs [bound_name_instr] >>
`UNIQUE t (t::MAP bound_name_instr l)` by METIS_TAC [] >>
sg `~MEM t (MAP bound_name_instr l)` >-
(fs [UNIQUE_DEF] >>
Cases_on `L1` >> fs [] >> rw []) >>
sg `!t'. MEM t' (MAP bound_name_instr l) ==> UNIQUE t' (MAP bound_name_instr l)` >-
(rw [] >>
`UNIQUE t' (t::MAP bound_name_instr l)` by METIS_TAC [] >>
Cases_on `t = t'` >> fs [] >>
fs [UNIQUE_DEF] >>
Cases_on `L1'` >> fs [] >> rw [] >>
METIS_TAC []) >>
METIS_TAC [NO_DUPLICATES_ALT,NO_DUPLICATE]
QED
Theorem NO_DUPLICATES_EQ_NO_DUPLICATES_ALT:
!l. NO_DUPLICATES l <=> NO_DUPLICATES_ALT l
Proof
rw [NO_DUPLICATES,ALL_DISTINCT_MAP_NO_DUPLICATES_ALT]
QED
Theorem MEM_MAP_bound_name_instr:
!l t c mop.
MEM_bound_name_instr_unique (i_assign t c mop::l) ==>
MEM t (MAP bound_name_instr l) ==>
MEM (i_assign t c mop) l
Proof
Induct_on `l` >> rw [] >-
(DISJ1_TAC >>
Cases_on `h` >> rw [bound_name_instr] >>
`i_assign n c mop = i_assign n e o'` suffices_by rw [bound_name_instr] >>
`MEM (i_assign n c mop) (i_assign n c mop::i_assign n e o'::l)` by rw [] >>
`MEM (i_assign n e o') (i_assign n c mop::i_assign n e o'::l)` by rw [] >>
`bound_name_instr (i_assign n c mop) = bound_name_instr (i_assign n e o')`
by rw [bound_name_instr] >>
`MEM_bound_name_instr_unique (i_assign n c mop::i_assign n e o'::l)`
by fs [bound_name_instr] >>
METIS_TAC [MEM_bound_name_instr_unique]) >>
Cases_on `h` >>
sg `MEM_bound_name_instr_unique (i_assign t c mop::l)` >-
(`MEM (i_assign t c mop) (i_assign t c mop::i_assign n e o'::l)` by rw [] >>
`!i. MEM i l ==> MEM i (i_assign t c mop::i_assign n e o'::l)` by rw [] >>
`!i. MEM i (i_assign t c mop::l) ==> i = i_assign t c mop \/ MEM i l` by rw [] >>
METIS_TAC [MEM_bound_name_instr_unique]) >>
METIS_TAC []
QED
Theorem MEM_MAP_bound_name_instr_unfolded[local]:
!l t c mop.
(!i i'. i = i_assign t c mop \/ MEM i l ==>
i' = i_assign t c mop \/ MEM i' l ==>
bound_name_instr i = bound_name_instr i' ==>
i = i') ==>
MEM t (MAP bound_name_instr l) ==>
MEM (i_assign t c mop) l
Proof
rw [] >>
sg `MEM_bound_name_instr_unique (i_assign t c mop::l)` >-
(rw [MEM_bound_name_instr_unique] >>
METIS_TAC [bound_name_instr]) >>
METIS_TAC [MEM_MAP_bound_name_instr]
QED
Theorem ALL_DISTINCT_NO_DUPLICATES_ALT:
!l. ALL_DISTINCT l ==>
(!i i'. MEM i l ==> MEM i' l ==>
bound_name_instr i = bound_name_instr i' ==>
i = i') ==>
NO_DUPLICATES_ALT l
Proof
Induct_on `l` >> rw [ALL_DISTINCT,NO_DUPLICATES_ALT,NO_DUPLICATE] >-
(Cases_on `h` >> rename1 `i_assign t c mop` >>
fs [bound_name_instr] >>
rw [UNIQUE_DEF] >>
Q.EXISTS_TAC `[]` >>
Q.EXISTS_TAC `MAP bound_name_instr l` >>
rw [] >>
strip_tac >>
`MEM (i_assign t c mop) l` suffices_by METIS_TAC [] >>
METIS_TAC [MEM_MAP_bound_name_instr_unfolded]) >>
`NO_DUPLICATES_ALT l` by METIS_TAC [] >>
Cases_on `h` >> rename1 `i_assign t' c mop` >>
fs [bound_name_instr] >>
fs [NO_DUPLICATES_ALT,NO_DUPLICATE] >>
`UNIQUE t (MAP bound_name_instr l)` by METIS_TAC [] >>
Cases_on `t = t'` >-
(rw [] >>
METIS_TAC [MEM_MAP,bound_name_instr]) >>
`?l1 l2. MAP bound_name_instr l = l1 ++ t::l2` by METIS_TAC [MEM_SPLIT] >>
rw [UNIQUE_DEF] >>
Q.EXISTS_TAC `t'::l1` >>
Q.EXISTS_TAC `l2` >>
fs [] >> rw [] >-
(`l1 ++ [t] ++ l2 = l1 ++ t::l2` by fs [] >>
`MEM t (t::l2)` by rw [] >>
METIS_TAC [UNIQUE_MEM_APP]) >>
`MEM t (l1 ++ [t])` by rw [] >>
strip_tac >>
METIS_TAC [UNIQUE_MEM_APP]
QED
Theorem ALL_DISTINCT_MAP_APPEND:
!l1 l2. ALL_DISTINCT (MAP bound_name_instr l1) ==> ALL_DISTINCT (MAP bound_name_instr l2) ==>
(!i i'. MEM i l1 ==> MEM i' l2 ==> bound_name_instr i <> bound_name_instr i') ==>
ALL_DISTINCT (MAP bound_name_instr (l1 ++ l2))
Proof
Induct_on `l1` >> rw [ALL_DISTINCT] >-
(Cases_on `h` >> rename1 `i_assign t c mop` >>
fs [bound_name_instr] >>
strip_tac >>
`?i. MEM i l2 /\ bound_name_instr i = t` by METIS_TAC [MEM_MAP] >>
METIS_TAC [bound_name_instr]) >>
Cases_on `h` >> rename1 `i_assign t c mop` >>
fs [bound_name_instr]