Skip to content

Commit 61a4258

Browse files
committed
Fix up some syntactic proofs in pan_to_word
As usual, the pancake combination theory contains some additional proofs over all of the phases to establish some syntactic properties, which need to be repaired.
1 parent 5eca553 commit 61a4258

File tree

1 file changed

+79
-122
lines changed

1 file changed

+79
-122
lines changed

pancake/proofs/pan_to_wordProofScript.sml

Lines changed: 79 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
(*
2-
Correctness proof for --
2+
Correctness proof for combined pan_to_word compilation.
33
*)
44

55
open preamble pan_to_wordTheory
@@ -523,7 +523,6 @@ Proof
523523
fs [] >>
524524
pop_assum kall_tac >>
525525
qmatch_goalsub_abbrev_tac ‘_ = semantics lst _’ >>
526-
527526
(* loop_to_word pass *)
528527
qmatch_asmsub_abbrev_tac ‘_ = SOME ([],cprog)’ >>
529528
drule pan_simpProofTheory.first_compile_prog_all_distinct >>
@@ -618,112 +617,40 @@ Proof
618617
fs []) >>
619618
fs [pan_to_wordTheory.compile_prog_def] >>
620619
fs [loop_to_wordTheory.compile_def] >>
621-
drule mem_prog_mem_compile_prog >> fs []) >>
622-
drule pan_commonPropsTheory.lookup_some_el >>
623-
strip_tac >>
624-
drule EL_MEM >>
625-
strip_tac >>
626-
rfs []
627-
>- (drule loop_removeProofTheory.comp_prog_no_loops >> fs []) >>
628-
drule loop_removeProofTheory.compile_prog_distinct_params >>
629-
impl_tac
620+
drule mem_prog_mem_compile_prog >> fs []
621+
)
630622
>- (
631-
ho_match_mp_tac crep_to_loopProofTheory.compile_prog_distinct_params >>
623+
drule pan_commonPropsTheory.lookup_some_el >> rw [] >>
624+
imp_res_tac EL_MEM >>
625+
gs [] >>
626+
drule loop_removeProofTheory.comp_prog_no_loops >> fs []
627+
)
628+
>- (
629+
drule pan_commonPropsTheory.lookup_some_el >> rw [] >>
630+
imp_res_tac EL_MEM >>
631+
gs [] >>
632+
drule_then irule loop_removeProofTheory.compile_prog_distinct_params >>
633+
irule crep_to_loopProofTheory.compile_prog_distinct_params >>
632634
fs [Abbr ‘ccode’] >>
633635
ho_match_mp_tac pan_to_crepProofTheory.compile_prog_distinct_params >>
634636
fs [Abbr ‘pcode’] >>
635637
ho_match_mp_tac pan_simpProofTheory.compile_prog_distinct_params >>
636-
fs [distinct_params_def]) >>
637-
fs []) >>
638+
fs [distinct_params_def])
639+
) >>
638640
drule fstate_rel_imp_semantics >>
639-
disch_then (qspecl_then [‘lc+first_name’,
640-
‘loop_live$optimise (comp_func c (make_funcs ccode) [] cprog)’] mp_tac) >>
641-
impl_tac
642-
>- (
643-
fs [Abbr ‘lst’, loop_state_def,
641+
disch_then irule >>
642+
fs [Abbr ‘lst’, loop_state_def,
644643
Abbr ‘ccode’, Abbr ‘pcode’,
645644
pan_to_wordTheory.compile_prog_def] >>
646-
fs [lookup_fromAList] >>
647-
fs [Abbr ‘cprog’] >>
648-
match_mp_tac ALOOKUP_ALL_DISTINCT_MEM >>
649-
conj_tac
650-
>- fs [crep_to_loopProofTheory.first_compile_prog_all_distinct] >>
651-
fs [crep_to_loopTheory.compile_prog_def] >>
652-
qmatch_goalsub_abbrev_tac ‘MEM ff _’ >>
653-
pop_assum mp_tac >>
654-
qpat_x_assum ‘lc < _’ mp_tac >>
655-
qpat_x_assum ‘EL lc pan_code = _’ mp_tac >>
656-
qpat_x_assum ‘FLOOKUP _ _ = SOME _’ mp_tac >>
657-
qpat_x_assum ‘ALOOKUP _ _ = SOME _’ mp_tac >>
658-
qpat_x_assum ‘ALOOKUP _ _ = SOME _’ mp_tac >>
659-
qpat_x_assum ‘ALOOKUP _ _ = SOME _’ mp_tac >>
660-
rpt (pop_assum kall_tac) >>
661-
rpt strip_tac >>
662-
qmatch_asmsub_abbrev_tac
663-
‘ALOOKUP (_ (_ pan_code)) start = SOME ([],cprog)’ >>
664-
‘lc < LENGTH (pan_to_crep$compile_prog (pan_simp$compile_prog pan_code))’ by
665-
fs [pan_to_crepTheory.compile_prog_def, pan_simpTheory.compile_prog_def] >>
666-
fs [MEM_EL] >>
667-
qexists_tac ‘lc’ >>
668-
rfs [] >>
669-
qmatch_goalsub_abbrev_tac ‘_ = EL lc (MAP2 gg xs ys)’ >>
670-
‘EL lc (MAP2 gg xs ys) = gg (EL lc xs) (EL lc ys)’ by (
671-
ho_match_mp_tac EL_MAP2 >>
672-
fs [Abbr ‘xs’, Abbr ‘ys’]) >>
673-
fs [Abbr ‘gg’, Abbr ‘xs’, Abbr ‘ys’] >>
674-
pop_assum kall_tac >>
675-
qmatch_goalsub_abbrev_tac ‘_ = hs x’ >>
676-
cases_on ‘x’ >> fs [] >>
677-
cases_on ‘r’ >> fs [] >>
678-
fs [Abbr ‘hs’, Abbr ‘ff’] >>
679-
conj_asm1_tac
680-
>- (
681-
fs [pan_to_crepTheory.compile_prog_def] >>
682-
pop_assum mp_tac >>
683-
qmatch_goalsub_abbrev_tac ‘EL n (MAP ff xs)’ >>
684-
‘EL n (MAP ff xs) = ff (EL n xs)’ by (
685-
match_mp_tac EL_MAP >>
686-
fs [Abbr ‘ff’, Abbr ‘xs’]) >>
687-
fs [Abbr ‘ff’, Abbr ‘xs’] >>
688-
pop_assum kall_tac >>
689-
strip_tac >>
690-
cases_on ‘EL n (pan_simp$compile_prog pan_code)’ >>
691-
fs [] >>
692-
cases_on ‘r’ >> fs [] >>
693-
unabbrev_all_tac >>
694-
fs [] >> rveq >> fs [] >>
695-
pop_assum mp_tac >>
696-
fs [pan_simpTheory.compile_prog_def] >>
697-
qmatch_goalsub_abbrev_tac ‘EL n (MAP ff xs)’ >>
698-
‘EL n (MAP ff xs) = ff (EL n xs)’ by (
699-
match_mp_tac EL_MAP >>
700-
fs [Abbr ‘ff’, Abbr ‘xs’]) >>
701-
fs [Abbr ‘ff’, Abbr ‘xs’] >> rveq >> gs [] >>
702-
fs [pan_to_crepTheory.crep_vars_def, panLangTheory.size_of_shape_def]) >>
703-
cases_on ‘q'’ >> fs [GENLIST] >>
704-
qsuff_tac ‘cprog = r'’
705-
>- fs [] >>
706-
fs [Abbr ‘cprog’] >>
707-
pop_assum kall_tac >>
708-
fs [pan_to_crepTheory.compile_prog_def] >>
709-
pop_assum mp_tac >>
710-
qmatch_goalsub_abbrev_tac ‘EL n (MAP ff xs)’ >>
711-
‘EL n (MAP ff xs) = ff (EL n xs)’ by (
712-
match_mp_tac EL_MAP >>
713-
fs [Abbr ‘ff’, Abbr ‘xs’]) >>
714-
fs [Abbr ‘ff’, Abbr ‘xs’] >>
715-
strip_tac >>
716-
cases_on ‘EL n (pan_simp$compile_prog pan_code)’ >>
717-
fs [] >>
718-
cases_on ‘r’ >> fs [] >> rveq >> gs [] >>
719-
pop_assum mp_tac >>
720-
fs [pan_simpTheory.compile_prog_def] >>
721-
qmatch_goalsub_abbrev_tac ‘EL n (MAP ff xs)’ >>
722-
‘EL n (MAP ff xs) = ff (EL n xs)’ by (
723-
match_mp_tac EL_MAP >>
724-
fs [Abbr ‘ff’, Abbr ‘xs’]) >>
725-
fs [Abbr ‘ff’, Abbr ‘xs’]) >>
726-
fs []
645+
fs [lookup_fromAList] >>
646+
irule_at Any ALOOKUP_ALL_DISTINCT_MEM >>
647+
irule_at Any crep_to_loopProofTheory.first_compile_prog_all_distinct >>
648+
fs [crep_to_loopTheory.compile_prog_def] >>
649+
simp [MAP2_MAP, MEM_MAP, EXISTS_PROD] >>
650+
csimp [MEM_ZIP, EL_GENLIST] >>
651+
fs [pan_to_crepTheory.compile_prog_def, pan_simpTheory.compile_prog_def] >>
652+
simp [EL_MAP] >>
653+
simp [pan_to_crepTheory.crep_vars_def, panLangTheory.size_of_shape_def]
727654
QED
728655

729656
(*** no_install/no_alloc/no_mt lemmas ***)
@@ -961,6 +888,38 @@ Proof
961888
rw[crep_to_loopTheory.mk_ctxt_def]
962889
QED
963890

891+
Theorem every_inst_ok_arith_simp_exp:
892+
! exp.
893+
every_exp (λx. ∀op es. x = Crepop op es ⇒ LENGTH es = 2) exp ==>
894+
every_exp (λx. ∀op es. x = Crepop op es ⇒ LENGTH es = 2) (simp_exp exp)
895+
Proof
896+
ho_match_mp_tac crep_arithTheory.simp_exp_ind
897+
\\ simp [crep_arithTheory.simp_exp_def, crepPropsTheory.every_exp_def]
898+
\\ rw [crep_arithTheory.mul_const_def]
899+
\\ every_case_tac \\ fs []
900+
\\ gvs [listTheory.MAP_EQ_CONS]
901+
\\ fs [crepPropsTheory.every_exp_def]
902+
\\ simp [EVERY_MAP]
903+
\\ fs [EVERY_MEM]
904+
QED
905+
906+
Theorem every_inst_ok_arith_simp_prog:
907+
! prog.
908+
EVERY (every_exp (λx. ∀op es. x = Crepop op es ⇒ LENGTH es = 2))
909+
(exps_of prog) ==>
910+
EVERY (every_exp (λx. ∀op es. x = Crepop op es ⇒ LENGTH es = 2))
911+
(exps_of (simp_prog prog))
912+
Proof
913+
ho_match_mp_tac crep_arithTheory.simp_prog_ind
914+
\\ simp [crep_arithTheory.simp_prog_def, crepPropsTheory.exps_of_def]
915+
\\ simp [every_inst_ok_arith_simp_exp]
916+
\\ rw []
917+
\\ every_case_tac \\ fs []
918+
\\ fs [crepPropsTheory.exps_of_def, every_inst_ok_arith_simp_exp]
919+
\\ fs [EVERY_MAP]
920+
\\ fs [EVERY_MEM, every_inst_ok_arith_simp_exp]
921+
QED
922+
964923
Theorem every_inst_ok_nested_decs:
965924
∀ns ps p.
966925
LENGTH ns = LENGTH ps ⇒
@@ -1228,6 +1187,22 @@ Proof
12281187
every_inst_ok_less_seq_assoc]
12291188
QED
12301189

