79 done |
79 done |
80 |
80 |
81 |
81 |
82 (***********************************************************************) |
82 (***********************************************************************) |
83 |
83 |
84 constdefs |
84 definition progression :: "jvm_prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> |
85 progression :: "jvm_prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> |
|
86 aheap \<Rightarrow> opstack \<Rightarrow> locvars \<Rightarrow> |
85 aheap \<Rightarrow> opstack \<Rightarrow> locvars \<Rightarrow> |
87 bytecode \<Rightarrow> |
86 bytecode \<Rightarrow> |
88 aheap \<Rightarrow> opstack \<Rightarrow> locvars \<Rightarrow> |
87 aheap \<Rightarrow> opstack \<Rightarrow> locvars \<Rightarrow> |
89 bool" |
88 bool" |
90 ("{_,_,_} \<turnstile> {_, _, _} >- _ \<rightarrow> {_, _, _}" [61,61,61,61,61,61,90,61,61,61]60) |
89 ("{_,_,_} \<turnstile> {_, _, _} >- _ \<rightarrow> {_, _, _}" [61,61,61,61,61,61,90,61,61,61]60) where |
91 "{G,C,S} \<turnstile> {hp0, os0, lvars0} >- instrs \<rightarrow> {hp1, os1, lvars1} == |
90 "{G,C,S} \<turnstile> {hp0, os0, lvars0} >- instrs \<rightarrow> {hp1, os1, lvars1} == |
92 \<forall> pre post frs. |
91 \<forall> pre post frs. |
93 (gis (gmb G C S) = pre @ instrs @ post) \<longrightarrow> |
92 (gis (gmb G C S) = pre @ instrs @ post) \<longrightarrow> |
94 G \<turnstile> (None,hp0,(os0,lvars0,C,S,length pre)#frs) -jvm\<rightarrow> |
93 G \<turnstile> (None,hp0,(os0,lvars0,C,S,length pre)#frs) -jvm\<rightarrow> |
95 (None,hp1,(os1,lvars1,C,S,(length pre) + (length instrs))#frs)" |
94 (None,hp1,(os1,lvars1,C,S,(length pre) + (length instrs))#frs)" |
159 apply (rule exec_all_one_step) |
158 apply (rule exec_all_one_step) |
160 apply auto |
159 apply auto |
161 done |
160 done |
162 |
161 |
163 (*****) |
162 (*****) |
164 constdefs |
163 definition jump_fwd :: "jvm_prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> |
165 jump_fwd :: "jvm_prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> |
|
166 aheap \<Rightarrow> locvars \<Rightarrow> opstack \<Rightarrow> opstack \<Rightarrow> |
164 aheap \<Rightarrow> locvars \<Rightarrow> opstack \<Rightarrow> opstack \<Rightarrow> |
167 instr \<Rightarrow> bytecode \<Rightarrow> bool" |
165 instr \<Rightarrow> bytecode \<Rightarrow> bool" where |
168 "jump_fwd G C S hp lvars os0 os1 instr instrs == |
166 "jump_fwd G C S hp lvars os0 os1 instr instrs == |
169 \<forall> pre post frs. |
167 \<forall> pre post frs. |
170 (gis (gmb G C S) = pre @ instr # instrs @ post) \<longrightarrow> |
168 (gis (gmb G C S) = pre @ instr # instrs @ post) \<longrightarrow> |
171 exec_all G (None,hp,(os0,lvars,C,S, length pre)#frs) |
169 exec_all G (None,hp,(os0,lvars,C,S, length pre)#frs) |
172 (None,hp,(os1,lvars,C,S,(length pre) + (length instrs) + 1)#frs)" |
170 (None,hp,(os1,lvars,C,S,(length pre) + (length instrs) + 1)#frs)" |
214 apply (rule jump_fwd_one_step) apply assumption+ |
212 apply (rule jump_fwd_one_step) apply assumption+ |
215 done |
213 done |
216 |
214 |
217 |
215 |
218 (* note: instrs and instr reversed wrt. jump_fwd *) |
216 (* note: instrs and instr reversed wrt. jump_fwd *) |
219 constdefs |
217 definition jump_bwd :: "jvm_prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> |
220 jump_bwd :: "jvm_prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> |
|
221 aheap \<Rightarrow> locvars \<Rightarrow> opstack \<Rightarrow> opstack \<Rightarrow> |
218 aheap \<Rightarrow> locvars \<Rightarrow> opstack \<Rightarrow> opstack \<Rightarrow> |
222 bytecode \<Rightarrow> instr \<Rightarrow> bool" |
219 bytecode \<Rightarrow> instr \<Rightarrow> bool" where |
223 "jump_bwd G C S hp lvars os0 os1 instrs instr == |
220 "jump_bwd G C S hp lvars os0 os1 instrs instr == |
224 \<forall> pre post frs. |
221 \<forall> pre post frs. |
225 (gis (gmb G C S) = pre @ instrs @ instr # post) \<longrightarrow> |
222 (gis (gmb G C S) = pre @ instrs @ instr # post) \<longrightarrow> |
226 exec_all G (None,hp,(os0,lvars,C,S, (length pre) + (length instrs))#frs) |
223 exec_all G (None,hp,(os0,lvars,C,S, (length pre) + (length instrs))#frs) |
227 (None,hp,(os1,lvars,C,S, (length pre))#frs)" |
224 (None,hp,(os1,lvars,C,S, (length pre))#frs)" |
256 |
253 |
257 |
254 |
258 (**********************************************************************) |
255 (**********************************************************************) |
259 |
256 |
260 (* class C with signature S is defined in program G *) |
257 (* class C with signature S is defined in program G *) |
261 constdefs class_sig_defined :: "'c prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> bool" |
258 definition class_sig_defined :: "'c prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> bool" where |
262 "class_sig_defined G C S == |
259 "class_sig_defined G C S == |
263 is_class G C \<and> (\<exists> D rT mb. (method (G, C) S = Some (D, rT, mb)))" |
260 is_class G C \<and> (\<exists> D rT mb. (method (G, C) S = Some (D, rT, mb)))" |
264 |
261 |
265 |
262 |
266 (* The environment of a java method body |
263 (* The environment of a java method body |
267 (characterized by class and signature) *) |
264 (characterized by class and signature) *) |
268 constdefs env_of_jmb :: "java_mb prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> java_mb env" |
265 definition env_of_jmb :: "java_mb prog \<Rightarrow> cname \<Rightarrow> sig \<Rightarrow> java_mb env" where |
269 "env_of_jmb G C S == |
266 "env_of_jmb G C S == |
270 (let (mn,pTs) = S; |
267 (let (mn,pTs) = S; |
271 (D,rT,(pns,lvars,blk,res)) = the(method (G, C) S) in |
268 (D,rT,(pns,lvars,blk,res)) = the(method (G, C) S) in |
272 (G,map_of lvars(pns[\<mapsto>]pTs)(This\<mapsto>Class C)))" |
269 (G,map_of lvars(pns[\<mapsto>]pTs)(This\<mapsto>Class C)))" |
273 |
270 |
329 apply (auto simp: wf_mdecl_def wf_java_mdecl_def) |
326 apply (auto simp: wf_mdecl_def wf_java_mdecl_def) |
330 done |
327 done |
331 |
328 |
332 (**********************************************************************) |
329 (**********************************************************************) |
333 |
330 |
334 constdefs wtpd_expr :: "java_mb env \<Rightarrow> expr \<Rightarrow> bool" |
331 definition wtpd_expr :: "java_mb env \<Rightarrow> expr \<Rightarrow> bool" where |
335 "wtpd_expr E e == (\<exists> T. E\<turnstile>e :: T)" |
332 "wtpd_expr E e == (\<exists> T. E\<turnstile>e :: T)" |
336 wtpd_exprs :: "java_mb env \<Rightarrow> (expr list) \<Rightarrow> bool" |
333 |
|
334 definition wtpd_exprs :: "java_mb env \<Rightarrow> (expr list) \<Rightarrow> bool" where |
337 "wtpd_exprs E e == (\<exists> T. E\<turnstile>e [::] T)" |
335 "wtpd_exprs E e == (\<exists> T. E\<turnstile>e [::] T)" |
338 wtpd_stmt :: "java_mb env \<Rightarrow> stmt \<Rightarrow> bool" |
336 |
|
337 definition wtpd_stmt :: "java_mb env \<Rightarrow> stmt \<Rightarrow> bool" where |
339 "wtpd_stmt E c == (E\<turnstile>c \<surd>)" |
338 "wtpd_stmt E c == (E\<turnstile>c \<surd>)" |
340 |
339 |
341 lemma wtpd_expr_newc: "wtpd_expr E (NewC C) \<Longrightarrow> is_class (prg E) C" |
340 lemma wtpd_expr_newc: "wtpd_expr E (NewC C) \<Longrightarrow> is_class (prg E) C" |
342 by (simp only: wtpd_expr_def, erule exE, erule ty_expr.cases, auto) |
341 by (simp only: wtpd_expr_def, erule exE, erule ty_expr.cases, auto) |
343 |
342 |