17 *} |
17 *} |
18 |
18 |
19 type_synonym env' = "prog \<times> (lname, ty) table" (* same as env of WellType.thy *) |
19 type_synonym env' = "prog \<times> (lname, ty) table" (* same as env of WellType.thy *) |
20 |
20 |
21 |
21 |
22 section "extension of global store" |
22 subsubsection "extension of global store" |
23 |
23 |
24 |
24 |
25 definition gext :: "st \<Rightarrow> st \<Rightarrow> bool" ("_\<le>|_" [71,71] 70) where |
25 definition gext :: "st \<Rightarrow> st \<Rightarrow> bool" ("_\<le>|_" [71,71] 70) where |
26 "s\<le>|s' \<equiv> \<forall>r. \<forall>obj\<in>globs s r: \<exists>obj'\<in>globs s' r: tag obj'= tag obj" |
26 "s\<le>|s' \<equiv> \<forall>r. \<forall>obj\<in>globs s r: \<exists>obj'\<in>globs s' r: tag obj'= tag obj" |
27 |
27 |
92 apply (unfold inited_def) |
92 apply (unfold inited_def) |
93 apply (auto dest: gext_objD) |
93 apply (auto dest: gext_objD) |
94 done |
94 done |
95 |
95 |
96 |
96 |
97 section "value conformance" |
97 subsubsection "value conformance" |
98 |
98 |
99 definition conf :: "prog \<Rightarrow> st \<Rightarrow> val \<Rightarrow> ty \<Rightarrow> bool" ("_,_\<turnstile>_\<Colon>\<preceq>_" [71,71,71,71] 70) |
99 definition conf :: "prog \<Rightarrow> st \<Rightarrow> val \<Rightarrow> ty \<Rightarrow> bool" ("_,_\<turnstile>_\<Colon>\<preceq>_" [71,71,71,71] 70) |
100 where "G,s\<turnstile>v\<Colon>\<preceq>T = (\<exists>T'\<in>typeof (\<lambda>a. map_option obj_ty (heap s a)) v:G\<turnstile>T'\<preceq>T)" |
100 where "G,s\<turnstile>v\<Colon>\<preceq>T = (\<exists>T'\<in>typeof (\<lambda>a. map_option obj_ty (heap s a)) v:G\<turnstile>T'\<preceq>T)" |
101 |
101 |
102 lemma conf_cong [simp]: "G,set_locals l s\<turnstile>v\<Colon>\<preceq>T = G,s\<turnstile>v\<Colon>\<preceq>T" |
102 lemma conf_cong [simp]: "G,set_locals l s\<turnstile>v\<Colon>\<preceq>T = G,s\<turnstile>v\<Colon>\<preceq>T" |
173 apply (induct_tac "a'") |
173 apply (induct_tac "a'") |
174 apply (auto dest: widen_PrimT) |
174 apply (auto dest: widen_PrimT) |
175 done |
175 done |
176 |
176 |
177 |
177 |
178 section "value list conformance" |
178 subsubsection "value list conformance" |
179 |
179 |
180 definition |
180 definition |
181 lconf :: "prog \<Rightarrow> st \<Rightarrow> ('a, val) table \<Rightarrow> ('a, ty) table \<Rightarrow> bool" ("_,_\<turnstile>_[\<Colon>\<preceq>]_" [71,71,71,71] 70) |
181 lconf :: "prog \<Rightarrow> st \<Rightarrow> ('a, val) table \<Rightarrow> ('a, ty) table \<Rightarrow> bool" ("_,_\<turnstile>_[\<Colon>\<preceq>]_" [71,71,71,71] 70) |
182 where "G,s\<turnstile>vs[\<Colon>\<preceq>]Ts = (\<forall>n. \<forall>T\<in>Ts n: \<exists>v\<in>vs n: G,s\<turnstile>v\<Colon>\<preceq>T)" |
182 where "G,s\<turnstile>vs[\<Colon>\<preceq>]Ts = (\<forall>n. \<forall>T\<in>Ts n: \<exists>v\<in>vs n: G,s\<turnstile>v\<Colon>\<preceq>T)" |
183 |
183 |
246 " \<forall>n. \<forall>T\<in>fs n:is_type G T \<Longrightarrow> G,s\<turnstile>init_vals fs[\<Colon>\<preceq>]fs" |
246 " \<forall>n. \<forall>T\<in>fs n:is_type G T \<Longrightarrow> G,s\<turnstile>init_vals fs[\<Colon>\<preceq>]fs" |
247 apply (unfold lconf_def) |
247 apply (unfold lconf_def) |
248 apply force |
248 apply force |
249 done |
249 done |
250 |
250 |
251 section "weak value list conformance" |
251 subsubsection "weak value list conformance" |
252 |
252 |
253 text {* Only if the value is defined it has to conform to its type. |
253 text {* Only if the value is defined it has to conform to its type. |
254 This is the contribution of the definite assignment analysis to |
254 This is the contribution of the definite assignment analysis to |
255 the notion of conformance. The definite assignment analysis ensures |
255 the notion of conformance. The definite assignment analysis ensures |
256 that the program only attempts to access local variables that |
256 that the program only attempts to access local variables that |
336 |
336 |
337 lemma lconf_wlconf: |
337 lemma lconf_wlconf: |
338 "G,s\<turnstile>l[\<Colon>\<preceq>]L \<Longrightarrow> G,s\<turnstile>l[\<sim>\<Colon>\<preceq>]L" |
338 "G,s\<turnstile>l[\<Colon>\<preceq>]L \<Longrightarrow> G,s\<turnstile>l[\<sim>\<Colon>\<preceq>]L" |
339 by (force simp add: lconf_def wlconf_def) |
339 by (force simp add: lconf_def wlconf_def) |
340 |
340 |
341 section "object conformance" |
341 subsubsection "object conformance" |
342 |
342 |
343 definition |
343 definition |
344 oconf :: "prog \<Rightarrow> st \<Rightarrow> obj \<Rightarrow> oref \<Rightarrow> bool" ("_,_\<turnstile>_\<Colon>\<preceq>\<surd>_" [71,71,71,71] 70) where |
344 oconf :: "prog \<Rightarrow> st \<Rightarrow> obj \<Rightarrow> oref \<Rightarrow> bool" ("_,_\<turnstile>_\<Colon>\<preceq>\<surd>_" [71,71,71,71] 70) where |
345 "(G,s\<turnstile>obj\<Colon>\<preceq>\<surd>r) = (G,s\<turnstile>values obj[\<Colon>\<preceq>]var_tys G (tag obj) r \<and> |
345 "(G,s\<turnstile>obj\<Colon>\<preceq>\<surd>r) = (G,s\<turnstile>values obj[\<Colon>\<preceq>]var_tys G (tag obj) r \<and> |
346 (case r of |
346 (case r of |
371 defer |
371 defer |
372 apply (subst obj_ty_cong) |
372 apply (subst obj_ty_cong) |
373 apply (auto dest!: fields_table_SomeD split add: sum.split_asm obj_tag.split_asm) |
373 apply (auto dest!: fields_table_SomeD split add: sum.split_asm obj_tag.split_asm) |
374 done |
374 done |
375 |
375 |
376 section "state conformance" |
376 subsubsection "state conformance" |
377 |
377 |
378 definition |
378 definition |
379 conforms :: "state \<Rightarrow> env' \<Rightarrow> bool" ("_\<Colon>\<preceq>_" [71,71] 70) where |
379 conforms :: "state \<Rightarrow> env' \<Rightarrow> bool" ("_\<Colon>\<preceq>_" [71,71] 70) where |
380 "xs\<Colon>\<preceq>E = |
380 "xs\<Colon>\<preceq>E = |
381 (let (G, L) = E; s = snd xs; l = locals s in |
381 (let (G, L) = E; s = snd xs; l = locals s in |
382 (\<forall>r. \<forall>obj\<in>globs s r: G,s\<turnstile>obj \<Colon>\<preceq>\<surd>r) \<and> G,s\<turnstile>l [\<sim>\<Colon>\<preceq>]L \<and> |
382 (\<forall>r. \<forall>obj\<in>globs s r: G,s\<turnstile>obj \<Colon>\<preceq>\<surd>r) \<and> G,s\<turnstile>l [\<sim>\<Colon>\<preceq>]L \<and> |
383 (\<forall>a. fst xs=Some(Xcpt (Loc a)) \<longrightarrow> G,s\<turnstile>Addr a\<Colon>\<preceq> Class (SXcpt Throwable)) \<and> |
383 (\<forall>a. fst xs=Some(Xcpt (Loc a)) \<longrightarrow> G,s\<turnstile>Addr a\<Colon>\<preceq> Class (SXcpt Throwable)) \<and> |
384 (fst xs=Some(Jump Ret) \<longrightarrow> l Result \<noteq> None))" |
384 (fst xs=Some(Jump Ret) \<longrightarrow> l Result \<noteq> None))" |
385 |
385 |
386 section "conforms" |
386 subsubsection "conforms" |
387 |
387 |
388 lemma conforms_globsD: |
388 lemma conforms_globsD: |
389 "\<lbrakk>(x, s)\<Colon>\<preceq>(G, L); globs s r = Some obj\<rbrakk> \<Longrightarrow> G,s\<turnstile>obj\<Colon>\<preceq>\<surd>r" |
389 "\<lbrakk>(x, s)\<Colon>\<preceq>(G, L); globs s r = Some obj\<rbrakk> \<Longrightarrow> G,s\<turnstile>obj\<Colon>\<preceq>\<surd>r" |
390 by (auto simp: conforms_def Let_def) |
390 by (auto simp: conforms_def Let_def) |
391 |
391 |