src/HOL/Bali/WellForm.thy
changeset 32960 69916a850301
parent 30235 58d147683393
child 34915 7894c7dab132
equal deleted inserted replaced
32959:23a8c5ac35f8 32960:69916a850301
    57 \end{itemize} 
    57 \end{itemize} 
    58 *}
    58 *}
    59 constdefs
    59 constdefs
    60   wf_mhead :: "prog \<Rightarrow> pname \<Rightarrow> sig \<Rightarrow> mhead \<Rightarrow> bool"
    60   wf_mhead :: "prog \<Rightarrow> pname \<Rightarrow> sig \<Rightarrow> mhead \<Rightarrow> bool"
    61  "wf_mhead G P \<equiv> \<lambda> sig mh. length (parTs sig) = length (pars mh) \<and>
    61  "wf_mhead G P \<equiv> \<lambda> sig mh. length (parTs sig) = length (pars mh) \<and>
    62 			    \<spacespace> ( \<forall>T\<in>set (parTs sig). is_acc_type G P T) \<and> 
    62                             \<spacespace> ( \<forall>T\<in>set (parTs sig). is_acc_type G P T) \<and> 
    63                             is_acc_type G P (resTy mh) \<and>
    63                             is_acc_type G P (resTy mh) \<and>
    64 			    \<spacespace> distinct (pars mh)"
    64                             \<spacespace> distinct (pars mh)"
    65 
    65 
    66 
    66 
    67 text {*
    67 text {*
    68 A method declaration is wellformed if:
    68 A method declaration is wellformed if:
    69 \begin{itemize}
    69 \begin{itemize}
    85             EName e 
    85             EName e 
    86             \<Rightarrow> (case e of 
    86             \<Rightarrow> (case e of 
    87                   VNam v 
    87                   VNam v 
    88                   \<Rightarrow>(table_of (lcls (mbody m))((pars m)[\<mapsto>](parTs sig))) v
    88                   \<Rightarrow>(table_of (lcls (mbody m))((pars m)[\<mapsto>](parTs sig))) v
    89                 | Res \<Rightarrow> Some (resTy m))
    89                 | Res \<Rightarrow> Some (resTy m))
    90 	  | This \<Rightarrow> if is_static m then None else Some (Class C))"
    90           | This \<Rightarrow> if is_static m then None else Some (Class C))"
    91 
    91 
    92 constdefs parameters :: "methd \<Rightarrow> lname set"
    92 constdefs parameters :: "methd \<Rightarrow> lname set"
    93 "parameters m \<equiv>  set (map (EName \<circ> VNam) (pars m)) 
    93 "parameters m \<equiv>  set (map (EName \<circ> VNam) (pars m)) 
    94                   \<union> (if (static m) then {} else {This})"
    94                   \<union> (if (static m) then {} else {This})"
    95 
    95 
    96 constdefs
    96 constdefs
    97   wf_mdecl :: "prog \<Rightarrow> qtname \<Rightarrow> mdecl \<Rightarrow> bool"
    97   wf_mdecl :: "prog \<Rightarrow> qtname \<Rightarrow> mdecl \<Rightarrow> bool"
    98  "wf_mdecl G C \<equiv> 
    98  "wf_mdecl G C \<equiv> 
    99       \<lambda>(sig,m).
    99       \<lambda>(sig,m).
   100 	  wf_mhead G (pid C) sig (mhead m) \<and> 
   100           wf_mhead G (pid C) sig (mhead m) \<and> 
   101           unique (lcls (mbody m)) \<and> 
   101           unique (lcls (mbody m)) \<and> 
   102           (\<forall>(vn,T)\<in>set (lcls (mbody m)). is_acc_type G (pid C) T) \<and> 
   102           (\<forall>(vn,T)\<in>set (lcls (mbody m)). is_acc_type G (pid C) T) \<and> 
   103 	  (\<forall>pn\<in>set (pars m). table_of (lcls (mbody m)) pn = None) \<and>
   103           (\<forall>pn\<in>set (pars m). table_of (lcls (mbody m)) pn = None) \<and>
   104           jumpNestingOkS {Ret} (stmt (mbody m)) \<and> 
   104           jumpNestingOkS {Ret} (stmt (mbody m)) \<and> 
   105           is_class G C \<and>
   105           is_class G C \<and>
   106           \<lparr>prg=G,cls=C,lcl=callee_lcl C sig m\<rparr>\<turnstile>(stmt (mbody m))\<Colon>\<surd> \<and>
   106           \<lparr>prg=G,cls=C,lcl=callee_lcl C sig m\<rparr>\<turnstile>(stmt (mbody m))\<Colon>\<surd> \<and>
   107           (\<exists> A. \<lparr>prg=G,cls=C,lcl=callee_lcl C sig m\<rparr> 
   107           (\<exists> A. \<lparr>prg=G,cls=C,lcl=callee_lcl C sig m\<rparr> 
   108                 \<turnstile> parameters m \<guillemotright>\<langle>stmt (mbody m)\<rangle>\<guillemotright> A 
   108                 \<turnstile> parameters m \<guillemotright>\<langle>stmt (mbody m)\<rangle>\<guillemotright> A 
   223 constdefs
   223 constdefs
   224   wf_idecl :: "prog  \<Rightarrow> idecl \<Rightarrow> bool"
   224   wf_idecl :: "prog  \<Rightarrow> idecl \<Rightarrow> bool"
   225  "wf_idecl G \<equiv> 
   225  "wf_idecl G \<equiv> 
   226     \<lambda>(I,i). 
   226     \<lambda>(I,i). 
   227         ws_idecl G I (isuperIfs i) \<and> 
   227         ws_idecl G I (isuperIfs i) \<and> 
   228 	\<not>is_class G I \<and>
   228         \<not>is_class G I \<and>
   229 	(\<forall>(sig,mh)\<in>set (imethods i). wf_mhead G (pid I) sig mh \<and> 
   229         (\<forall>(sig,mh)\<in>set (imethods i). wf_mhead G (pid I) sig mh \<and> 
   230                                      \<not>is_static mh \<and>
   230                                      \<not>is_static mh \<and>
   231                                       accmodi mh = Public) \<and>
   231                                       accmodi mh = Public) \<and>
   232 	unique (imethods i) \<and>
   232         unique (imethods i) \<and>
   233         (\<forall> J\<in>set (isuperIfs i). is_acc_iface G (pid I) J) \<and>
   233         (\<forall> J\<in>set (isuperIfs i). is_acc_iface G (pid I) J) \<and>
   234         (table_of (imethods i)
   234         (table_of (imethods i)
   235           hiding (methd G Object)
   235           hiding (methd G Object)
   236           under  (\<lambda> new old. accmodi old \<noteq> Private)
   236           under  (\<lambda> new old. accmodi old \<noteq> Private)
   237           entails (\<lambda>new old. G\<turnstile>resTy new\<preceq>resTy old \<and> 
   237           entails (\<lambda>new old. G\<turnstile>resTy new\<preceq>resTy old \<and> 
   238                              is_static new = is_static old)) \<and> 
   238                              is_static new = is_static old)) \<and> 
   239         (Option.set \<circ> table_of (imethods i) 
   239         (Option.set \<circ> table_of (imethods i) 
   240                hidings Un_tables((\<lambda>J.(imethds G J))`set (isuperIfs i))
   240                hidings Un_tables((\<lambda>J.(imethds G J))`set (isuperIfs i))
   241 	       entails (\<lambda>new old. G\<turnstile>resTy new\<preceq>resTy old))"
   241                entails (\<lambda>new old. G\<turnstile>resTy new\<preceq>resTy old))"
   242 
   242 
   243 lemma wf_idecl_mhead: "\<lbrakk>wf_idecl G (I,i); (sig,mh)\<in>set (imethods i)\<rbrakk> \<Longrightarrow>  
   243 lemma wf_idecl_mhead: "\<lbrakk>wf_idecl G (I,i); (sig,mh)\<in>set (imethods i)\<rbrakk> \<Longrightarrow>  
   244   wf_mhead G (pid I) sig mh \<and> \<not>is_static mh \<and> accmodi mh = Public"
   244   wf_mhead G (pid I) sig mh \<and> \<not>is_static mh \<and> accmodi mh = Public"
   245 apply (unfold wf_idecl_def)
   245 apply (unfold wf_idecl_def)
   246 apply auto
   246 apply auto
   338 "wf_cdecl G \<equiv> 
   338 "wf_cdecl G \<equiv> 
   339    \<lambda>(C,c).
   339    \<lambda>(C,c).
   340       \<not>is_iface G C \<and>
   340       \<not>is_iface G C \<and>
   341       (\<forall>I\<in>set (superIfs c). is_acc_iface G (pid C) I \<and>
   341       (\<forall>I\<in>set (superIfs c). is_acc_iface G (pid C) I \<and>
   342         (\<forall>s. \<forall> im \<in> imethds G I s.
   342         (\<forall>s. \<forall> im \<in> imethds G I s.
   343       	    (\<exists> cm \<in> methd  G C s: G\<turnstile>resTy cm\<preceq>resTy im \<and>
   343             (\<exists> cm \<in> methd  G C s: G\<turnstile>resTy cm\<preceq>resTy im \<and>
   344       	                             \<not> is_static cm \<and>
   344                                      \<not> is_static cm \<and>
   345                                      accmodi im \<le> accmodi cm))) \<and>
   345                                      accmodi im \<le> accmodi cm))) \<and>
   346       (\<forall>f\<in>set (cfields c). wf_fdecl G (pid C) f) \<and> unique (cfields c) \<and> 
   346       (\<forall>f\<in>set (cfields c). wf_fdecl G (pid C) f) \<and> unique (cfields c) \<and> 
   347       (\<forall>m\<in>set (methods c). wf_mdecl G C m) \<and> unique (methods c) \<and>
   347       (\<forall>m\<in>set (methods c). wf_mdecl G C m) \<and> unique (methods c) \<and>
   348       jumpNestingOkS {} (init c) \<and>
   348       jumpNestingOkS {} (init c) \<and>
   349       (\<exists> A. \<lparr>prg=G,cls=C,lcl=empty\<rparr>\<turnstile> {} \<guillemotright>\<langle>init c\<rangle>\<guillemotright> A) \<and>
   349       (\<exists> A. \<lparr>prg=G,cls=C,lcl=empty\<rparr>\<turnstile> {} \<guillemotright>\<langle>init c\<rangle>\<guillemotright> A) \<and>
   353             (table_of (map (\<lambda> (s,m). (s,C,m)) (methods c)) 
   353             (table_of (map (\<lambda> (s,m). (s,C,m)) (methods c)) 
   354              entails (\<lambda> new. \<forall> old sig. 
   354              entails (\<lambda> new. \<forall> old sig. 
   355                        (G,sig\<turnstile>new overrides\<^sub>S old 
   355                        (G,sig\<turnstile>new overrides\<^sub>S old 
   356                         \<longrightarrow> (G\<turnstile>resTy new\<preceq>resTy old \<and>
   356                         \<longrightarrow> (G\<turnstile>resTy new\<preceq>resTy old \<and>
   357                              accmodi old \<le> accmodi new \<and>
   357                              accmodi old \<le> accmodi new \<and>
   358       	                     \<not>is_static old)) \<and>
   358                              \<not>is_static old)) \<and>
   359                        (G,sig\<turnstile>new hides old 
   359                        (G,sig\<turnstile>new hides old 
   360                          \<longrightarrow> (accmodi old \<le> accmodi new \<and>
   360                          \<longrightarrow> (accmodi old \<le> accmodi new \<and>
   361       	                      is_static old)))) 
   361                               is_static old)))) 
   362             ))"
   362             ))"
   363 
   363 
   364 (*
   364 (*
   365 constdefs
   365 constdefs
   366  wf_cdecl :: "prog \<Rightarrow> cdecl \<Rightarrow> bool"
   366  wf_cdecl :: "prog \<Rightarrow> cdecl \<Rightarrow> bool"
   367 "wf_cdecl G \<equiv> 
   367 "wf_cdecl G \<equiv> 
   368    \<lambda>(C,c).
   368    \<lambda>(C,c).
   369       \<not>is_iface G C \<and>
   369       \<not>is_iface G C \<and>
   370       (\<forall>I\<in>set (superIfs c). is_acc_iface G (pid C) I \<and>
   370       (\<forall>I\<in>set (superIfs c). is_acc_iface G (pid C) I \<and>
   371         (\<forall>s. \<forall> im \<in> imethds G I s.
   371         (\<forall>s. \<forall> im \<in> imethds G I s.
   372       	    (\<exists> cm \<in> methd  G C s: G\<turnstile>resTy (mthd cm)\<preceq>resTy (mthd im) \<and>
   372             (\<exists> cm \<in> methd  G C s: G\<turnstile>resTy (mthd cm)\<preceq>resTy (mthd im) \<and>
   373       	                             \<not> is_static cm \<and>
   373                                      \<not> is_static cm \<and>
   374                                      accmodi im \<le> accmodi cm))) \<and>
   374                                      accmodi im \<le> accmodi cm))) \<and>
   375       (\<forall>f\<in>set (cfields c). wf_fdecl G (pid C) f) \<and> unique (cfields c) \<and> 
   375       (\<forall>f\<in>set (cfields c). wf_fdecl G (pid C) f) \<and> unique (cfields c) \<and> 
   376       (\<forall>m\<in>set (methods c). wf_mdecl G C m) \<and> unique (methods c) \<and> 
   376       (\<forall>m\<in>set (methods c). wf_mdecl G C m) \<and> unique (methods c) \<and> 
   377       \<lparr>prg=G,cls=C,lcl=empty\<rparr>\<turnstile>(init c)\<Colon>\<surd> \<and> ws_cdecl G C (super c) \<and>
   377       \<lparr>prg=G,cls=C,lcl=empty\<rparr>\<turnstile>(init c)\<Colon>\<surd> \<and> ws_cdecl G C (super c) \<and>
   378       (C \<noteq> Object \<longrightarrow> 
   378       (C \<noteq> Object \<longrightarrow> 
   381               hiding methd G (super c)
   381               hiding methd G (super c)
   382               under (\<lambda> new old. G\<turnstile>new overrides old)
   382               under (\<lambda> new old. G\<turnstile>new overrides old)
   383               entails (\<lambda> new old. 
   383               entails (\<lambda> new old. 
   384                            (G\<turnstile>resTy (mthd new)\<preceq>resTy (mthd old) \<and>
   384                            (G\<turnstile>resTy (mthd new)\<preceq>resTy (mthd old) \<and>
   385                             accmodi old \<le> accmodi new \<and>
   385                             accmodi old \<le> accmodi new \<and>
   386       	                   \<not> is_static old)))  \<and>
   386                            \<not> is_static old)))  \<and>
   387             (table_of (map (\<lambda> (s,m). (s,C,m)) (methods c)) 
   387             (table_of (map (\<lambda> (s,m). (s,C,m)) (methods c)) 
   388               hiding methd G (super c)
   388               hiding methd G (super c)
   389               under (\<lambda> new old. G\<turnstile>new hides old)
   389               under (\<lambda> new old. G\<turnstile>new hides old)
   390               entails (\<lambda> new old. is_static old \<and> 
   390               entails (\<lambda> new old. is_static old \<and> 
   391                                   accmodi old \<le> accmodi new))  \<and>
   391                                   accmodi old \<le> accmodi new))  \<and>
   396 lemma wf_cdeclE [consumes 1]: 
   396 lemma wf_cdeclE [consumes 1]: 
   397  "\<lbrakk>wf_cdecl G (C,c);
   397  "\<lbrakk>wf_cdecl G (C,c);
   398    \<lbrakk>\<not>is_iface G C;
   398    \<lbrakk>\<not>is_iface G C;
   399     (\<forall>I\<in>set (superIfs c). is_acc_iface G (pid C) I \<and>
   399     (\<forall>I\<in>set (superIfs c). is_acc_iface G (pid C) I \<and>
   400         (\<forall>s. \<forall> im \<in> imethds G I s.
   400         (\<forall>s. \<forall> im \<in> imethds G I s.
   401       	    (\<exists> cm \<in> methd  G C s: G\<turnstile>resTy cm\<preceq>resTy im \<and>
   401             (\<exists> cm \<in> methd  G C s: G\<turnstile>resTy cm\<preceq>resTy im \<and>
   402       	                             \<not> is_static cm \<and>
   402                                      \<not> is_static cm \<and>
   403                                      accmodi im \<le> accmodi cm))); 
   403                                      accmodi im \<le> accmodi cm))); 
   404       \<forall>f\<in>set (cfields c). wf_fdecl G (pid C) f; unique (cfields c); 
   404       \<forall>f\<in>set (cfields c). wf_fdecl G (pid C) f; unique (cfields c); 
   405       \<forall>m\<in>set (methods c). wf_mdecl G C m; unique (methods c);
   405       \<forall>m\<in>set (methods c). wf_mdecl G C m; unique (methods c);
   406       jumpNestingOkS {} (init c);
   406       jumpNestingOkS {} (init c);
   407       \<exists> A. \<lparr>prg=G,cls=C,lcl=empty\<rparr>\<turnstile> {} \<guillemotright>\<langle>init c\<rangle>\<guillemotright> A;
   407       \<exists> A. \<lparr>prg=G,cls=C,lcl=empty\<rparr>\<turnstile> {} \<guillemotright>\<langle>init c\<rangle>\<guillemotright> A;
   412             (table_of (map (\<lambda> (s,m). (s,C,m)) (methods c)) 
   412             (table_of (map (\<lambda> (s,m). (s,C,m)) (methods c)) 
   413              entails (\<lambda> new. \<forall> old sig. 
   413              entails (\<lambda> new. \<forall> old sig. 
   414                        (G,sig\<turnstile>new overrides\<^sub>S old 
   414                        (G,sig\<turnstile>new overrides\<^sub>S old 
   415                         \<longrightarrow> (G\<turnstile>resTy new\<preceq>resTy old \<and>
   415                         \<longrightarrow> (G\<turnstile>resTy new\<preceq>resTy old \<and>
   416                              accmodi old \<le> accmodi new \<and>
   416                              accmodi old \<le> accmodi new \<and>
   417       	                     \<not>is_static old)) \<and>
   417                              \<not>is_static old)) \<and>
   418                        (G,sig\<turnstile>new hides old 
   418                        (G,sig\<turnstile>new hides old 
   419                          \<longrightarrow> (accmodi old \<le> accmodi new \<and>
   419                          \<longrightarrow> (accmodi old \<le> accmodi new \<and>
   420       	                      is_static old)))) 
   420                               is_static old)))) 
   421             ))\<rbrakk> \<Longrightarrow> P
   421             ))\<rbrakk> \<Longrightarrow> P
   422   \<rbrakk> \<Longrightarrow> P"
   422   \<rbrakk> \<Longrightarrow> P"
   423 by (unfold wf_cdecl_def) simp
   423 by (unfold wf_cdecl_def) simp
   424 
   424 
   425 lemma wf_cdecl_unique: 
   425 lemma wf_cdecl_unique: 
   520 \end{itemize}
   520 \end{itemize}
   521 *}
   521 *}
   522 constdefs
   522 constdefs
   523   wf_prog  :: "prog \<Rightarrow> bool"
   523   wf_prog  :: "prog \<Rightarrow> bool"
   524  "wf_prog G \<equiv> let is = ifaces G; cs = classes G in
   524  "wf_prog G \<equiv> let is = ifaces G; cs = classes G in
   525 	         ObjectC \<in> set cs \<and> 
   525                  ObjectC \<in> set cs \<and> 
   526                 (\<forall> m\<in>set Object_mdecls. accmodi m \<noteq> Package) \<and>
   526                 (\<forall> m\<in>set Object_mdecls. accmodi m \<noteq> Package) \<and>
   527                 (\<forall>xn. SXcptC xn \<in> set cs) \<and>
   527                 (\<forall>xn. SXcptC xn \<in> set cs) \<and>
   528 		(\<forall>i\<in>set is. wf_idecl G i) \<and> unique is \<and>
   528                 (\<forall>i\<in>set is. wf_idecl G i) \<and> unique is \<and>
   529 		(\<forall>c\<in>set cs. wf_cdecl G c) \<and> unique cs"
   529                 (\<forall>c\<in>set cs. wf_cdecl G c) \<and> unique cs"
   530 
   530 
   531 lemma wf_prog_idecl: "\<lbrakk>iface G I = Some i; wf_prog G\<rbrakk> \<Longrightarrow> wf_idecl G (I,i)"
   531 lemma wf_prog_idecl: "\<lbrakk>iface G I = Some i; wf_prog G\<rbrakk> \<Longrightarrow> wf_idecl G (I,i)"
   532 apply (unfold wf_prog_def Let_def)
   532 apply (unfold wf_prog_def Let_def)
   533 apply simp
   533 apply simp
   534 apply (fast dest: map_of_SomeD)
   534 apply (fast dest: map_of_SomeD)
   591 apply (unfold wf_prog_def Let_def SXcptC_def)
   591 apply (unfold wf_prog_def Let_def SXcptC_def)
   592 apply (fast dest!: map_of_SomeI)
   592 apply (fast dest!: map_of_SomeI)
   593 done
   593 done
   594 
   594 
   595 lemma wf_ObjectC [simp]: 
   595 lemma wf_ObjectC [simp]: 
   596 	"wf_cdecl G ObjectC = (\<not>is_iface G Object \<and> Ball (set Object_mdecls)
   596         "wf_cdecl G ObjectC = (\<not>is_iface G Object \<and> Ball (set Object_mdecls)
   597   (wf_mdecl G Object) \<and> unique Object_mdecls)"
   597   (wf_mdecl G Object) \<and> unique Object_mdecls)"
   598 apply (unfold wf_cdecl_def ws_cdecl_def ObjectC_def)
   598 apply (unfold wf_cdecl_def ws_cdecl_def ObjectC_def)
   599 apply (auto intro: da.Skip)
   599 apply (auto intro: da.Skip)
   600 done
   600 done
   601 
   601 
   751     show "\<not>is_static im \<and> accmodi im = Public" 
   751     show "\<not>is_static im \<and> accmodi im = Public" 
   752     proof -
   752     proof -
   753       let ?inherited = "Un_tables (imethds G ` set (isuperIfs i))"
   753       let ?inherited = "Un_tables (imethds G ` set (isuperIfs i))"
   754       let ?new = "(Option.set \<circ> table_of (map (\<lambda>(s, mh). (s, I, mh)) (imethods i)))"
   754       let ?new = "(Option.set \<circ> table_of (map (\<lambda>(s, mh). (s, I, mh)) (imethods i)))"
   755       from if_I wf im have imethds:"im \<in> (?inherited \<oplus>\<oplus> ?new) sig"
   755       from if_I wf im have imethds:"im \<in> (?inherited \<oplus>\<oplus> ?new) sig"
   756 	by (simp add: imethds_rec)
   756         by (simp add: imethds_rec)
   757       from wf if_I have 
   757       from wf if_I have 
   758 	wf_supI: "\<forall> J. J \<in> set (isuperIfs i) \<longrightarrow> (\<exists> j. iface G J = Some j)"
   758         wf_supI: "\<forall> J. J \<in> set (isuperIfs i) \<longrightarrow> (\<exists> j. iface G J = Some j)"
   759 	by (blast dest: wf_prog_idecl wf_idecl_supD is_acc_ifaceD)
   759         by (blast dest: wf_prog_idecl wf_idecl_supD is_acc_ifaceD)
   760       from wf if_I have
   760       from wf if_I have
   761 	"\<forall> im \<in> set (imethods i). \<not> is_static im \<and> accmodi im = Public"
   761         "\<forall> im \<in> set (imethods i). \<not> is_static im \<and> accmodi im = Public"
   762 	by (auto dest!: wf_prog_idecl wf_idecl_mhead)
   762         by (auto dest!: wf_prog_idecl wf_idecl_mhead)
   763       then have new_ok: "\<forall> im. table_of (imethods i) sig = Some im 
   763       then have new_ok: "\<forall> im. table_of (imethods i) sig = Some im 
   764                          \<longrightarrow>  \<not> is_static im \<and> accmodi im = Public"
   764                          \<longrightarrow>  \<not> is_static im \<and> accmodi im = Public"
   765 	by (auto dest!: table_of_Some_in_set)
   765         by (auto dest!: table_of_Some_in_set)
   766       show ?thesis
   766       show ?thesis
   767 	proof (cases "?new sig = {}")
   767         proof (cases "?new sig = {}")
   768 	  case True
   768           case True
   769 	  from True wf wf_supI if_I imethds hyp 
   769           from True wf wf_supI if_I imethds hyp 
   770 	  show ?thesis by (auto simp del:  split_paired_All)  
   770           show ?thesis by (auto simp del:  split_paired_All)  
   771 	next
   771         next
   772 	  case False
   772           case False
   773 	  from False wf wf_supI if_I imethds new_ok hyp 
   773           from False wf wf_supI if_I imethds new_ok hyp 
   774 	  show ?thesis by (auto dest: wf_idecl_hidings hidings_entailsD)
   774           show ?thesis by (auto dest: wf_idecl_hidings hidings_entailsD)
   775 	qed
   775         qed
   776       qed
   776       qed
   777     qed
   777     qed
   778   with asm show ?thesis by (auto simp del: split_paired_All)
   778   with asm show ?thesis by (auto simp del: split_paired_All)
   779 qed
   779 qed
   780 
   780 
   868       by (auto dest: wf_prog_stat_overridesD)  
   868       by (auto dest: wf_prog_stat_overridesD)  
   869     have not_private_new: "accmodi new \<noteq> Private"
   869     have not_private_new: "accmodi new \<noteq> Private"
   870     proof -
   870     proof -
   871       from stat_override 
   871       from stat_override 
   872       have "accmodi old \<noteq> Private"
   872       have "accmodi old \<noteq> Private"
   873 	by (rule no_Private_stat_override)
   873         by (rule no_Private_stat_override)
   874       moreover
   874       moreover
   875       from stat_override wf
   875       from stat_override wf
   876       have "accmodi old \<le> accmodi new"
   876       have "accmodi old \<le> accmodi new"
   877 	by (auto dest: wf_prog_stat_overridesD)
   877         by (auto dest: wf_prog_stat_overridesD)
   878       ultimately
   878       ultimately
   879       show ?thesis
   879       show ?thesis
   880 	by (auto dest: acc_modi_bottom)
   880         by (auto dest: acc_modi_bottom)
   881     qed
   881     qed
   882     with Direct resTy_widen not_static_old 
   882     with Direct resTy_widen not_static_old 
   883     show "?Overrides new old" 
   883     show "?Overrides new old" 
   884       by (auto intro: overridesR.Direct stat_override_declclasses_relation) 
   884       by (auto intro: overridesR.Direct stat_override_declclasses_relation) 
   885   next
   885   next
   933       from member_super
   933       from member_super
   934       have old_declared: "G\<turnstile>Method old declared_in (declclass old)"
   934       have old_declared: "G\<turnstile>Method old declared_in (declclass old)"
   935        by (cases old) (auto dest: member_of_declC)
   935        by (cases old) (auto dest: member_of_declC)
   936       have "?P C old"
   936       have "?P C old"
   937       proof (cases "G\<turnstile>mid (msig old) undeclared_in C")
   937       proof (cases "G\<turnstile>mid (msig old) undeclared_in C")
   938 	case True
   938         case True
   939 	with inheritable super accessible_super member_super
   939         with inheritable super accessible_super member_super
   940 	have "G\<turnstile>Method old member_of C"
   940         have "G\<turnstile>Method old member_of C"
   941 	  by (cases old) (auto intro: members.Inherited)
   941           by (cases old) (auto intro: members.Inherited)
   942 	then show ?thesis
   942         then show ?thesis
   943 	  by auto
   943           by auto
   944       next
   944       next
   945 	case False
   945         case False
   946 	then obtain new_member where
   946         then obtain new_member where
   947 	     "G\<turnstile>new_member declared_in C" and
   947              "G\<turnstile>new_member declared_in C" and
   948              "mid (msig old) = memberid new_member"
   948              "mid (msig old) = memberid new_member"
   949           by (auto dest: not_undeclared_declared)
   949           by (auto dest: not_undeclared_declared)
   950 	then obtain new where
   950         then obtain new where
   951 	          new: "G\<turnstile>Method new declared_in C" and
   951                   new: "G\<turnstile>Method new declared_in C" and
   952                eq_sig: "msig old = msig new" and
   952                eq_sig: "msig old = msig new" and
   953 	    declC_new: "declclass new = C" 
   953             declC_new: "declclass new = C" 
   954 	  by (cases new_member) auto
   954           by (cases new_member) auto
   955 	then have member_new: "G\<turnstile>Method new member_of C"
   955         then have member_new: "G\<turnstile>Method new member_of C"
   956 	  by (cases new) (auto intro: members.Immediate)
   956           by (cases new) (auto intro: members.Immediate)
   957 	from declC_new super member_super
   957         from declC_new super member_super
   958 	have subcls_new_old: "G\<turnstile>declclass new \<prec>\<^sub>C declclass old"
   958         have subcls_new_old: "G\<turnstile>declclass new \<prec>\<^sub>C declclass old"
   959 	  by (auto dest!: member_of_subclseq_declC
   959           by (auto dest!: member_of_subclseq_declC
   960 	            dest: r_into_trancl intro: trancl_rtrancl_trancl)
   960                     dest: r_into_trancl intro: trancl_rtrancl_trancl)
   961 	show ?thesis
   961         show ?thesis
   962 	proof (cases "is_static new")
   962         proof (cases "is_static new")
   963 	  case False
   963           case False
   964 	  with eq_sig declC_new new old_declared inheritable
   964           with eq_sig declC_new new old_declared inheritable
   965 	       super member_super subcls_new_old
   965                super member_super subcls_new_old
   966 	  have "G\<turnstile>new overrides\<^sub>S old"
   966           have "G\<turnstile>new overrides\<^sub>S old"
   967 	    by (auto intro!: stat_overridesR.Direct)
   967             by (auto intro!: stat_overridesR.Direct)
   968 	  with member_new show ?thesis
   968           with member_new show ?thesis
   969 	    by blast
   969             by blast
   970 	next
   970         next
   971 	  case True
   971           case True
   972 	  with eq_sig declC_new subcls_new_old new old_declared inheritable
   972           with eq_sig declC_new subcls_new_old new old_declared inheritable
   973 	  have "G\<turnstile>new hides old"
   973           have "G\<turnstile>new hides old"
   974 	    by (auto intro: hidesI)    
   974             by (auto intro: hidesI)    
   975 	  with wf 
   975           with wf 
   976 	  have "is_static old"
   976           have "is_static old"
   977 	    by (blast dest: wf_prog_hidesD)
   977             by (blast dest: wf_prog_hidesD)
   978 	  with instance_method
   978           with instance_method
   979 	  show ?thesis
   979           show ?thesis
   980 	    by (contradiction)
   980             by (contradiction)
   981 	qed
   981         qed
   982       qed
   982       qed
   983     } note hyp_member_super = this
   983     } note hyp_member_super = this
   984     from subclsC cls_C 
   984     from subclsC cls_C 
   985     have "G\<turnstile>(super c)\<preceq>\<^sub>C declclass old"
   985     have "G\<turnstile>(super c)\<preceq>\<^sub>C declclass old"
   986       by (rule subcls_superD)
   986       by (rule subcls_superD)
   989     proof (cases rule: subclseq_cases) 
   989     proof (cases rule: subclseq_cases) 
   990       case Eq
   990       case Eq
   991       assume "super c = declclass old"
   991       assume "super c = declclass old"
   992       with old_declared 
   992       with old_declared 
   993       have "G\<turnstile>Method old member_of (super c)" 
   993       have "G\<turnstile>Method old member_of (super c)" 
   994 	by (cases old) (auto intro: members.Immediate)
   994         by (cases old) (auto intro: members.Immediate)
   995       with inheritable instance_method 
   995       with inheritable instance_method 
   996       show ?thesis
   996       show ?thesis
   997 	by (blast dest: hyp_member_super)
   997         by (blast dest: hyp_member_super)
   998     next
   998     next
   999       case Subcls
   999       case Subcls
  1000       assume "G\<turnstile>super c\<prec>\<^sub>C declclass old"
  1000       assume "G\<turnstile>super c\<prec>\<^sub>C declclass old"
  1001       moreover
  1001       moreover
  1002       from inheritable accmodi_old
  1002       from inheritable accmodi_old
  1003       have "G \<turnstile>Method old inheritable_in pid (super c)"
  1003       have "G \<turnstile>Method old inheritable_in pid (super c)"
  1004 	by (cases "accmodi old") (auto simp add: inheritable_in_def)
  1004         by (cases "accmodi old") (auto simp add: inheritable_in_def)
  1005       ultimately
  1005       ultimately
  1006       have "?P (super c) old"
  1006       have "?P (super c) old"
  1007 	by (blast dest: hyp)
  1007         by (blast dest: hyp)
  1008       then show ?thesis
  1008       then show ?thesis
  1009       proof
  1009       proof
  1010 	assume "G \<turnstile>Method old member_of super c"
  1010         assume "G \<turnstile>Method old member_of super c"
  1011 	with inheritable instance_method
  1011         with inheritable instance_method
  1012 	show ?thesis
  1012         show ?thesis
  1013 	  by (blast dest: hyp_member_super)
  1013           by (blast dest: hyp_member_super)
  1014       next
  1014       next
  1015 	assume "\<exists>new. G \<turnstile> new overrides\<^sub>S old \<and> G \<turnstile>Method new member_of super c"
  1015         assume "\<exists>new. G \<turnstile> new overrides\<^sub>S old \<and> G \<turnstile>Method new member_of super c"
  1016 	then obtain super_new where
  1016         then obtain super_new where
  1017 	  super_new_override:  "G \<turnstile> super_new overrides\<^sub>S old" and
  1017           super_new_override:  "G \<turnstile> super_new overrides\<^sub>S old" and
  1018             super_new_member:  "G \<turnstile>Method super_new member_of super c"
  1018             super_new_member:  "G \<turnstile>Method super_new member_of super c"
  1019 	  by blast
  1019           by blast
  1020 	from super_new_override wf
  1020         from super_new_override wf
  1021 	have "accmodi old \<le> accmodi super_new"
  1021         have "accmodi old \<le> accmodi super_new"
  1022 	  by (auto dest: wf_prog_stat_overridesD)
  1022           by (auto dest: wf_prog_stat_overridesD)
  1023 	with inheritable accmodi_old
  1023         with inheritable accmodi_old
  1024 	have "G \<turnstile>Method super_new inheritable_in pid C"
  1024         have "G \<turnstile>Method super_new inheritable_in pid C"
  1025 	  by (auto simp add: inheritable_in_def 
  1025           by (auto simp add: inheritable_in_def 
  1026 	              split: acc_modi.splits
  1026                       split: acc_modi.splits
  1027                        dest: acc_modi_le_Dests)
  1027                        dest: acc_modi_le_Dests)
  1028 	moreover
  1028         moreover
  1029 	from super_new_override 
  1029         from super_new_override 
  1030 	have "\<not> is_static super_new"
  1030         have "\<not> is_static super_new"
  1031 	  by (auto dest: stat_overrides_commonD)
  1031           by (auto dest: stat_overrides_commonD)
  1032 	moreover
  1032         moreover
  1033 	note super_new_member
  1033         note super_new_member
  1034 	ultimately have "?P C super_new"
  1034         ultimately have "?P C super_new"
  1035 	  by (auto dest: hyp_member_super)
  1035           by (auto dest: hyp_member_super)
  1036 	then show ?thesis
  1036         then show ?thesis
  1037 	proof 
  1037         proof 
  1038 	  assume "G \<turnstile>Method super_new member_of C"
  1038           assume "G \<turnstile>Method super_new member_of C"
  1039 	  with super_new_override
  1039           with super_new_override
  1040 	  show ?thesis
  1040           show ?thesis
  1041 	    by blast
  1041             by blast
  1042 	next
  1042         next
  1043 	  assume "\<exists>new. G \<turnstile> new overrides\<^sub>S super_new \<and> 
  1043           assume "\<exists>new. G \<turnstile> new overrides\<^sub>S super_new \<and> 
  1044                   G \<turnstile>Method new member_of C"
  1044                   G \<turnstile>Method new member_of C"
  1045 	  with super_new_override show ?thesis
  1045           with super_new_override show ?thesis
  1046 	    by (blast intro: stat_overridesR.Indirect) 
  1046             by (blast intro: stat_overridesR.Indirect) 
  1047 	qed
  1047         qed
  1048       qed
  1048       qed
  1049     qed
  1049     qed
  1050   qed
  1050   qed
  1051 qed
  1051 qed
  1052 
  1052 
  1093     proof (cases rule: non_Package_instance_method_inheritance_cases)
  1093     proof (cases rule: non_Package_instance_method_inheritance_cases)
  1094       case Inheritance
  1094       case Inheritance
  1095       assume "G \<turnstile>Method old member_of declclass new"
  1095       assume "G \<turnstile>Method old member_of declclass new"
  1096       then have "G\<turnstile>mid (msig old) undeclared_in declclass new"
  1096       then have "G\<turnstile>mid (msig old) undeclared_in declclass new"
  1097       proof cases
  1097       proof cases
  1098 	case Immediate 
  1098         case Immediate 
  1099 	with subcls_new_old wf show ?thesis 	
  1099         with subcls_new_old wf show ?thesis     
  1100 	  by (auto dest: subcls_irrefl)
  1100           by (auto dest: subcls_irrefl)
  1101       next
  1101       next
  1102 	case Inherited
  1102         case Inherited
  1103 	then show ?thesis
  1103         then show ?thesis
  1104 	  by (cases old) auto
  1104           by (cases old) auto
  1105       qed
  1105       qed
  1106       with eq_sig_new_old new_declared
  1106       with eq_sig_new_old new_declared
  1107       show ?thesis
  1107       show ?thesis
  1108 	by (cases old,cases new) (auto dest!: declared_not_undeclared)
  1108         by (cases old,cases new) (auto dest!: declared_not_undeclared)
  1109     next
  1109     next
  1110       case (Overriding new') 
  1110       case (Overriding new') 
  1111       assume stat_override_new': "G \<turnstile> new' overrides\<^sub>S old"
  1111       assume stat_override_new': "G \<turnstile> new' overrides\<^sub>S old"
  1112       then have "msig new' = msig old"
  1112       then have "msig new' = msig old"
  1113 	by (auto dest: stat_overrides_commonD)
  1113         by (auto dest: stat_overrides_commonD)
  1114       with eq_sig_new_old have eq_sig_new_new': "msig new=msig new'"
  1114       with eq_sig_new_old have eq_sig_new_new': "msig new=msig new'"
  1115 	by simp
  1115         by simp
  1116       assume "G \<turnstile>Method new' member_of declclass new"
  1116       assume "G \<turnstile>Method new' member_of declclass new"
  1117       then show ?thesis
  1117       then show ?thesis
  1118       proof (cases)
  1118       proof (cases)
  1119 	case Immediate
  1119         case Immediate
  1120 	then have declC_new: "declclass new' = declclass new" 
  1120         then have declC_new: "declclass new' = declclass new" 
  1121 	  by auto
  1121           by auto
  1122 	from Immediate 
  1122         from Immediate 
  1123 	have "G\<turnstile>Method new' declared_in declclass new"
  1123         have "G\<turnstile>Method new' declared_in declclass new"
  1124 	  by (cases new') auto
  1124           by (cases new') auto
  1125 	with new_declared eq_sig_new_new' declC_new 
  1125         with new_declared eq_sig_new_new' declC_new 
  1126 	have "new=new'"
  1126         have "new=new'"
  1127 	  by (cases new, cases new') (auto dest: unique_declared_in) 
  1127           by (cases new, cases new') (auto dest: unique_declared_in) 
  1128 	with stat_override_new'
  1128         with stat_override_new'
  1129 	show ?thesis
  1129         show ?thesis
  1130 	  by simp
  1130           by simp
  1131       next
  1131       next
  1132 	case Inherited
  1132         case Inherited
  1133 	then have "G\<turnstile>mid (msig new') undeclared_in declclass new"
  1133         then have "G\<turnstile>mid (msig new') undeclared_in declclass new"
  1134 	  by (cases new') (auto)
  1134           by (cases new') (auto)
  1135 	with eq_sig_new_new' new_declared
  1135         with eq_sig_new_new' new_declared
  1136 	show ?thesis
  1136         show ?thesis
  1137 	  by (cases new,cases new') (auto dest!: declared_not_undeclared)
  1137           by (cases new,cases new') (auto dest!: declared_not_undeclared)
  1138       qed
  1138       qed
  1139     qed
  1139     qed
  1140   next
  1140   next
  1141     case (Indirect new inter old)
  1141     case (Indirect new inter old)
  1142     assume accmodi_old: "accmodi old \<noteq> Package"
  1142     assume accmodi_old: "accmodi old \<noteq> Package"
  1149     moreover
  1149     moreover
  1150     have "accmodi inter \<noteq> Package"
  1150     have "accmodi inter \<noteq> Package"
  1151     proof -
  1151     proof -
  1152       from stat_override_inter_old wf 
  1152       from stat_override_inter_old wf 
  1153       have "accmodi old \<le> accmodi inter"
  1153       have "accmodi old \<le> accmodi inter"
  1154 	by (auto dest: wf_prog_stat_overridesD)
  1154         by (auto dest: wf_prog_stat_overridesD)
  1155       with stat_override_inter_old accmodi_old
  1155       with stat_override_inter_old accmodi_old
  1156       show ?thesis
  1156       show ?thesis
  1157 	by (auto dest!: no_Private_stat_override
  1157         by (auto dest!: no_Private_stat_override
  1158                  split: acc_modi.splits 
  1158                  split: acc_modi.splits 
  1159 	         dest: acc_modi_le_Dests)
  1159                  dest: acc_modi_le_Dests)
  1160     qed
  1160     qed
  1161     ultimately show "?Overrides new old"
  1161     ultimately show "?Overrides new old"
  1162       by (blast intro: stat_overridesR.Indirect)
  1162       by (blast intro: stat_overridesR.Indirect)
  1163   qed
  1163   qed
  1164 qed
  1164 qed
  1295     proof (cases "pid (declclass old) = pid (declclass inter)")
  1295     proof (cases "pid (declclass old) = pid (declclass inter)")
  1296       case True
  1296       case True
  1297       note same_pack_old_inter = this
  1297       note same_pack_old_inter = this
  1298       show ?thesis
  1298       show ?thesis
  1299       proof (cases "pid (declclass inter) = pid (declclass new)")
  1299       proof (cases "pid (declclass inter) = pid (declclass new)")
  1300 	case True
  1300         case True
  1301 	with same_pack_old_inter outside_pack
  1301         with same_pack_old_inter outside_pack
  1302 	show ?thesis
  1302         show ?thesis
  1303 	  by auto
  1303           by auto
  1304       next
  1304       next
  1305 	case False
  1305         case False
  1306 	note diff_pack_inter_new = this
  1306         note diff_pack_inter_new = this
  1307 	show ?thesis
  1307         show ?thesis
  1308 	proof (cases "accmodi inter = Package")
  1308         proof (cases "accmodi inter = Package")
  1309 	  case True
  1309           case True
  1310 	  with diff_pack_inter_new hyp_new_inter  
  1310           with diff_pack_inter_new hyp_new_inter  
  1311 	  obtain newinter where
  1311           obtain newinter where
  1312 	    over_new_newinter: "G \<turnstile> new overrides newinter" and
  1312             over_new_newinter: "G \<turnstile> new overrides newinter" and
  1313             over_newinter_inter: "G \<turnstile> newinter overrides inter" and 
  1313             over_newinter_inter: "G \<turnstile> newinter overrides inter" and 
  1314             eq_pid: "pid (declclass inter) = pid (declclass newinter)" and
  1314             eq_pid: "pid (declclass inter) = pid (declclass newinter)" and
  1315             accmodi_newinter: "Protected \<le> accmodi newinter"
  1315             accmodi_newinter: "Protected \<le> accmodi newinter"
  1316 	    by auto
  1316             by auto
  1317 	  from over_newinter_inter override_inter_old
  1317           from over_newinter_inter override_inter_old
  1318 	  have "G\<turnstile>newinter overrides old"
  1318           have "G\<turnstile>newinter overrides old"
  1319 	    by (rule overridesR.Indirect)
  1319             by (rule overridesR.Indirect)
  1320 	  moreover
  1320           moreover
  1321 	  from eq_pid same_pack_old_inter 
  1321           from eq_pid same_pack_old_inter 
  1322 	  have "pid (declclass old) = pid (declclass newinter)"
  1322           have "pid (declclass old) = pid (declclass newinter)"
  1323 	    by simp
  1323             by simp
  1324 	  moreover
  1324           moreover
  1325 	  note over_new_newinter accmodi_newinter
  1325           note over_new_newinter accmodi_newinter
  1326 	  ultimately show ?thesis
  1326           ultimately show ?thesis
  1327 	    by blast
  1327             by blast
  1328 	next
  1328         next
  1329 	  case False
  1329           case False
  1330 	  with override_new_inter
  1330           with override_new_inter
  1331 	  have "Protected \<le> accmodi inter"
  1331           have "Protected \<le> accmodi inter"
  1332 	    by (cases "accmodi inter") (auto dest: no_Private_override)
  1332             by (cases "accmodi inter") (auto dest: no_Private_override)
  1333 	  with override_new_inter override_inter_old same_pack_old_inter
  1333           with override_new_inter override_inter_old same_pack_old_inter
  1334 	  show ?thesis
  1334           show ?thesis
  1335 	    by blast
  1335             by blast
  1336 	qed
  1336         qed
  1337       qed
  1337       qed
  1338     next
  1338     next
  1339       case False
  1339       case False
  1340       with accmodi_old hyp_inter_old
  1340       with accmodi_old hyp_inter_old
  1341       obtain newinter where
  1341       obtain newinter where
  1342 	over_inter_newinter: "G \<turnstile> inter overrides newinter" and
  1342         over_inter_newinter: "G \<turnstile> inter overrides newinter" and
  1343           over_newinter_old: "G \<turnstile> newinter overrides old" and 
  1343           over_newinter_old: "G \<turnstile> newinter overrides old" and 
  1344                 eq_pid: "pid (declclass old) = pid (declclass newinter)" and
  1344                 eq_pid: "pid (declclass old) = pid (declclass newinter)" and
  1345 	accmodi_newinter: "Protected \<le> accmodi newinter"
  1345         accmodi_newinter: "Protected \<le> accmodi newinter"
  1346 	by auto
  1346         by auto
  1347       from override_new_inter over_inter_newinter 
  1347       from override_new_inter over_inter_newinter 
  1348       have "G \<turnstile> new overrides newinter"
  1348       have "G \<turnstile> new overrides newinter"
  1349 	by (rule overridesR.Indirect)
  1349         by (rule overridesR.Indirect)
  1350       with eq_pid over_newinter_old accmodi_newinter
  1350       with eq_pid over_newinter_old accmodi_newinter
  1351       show ?thesis
  1351       show ?thesis
  1352 	by blast
  1352         by blast
  1353     qed
  1353     qed
  1354   qed
  1354   qed
  1355 qed
  1355 qed
  1356 
  1356 
  1357 lemma declclass_widen[rule_format]: 
  1357 lemma declclass_widen[rule_format]: 
  1377       by (simp add: methd_rec)
  1377       by (simp add: methd_rec)
  1378     show ?thesis
  1378     show ?thesis
  1379     proof (cases "?table sig")
  1379     proof (cases "?table sig")
  1380       case None
  1380       case None
  1381       from this methd_C have "?filter (methd G (super c)) sig = Some m"
  1381       from this methd_C have "?filter (methd G (super c)) sig = Some m"
  1382 	by simp
  1382         by simp
  1383       moreover
  1383       moreover
  1384       from wf cls_C False obtain sup where "class G (super c) = Some sup"
  1384       from wf cls_C False obtain sup where "class G (super c) = Some sup"
  1385 	by (blast dest: wf_prog_cdecl wf_cdecl_supD is_acc_class_is_class)
  1385         by (blast dest: wf_prog_cdecl wf_cdecl_supD is_acc_class_is_class)
  1386       moreover note wf False cls_C  
  1386       moreover note wf False cls_C  
  1387       ultimately have "G\<turnstile>super c \<preceq>\<^sub>C declclass m"  
  1387       ultimately have "G\<turnstile>super c \<preceq>\<^sub>C declclass m"  
  1388 	by (auto intro: Hyp [rule_format])
  1388         by (auto intro: Hyp [rule_format])
  1389       moreover from cls_C False have  "G\<turnstile>C \<prec>\<^sub>C\<^sub>1 super c" by (rule subcls1I)
  1389       moreover from cls_C False have  "G\<turnstile>C \<prec>\<^sub>C\<^sub>1 super c" by (rule subcls1I)
  1390       ultimately show ?thesis by - (rule rtrancl_into_rtrancl2)
  1390       ultimately show ?thesis by - (rule rtrancl_into_rtrancl2)
  1391     next
  1391     next
  1392       case Some
  1392       case Some
  1393       from this wf False cls_C methd_C show ?thesis by auto
  1393       from this wf False cls_C methd_C show ?thesis by auto
  1497     from methd ws clsC neq_C_Obj
  1497     from methd ws clsC neq_C_Obj
  1498     show "?MemberOf C"
  1498     show "?MemberOf C"
  1499     proof (cases rule: methd_rec_Some_cases)
  1499     proof (cases rule: methd_rec_Some_cases)
  1500       case NewMethod
  1500       case NewMethod
  1501       with clsC show ?thesis
  1501       with clsC show ?thesis
  1502 	by (auto dest: method_declared_inI intro!: members.Immediate)
  1502         by (auto dest: method_declared_inI intro!: members.Immediate)
  1503     next
  1503     next
  1504       case InheritedMethod
  1504       case InheritedMethod
  1505       then show "?thesis"
  1505       then show "?thesis"
  1506 	by (blast dest: inherits_member)
  1506         by (blast dest: inherits_member)
  1507     qed
  1507     qed
  1508   qed
  1508   qed
  1509 qed
  1509 qed
  1510 
  1510 
  1511 lemma current_methd: 
  1511 lemma current_methd: 
  1609     from ws clsC neq_C_Obj
  1609     from ws clsC neq_C_Obj
  1610     have is_cls_super: "is_class G (super c)"
  1610     have is_cls_super: "is_class G (super c)"
  1611       by (auto dest: ws_prog_cdeclD)
  1611       by (auto dest: ws_prog_cdeclD)
  1612     from clsC wf neq_C_Obj 
  1612     from clsC wf neq_C_Obj 
  1613     have superAccessible: "G\<turnstile>(Class (super c)) accessible_in (pid C)" and
  1613     have superAccessible: "G\<turnstile>(Class (super c)) accessible_in (pid C)" and
  1614 	 subcls1_C_super: "G\<turnstile>C \<prec>\<^sub>C\<^sub>1 super c"
  1614          subcls1_C_super: "G\<turnstile>C \<prec>\<^sub>C\<^sub>1 super c"
  1615       by (auto dest: wf_prog_cdecl wf_cdecl_supD is_acc_classD
  1615       by (auto dest: wf_prog_cdecl wf_cdecl_supD is_acc_classD
  1616               intro: subcls1I)
  1616               intro: subcls1I)
  1617     show "\<exists>new. ?Constraint C new old"
  1617     show "\<exists>new. ?Constraint C new old"
  1618     proof (cases "G\<turnstile>super c\<preceq>\<^sub>C D")
  1618     proof (cases "G\<turnstile>super c\<preceq>\<^sub>C D")
  1619       case False
  1619       case False
  1620       from False Subcls 
  1620       from False Subcls 
  1621       have eq_C_D: "C=D"
  1621       have eq_C_D: "C=D"
  1622 	by (auto dest: subclseq_superD)
  1622         by (auto dest: subclseq_superD)
  1623       with old 
  1623       with old 
  1624       have "?Constraint C old old"
  1624       have "?Constraint C old old"
  1625 	by auto
  1625         by auto
  1626       with eq_C_D 
  1626       with eq_C_D 
  1627       show "\<exists> new. ?Constraint C new old" by auto
  1627       show "\<exists> new. ?Constraint C new old" by auto
  1628     next
  1628     next
  1629       case True
  1629       case True
  1630       with hyp obtain super_method
  1630       with hyp obtain super_method
  1631 	where super: "?Constraint (super c) super_method old" by blast
  1631         where super: "?Constraint (super c) super_method old" by blast
  1632       from super not_static_old
  1632       from super not_static_old
  1633       have not_static_super: "\<not> is_static super_method"
  1633       have not_static_super: "\<not> is_static super_method"
  1634 	by (auto dest!: stat_overrides_commonD)
  1634         by (auto dest!: stat_overrides_commonD)
  1635       from super old wf accmodi_old
  1635       from super old wf accmodi_old
  1636       have accmodi_super_method: "Protected \<le> accmodi super_method"
  1636       have accmodi_super_method: "Protected \<le> accmodi super_method"
  1637 	by (auto dest!: wf_prog_stat_overridesD)
  1637         by (auto dest!: wf_prog_stat_overridesD)
  1638       from super accmodi_old wf
  1638       from super accmodi_old wf
  1639       have inheritable: "G\<turnstile>Methd sig super_method inheritable_in (pid C)"
  1639       have inheritable: "G\<turnstile>Methd sig super_method inheritable_in (pid C)"
  1640 	by (auto dest!: wf_prog_stat_overridesD
  1640         by (auto dest!: wf_prog_stat_overridesD
  1641                         acc_modi_le_Dests
  1641                         acc_modi_le_Dests
  1642               simp add: inheritable_in_def)	           
  1642               simp add: inheritable_in_def)                
  1643       from super wf is_cls_super
  1643       from super wf is_cls_super
  1644       have member: "G\<turnstile>Methd sig super_method member_of (super c)"
  1644       have member: "G\<turnstile>Methd sig super_method member_of (super c)"
  1645 	by (auto intro: methd_member_of) 
  1645         by (auto intro: methd_member_of) 
  1646       from member
  1646       from member
  1647       have decl_super_method:
  1647       have decl_super_method:
  1648         "G\<turnstile>Methd sig super_method declared_in (declclass super_method)"
  1648         "G\<turnstile>Methd sig super_method declared_in (declclass super_method)"
  1649 	by (auto dest: member_of_declC)
  1649         by (auto dest: member_of_declC)
  1650       from super subcls1_C_super ws is_cls_super 
  1650       from super subcls1_C_super ws is_cls_super 
  1651       have subcls_C_super: "G\<turnstile>C \<prec>\<^sub>C (declclass super_method)"
  1651       have subcls_C_super: "G\<turnstile>C \<prec>\<^sub>C (declclass super_method)"
  1652 	by (auto intro: rtrancl_into_trancl2 dest: methd_declC) 
  1652         by (auto intro: rtrancl_into_trancl2 dest: methd_declC) 
  1653       show "\<exists> new. ?Constraint C new old"
  1653       show "\<exists> new. ?Constraint C new old"
  1654       proof (cases "methd G C sig")
  1654       proof (cases "methd G C sig")
  1655 	case None
  1655         case None
  1656 	have "methd G (super c) sig = None"
  1656         have "methd G (super c) sig = None"
  1657 	proof -
  1657         proof -
  1658 	  from clsC ws None 
  1658           from clsC ws None 
  1659 	  have no_new: "table_of (methods c) sig = None" 
  1659           have no_new: "table_of (methods c) sig = None" 
  1660 	    by (auto simp add: methd_rec)
  1660             by (auto simp add: methd_rec)
  1661 	  with clsC 
  1661           with clsC 
  1662 	  have undeclared: "G\<turnstile>mid sig undeclared_in C"
  1662           have undeclared: "G\<turnstile>mid sig undeclared_in C"
  1663 	    by (auto simp add: undeclared_in_def cdeclaredmethd_def)
  1663             by (auto simp add: undeclared_in_def cdeclaredmethd_def)
  1664 	  with inheritable member superAccessible subcls1_C_super
  1664           with inheritable member superAccessible subcls1_C_super
  1665 	  have inherits: "G\<turnstile>C inherits (method sig super_method)"
  1665           have inherits: "G\<turnstile>C inherits (method sig super_method)"
  1666 	    by (auto simp add: inherits_def)
  1666             by (auto simp add: inherits_def)
  1667 	  with clsC ws no_new super neq_C_Obj
  1667           with clsC ws no_new super neq_C_Obj
  1668 	  have "methd G C sig = Some super_method"
  1668           have "methd G C sig = Some super_method"
  1669 	    by (auto simp add: methd_rec map_add_def intro: filter_tab_SomeI)
  1669             by (auto simp add: methd_rec map_add_def intro: filter_tab_SomeI)
  1670           with None show ?thesis
  1670           with None show ?thesis
  1671 	    by simp
  1671             by simp
  1672 	qed
  1672         qed
  1673 	with super show ?thesis by auto
  1673         with super show ?thesis by auto
  1674       next
  1674       next
  1675 	case (Some new)
  1675         case (Some new)
  1676 	from this ws clsC neq_C_Obj
  1676         from this ws clsC neq_C_Obj
  1677 	show ?thesis
  1677         show ?thesis
  1678 	proof (cases rule: methd_rec_Some_cases)
  1678         proof (cases rule: methd_rec_Some_cases)
  1679 	  case InheritedMethod
  1679           case InheritedMethod
  1680 	  with super Some show ?thesis 
  1680           with super Some show ?thesis 
  1681 	    by auto
  1681             by auto
  1682 	next
  1682         next
  1683 	  case NewMethod
  1683           case NewMethod
  1684 	  assume new: "table_of (map (\<lambda>(s, m). (s, C, m)) (methods c)) sig 
  1684           assume new: "table_of (map (\<lambda>(s, m). (s, C, m)) (methods c)) sig 
  1685                        = Some new"
  1685                        = Some new"
  1686 	  from new 
  1686           from new 
  1687 	  have declcls_new: "declclass new = C" 
  1687           have declcls_new: "declclass new = C" 
  1688 	    by auto
  1688             by auto
  1689 	  from wf clsC neq_C_Obj super new not_static_super accmodi_super_method
  1689           from wf clsC neq_C_Obj super new not_static_super accmodi_super_method
  1690 	  have not_static_new: "\<not> is_static new" 
  1690           have not_static_new: "\<not> is_static new" 
  1691 	    by (auto dest: wf_prog_staticD) 
  1691             by (auto dest: wf_prog_staticD) 
  1692 	  from clsC new
  1692           from clsC new
  1693 	  have decl_new: "G\<turnstile>Methd sig new declared_in C"
  1693           have decl_new: "G\<turnstile>Methd sig new declared_in C"
  1694 	    by (auto simp add: declared_in_def cdeclaredmethd_def)
  1694             by (auto simp add: declared_in_def cdeclaredmethd_def)
  1695 	  from not_static_new decl_new decl_super_method
  1695           from not_static_new decl_new decl_super_method
  1696 	       member subcls1_C_super inheritable declcls_new subcls_C_super 
  1696                member subcls1_C_super inheritable declcls_new subcls_C_super 
  1697 	  have "G,sig\<turnstile> new overrides\<^sub>S super_method"
  1697           have "G,sig\<turnstile> new overrides\<^sub>S super_method"
  1698 	    by (auto intro: stat_overridesR.Direct) 
  1698             by (auto intro: stat_overridesR.Direct) 
  1699 	  with super Some
  1699           with super Some
  1700 	  show ?thesis
  1700           show ?thesis
  1701 	    by (auto intro: stat_overridesR.Indirect)
  1701             by (auto intro: stat_overridesR.Indirect)
  1702 	qed
  1702         qed
  1703       qed
  1703       qed
  1704     qed
  1704     qed
  1705   qed
  1705   qed
  1706 qed
  1706 qed
  1707 
  1707 
  1747     with Overriding not_static_old accmodi_old wf 
  1747     with Overriding not_static_old accmodi_old wf 
  1748     show ?thesis 
  1748     show ?thesis 
  1749       by (auto dest!: wf_prog_stat_overridesD)
  1749       by (auto dest!: wf_prog_stat_overridesD)
  1750   qed
  1750   qed
  1751 qed
  1751 qed
  1752  	      
  1752               
  1753 (* local lemma *)
  1753 (* local lemma *)
  1754 lemma bexI': "x \<in> A \<Longrightarrow> P x \<Longrightarrow> \<exists>x\<in>A. P x" by blast
  1754 lemma bexI': "x \<in> A \<Longrightarrow> P x \<Longrightarrow> \<exists>x\<in>A. P x" by blast
  1755 lemma ballE': "\<forall>x\<in>A. P x \<Longrightarrow> (x \<notin> A \<Longrightarrow> Q) \<Longrightarrow> (P x \<Longrightarrow> Q) \<Longrightarrow> Q" by blast
  1755 lemma ballE': "\<forall>x\<in>A. P x \<Longrightarrow> (x \<notin> A \<Longrightarrow> Q) \<Longrightarrow> (P x \<Longrightarrow> Q) \<Longrightarrow> Q" by blast
  1756 
  1756 
  1757 lemma subint_widen_imethds: 
  1757 lemma subint_widen_imethds: 
  1787     show "?Concl I"
  1787     show "?Concl I"
  1788     proof (cases "?newMethods sig = {}")
  1788     proof (cases "?newMethods sig = {}")
  1789       case True
  1789       case True
  1790       with ifI SI hyp wf jm 
  1790       with ifI SI hyp wf jm 
  1791       show "?thesis" 
  1791       show "?thesis" 
  1792 	by (auto simp add: imethds_rec) 
  1792         by (auto simp add: imethds_rec) 
  1793     next
  1793     next
  1794       case False
  1794       case False
  1795       from ifI wf False
  1795       from ifI wf False
  1796       have imethds: "imethds G I sig = ?newMethods sig"
  1796       have imethds: "imethds G I sig = ?newMethods sig"
  1797 	by (simp add: imethds_rec)
  1797         by (simp add: imethds_rec)
  1798       from False
  1798       from False
  1799       obtain im where
  1799       obtain im where
  1800         imdef: "im \<in> ?newMethods sig" 
  1800         imdef: "im \<in> ?newMethods sig" 
  1801 	by (blast)
  1801         by (blast)
  1802       with imethds 
  1802       with imethds 
  1803       have im: "im \<in> imethds G I sig"
  1803       have im: "im \<in> imethds G I sig"
  1804 	by (blast)
  1804         by (blast)
  1805       with im wf ifI 
  1805       with im wf ifI 
  1806       obtain
  1806       obtain
  1807 	 imStatic: "\<not> is_static im" and
  1807          imStatic: "\<not> is_static im" and
  1808          imPublic: "accmodi im = Public"
  1808          imPublic: "accmodi im = Public"
  1809 	by (auto dest!: imethds_wf_mhead)	
  1809         by (auto dest!: imethds_wf_mhead)       
  1810       from ifI wf 
  1810       from ifI wf 
  1811       have wf_I: "wf_idecl G (I,i)" 
  1811       have wf_I: "wf_idecl G (I,i)" 
  1812 	by (rule wf_prog_idecl)
  1812         by (rule wf_prog_idecl)
  1813       with SI wf  
  1813       with SI wf  
  1814       obtain si where
  1814       obtain si where
  1815 	 ifSI: "iface G SI = Some si" and
  1815          ifSI: "iface G SI = Some si" and
  1816 	wf_SI: "wf_idecl G (SI,si)" 
  1816         wf_SI: "wf_idecl G (SI,si)" 
  1817 	by (auto dest!: wf_idecl_supD is_acc_ifaceD
  1817         by (auto dest!: wf_idecl_supD is_acc_ifaceD
  1818                   dest: wf_prog_idecl)
  1818                   dest: wf_prog_idecl)
  1819       from jm hyp 
  1819       from jm hyp 
  1820       obtain sim::"qtname \<times> mhead"  where
  1820       obtain sim::"qtname \<times> mhead"  where
  1821                       sim: "sim \<in> imethds G SI sig" and
  1821                       sim: "sim \<in> imethds G SI sig" and
  1822          eq_static_sim_jm: "is_static sim = is_static jm" and 
  1822          eq_static_sim_jm: "is_static sim = is_static jm" and 
  1823          eq_access_sim_jm: "accmodi sim = accmodi jm" and 
  1823          eq_access_sim_jm: "accmodi sim = accmodi jm" and 
  1824         resTy_widen_sim_jm: "G\<turnstile>resTy sim\<preceq>resTy jm"
  1824         resTy_widen_sim_jm: "G\<turnstile>resTy sim\<preceq>resTy jm"
  1825 	by blast
  1825         by blast
  1826       with wf_I SI imdef sim 
  1826       with wf_I SI imdef sim 
  1827       have "G\<turnstile>resTy im\<preceq>resTy sim"   
  1827       have "G\<turnstile>resTy im\<preceq>resTy sim"   
  1828 	by (auto dest!: wf_idecl_hidings hidings_entailsD)
  1828         by (auto dest!: wf_idecl_hidings hidings_entailsD)
  1829       with wf resTy_widen_sim_jm 
  1829       with wf resTy_widen_sim_jm 
  1830       have resTy_widen_im_jm: "G\<turnstile>resTy im\<preceq>resTy jm"
  1830       have resTy_widen_im_jm: "G\<turnstile>resTy im\<preceq>resTy jm"
  1831 	by (blast intro: widen_trans)
  1831         by (blast intro: widen_trans)
  1832       from sim wf ifSI  
  1832       from sim wf ifSI  
  1833       obtain
  1833       obtain
  1834 	simStatic: "\<not> is_static sim" and
  1834         simStatic: "\<not> is_static sim" and
  1835         simPublic: "accmodi sim = Public"
  1835         simPublic: "accmodi sim = Public"
  1836 	by (auto dest!: imethds_wf_mhead)
  1836         by (auto dest!: imethds_wf_mhead)
  1837       from im 
  1837       from im 
  1838            imStatic simStatic eq_static_sim_jm
  1838            imStatic simStatic eq_static_sim_jm
  1839            imPublic simPublic eq_access_sim_jm
  1839            imPublic simPublic eq_access_sim_jm
  1840            resTy_widen_im_jm
  1840            resTy_widen_im_jm
  1841       show ?thesis 
  1841       show ?thesis 
  1842 	by auto 
  1842         by auto 
  1843     qed
  1843     qed
  1844   qed
  1844   qed
  1845 qed
  1845 qed
  1846      
  1846      
  1847 (* Tactical version *)
  1847 (* Tactical version *)
  1997       show "?thesis" by (auto simp add: methd_rec) (rule hyp)
  1997       show "?thesis" by (auto simp add: methd_rec) (rule hyp)
  1998     next
  1998     next
  1999       case Some
  1999       case Some
  2000       from Some clsC nObj ws m declC
  2000       from Some clsC nObj ws m declC
  2001       show "?thesis" 
  2001       show "?thesis" 
  2002 	by (auto simp add: methd_rec
  2002         by (auto simp add: methd_rec
  2003                      dest: wf_prog_cdecl wf_cdecl_supD is_acc_class_is_class)
  2003                      dest: wf_prog_cdecl wf_cdecl_supD is_acc_class_is_class)
  2004     qed
  2004     qed
  2005   qed
  2005   qed
  2006 qed
  2006 qed
  2007 
  2007 
  2083     show "?P new"
  2083     show "?P new"
  2084     proof (cases rule: imethds_cases)
  2084     proof (cases rule: imethds_cases)
  2085       case NewMethod
  2085       case NewMethod
  2086       with ifI hyp_newmethod
  2086       with ifI hyp_newmethod
  2087       show ?thesis
  2087       show ?thesis
  2088 	by auto
  2088         by auto
  2089     next
  2089     next
  2090       case (InheritedMethod J)
  2090       case (InheritedMethod J)
  2091       assume "J \<in> set (isuperIfs i)" 
  2091       assume "J \<in> set (isuperIfs i)" 
  2092              "new \<in> imethds G J sig"
  2092              "new \<in> imethds G J sig"
  2093       with hyp 
  2093       with hyp 
  2094       show "?thesis"
  2094       show "?thesis"
  2095 	by auto
  2095         by auto
  2096     qed
  2096     qed
  2097   qed
  2097   qed
  2098 qed
  2098 qed
  2099 
  2099 
  2100 text {*
  2100 text {*
  2248      show ?thesis 
  2248      show ?thesis 
  2249      proof (cases "imethds G I sig = {}")
  2249      proof (cases "imethds G I sig = {}")
  2250        case True
  2250        case True
  2251        with statI 
  2251        with statI 
  2252        have dynlookup: "dynlookup G statT dynC sig = dynmethd G Object dynC sig"
  2252        have dynlookup: "dynlookup G statT dynC sig = dynmethd G Object dynC sig"
  2253 	 by (simp add: dynlookup_def dynimethd_def)
  2253          by (simp add: dynlookup_def dynimethd_def)
  2254        from wf dynC 
  2254        from wf dynC 
  2255        have subclsObj: "G\<turnstile>dynC \<preceq>\<^sub>C Object"
  2255        have subclsObj: "G\<turnstile>dynC \<preceq>\<^sub>C Object"
  2256 	 by (auto intro: subcls_ObjectI)
  2256          by (auto intro: subcls_ObjectI)
  2257        from wf dynC dynC_Prop istype sm subclsObj 
  2257        from wf dynC dynC_Prop istype sm subclsObj 
  2258        obtain dm where
  2258        obtain dm where
  2259 	 "dynmethd G Object dynC sig = Some dm"
  2259          "dynmethd G Object dynC sig = Some dm"
  2260 	 "is_static dm = is_static sm" 
  2260          "is_static dm = is_static sm" 
  2261 	 "G\<turnstile>resTy (mthd dm)\<preceq>resTy (mthd sm)"  
  2261          "G\<turnstile>resTy (mthd dm)\<preceq>resTy (mthd sm)"  
  2262 	 by (auto dest!: ws_dynmethd accmethd_SomeD 
  2262          by (auto dest!: ws_dynmethd accmethd_SomeD 
  2263                   intro: class_Object [OF wf] intro: that)
  2263                   intro: class_Object [OF wf] intro: that)
  2264        with dynlookup eq_mheads
  2264        with dynlookup eq_mheads
  2265        show ?thesis 
  2265        show ?thesis 
  2266 	 by (cases emh type: *) (auto)
  2266          by (cases emh type: *) (auto)
  2267      next
  2267      next
  2268        case False
  2268        case False
  2269        with statI
  2269        with statI
  2270        have dynlookup: "dynlookup G statT dynC sig = methd G dynC sig"
  2270        have dynlookup: "dynlookup G statT dynC sig = methd G dynC sig"
  2271 	 by (simp add: dynlookup_def dynimethd_def)
  2271          by (simp add: dynlookup_def dynimethd_def)
  2272        from istype statI
  2272        from istype statI
  2273        have "is_iface G I"
  2273        have "is_iface G I"
  2274 	 by auto
  2274          by auto
  2275        with wf sm nPriv False 
  2275        with wf sm nPriv False 
  2276        obtain im where
  2276        obtain im where
  2277 	      im: "im \<in> imethds G I sig" and
  2277               im: "im \<in> imethds G I sig" and
  2278 	 eq_stat: "is_static im = is_static sm" and
  2278          eq_stat: "is_static im = is_static sm" and
  2279          resProp: "G\<turnstile>resTy (mthd im)\<preceq>resTy (mthd sm)"
  2279          resProp: "G\<turnstile>resTy (mthd im)\<preceq>resTy (mthd sm)"
  2280 	 by (auto dest: wf_imethds_hiding_objmethdsD accmethd_SomeD)
  2280          by (auto dest: wf_imethds_hiding_objmethdsD accmethd_SomeD)
  2281        from im wf statI istype eq_stat eq_mheads
  2281        from im wf statI istype eq_stat eq_mheads
  2282        have not_static_sm: "\<not> is_static emh"
  2282        have not_static_sm: "\<not> is_static emh"
  2283 	 by (cases emh) (auto dest: wf_prog_idecl imethds_wf_mhead)
  2283          by (cases emh) (auto dest: wf_prog_idecl imethds_wf_mhead)
  2284        from im wf dynC_Prop dynC istype statI not_static_sm
  2284        from im wf dynC_Prop dynC istype statI not_static_sm
  2285        obtain dm where
  2285        obtain dm where
  2286 	 "methd G dynC sig = Some dm"
  2286          "methd G dynC sig = Some dm"
  2287 	 "is_static dm = is_static im" 
  2287          "is_static dm = is_static im" 
  2288 	 "G\<turnstile>resTy (mthd dm)\<preceq>resTy (mthd im)" 
  2288          "G\<turnstile>resTy (mthd dm)\<preceq>resTy (mthd im)" 
  2289 	 by (auto dest: implmt_methd)
  2289          by (auto dest: implmt_methd)
  2290        with wf eq_stat resProp dynlookup eq_mheads
  2290        with wf eq_stat resProp dynlookup eq_mheads
  2291        show ?thesis 
  2291        show ?thesis 
  2292 	 by (cases emh type: *) (auto intro: widen_trans)
  2292          by (cases emh type: *) (auto intro: widen_trans)
  2293      qed
  2293      qed
  2294   next
  2294   next
  2295     case Array_Object_methd
  2295     case Array_Object_methd
  2296     fix T sm
  2296     fix T sm
  2297     assume statArr: "statT = ArrayT T" and
  2297     assume statArr: "statT = ArrayT T" and
  2380 "\<lbrakk>class G C = Some c; wf_prog G; methd G C sig = Some m\<rbrakk> 
  2380 "\<lbrakk>class G C = Some c; wf_prog G; methd G C sig = Some m\<rbrakk> 
  2381  \<Longrightarrow> methd G (declclass m) sig = Some m"
  2381  \<Longrightarrow> methd G (declclass m) sig = Some m"
  2382 proof -
  2382 proof -
  2383   assume asm: "class G C = Some c" "wf_prog G" "methd G C sig = Some m"
  2383   assume asm: "class G C = Some c" "wf_prog G" "methd G C sig = Some m"
  2384   have "wf_prog G  \<longrightarrow> 
  2384   have "wf_prog G  \<longrightarrow> 
  2385 	   (\<forall> c m. class G C = Some c \<longrightarrow>  methd G C sig = Some m 
  2385            (\<forall> c m. class G C = Some c \<longrightarrow>  methd G C sig = Some m 
  2386                    \<longrightarrow>  methd G (declclass m) sig = Some m)"      (is "?P G C") 
  2386                    \<longrightarrow>  methd G (declclass m) sig = Some m)"      (is "?P G C") 
  2387   proof (rule class_rec.induct,intro allI impI)
  2387   proof (rule class_rec.induct,intro allI impI)
  2388     fix G C c m
  2388     fix G C c m
  2389     assume hyp: "\<forall>c. C \<noteq> Object \<and> ws_prog G \<and> class G C = Some c \<longrightarrow>
  2389     assume hyp: "\<forall>c. C \<noteq> Object \<and> ws_prog G \<and> class G C = Some c \<longrightarrow>
  2390                      ?P G (super c)"
  2390                      ?P G (super c)"
  2398       let ?filter="filter_tab (\<lambda>sig m. G\<turnstile>C inherits method sig m)"
  2398       let ?filter="filter_tab (\<lambda>sig m. G\<turnstile>C inherits method sig m)"
  2399       let ?table = "table_of (map (\<lambda>(s, m). (s, C, m)) (methods c))"
  2399       let ?table = "table_of (map (\<lambda>(s, m). (s, C, m)) (methods c))"
  2400       case False
  2400       case False
  2401       with cls_C wf m
  2401       with cls_C wf m
  2402       have methd_C: "(?filter (methd G (super c)) ++ ?table) sig = Some m "
  2402       have methd_C: "(?filter (methd G (super c)) ++ ?table) sig = Some m "
  2403 	by (simp add: methd_rec)
  2403         by (simp add: methd_rec)
  2404       show ?thesis
  2404       show ?thesis
  2405       proof (cases "?table sig")
  2405       proof (cases "?table sig")
  2406 	case None
  2406         case None
  2407 	from this methd_C have "?filter (methd G (super c)) sig = Some m"
  2407         from this methd_C have "?filter (methd G (super c)) sig = Some m"
  2408 	  by simp
  2408           by simp
  2409 	moreover
  2409         moreover
  2410 	from wf cls_C False obtain sup where "class G (super c) = Some sup"
  2410         from wf cls_C False obtain sup where "class G (super c) = Some sup"
  2411 	  by (blast dest: wf_prog_cdecl wf_cdecl_supD is_acc_class_is_class)
  2411           by (blast dest: wf_prog_cdecl wf_cdecl_supD is_acc_class_is_class)
  2412 	moreover note wf False cls_C 
  2412         moreover note wf False cls_C 
  2413 	ultimately show ?thesis by (auto intro: hyp [rule_format])
  2413         ultimately show ?thesis by (auto intro: hyp [rule_format])
  2414       next
  2414       next
  2415 	case Some
  2415         case Some
  2416 	from this methd_C m show ?thesis by auto 
  2416         from this methd_C m show ?thesis by auto 
  2417       qed
  2417       qed
  2418     qed
  2418     qed
  2419   qed	
  2419   qed   
  2420   with asm show ?thesis by auto
  2420   with asm show ?thesis by auto
  2421 qed
  2421 qed
  2422 
  2422 
  2423 lemma dynmethd_declclass:
  2423 lemma dynmethd_declclass:
  2424  "\<lbrakk>dynmethd G statC dynC sig = Some m;
  2424  "\<lbrakk>dynmethd G statC dynC sig = Some m;
  2648     proof (cases rule: subclseq_cases)
  2648     proof (cases rule: subclseq_cases)
  2649       case Eq
  2649       case Eq
  2650       assume "dynC=statC"
  2650       assume "dynC=statC"
  2651       moreover
  2651       moreover
  2652       from is_cls_statC obtain c
  2652       from is_cls_statC obtain c
  2653 	where "class G statC = Some c"
  2653         where "class G statC = Some c"
  2654 	by auto
  2654         by auto
  2655       moreover 
  2655       moreover 
  2656       note statM ws dynmethd 
  2656       note statM ws dynmethd 
  2657       ultimately
  2657       ultimately
  2658       have "newM=statM" 
  2658       have "newM=statM" 
  2659 	by (auto simp add: dynmethd_C_C)
  2659         by (auto simp add: dynmethd_C_C)
  2660       with neq show ?thesis 
  2660       with neq show ?thesis 
  2661 	by (contradiction)
  2661         by (contradiction)
  2662     next
  2662     next
  2663       case Subcls then show ?thesis .
  2663       case Subcls then show ?thesis .
  2664     qed 
  2664     qed 
  2665     moreover
  2665     moreover
  2666     from stat_acc wf 
  2666     from stat_acc wf 
  2769     show ?thesis
  2769     show ?thesis
  2770     proof (cases "is_static emh")
  2770     proof (cases "is_static emh")
  2771       case False
  2771       case False
  2772       with statT dynC_prop 
  2772       with statT dynC_prop 
  2773       have widen_dynC: "G\<turnstile>Class dynC \<preceq> RefT statT"
  2773       have widen_dynC: "G\<turnstile>Class dynC \<preceq> RefT statT"
  2774 	by simp
  2774         by simp
  2775       from statT widen_dynC
  2775       from statT widen_dynC
  2776       have implmnt: "G\<turnstile>dynC\<leadsto>I"
  2776       have implmnt: "G\<turnstile>dynC\<leadsto>I"
  2777 	by auto    
  2777         by auto    
  2778       from eq_static False 
  2778       from eq_static False 
  2779       have not_static_dynM: "\<not> is_static dynM" 
  2779       have not_static_dynM: "\<not> is_static dynM" 
  2780 	by simp
  2780         by simp
  2781       from iface_methd implmnt isif_I wf dynM'
  2781       from iface_methd implmnt isif_I wf dynM'
  2782       show ?thesis
  2782       show ?thesis
  2783 	by - (drule implmt_dynimethd_access, auto)
  2783         by - (drule implmt_dynimethd_access, auto)
  2784     next
  2784     next
  2785       case True
  2785       case True
  2786       assume "is_static emh"
  2786       assume "is_static emh"
  2787       moreover
  2787       moreover
  2788       from wf isT_statT statT im 
  2788       from wf isT_statT statT im 
  2789       have "\<not> is_static im"
  2789       have "\<not> is_static im"
  2790 	by (auto dest: accimethdsD wf_prog_idecl imethds_wf_mhead)
  2790         by (auto dest: accimethdsD wf_prog_idecl imethds_wf_mhead)
  2791       moreover note eq_mhds
  2791       moreover note eq_mhds
  2792       ultimately show ?thesis
  2792       ultimately show ?thesis
  2793 	by (cases emh) auto
  2793         by (cases emh) auto
  2794     qed
  2794     qed
  2795   next
  2795   next
  2796     case (Iface_Object_methd I statM)
  2796     case (Iface_Object_methd I statM)
  2797     assume statT: "statT = IfaceT I"
  2797     assume statT: "statT = IfaceT I"
  2798     assume "accmethd G accC Object sig = Some statM"
  2798     assume "accmethd G accC Object sig = Some statM"
  2807     show ?thesis
  2807     show ?thesis
  2808     proof (cases "imethds G I sig = {}")
  2808     proof (cases "imethds G I sig = {}")
  2809       case True
  2809       case True
  2810       from dynM statT True
  2810       from dynM statT True
  2811       have dynM': "dynmethd G Object dynC sig = Some dynM"
  2811       have dynM': "dynmethd G Object dynC sig = Some dynM"
  2812 	by (simp add: dynlookup_def dynimethd_def)
  2812         by (simp add: dynlookup_def dynimethd_def)
  2813       from statT  
  2813       from statT  
  2814       have "G\<turnstile>RefT statT \<preceq>Class Object"
  2814       have "G\<turnstile>RefT statT \<preceq>Class Object"
  2815 	by auto
  2815         by auto
  2816       with statM statT_acc stat_acc widen_dynC_Obj statT isT_statT 
  2816       with statM statT_acc stat_acc widen_dynC_Obj statT isT_statT 
  2817         wf dynM' eq_static dynC_prop  
  2817         wf dynM' eq_static dynC_prop  
  2818       show ?thesis
  2818       show ?thesis
  2819 	by - (drule dynmethd_access_prop,force+) 
  2819         by - (drule dynmethd_access_prop,force+) 
  2820     next
  2820     next
  2821       case False
  2821       case False
  2822       then obtain im where
  2822       then obtain im where
  2823 	im: "im \<in>  imethds G I sig"
  2823         im: "im \<in>  imethds G I sig"
  2824 	by auto
  2824         by auto
  2825       have not_static_emh: "\<not> is_static emh"
  2825       have not_static_emh: "\<not> is_static emh"
  2826       proof -
  2826       proof -
  2827 	from im statM statT isT_statT wf not_Private_statM 
  2827         from im statM statT isT_statT wf not_Private_statM 
  2828 	have "is_static im = is_static statM"
  2828         have "is_static im = is_static statM"
  2829 	  by (fastsimp dest: wf_imethds_hiding_objmethdsD)
  2829           by (fastsimp dest: wf_imethds_hiding_objmethdsD)
  2830 	with wf isT_statT statT im 
  2830         with wf isT_statT statT im 
  2831 	have "\<not> is_static statM"
  2831         have "\<not> is_static statM"
  2832 	  by (auto dest: wf_prog_idecl imethds_wf_mhead)
  2832           by (auto dest: wf_prog_idecl imethds_wf_mhead)
  2833 	with eq_mhds
  2833         with eq_mhds
  2834 	show ?thesis  
  2834         show ?thesis  
  2835 	  by (cases emh) auto
  2835           by (cases emh) auto
  2836       qed
  2836       qed
  2837       with statT dynC_prop
  2837       with statT dynC_prop
  2838       have implmnt: "G\<turnstile>dynC\<leadsto>I"
  2838       have implmnt: "G\<turnstile>dynC\<leadsto>I"
  2839 	by simp
  2839         by simp
  2840       with isT_statT statT
  2840       with isT_statT statT
  2841       have isif_I: "is_iface G I"
  2841       have isif_I: "is_iface G I"
  2842 	by simp
  2842         by simp
  2843       from dynM statT
  2843       from dynM statT
  2844       have dynM': "dynimethd G I dynC sig = Some dynM"
  2844       have dynM': "dynimethd G I dynC sig = Some dynM"
  2845 	by (simp add: dynlookup_def) 
  2845         by (simp add: dynlookup_def) 
  2846       from False implmnt isif_I wf dynM'
  2846       from False implmnt isif_I wf dynM'
  2847       show ?thesis
  2847       show ?thesis
  2848 	by - (drule implmt_dynimethd_access, auto)
  2848         by - (drule implmt_dynimethd_access, auto)
  2849     qed
  2849     qed
  2850   next
  2850   next
  2851     case (Array_Object_methd T statM)
  2851     case (Array_Object_methd T statM)
  2852     assume statT: "statT = ArrayT T"
  2852     assume statT: "statT = ArrayT T"
  2853     assume "accmethd G accC Object sig = Some statM"
  2853     assume "accmethd G accC Object sig = Some statM"