303 | Fin: "\<lbrakk>E,dt\<Turnstile>c1\<Colon>\<surd>; E,dt\<Turnstile>c2\<Colon>\<surd>\<rbrakk> \<Longrightarrow> |
303 | Fin: "\<lbrakk>E,dt\<Turnstile>c1\<Colon>\<surd>; E,dt\<Turnstile>c2\<Colon>\<surd>\<rbrakk> \<Longrightarrow> |
304 E,dt\<Turnstile>c1 Finally c2\<Colon>\<surd>" |
304 E,dt\<Turnstile>c1 Finally c2\<Colon>\<surd>" |
305 |
305 |
306 | Init: "\<lbrakk>is_class (prg E) C\<rbrakk> \<Longrightarrow> |
306 | Init: "\<lbrakk>is_class (prg E) C\<rbrakk> \<Longrightarrow> |
307 E,dt\<Turnstile>Init C\<Colon>\<surd>" |
307 E,dt\<Turnstile>Init C\<Colon>\<surd>" |
308 \<comment> \<open>@{term Init} is created on the fly during evaluation (see Eval.thy). |
308 \<comment> \<open>\<^term>\<open>Init\<close> is created on the fly during evaluation (see Eval.thy). |
309 The class isn't necessarily accessible from the points @{term Init} |
309 The class isn't necessarily accessible from the points \<^term>\<open>Init\<close> |
310 is called. Therefor we only demand @{term is_class} and not |
310 is called. Therefor we only demand \<^term>\<open>is_class\<close> and not |
311 @{term is_acc_class} here.\<close> |
311 \<^term>\<open>is_acc_class\<close> here.\<close> |
312 |
312 |
313 \<comment> \<open>well-typed expressions\<close> |
313 \<comment> \<open>well-typed expressions\<close> |
314 |
314 |
315 \<comment> \<open>cf. 15.8\<close> |
315 \<comment> \<open>cf. 15.8\<close> |
316 | NewC: "\<lbrakk>is_acc_class (prg E) (pkg E) C\<rbrakk> \<Longrightarrow> |
316 | NewC: "\<lbrakk>is_acc_class (prg E) (pkg E) C\<rbrakk> \<Longrightarrow> |
374 |
374 |
375 | Methd: "\<lbrakk>is_class (prg E) C; |
375 | Methd: "\<lbrakk>is_class (prg E) C; |
376 methd (prg E) C sig = Some m; |
376 methd (prg E) C sig = Some m; |
377 E,dt\<Turnstile>Body (declclass m) (stmt (mbody (mthd m)))\<Colon>-T\<rbrakk> \<Longrightarrow> |
377 E,dt\<Turnstile>Body (declclass m) (stmt (mbody (mthd m)))\<Colon>-T\<rbrakk> \<Longrightarrow> |
378 E,dt\<Turnstile>Methd C sig\<Colon>-T" |
378 E,dt\<Turnstile>Methd C sig\<Colon>-T" |
379 \<comment> \<open>The class @{term C} is the dynamic class of the method call |
379 \<comment> \<open>The class \<^term>\<open>C\<close> is the dynamic class of the method call |
380 (cf. Eval.thy). |
380 (cf. Eval.thy). |
381 It hasn't got to be directly accessible from the current package |
381 It hasn't got to be directly accessible from the current package |
382 @{term "(pkg E)"}. |
382 \<^term>\<open>(pkg E)\<close>. |
383 Only the static class must be accessible (enshured indirectly by |
383 Only the static class must be accessible (enshured indirectly by |
384 @{term Call}). |
384 \<^term>\<open>Call\<close>). |
385 Note that l is just a dummy value. It is only used in the smallstep |
385 Note that l is just a dummy value. It is only used in the smallstep |
386 semantics. To proof typesafety directly for the smallstep semantics |
386 semantics. To proof typesafety directly for the smallstep semantics |
387 we would have to assume conformance of l here!\<close> |
387 we would have to assume conformance of l here!\<close> |
388 |
388 |
389 | Body: "\<lbrakk>is_class (prg E) D; |
389 | Body: "\<lbrakk>is_class (prg E) D; |
390 E,dt\<Turnstile>blk\<Colon>\<surd>; |
390 E,dt\<Turnstile>blk\<Colon>\<surd>; |
391 (lcl E) Result = Some T; |
391 (lcl E) Result = Some T; |
392 is_type (prg E) T\<rbrakk> \<Longrightarrow> |
392 is_type (prg E) T\<rbrakk> \<Longrightarrow> |
393 E,dt\<Turnstile>Body D blk\<Colon>-T" |
393 E,dt\<Turnstile>Body D blk\<Colon>-T" |
394 \<comment> \<open>The class @{term D} implementing the method must not directly be |
394 \<comment> \<open>The class \<^term>\<open>D\<close> implementing the method must not directly be |
395 accessible from the current package @{term "(pkg E)"}, but can also |
395 accessible from the current package \<^term>\<open>(pkg E)\<close>, but can also |
396 be indirectly accessible due to inheritance (enshured in @{term Call}) |
396 be indirectly accessible due to inheritance (enshured in \<^term>\<open>Call\<close>) |
397 The result type hasn't got to be accessible in Java! (If it is not |
397 The result type hasn't got to be accessible in Java! (If it is not |
398 accessible you can only assign it to Object). |
398 accessible you can only assign it to Object). |
399 For dummy value l see rule @{term Methd}.\<close> |
399 For dummy value l see rule \<^term>\<open>Methd\<close>.\<close> |
400 |
400 |
401 \<comment> \<open>well-typed variables\<close> |
401 \<comment> \<open>well-typed variables\<close> |
402 |
402 |
403 \<comment> \<open>cf. 15.13.1\<close> |
403 \<comment> \<open>cf. 15.13.1\<close> |
404 | LVar: "\<lbrakk>lcl E vn = Some T; is_acc_type (prg E) (pkg E) T\<rbrakk> \<Longrightarrow> |
404 | LVar: "\<lbrakk>lcl E vn = Some T; is_acc_type (prg E) (pkg E) T\<rbrakk> \<Longrightarrow> |
585 apply auto |
585 apply auto |
586 done |
586 done |
587 |
587 |
588 \<comment> \<open>In the special syntax to distinguish the typing judgements for expressions, |
588 \<comment> \<open>In the special syntax to distinguish the typing judgements for expressions, |
589 statements, variables and expression lists the kind of term corresponds |
589 statements, variables and expression lists the kind of term corresponds |
590 to the kind of type in the end e.g. An statement (injection @{term In3} |
590 to the kind of type in the end e.g. An statement (injection \<^term>\<open>In3\<close> |
591 into terms, always has type void (injection @{term Inl} into the generalised |
591 into terms, always has type void (injection \<^term>\<open>Inl\<close> into the generalised |
592 types. The following simplification procedures establish these kinds of |
592 types. The following simplification procedures establish these kinds of |
593 correlation.\<close> |
593 correlation.\<close> |
594 |
594 |
595 lemma wt_expr_eq: "E,dt\<Turnstile>In1l t\<Colon>U = (\<exists>T. U=Inl T \<and> E,dt\<Turnstile>t\<Colon>-T)" |
595 lemma wt_expr_eq: "E,dt\<Turnstile>In1l t\<Colon>U = (\<exists>T. U=Inl T \<and> E,dt\<Turnstile>t\<Colon>-T)" |
596 by (auto, frule wt_Inj_elim, auto) |
596 by (auto, frule wt_Inj_elim, auto) |
654 apply (simp_all (no_asm_use) split del: if_split_asm) |
654 apply (simp_all (no_asm_use) split del: if_split_asm) |
655 apply (safe del: disjE) |
655 apply (safe del: disjE) |
656 (* 17 subgoals *) |
656 (* 17 subgoals *) |
657 apply (tactic \<open>ALLGOALS (fn i => |
657 apply (tactic \<open>ALLGOALS (fn i => |
658 if i = 11 then EVERY' |
658 if i = 11 then EVERY' |
659 [Rule_Insts.thin_tac @{context} "E,dt\<Turnstile>e0\<Colon>-PrimT Boolean" [(@{binding E}, NONE, NoSyn)], |
659 [Rule_Insts.thin_tac \<^context> "E,dt\<Turnstile>e0\<Colon>-PrimT Boolean" [(\<^binding>\<open>E\<close>, NONE, NoSyn)], |
660 Rule_Insts.thin_tac @{context} "E,dt\<Turnstile>e1\<Colon>-T1" [(@{binding E}, NONE, NoSyn), (@{binding T1}, NONE, NoSyn)], |
660 Rule_Insts.thin_tac \<^context> "E,dt\<Turnstile>e1\<Colon>-T1" [(\<^binding>\<open>E\<close>, NONE, NoSyn), (\<^binding>\<open>T1\<close>, NONE, NoSyn)], |
661 Rule_Insts.thin_tac @{context} "E,dt\<Turnstile>e2\<Colon>-T2" [(@{binding E}, NONE, NoSyn), (@{binding T2}, NONE, NoSyn)]] i |
661 Rule_Insts.thin_tac \<^context> "E,dt\<Turnstile>e2\<Colon>-T2" [(\<^binding>\<open>E\<close>, NONE, NoSyn), (\<^binding>\<open>T2\<close>, NONE, NoSyn)]] i |
662 else Rule_Insts.thin_tac @{context} "All P" [(@{binding P}, NONE, NoSyn)] i)\<close>) |
662 else Rule_Insts.thin_tac \<^context> "All P" [(\<^binding>\<open>P\<close>, NONE, NoSyn)] i)\<close>) |
663 (*apply (safe del: disjE elim!: wt_elim_cases)*) |
663 (*apply (safe del: disjE elim!: wt_elim_cases)*) |
664 apply (tactic \<open>ALLGOALS (eresolve_tac @{context} @{thms wt_elim_cases})\<close>) |
664 apply (tactic \<open>ALLGOALS (eresolve_tac \<^context> @{thms wt_elim_cases})\<close>) |
665 apply (simp_all (no_asm_use) split del: if_split_asm) |
665 apply (simp_all (no_asm_use) split del: if_split_asm) |
666 apply (erule_tac [12] V = "All P" for P in thin_rl) (* Call *) |
666 apply (erule_tac [12] V = "All P" for P in thin_rl) (* Call *) |
667 apply (blast del: equalityCE dest: sym [THEN trans])+ |
667 apply (blast del: equalityCE dest: sym [THEN trans])+ |
668 done |
668 done |
669 |
669 |