src/HOL/MicroJava/BV/BVSpecTypeSafe.ML
changeset 9376 c32c5696ec2a
parent 9348 f495dba0cb07
child 9549 40d64cb4f4e6
equal deleted inserted replaced
9375:cc0fd5226bb7 9376:c32c5696ec2a
     3     Author:     Cornelia Pusch
     3     Author:     Cornelia Pusch
     4     Copyright   1999 Technische Universitaet Muenchen
     4     Copyright   1999 Technische Universitaet Muenchen
     5 *)
     5 *)
     6 
     6 
     7 val defs1 = exec.simps@[split_def,sup_state_def,correct_state_def,
     7 val defs1 = exec.simps@[split_def,sup_state_def,correct_state_def,
     8 		correct_frame_def,wt_instr_def];
     8 		correct_frame_def];
     9 
     9 
    10 Goalw [correct_state_def,Let_def,correct_frame_def,split_def]
    10 Goalw [correct_state_def,Let_def,correct_frame_def,split_def]
    11 "\\<lbrakk> wt_jvm_prog G phi; \
    11 "\\<lbrakk> wt_jvm_prog G phi; \
    12 \   method (G,C) sig = Some (C,rT,maxl,ins); \
    12 \   method (G,C) sig = Some (C,rT,maxl,ins); \
    13 \   G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    13 \   G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    23 (******* LS *******)
    23 (******* LS *******)
    24 
    24 
    25 Goal
    25 Goal
    26 "\\<lbrakk> wf_prog wt G; \
    26 "\\<lbrakk> wf_prog wt G; \
    27 \  method (G,C) sig = Some (C,rT,maxl,ins); \
    27 \  method (G,C) sig = Some (C,rT,maxl,ins); \
    28 \  ins!pc = LS(Load idx); \
    28 \  ins!pc = Load idx; \
    29 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
    29 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
    30 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs); \
    30 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs); \
    31 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    31 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    32 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
    32 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
    33 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_val_sup,
    33 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_val_sup,
    36 qed "Load_correct";
    36 qed "Load_correct";
    37 
    37 
    38 Goal 
    38 Goal 
    39 "\\<lbrakk> wf_prog wt G; \
    39 "\\<lbrakk> wf_prog wt G; \
    40 \  method (G,C) sig = Some (C,rT,maxl,ins); \
    40 \  method (G,C) sig = Some (C,rT,maxl,ins); \
    41 \  ins!pc = LS(Store idx); \
    41 \  ins!pc = Store idx; \
    42 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
    42 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
    43 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
    43 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
    44 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    44 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    45 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
    45 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
    46 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_subst RSN(2, approx_loc_imp_approx_loc_sup)]
    46 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_subst RSN(2, approx_loc_imp_approx_loc_sup)]
    53 AddIffs [conf_Intg_Integer];
    53 AddIffs [conf_Intg_Integer];
    54 
    54 
    55 Goal
    55 Goal
    56 "\\<lbrakk> wf_prog wt G; \
    56 "\\<lbrakk> wf_prog wt G; \
    57 \  method (G,C) sig = Some (C,rT,maxl,ins); \
    57 \  method (G,C) sig = Some (C,rT,maxl,ins); \
    58 \  ins!pc = LS(Bipush i); \
    58 \  ins!pc = Bipush i; \
    59 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
    59 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
    60 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
    60 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
    61 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    61 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    62 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
    62 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
    63 by (fast_tac (claset()addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup]
    63 by (fast_tac (claset()addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup]
    77 qed "NT_subtype_conv";
    77 qed "NT_subtype_conv";
    78 
    78 
    79 Goal 
    79 Goal 
    80 "\\<lbrakk> wf_prog wt G; \
    80 "\\<lbrakk> wf_prog wt G; \
    81 \  method (G,C) sig = Some (C,rT,maxl,ins); \
    81 \  method (G,C) sig = Some (C,rT,maxl,ins); \
    82 \  ins!pc = LS Aconst_null; \
    82 \  ins!pc =  Aconst_null; \
    83 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
    83 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
    84 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
    84 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
    85 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    85 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
    86 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
    86 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
    87 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup]
    87 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup]
    88 	addss (simpset() addsimps [approx_val_Null,NT_subtype_conv,map_eq_Cons]@defs1)) 1);
    88 	addss (simpset() addsimps [approx_val_Null,NT_subtype_conv,map_eq_Cons]@defs1)) 1);
    89 qed "Aconst_null_correct";
    89 qed "Aconst_null_correct";
    90 
    90 
    91 
    91 
    92 Goal
       
    93 "\\<lbrakk> wt_jvm_prog G phi; \
       
    94 \  method (G,C) sig = Some (C,rT,maxl,ins); \
       
    95 \  ins!pc = LS ls_com; \
       
    96 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
       
    97 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
       
    98 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
       
    99 by(forward_tac [wt_jvm_prog_impl_wt_instr_cor] 1);
       
   100   ba 1;
       
   101  ba 1;
       
   102 by(rewtac wt_jvm_prog_def);
       
   103 by (case_tac "ls_com" 1);
       
   104 by (ALLGOALS (fast_tac (claset() addIs [Load_correct,Store_correct,Bipush_correct,Aconst_null_correct])));
       
   105 qed "LS_correct";
       
   106 
       
   107 
       
   108 (**** CH ****)
       
   109 
    92 
   110 Goalw [cast_ok_def]
    93 Goalw [cast_ok_def]
   111  "\\<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> \
    94  "\\<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> \
   112 \ \\<Longrightarrow> G,h\\<turnstile>v\\<Colon>\\<preceq>T";
    95 \ \\<Longrightarrow> G,h\\<turnstile>v\\<Colon>\\<preceq>T";
   113 by (forward_tac [widen_Class] 1);
    96 by (forward_tac [widen_Class] 1);
   122 qed "Cast_conf2";
   105 qed "Cast_conf2";
   123 
   106 
   124 Goal
   107 Goal
   125 "\\<lbrakk> wf_prog wt G; \
   108 "\\<lbrakk> wf_prog wt G; \
   126 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   109 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   127 \  ins!pc = CH (Checkcast D); \
   110 \  ins!pc = Checkcast D; \
   128 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   111 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   129 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   112 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   130 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   113 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   131 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   114 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   132 by (asm_full_simp_tac (simpset() addsimps [map_eq_Cons,
   115 by (asm_full_simp_tac (simpset() addsimps [map_eq_Cons,
   133 		raise_xcpt_def]@defs1 addsplits [option.split]) 1);
   116 		raise_xcpt_def]@defs1 addsplits [option.split]) 1);
   134 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup,Cast_conf2] 
   117 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup,Cast_conf2] 
   135 	addss (simpset() addsimps [map_eq_Cons,approx_val_def])) 1);
   118 	addss (simpset() addsimps [map_eq_Cons,approx_val_def])) 1);
   136 qed "Checkcast_correct";
   119 qed "Checkcast_correct";
   137 
   120 
   138 Goal
   121 
   139 "\\<lbrakk> wt_jvm_prog G phi; \
   122 Goal
   140 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   123 "\\<lbrakk> wf_prog wt G; \
   141 \  ins!pc = CH ch_com; \
   124 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   142 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   125 \  ins!pc = Getfield F D; \
   143 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
       
   144 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
       
   145 by(forward_tac [wt_jvm_prog_impl_wt_instr_cor] 1);
       
   146   ba 1;
       
   147  ba 1;
       
   148 by(rewtac wt_jvm_prog_def);
       
   149 by (case_tac "ch_com" 1);
       
   150 by (ALLGOALS (fast_tac (claset() addIs [Checkcast_correct])));
       
   151 qed "CH_correct";
       
   152 
       
   153 
       
   154 (******* MO *******)
       
   155 
       
   156 Goal
       
   157 "\\<lbrakk> wf_prog wt G; \
       
   158 \  method (G,C) sig = Some (C,rT,maxl,ins); \
       
   159 \  ins!pc = MO (Getfield F D); \
       
   160 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   126 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   161 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   127 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   162 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   128 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   163 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   129 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   164 by (asm_full_simp_tac (simpset() addsimps [raise_xcpt_def]@defs1 addsplits [option.split]) 1);
   130 by (asm_full_simp_tac (simpset() addsimps [raise_xcpt_def]@defs1 addsplits [option.split]) 1);
   185 
   151 
   186 
   152 
   187 Goal
   153 Goal
   188 "\\<lbrakk> wf_prog wt G; \
   154 "\\<lbrakk> wf_prog wt G; \
   189 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   155 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   190 \  ins!pc = MO (Putfield F D); \
   156 \  ins!pc = Putfield F D; \
   191 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   157 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   192 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   158 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   193 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   159 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   194 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   160 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   195 by (asm_full_simp_tac (simpset() addsimps [raise_xcpt_def]@defs1 addsplits [option.split]) 1);
   161 by (asm_full_simp_tac (simpset() addsimps [raise_xcpt_def]@defs1 addsplits [option.split]) 1);
   207 		hconf_imp_hconf_field_update,
   173 		hconf_imp_hconf_field_update,
   208 		correct_frames_imp_correct_frames_field_update,conf_widen] addss (simpset())) 1);
   174 		correct_frames_imp_correct_frames_field_update,conf_widen] addss (simpset())) 1);
   209 qed "Putfield_correct";
   175 qed "Putfield_correct";
   210 
   176 
   211 
   177 
   212 Goal
       
   213 "\\<lbrakk> wt_jvm_prog G phi; \
       
   214 \  method (G,C) sig = Some (C,rT,maxl,ins); \
       
   215 \  ins!pc = MO mo_com; \
       
   216 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
       
   217 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
       
   218 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
       
   219 by(forward_tac [wt_jvm_prog_impl_wt_instr_cor] 1);
       
   220   ba 1;
       
   221  ba 1;
       
   222 by(rewtac wt_jvm_prog_def);
       
   223 by (case_tac "mo_com" 1);
       
   224 by (ALLGOALS (fast_tac (claset() addIs [Getfield_correct,Putfield_correct])));
       
   225 qed "MO_correct";
       
   226 
       
   227 
       
   228 (****** CO ******)
       
   229 
       
   230 Goal "(\\<forall>x y. P(x,y)) = (\\<forall>z. P z)";
   178 Goal "(\\<forall>x y. P(x,y)) = (\\<forall>z. P z)";
   231 by(Fast_tac 1);
   179 by(Fast_tac 1);
   232 qed "collapse_paired_All";
   180 qed "collapse_paired_All";
   233 
   181 
   234 Goal
   182 Goal
   235 "\\<lbrakk> wf_prog wt G; \
   183 "\\<lbrakk> wf_prog wt G; \
   236 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   184 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   237 \  ins!pc = CO(New cl_idx); \
   185 \  ins!pc = New cl_idx; \
   238 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   186 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   239 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   187 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   240 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   188 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   241 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   189 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   242 by (fast_tac (claset() addSDs [collapse_paired_All RS iffD1]addIs [sup_heap_newref,
   190 by (fast_tac (claset() addSDs [collapse_paired_All RS iffD1]addIs [sup_heap_newref,
   247 	addss (simpset() addsimps [NT_subtype_conv,approx_val_def,conf_def,
   195 	addss (simpset() addsimps [NT_subtype_conv,approx_val_def,conf_def,
   248 		fun_upd_apply,map_eq_Cons,is_class_def,raise_xcpt_def,init_vars_def]@defs1 
   196 		fun_upd_apply,map_eq_Cons,is_class_def,raise_xcpt_def,init_vars_def]@defs1 
   249 	addsplits [option.split])) 1);
   197 	addsplits [option.split])) 1);
   250 qed "New_correct";
   198 qed "New_correct";
   251 
   199 
       
   200 
       
   201 (****** Method Invocation ******)
       
   202 
   252 Goal
   203 Goal
   253 "\\<lbrakk> wt_jvm_prog G phi; \
   204 "\\<lbrakk> wt_jvm_prog G phi; \
   254 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   205 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   255 \  ins!pc = CO co_com; \
   206 \  ins ! pc = Invoke mn pTs; \
   256 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
       
   257 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
       
   258 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
       
   259 by(forward_tac [wt_jvm_prog_impl_wt_instr_cor] 1);
       
   260   ba 1;
       
   261  ba 1;
       
   262 by(rewtac wt_jvm_prog_def);
       
   263 by (case_tac "co_com" 1);
       
   264 by (ALLGOALS (fast_tac (claset() addIs [New_correct])));
       
   265 qed "CO_correct";
       
   266 
       
   267 
       
   268 (****** MI ******)
       
   269 
       
   270 Goal
       
   271 "\\<lbrakk> wt_jvm_prog G phi; \
       
   272 \  method (G,C) sig = Some (C,rT,maxl,ins); \
       
   273 \  ins ! pc = MI(Invoke mn pTs); \
       
   274 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   207 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   275 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   208 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   276 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   209 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   277 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   210 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   278 by(forward_tac [wt_jvm_progD] 1);
   211 by(forward_tac [wt_jvm_progD] 1);
   345 by (asm_full_simp_tac (simpset() addsimps [approx_val_def, raise_xcpt_def]) 1);
   278 by (asm_full_simp_tac (simpset() addsimps [approx_val_def, raise_xcpt_def]) 1);
   346 bd conf_NullTD 1;
   279 bd conf_NullTD 1;
   347 by (Asm_simp_tac 1);
   280 by (Asm_simp_tac 1);
   348 qed "Invoke_correct";
   281 qed "Invoke_correct";
   349 
   282 
       
   283 
       
   284 Delsimps [map_append];
   350 Goal
   285 Goal
   351 "\\<lbrakk> wt_jvm_prog G phi; \
   286 "\\<lbrakk> wt_jvm_prog G phi; \
   352 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   287 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   353 \  ins!pc = MI mi_com; \
   288 \  ins ! pc = Return; \
   354 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
       
   355 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
       
   356 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
       
   357 by(forward_tac [wt_jvm_prog_impl_wt_instr_cor] 1);
       
   358   ba 1;
       
   359  ba 1;
       
   360 by (case_tac "mi_com" 1);
       
   361 by (ALLGOALS (fast_tac (claset() addIs [Invoke_correct])));
       
   362 qed "MI_correct";
       
   363 
       
   364 (****** MR ******)
       
   365 
       
   366 Delsimps [map_append];
       
   367 Goal
       
   368 "\\<lbrakk> wt_jvm_prog G phi; \
       
   369 \  method (G,C) sig = Some (C,rT,maxl,ins); \
       
   370 \  ins ! pc = MR Return; \
       
   371 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   289 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   372 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   290 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   373 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   291 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   374 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   292 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   375 by (asm_full_simp_tac (simpset() addsimps (neq_Nil_conv::defs1) addsplits [split_if_asm]) 1);
   293 by (asm_full_simp_tac (simpset() addsimps (neq_Nil_conv::defs1) addsplits [split_if_asm]) 1);
   386  addIs [conf_widen]
   304  addIs [conf_widen]
   387  addss (simpset() addsimps [approx_val_def,append_eq_conv_conj,map_eq_Cons]@defs1)) 1);
   305  addss (simpset() addsimps [approx_val_def,append_eq_conv_conj,map_eq_Cons]@defs1)) 1);
   388 qed "Return_correct";
   306 qed "Return_correct";
   389 Addsimps [map_append];
   307 Addsimps [map_append];
   390 
   308 
   391 Goal
   309 
   392 "\\<lbrakk> wt_jvm_prog G phi; \
   310 Goal 
   393 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   311 "\\<lbrakk> wf_prog wt G; \
   394 \  ins!pc = MR mr; \
   312 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   395 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   313 \  ins ! pc = Goto branch; \
   396 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
       
   397 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
       
   398 by(forward_tac [wt_jvm_prog_impl_wt_instr_cor] 1);
       
   399   ba 1;
       
   400  ba 1;
       
   401 by (case_tac "mr" 1);
       
   402 by (ALLGOALS (fast_tac (claset() addIs [Return_correct])));
       
   403 qed "MR_correct";
       
   404 
       
   405 (****** BR ******)
       
   406 Goal 
       
   407 "\\<lbrakk> wf_prog wt G; \
       
   408 \  method (G,C) sig = Some (C,rT,maxl,ins); \
       
   409 \  ins ! pc = BR(Goto branch); \
       
   410 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   314 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   411 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   315 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   412 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   316 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   413 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   317 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   414 by (fast_tac (claset() addIs [approx_loc_imp_approx_loc_sup,approx_stk_imp_approx_stk_sup]
   318 by (fast_tac (claset() addIs [approx_loc_imp_approx_loc_sup,approx_stk_imp_approx_stk_sup]
   417 
   321 
   418 
   322 
   419 Goal 
   323 Goal 
   420 "\\<lbrakk> wf_prog wt G; \
   324 "\\<lbrakk> wf_prog wt G; \
   421 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   325 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   422 \  ins!pc = BR(Ifcmpeq branch); \
   326 \  ins!pc = Ifcmpeq branch; \
   423 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   327 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   424 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   328 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   425 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   329 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   426 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   330 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   427 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup] addss (simpset() addsimps defs1)) 1);
   331 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup] addss (simpset() addsimps defs1)) 1);
   428 qed "Ifiacmpeq_correct";
   332 qed "Ifiacmpeq_correct";
   429 
   333 
   430 
   334 
   431 Goal
   335 Goal 
   432 "\\<lbrakk> wt_jvm_prog G phi; \
   336 "\\<lbrakk> wf_prog wt G; \
   433 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   337 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   434 \  ins!pc = BR br_com; \
   338 \  ins ! pc = Pop; \
   435 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
       
   436 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
       
   437 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
       
   438 by(forward_tac [wt_jvm_prog_impl_wt_instr_cor] 1);
       
   439   ba 1;
       
   440  ba 1;
       
   441 by(rewtac wt_jvm_prog_def);
       
   442 by (case_tac "br_com" 1);
       
   443 by (ALLGOALS (fast_tac (claset() addIs [Goto_correct,Ifiacmpeq_correct])));
       
   444 qed "BR_correct";
       
   445 
       
   446 
       
   447 (****** OS ******)
       
   448 
       
   449 Goal 
       
   450 "\\<lbrakk> wf_prog wt G; \
       
   451 \  method (G,C) sig = Some (C,rT,maxl,ins); \
       
   452 \  ins ! pc = OS Pop; \
       
   453 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   339 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   454 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   340 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   455 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   341 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   456 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   342 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   457 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup] addss (simpset() addsimps defs1)) 1);
   343 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_loc_imp_approx_loc_sup] addss (simpset() addsimps defs1)) 1);
   459 
   345 
   460 
   346 
   461 Goal 
   347 Goal 
   462 "\\<lbrakk> wf_prog wt G; \
   348 "\\<lbrakk> wf_prog wt G; \
   463 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   349 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   464 \  ins ! pc = OS Dup; \
   350 \  ins ! pc = Dup; \
   465 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   351 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   466 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   352 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   467 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   353 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   468 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   354 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   469 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup] 
   355 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup] 
   472 
   358 
   473 
   359 
   474 Goal 
   360 Goal 
   475 "\\<lbrakk> wf_prog wt G; \
   361 "\\<lbrakk> wf_prog wt G; \
   476 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   362 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   477 \  ins ! pc = OS Dup_x1; \
   363 \  ins ! pc = Dup_x1; \
   478 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   364 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   479 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   365 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   480 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   366 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   481 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   367 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   482 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup] 
   368 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup] 
   484 qed "Dup_x1_correct";
   370 qed "Dup_x1_correct";
   485 
   371 
   486 Goal 
   372 Goal 
   487 "\\<lbrakk> wf_prog wt G; \
   373 "\\<lbrakk> wf_prog wt G; \
   488 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   374 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   489 \  ins ! pc = OS Dup_x2; \
   375 \  ins ! pc = Dup_x2; \
   490 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   376 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   491 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   377 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   492 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   378 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   493 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   379 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   494 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup] 
   380 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup] 
   496 qed "Dup_x2_correct";
   382 qed "Dup_x2_correct";
   497 
   383 
   498 Goal 
   384 Goal 
   499 "\\<lbrakk> wf_prog wt G; \
   385 "\\<lbrakk> wf_prog wt G; \
   500 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   386 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   501 \  ins ! pc = OS Swap; \
   387 \  ins ! pc = Swap; \
   502 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   388 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   503 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   389 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   504 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   390 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   505 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   391 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   506 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup] 
   392 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup] 
   509 
   395 
   510 
   396 
   511 Goal 
   397 Goal 
   512 "\\<lbrakk> wf_prog wt G; \
   398 "\\<lbrakk> wf_prog wt G; \
   513 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   399 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   514 \  ins ! pc = OS IAdd; \
   400 \  ins ! pc = IAdd; \
   515 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   401 \  wt_instr (ins!pc) G rT (phi C sig) (length ins) pc; \
   516 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   402 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   517 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   403 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   518 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   404 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   519 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup]
   405 by (fast_tac (claset() addIs [approx_stk_imp_approx_stk_sup,approx_val_imp_approx_val_sup,approx_loc_imp_approx_loc_sup]
   520   addss (simpset() addsimps [map_eq_Cons, approx_val_def]@defs1)) 1);
   406   addss (simpset() addsimps [map_eq_Cons, approx_val_def]@defs1)) 1);
   521 qed "IAdd_correct";
   407 qed "IAdd_correct";
   522 
   408 
   523 
   409 
       
   410 (** instr correct **)
       
   411 
   524 Goal
   412 Goal
   525 "\\<lbrakk> wt_jvm_prog G phi; \
   413 "\\<lbrakk> wt_jvm_prog G phi; \
   526 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   414 \  method (G,C) sig = Some (C,rT,maxl,ins); \
   527 \  ins!pc = OS os_com; \
       
   528 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   415 \  Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; \
   529 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   416 \  G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \\<rbrakk> \
   530 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   417 \\\<Longrightarrow> G,phi \\<turnstile>JVM state'\\<surd>";
   531 by(forward_tac [wt_jvm_prog_impl_wt_instr_cor] 1);
   418 by(forward_tac [wt_jvm_prog_impl_wt_instr_cor] 1);
   532   ba 1;
   419   ba 1;
   533  ba 1;
   420  ba 1;
       
   421 by(case_tac "ins!pc" 1);
       
   422 by(fast_tac (claset() addIs [Invoke_correct]) 9);
       
   423 by(fast_tac (claset() addIs [Return_correct]) 9);
   534 by(rewtac wt_jvm_prog_def);
   424 by(rewtac wt_jvm_prog_def);
   535 by (case_tac "os_com" 1);
   425 by (ALLGOALS (fast_tac (claset() addIs 
   536 by (ALLGOALS (fast_tac (claset() addIs [Pop_correct,Dup_correct,Dup_x1_correct,Dup_x2_correct,Swap_correct,IAdd_correct])));
   426       [Load_correct,Store_correct,Bipush_correct,Aconst_null_correct,
   537 qed "OS_correct";
   427        Checkcast_correct,Getfield_correct,Putfield_correct,New_correct,
       
   428        Goto_correct,Ifiacmpeq_correct,Pop_correct,Dup_correct,
       
   429        Dup_x1_correct,Dup_x2_correct,Swap_correct,IAdd_correct])));
       
   430 qed "instr_correct";
       
   431 
   538 
   432 
   539 (** Main **)
   433 (** Main **)
   540 
   434 
   541 Goalw [correct_state_def,Let_def]
   435 Goalw [correct_state_def,Let_def]
   542  "G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \
   436  "G,phi \\<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\\<surd> \
   554  by (case_tac "frs" 1);
   448  by (case_tac "frs" 1);
   555   by (asm_full_simp_tac (simpset() addsimps exec.simps) 1);
   449   by (asm_full_simp_tac (simpset() addsimps exec.simps) 1);
   556  by(split_all_tac 1);
   450  by(split_all_tac 1);
   557  by(hyp_subst_tac 1);
   451  by(hyp_subst_tac 1);
   558  by(forward_tac [correct_state_impl_Some_method] 1);
   452  by(forward_tac [correct_state_impl_Some_method] 1);
   559  by (force_tac (claset() addIs [LS_correct,CO_correct,MO_correct,CH_correct,MI_correct,MR_correct,OS_correct,
   453  by (force_tac (claset() addIs [instr_correct], simpset() addsplits [split_if_asm] addsimps exec.simps@[split_def]) 1);
   560 	BR_correct], simpset() addsplits [split_if_asm,instr.split,instr.split_asm] addsimps exec.simps@[split_def]) 1);
       
   561 by (case_tac "frs" 1);
   454 by (case_tac "frs" 1);
   562  by (ALLGOALS(asm_full_simp_tac (simpset() addsimps exec.simps)));
   455  by (ALLGOALS(asm_full_simp_tac (simpset() addsimps exec.simps)));
   563 qed_spec_mp "BV_correct_1";
   456 qed_spec_mp "BV_correct_1";
   564 
   457 
   565 (*******)
   458 (*******)
   566 Goal
   459 Goal
   567 "\\<lbrakk> xp=None; frs\\<noteq>[] \\<rbrakk> \\<Longrightarrow> (\\<exists>state'. exec (G,xp,hp,frs) = Some state')";
   460 "\\<lbrakk> xp=None; frs\\<noteq>[] \\<rbrakk> \\<Longrightarrow> (\\<exists>state'. exec (G,xp,hp,frs) = Some state')";
   568 by (fast_tac (claset() addIs [BV_correct_1] 
   461 by (auto_tac (claset() addIs [BV_correct_1],
   569 	addss (simpset() addsplits [instr.split] addsimps [neq_Nil_conv]@defs1)) 1);
   462              (simpset() addsplits [instr.split] addsimps [neq_Nil_conv]@defs1)));
       
   463 by (case_tac "(snd (snd (snd (the (method (G, ab) (ac, b)))))) ! ba" 1);
       
   464 by (ALLGOALS (asm_simp_tac (simpset() addsimps defs1)));
   570 val lemma = result();
   465 val lemma = result();
   571 
   466 
   572 Goal
   467 Goal
   573 "\\<lbrakk> wt_jvm_prog G phi; G,phi \\<turnstile>JVM (xp,hp,frs)\\<surd>; xp=None; frs\\<noteq>[] \\<rbrakk> \
   468 "\\<lbrakk> wt_jvm_prog G phi; G,phi \\<turnstile>JVM (xp,hp,frs)\\<surd>; xp=None; frs\\<noteq>[] \\<rbrakk> \
   574 \ \\<Longrightarrow> \\<exists>state'. exec(G,xp,hp,frs) = Some state' \\<and> G,phi \\<turnstile>JVM state'\\<surd>";
   469 \ \\<Longrightarrow> \\<exists>state'. exec(G,xp,hp,frs) = Some state' \\<and> G,phi \\<turnstile>JVM state'\\<surd>";