| author | haftmann | 
| Tue, 05 Jan 2010 11:38:51 +0100 | |
| changeset 34271 | 70af06abb13d | 
| parent 33954 | 1bc3b688548c | 
| child 35355 | 613e133966ea | 
| child 35416 | d8d7d1b785af | 
| permissions | -rwxr-xr-x | 
| 8011 | 1 | (* Title: HOL/MicroJava/BV/Correct.thy | 
| 12516 | 2 | Author: Cornelia Pusch, Gerwin Klein | 
| 8011 | 3 | Copyright 1999 Technische Universitaet Muenchen | 
| 4 | *) | |
| 5 | ||
| 12911 | 6 | header {* \isaheader{BV Type Safety Invariant} *}
 | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 7 | |
| 33954 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 haftmann parents: 
26438diff
changeset | 8 | theory Correct | 
| 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 haftmann parents: 
26438diff
changeset | 9 | imports BVSpec "../JVM/JVMExec" | 
| 
1bc3b688548c
backported parts of abstract byte code verifier from AFP/Jinja
 haftmann parents: 
26438diff
changeset | 10 | begin | 
| 8011 | 11 | |
| 12 | constdefs | |
| 13006 | 13 | approx_val :: "[jvm_prog,aheap,val,ty err] \<Rightarrow> bool" | 
| 14 | "approx_val G h v any == case any of Err \<Rightarrow> True | OK T \<Rightarrow> G,h\<turnstile>v::\<preceq>T" | |
| 8011 | 15 | |
| 13006 | 16 | approx_loc :: "[jvm_prog,aheap,val list,locvars_type] \<Rightarrow> bool" | 
| 10056 | 17 | "approx_loc G hp loc LT == list_all2 (approx_val G hp) loc LT" | 
| 18 | ||
| 13006 | 19 | approx_stk :: "[jvm_prog,aheap,opstack,opstack_type] \<Rightarrow> bool" | 
| 10496 | 20 | "approx_stk G hp stk ST == approx_loc G hp stk (map OK ST)" | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 21 | |
| 13006 | 22 | correct_frame :: "[jvm_prog,aheap,state_type,nat,bytecode] \<Rightarrow> frame \<Rightarrow> bool" | 
| 10056 | 23 | "correct_frame G hp == \<lambda>(ST,LT) maxl ins (stk,loc,C,sig,pc). | 
| 24 | approx_stk G hp stk ST \<and> approx_loc G hp loc LT \<and> | |
| 25 | pc < length ins \<and> length loc=length(snd sig)+maxl+1" | |
| 8011 | 26 | |
| 27 | ||
| 28 | consts | |
| 13006 | 29 | correct_frames :: "[jvm_prog,aheap,prog_type,ty,sig,frame list] \<Rightarrow> bool" | 
| 8011 | 30 | primrec | 
| 8045 
816f566c414f
Fixed a problem with returning from the last frame.
 nipkow parents: 
8034diff
changeset | 31 | "correct_frames G hp phi rT0 sig0 [] = True" | 
| 8011 | 32 | |
| 8045 
816f566c414f
Fixed a problem with returning from the last frame.
 nipkow parents: 
