39 lemma idealD3: |
39 lemma idealD3: |
40 "\<lbrakk>ideal A; x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A" |
40 "\<lbrakk>ideal A; x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A" |
41 unfolding ideal_def by fast |
41 unfolding ideal_def by fast |
42 |
42 |
43 lemma ideal_principal: "ideal {x. x \<preceq> z}" |
43 lemma ideal_principal: "ideal {x. x \<preceq> z}" |
44 apply (rule idealI) |
44 apply (rule idealI) |
45 apply (rule_tac x=z in exI) |
45 apply (rule exI [where x = z]) |
46 apply (fast intro: r_refl) |
46 apply (fast intro: r_refl) |
47 apply (rule_tac x=z in bexI, fast) |
47 apply (rule bexI [where x = z], fast) |
48 apply (fast intro: r_refl) |
48 apply (fast intro: r_refl) |
49 apply (fast intro: r_trans) |
49 apply (fast intro: r_trans) |
50 done |
50 done |
51 |
51 |
52 lemma ex_ideal: "\<exists>A. A \<in> {A. ideal A}" |
52 lemma ex_ideal: "\<exists>A. A \<in> {A. ideal A}" |
53 by (fast intro: ideal_principal) |
53 by (fast intro: ideal_principal) |
54 |
54 |
55 text \<open>The set of ideals is a cpo\<close> |
55 text \<open>The set of ideals is a cpo\<close> |
57 lemma ideal_UN: |
57 lemma ideal_UN: |
58 fixes A :: "nat \<Rightarrow> 'a set" |
58 fixes A :: "nat \<Rightarrow> 'a set" |
59 assumes ideal_A: "\<And>i. ideal (A i)" |
59 assumes ideal_A: "\<And>i. ideal (A i)" |
60 assumes chain_A: "\<And>i j. i \<le> j \<Longrightarrow> A i \<subseteq> A j" |
60 assumes chain_A: "\<And>i j. i \<le> j \<Longrightarrow> A i \<subseteq> A j" |
61 shows "ideal (\<Union>i. A i)" |
61 shows "ideal (\<Union>i. A i)" |
62 apply (rule idealI) |
62 apply (rule idealI) |
63 apply (cut_tac idealD1 [OF ideal_A], fast) |
63 using idealD1 [OF ideal_A] apply fast |
64 apply (clarify, rename_tac i j) |
64 apply (clarify) |
65 apply (drule subsetD [OF chain_A [OF max.cobounded1]]) |
65 subgoal for i j |
66 apply (drule subsetD [OF chain_A [OF max.cobounded2]]) |
66 apply (drule subsetD [OF chain_A [OF max.cobounded1]]) |
67 apply (drule (1) idealD2 [OF ideal_A]) |
67 apply (drule subsetD [OF chain_A [OF max.cobounded2]]) |
68 apply blast |
68 apply (drule (1) idealD2 [OF ideal_A]) |
69 apply clarify |
69 apply blast |
70 apply (drule (1) idealD3 [OF ideal_A]) |
70 done |
71 apply fast |
71 apply clarify |
72 done |
72 apply (drule (1) idealD3 [OF ideal_A]) |
|
73 apply fast |
|
74 done |
73 |
75 |
74 lemma typedef_ideal_po: |
76 lemma typedef_ideal_po: |
75 fixes Abs :: "'a set \<Rightarrow> 'b::below" |
77 fixes Abs :: "'a set \<Rightarrow> 'b::below" |
76 assumes type: "type_definition Rep Abs {S. ideal S}" |
78 assumes type: "type_definition Rep Abs {S. ideal S}" |
77 assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y" |
79 assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y" |
206 have X_Suc: "\<And>n. X (Suc n) = (if P (X n) then c (X n) (b (X n)) else X n)" |
208 have X_Suc: "\<And>n. X (Suc n) = (if P (X n) then c (X n) (b (X n)) else X n)" |
207 unfolding X_def by simp |
209 unfolding X_def by simp |
208 have a_mem: "enum a \<in> rep x" |
210 have a_mem: "enum a \<in> rep x" |
209 unfolding a_def |
211 unfolding a_def |
210 apply (rule LeastI_ex) |
212 apply (rule LeastI_ex) |
211 apply (cut_tac ideal_rep [of x]) |
213 apply (insert ideal_rep [of x]) |
212 apply (drule idealD1) |
214 apply (drule idealD1) |
213 apply (clarify, rename_tac a) |
215 apply (clarify) |
214 apply (rule_tac x="count a" in exI, simp) |
216 subgoal for a by (rule exI [where x="count a"]) simp |
215 done |
217 done |
216 have b: "\<And>i. P i \<Longrightarrow> enum i \<in> rep x |
218 have b: "\<And>i. P i \<Longrightarrow> enum i \<in> rep x |
217 \<Longrightarrow> enum (b i) \<in> rep x \<and> \<not> enum (b i) \<preceq> enum i" |
219 \<Longrightarrow> enum (b i) \<in> rep x \<and> \<not> enum (b i) \<preceq> enum i" |
218 unfolding P_def b_def by (erule LeastI2_ex, simp) |
220 unfolding P_def b_def by (erule LeastI2_ex, simp) |
219 have c: "\<And>i j. enum i \<in> rep x \<Longrightarrow> enum j \<in> rep x |
221 have c: "\<And>i j. enum i \<in> rep x \<Longrightarrow> enum j \<in> rep x |
220 \<Longrightarrow> enum (c i j) \<in> rep x \<and> enum i \<preceq> enum (c i j) \<and> enum j \<preceq> enum (c i j)" |
222 \<Longrightarrow> enum (c i j) \<in> rep x \<and> enum i \<preceq> enum (c i j) \<and> enum j \<preceq> enum (c i j)" |
221 unfolding c_def |
223 unfolding c_def |
222 apply (drule (1) idealD2 [OF ideal_rep], clarify) |
224 apply (drule (1) idealD2 [OF ideal_rep], clarify) |
223 apply (rule_tac a="count z" in LeastI2, simp, simp) |
225 subgoal for \<dots> z by (rule LeastI2 [where a="count z"], simp, simp) |
224 done |
226 done |
225 have X_mem: "\<And>n. enum (X n) \<in> rep x" |
227 have X_mem: "enum (X n) \<in> rep x" for n |
226 apply (induct_tac n) |
228 proof (induct n) |
227 apply (simp add: X_0 a_mem) |
229 case 0 |
228 apply (clarsimp simp add: X_Suc, rename_tac n) |
230 then show ?case by (simp add: X_0 a_mem) |
229 apply (simp add: b c) |
231 next |
230 done |
232 case (Suc n) |
|
233 with b c show ?case by (auto simp: X_Suc) |
|
234 qed |
231 have X_chain: "\<And>n. enum (X n) \<preceq> enum (X (Suc n))" |
235 have X_chain: "\<And>n. enum (X n) \<preceq> enum (X (Suc n))" |
232 apply (clarsimp simp add: X_Suc r_refl) |
236 apply (clarsimp simp add: X_Suc r_refl) |
233 apply (simp add: b c X_mem) |
237 apply (simp add: b c X_mem) |
234 done |
238 done |
235 have less_b: "\<And>n i. n < b i \<Longrightarrow> enum n \<in> rep x \<Longrightarrow> enum n \<preceq> enum i" |
239 have less_b: "\<And>n i. n < b i \<Longrightarrow> enum n \<in> rep x \<Longrightarrow> enum n \<preceq> enum i" |
236 unfolding b_def by (drule not_less_Least, simp) |
240 unfolding b_def by (drule not_less_Least, simp) |
237 have X_covers: "\<And>n. \<forall>k\<le>n. enum k \<in> rep x \<longrightarrow> enum k \<preceq> enum (X n)" |
241 have X_covers: "\<forall>k\<le>n. enum k \<in> rep x \<longrightarrow> enum k \<preceq> enum (X n)" for n |
238 apply (induct_tac n) |
242 proof (induct n) |
239 apply (clarsimp simp add: X_0 a_def) |
243 case 0 |
240 apply (drule_tac k=0 in Least_le, simp add: r_refl) |
244 then show ?case |
241 apply (clarsimp, rename_tac n k) |
245 apply (clarsimp simp add: X_0 a_def) |
242 apply (erule le_SucE) |
246 apply (drule Least_le [where k=0], simp add: r_refl) |
243 apply (rule r_trans [OF _ X_chain], simp) |
247 done |
244 apply (case_tac "P (X n)", simp add: X_Suc) |
248 next |
245 apply (rule_tac x="b (X n)" and y="Suc n" in linorder_cases) |
249 case (Suc n) |
246 apply (simp only: less_Suc_eq_le) |
250 then show ?case |
247 apply (drule spec, drule (1) mp, simp add: b X_mem) |
251 apply clarsimp |
248 apply (simp add: c X_mem) |
252 apply (erule le_SucE) |
249 apply (drule (1) less_b) |
253 apply (rule r_trans [OF _ X_chain], simp) |
250 apply (erule r_trans) |
254 apply (cases "P (X n)", simp add: X_Suc) |
251 apply (simp add: b c X_mem) |
255 apply (rule linorder_cases [where x="b (X n)" and y="Suc n"]) |
252 apply (simp add: X_Suc) |
256 apply (simp only: less_Suc_eq_le) |
253 apply (simp add: P_def) |
257 apply (drule spec, drule (1) mp, simp add: b X_mem) |
254 done |
258 apply (simp add: c X_mem) |
|
259 apply (drule (1) less_b) |
|
260 apply (erule r_trans) |
|
261 apply (simp add: b c X_mem) |
|
262 apply (simp add: X_Suc) |
|
263 apply (simp add: P_def) |
|
264 done |
|
265 qed |
255 have 1: "\<forall>i. enum (X i) \<preceq> enum (X (Suc i))" |
266 have 1: "\<forall>i. enum (X i) \<preceq> enum (X (Suc i))" |
256 by (simp add: X_chain) |
267 by (simp add: X_chain) |
257 have 2: "x = (\<Squnion>n. principal (enum (X n)))" |
268 have "x = (\<Squnion>n. principal (enum (X n)))" |
258 apply (simp add: eq_iff rep_lub 1 rep_principal) |
269 apply (simp add: eq_iff rep_lub 1 rep_principal) |
259 apply (auto, rename_tac a) |
270 apply auto |
260 apply (subgoal_tac "\<exists>i. a = enum i", erule exE) |
271 subgoal for a |
261 apply (rule_tac x=i in exI, simp add: X_covers) |
272 apply (subgoal_tac "\<exists>i. a = enum i", erule exE) |
262 apply (rule_tac x="count a" in exI, simp) |
273 apply (rule_tac x=i in exI, simp add: X_covers) |
263 apply (erule idealD3 [OF ideal_rep]) |
274 apply (rule_tac x="count a" in exI, simp) |
264 apply (rule X_mem) |
275 done |
265 done |
276 subgoal |
266 from 1 2 show ?thesis .. |
277 apply (erule idealD3 [OF ideal_rep]) |
|
278 apply (rule X_mem) |
|
279 done |
|
280 done |
|
281 with 1 show ?thesis .. |
267 qed |
282 qed |
268 |
283 |
269 lemma principal_induct: |
284 lemma principal_induct: |
270 assumes adm: "adm P" |
285 assumes adm: "adm P" |
271 assumes P: "\<And>a. P (principal a)" |
286 assumes P: "\<And>a. P (principal a)" |
299 by (rule chainI, simp add: f_mono Y) |
314 by (rule chainI, simp add: f_mono Y) |
300 have rep_x: "rep x = (\<Union>n. {a. a \<preceq> Y n})" |
315 have rep_x: "rep x = (\<Union>n. {a. a \<preceq> Y n})" |
301 by (simp add: x rep_lub Y rep_principal) |
316 by (simp add: x rep_lub Y rep_principal) |
302 have "f ` rep x <<| (\<Squnion>n. f (Y n))" |
317 have "f ` rep x <<| (\<Squnion>n. f (Y n))" |
303 apply (rule is_lubI) |
318 apply (rule is_lubI) |
304 apply (rule ub_imageI, rename_tac a) |
319 apply (rule ub_imageI) |
305 apply (clarsimp simp add: rep_x) |
320 subgoal for a |
306 apply (drule f_mono) |
321 apply (clarsimp simp add: rep_x) |
307 apply (erule below_lub [OF chain]) |
322 apply (drule f_mono) |
|
323 apply (erule below_lub [OF chain]) |
|
324 done |
308 apply (rule lub_below [OF chain]) |
325 apply (rule lub_below [OF chain]) |
309 apply (drule_tac x="Y n" in ub_imageD) |
326 subgoal for \<dots> n |
310 apply (simp add: rep_x, fast intro: r_refl) |
327 apply (drule ub_imageD [where x="Y n"]) |
311 apply assumption |
328 apply (simp add: rep_x, fast intro: r_refl) |
312 done |
329 apply assumption |
313 thus ?thesis .. |
330 done |
|
331 done |
|
332 then show ?thesis .. |
314 qed |
333 qed |
315 |
334 |
316 lemma extension_beta: |
335 lemma extension_beta: |
317 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
336 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
318 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
337 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
351 lemma extension_mono: |
370 lemma extension_mono: |
352 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
371 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
353 assumes g_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> g a \<sqsubseteq> g b" |
372 assumes g_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> g a \<sqsubseteq> g b" |
354 assumes below: "\<And>a. f a \<sqsubseteq> g a" |
373 assumes below: "\<And>a. f a \<sqsubseteq> g a" |
355 shows "extension f \<sqsubseteq> extension g" |
374 shows "extension f \<sqsubseteq> extension g" |
356 apply (rule cfun_belowI) |
375 apply (rule cfun_belowI) |
357 apply (simp only: extension_beta f_mono g_mono) |
376 apply (simp only: extension_beta f_mono g_mono) |
358 apply (rule is_lub_thelub_ex) |
377 apply (rule is_lub_thelub_ex) |
359 apply (rule extension_lemma, erule f_mono) |
378 apply (rule extension_lemma, erule f_mono) |
360 apply (rule ub_imageI, rename_tac a) |
379 apply (rule ub_imageI) |
361 apply (rule below_trans [OF below]) |
380 subgoal for x a |
362 apply (rule is_ub_thelub_ex) |
381 apply (rule below_trans [OF below]) |
363 apply (rule extension_lemma, erule g_mono) |
382 apply (rule is_ub_thelub_ex) |
364 apply (erule imageI) |
383 apply (rule extension_lemma, erule g_mono) |
365 done |
384 apply (erule imageI) |
|
385 done |
|
386 done |
366 |
387 |
367 lemma cont_extension: |
388 lemma cont_extension: |
368 assumes f_mono: "\<And>a b x. a \<preceq> b \<Longrightarrow> f x a \<sqsubseteq> f x b" |
389 assumes f_mono: "\<And>a b x. a \<preceq> b \<Longrightarrow> f x a \<sqsubseteq> f x b" |
369 assumes f_cont: "\<And>a. cont (\<lambda>x. f x a)" |
390 assumes f_cont: "\<And>a. cont (\<lambda>x. f x a)" |
370 shows "cont (\<lambda>x. extension (\<lambda>a. f x a))" |
391 shows "cont (\<lambda>x. extension (\<lambda>a. f x a))" |