1253 lemma bc_mt_corresp_Getfield: "\<lbrakk> wf_prog wf_mb G; |
1248 lemma bc_mt_corresp_Getfield: "\<lbrakk> wf_prog wf_mb G; |
1254 field (G, C) vname = Some (cname, T); is_class G C \<rbrakk> |
1249 field (G, C) vname = Some (cname, T); is_class G C \<rbrakk> |
1255 \<Longrightarrow> bc_mt_corresp [Getfield vname cname] |
1250 \<Longrightarrow> bc_mt_corresp [Getfield vname cname] |
1256 (replST (Suc 0) (snd (the (field (G, cname) vname)))) |
1251 (replST (Suc 0) (snd (the (field (G, cname) vname)))) |
1257 (Class C # ST, LT) (comp G) rT mxr (Suc 0)" |
1252 (Class C # ST, LT) (comp G) rT mxr (Suc 0)" |
1258 apply (frule wf_subcls1) |
1253 apply (frule wf_prog_ws_prog [THEN wf_subcls1]) |
1259 apply (frule field_in_fd, assumption+) |
1254 apply (frule field_in_fd, assumption+) |
1260 apply (frule widen_field, assumption+) |
1255 apply (frule widen_field, assumption+) |
1261 apply (simp add: bc_mt_corresp_def replST_def wt_instr_altern_def eff_def norm_eff_def) |
1256 apply (simp add: bc_mt_corresp_def replST_def wt_instr_altern_def eff_def norm_eff_def) |
1262 apply (simp add: comp_field [THEN sym] comp_subcls1 [THEN sym] comp_widen [THEN sym] comp_is_class [THEN sym]) |
1257 apply (simp add: comp_field comp_subcls1 comp_widen comp_is_class) |
1263 apply (simp add: max_ssize_def max_of_list_def ssize_sto_def) |
1258 apply (simp add: max_ssize_def max_of_list_def ssize_sto_def) |
1264 apply (intro strip) |
1259 apply (intro strip) |
1265 apply (simp add: check_type_simps) |
1260 apply (simp add: check_type_simps) |
1266 apply clarify |
1261 apply clarify |
1267 apply (rule_tac x="Suc (length ST)" in exI) |
1262 apply (rule_tac x="Suc (length ST)" in exI) |
1268 apply simp+ |
1263 apply simp+ |
1269 apply (simp only: comp_is_type [THEN sym]) |
1264 apply (simp only: comp_is_type) |
1270 apply (rule_tac C=cname in fields_is_type) |
1265 apply (rule_tac C=cname in fields_is_type) |
1271 apply (simp add: field_def) |
1266 apply (simp add: field_def) |
1272 apply (drule JBasis.table_of_remap_SomeD)+ |
1267 apply (drule JBasis.table_of_remap_SomeD)+ |
1273 apply assumption+ |
1268 apply assumption+ |
|
1269 apply (erule wf_prog_ws_prog) |
|
1270 apply assumption |
1274 done |
1271 done |
1275 |
1272 |
1276 lemma bc_mt_corresp_Putfield: "\<lbrakk> wf_prog wf_mb G; |
1273 lemma bc_mt_corresp_Putfield: "\<lbrakk> wf_prog wf_mb G; |
1277 field (G, C) vname = Some (cname, Ta); G \<turnstile> T \<preceq> Ta; is_class G C \<rbrakk> |
1274 field (G, C) vname = Some (cname, Ta); G \<turnstile> T \<preceq> Ta; is_class G C \<rbrakk> |
1278 \<Longrightarrow> bc_mt_corresp [Putfield vname cname] (popST 2) (T # Class C # T # ST, LT) |
1275 \<Longrightarrow> bc_mt_corresp [Putfield vname cname] (popST 2) (T # Class C # T # ST, LT) |
1279 (comp G) rT mxr (Suc 0)" |
1276 (comp G) rT mxr (Suc 0)" |
1280 apply (frule wf_subcls1) |
1277 apply (frule wf_prog_ws_prog [THEN wf_subcls1]) |
1281 apply (frule field_in_fd, assumption+) |
1278 apply (frule field_in_fd, assumption+) |
1282 apply (frule widen_field, assumption+) |
1279 apply (frule widen_field, assumption+) |
1283 apply (simp add: bc_mt_corresp_def popST_def wt_instr_altern_def eff_def norm_eff_def) |
1280 apply (simp add: bc_mt_corresp_def popST_def wt_instr_altern_def eff_def norm_eff_def) |
1284 apply (simp add: comp_field [THEN sym] comp_subcls1 [THEN sym] comp_widen [THEN sym] comp_is_class [THEN sym]) |
1281 apply (simp add: comp_field comp_subcls1 comp_widen comp_is_class) |
1285 apply (simp add: max_ssize_def max_of_list_def ssize_sto_def max_def) |
1282 apply (simp add: max_ssize_def max_of_list_def ssize_sto_def max_def) |
1286 |
1283 |
1287 apply (intro strip) |
1284 apply (intro strip) |
1288 apply (simp add: check_type_simps) |
1285 apply (simp add: check_type_simps) |
1289 apply clarify |
1286 apply clarify |
1300 apply (subgoal_tac "(\<exists>mD' rT' comp_b. |
1297 apply (subgoal_tac "(\<exists>mD' rT' comp_b. |
1301 method (comp G, cname) (mname, pTs') = Some (mD', rT', comp_b))") |
1298 method (comp G, cname) (mname, pTs') = Some (mD', rT', comp_b))") |
1302 apply (simp add: comp_is_class) |
1299 apply (simp add: comp_is_class) |
1303 apply (rule_tac x=pTsa in exI) |
1300 apply (rule_tac x=pTsa in exI) |
1304 apply (rule_tac x="Class cname" in exI) |
1301 apply (rule_tac x="Class cname" in exI) |
1305 apply (simp add: max_spec_preserves_length comp_is_class [THEN sym]) |
1302 apply (simp add: max_spec_preserves_length comp_is_class) |
1306 apply (frule max_spec2mheads, (erule exE)+, (erule conjE)+) |
1303 apply (frule max_spec2mheads, (erule exE)+, (erule conjE)+) |
1307 apply (simp add: comp_widen list_all2_def) |
1304 apply (simp add: split_paired_all comp_widen list_all2_def) |
1308 apply (frule max_spec2mheads, (erule exE)+, (erule conjE)+) |
1305 apply (frule max_spec2mheads, (erule exE)+, (erule conjE)+) |
1309 apply (rule exI)+ |
1306 apply (rule exI)+ |
1310 apply (rule comp_method) |
1307 apply (simp add: wf_prog_ws_prog [THEN comp_method]) |
1311 apply assumption+ |
1308 apply auto |
1312 done |
1309 done |
1313 |
1310 |
1314 |
1311 |
1315 lemma bc_mt_corresp_Invoke: "\<lbrakk> wf_prog wf_mb G; |
1312 lemma bc_mt_corresp_Invoke: "\<lbrakk> wf_prog wf_mb G; |
1316 max_spec G cname (mname, pTsa) = {((md, T), fpTs)}; |
1313 max_spec G cname (mname, pTsa) = {((md, T), fpTs)}; |
1920 apply (simp only: compTpExpr_LT_ST) |
1918 apply (simp only: compTpExpr_LT_ST) |
1921 apply (rule bc_mt_corresp_comb, (rule HOL.refl)+) apply blast |
1919 apply (rule bc_mt_corresp_comb, (rule HOL.refl)+) apply blast |
1922 apply (simp only: compTpExprs_LT_ST) |
1920 apply (simp only: compTpExprs_LT_ST) |
1923 apply (simp (no_asm_simp)) |
1921 apply (simp (no_asm_simp)) |
1924 apply (rule bc_mt_corresp_Invoke) apply assumption+ |
1922 apply (rule bc_mt_corresp_Invoke) apply assumption+ |
1925 apply (rule wt_class_expr_is_class, assumption+) apply (rule HOL.refl) |
1923 apply (fast intro: wt_class_expr_is_class) |
1926 apply (simp (no_asm_simp) add: start_sttp_resp_def) |
1924 apply (simp (no_asm_simp) add: start_sttp_resp_def) |
1927 apply (rule start_sttp_resp_comb) |
1925 apply (rule start_sttp_resp_comb) |
1928 apply (simp (no_asm_simp)) |
1926 apply (simp (no_asm_simp)) |
1929 apply (simp (no_asm_simp) add: start_sttp_resp_def) |
1927 apply (simp (no_asm_simp) add: start_sttp_resp_def) |
1930 |
1928 |
2245 and "f3.0"="comb_nil" |
2243 and "f3.0"="comb_nil" |
2246 in bc_mt_corresp_comb_wt_instr) |
2244 in bc_mt_corresp_comb_wt_instr) |
2247 apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt)+ |
2245 apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt)+ |
2248 apply (intro strip) |
2246 apply (intro strip) |
2249 apply (rule wt_instr_Goto) |
2247 apply (rule wt_instr_Goto) |
2250 apply (simp (no_asm_simp) add: nat_canonify) |
2248 apply arith |
2251 apply (simp (no_asm_simp) add: nat_canonify) |
2249 apply arith |
2252 (* \<dots> ! nat (int pc + i) = \<dots> ! pc *) |
2250 (* \<dots> ! nat (int pc + i) = \<dots> ! pc *) |
2253 apply (simp (no_asm_simp) add: nat_canonify) |
2251 apply (simp (no_asm_simp)) |
2254 apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt) |
2252 apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt) |
2255 apply (simp (no_asm_simp) add: pushST_def popST_def nochangeST_def) |
2253 apply (simp (no_asm_simp) add: pushST_def popST_def nochangeST_def) |
2256 apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST) |
2254 apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST) |
2257 apply (simp (no_asm_simp) only: int_outside_right nat_int) |
|
2258 apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt) |
2255 apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt) |
2259 apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST) |
2256 apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST) |
2260 apply (simp (no_asm_simp) add: pushST_def popST_def nochangeST_def) |
2257 apply (simp (no_asm_simp) add: pushST_def popST_def nochangeST_def) |
2261 apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt) |
2258 apply (simp (no_asm_simp) add: length_compTpExpr length_compTpStmt) |
2262 apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST) |
2259 apply (simp only: compTpExpr_LT_ST compTpStmt_LT_ST) |
2590 |
2587 |
2591 (* subgoal jmb = (\<dots>) *) |
2588 (* subgoal jmb = (\<dots>) *) |
2592 apply (simp only: split_paired_All, simp) |
2589 apply (simp only: split_paired_All, simp) |
2593 |
2590 |
2594 (* subgoal is_class / wf_mhead / wf_java_mdecl *) |
2591 (* subgoal is_class / wf_mhead / wf_java_mdecl *) |
2595 apply (rule methd [THEN conjunct2]) apply assumption+ apply (simp only:) |
2592 apply (blast intro: methd [THEN conjunct2]) |
2596 apply (rule wf_prog_wf_mhead, assumption+) apply (simp only:) |
2593 apply (frule wf_prog_wf_mdecl, assumption+) apply (simp only:) apply (simp add: wf_mdecl_def) |
2597 apply (rule wf_java_prog_wf_java_mdecl, assumption+) |
2594 apply (rule wf_java_prog_wf_java_mdecl, assumption+) |
2598 |
2595 done |
2599 done |
|
2600 |
|
2601 |
|
2602 (**********************************************************************************) |
|
2603 |
|
2604 |
2596 |
2605 |
2597 |
2606 lemma comp_set_ms: "(C, D, fs, cms)\<in>set (comp G) |
2598 lemma comp_set_ms: "(C, D, fs, cms)\<in>set (comp G) |
2607 \<Longrightarrow> \<exists> ms. (C, D, fs, ms) \<in>set G \<and> cms = map (compMethod G C) ms" |
2599 \<Longrightarrow> \<exists> ms. (C, D, fs, ms) \<in>set G \<and> cms = map (compMethod G C) ms" |
2608 by (auto simp: comp_def compClass_def) |
2600 by (auto simp: comp_def compClass_def) |
2609 |
2601 |
2610 lemma method_body_source: "\<lbrakk> wf_prog wf_mb G; is_class G C; method (comp G, C) sig = Some (D, rT, cmb) \<rbrakk> |
2602 |
2611 \<Longrightarrow> (\<exists> mb. method (G, C) sig = Some (D, rT, mb))" |
2603 (* ---------------------------------------------------------------------- *) |
2612 apply (simp add: comp_method_eq comp_method_result_def) |
|
2613 apply (case_tac "method (G, C) sig") |
|
2614 apply auto |
|
2615 done |
|
2616 |
2604 |
2617 section "Main Theorem" |
2605 section "Main Theorem" |
2618 (* MAIN THEOREM: |
2606 (* MAIN THEOREM: |
2619 Methodtype computed by comp is correct for bytecode generated by compTp *) |
2607 Methodtype computed by comp is correct for bytecode generated by compTp *) |
2620 theorem wt_prog_comp: "wf_java_prog G \<Longrightarrow> wt_jvm_prog (comp G) (compTp G)" |
2608 theorem wt_prog_comp: "wf_java_prog G \<Longrightarrow> wt_jvm_prog (comp G) (compTp G)" |
2621 apply (simp add: wf_prog_def) |
2609 apply (simp add: wf_prog_def) |
|
2610 |
2622 apply (subgoal_tac "wf_java_prog G") prefer 2 apply (simp add: wf_prog_def) |
2611 apply (subgoal_tac "wf_java_prog G") prefer 2 apply (simp add: wf_prog_def) |
2623 apply (simp (no_asm_simp) add: wf_prog_def wt_jvm_prog_def) |
2612 apply (simp (no_asm_simp) add: wf_prog_def wt_jvm_prog_def) |
2624 apply (simp add: comp_unique comp_wf_syscls wf_cdecl_def) |
2613 apply (simp add: comp_ws_prog) |
|
2614 |
|
2615 apply (intro strip) |
|
2616 apply (subgoal_tac "\<exists> C D fs cms. c = (C, D, fs, cms)") |
2625 apply clarify |
2617 apply clarify |
2626 apply (frule comp_set_ms) |
2618 apply (frule comp_set_ms) |
2627 apply clarify |
2619 apply clarify |
2628 apply (drule bspec, assumption) |
2620 apply (drule bspec, assumption) |
2629 apply (simp add: comp_wf_fdecl) |
|
2630 apply (simp add: wf_mdecl_def) |
|
2631 |
|
2632 apply (rule conjI) |
2621 apply (rule conjI) |
2633 apply (rule ballI) |
2622 |
2634 apply (subgoal_tac "\<exists> sig rT mb. x = (sig, rT, mb)") prefer 2 apply (case_tac x, simp) |
2623 (* wf_mrT *) |
|
2624 apply (case_tac "C = Object") |
|
2625 apply (simp add: wf_mrT_def) |
|
2626 apply (subgoal_tac "is_class G D") |
|
2627 apply (simp add: comp_wf_mrT) |
|
2628 apply (simp add: wf_prog_def ws_prog_def ws_cdecl_def) |
|
2629 apply blast |
|
2630 |
|
2631 (* wf_cdecl_mdecl *) |
|
2632 apply (simp add: wf_cdecl_mdecl_def) |
|
2633 apply (simp add: split_beta) |
|
2634 apply (intro strip) |
|
2635 |
|
2636 (* show wt_method \<dots> *) |
|
2637 apply (subgoal_tac "\<exists> sig rT mb. x = (sig, rT, mb)") |
2635 apply (erule exE)+ |
2638 apply (erule exE)+ |
2636 apply (simp (no_asm_simp) add: compMethod_def split_beta) |
2639 apply (simp (no_asm_simp) add: compMethod_def split_beta) |
2637 apply (erule conjE)+ |
2640 apply (erule conjE)+ |
2638 apply (drule_tac x="(sig, rT, mb)" in bspec) apply simp |
2641 apply (drule_tac x="(sig, rT, mb)" in bspec) apply simp |
2639 apply (rule conjI) |
|
2640 apply (simp add: comp_wf_mhead) |
|
2641 apply (rule_tac mn="fst sig" and pTs="snd sig" in wt_method_comp) |
2642 apply (rule_tac mn="fst sig" and pTs="snd sig" in wt_method_comp) |
2642 apply assumption+ |
2643 apply assumption+ |
2643 apply simp |
2644 apply simp |
2644 apply (simp (no_asm_simp) add: compTp_def) |
2645 apply (simp (no_asm_simp) add: compTp_def) |
2645 apply (simp (no_asm_simp) add: compMethod_def split_beta) |
2646 apply (simp (no_asm_simp) add: compMethod_def split_beta) |
2646 apply (frule WellForm.methd) apply assumption+ |
2647 apply (frule WellForm.methd) apply assumption+ |
2647 apply simp |
2648 apply simp |
2648 apply simp |
2649 apply simp |
2649 apply (simp add: compMethod_def split_beta) |
2650 apply (simp add: compMethod_def split_beta) |
2650 |
2651 apply auto |
2651 apply (rule conjI) |
2652 done |
2652 apply (rule unique_map_fst [THEN iffD1]) |
|
2653 apply (simp (no_asm_simp) add: compMethod_def split_beta) apply simp |
|
2654 |
|
2655 apply clarify |
|
2656 apply (rule conjI) apply (simp add: comp_is_class) |
|
2657 apply (rule conjI) apply (simp add: comp_subcls) |
|
2658 apply (simp add: compMethod_def split_beta) |
|
2659 apply (intro strip) |
|
2660 apply (drule_tac x=x in bspec, assumption, drule_tac x="D'" in spec, drule_tac x="rT'" in spec) |
|
2661 apply (erule exE) |
|
2662 |
|
2663 apply (frule method_body_source) apply assumption+ |
|
2664 apply (drule mp, assumption) |
|
2665 apply (simp add: comp_widen) |
|
2666 done |
|
2667 |
|
2668 |
2653 |
2669 |
2654 |
2670 |
2655 |
2671 (**********************************************************************************) |
2656 (**********************************************************************************) |
2672 |
2657 |