8034diff
changeset | 33 | "correct_frames G hp phi rT0 sig0 (f#frs) = | 
| 11252 | 34 | (let (stk,loc,C,sig,pc) = f in | 
| 12516 | 35 | (\<exists>ST LT rT maxs maxl ins et. | 
| 10625 
022c6b2bcd6b
strengthened invariant: current class must be defined
 kleing parents: 
10612diff
changeset | 36 | phi C sig ! pc = Some (ST,LT) \<and> is_class G C \<and> | 
| 12516 | 37 | method (G,C) sig = Some(C,rT,(maxs,maxl,ins,et)) \<and> | 
| 38 | (\<exists>C' mn pTs. ins!pc = (Invoke C' mn pTs) \<and> | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 39 | (mn,pTs) = sig0 \<and> | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 40 | (\<exists>apTs D ST' LT'. | 
| 12516 | 41 | (phi C sig)!pc = Some ((rev apTs) @ (Class D) # ST', LT') \<and> | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 42 | length apTs = length pTs \<and> | 
| 12516 | 43 | (\<exists>D' rT' maxs' maxl' ins' et'. | 
| 44 | method (G,D) sig0 = Some(D',rT',(maxs',maxl',ins',et')) \<and> | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 45 | G \<turnstile> rT0 \<preceq> rT') \<and> | 
| 12516 | 46 | correct_frame G hp (ST, LT) maxl ins f \<and> | 
| 47 | correct_frames G hp phi rT sig frs))))" | |
| 8011 | 48 | |
| 49 | ||
| 50 | constdefs | |
| 13006 | 51 | correct_state :: "[jvm_prog,prog_type,jvm_state] \<Rightarrow> bool" | 
| 11372 | 52 |                   ("_,_ |-JVM _ [ok]"  [51,51] 50)
 | 
| 10042 | 53 | "correct_state G phi == \<lambda>(xp,hp,frs). | 
| 8011 | 54 | case xp of | 
| 13006 | 55 | None \<Rightarrow> (case frs of | 
| 56 | [] \<Rightarrow> True | |
| 57 | | (f#fs) \<Rightarrow> G\<turnstile>h hp\<surd> \<and> preallocated hp \<and> | |
| 12516 | 58 | (let (stk,loc,C,sig,pc) = f | 
| 59 | in | |
| 60 | \<exists>rT maxs maxl ins et s. | |
| 10625 
022c6b2bcd6b
strengthened invariant: current class must be defined
 kleing parents: 
10612diff
changeset | 61 | is_class G C \<and> | 
| 12516 | 62 | method (G,C) sig = Some(C,rT,(maxs,maxl,ins,et)) \<and> | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 63 | phi C sig ! pc = Some s \<and> | 
| 12516 | 64 | correct_frame G hp s maxl ins f \<and> | 
| 65 | correct_frames G hp phi rT sig fs)) | |
| 13006 | 66 | | Some x \<Rightarrow> frs = []" | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 67 | |
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 68 | |
| 11372 | 69 | syntax (xsymbols) | 
| 13006 | 70 | correct_state :: "[jvm_prog,prog_type,jvm_state] \<Rightarrow> bool" | 
| 11372 | 71 |                   ("_,_ \<turnstile>JVM _ \<surd>"  [51,51] 50)
 | 
| 10060 | 72 | |
| 11252 | 73 | |
| 74 | lemma sup_ty_opt_OK: | |
| 75 | "(G \<turnstile> X <=o (OK T')) = (\<exists>T. X = OK T \<and> G \<turnstile> T \<preceq> T')" | |
| 76 | apply (cases X) | |
| 77 | apply auto | |
| 78 | done | |
| 79 | ||
| 80 | ||
| 11085 | 81 | section {* approx-val *}
 | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 82 | |
| 11252 | 83 | lemma approx_val_Err [simp,intro!]: | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 84 | "approx_val G hp x Err" | 
| 11252 | 85 | by (simp add: approx_val_def) | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 86 | |
| 11252 | 87 | lemma approx_val_OK [iff]: | 
| 88 | "approx_val G hp x (OK T) = (G,hp \<turnstile> x ::\<preceq> T)" | |
| 89 | by (simp add: approx_val_def) | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 90 | |
| 11252 | 91 | lemma approx_val_Null [simp,intro!]: | 
| 92 | "approx_val G hp Null (OK (RefT x))" | |
| 93 | by (auto simp add: approx_val_def) | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 94 | |
| 11252 | 95 | lemma approx_val_sup_heap: | 
| 96 | "\<lbrakk> approx_val G hp v T; hp \<le>| hp' \<rbrakk> \<Longrightarrow> approx_val G hp' v T" | |
| 97 | by (cases T) (blast intro: conf_hext)+ | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 98 | |
| 11252 | 99 | lemma approx_val_heap_update: | 
| 13006 | 100 | "\<lbrakk> hp a = Some obj'; G,hp\<turnstile> v::\<preceq>T; obj_ty obj = obj_ty obj'\<rbrakk> | 
| 101 | \<Longrightarrow> G,hp(a\<mapsto>obj)\<turnstile> v::\<preceq>T" | |
| 11252 | 102 | by (cases v, auto simp add: obj_ty_def conf_def) | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 103 | |
| 11252 | 104 | lemma approx_val_widen: | 
| 105 | "\<lbrakk> approx_val G hp v T; G \<turnstile> T <=o T'; wf_prog wt G \<rbrakk> | |
| 106 | \<Longrightarrow> approx_val G hp v T'" | |
| 107 | by (cases T', auto simp add: sup_ty_opt_OK intro: conf_widen) | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 108 | |
| 11085 | 109 | section {* approx-loc *}
 | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 110 | |
| 11252 | 111 | lemma approx_loc_Nil [simp,intro!]: | 
| 112 | "approx_loc G hp [] []" | |
| 113 | by (simp add: approx_loc_def) | |
| 114 | ||
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 115 | lemma approx_loc_Cons [iff]: | 
| 11252 | 116 | "approx_loc G hp (l#ls) (L#LT) = | 
| 117 | (approx_val G hp l L \<and> approx_loc G hp ls LT)" | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 118 | by (simp add: approx_loc_def) | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 119 | |
| 11252 | 120 | lemma approx_loc_nth: | 
| 121 | "\<lbrakk> approx_loc G hp loc LT; n < length LT \<rbrakk> | |
| 122 | \<Longrightarrow> approx_val G hp (loc!n) (LT!n)" | |
| 123 | by (simp add: approx_loc_def list_all2_conv_all_nth) | |
| 124 | ||
| 125 | lemma approx_loc_imp_approx_val_sup: | |
| 126 | "\<lbrakk>approx_loc G hp loc LT; n < length LT; LT ! n = OK T; G \<turnstile> T \<preceq> T'; wf_prog wt G\<rbrakk> | |
| 127 | \<Longrightarrow> G,hp \<turnstile> (loc!n) ::\<preceq> T'" | |
| 128 | apply (drule approx_loc_nth, assumption) | |
| 129 | apply simp | |
| 130 | apply (erule conf_widen, assumption+) | |
| 131 | done | |
| 132 | ||
| 133 | lemma approx_loc_conv_all_nth: | |
| 134 | "approx_loc G hp loc LT = | |
| 135 | (length loc = length LT \<and> (\<forall>n < length loc. approx_val G hp (loc!n) (LT!n)))" | |
| 136 | by (simp add: approx_loc_def list_all2_conv_all_nth) | |
| 137 | ||
| 138 | lemma approx_loc_sup_heap: | |
| 139 | "\<lbrakk> approx_loc G hp loc LT; hp \<le>| hp' \<rbrakk> | |
| 140 | \<Longrightarrow> approx_loc G hp' loc LT" | |
| 141 | apply (clarsimp simp add: approx_loc_conv_all_nth) | |
| 142 | apply (blast intro: approx_val_sup_heap) | |
| 143 | done | |
| 144 | ||
| 145 | lemma approx_loc_widen: | |
| 146 | "\<lbrakk> approx_loc G hp loc LT; G \<turnstile> LT <=l LT'; wf_prog wt G \<rbrakk> | |
| 147 | \<Longrightarrow> approx_loc G hp loc LT'" | |
| 148 | apply (unfold Listn.le_def lesub_def sup_loc_def) | |
| 149 | apply (simp (no_asm_use) only: list_all2_conv_all_nth approx_loc_conv_all_nth) | |
| 150 | apply (simp (no_asm_simp)) | |
| 151 | apply clarify | |
| 152 | apply (erule allE, erule impE) | |
| 153 | apply simp | |
| 154 | apply (erule approx_val_widen) | |
| 155 | apply simp | |
| 156 | apply assumption | |
| 10056 | 157 | done | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 158 | |
| 13052 | 159 | lemma loc_widen_Err [dest]: | 
| 160 | "\<And>XT. G \<turnstile> replicate n Err <=l XT \<Longrightarrow> XT = replicate n Err" | |
| 161 | by (induct n) auto | |
| 162 | ||
| 163 | lemma approx_loc_Err [iff]: | |
| 164 | "approx_loc G hp (replicate n v) (replicate n Err)" | |
| 165 | by (induct n) auto | |
| 166 | ||
| 11252 | 167 | lemma approx_loc_subst: | 
| 168 | "\<lbrakk> approx_loc G hp loc LT; approx_val G hp x X \<rbrakk> | |
| 169 | \<Longrightarrow> approx_loc G hp (loc[idx:=x]) (LT[idx:=X])" | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 170 | apply (unfold approx_loc_def list_all2_def) | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 171 | apply (auto dest: subsetD [OF set_update_subset_insert] simp add: zip_update) | 
| 10056 | 172 | done | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 173 | |
| 11252 | 174 | lemma approx_loc_append: | 
| 175 | "length l1=length L1 \<Longrightarrow> | |
| 10056 | 176 | approx_loc G hp (l1@l2) (L1@L2) = | 
| 177 | (approx_loc G hp l1 L1 \<and> approx_loc G hp l2 L2)" | |
| 11252 | 178 | apply (unfold approx_loc_def list_all2_def) | 
| 179 | apply (simp cong: conj_cong) | |
| 180 | apply blast | |
| 181 | done | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 182 | |
| 11085 | 183 | section {* approx-stk *}
 | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 184 | |
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 185 | lemma approx_stk_rev_lem: | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 186 | "approx_stk G hp (rev s) (rev t) = approx_stk G hp s t" | 
| 11252 | 187 | apply (unfold approx_stk_def approx_loc_def) | 
| 188 | apply (simp add: rev_map [THEN sym]) | |
| 189 | done | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 190 | |
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 191 | lemma approx_stk_rev: | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 192 | "approx_stk G hp (rev s) t = approx_stk G hp s (rev t)" | 
| 11252 | 193 | by (auto intro: subst [OF approx_stk_rev_lem]) | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 194 | |
| 11252 | 195 | lemma approx_stk_sup_heap: | 
| 196 | "\<lbrakk> approx_stk G hp stk ST; hp \<le>| hp' \<rbrakk> \<Longrightarrow> approx_stk G hp' stk ST" | |
| 197 | by (auto intro: approx_loc_sup_heap simp add: approx_stk_def) | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 198 | |
| 11252 | 199 | lemma approx_stk_widen: | 
| 200 | "\<lbrakk> approx_stk G hp stk ST; G \<turnstile> map OK ST <=l map OK ST'; wf_prog wt G \<rbrakk> | |
| 201 | \<Longrightarrow> approx_stk G hp stk ST'" | |
| 202 | by (auto elim: approx_loc_widen simp add: approx_stk_def) | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 203 | |
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 204 | lemma approx_stk_Nil [iff]: | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 205 | "approx_stk G hp [] []" | 
| 11252 | 206 | by (simp add: approx_stk_def) | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 207 | |
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 208 | lemma approx_stk_Cons [iff]: | 
| 11252 | 209 | "approx_stk G hp (x#stk) (S#ST) = | 
| 210 | (approx_val G hp x (OK S) \<and> approx_stk G hp stk ST)" | |
| 211 | by (simp add: approx_stk_def) | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 212 | |
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 213 | lemma approx_stk_Cons_lemma [iff]: | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 214 | "approx_stk G hp stk (S#ST') = | 
| 10496 | 215 | (\<exists>s stk'. stk = s#stk' \<and> approx_val G hp s (OK S) \<and> approx_stk G hp stk' ST')" | 
| 11252 | 216 | by (simp add: list_all2_Cons2 approx_stk_def approx_loc_def) | 
| 217 | ||
| 218 | lemma approx_stk_append: | |
| 219 | "approx_stk G hp stk (S@S') \<Longrightarrow> | |
| 220 | (\<exists>s stk'. stk = s@stk' \<and> length s = length S \<and> length stk' = length S' \<and> | |
| 221 | approx_stk G hp s S \<and> approx_stk G hp stk' S')" | |
| 222 | by (simp add: list_all2_append2 approx_stk_def approx_loc_def) | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 223 | |
| 11252 | 224 | lemma approx_stk_all_widen: | 
| 22271 | 225 | "\<lbrakk> approx_stk G hp stk ST; \<forall>(x, y) \<in> set (zip ST ST'). G \<turnstile> x \<preceq> y; length ST = length ST'; wf_prog wt G \<rbrakk> | 
| 11252 | 226 | \<Longrightarrow> approx_stk G hp stk ST'" | 
| 227 | apply (unfold approx_stk_def) | |
| 228 | apply (clarsimp simp add: approx_loc_conv_all_nth all_set_conv_all_nth) | |
| 229 | apply (erule allE, erule impE, assumption) | |
| 230 | apply (erule allE, erule impE, assumption) | |
| 231 | apply (erule conf_widen, assumption+) | |
| 232 | done | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 233 | |
| 11085 | 234 | section {* oconf *}
 | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 235 | |
| 11252 | 236 | lemma oconf_field_update: | 
| 13006 | 237 | "\<lbrakk>map_of (fields (G, oT)) FD = Some T; G,hp\<turnstile>v::\<preceq>T; G,hp\<turnstile>(oT,fs)\<surd> \<rbrakk> | 
| 238 | \<Longrightarrow> G,hp\<turnstile>(oT, fs(FD\<mapsto>v))\<surd>" | |
| 11252 | 239 | by (simp add: oconf_def lconf_def) | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 240 | |
| 11252 | 241 | lemma oconf_newref: | 
| 242 | "\<lbrakk>hp oref = None; G,hp \<turnstile> obj \<surd>; G,hp \<turnstile> obj' \<surd>\<rbrakk> \<Longrightarrow> G,hp(oref\<mapsto>obj') \<turnstile> obj \<surd>" | |
| 243 | apply (unfold oconf_def lconf_def) | |
| 244 | apply simp | |
| 245 | apply (blast intro: conf_hext hext_new) | |
| 246 | done | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 247 | |
| 11252 | 248 | lemma oconf_heap_update: | 
| 249 | "\<lbrakk> hp a = Some obj'; obj_ty obj' = obj_ty obj''; G,hp\<turnstile>obj\<surd> \<rbrakk> | |
| 250 | \<Longrightarrow> G,hp(a\<mapsto>obj'')\<turnstile>obj\<surd>" | |
| 251 | apply (unfold oconf_def lconf_def) | |
| 252 | apply (fastsimp intro: approx_val_heap_update) | |
| 253 | done | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 254 | |
| 11085 | 255 | section {* hconf *}
 | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 256 | |
| 11252 | 257 | lemma hconf_newref: | 
| 258 | "\<lbrakk> hp oref = None; G\<turnstile>h hp\<surd>; G,hp\<turnstile>obj\<surd> \<rbrakk> \<Longrightarrow> G\<turnstile>h hp(oref\<mapsto>obj)\<surd>" | |
| 259 | apply (simp add: hconf_def) | |
| 260 | apply (fast intro: oconf_newref) | |
| 261 | done | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 262 | |
| 11252 | 263 | lemma hconf_field_update: | 
| 264 | "\<lbrakk> map_of (fields (G, oT)) X = Some T; hp a = Some(oT,fs); | |
| 265 | G,hp\<turnstile>v::\<preceq>T; G\<turnstile>h hp\<surd> \<rbrakk> | |
| 266 | \<Longrightarrow> G\<turnstile>h hp(a \<mapsto> (oT, fs(X\<mapsto>v)))\<surd>" | |
| 267 | apply (simp add: hconf_def) | |
| 268 | apply (fastsimp intro: oconf_heap_update oconf_field_update | |
| 269 | simp add: obj_ty_def) | |
| 270 | done | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 271 | |
| 12545 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 272 | section {* preallocated *}
 | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 273 | |
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 274 | lemma preallocated_field_update: | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 275 | "\<lbrakk> map_of (fields (G, oT)) X = Some T; hp a = Some(oT,fs); | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 276 | G\<turnstile>h hp\<surd>; preallocated hp \<rbrakk> | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 277 | \<Longrightarrow> preallocated (hp(a \<mapsto> (oT, fs(X\<mapsto>v))))" | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 278 | apply (unfold preallocated_def) | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 279 | apply (rule allI) | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 280 | apply (erule_tac x=x in allE) | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 281 | apply simp | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 282 | apply (rule ccontr) | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 283 | apply (unfold hconf_def) | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 284 | apply (erule allE, erule allE, erule impE, assumption) | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 285 | apply (unfold oconf_def lconf_def) | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 286 | apply (simp del: split_paired_All) | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 287 | done | 
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 288 | |
| 
7319d384d0d3
removed preallocated heaps axiom (now in type safety invariant)
 kleing parents: 
12516diff
changeset | 289 | |
| 13052 | 290 | lemma | 
| 291 | assumes none: "hp oref = None" and alloc: "preallocated hp" | |
| 292 | shows preallocated_newref: "preallocated (hp(oref\<mapsto>obj))" | |
| 293 | proof (cases oref) | |
| 294 | case (XcptRef x) | |
| 295 | with none alloc have "False" by (auto elim: preallocatedE [of _ x]) | |
| 296 | thus ?thesis .. | |
| 297 | next | |
| 298 | case (Loc l) | |
| 299 | with alloc show ?thesis by (simp add: preallocated_def) | |
| 300 | qed | |
| 301 | ||
| 11085 | 302 | section {* correct-frames *}
 | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 303 | |
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 304 | lemmas [simp del] = fun_upd_apply | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 305 | |
| 11252 | 306 | lemma correct_frames_field_update [rule_format]: | 
| 307 | "\<forall>rT C sig. | |
| 13006 | 308 | correct_frames G hp phi rT sig frs \<longrightarrow> | 
| 309 | hp a = Some (C,fs) \<longrightarrow> | |
| 310 | map_of (fields (G, C)) fl = Some fd \<longrightarrow> | |
| 10042 | 311 | G,hp\<turnstile>v::\<preceq>fd | 
| 13006 | 312 | \<longrightarrow> correct_frames G (hp(a \<mapsto> (C, fs(fl\<mapsto>v)))) phi rT sig frs"; | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 313 | apply (induct frs) | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 314 | apply simp | 
| 10920 | 315 | apply clarify | 
| 11252 | 316 | apply (simp (no_asm_use)) | 
| 10920 | 317 | apply clarify | 
| 318 | apply (unfold correct_frame_def) | |
| 319 | apply (simp (no_asm_use)) | |
| 11252 | 320 | apply clarify | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 321 | apply (intro exI conjI) | 
| 11252 | 322 | apply assumption+ | 
| 323 | apply (erule approx_stk_sup_heap) | |
| 324 | apply (erule hext_upd_obj) | |
| 325 | apply (erule approx_loc_sup_heap) | |
| 326 | apply (erule hext_upd_obj) | |
| 327 | apply assumption+ | |
| 328 | apply blast | |
| 10056 | 329 | done | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 330 | |
| 11252 | 331 | lemma correct_frames_newref [rule_format]: | 
| 332 | "\<forall>rT C sig. | |
| 333 | hp x = None \<longrightarrow> | |
| 334 | correct_frames G hp phi rT sig frs \<longrightarrow> | |
| 13681 | 335 | correct_frames G (hp(x \<mapsto> obj)) phi rT sig frs" | 
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 336 | apply (induct frs) | 
| 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 337 | apply simp | 
| 11252 | 338 | apply clarify | 
| 339 | apply (simp (no_asm_use)) | |
| 340 | apply clarify | |
| 341 | apply (unfold correct_frame_def) | |
| 342 | apply (simp (no_asm_use)) | |
| 343 | apply clarify | |
| 9757 
1024a2d80ac0
functional LBV style, dead code, type safety -> Isar
 kleing parents: 
9549diff
changeset | 344 | apply (intro exI conjI) | 
| 11252 | 345 | apply assumption+ | 
| 346 | apply (erule approx_stk_sup_heap) | |
| 347 | apply (erule hext_new) | |
| 348 | apply (erule approx_loc_sup_heap) | |
| 349 | apply (erule hext_new) | |
| 350 | apply assumption+ | |
| 351 | apply blast | |
| 10056 | 352 | done | 
| 8011 | 353 | |
| 354 | end |