1005 \<Longrightarrow> m = n" |
1005 \<Longrightarrow> m = n" |
1006 by (auto simp add: declared_in_def cdeclaredmethd_def cdeclaredfield_def |
1006 by (auto simp add: declared_in_def cdeclaredmethd_def cdeclaredfield_def |
1007 split: memberdecl.splits) |
1007 split: memberdecl.splits) |
1008 |
1008 |
1009 lemma unique_member_of: |
1009 lemma unique_member_of: |
1010 (assumes n: "G\<turnstile>n member_of C" and |
1010 assumes n: "G\<turnstile>n member_of C" and |
1011 m: "G\<turnstile>m member_of C" and |
1011 m: "G\<turnstile>m member_of C" and |
1012 eqid: "memberid n = memberid m" |
1012 eqid: "memberid n = memberid m" |
1013 ) "n=m" |
1013 shows "n=m" |
1014 proof - |
1014 proof - |
1015 from n m eqid |
1015 from n m eqid |
1016 show "n=m" |
1016 show "n=m" |
1017 proof (induct) |
1017 proof (induct) |
1018 case (Immediate C n) |
1018 case (Immediate C n) |
1171 "\<lbrakk>G\<turnstile>m in C permits_acc_to accC; G\<turnstile>m member_in C; is_static m |
1171 "\<lbrakk>G\<turnstile>m in C permits_acc_to accC; G\<turnstile>m member_in C; is_static m |
1172 \<rbrakk> \<Longrightarrow> G\<turnstile>m in (declclass m) permits_acc_to accC" |
1172 \<rbrakk> \<Longrightarrow> G\<turnstile>m in (declclass m) permits_acc_to accC" |
1173 by (cases "accmodi m") (auto simp add: permits_acc_def) |
1173 by (cases "accmodi m") (auto simp add: permits_acc_def) |
1174 |
1174 |
1175 lemma dyn_accessible_from_static_declC: |
1175 lemma dyn_accessible_from_static_declC: |
1176 (assumes acc_C: "G\<turnstile>m in C dyn_accessible_from accC" and |
1176 assumes acc_C: "G\<turnstile>m in C dyn_accessible_from accC" and |
1177 static: "is_static m" |
1177 static: "is_static m" |
1178 ) "G\<turnstile>m in (declclass m) dyn_accessible_from accC" |
1178 shows "G\<turnstile>m in (declclass m) dyn_accessible_from accC" |
1179 proof - |
1179 proof - |
1180 from acc_C static |
1180 from acc_C static |
1181 show "G\<turnstile>m in (declclass m) dyn_accessible_from accC" |
1181 show "G\<turnstile>m in (declclass m) dyn_accessible_from accC" |
1182 proof (induct) |
1182 proof (induct) |
1183 case (Immediate C m) |
1183 case (Immediate C m) |
1302 lemma member_of_subclseq_declC: |
1302 lemma member_of_subclseq_declC: |
1303 "G\<turnstile>m member_of C \<Longrightarrow> G\<turnstile>C \<preceq>\<^sub>C declclass m" |
1303 "G\<turnstile>m member_of C \<Longrightarrow> G\<turnstile>C \<preceq>\<^sub>C declclass m" |
1304 by (induct set: members) (auto dest: r_into_rtrancl intro: rtrancl_trans) |
1304 by (induct set: members) (auto dest: r_into_rtrancl intro: rtrancl_trans) |
1305 |
1305 |
1306 lemma member_of_inheritance: |
1306 lemma member_of_inheritance: |
1307 (assumes m: "G\<turnstile>m member_of D" and |
1307 assumes m: "G\<turnstile>m member_of D" and |
1308 subclseq_D_C: "G\<turnstile>D \<preceq>\<^sub>C C" and |
1308 subclseq_D_C: "G\<turnstile>D \<preceq>\<^sub>C C" and |
1309 subclseq_C_m: "G\<turnstile>C \<preceq>\<^sub>C declclass m" and |
1309 subclseq_C_m: "G\<turnstile>C \<preceq>\<^sub>C declclass m" and |
1310 ws: "ws_prog G" |
1310 ws: "ws_prog G" |
1311 ) "G\<turnstile>m member_of C" |
1311 shows "G\<turnstile>m member_of C" |
1312 proof - |
1312 proof - |
1313 from m subclseq_D_C subclseq_C_m |
1313 from m subclseq_D_C subclseq_C_m |
1314 show ?thesis |
1314 show ?thesis |
1315 proof (induct) |
1315 proof (induct) |
1316 case (Immediate D m) |
1316 case (Immediate D m) |
1350 qed |
1350 qed |
1351 qed |
1351 qed |
1352 qed |
1352 qed |
1353 |
1353 |
1354 lemma member_of_subcls: |
1354 lemma member_of_subcls: |
1355 (assumes old: "G\<turnstile>old member_of C" and |
1355 assumes old: "G\<turnstile>old member_of C" and |
1356 new: "G\<turnstile>new member_of D" and |
1356 new: "G\<turnstile>new member_of D" and |
1357 eqid: "memberid new = memberid old" and |
1357 eqid: "memberid new = memberid old" and |
1358 subclseq_D_C: "G\<turnstile>D \<preceq>\<^sub>C C" and |
1358 subclseq_D_C: "G\<turnstile>D \<preceq>\<^sub>C C" and |
1359 subcls_new_old: "G\<turnstile>declclass new \<prec>\<^sub>C declclass old" and |
1359 subcls_new_old: "G\<turnstile>declclass new \<prec>\<^sub>C declclass old" and |
1360 ws: "ws_prog G" |
1360 ws: "ws_prog G" |
1361 ) "G\<turnstile>D \<prec>\<^sub>C C" |
1361 shows "G\<turnstile>D \<prec>\<^sub>C C" |
1362 proof - |
1362 proof - |
1363 from old |
1363 from old |
1364 have subclseq_C_old: "G\<turnstile>C \<preceq>\<^sub>C declclass old" |
1364 have subclseq_C_old: "G\<turnstile>C \<preceq>\<^sub>C declclass old" |
1365 by (auto dest: member_of_subclseq_declC) |
1365 by (auto dest: member_of_subclseq_declC) |
1366 from new |
1366 from new |
1421 by (drule stat_overrides_commonD) (auto intro: member_of_subcls) |
1421 by (drule stat_overrides_commonD) (auto intro: member_of_subcls) |
1422 |
1422 |
1423 |
1423 |
1424 |
1424 |
1425 lemma inherited_field_access: |
1425 lemma inherited_field_access: |
1426 (assumes stat_acc: "G\<turnstile>membr of statC accessible_from accC" and |
1426 assumes stat_acc: "G\<turnstile>membr of statC accessible_from accC" and |
1427 is_field: "is_field membr" and |
1427 is_field: "is_field membr" and |
1428 subclseq: "G \<turnstile> dynC \<preceq>\<^sub>C statC" |
1428 subclseq: "G \<turnstile> dynC \<preceq>\<^sub>C statC" |
1429 ) "G\<turnstile>membr in dynC dyn_accessible_from accC" |
1429 shows "G\<turnstile>membr in dynC dyn_accessible_from accC" |
1430 proof - |
1430 proof - |
1431 from stat_acc is_field subclseq |
1431 from stat_acc is_field subclseq |
1432 show ?thesis |
1432 show ?thesis |
1433 by (auto dest: accessible_fieldD |
1433 by (auto dest: accessible_fieldD |
1434 intro: dyn_accessible_fromR.Immediate |
1434 intro: dyn_accessible_fromR.Immediate |
1435 member_inI |
1435 member_inI |
1436 permits_acc_inheritance) |
1436 permits_acc_inheritance) |
1437 qed |
1437 qed |
1438 |
1438 |
1439 lemma accessible_inheritance: |
1439 lemma accessible_inheritance: |
1440 (assumes stat_acc: "G\<turnstile>m of statC accessible_from accC" and |
1440 assumes stat_acc: "G\<turnstile>m of statC accessible_from accC" and |
1441 subclseq: "G\<turnstile>dynC \<preceq>\<^sub>C statC" and |
1441 subclseq: "G\<turnstile>dynC \<preceq>\<^sub>C statC" and |
1442 member_dynC: "G\<turnstile>m member_of dynC" and |
1442 member_dynC: "G\<turnstile>m member_of dynC" and |
1443 dynC_acc: "G\<turnstile>(Class dynC) accessible_in (pid accC)" |
1443 dynC_acc: "G\<turnstile>(Class dynC) accessible_in (pid accC)" |
1444 ) "G\<turnstile>m of dynC accessible_from accC" |
1444 shows "G\<turnstile>m of dynC accessible_from accC" |
1445 proof - |
1445 proof - |
1446 from stat_acc |
1446 from stat_acc |
1447 have member_statC: "G\<turnstile>m member_of statC" |
1447 have member_statC: "G\<turnstile>m member_of statC" |
1448 by (auto dest: accessible_from_commonD) |
1448 by (auto dest: accessible_from_commonD) |
1449 from stat_acc |
1449 from stat_acc |
1662 apply (subst imethds_rec, erule conjunct1, assumption) |
1662 apply (subst imethds_rec, erule conjunct1, assumption) |
1663 apply (force elim: imethds_norec intro: rtrancl_into_rtrancl2) |
1663 apply (force elim: imethds_norec intro: rtrancl_into_rtrancl2) |
1664 done |
1664 done |
1665 |
1665 |
1666 lemma imethds_cases [consumes 3, case_names NewMethod InheritedMethod]: |
1666 lemma imethds_cases [consumes 3, case_names NewMethod InheritedMethod]: |
1667 (assumes im: "im \<in> imethds G I sig" and |
1667 assumes im: "im \<in> imethds G I sig" and |
1668 ifI: "iface G I = Some i" and |
1668 ifI: "iface G I = Some i" and |
1669 ws: "ws_prog G" and |
1669 ws: "ws_prog G" and |
1670 hyp_new: "table_of (map (\<lambda>(s, mh). (s, I, mh)) (imethods i)) sig |
1670 hyp_new: "table_of (map (\<lambda>(s, mh). (s, I, mh)) (imethods i)) sig |
1671 = Some im \<Longrightarrow> P" and |
1671 = Some im \<Longrightarrow> P" and |
1672 hyp_inh: "\<And> J. \<lbrakk>J \<in> set (isuperIfs i); im \<in> imethds G J sig\<rbrakk> \<Longrightarrow> P" |
1672 hyp_inh: "\<And> J. \<lbrakk>J \<in> set (isuperIfs i); im \<in> imethds G J sig\<rbrakk> \<Longrightarrow> P" |
1673 ) "P" |
1673 shows P |
1674 proof - |
1674 proof - |
1675 from ifI ws im hyp_new hyp_inh |
1675 from ifI ws im hyp_new hyp_inh |
1676 show "P" |
1676 show "P" |
1677 by (auto simp add: imethds_rec) |
1677 by (auto simp add: imethds_rec) |
1678 qed |
1678 qed |
1754 "\<lbrakk>methd G C sig = Some m; ws_prog G;is_class G C\<rbrakk> |
1754 "\<lbrakk>methd G C sig = Some m; ws_prog G;is_class G C\<rbrakk> |
1755 \<Longrightarrow> G\<turnstile>Methd sig m declared_in (declclass m)" |
1755 \<Longrightarrow> G\<turnstile>Methd sig m declared_in (declclass m)" |
1756 by (auto dest: methd_declC method_declared_inI) |
1756 by (auto dest: methd_declC method_declared_inI) |
1757 |
1757 |
1758 lemma member_methd: |
1758 lemma member_methd: |
1759 (assumes member_of: "G\<turnstile>Methd sig m member_of C" and |
1759 assumes member_of: "G\<turnstile>Methd sig m member_of C" and |
1760 ws: "ws_prog G" |
1760 ws: "ws_prog G" |
1761 ) "methd G C sig = Some m" |
1761 shows "methd G C sig = Some m" |
1762 proof - |
1762 proof - |
1763 from member_of |
1763 from member_of |
1764 have iscls_C: "is_class G C" |
1764 have iscls_C: "is_class G C" |
1765 by (rule member_of_is_classD) |
1765 by (rule member_of_is_classD) |
1766 from iscls_C ws member_of |
1766 from iscls_C ws member_of |
2011 apply clarify |
2011 apply clarify |
2012 apply rotate_tac |
2012 apply rotate_tac |
2013 by (auto simp add: dynmethd_rec) |
2013 by (auto simp add: dynmethd_rec) |
2014 |
2014 |
2015 lemma dynmethd_Some_cases [consumes 3, case_names Static Overrides]: |
2015 lemma dynmethd_Some_cases [consumes 3, case_names Static Overrides]: |
2016 (assumes dynM: "dynmethd G statC dynC sig = Some dynM" and |
2016 assumes dynM: "dynmethd G statC dynC sig = Some dynM" and |
2017 is_cls_dynC: "is_class G dynC" and |
2017 is_cls_dynC: "is_class G dynC" and |
2018 ws: "ws_prog G" and |
2018 ws: "ws_prog G" and |
2019 hyp_static: "methd G statC sig = Some dynM \<Longrightarrow> P" and |
2019 hyp_static: "methd G statC sig = Some dynM \<Longrightarrow> P" and |
2020 hyp_override: "\<And> statM. \<lbrakk>methd G statC sig = Some statM;dynM\<noteq>statM; |
2020 hyp_override: "\<And> statM. \<lbrakk>methd G statC sig = Some statM;dynM\<noteq>statM; |
2021 G,sig\<turnstile>dynM overrides statM\<rbrakk> \<Longrightarrow> P" |
2021 G,sig\<turnstile>dynM overrides statM\<rbrakk> \<Longrightarrow> P" |
2022 ) "P" |
2022 shows P |
2023 proof - |
2023 proof - |
2024 from is_cls_dynC obtain dc where clsDynC: "class G dynC = Some dc" by blast |
2024 from is_cls_dynC obtain dc where clsDynC: "class G dynC = Some dc" by blast |
2025 from clsDynC ws dynM hyp_static hyp_override |
2025 from clsDynC ws dynM hyp_static hyp_override |
2026 show "P" |
2026 show "P" |
2027 proof (induct rule: ws_class_induct) |
2027 proof (induct rule: ws_class_induct) |
2035 by (auto simp add: dynmethd_rec) |
2035 by (auto simp add: dynmethd_rec) |
2036 qed |
2036 qed |
2037 qed |
2037 qed |
2038 |
2038 |
2039 lemma no_override_in_Object: |
2039 lemma no_override_in_Object: |
2040 (assumes dynM: "dynmethd G statC dynC sig = Some dynM" and |
2040 assumes dynM: "dynmethd G statC dynC sig = Some dynM" and |
2041 is_cls_dynC: "is_class G dynC" and |
2041 is_cls_dynC: "is_class G dynC" and |
2042 ws: "ws_prog G" and |
2042 ws: "ws_prog G" and |
2043 statM: "methd G statC sig = Some statM" and |
2043 statM: "methd G statC sig = Some statM" and |
2044 neq_dynM_statM: "dynM\<noteq>statM" |
2044 neq_dynM_statM: "dynM\<noteq>statM" |
2045 ) |
2045 shows "dynC \<noteq> Object" |
2046 "dynC \<noteq> Object" |
|
2047 proof - |
2046 proof - |
2048 from is_cls_dynC obtain dc where clsDynC: "class G dynC = Some dc" by blast |
2047 from is_cls_dynC obtain dc where clsDynC: "class G dynC = Some dc" by blast |
2049 from clsDynC ws dynM statM neq_dynM_statM |
2048 from clsDynC ws dynM statM neq_dynM_statM |
2050 show ?thesis (is "?P dynC") |
2049 show ?thesis (is "?P dynC") |
2051 proof (induct rule: ws_class_induct) |
2050 proof (induct rule: ws_class_induct) |
2061 qed |
2060 qed |
2062 |
2061 |
2063 |
2062 |
2064 lemma dynmethd_Some_rec_cases [consumes 3, |
2063 lemma dynmethd_Some_rec_cases [consumes 3, |
2065 case_names Static Override Recursion]: |
2064 case_names Static Override Recursion]: |
2066 (assumes dynM: "dynmethd G statC dynC sig = Some dynM" and |
2065 assumes dynM: "dynmethd G statC dynC sig = Some dynM" and |
2067 clsDynC: "class G dynC = Some c" and |
2066 clsDynC: "class G dynC = Some c" and |
2068 ws: "ws_prog G" and |
2067 ws: "ws_prog G" and |
2069 hyp_static: "methd G statC sig = Some dynM \<Longrightarrow> P" and |
2068 hyp_static: "methd G statC sig = Some dynM \<Longrightarrow> P" and |
2070 hyp_override: "\<And> statM. \<lbrakk>methd G statC sig = Some statM; |
2069 hyp_override: "\<And> statM. \<lbrakk>methd G statC sig = Some statM; |
2071 methd G dynC sig = Some dynM; statM\<noteq>dynM; |
2070 methd G dynC sig = Some dynM; statM\<noteq>dynM; |
2072 G,sig\<turnstile> dynM overrides statM\<rbrakk> \<Longrightarrow> P" and |
2071 G,sig\<turnstile> dynM overrides statM\<rbrakk> \<Longrightarrow> P" and |
2073 |
2072 |
2074 hyp_recursion: "\<lbrakk>dynC\<noteq>Object; |
2073 hyp_recursion: "\<lbrakk>dynC\<noteq>Object; |
2075 dynmethd G statC (super c) sig = Some dynM\<rbrakk> \<Longrightarrow> P" |
2074 dynmethd G statC (super c) sig = Some dynM\<rbrakk> \<Longrightarrow> P" |
2076 ) "P" |
2075 shows P |
2077 proof - |
2076 proof - |
2078 from clsDynC have "is_class G dynC" by simp |
2077 from clsDynC have "is_class G dynC" by simp |
2079 note no_override_in_Object' = no_override_in_Object [OF dynM this ws] |
2078 note no_override_in_Object' = no_override_in_Object [OF dynM this ws] |
2080 from ws clsDynC dynM hyp_static hyp_override hyp_recursion |
2079 from ws clsDynC dynM hyp_static hyp_override hyp_recursion |
2081 show ?thesis |
2080 show ?thesis |
2137 qed |
2136 qed |
2138 qed |
2137 qed |
2139 qed |
2138 qed |
2140 |
2139 |
2141 lemma methd_Some_dynmethd_Some: |
2140 lemma methd_Some_dynmethd_Some: |
2142 (assumes statM: "methd G statC sig = Some statM" and |
2141 assumes statM: "methd G statC sig = Some statM" and |
2143 subclseq: "G\<turnstile>dynC \<preceq>\<^sub>C statC" and |
2142 subclseq: "G\<turnstile>dynC \<preceq>\<^sub>C statC" and |
2144 is_cls_statC: "is_class G statC" and |
2143 is_cls_statC: "is_class G statC" and |
2145 ws: "ws_prog G" |
2144 ws: "ws_prog G" |
2146 ) "\<exists> dynM. dynmethd G statC dynC sig = Some dynM" |
2145 shows "\<exists> dynM. dynmethd G statC dynC sig = Some dynM" |
2147 (is "?P dynC") |
2146 (is "?P dynC") |
2148 proof - |
2147 proof - |
2149 from subclseq is_cls_statC |
2148 from subclseq is_cls_statC |
2150 have is_cls_dynC: "is_class G dynC" by (rule subcls_is_class2) |
2149 have is_cls_dynC: "is_class G dynC" by (rule subcls_is_class2) |
2151 then obtain dc where |
2150 then obtain dc where |
2152 clsDynC: "class G dynC = Some dc" by blast |
2151 clsDynC: "class G dynC = Some dc" by blast |
2183 qed |
2182 qed |
2184 qed |
2183 qed |
2185 qed |
2184 qed |
2186 |
2185 |
2187 lemma dynmethd_cases [consumes 4, case_names Static Overrides]: |
2186 lemma dynmethd_cases [consumes 4, case_names Static Overrides]: |
2188 (assumes statM: "methd G statC sig = Some statM" and |
2187 assumes statM: "methd G statC sig = Some statM" and |
2189 subclseq: "G\<turnstile>dynC \<preceq>\<^sub>C statC" and |
2188 subclseq: "G\<turnstile>dynC \<preceq>\<^sub>C statC" and |
2190 is_cls_statC: "is_class G statC" and |
2189 is_cls_statC: "is_class G statC" and |
2191 ws: "ws_prog G" and |
2190 ws: "ws_prog G" and |
2192 hyp_static: "dynmethd G statC dynC sig = Some statM \<Longrightarrow> P" and |
2191 hyp_static: "dynmethd G statC dynC sig = Some statM \<Longrightarrow> P" and |
2193 hyp_override: "\<And> dynM. \<lbrakk>dynmethd G statC dynC sig = Some dynM; |
2192 hyp_override: "\<And> dynM. \<lbrakk>dynmethd G statC dynC sig = Some dynM; |
2194 dynM\<noteq>statM; |
2193 dynM\<noteq>statM; |
2195 G,sig\<turnstile>dynM overrides statM\<rbrakk> \<Longrightarrow> P" |
2194 G,sig\<turnstile>dynM overrides statM\<rbrakk> \<Longrightarrow> P" |
2196 ) "P" |
2195 shows P |
2197 proof - |
2196 proof - |
2198 from subclseq is_cls_statC |
2197 from subclseq is_cls_statC |
2199 have is_cls_dynC: "is_class G dynC" by (rule subcls_is_class2) |
2198 have is_cls_dynC: "is_class G dynC" by (rule subcls_is_class2) |
2200 then obtain dc where |
2199 then obtain dc where |
2201 clsDynC: "class G dynC = Some dc" by blast |
2200 clsDynC: "class G dynC = Some dc" by blast |
2213 with hyp_override dynM statM show ?thesis by simp |
2212 with hyp_override dynM statM show ?thesis by simp |
2214 qed |
2213 qed |
2215 qed |
2214 qed |
2216 |
2215 |
2217 lemma ws_dynmethd: |
2216 lemma ws_dynmethd: |
2218 (assumes statM: "methd G statC sig = Some statM" and |
2217 assumes statM: "methd G statC sig = Some statM" and |
2219 subclseq: "G\<turnstile>dynC \<preceq>\<^sub>C statC" and |
2218 subclseq: "G\<turnstile>dynC \<preceq>\<^sub>C statC" and |
2220 is_cls_statC: "is_class G statC" and |
2219 is_cls_statC: "is_class G statC" and |
2221 ws: "ws_prog G" |
2220 ws: "ws_prog G" |
2222 ) |
2221 shows |
2223 "\<exists> dynM. dynmethd G statC dynC sig = Some dynM \<and> |
2222 "\<exists> dynM. dynmethd G statC dynC sig = Some dynM \<and> |
2224 is_static dynM = is_static statM \<and> G\<turnstile>resTy dynM\<preceq>resTy statM" |
2223 is_static dynM = is_static statM \<and> G\<turnstile>resTy dynM\<preceq>resTy statM" |
2225 proof - |
2224 proof - |
2226 from statM subclseq is_cls_statC ws |
2225 from statM subclseq is_cls_statC ws |
2227 show ?thesis |
2226 show ?thesis |
2228 proof (cases rule: dynmethd_cases) |
2227 proof (cases rule: dynmethd_cases) |
2229 case Static |
2228 case Static |