1190+
Theorem every_inst_ok_less_crep_to_loop_compile_prog:
1191+
EVERY (λ(name,params,body). EVERY (every_exp (λx. ∀op es. x = Crepop op es ⇒ LENGTH es = 2)) (exps_of body)) crep_code ⇒
1192+
EVERY (λ(name,params,body). every_prog (loop_inst_ok c) body)
1193+
(crep_to_loop$compile_prog c.ISA crep_code)
1194+
Proof
1195+
simp [crep_to_loopTheory.compile_prog_def]
1196+
\\ simp [MAP2_MAP, EVERY_MAP]
1197+
\\ simp [ELIM_UNCURRY, every_zip_snd]
1198+
\\ rw [EVERY_MEM]
1199+
\\ irule every_inst_ok_less_optimise
1200+
\\ irule every_inst_ok_less_comp_func
1201+
\\ irule every_inst_ok_arith_simp_prog
1202+
\\ fs [EVERY_MEM]
1203+
\\ res_tac
1204+
QED
1205+
12311206
Theorem every_inst_ok_less_pan_simp_compile_prog:
12321207
EVERY (λ(name,params,body). EVERY (every_exp (λx. ∀op es. x = Panop op es ⇒ LENGTH es = 2)) (exps_of body)) pan_code ⇒
12331208
EVERY (λ(name,params,body). EVERY (every_exp (λx. ∀op es. x = Panop op es ⇒ LENGTH es = 2)) (exps_of body)) (pan_simp$compile_prog pan_code)
@@ -1251,28 +1226,10 @@ Proof
12511226
gs[pan_to_wordTheory.compile_prog_def]>>strip_tac>>
12521227
drule_then irule loop_to_word_every_inst_ok_less>>gs[]>>
12531228
last_x_assum kall_tac>>
1254-
simp[crep_to_loopTheory.compile_prog_def,EVERY_MEM]>>
1255-
dep_rewrite.DEP_ONCE_REWRITE_TAC [MAP2_ZIP]>>simp[]>>
1256-
rw[MEM_MAP,MEM_ZIP]>>
1257-
rpt(pairarg_tac>>gvs[])>>
1258-
match_mp_tac every_inst_ok_less_optimise>>
1259-
match_mp_tac every_inst_ok_less_comp_func>>
1260-
rw[EVERY_MEM,MEM_EL]>>
1261-
drule_at (Pos last) $ MP_CANON $ SIMP_RULE std_ss [MEM_EL,EVERY_MEM,PULL_EXISTS,PULL_FORALL] every_inst_ok_less_pan_to_crep_compile_prog>>
1262-
simp[] >>
1263-
disch_then $ match_mp_tac o MP_CANON>>
1264-
rw[] >>
1265-
pairarg_tac>>
1266-
rw[]>>
1267-
drule_at (Pos last) $ MP_CANON $ SIMP_RULE std_ss [MEM_EL,EVERY_MEM,PULL_EXISTS,PULL_FORALL] every_inst_ok_less_pan_simp_compile_prog>>
1268-
simp[]>>
1269-
disch_then $ match_mp_tac o MP_CANON>>
1270-
rw[]>>
1271-
pairarg_tac >>
1272-
rw[]>>
1273-
gvs[EVERY_MEM,MEM_EL,PULL_EXISTS]>>
1274-
first_x_assum dxrule>>
1275-
simp[]
1229+
irule every_inst_ok_less_crep_to_loop_compile_prog>>
1230+
irule every_inst_ok_less_pan_to_crep_compile_prog>>
1231+
irule every_inst_ok_less_pan_simp_compile_prog>>
1232+
simp []
12761233
QED
12771234

12781235
val _ = export_theory();

0 commit comments

Comments
 (0)