71 by (simp add: unique_def fst_set image_comp) |
64 by (simp add: unique_def fst_set image_comp) |
72 qed |
65 qed |
73 qed |
66 qed |
74 |
67 |
75 lemma comp_unique: "unique (comp G) = unique G" |
68 lemma comp_unique: "unique (comp G) = unique G" |
76 apply (simp add: comp_def) |
69 apply (simp add: comp_def) |
77 apply (rule unique_map_fst) |
70 apply (rule unique_map_fst) |
78 apply (simp add: compClass_def split_beta) |
71 apply (simp add: compClass_def split_beta) |
79 done |
72 done |
80 |
73 |
81 |
74 |
82 (**********************************************************************) |
75 (**********************************************************************) |
83 (* invariance of properties under compilation *) |
76 (* invariance of properties under compilation *) |
84 |
77 |
85 lemma comp_class_imp: |
78 lemma comp_class_imp: |
86 "(class G C = Some(D, fs, ms)) \<Longrightarrow> |
79 "(class G C = Some(D, fs, ms)) \<Longrightarrow> |
87 (class (comp G) C = Some(D, fs, map (compMethod G C) ms))" |
80 (class (comp G) C = Some(D, fs, map (compMethod G C) ms))" |
88 apply (simp add: class_def comp_def compClass_def) |
81 apply (simp add: class_def comp_def compClass_def) |
89 apply (rule HOL.trans) |
82 apply (rule trans) |
90 apply (rule map_of_map2) |
83 apply (rule map_of_map2) |
91 apply auto |
84 apply auto |
92 done |
85 done |
93 |
86 |
94 lemma comp_class_None: |
87 lemma comp_class_None: |
95 "(class G C = None) = (class (comp G) C = None)" |
88 "(class G C = None) = (class (comp G) C = None)" |
96 apply (simp add: class_def comp_def compClass_def) |
89 apply (simp add: class_def comp_def compClass_def) |
97 apply (simp add: map_of_in_set) |
90 apply (simp add: map_of_in_set) |
98 apply (simp add: image_comp [symmetric] o_def split_beta) |
91 apply (simp add: image_comp [symmetric] o_def split_beta) |
99 done |
92 done |
100 |
93 |
101 lemma comp_is_class: "is_class (comp G) C = is_class G C" |
94 lemma comp_is_class: "is_class (comp G) C = is_class G C" |
102 by (cases "class G C") (auto simp: is_class_def comp_class_None dest: comp_class_imp) |
95 by (cases "class G C") (auto simp: is_class_def comp_class_None dest: comp_class_imp) |
103 |
96 |
104 |
97 |
105 lemma comp_is_type: "is_type (comp G) T = is_type G T" |
98 lemma comp_is_type: "is_type (comp G) T = is_type G T" |
106 apply (cases T) |
99 apply (cases T, simp) |
107 apply simp |
|
108 apply (induct G) |
100 apply (induct G) |
109 apply simp |
101 apply simp |
110 apply (simp only: comp_is_class) |
102 apply (simp only: comp_is_class) |
111 apply (simp add: comp_is_class) |
103 apply (simp add: comp_is_class) |
112 apply (simp only: comp_is_class) |
104 apply (simp only: comp_is_class) |
113 done |
105 done |
114 |
106 |
115 lemma comp_classname: "is_class G C |
107 lemma comp_classname: |
116 \<Longrightarrow> fst (the (class G C)) = fst (the (class (comp G) C))" |
108 "is_class G C \<Longrightarrow> fst (the (class G C)) = fst (the (class (comp G) C))" |
117 by (cases "class G C") (auto simp: is_class_def dest: comp_class_imp) |
109 by (cases "class G C") (auto simp: is_class_def dest: comp_class_imp) |
118 |
110 |
119 lemma comp_subcls1: "subcls1 (comp G) = subcls1 G" |
111 lemma comp_subcls1: "subcls1 (comp G) = subcls1 G" |
120 by (auto simp add: subcls1_def2 comp_classname comp_is_class) |
112 by (auto simp add: subcls1_def2 comp_classname comp_is_class) |
121 |
113 |
122 lemma comp_widen: "widen (comp G) = widen G" |
114 lemma comp_widen: "widen (comp G) = widen G" |
123 apply (simp add: fun_eq_iff) |
115 apply (simp add: fun_eq_iff) |
124 apply (intro allI iffI) |
116 apply (intro allI iffI) |
125 apply (erule widen.cases) |
117 apply (erule widen.cases) |
126 apply (simp_all add: comp_subcls1 widen.null) |
118 apply (simp_all add: comp_subcls1 widen.null) |
127 apply (erule widen.cases) |
119 apply (erule widen.cases) |
128 apply (simp_all add: comp_subcls1 widen.null) |
120 apply (simp_all add: comp_subcls1 widen.null) |
129 done |
121 done |
130 |
122 |
131 lemma comp_cast: "cast (comp G) = cast G" |
123 lemma comp_cast: "cast (comp G) = cast G" |
132 apply (simp add: fun_eq_iff) |
124 apply (simp add: fun_eq_iff) |
133 apply (intro allI iffI) |
125 apply (intro allI iffI) |
134 apply (erule cast.cases) |
126 apply (erule cast.cases) |
135 apply (simp_all add: comp_subcls1 cast.widen cast.subcls) |
127 apply (simp_all add: comp_subcls1 cast.widen cast.subcls) |
136 apply (rule cast.widen) apply (simp add: comp_widen) |
128 apply (rule cast.widen) |
|
129 apply (simp add: comp_widen) |
137 apply (erule cast.cases) |
130 apply (erule cast.cases) |
138 apply (simp_all add: comp_subcls1 cast.widen cast.subcls) |
131 apply (simp_all add: comp_subcls1 cast.widen cast.subcls) |
139 apply (rule cast.widen) apply (simp add: comp_widen) |
132 apply (rule cast.widen) |
|
133 apply (simp add: comp_widen) |
140 done |
134 done |
141 |
135 |
142 lemma comp_cast_ok: "cast_ok (comp G) = cast_ok G" |
136 lemma comp_cast_ok: "cast_ok (comp G) = cast_ok G" |
143 by (simp add: fun_eq_iff cast_ok_def comp_widen) |
137 by (simp add: fun_eq_iff cast_ok_def comp_widen) |
144 |
138 |
145 |
139 |
146 lemma compClass_fst [simp]: "(fst (compClass G C)) = (fst C)" |
140 lemma compClass_fst [simp]: "(fst (compClass G C)) = (fst C)" |
147 by (simp add: compClass_def split_beta) |
141 by (simp add: compClass_def split_beta) |
148 |
142 |
149 lemma compClass_fst_snd [simp]: "(fst (snd (compClass G C))) = (fst (snd C))" |
143 lemma compClass_fst_snd [simp]: "(fst (snd (compClass G C))) = (fst (snd C))" |
150 by (simp add: compClass_def split_beta) |
144 by (simp add: compClass_def split_beta) |
151 |
145 |
152 lemma compClass_fst_snd_snd [simp]: "(fst (snd (snd (compClass G C)))) = (fst (snd (snd C)))" |
146 lemma compClass_fst_snd_snd [simp]: "(fst (snd (snd (compClass G C)))) = (fst (snd (snd C)))" |
153 by (simp add: compClass_def split_beta) |
147 by (simp add: compClass_def split_beta) |
154 |
148 |
155 lemma comp_wf_fdecl [simp]: "wf_fdecl (comp G) fd = wf_fdecl G fd" |
149 lemma comp_wf_fdecl [simp]: "wf_fdecl (comp G) fd = wf_fdecl G fd" |
156 by (cases fd) (simp add: wf_fdecl_def comp_is_type) |
150 by (cases fd) (simp add: wf_fdecl_def comp_is_type) |
157 |
151 |
158 |
152 |
159 lemma compClass_forall [simp]: " |
153 lemma compClass_forall [simp]: |
160 (\<forall>x\<in>set (snd (snd (snd (compClass G C)))). P (fst x) (fst (snd x))) = |
154 "(\<forall>x\<in>set (snd (snd (snd (compClass G C)))). P (fst x) (fst (snd x))) = |
161 (\<forall>x\<in>set (snd (snd (snd C))). P (fst x) (fst (snd x)))" |
155 (\<forall>x\<in>set (snd (snd (snd C))). P (fst x) (fst (snd x)))" |
162 by (simp add: compClass_def compMethod_def split_beta) |
156 by (simp add: compClass_def compMethod_def split_beta) |
163 |
157 |
164 lemma comp_wf_mhead: "wf_mhead (comp G) S rT = wf_mhead G S rT" |
158 lemma comp_wf_mhead: "wf_mhead (comp G) S rT = wf_mhead G S rT" |
165 by (simp add: wf_mhead_def split_beta comp_is_type) |
159 by (simp add: wf_mhead_def split_beta comp_is_type) |
166 |
160 |
167 lemma comp_ws_cdecl: " |
161 lemma comp_ws_cdecl: |
168 ws_cdecl (TranslComp.comp G) (compClass G C) = ws_cdecl G C" |
162 "ws_cdecl (TranslComp.comp G) (compClass G C) = ws_cdecl G C" |
169 apply (simp add: ws_cdecl_def split_beta comp_is_class comp_subcls1) |
163 apply (simp add: ws_cdecl_def split_beta comp_is_class comp_subcls1) |
170 apply (simp (no_asm_simp) add: comp_wf_mhead) |
164 apply (simp (no_asm_simp) add: comp_wf_mhead) |
171 apply (simp add: compClass_def compMethod_def split_beta unique_map_fst) |
165 apply (simp add: compClass_def compMethod_def split_beta unique_map_fst) |
172 done |
166 done |
173 |
167 |
174 |
168 |
175 lemma comp_wf_syscls: "wf_syscls (comp G) = wf_syscls G" |
169 lemma comp_wf_syscls: "wf_syscls (comp G) = wf_syscls G" |
176 apply (simp add: wf_syscls_def comp_def compClass_def split_beta) |
170 apply (simp add: wf_syscls_def comp_def compClass_def split_beta) |
177 apply (simp add: image_comp) |
171 apply (simp add: image_comp) |
178 apply (subgoal_tac "(Fun.comp fst (\<lambda>(C, cno::cname, fdls::fdecl list, jmdls). |
172 apply (subgoal_tac "(Fun.comp fst (\<lambda>(C, cno::cname, fdls::fdecl list, jmdls). |
179 (C, cno, fdls, map (compMethod G C) jmdls))) = fst") |
173 (C, cno, fdls, map (compMethod G C) jmdls))) = fst") |
180 apply simp |
174 apply simp |
181 apply (simp add: fun_eq_iff split_beta) |
175 apply (simp add: fun_eq_iff split_beta) |
182 done |
176 done |
183 |
177 |
184 |
178 |
185 lemma comp_ws_prog: "ws_prog (comp G) = ws_prog G" |
179 lemma comp_ws_prog: "ws_prog (comp G) = ws_prog G" |
186 apply (rule sym) |
180 apply (rule sym) |
187 apply (simp add: ws_prog_def comp_ws_cdecl comp_unique) |
181 apply (simp add: ws_prog_def comp_ws_cdecl comp_unique) |
188 apply (simp add: comp_wf_syscls) |
182 apply (simp add: comp_wf_syscls) |
189 apply (auto simp add: comp_ws_cdecl [symmetric] TranslComp.comp_def) |
183 apply (auto simp add: comp_ws_cdecl [symmetric] TranslComp.comp_def) |
190 done |
184 done |
191 |
185 |
192 |
186 |
193 lemma comp_class_rec: " wf ((subcls1 G)^-1) \<Longrightarrow> |
187 lemma comp_class_rec: |
194 class_rec (comp G) C t f = |
188 "wf ((subcls1 G)^-1) \<Longrightarrow> |
|
189 class_rec (comp G) C t f = |
195 class_rec G C t (\<lambda> C' fs' ms' r'. f C' fs' (map (compMethod G C') ms') r')" |
190 class_rec G C t (\<lambda> C' fs' ms' r'. f C' fs' (map (compMethod G C') ms') r')" |
196 apply (rule_tac a = C in wf_induct) apply assumption |
191 apply (rule_tac a = C in wf_induct) |
197 apply (subgoal_tac "wf ((subcls1 (comp G))^-1)") |
192 apply assumption |
198 apply (subgoal_tac "(class G x = None) \<or> (\<exists> D fs ms. (class G x = Some (D, fs, ms)))") |
193 apply (subgoal_tac "wf ((subcls1 (comp G))^-1)") |
199 apply (erule disjE) |
194 apply (subgoal_tac "(class G x = None) \<or> (\<exists> D fs ms. (class G x = Some (D, fs, ms)))") |
200 |
195 apply (erule disjE) |
201 (* case class G x = None *) |
196 |
202 apply (simp (no_asm_simp) add: class_rec_def comp_subcls1 |
197 (* case class G x = None *) |
203 wfrec [where R="(subcls1 G)^-1", simplified]) |
198 apply (simp (no_asm_simp) add: class_rec_def comp_subcls1 |
204 apply (simp add: comp_class_None) |
199 wfrec [where R="(subcls1 G)^-1", simplified]) |
205 |
200 apply (simp add: comp_class_None) |
206 (* case \<exists> D fs ms. (class G x = Some (D, fs, ms)) *) |
201 |
207 apply (erule exE)+ |
202 (* case \<exists> D fs ms. (class G x = Some (D, fs, ms)) *) |
208 apply (frule comp_class_imp) |
203 apply (erule exE)+ |
209 apply (frule_tac G="comp G" and C=x and t=t and f=f in class_rec_lemma) |
204 apply (frule comp_class_imp) |
210 apply assumption |
205 apply (frule_tac G="comp G" and C=x and t=t and f=f in class_rec_lemma) |
211 apply (frule_tac G=G and C=x and t=t |
206 apply assumption |
212 and f="(\<lambda>C' fs' ms'. f C' fs' (map (compMethod G C') ms'))" in class_rec_lemma) |
207 apply (frule_tac G=G and C=x and t=t |
213 apply assumption |
208 and f="(\<lambda>C' fs' ms'. f C' fs' (map (compMethod G C') ms'))" in class_rec_lemma) |
214 apply (simp only:) |
209 apply assumption |
215 |
210 apply (simp only:) |
216 apply (case_tac "x = Object") |
211 apply (case_tac "x = Object") |
217 apply simp |
212 apply simp |
218 apply (frule subcls1I, assumption) |
213 apply (frule subcls1I, assumption) |
219 apply (drule_tac x=D in spec, drule mp, simp) |
214 apply (drule_tac x=D in spec, drule mp, simp) |
220 apply simp |
215 apply simp |
221 |
216 |
222 (* subgoals *) |
217 (* subgoals *) |
223 apply (case_tac "class G x") |
218 apply (case_tac "class G x") |
224 apply auto |
219 apply auto |
225 apply (simp add: comp_subcls1) |
220 apply (simp add: comp_subcls1) |
226 done |
221 done |
227 |
222 |
228 lemma comp_fields: "wf ((subcls1 G)^-1) \<Longrightarrow> |
223 lemma comp_fields: "wf ((subcls1 G)^-1) \<Longrightarrow> |
229 fields (comp G,C) = fields (G,C)" |
224 fields (comp G,C) = fields (G,C)" |
230 by (simp add: fields_def comp_class_rec) |
225 by (simp add: fields_def comp_class_rec) |
231 |
226 |
232 lemma comp_field: "wf ((subcls1 G)^-1) \<Longrightarrow> |
227 lemma comp_field: "wf ((subcls1 G)^-1) \<Longrightarrow> |
233 field (comp G,C) = field (G,C)" |
228 field (comp G,C) = field (G,C)" |
234 by (simp add: TypeRel.field_def comp_fields) |
229 by (simp add: TypeRel.field_def comp_fields) |
235 |
|
236 |
230 |
237 |
231 |
238 lemma class_rec_relation [rule_format (no_asm)]: "\<lbrakk> ws_prog G; |
232 lemma class_rec_relation [rule_format (no_asm)]: "\<lbrakk> ws_prog G; |
239 \<forall> fs ms. R (f1 Object fs ms t1) (f2 Object fs ms t2); |
233 \<forall>fs ms. R (f1 Object fs ms t1) (f2 Object fs ms t2); |
240 \<forall> C fs ms r1 r2. (R r1 r2) \<longrightarrow> (R (f1 C fs ms r1) (f2 C fs ms r2)) \<rbrakk> |
234 \<forall>C fs ms r1 r2. (R r1 r2) \<longrightarrow> (R (f1 C fs ms r1) (f2 C fs ms r2)) \<rbrakk> |
241 \<Longrightarrow> ((class G C) \<noteq> None) \<longrightarrow> |
235 \<Longrightarrow> ((class G C) \<noteq> None) \<longrightarrow> R (class_rec G C t1 f1) (class_rec G C t2 f2)" |
242 R (class_rec G C t1 f1) (class_rec G C t2 f2)" |
236 apply (frule wf_subcls1) (* establish wf ((subcls1 G)^-1) *) |
243 apply (frule wf_subcls1) (* establish wf ((subcls1 G)^-1) *) |
237 apply (rule_tac a = C in wf_induct) |
244 apply (rule_tac a = C in wf_induct) apply assumption |
238 apply assumption |
245 apply (intro strip) |
239 apply (intro strip) |
246 apply (subgoal_tac "(\<exists>D rT mb. class G x = Some (D, rT, mb))") |
240 apply (subgoal_tac "(\<exists>D rT mb. class G x = Some (D, rT, mb))") |
247 apply (erule exE)+ |
241 apply (erule exE)+ |
248 apply (frule_tac C=x and t=t1 and f=f1 in class_rec_lemma) |
242 apply (frule_tac C=x and t=t1 and f=f1 in class_rec_lemma) |
249 apply assumption |
243 apply assumption |
250 apply (frule_tac C=x and t=t2 and f=f2 in class_rec_lemma) |
244 apply (frule_tac C=x and t=t2 and f=f2 in class_rec_lemma) |
251 apply assumption |
245 apply assumption |
252 apply (simp only:) |
246 apply (simp only:) |
253 |
247 |
254 apply (case_tac "x = Object") |
248 apply (case_tac "x = Object") |
255 apply simp |
|
256 apply (frule subcls1I, assumption) |
|
257 apply (drule_tac x=D in spec, drule mp, simp) |
|
258 apply simp |
249 apply simp |
259 apply (subgoal_tac "(\<exists>D' rT' mb'. class G D = Some (D', rT', mb'))") |
250 apply (frule subcls1I, assumption) |
|
251 apply (drule_tac x=D in spec, drule mp, simp) |
|
252 apply simp |
|
253 apply (subgoal_tac "(\<exists>D' rT' mb'. class G D = Some (D', rT', mb'))") |
260 apply blast |
254 apply blast |
261 |
255 |
262 (* subgoals *) |
256 (* subgoals *) |
263 |
257 apply (frule class_wf_struct, assumption) |
264 apply (frule class_wf_struct) apply assumption |
258 apply (simp add: ws_cdecl_def is_class_def) |
265 apply (simp add: ws_cdecl_def is_class_def) |
259 apply (simp add: subcls1_def2 is_class_def) |
266 |
260 apply auto |
267 apply (simp add: subcls1_def2 is_class_def) |
261 done |
268 apply auto |
|
269 done |
|
270 |
262 |
271 |
263 |
272 abbreviation (input) |
264 abbreviation (input) |
273 "mtd_mb == snd o snd" |
265 "mtd_mb == snd o snd" |
274 |
266 |
275 lemma map_of_map: |
267 lemma map_of_map: |
276 "map_of (map (\<lambda>(k, v). (k, f v)) xs) k = map_option f (map_of xs k)" |
268 "map_of (map (\<lambda>(k, v). (k, f v)) xs) k = map_option f (map_of xs k)" |
277 by (simp add: map_of_map) |
269 by (simp add: map_of_map) |
278 |
270 |
279 lemma map_of_map_fst: "\<lbrakk> inj f; |
271 lemma map_of_map_fst: |
280 \<forall>x\<in>set xs. fst (f x) = fst x; \<forall>x\<in>set xs. fst (g x) = fst x \<rbrakk> |
272 "\<lbrakk> inj f; \<forall>x\<in>set xs. fst (f x) = fst x; \<forall>x\<in>set xs. fst (g x) = fst x \<rbrakk> |
281 \<Longrightarrow> map_of (map g xs) k |
273 \<Longrightarrow> map_of (map g xs) k = map_option (\<lambda> e. (snd (g ((inv f) (k, e))))) (map_of (map f xs) k)" |
282 = map_option (\<lambda> e. (snd (g ((inv f) (k, e))))) (map_of (map f xs) k)" |
274 apply (induct xs) |
283 apply (induct xs) |
275 apply simp |
284 apply simp |
276 apply simp |
285 apply simp |
277 apply (case_tac "k = fst a") |
286 apply (case_tac "k = fst a") |
278 apply simp |
287 apply simp |
279 apply (subgoal_tac "(inv f (fst a, snd (f a))) = a", simp) |
288 apply (subgoal_tac "(inv f (fst a, snd (f a))) = a", simp) |
280 apply (subgoal_tac "(fst a, snd (f a)) = f a", simp) |
289 apply (subgoal_tac "(fst a, snd (f a)) = f a", simp) |
281 apply (erule conjE)+ |
290 apply (erule conjE)+ |
282 apply (drule_tac s ="fst (f a)" and t="fst a" in sym) |
291 apply (drule_tac s ="fst (f a)" and t="fst a" in sym) |
283 apply simp |
292 apply simp |
284 apply (simp add: surjective_pairing) |
293 apply (simp add: surjective_pairing) |
285 done |
294 done |
286 |
295 |
287 lemma comp_method [rule_format (no_asm)]: |
296 lemma comp_method [rule_format (no_asm)]: "\<lbrakk> ws_prog G; is_class G C\<rbrakk> \<Longrightarrow> |
288 "\<lbrakk> ws_prog G; is_class G C\<rbrakk> \<Longrightarrow> |
297 ((method (comp G, C) S) = |
289 ((method (comp G, C) S) = |
298 map_option (\<lambda> (D,rT,b). (D, rT, mtd_mb (compMethod G D (S, rT, b)))) |
290 map_option (\<lambda> (D,rT,b). (D, rT, mtd_mb (compMethod G D (S, rT, b)))) |
299 (method (G, C) S))" |
291 (method (G, C) S))" |
300 apply (simp add: method_def) |
292 apply (simp add: method_def) |
301 apply (frule wf_subcls1) |
293 apply (frule wf_subcls1) |
302 apply (simp add: comp_class_rec) |
294 apply (simp add: comp_class_rec) |
303 apply (simp add: split_iter split_compose map_map [symmetric] del: map_map) |
295 apply (simp add: split_iter split_compose map_map [symmetric] del: map_map) |
304 apply (rule_tac R="%x y. ((x S) = (map_option (\<lambda>(D, rT, b). |
296 apply (rule_tac R="\<lambda>x y. ((x S) = (map_option (\<lambda>(D, rT, b). |
305 (D, rT, snd (snd (compMethod G D (S, rT, b))))) (y S)))" |
297 (D, rT, snd (snd (compMethod G D (S, rT, b))))) (y S)))" |
306 in class_rec_relation) |
298 in class_rec_relation) |
307 apply assumption |
299 apply assumption |
308 |
300 |
309 apply (intro strip) |
301 apply (intro strip) |
310 apply simp |
302 apply simp |
311 |
303 apply (rule trans) |
312 apply (rule trans) |
304 |
313 |
305 apply (rule_tac f="(\<lambda>(s, m). (s, Object, m))" and |
314 apply (rule_tac f="(\<lambda>(s, m). (s, Object, m))" and |
306 g="(Fun.comp (\<lambda>(s, m). (s, Object, m)) (compMethod G Object))" |
315 g="(Fun.comp (\<lambda>(s, m). (s, Object, m)) (compMethod G Object))" |
307 in map_of_map_fst) |
316 in map_of_map_fst) |
308 defer (* inj \<dots> *) |
317 defer (* inj \<dots> *) |
309 apply (simp add: inj_on_def split_beta) |
318 apply (simp add: inj_on_def split_beta) |
310 apply (simp add: split_beta compMethod_def) |
319 apply (simp add: split_beta compMethod_def) |
311 apply (simp add: map_of_map [symmetric]) |
320 apply (simp add: map_of_map [symmetric]) |
312 apply (simp add: split_beta) |
321 apply (simp add: split_beta) |
313 apply (simp add: Fun.comp_def split_beta) |
322 apply (simp add: Fun.comp_def split_beta) |
314 apply (subgoal_tac "(\<lambda>x\<Colon>(vname list \<times> fdecl list \<times> stmt \<times> expr) mdecl. |
323 apply (subgoal_tac "(\<lambda>x\<Colon>(vname list \<times> fdecl list \<times> stmt \<times> expr) mdecl. |
315 (fst x, Object, |
324 (fst x, Object, |
316 snd (compMethod G Object |
325 snd (compMethod G Object |
317 (inv (\<lambda>(s\<Colon>sig, m\<Colon>ty \<times> vname list \<times> fdecl list \<times> stmt \<times> expr). |
326 (inv (\<lambda>(s\<Colon>sig, m\<Colon>ty \<times> vname list \<times> fdecl list \<times> stmt \<times> expr). |
318 (s, Object, m)) |
327 (s, Object, m)) |
319 (S, Object, snd x))))) |
328 (S, Object, snd x))))) |
320 = (\<lambda>x. (fst x, Object, fst (snd x), |
329 = (\<lambda>x. (fst x, Object, fst (snd x), |
321 snd (snd (compMethod G Object (S, snd x)))))") |
330 snd (snd (compMethod G Object (S, snd x)))))") |
322 apply (simp only:) |
331 apply (simp only:) |
323 apply (simp add: fun_eq_iff) |
332 apply (simp add: fun_eq_iff) |
324 apply (intro strip) |
333 apply (intro strip) |
325 apply (subgoal_tac "(inv (\<lambda>(s, m). (s, Object, m)) (S, Object, snd x)) = (S, snd x)") |
334 apply (subgoal_tac "(inv (\<lambda>(s, m). (s, Object, m)) (S, Object, snd x)) = (S, snd x)") |
326 apply (simp only:) |
335 apply (simp only:) |
327 apply (simp add: compMethod_def split_beta) |
336 apply (simp add: compMethod_def split_beta) |
328 apply (rule inv_f_eq) |
337 apply (rule inv_f_eq) |
329 defer |
338 defer |
330 defer |
339 defer |
331 |
340 |
332 apply (intro strip) |
341 apply (intro strip) |
333 apply (simp add: map_add_Some_iff map_of_map) |
342 apply (simp add: map_add_Some_iff map_of_map) |
334 apply (simp add: map_add_def) |
343 apply (simp add: map_add_def) |
335 apply (subgoal_tac "inj (\<lambda>(s, m). (s, Ca, m))") |
344 apply (subgoal_tac "inj (\<lambda>(s, m). (s, Ca, m))") |
336 apply (drule_tac g="(Fun.comp (\<lambda>(s, m). (s, Ca, m)) (compMethod G Ca))" and xs=ms |
345 apply (drule_tac g="(Fun.comp (\<lambda>(s, m). (s, Ca, m)) (compMethod G Ca))" and xs=ms |
337 and k=S in map_of_map_fst) |
346 and k=S in map_of_map_fst) |
338 apply (simp add: split_beta) |
347 apply (simp add: split_beta) |
339 apply (simp add: compMethod_def split_beta) |
348 apply (simp add: compMethod_def split_beta) |
340 apply (case_tac "(map_of (map (\<lambda>(s, m). (s, Ca, m)) ms) S)") |
349 apply (case_tac "(map_of (map (\<lambda>(s, m). (s, Ca, m)) ms) S)") |
341 apply simp |
350 apply simp |
342 apply (simp add: split_beta map_of_map) |
351 apply simp apply (simp add: split_beta map_of_map) apply (erule exE) apply (erule conjE)+ |
343 apply (elim exE conjE) |
352 apply (drule_tac t=a in sym) |
344 apply (drule_tac t=a in sym) |
353 apply (subgoal_tac "(inv (\<lambda>(s, m). (s, Ca, m)) (S, a)) = (S, snd a)") |
345 apply (subgoal_tac "(inv (\<lambda>(s, m). (s, Ca, m)) (S, a)) = (S, snd a)") |
354 apply simp |
346 apply simp |
355 apply (subgoal_tac "\<forall>x\<in>set ms. fst ((Fun.comp (\<lambda>(s, m). (s, Ca, m)) (compMethod G Ca)) x) = fst x") |
347 apply (subgoal_tac "\<forall>x\<in>set ms. fst ((Fun.comp (\<lambda>(s, m). (s, Ca, m)) (compMethod G Ca)) x) = fst x") |
356 prefer 2 apply (simp (no_asm_simp) add: compMethod_def split_beta) |
348 prefer 2 apply (simp (no_asm_simp) add: compMethod_def split_beta) |
357 apply (simp add: map_of_map2) |
349 apply (simp add: map_of_map2) |
358 apply (simp (no_asm_simp) add: compMethod_def split_beta) |
350 apply (simp (no_asm_simp) add: compMethod_def split_beta) |
359 |
351 |
360 -- "remaining subgoals" |
352 -- "remaining subgoals" |
361 apply (auto intro: inv_f_eq simp add: inj_on_def is_class_def) |
353 apply (auto intro: inv_f_eq simp add: inj_on_def is_class_def) |
362 done |
354 done |
363 |
355 |
364 |
356 |
365 |
357 |
366 lemma comp_wf_mrT: "\<lbrakk> ws_prog G; is_class G D\<rbrakk> \<Longrightarrow> |
358 lemma comp_wf_mrT: "\<lbrakk> ws_prog G; is_class G D\<rbrakk> \<Longrightarrow> |
367 wf_mrT (TranslComp.comp G) (C, D, fs, map (compMethod G a) ms) = |
359 wf_mrT (TranslComp.comp G) (C, D, fs, map (compMethod G a) ms) = |
368 wf_mrT G (C, D, fs, ms)" |
360 wf_mrT G (C, D, fs, ms)" |
369 apply (simp add: wf_mrT_def compMethod_def split_beta) |
361 apply (simp add: wf_mrT_def compMethod_def split_beta) |
370 apply (simp add: comp_widen) |
362 apply (simp add: comp_widen) |
371 apply (rule iffI) |
363 apply (rule iffI) |
372 apply (intro strip) |
364 apply (intro strip) |
373 apply simp |
365 apply simp |
374 apply (drule bspec) apply assumption |
366 apply (drule (1) bspec) |
375 apply (drule_tac x=D' in spec) apply (drule_tac x=rT' in spec) apply (drule mp) |
367 apply (drule_tac x=D' in spec) |
376 prefer 2 apply assumption |
368 apply (drule_tac x=rT' in spec) |
377 apply (simp add: comp_method [of G D]) |
369 apply (drule mp) |
378 apply (erule exE)+ |
370 prefer 2 apply assumption |
379 apply (simp add: split_paired_all) |
371 apply (simp add: comp_method [of G D]) |
380 apply (intro strip) |
372 apply (erule exE)+ |
381 apply (simp add: comp_method) |
373 apply (simp add: split_paired_all) |
382 apply auto |
374 apply (auto simp: comp_method) |
383 done |
375 done |
384 |
376 |
385 |
377 |
386 (**********************************************************************) |
378 (**********************************************************************) |
387 (* DIVERSE OTHER LEMMAS *) |
379 (* DIVERSE OTHER LEMMAS *) |
388 (**********************************************************************) |
380 (**********************************************************************) |
389 |
381 |
390 lemma max_spec_preserves_length: |
382 lemma max_spec_preserves_length: |
391 "max_spec G C (mn, pTs) = {((md,rT),pTs')} |
383 "max_spec G C (mn, pTs) = {((md,rT),pTs')} \<Longrightarrow> length pTs = length pTs'" |
392 \<Longrightarrow> length pTs = length pTs'" |
384 apply (frule max_spec2mheads) |
393 apply (frule max_spec2mheads) |
385 apply (clarsimp simp: list_all2_iff) |
394 apply (erule exE)+ |
386 done |
395 apply (simp add: list_all2_iff) |
|
396 done |
|
397 |
387 |
398 |
388 |
399 lemma ty_exprs_length [simp]: "(E\<turnstile>es[::]Ts \<longrightarrow> length es = length Ts)" |
389 lemma ty_exprs_length [simp]: "(E\<turnstile>es[::]Ts \<longrightarrow> length es = length Ts)" |
400 apply (subgoal_tac "(E\<turnstile>e::T \<longrightarrow> True) \<and> (E\<turnstile>es[::]Ts \<longrightarrow> length es = length Ts) \<and> (E\<turnstile>s\<surd> \<longrightarrow> True)") |
390 apply (subgoal_tac "(E\<turnstile>e::T \<longrightarrow> True) \<and> (E\<turnstile>es[::]Ts \<longrightarrow> length es = length Ts) \<and> (E\<turnstile>s\<surd> \<longrightarrow> True)") |
401 apply blast |
391 apply blast |
402 apply (rule ty_expr_ty_exprs_wt_stmt.induct) |
392 apply (rule ty_expr_ty_exprs_wt_stmt.induct, auto) |
403 apply auto |
393 done |
404 done |
|
405 |
394 |
406 |
395 |
407 lemma max_spec_preserves_method_rT [simp]: |
396 lemma max_spec_preserves_method_rT [simp]: |
408 "max_spec G C (mn, pTs) = {((md,rT),pTs')} |
397 "max_spec G C (mn, pTs) = {((md,rT),pTs')} |
409 \<Longrightarrow> method_rT (the (method (G, C) (mn, pTs'))) = rT" |
398 \<Longrightarrow> method_rT (the (method (G, C) (mn, pTs'))) = rT" |
410 apply (frule max_spec2mheads) |
399 apply (frule max_spec2mheads) |
411 apply (erule exE)+ |
400 apply (clarsimp simp: method_rT_def) |
412 apply (simp add: method_rT_def) |
401 done |
413 done |
|
414 |
402 |
415 (**********************************************************************************) |
403 (**********************************************************************************) |
|
404 |
|
405 end (* context *) |
416 |
406 |
417 declare compClass_fst [simp del] |
407 declare compClass_fst [simp del] |
418 declare compClass_fst_snd [simp del] |
408 declare compClass_fst_snd [simp del] |
419 declare compClass_fst_snd_snd [simp del] |
409 declare compClass_fst_snd_snd [simp del] |
420 |
410 |
421 declare split_paired_All [simp add] |
|
422 declare split_paired_Ex [simp add] |
|
423 |
|
424 end |
411 end |