48 \<close> |
48 \<close> |
49 lemma exec_instr_xcpt: |
49 lemma exec_instr_xcpt: |
50 "(fst (exec_instr i G hp stk vars Cl sig pc frs) = Some xcp) |
50 "(fst (exec_instr i G hp stk vars Cl sig pc frs) = Some xcp) |
51 = (\<exists>stk'. exec_instr i G hp stk vars Cl sig pc frs = |
51 = (\<exists>stk'. exec_instr i G hp stk vars Cl sig pc frs = |
52 (Some xcp, hp, (stk', vars, Cl, sig, pc)#frs))" |
52 (Some xcp, hp, (stk', vars, Cl, sig, pc)#frs))" |
53 by (cases i, auto simp add: split_beta split: split_if_asm) |
53 by (cases i, auto simp add: split_beta split: if_split_asm) |
54 |
54 |
55 |
55 |
56 text \<open> |
56 text \<open> |
57 Relates \<open>match_any\<close> from the Bytecode Verifier with |
57 Relates \<open>match_any\<close> from the Bytecode Verifier with |
58 \<open>match_exception_table\<close> from the operational semantics: |
58 \<open>match_exception_table\<close> from the operational semantics: |
118 lemma match_et_imp_match: |
118 lemma match_et_imp_match: |
119 "match_exception_table G (Xcpt X) pc et = Some handler |
119 "match_exception_table G (Xcpt X) pc et = Some handler |
120 \<Longrightarrow> match G X pc et = [Xcpt X]" |
120 \<Longrightarrow> match G X pc et = [Xcpt X]" |
121 apply (simp add: match_some_entry) |
121 apply (simp add: match_some_entry) |
122 apply (induct et) |
122 apply (induct et) |
123 apply (auto split: split_if_asm) |
123 apply (auto split: if_split_asm) |
124 done |
124 done |
125 |
125 |
126 text \<open> |
126 text \<open> |
127 We can prove separately that the recursive search for exception |
127 We can prove separately that the recursive search for exception |
128 handlers (\<open>find_handler\<close>) in the frame stack results in |
128 handlers (\<open>find_handler\<close>) in the frame stack results in |
255 G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> |
255 G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd> \<rbrakk> |
256 \<Longrightarrow> \<exists>adr T. xcp = Addr adr \<and> hp adr = Some T" |
256 \<Longrightarrow> \<exists>adr T. xcp = Addr adr \<and> hp adr = Some T" |
257 (is "\<lbrakk> ?xcpt; ?wt; ?correct \<rbrakk> \<Longrightarrow> ?thesis") |
257 (is "\<lbrakk> ?xcpt; ?wt; ?correct \<rbrakk> \<Longrightarrow> ?thesis") |
258 proof - |
258 proof - |
259 note [simp] = split_beta raise_system_xcpt_def |
259 note [simp] = split_beta raise_system_xcpt_def |
260 note [split] = split_if_asm option.split_asm |
260 note [split] = if_split_asm option.split_asm |
261 |
261 |
262 assume wt: ?wt ?correct |
262 assume wt: ?wt ?correct |
263 hence pre: "preallocated hp" by (simp add: correct_state_def) |
263 hence pre: "preallocated hp" by (simp add: correct_state_def) |
264 |
264 |
265 assume xcpt: ?xcpt with pre show ?thesis |
265 assume xcpt: ?xcpt with pre show ?thesis |
346 |
346 |
347 from some_handler xp' |
347 from some_handler xp' |
348 have state': |
348 have state': |
349 "state' = (None, hp, ([xcp], loc, C, sig, handler)#frs)" |
349 "state' = (None, hp, ([xcp], loc, C, sig, handler)#frs)" |
350 by (cases "ins!pc") (auto simp add: raise_system_xcpt_def split_beta |
350 by (cases "ins!pc") (auto simp add: raise_system_xcpt_def split_beta |
351 split: split_if_asm) (* takes long! *) |
351 split: if_split_asm) (* takes long! *) |
352 |
352 |
353 let ?f' = "([xcp], loc, C, sig, handler)" |
353 let ?f' = "([xcp], loc, C, sig, handler)" |
354 from eff |
354 from eff |
355 obtain ST' LT' where |
355 obtain ST' LT' where |
356 phi_pc': "phi C sig ! handler = Some (ST', LT')" and |
356 phi_pc': "phi C sig ! handler = Some (ST', LT')" and |
357 frame': "correct_frame G hp (ST',LT') maxl ins ?f'" |
357 frame': "correct_frame G hp (ST',LT') maxl ins ?f'" |
358 proof (cases "ins!pc") |
358 proof (cases "ins!pc") |
359 case Return \<comment> "can't generate exceptions:" |
359 case Return \<comment> "can't generate exceptions:" |
360 with xp' have False by (simp add: split_beta split: split_if_asm) |
360 with xp' have False by (simp add: split_beta split: if_split_asm) |
361 thus ?thesis .. |
361 thus ?thesis .. |
362 next |
362 next |
363 case New |
363 case New |
364 with some_handler xp' |
364 with some_handler xp' |
365 have xcp: "xcp = Addr (XcptRef OutOfMemory)" |
365 have xcp: "xcp = Addr (XcptRef OutOfMemory)" |
391 show ?thesis by (rule that) |
391 show ?thesis by (rule that) |
392 next |
392 next |
393 case Getfield |
393 case Getfield |
394 with some_handler xp' |
394 with some_handler xp' |
395 have xcp: "xcp = Addr (XcptRef NullPointer)" |
395 have xcp: "xcp = Addr (XcptRef NullPointer)" |
396 by (simp add: raise_system_xcpt_def split_beta split: split_if_asm) |
396 by (simp add: raise_system_xcpt_def split_beta split: if_split_asm) |
397 with prehp have "cname_of hp xcp = Xcpt NullPointer" .. |
397 with prehp have "cname_of hp xcp = Xcpt NullPointer" .. |
398 with Getfield some_handler phi_pc eff |
398 with Getfield some_handler phi_pc eff |
399 obtain ST' LT' where |
399 obtain ST' LT' where |
400 phi': "phi C sig ! handler = Some (ST', LT')" and |
400 phi': "phi C sig ! handler = Some (ST', LT')" and |
401 less: "G \<turnstile> ([Class (Xcpt NullPointer)], LT) <=s (ST', LT')" and |
401 less: "G \<turnstile> ([Class (Xcpt NullPointer)], LT) <=s (ST', LT')" and |
421 show ?thesis by (rule that) |
421 show ?thesis by (rule that) |
422 next |
422 next |
423 case Putfield |
423 case Putfield |
424 with some_handler xp' |
424 with some_handler xp' |
425 have xcp: "xcp = Addr (XcptRef NullPointer)" |
425 have xcp: "xcp = Addr (XcptRef NullPointer)" |
426 by (simp add: raise_system_xcpt_def split_beta split: split_if_asm) |
426 by (simp add: raise_system_xcpt_def split_beta split: if_split_asm) |
427 with prehp have "cname_of hp xcp = Xcpt NullPointer" .. |
427 with prehp have "cname_of hp xcp = Xcpt NullPointer" .. |
428 with Putfield some_handler phi_pc eff |
428 with Putfield some_handler phi_pc eff |
429 obtain ST' LT' where |
429 obtain ST' LT' where |
430 phi': "phi C sig ! handler = Some (ST', LT')" and |
430 phi': "phi C sig ! handler = Some (ST', LT')" and |
431 less: "G \<turnstile> ([Class (Xcpt NullPointer)], LT) <=s (ST', LT')" and |
431 less: "G \<turnstile> ([Class (Xcpt NullPointer)], LT) <=s (ST', LT')" and |
451 show ?thesis by (rule that) |
451 show ?thesis by (rule that) |
452 next |
452 next |
453 case Checkcast |
453 case Checkcast |
454 with some_handler xp' |
454 with some_handler xp' |
455 have xcp: "xcp = Addr (XcptRef ClassCast)" |
455 have xcp: "xcp = Addr (XcptRef ClassCast)" |
456 by (simp add: raise_system_xcpt_def split_beta split: split_if_asm) |
456 by (simp add: raise_system_xcpt_def split_beta split: if_split_asm) |
457 with prehp have "cname_of hp xcp = Xcpt ClassCast" .. |
457 with prehp have "cname_of hp xcp = Xcpt ClassCast" .. |
458 with Checkcast some_handler phi_pc eff |
458 with Checkcast some_handler phi_pc eff |
459 obtain ST' LT' where |
459 obtain ST' LT' where |
460 phi': "phi C sig ! handler = Some (ST', LT')" and |
460 phi': "phi C sig ! handler = Some (ST', LT')" and |
461 less: "G \<turnstile> ([Class (Xcpt ClassCast)], LT) <=s (ST', LT')" and |
461 less: "G \<turnstile> ([Class (Xcpt ClassCast)], LT) <=s (ST', LT')" and |
653 wt_instr (ins!pc) G rT (phi C sig) maxs (length ins) et pc; |
653 wt_instr (ins!pc) G rT (phi C sig) maxs (length ins) et pc; |
654 Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; |
654 Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; |
655 G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd>; |
655 G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd>; |
656 fst (exec_instr (ins!pc) G hp stk loc C sig pc frs) = None \<rbrakk> |
656 fst (exec_instr (ins!pc) G hp stk loc C sig pc frs) = None \<rbrakk> |
657 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>" |
657 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>" |
658 apply (clarsimp simp add: defs2 wt_jvm_prog_def split: split_if_asm) |
658 apply (clarsimp simp add: defs2 wt_jvm_prog_def split: if_split_asm) |
659 apply (blast intro: Cast_conf2) |
659 apply (blast intro: Cast_conf2) |
660 done |
660 done |
661 |
661 |
662 |
662 |
663 lemma Getfield_correct: |
663 lemma Getfield_correct: |
668 Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; |
668 Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; |
669 G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd>; |
669 G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd>; |
670 fst (exec_instr (ins!pc) G hp stk loc C sig pc frs) = None \<rbrakk> |
670 fst (exec_instr (ins!pc) G hp stk loc C sig pc frs) = None \<rbrakk> |
671 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>" |
671 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>" |
672 apply (clarsimp simp add: defs2 wt_jvm_prog_def split_beta |
672 apply (clarsimp simp add: defs2 wt_jvm_prog_def split_beta |
673 split: option.split split_if_asm) |
673 split: option.split if_split_asm) |
674 apply (frule conf_widen) |
674 apply (frule conf_widen) |
675 apply assumption+ |
675 apply assumption+ |
676 apply (drule conf_RefTD) |
676 apply (drule conf_RefTD) |
677 apply (clarsimp simp add: defs2) |
677 apply (clarsimp simp add: defs2) |
678 apply (rule conjI) |
678 apply (rule conjI) |
700 wt_instr (ins!pc) G rT (phi C sig) maxs (length ins) et pc; |
700 wt_instr (ins!pc) G rT (phi C sig) maxs (length ins) et pc; |
701 Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; |
701 Some state' = exec (G, None, hp, (stk,loc,C,sig,pc)#frs) ; |
702 G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd>; |
702 G,phi \<turnstile>JVM (None, hp, (stk,loc,C,sig,pc)#frs)\<surd>; |
703 fst (exec_instr (ins!pc) G hp stk loc C sig pc frs) = None \<rbrakk> |
703 fst (exec_instr (ins!pc) G hp stk loc C sig pc frs) = None \<rbrakk> |
704 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>" |
704 \<Longrightarrow> G,phi \<turnstile>JVM state'\<surd>" |
705 apply (clarsimp simp add: defs2 split_beta split: option.split list.split split_if_asm) |
705 apply (clarsimp simp add: defs2 split_beta split: option.split list.split if_split_asm) |
706 apply (frule conf_widen) |
706 apply (frule conf_widen) |
707 prefer 2 |
707 prefer 2 |
708 apply assumption |
708 apply assumption |
709 apply assumption |
709 apply assumption |
710 apply (drule conf_RefTD) |
710 apply (drule conf_RefTD) |
1326 lemma |
1326 lemma |
1327 fixes G :: jvm_prog ("\<Gamma>") |
1327 fixes G :: jvm_prog ("\<Gamma>") |
1328 assumes wf: "wf_prog wf_mb \<Gamma>" |
1328 assumes wf: "wf_prog wf_mb \<Gamma>" |
1329 shows hconf_start: "\<Gamma> \<turnstile>h (start_heap \<Gamma>) \<surd>" |
1329 shows hconf_start: "\<Gamma> \<turnstile>h (start_heap \<Gamma>) \<surd>" |
1330 apply (unfold hconf_def start_heap_def) |
1330 apply (unfold hconf_def start_heap_def) |
1331 apply (auto simp add: fun_upd_apply blank_def oconf_def split: split_if_asm) |
1331 apply (auto simp add: fun_upd_apply blank_def oconf_def split: if_split_asm) |
1332 apply (simp add: fields_is_type |
1332 apply (simp add: fields_is_type |
1333 [OF _ wf [THEN wf_prog_ws_prog] |
1333 [OF _ wf [THEN wf_prog_ws_prog] |
1334 is_class_xcpt [OF wf [THEN wf_prog_ws_prog]]])+ |
1334 is_class_xcpt [OF wf [THEN wf_prog_ws_prog]]])+ |
1335 done |
1335 done |
1336 |
1336 |