10 |
10 |
11 theory Correct = BVSpec: |
11 theory Correct = BVSpec: |
12 |
12 |
13 constdefs |
13 constdefs |
14 approx_val :: "[jvm_prog,aheap,val,ty err] => bool" |
14 approx_val :: "[jvm_prog,aheap,val,ty err] => bool" |
15 "approx_val G h v any == case any of Err => True | Ok T => G,h\<turnstile>v::\<preceq>T" |
15 "approx_val G h v any == case any of Err => True | OK T => G,h\<turnstile>v::\<preceq>T" |
16 |
16 |
17 approx_loc :: "[jvm_prog,aheap,val list,locvars_type] => bool" |
17 approx_loc :: "[jvm_prog,aheap,val list,locvars_type] => bool" |
18 "approx_loc G hp loc LT == list_all2 (approx_val G hp) loc LT" |
18 "approx_loc G hp loc LT == list_all2 (approx_val G hp) loc LT" |
19 |
19 |
20 approx_stk :: "[jvm_prog,aheap,opstack,opstack_type] => bool" |
20 approx_stk :: "[jvm_prog,aheap,opstack,opstack_type] => bool" |
21 "approx_stk G hp stk ST == approx_loc G hp stk (map Ok ST)" |
21 "approx_stk G hp stk ST == approx_loc G hp stk (map OK ST)" |
22 |
22 |
23 correct_frame :: "[jvm_prog,aheap,state_type,nat,bytecode] => frame => bool" |
23 correct_frame :: "[jvm_prog,aheap,state_type,nat,bytecode] => frame => bool" |
24 "correct_frame G hp == \<lambda>(ST,LT) maxl ins (stk,loc,C,sig,pc). |
24 "correct_frame G hp == \<lambda>(ST,LT) maxl ins (stk,loc,C,sig,pc). |
25 approx_stk G hp stk ST \<and> approx_loc G hp loc LT \<and> |
25 approx_stk G hp stk ST \<and> approx_loc G hp loc LT \<and> |
26 pc < length ins \<and> length loc=length(snd sig)+maxl+1" |
26 pc < length ins \<and> length loc=length(snd sig)+maxl+1" |
94 lemma approx_val_Err: |
94 lemma approx_val_Err: |
95 "approx_val G hp x Err" |
95 "approx_val G hp x Err" |
96 by (simp add: approx_val_def) |
96 by (simp add: approx_val_def) |
97 |
97 |
98 lemma approx_val_Null: |
98 lemma approx_val_Null: |
99 "approx_val G hp Null (Ok (RefT x))" |
99 "approx_val G hp Null (OK (RefT x))" |
100 by (auto intro: null simp add: approx_val_def) |
100 by (auto intro: null simp add: approx_val_def) |
101 |
101 |
102 lemma approx_val_imp_approx_val_assConvertible [rule_format]: |
102 lemma approx_val_imp_approx_val_assConvertible [rule_format]: |
103 "wf_prog wt G ==> approx_val G hp v (Ok T) --> G\<turnstile> T\<preceq>T' |
103 "wf_prog wt G ==> approx_val G hp v (OK T) --> G\<turnstile> T\<preceq>T' |
104 --> approx_val G hp v (Ok T')" |
104 --> approx_val G hp v (OK T')" |
105 by (cases T) (auto intro: conf_widen simp add: approx_val_def) |
105 by (cases T) (auto intro: conf_widen simp add: approx_val_def) |
106 |
106 |
107 lemma approx_val_imp_approx_val_sup_heap [rule_format]: |
107 lemma approx_val_imp_approx_val_sup_heap [rule_format]: |
108 "approx_val G hp v at --> hp \<le>| hp' --> approx_val G hp' v at" |
108 "approx_val G hp v at --> hp \<le>| hp' --> approx_val G hp' v at" |
109 apply (simp add: approx_val_def split: err.split) |
109 apply (simp add: approx_val_def split: err.split) |
141 by (simp add: approx_loc_def) |
141 by (simp add: approx_loc_def) |
142 |
142 |
143 lemma assConv_approx_stk_imp_approx_loc [rule_format]: |
143 lemma assConv_approx_stk_imp_approx_loc [rule_format]: |
144 "wf_prog wt G ==> (\<forall>tt'\<in>set (zip tys_n ts). tt' \<in> widen G) |
144 "wf_prog wt G ==> (\<forall>tt'\<in>set (zip tys_n ts). tt' \<in> widen G) |
145 --> length tys_n = length ts --> approx_stk G hp s tys_n --> |
145 --> length tys_n = length ts --> approx_stk G hp s tys_n --> |
146 approx_loc G hp s (map Ok ts)" |
146 approx_loc G hp s (map OK ts)" |
147 apply (unfold approx_stk_def approx_loc_def list_all2_def) |
147 apply (unfold approx_stk_def approx_loc_def list_all2_def) |
148 apply (clarsimp simp add: all_set_conv_all_nth) |
148 apply (clarsimp simp add: all_set_conv_all_nth) |
149 apply (rule approx_val_imp_approx_val_assConvertible) |
149 apply (rule approx_val_imp_approx_val_assConvertible) |
150 apply auto |
150 apply auto |
151 done |
151 done |
210 "\<forall>lvars. approx_stk G hp lvars lt --> hp \<le>| hp' |
210 "\<forall>lvars. approx_stk G hp lvars lt --> hp \<le>| hp' |
211 --> approx_stk G hp' lvars lt" |
211 --> approx_stk G hp' lvars lt" |
212 by (auto intro: approx_loc_imp_approx_loc_sup_heap simp add: approx_stk_def) |
212 by (auto intro: approx_loc_imp_approx_loc_sup_heap simp add: approx_stk_def) |
213 |
213 |
214 lemma approx_stk_imp_approx_stk_sup [rule_format]: |
214 lemma approx_stk_imp_approx_stk_sup [rule_format]: |
215 "wf_prog wt G ==> approx_stk G hp lvars st --> (G \<turnstile> map Ok st <=l (map Ok st')) |
215 "wf_prog wt G ==> approx_stk G hp lvars st --> (G \<turnstile> map OK st <=l (map OK st')) |
216 --> approx_stk G hp lvars st'" |
216 --> approx_stk G hp lvars st'" |
217 by (auto intro: approx_loc_imp_approx_loc_sup simp add: approx_stk_def) |
217 by (auto intro: approx_loc_imp_approx_loc_sup simp add: approx_stk_def) |
218 |
218 |
219 lemma approx_stk_Nil [iff]: |
219 lemma approx_stk_Nil [iff]: |
220 "approx_stk G hp [] []" |
220 "approx_stk G hp [] []" |
221 by (simp add: approx_stk_def approx_loc_def) |
221 by (simp add: approx_stk_def approx_loc_def) |
222 |
222 |
223 lemma approx_stk_Cons [iff]: |
223 lemma approx_stk_Cons [iff]: |
224 "approx_stk G hp (x # stk) (S#ST) = |
224 "approx_stk G hp (x # stk) (S#ST) = |
225 (approx_val G hp x (Ok S) \<and> approx_stk G hp stk ST)" |
225 (approx_val G hp x (OK S) \<and> approx_stk G hp stk ST)" |
226 by (simp add: approx_stk_def approx_loc_def) |
226 by (simp add: approx_stk_def approx_loc_def) |
227 |
227 |
228 lemma approx_stk_Cons_lemma [iff]: |
228 lemma approx_stk_Cons_lemma [iff]: |
229 "approx_stk G hp stk (S#ST') = |
229 "approx_stk G hp stk (S#ST') = |
230 (\<exists>s stk'. stk = s#stk' \<and> approx_val G hp s (Ok S) \<and> approx_stk G hp stk' ST')" |
230 (\<exists>s stk'. stk = s#stk' \<and> approx_val G hp s (OK S) \<and> approx_stk G hp stk' ST')" |
231 by (simp add: list_all2_Cons2 approx_stk_def approx_loc_def) |
231 by (simp add: list_all2_Cons2 approx_stk_def approx_loc_def) |
232 |
232 |
233 lemma approx_stk_append_lemma: |
233 lemma approx_stk_append_lemma: |
234 "approx_stk G hp stk (S@ST') ==> |
234 "approx_stk G hp stk (S@ST') ==> |
235 (\<exists>s stk'. stk = s@stk' \<and> length s = length S \<and> length stk' = length ST' \<and> |
235 (\<exists>s stk'. stk = s@stk' \<and> length s = length S \<and> length stk' = length ST' \<and> |