114 done |
114 done |
115 |
115 |
116 lemma is_lub_thelub0: "\<lbrakk>\<exists>u. S <<| u; S <| x\<rbrakk> \<Longrightarrow> lub S \<sqsubseteq> x" |
116 lemma is_lub_thelub0: "\<lbrakk>\<exists>u. S <<| u; S <| x\<rbrakk> \<Longrightarrow> lub S \<sqsubseteq> x" |
117 by (erule exE, drule lubI, erule is_lub_lub) |
117 by (erule exE, drule lubI, erule is_lub_lub) |
118 |
118 |
119 locale plotkin_order = preorder r + |
119 locale basis_take = preorder r + |
120 fixes take :: "nat \<Rightarrow> 'a::type \<Rightarrow> 'a" |
120 fixes take :: "nat \<Rightarrow> 'a::type \<Rightarrow> 'a" |
121 assumes take_less: "r (take n a) a" |
121 assumes take_less: "r (take n a) a" |
122 assumes take_take: "take n (take n a) = take n a" |
122 assumes take_take: "take n (take n a) = take n a" |
123 assumes take_mono: "r a b \<Longrightarrow> r (take n a) (take n b)" |
123 assumes take_mono: "r a b \<Longrightarrow> r (take n a) (take n b)" |
124 assumes take_chain: "r (take n a) (take (Suc n) a)" |
124 assumes take_chain: "r (take n a) (take (Suc n) a)" |
125 assumes finite_range_take: "finite (range (take n))" |
125 assumes finite_range_take: "finite (range (take n))" |
126 assumes take_covers: "\<exists>n. take n a = a" |
126 assumes take_covers: "\<exists>n. take n a = a" |
127 |
127 |
128 locale bifinite_basis = plotkin_order r + |
128 locale ideal_completion = basis_take r + |
129 fixes principal :: "'a::type \<Rightarrow> 'b::cpo" |
129 fixes principal :: "'a::type \<Rightarrow> 'b::cpo" |
130 fixes approxes :: "'b::cpo \<Rightarrow> 'a::type set" |
130 fixes rep :: "'b::cpo \<Rightarrow> 'a::type set" |
131 assumes ideal_approxes: "\<And>x. preorder.ideal r (approxes x)" |
131 assumes ideal_rep: "\<And>x. preorder.ideal r (rep x)" |
132 assumes cont_approxes: "cont approxes" |
132 assumes cont_rep: "cont rep" |
133 assumes approxes_principal: "\<And>a. approxes (principal a) = {b. r b a}" |
133 assumes rep_principal: "\<And>a. rep (principal a) = {b. r b a}" |
134 assumes subset_approxesD: "\<And>x y. approxes x \<subseteq> approxes y \<Longrightarrow> x \<sqsubseteq> y" |
134 assumes subset_repD: "\<And>x y. rep x \<subseteq> rep y \<Longrightarrow> x \<sqsubseteq> y" |
135 begin |
135 begin |
136 |
136 |
137 lemma finite_take_approxes: "finite (take n ` approxes x)" |
137 lemma finite_take_rep: "finite (take n ` rep x)" |
138 by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range_take]) |
138 by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range_take]) |
139 |
139 |
140 lemma basis_fun_lemma0: |
140 lemma basis_fun_lemma0: |
141 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
141 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
142 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
142 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
143 shows "\<exists>u. f ` take i ` approxes x <<| u" |
143 shows "\<exists>u. f ` take i ` rep x <<| u" |
144 apply (rule finite_directed_has_lub) |
144 apply (rule finite_directed_has_lub) |
145 apply (rule finite_imageI) |
145 apply (rule finite_imageI) |
146 apply (rule finite_take_approxes) |
146 apply (rule finite_take_rep) |
147 apply (subst image_image) |
147 apply (subst image_image) |
148 apply (rule directed_image_ideal) |
148 apply (rule directed_image_ideal) |
149 apply (rule ideal_approxes) |
149 apply (rule ideal_rep) |
150 apply (rule f_mono) |
150 apply (rule f_mono) |
151 apply (erule take_mono) |
151 apply (erule take_mono) |
152 done |
152 done |
153 |
153 |
154 lemma basis_fun_lemma1: |
154 lemma basis_fun_lemma1: |
155 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
155 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
156 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
156 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
157 shows "chain (\<lambda>i. lub (f ` take i ` approxes x))" |
157 shows "chain (\<lambda>i. lub (f ` take i ` rep x))" |
158 apply (rule chainI) |
158 apply (rule chainI) |
159 apply (rule is_lub_thelub0) |
159 apply (rule is_lub_thelub0) |
160 apply (rule basis_fun_lemma0, erule f_mono) |
160 apply (rule basis_fun_lemma0, erule f_mono) |
161 apply (rule is_ubI, clarsimp, rename_tac a) |
161 apply (rule is_ubI, clarsimp, rename_tac a) |
162 apply (rule sq_le.trans_less [OF f_mono [OF take_chain]]) |
162 apply (rule sq_le.trans_less [OF f_mono [OF take_chain]]) |
189 done |
189 done |
190 |
190 |
191 lemma basis_fun_lemma: |
191 lemma basis_fun_lemma: |
192 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
192 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
193 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
193 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
194 shows "\<exists>u. f ` approxes x <<| u" |
194 shows "\<exists>u. f ` rep x <<| u" |
195 by (rule exI, rule basis_fun_lemma2, erule f_mono) |
195 by (rule exI, rule basis_fun_lemma2, erule f_mono) |
196 |
196 |
197 lemma approxes_mono: "x \<sqsubseteq> y \<Longrightarrow> approxes x \<subseteq> approxes y" |
197 lemma rep_mono: "x \<sqsubseteq> y \<Longrightarrow> rep x \<subseteq> rep y" |
198 apply (drule cont_approxes [THEN cont2mono, THEN monofunE]) |
198 apply (drule cont_rep [THEN cont2mono, THEN monofunE]) |
199 apply (simp add: set_cpo_simps) |
199 apply (simp add: set_cpo_simps) |
200 done |
200 done |
201 |
201 |
202 lemma approxes_contlub: |
202 lemma rep_contlub: |
203 "chain Y \<Longrightarrow> approxes (\<Squnion>i. Y i) = (\<Union>i. approxes (Y i))" |
203 "chain Y \<Longrightarrow> rep (\<Squnion>i. Y i) = (\<Union>i. rep (Y i))" |
204 by (simp add: cont2contlubE [OF cont_approxes] set_cpo_simps) |
204 by (simp add: cont2contlubE [OF cont_rep] set_cpo_simps) |
205 |
205 |
206 lemma less_def: "(x \<sqsubseteq> y) = (approxes x \<subseteq> approxes y)" |
206 lemma less_def: "x \<sqsubseteq> y \<longleftrightarrow> rep x \<subseteq> rep y" |
207 by (rule iffI [OF approxes_mono subset_approxesD]) |
207 by (rule iffI [OF rep_mono subset_repD]) |
208 |
208 |
209 lemma approxes_eq: "approxes x = {a. principal a \<sqsubseteq> x}" |
209 lemma rep_eq: "rep x = {a. principal a \<sqsubseteq> x}" |
210 unfolding less_def approxes_principal |
210 unfolding less_def rep_principal |
211 apply safe |
211 apply safe |
212 apply (erule (1) idealD3 [OF ideal_approxes]) |
212 apply (erule (1) idealD3 [OF ideal_rep]) |
213 apply (erule subsetD, simp add: refl) |
213 apply (erule subsetD, simp add: refl) |
214 done |
214 done |
215 |
215 |
216 lemma mem_approxes_iff: "(a \<in> approxes x) = (principal a \<sqsubseteq> x)" |
216 lemma mem_rep_iff_principal_less: "a \<in> rep x \<longleftrightarrow> principal a \<sqsubseteq> x" |
217 by (simp add: approxes_eq) |
217 by (simp add: rep_eq) |
218 |
218 |
219 lemma principal_less_iff: "(principal a \<sqsubseteq> x) = (a \<in> approxes x)" |
219 lemma principal_less_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x" |
220 by (simp add: approxes_eq) |
220 by (simp add: rep_eq) |
221 |
221 |
222 lemma approxesD: "a \<in> approxes x \<Longrightarrow> principal a \<sqsubseteq> x" |
222 lemma principal_less_iff: "principal a \<sqsubseteq> principal b \<longleftrightarrow> r a b" |
223 by (simp add: approxes_eq) |
223 by (simp add: principal_less_iff_mem_rep rep_principal) |
|
224 |
|
225 lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> r a b \<and> r b a" |
|
226 unfolding po_eq_conv [where 'a='b] principal_less_iff .. |
|
227 |
|
228 lemma repD: "a \<in> rep x \<Longrightarrow> principal a \<sqsubseteq> x" |
|
229 by (simp add: rep_eq) |
224 |
230 |
225 lemma principal_mono: "r a b \<Longrightarrow> principal a \<sqsubseteq> principal b" |
231 lemma principal_mono: "r a b \<Longrightarrow> principal a \<sqsubseteq> principal b" |
226 by (rule approxesD, simp add: approxes_principal) |
232 by (simp add: principal_less_iff) |
227 |
233 |
228 lemma lessI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u" |
234 lemma lessI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u" |
229 unfolding principal_less_iff |
235 unfolding principal_less_iff_mem_rep |
230 by (simp add: less_def subset_eq) |
236 by (simp add: less_def subset_eq) |
231 |
237 |
232 lemma lub_principal_approxes: "principal ` approxes x <<| x" |
238 lemma lub_principal_rep: "principal ` rep x <<| x" |
233 apply (rule is_lubI) |
239 apply (rule is_lubI) |
234 apply (rule ub_imageI) |
240 apply (rule ub_imageI) |
235 apply (erule approxesD) |
241 apply (erule repD) |
236 apply (subst less_def) |
242 apply (subst less_def) |
237 apply (rule subsetI) |
243 apply (rule subsetI) |
238 apply (drule (1) ub_imageD) |
244 apply (drule (1) ub_imageD) |
239 apply (simp add: approxes_eq) |
245 apply (simp add: rep_eq) |
240 done |
246 done |
241 |
247 |
242 definition |
248 definition |
243 basis_fun :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where |
249 basis_fun :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where |
244 "basis_fun = (\<lambda>f. (\<Lambda> x. lub (f ` approxes x)))" |
250 "basis_fun = (\<lambda>f. (\<Lambda> x. lub (f ` rep x)))" |
245 |
251 |
246 lemma basis_fun_beta: |
252 lemma basis_fun_beta: |
247 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
253 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
248 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
254 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
249 shows "basis_fun f\<cdot>x = lub (f ` approxes x)" |
255 shows "basis_fun f\<cdot>x = lub (f ` rep x)" |
250 unfolding basis_fun_def |
256 unfolding basis_fun_def |
251 proof (rule beta_cfun) |
257 proof (rule beta_cfun) |
252 have lub: "\<And>x. \<exists>u. f ` approxes x <<| u" |
258 have lub: "\<And>x. \<exists>u. f ` rep x <<| u" |
253 using f_mono by (rule basis_fun_lemma) |
259 using f_mono by (rule basis_fun_lemma) |
254 show cont: "cont (\<lambda>x. lub (f ` approxes x))" |
260 show cont: "cont (\<lambda>x. lub (f ` rep x))" |
255 apply (rule contI2) |
261 apply (rule contI2) |
256 apply (rule monofunI) |
262 apply (rule monofunI) |
257 apply (rule is_lub_thelub0 [OF lub ub_imageI]) |
263 apply (rule is_lub_thelub0 [OF lub ub_imageI]) |
258 apply (rule is_ub_thelub0 [OF lub imageI]) |
264 apply (rule is_ub_thelub0 [OF lub imageI]) |
259 apply (erule (1) subsetD [OF approxes_mono]) |
265 apply (erule (1) subsetD [OF rep_mono]) |
260 apply (rule is_lub_thelub0 [OF lub ub_imageI]) |
266 apply (rule is_lub_thelub0 [OF lub ub_imageI]) |
261 apply (simp add: approxes_contlub, clarify) |
267 apply (simp add: rep_contlub, clarify) |
262 apply (erule rev_trans_less [OF is_ub_thelub]) |
268 apply (erule rev_trans_less [OF is_ub_thelub]) |
263 apply (erule is_ub_thelub0 [OF lub imageI]) |
269 apply (erule is_ub_thelub0 [OF lub imageI]) |
264 done |
270 done |
265 qed |
271 qed |
266 |
272 |
267 lemma basis_fun_principal: |
273 lemma basis_fun_principal: |
268 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
274 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
269 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
275 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
270 shows "basis_fun f\<cdot>(principal a) = f a" |
276 shows "basis_fun f\<cdot>(principal a) = f a" |
271 apply (subst basis_fun_beta, erule f_mono) |
277 apply (subst basis_fun_beta, erule f_mono) |
272 apply (subst approxes_principal) |
278 apply (subst rep_principal) |
273 apply (rule lub_image_principal, erule f_mono) |
279 apply (rule lub_image_principal, erule f_mono) |
274 done |
280 done |
275 |
281 |
276 lemma basis_fun_mono: |
282 lemma basis_fun_mono: |
277 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
283 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
288 apply (rule basis_fun_lemma, erule g_mono) |
294 apply (rule basis_fun_lemma, erule g_mono) |
289 apply (erule imageI) |
295 apply (erule imageI) |
290 done |
296 done |
291 |
297 |
292 lemma compact_principal: "compact (principal a)" |
298 lemma compact_principal: "compact (principal a)" |
293 by (rule compactI2, simp add: principal_less_iff approxes_contlub) |
299 by (rule compactI2, simp add: principal_less_iff_mem_rep rep_contlub) |
294 |
300 |
295 lemma chain_basis_fun_take: |
301 definition |
296 "chain (\<lambda>i. basis_fun (\<lambda>a. principal (take i a)))" |
302 completion_approx :: "nat \<Rightarrow> 'b \<rightarrow> 'b" where |
|
303 "completion_approx = (\<lambda>i. basis_fun (\<lambda>a. principal (take i a)))" |
|
304 |
|
305 lemma completion_approx_beta: |
|
306 "completion_approx i\<cdot>x = (\<Squnion>a\<in>rep x. principal (take i a))" |
|
307 unfolding completion_approx_def |
|
308 by (simp add: basis_fun_beta principal_mono take_mono) |
|
309 |
|
310 lemma completion_approx_principal: |
|
311 "completion_approx i\<cdot>(principal a) = principal (take i a)" |
|
312 unfolding completion_approx_def |
|
313 by (simp add: basis_fun_principal principal_mono take_mono) |
|
314 |
|
315 lemma chain_completion_approx: "chain completion_approx" |
|
316 unfolding completion_approx_def |
297 apply (rule chainI) |
317 apply (rule chainI) |
298 apply (rule basis_fun_mono) |
318 apply (rule basis_fun_mono) |
299 apply (erule principal_mono [OF take_mono]) |
319 apply (erule principal_mono [OF take_mono]) |
300 apply (erule principal_mono [OF take_mono]) |
320 apply (erule principal_mono [OF take_mono]) |
301 apply (rule principal_mono [OF take_chain]) |
321 apply (rule principal_mono [OF take_chain]) |
302 done |
322 done |
303 |
323 |
304 lemma lub_basis_fun_take: |
324 lemma lub_completion_approx: "(\<Squnion>i. completion_approx i\<cdot>x) = x" |
305 "(\<Squnion>i. basis_fun (\<lambda>a. principal (take i a))\<cdot>x) = x" |
325 unfolding completion_approx_beta |
306 apply (simp add: basis_fun_beta principal_mono take_mono) |
|
307 apply (subst image_image [where f=principal, symmetric]) |
326 apply (subst image_image [where f=principal, symmetric]) |
308 apply (rule unique_lub [OF _ lub_principal_approxes]) |
327 apply (rule unique_lub [OF _ lub_principal_rep]) |
309 apply (rule basis_fun_lemma2, erule principal_mono) |
328 apply (rule basis_fun_lemma2, erule principal_mono) |
310 done |
329 done |
311 |
330 |
312 lemma basis_fun_take_eq_principal: |
331 lemma completion_approx_eq_principal: |
313 "\<exists>a\<in>approxes x. |
332 "\<exists>a\<in>rep x. completion_approx i\<cdot>x = principal (take i a)" |
314 basis_fun (\<lambda>a. principal (take i a))\<cdot>x = principal (take i a)" |
333 unfolding completion_approx_beta |
315 apply (simp add: basis_fun_beta principal_mono take_mono) |
|
316 apply (subst image_image [where f=principal, symmetric]) |
334 apply (subst image_image [where f=principal, symmetric]) |
317 apply (subgoal_tac "finite (principal ` take i ` approxes x)") |
335 apply (subgoal_tac "finite (principal ` take i ` rep x)") |
318 apply (subgoal_tac "directed (principal ` take i ` approxes x)") |
336 apply (subgoal_tac "directed (principal ` take i ` rep x)") |
319 apply (drule (1) lub_finite_directed_in_self, fast) |
337 apply (drule (1) lub_finite_directed_in_self, fast) |
320 apply (subst image_image) |
338 apply (subst image_image) |
321 apply (rule directed_image_ideal) |
339 apply (rule directed_image_ideal) |
322 apply (rule ideal_approxes) |
340 apply (rule ideal_rep) |
323 apply (erule principal_mono [OF take_mono]) |
341 apply (erule principal_mono [OF take_mono]) |
324 apply (rule finite_imageI) |
342 apply (rule finite_imageI) |
325 apply (rule finite_take_approxes) |
343 apply (rule finite_take_rep) |
326 done |
344 done |
327 |
345 |
328 lemma principal_induct: |
346 lemma completion_approx_idem: |
329 assumes adm: "adm P" |
347 "completion_approx i\<cdot>(completion_approx i\<cdot>x) = completion_approx i\<cdot>x" |
330 assumes P: "\<And>a. P (principal a)" |
348 using completion_approx_eq_principal [where i=i and x=x] |
331 shows "P x" |
349 by (auto simp add: completion_approx_principal take_take) |
332 apply (subgoal_tac "P (\<Squnion>i. basis_fun (\<lambda>a. principal (take i a))\<cdot>x)") |
350 |
333 apply (simp add: lub_basis_fun_take) |
351 lemma finite_fixes_completion_approx: |
334 apply (rule admD [OF adm]) |
352 "finite {x. completion_approx i\<cdot>x = x}" (is "finite ?S") |
335 apply (simp add: chain_basis_fun_take) |
|
336 apply (cut_tac x=x and i=i in basis_fun_take_eq_principal) |
|
337 apply (clarify, simp add: P) |
|
338 done |
|
339 |
|
340 lemma finite_fixes_basis_fun_take: |
|
341 "finite {x. basis_fun (\<lambda>a. principal (take i a))\<cdot>x = x}" (is "finite ?S") |
|
342 apply (subgoal_tac "?S \<subseteq> principal ` range (take i)") |
353 apply (subgoal_tac "?S \<subseteq> principal ` range (take i)") |
343 apply (erule finite_subset) |
354 apply (erule finite_subset) |
344 apply (rule finite_imageI) |
355 apply (rule finite_imageI) |
345 apply (rule finite_range_take) |
356 apply (rule finite_range_take) |
346 apply (clarify, erule subst) |
357 apply (clarify, erule subst) |
347 apply (cut_tac x=x and i=i in basis_fun_take_eq_principal) |
358 apply (cut_tac x=x and i=i in completion_approx_eq_principal) |
348 apply fast |
359 apply fast |
|
360 done |
|
361 |
|
362 lemma principal_induct: |
|
363 assumes adm: "adm P" |
|
364 assumes P: "\<And>a. P (principal a)" |
|
365 shows "P x" |
|
366 apply (subgoal_tac "P (\<Squnion>i. completion_approx i\<cdot>x)") |
|
367 apply (simp add: lub_completion_approx) |
|
368 apply (rule admD [OF adm]) |
|
369 apply (simp add: chain_completion_approx) |
|
370 apply (cut_tac x=x and i=i in completion_approx_eq_principal) |
|
371 apply (clarify, simp add: P) |
349 done |
372 done |
350 |
373 |
351 end |
374 end |
352 |
375 |
353 |
376 |