src/HOL/MicroJava/BV/BVSpecTypeSafe.thy
changeset 9819 e9fb6d44a490
parent 9757 1024a2d80ac0
child 9906 5c027cca6262
equal deleted inserted replaced
9818:71de955e8fc9 9819:e9fb6d44a490
    19       G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> |] 
    19       G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> |] 
    20   ==> wt_instr (ins!pc) G rT (phi C sig) (length ins) pc"
    20   ==> wt_instr (ins!pc) G rT (phi C sig) (length ins) pc"
    21 apply (unfold correct_state_def Let_def correct_frame_def)
    21 apply (unfold correct_state_def Let_def correct_frame_def)
    22 apply simp
    22 apply simp
    23 apply (blast intro: wt_jvm_prog_impl_wt_instr)
    23 apply (blast intro: wt_jvm_prog_impl_wt_instr)
    24 .
    24 done
    25 
    25 
    26 lemma Load_correct:
    26 lemma Load_correct:
    27 "\<lbrakk> wf_prog wt G;
    27 "\<lbrakk> wf_prog wt G;
    28    method (G,C) sig = Some (C,rT,maxl,ins); 
    28    method (G,C) sig = Some (C,rT,maxl,ins); 
    29    ins!pc = Load idx; 
    29    ins!pc = Load idx; 
    34 apply (clarsimp simp add: defs1 map_eq_Cons)
    34 apply (clarsimp simp add: defs1 map_eq_Cons)
    35 apply (rule conjI)
    35 apply (rule conjI)
    36  apply (rule approx_loc_imp_approx_val_sup)
    36  apply (rule approx_loc_imp_approx_val_sup)
    37  apply simp+
    37  apply simp+
    38 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup)
    38 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup)
    39 .
    39 done
    40 
    40 
    41 lemma Store_correct:
    41 lemma Store_correct:
    42 "\<lbrakk> wf_prog wt G;
    42 "\<lbrakk> wf_prog wt G;
    43   method (G,C) sig = Some (C,rT,maxl,ins);
    43   method (G,C) sig = Some (C,rT,maxl,ins);
    44   ins!pc = Store idx;
    44   ins!pc = Store idx;
    48 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
    48 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
    49 apply (clarsimp simp add: defs1 map_eq_Cons)
    49 apply (clarsimp simp add: defs1 map_eq_Cons)
    50 apply (rule conjI)
    50 apply (rule conjI)
    51  apply (blast intro: approx_stk_imp_approx_stk_sup)
    51  apply (blast intro: approx_stk_imp_approx_stk_sup)
    52 apply (blast intro: approx_loc_imp_approx_loc_subst approx_loc_imp_approx_loc_sup)
    52 apply (blast intro: approx_loc_imp_approx_loc_subst approx_loc_imp_approx_loc_sup)
    53 .
    53 done
    54 
    54 
    55 
    55 
    56 lemma conf_Intg_Integer [iff]:
    56 lemma conf_Intg_Integer [iff]:
    57   "G,h \<turnstile> Intg i \<Colon>\<preceq> PrimT Integer"
    57   "G,h \<turnstile> Intg i \<Colon>\<preceq> PrimT Integer"
    58 by (simp add: conf_def)
    58 by (simp add: conf_def)
    63   method (G,C) sig = Some (C,rT,maxl,ins); 
    63   method (G,C) sig = Some (C,rT,maxl,ins); 
    64   ins!pc = Bipush i; 
    64   ins!pc = Bipush i; 
    65   wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; 
    65   wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; 
    66   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs);
    66   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs);
    67   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk>
    67   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk>
    68 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>";
    68 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
    69 apply (clarsimp simp add: defs1 approx_val_def sup_PTS_eq map_eq_Cons)
    69 apply (clarsimp simp add: defs1 approx_val_def sup_PTS_eq map_eq_Cons)
    70 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup)
    70 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup)
    71 .
    71 done
    72 
    72 
    73 lemma NT_subtype_conv:
    73 lemma NT_subtype_conv:
    74   "G \<turnstile> NT \<preceq> T = (T=NT \<or> (\<exists>C. T = Class C))"
    74   "G \<turnstile> NT \<preceq> T = (T=NT \<or> (\<exists>C. T = Class C))"
    75 proof -
    75 proof -
    76   have "\<And>T T'. G \<turnstile> T' \<preceq> T \<Longrightarrow> T' = NT \<longrightarrow> (T=NT | (\<exists>C. T = Class C))"
    76   have "\<And>T T'. G \<turnstile> T' \<preceq> T \<Longrightarrow> T' = NT \<longrightarrow> (T=NT | (\<exists>C. T = Class C))"
    77     apply (erule widen.induct)
    77     apply (erule widen.induct)
    78     apply auto
    78     apply auto
    79     apply (case_tac R)
    79     apply (case_tac R)
    80     apply auto
    80     apply auto
    81     .
    81     done
    82   note l = this
    82   note l = this
    83 
    83 
    84   show ?thesis 
    84   show ?thesis 
    85     by (force intro: null dest: l)
    85     by (force intro: null dest: l)
    86 qed
    86 qed
    90   method (G,C) sig = Some (C,rT,maxl,ins); 
    90   method (G,C) sig = Some (C,rT,maxl,ins); 
    91   ins!pc =  Aconst_null; 
    91   ins!pc =  Aconst_null; 
    92   wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; 
    92   wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; 
    93   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs); 
    93   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs); 
    94   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
    94   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
    95 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>";
    95 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
    96 apply (clarsimp simp add: defs1 map_eq_Cons)
    96 apply (clarsimp simp add: defs1 map_eq_Cons)
    97 apply (rule conjI)
    97 apply (rule conjI)
    98  apply (force simp add: approx_val_Null NT_subtype_conv)
    98  apply (force simp add: approx_val_Null NT_subtype_conv)
    99 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup)
    99 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup)
   100 .
   100 done
   101 
   101 
   102 
   102 
   103 lemma Cast_conf2:
   103 lemma Cast_conf2:
   104   "\<lbrakk>wf_prog ok G; G,h\<turnstile>v\<Colon>\<preceq>RefT rt; cast_ok G C h v; G\<turnstile>Class C\<preceq>T; is_class G C\<rbrakk> 
   104   "\<lbrakk>wf_prog ok G; G,h\<turnstile>v\<Colon>\<preceq>RefT rt; cast_ok G C h v; G\<turnstile>Class C\<preceq>T; is_class G C\<rbrakk> 
   105   \<Longrightarrow> G,h\<turnstile>v\<Colon>\<preceq>T"
   105   \<Longrightarrow> G,h\<turnstile>v\<Colon>\<preceq>T"
   108 apply (elim exE disjE)
   108 apply (elim exE disjE)
   109  apply (simp add: null)
   109  apply (simp add: null)
   110 apply (clarsimp simp add: conf_def obj_ty_def)
   110 apply (clarsimp simp add: conf_def obj_ty_def)
   111 apply (cases v)
   111 apply (cases v)
   112 apply (auto intro: null rtrancl_trans)
   112 apply (auto intro: null rtrancl_trans)
   113 .
   113 done
   114 
   114 
   115 
   115 
   116 lemma Checkcast_correct:
   116 lemma Checkcast_correct:
   117 "\<lbrakk> wf_prog wt G;
   117 "\<lbrakk> wf_prog wt G;
   118   method (G,C) sig = Some (C,rT,maxl,ins); 
   118   method (G,C) sig = Some (C,rT,maxl,ins); 
   121   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   121   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   122   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   122   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   123 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   123 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   124 apply (clarsimp simp add: defs1 map_eq_Cons raise_xcpt_def approx_val_def)
   124 apply (clarsimp simp add: defs1 map_eq_Cons raise_xcpt_def approx_val_def)
   125 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup Cast_conf2)
   125 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup Cast_conf2)
   126 .
   126 done
   127 
   127 
   128 
   128 
   129 lemma Getfield_correct:
   129 lemma Getfield_correct:
   130 "\<lbrakk> wf_prog wt G;
   130 "\<lbrakk> wf_prog wt G;
   131   method (G,C) sig = Some (C,rT,maxl,ins); 
   131   method (G,C) sig = Some (C,rT,maxl,ins); 
   132   ins!pc = Getfield F D; 
   132   ins!pc = Getfield F D; 
   133   wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; 
   133   wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; 
   134   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   134   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   135   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   135   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   136 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>";
   136 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   137 apply (clarsimp simp add: defs1 raise_xcpt_def map_eq_Cons approx_val_def split: option.split)
   137 apply (clarsimp simp add: defs1 raise_xcpt_def map_eq_Cons approx_val_def split: option.split)
   138 apply (frule conf_widen)
   138 apply (frule conf_widen)
   139 apply assumption+
   139 apply assumption+
   140 apply (drule conf_RefTD)
   140 apply (drule conf_RefTD)
   141 apply (clarsimp simp add: defs1 approx_val_def)
   141 apply (clarsimp simp add: defs1 approx_val_def)
   142 apply (rule conjI)
   142 apply (rule conjI)
   143  apply (drule widen_cfs_fields)
   143  apply (drule widen_cfs_fields)
   144  apply assumption+
   144  apply assumption+
   145  apply (force intro: conf_widen simp add: hconf_def oconf_def lconf_def)
   145  apply (force intro: conf_widen simp add: hconf_def oconf_def lconf_def)
   146 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup)
   146 apply (blast intro: approx_stk_imp_approx_stk_sup approx_loc_imp_approx_loc_sup)
   147 .
   147 done
   148 
   148 
   149 lemma Putfield_correct:
   149 lemma Putfield_correct:
   150 "\<lbrakk> wf_prog wt G;
   150 "\<lbrakk> wf_prog wt G;
   151   method (G,C) sig = Some (C,rT,maxl,ins); 
   151   method (G,C) sig = Some (C,rT,maxl,ins); 
   152   ins!pc = Putfield F D; 
   152   ins!pc = Putfield F D; 
   153   wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; 
   153   wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; 
   154   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   154   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   155   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   155   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   156 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>";
   156 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   157 apply (clarsimp simp add: defs1 raise_xcpt_def split: option.split List.split)
   157 apply (clarsimp simp add: defs1 raise_xcpt_def split: option.split List.split)
   158 apply (clarsimp simp add: approx_val_def)
   158 apply (clarsimp simp add: approx_val_def)
   159 apply (frule conf_widen)
   159 apply (frule conf_widen)
   160 prefer 2
   160 prefer 2
   161 apply assumption
   161 apply assumption
   162 apply assumption
   162 apply assumption
   163 apply (drule conf_RefTD)
   163 apply (drule conf_RefTD)
   164 apply clarsimp
   164 apply clarsimp
   165 apply (blast intro: sup_heap_update_value approx_stk_imp_approx_stk_sup_heap approx_stk_imp_approx_stk_sup
   165 apply (blast intro: sup_heap_update_value approx_stk_imp_approx_stk_sup_heap
   166 		approx_loc_imp_approx_loc_sup_heap approx_loc_imp_approx_loc_sup
   166   approx_stk_imp_approx_stk_sup
   167 		hconf_imp_hconf_field_update
   167   approx_loc_imp_approx_loc_sup_heap approx_loc_imp_approx_loc_sup
   168 		correct_frames_imp_correct_frames_field_update conf_widen dest: widen_cfs_fields)
   168   hconf_imp_hconf_field_update
   169 .
   169   correct_frames_imp_correct_frames_field_update conf_widen dest: widen_cfs_fields)
       
   170 done
   170 
   171 
   171 lemma collapse_paired_All:
   172 lemma collapse_paired_All:
   172   "(\<forall>x y. P(x,y)) = (\<forall>z. P z)"
   173   "(\<forall>x y. P(x,y)) = (\<forall>z. P z)"
   173   by fast
   174   by fast
   174 
   175 
   188                    approx_loc_imp_approx_loc_sup_heap approx_loc_imp_approx_loc_sup
   189                    approx_loc_imp_approx_loc_sup_heap approx_loc_imp_approx_loc_sup
   189                    hconf_imp_hconf_newref correct_frames_imp_correct_frames_newref
   190                    hconf_imp_hconf_newref correct_frames_imp_correct_frames_newref
   190                    correct_init_obj simp add:  NT_subtype_conv approx_val_def conf_def
   191                    correct_init_obj simp add:  NT_subtype_conv approx_val_def conf_def
   191 		   fun_upd_apply map_eq_Cons is_class_def raise_xcpt_def init_vars_def defs1 
   192 		   fun_upd_apply map_eq_Cons is_class_def raise_xcpt_def init_vars_def defs1 
   192        split: option.split)
   193        split: option.split)
   193 .
   194 done
   194 
   195 
   195 
   196 
   196 (****** Method Invocation ******)
   197 (****** Method Invocation ******)
   197 
   198 
   198 lemmas [simp del] = split_paired_Ex
   199 lemmas [simp del] = split_paired_Ex
   440   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   441   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   441   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   442   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   442 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   443 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   443 apply (clarsimp simp add: neq_Nil_conv defs1 split: split_if_asm)
   444 apply (clarsimp simp add: neq_Nil_conv defs1 split: split_if_asm)
   444 apply (frule wt_jvm_prog_impl_wt_instr)
   445 apply (frule wt_jvm_prog_impl_wt_instr)
   445 apply (tactic "EVERY1[atac, etac Suc_lessD]")
   446 apply (assumption, erule Suc_lessD)
   446 apply (unfold wt_jvm_prog_def)
   447 apply (unfold wt_jvm_prog_def)
   447 apply (tactic {* fast_tac (claset()
   448 apply (fastsimp
   448  addDs [thm "subcls_widen_methd"]
   449   dest: subcls_widen_methd
   449  addEs [rotate_prems 1 widen_trans]
   450   elim: widen_trans [COMP swap_prems_rl]
   450  addIs [conf_widen]
   451   intro: conf_widen
   451  addss (simpset() addsimps [thm "approx_val_def",thm "append_eq_conv_conj", map_eq_Cons]@thms "defs1")) 1 *})
   452   simp: approx_val_def append_eq_conv_conj map_eq_Cons defs1)
   452 .
   453 done
   453 
   454 
   454 lemmas [simp] = map_append
   455 lemmas [simp] = map_append
   455 
   456 
   456 lemma Goto_correct:
   457 lemma Goto_correct:
   457 "\<lbrakk> wf_prog wt G; 
   458 "\<lbrakk> wf_prog wt G; 
   461   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   462   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   462   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   463   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   463 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   464 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   464 apply (clarsimp simp add: defs1)
   465 apply (clarsimp simp add: defs1)
   465 apply (fast intro: approx_loc_imp_approx_loc_sup approx_stk_imp_approx_stk_sup)
   466 apply (fast intro: approx_loc_imp_approx_loc_sup approx_stk_imp_approx_stk_sup)
   466 .
   467 done
   467 
   468 
   468 
   469 
   469 lemma Ifcmpeq_correct:
   470 lemma Ifcmpeq_correct:
   470 "\<lbrakk> wf_prog wt G; 
   471 "\<lbrakk> wf_prog wt G; 
   471   method (G,C) sig = Some (C,rT,maxl,ins); 
   472   method (G,C) sig = Some (C,rT,maxl,ins); 
   474   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   475   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   475   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   476   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   476 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   477 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   477 apply (clarsimp simp add: defs1)
   478 apply (clarsimp simp add: defs1)
   478 apply (fast intro: approx_loc_imp_approx_loc_sup approx_stk_imp_approx_stk_sup)
   479 apply (fast intro: approx_loc_imp_approx_loc_sup approx_stk_imp_approx_stk_sup)
   479 .
   480 done
   480 
   481 
   481 lemma Pop_correct:
   482 lemma Pop_correct:
   482 "\<lbrakk> wf_prog wt G; 
   483 "\<lbrakk> wf_prog wt G; 
   483   method (G,C) sig = Some (C,rT,maxl,ins); 
   484   method (G,C) sig = Some (C,rT,maxl,ins); 
   484   ins ! pc = Pop;
   485   ins ! pc = Pop;
   486   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   487   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   487   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   488   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   488 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   489 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   489 apply (clarsimp simp add: defs1)
   490 apply (clarsimp simp add: defs1)
   490 apply (fast intro: approx_loc_imp_approx_loc_sup approx_stk_imp_approx_stk_sup)
   491 apply (fast intro: approx_loc_imp_approx_loc_sup approx_stk_imp_approx_stk_sup)
   491 .
   492 done
   492 
   493 
   493 lemma Dup_correct:
   494 lemma Dup_correct:
   494 "\<lbrakk> wf_prog wt G; 
   495 "\<lbrakk> wf_prog wt G; 
   495   method (G,C) sig = Some (C,rT,maxl,ins); 
   496   method (G,C) sig = Some (C,rT,maxl,ins); 
   496   ins ! pc = Dup;
   497   ins ! pc = Dup;
   499   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   500   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   500 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   501 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   501 apply (clarsimp simp add: defs1 map_eq_Cons)
   502 apply (clarsimp simp add: defs1 map_eq_Cons)
   502 apply (force intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup
   503 apply (force intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup
   503              simp add: defs1 map_eq_Cons)
   504              simp add: defs1 map_eq_Cons)
   504 .
   505 done
   505 
   506 
   506 lemma Dup_x1_correct:
   507 lemma Dup_x1_correct:
   507 "\<lbrakk> wf_prog wt G; 
   508 "\<lbrakk> wf_prog wt G; 
   508   method (G,C) sig = Some (C,rT,maxl,ins); 
   509   method (G,C) sig = Some (C,rT,maxl,ins); 
   509   ins ! pc = Dup_x1;
   510   ins ! pc = Dup_x1;
   512   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   513   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   513 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   514 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   514 apply (clarsimp simp add: defs1 map_eq_Cons)
   515 apply (clarsimp simp add: defs1 map_eq_Cons)
   515 apply (force intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup
   516 apply (force intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup
   516              simp add: defs1 map_eq_Cons)
   517              simp add: defs1 map_eq_Cons)
   517 .
   518 done
   518 
   519 
   519 lemma Dup_x2_correct:
   520 lemma Dup_x2_correct:
   520 "\<lbrakk> wf_prog wt G; 
   521 "\<lbrakk> wf_prog wt G; 
   521   method (G,C) sig = Some (C,rT,maxl,ins); 
   522   method (G,C) sig = Some (C,rT,maxl,ins); 
   522   ins ! pc = Dup_x2;
   523   ins ! pc = Dup_x2;
   525   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   526   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   526 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   527 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   527 apply (clarsimp simp add: defs1 map_eq_Cons)
   528 apply (clarsimp simp add: defs1 map_eq_Cons)
   528 apply (force intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup
   529 apply (force intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup
   529              simp add: defs1 map_eq_Cons)
   530              simp add: defs1 map_eq_Cons)
   530 .
   531 done
   531 
   532 
   532 lemma Swap_correct:
   533 lemma Swap_correct:
   533 "\<lbrakk> wf_prog wt G; 
   534 "\<lbrakk> wf_prog wt G; 
   534   method (G,C) sig = Some (C,rT,maxl,ins); 
   535   method (G,C) sig = Some (C,rT,maxl,ins); 
   535   ins ! pc = Swap;
   536   ins ! pc = Swap;
   538   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   539   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   539 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   540 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   540 apply (clarsimp simp add: defs1 map_eq_Cons)
   541 apply (clarsimp simp add: defs1 map_eq_Cons)
   541 apply (force intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup
   542 apply (force intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup
   542              simp add: defs1 map_eq_Cons)
   543              simp add: defs1 map_eq_Cons)
   543 .
   544 done
   544 
   545 
   545 lemma IAdd_correct:
   546 lemma IAdd_correct:
   546 "\<lbrakk> wf_prog wt G; 
   547 "\<lbrakk> wf_prog wt G; 
   547   method (G,C) sig = Some (C,rT,maxl,ins); 
   548   method (G,C) sig = Some (C,rT,maxl,ins); 
   548   ins ! pc = IAdd; 
   549   ins ! pc = IAdd; 
   550   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   551   Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; 
   551   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   552   G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> 
   552 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   553 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   553 apply (clarsimp simp add: defs1 map_eq_Cons approx_val_def conf_def)
   554 apply (clarsimp simp add: defs1 map_eq_Cons approx_val_def conf_def)
   554 apply (blast intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup)
   555 apply (blast intro: approx_stk_imp_approx_stk_sup approx_val_imp_approx_val_sup approx_loc_imp_approx_loc_sup)
   555 .
   556 done
   556 
   557 
   557 
   558 
   558 (** instr correct **)
   559 (** instr correct **)
   559 
   560 
   560 lemma instr_correct:
   561 lemma instr_correct:
   573 apply (unfold wt_jvm_prog_def)
   574 apply (unfold wt_jvm_prog_def)
   574 apply (fast intro: Load_correct Store_correct Bipush_correct Aconst_null_correct 
   575 apply (fast intro: Load_correct Store_correct Bipush_correct Aconst_null_correct 
   575        Checkcast_correct Getfield_correct Putfield_correct New_correct 
   576        Checkcast_correct Getfield_correct Putfield_correct New_correct 
   576        Goto_correct Ifcmpeq_correct Pop_correct Dup_correct 
   577        Goto_correct Ifcmpeq_correct Pop_correct Dup_correct 
   577        Dup_x1_correct Dup_x2_correct Swap_correct IAdd_correct)+
   578        Dup_x1_correct Dup_x2_correct Swap_correct IAdd_correct)+
   578 .
   579 done
   579 
   580 
   580 
   581 
   581 (** Main **)
   582 (** Main **)
   582 
   583 
   583 lemma correct_state_impl_Some_method:
   584 lemma correct_state_impl_Some_method:
   586 by (auto simp add: correct_state_def Let_def)
   587 by (auto simp add: correct_state_def Let_def)
   587 
   588 
   588 
   589 
   589 lemma BV_correct_1 [rulify]:
   590 lemma BV_correct_1 [rulify]:
   590 "\<And>state. \<lbrakk> wt_jvm_prog G phi; G,phi \<turnstile>JVM state\<surd>\<rbrakk> 
   591 "\<And>state. \<lbrakk> wt_jvm_prog G phi; G,phi \<turnstile>JVM state\<surd>\<rbrakk> 
   591  \<Longrightarrow> exec (G,state) = Some state' \<longrightarrow> G,phi \<turnstile>JVM state'\<surd>";
   592  \<Longrightarrow> exec (G,state) = Some state' \<longrightarrow> G,phi \<turnstile>JVM state'\<surd>"
   592 apply (tactic "split_all_tac 1")
   593 apply (simp only: split_tupled_all)
   593 apply (rename_tac xp hp frs)
   594 apply (rename_tac xp hp frs)
   594 apply (case_tac xp)
   595 apply (case_tac xp)
   595  apply (case_tac frs)
   596  apply (case_tac frs)
   596   apply simp
   597   apply simp
   597  apply (tactic "split_all_tac 1")
   598  apply (simp only: split_tupled_all)
   598  apply (tactic "hyp_subst_tac 1")
   599  apply hypsubst
   599  apply (frule correct_state_impl_Some_method)
   600  apply (frule correct_state_impl_Some_method)
   600  apply (force intro: instr_correct)
   601  apply (force intro: instr_correct)
   601 apply (case_tac frs)
   602 apply (case_tac frs)
   602 apply simp+
   603 apply simp_all
   603 .
   604 done
   604 
   605 
   605 
   606 
   606 lemma L0:
   607 lemma L0:
   607   "\<lbrakk> xp=None; frs\<noteq>[] \<rbrakk> \<Longrightarrow> (\<exists>state'. exec (G,xp,hp,frs) = Some state')"
   608   "\<lbrakk> xp=None; frs\<noteq>[] \<rbrakk> \<Longrightarrow> (\<exists>state'. exec (G,xp,hp,frs) = Some state')"
   608 by (clarsimp simp add: neq_Nil_conv simp del: split_paired_Ex)
   609 by (clarsimp simp add: neq_Nil_conv simp del: split_paired_Ex)
   611   "\<lbrakk>wt_jvm_prog G phi; G,phi \<turnstile>JVM (xp,hp,frs)\<surd>; xp=None; frs\<noteq>[]\<rbrakk> 
   612   "\<lbrakk>wt_jvm_prog G phi; G,phi \<turnstile>JVM (xp,hp,frs)\<surd>; xp=None; frs\<noteq>[]\<rbrakk> 
   612   \<Longrightarrow> \<exists>state'. exec(G,xp,hp,frs) = Some state' \<and> G,phi \<turnstile>JVM state'\<surd>"
   613   \<Longrightarrow> \<exists>state'. exec(G,xp,hp,frs) = Some state' \<and> G,phi \<turnstile>JVM state'\<surd>"
   613 apply (drule L0)
   614 apply (drule L0)
   614 apply assumption
   615 apply assumption
   615 apply (fast intro: BV_correct_1)
   616 apply (fast intro: BV_correct_1)
   616 .
   617 done
   617 
   618 
   618 
   619 
   619 theorem BV_correct [rulify]:
   620 theorem BV_correct [rulify]:
   620 "\<lbrakk> wt_jvm_prog G phi; G \<turnstile> s -jvm\<rightarrow> t \<rbrakk> \<Longrightarrow> G,phi \<turnstile>JVM s\<surd> \<longrightarrow> G,phi \<turnstile>JVM t\<surd>"
   621 "\<lbrakk> wt_jvm_prog G phi; G \<turnstile> s -jvm\<rightarrow> t \<rbrakk> \<Longrightarrow> G,phi \<turnstile>JVM s\<surd> \<longrightarrow> G,phi \<turnstile>JVM t\<surd>"
   621 apply (unfold exec_all_def)
   622 apply (unfold exec_all_def)
   622 apply (erule rtrancl_induct)
   623 apply (erule rtrancl_induct)
   623  apply simp
   624  apply simp
   624 apply (auto intro: BV_correct_1)
   625 apply (auto intro: BV_correct_1)
   625 .
   626 done
   626 
   627 
   627 
   628 
   628 theorem BV_correct_initial:
   629 theorem BV_correct_initial:
   629 "\<lbrakk> wt_jvm_prog G phi; G \<turnstile> s0 -jvm\<rightarrow> (None,hp,(stk,loc,C,sig,pc)#frs); G,phi \<turnstile>JVM s0 \<surd>\<rbrakk> 
   630 "\<lbrakk> wt_jvm_prog G phi; G \<turnstile> s0 -jvm\<rightarrow> (None,hp,(stk,loc,C,sig,pc)#frs); G,phi \<turnstile>JVM s0 \<surd>\<rbrakk> 
   630  \<Longrightarrow>  approx_stk G hp stk (fst (the (((phi  C)  sig) ! pc))) \<and> approx_loc G hp loc (snd (the (((phi  C)  sig) ! pc)))"
   631  \<Longrightarrow>  approx_stk G hp stk (fst (the (((phi  C)  sig) ! pc))) \<and> approx_loc G hp loc (snd (the (((phi  C)  sig) ! pc)))"
   631 apply (drule BV_correct)
   632 apply (drule BV_correct)
   632 apply assumption+
   633 apply assumption+
   633 apply (simp add: correct_state_def correct_frame_def split_def split: option.splits)
   634 apply (simp add: correct_state_def correct_frame_def split_def split: option.splits)
   634 .
   635 done
   635 
   636 
   636 end
   637 end