106 apply (drule (1) idealD3 [OF ideal_A]) |
106 apply (drule (1) idealD3 [OF ideal_A]) |
107 apply fast |
107 apply fast |
108 done |
108 done |
109 |
109 |
110 lemma typedef_ideal_po: |
110 lemma typedef_ideal_po: |
111 fixes Abs :: "'a set \<Rightarrow> 'b::sq_ord" |
111 fixes Abs :: "'a set \<Rightarrow> 'b::below" |
112 assumes type: "type_definition Rep Abs {S. ideal S}" |
112 assumes type: "type_definition Rep Abs {S. ideal S}" |
113 assumes less: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y" |
113 assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y" |
114 shows "OFCLASS('b, po_class)" |
114 shows "OFCLASS('b, po_class)" |
115 apply (intro_classes, unfold less) |
115 apply (intro_classes, unfold below) |
116 apply (rule subset_refl) |
116 apply (rule subset_refl) |
117 apply (erule (1) subset_trans) |
117 apply (erule (1) subset_trans) |
118 apply (rule type_definition.Rep_inject [OF type, THEN iffD1]) |
118 apply (rule type_definition.Rep_inject [OF type, THEN iffD1]) |
119 apply (erule (1) subset_antisym) |
119 apply (erule (1) subset_antisym) |
120 done |
120 done |
121 |
121 |
122 lemma |
122 lemma |
123 fixes Abs :: "'a set \<Rightarrow> 'b::po" |
123 fixes Abs :: "'a set \<Rightarrow> 'b::po" |
124 assumes type: "type_definition Rep Abs {S. ideal S}" |
124 assumes type: "type_definition Rep Abs {S. ideal S}" |
125 assumes less: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y" |
125 assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y" |
126 assumes S: "chain S" |
126 assumes S: "chain S" |
127 shows typedef_ideal_lub: "range S <<| Abs (\<Union>i. Rep (S i))" |
127 shows typedef_ideal_lub: "range S <<| Abs (\<Union>i. Rep (S i))" |
128 and typedef_ideal_rep_contlub: "Rep (\<Squnion>i. S i) = (\<Union>i. Rep (S i))" |
128 and typedef_ideal_rep_contlub: "Rep (\<Squnion>i. S i) = (\<Union>i. Rep (S i))" |
129 proof - |
129 proof - |
130 have 1: "ideal (\<Union>i. Rep (S i))" |
130 have 1: "ideal (\<Union>i. Rep (S i))" |
131 apply (rule ideal_UN) |
131 apply (rule ideal_UN) |
132 apply (rule type_definition.Rep [OF type, unfolded mem_Collect_eq]) |
132 apply (rule type_definition.Rep [OF type, unfolded mem_Collect_eq]) |
133 apply (subst less [symmetric]) |
133 apply (subst below [symmetric]) |
134 apply (erule chain_mono [OF S]) |
134 apply (erule chain_mono [OF S]) |
135 done |
135 done |
136 hence 2: "Rep (Abs (\<Union>i. Rep (S i))) = (\<Union>i. Rep (S i))" |
136 hence 2: "Rep (Abs (\<Union>i. Rep (S i))) = (\<Union>i. Rep (S i))" |
137 by (simp add: type_definition.Abs_inverse [OF type]) |
137 by (simp add: type_definition.Abs_inverse [OF type]) |
138 show 3: "range S <<| Abs (\<Union>i. Rep (S i))" |
138 show 3: "range S <<| Abs (\<Union>i. Rep (S i))" |
139 apply (rule is_lubI) |
139 apply (rule is_lubI) |
140 apply (rule is_ubI) |
140 apply (rule is_ubI) |
141 apply (simp add: less 2, fast) |
141 apply (simp add: below 2, fast) |
142 apply (simp add: less 2 is_ub_def, fast) |
142 apply (simp add: below 2 is_ub_def, fast) |
143 done |
143 done |
144 hence 4: "(\<Squnion>i. S i) = Abs (\<Union>i. Rep (S i))" |
144 hence 4: "(\<Squnion>i. S i) = Abs (\<Union>i. Rep (S i))" |
145 by (rule thelubI) |
145 by (rule thelubI) |
146 show 5: "Rep (\<Squnion>i. S i) = (\<Union>i. Rep (S i))" |
146 show 5: "Rep (\<Squnion>i. S i) = (\<Union>i. Rep (S i))" |
147 by (simp add: 4 2) |
147 by (simp add: 4 2) |
148 qed |
148 qed |
149 |
149 |
150 lemma typedef_ideal_cpo: |
150 lemma typedef_ideal_cpo: |
151 fixes Abs :: "'a set \<Rightarrow> 'b::po" |
151 fixes Abs :: "'a set \<Rightarrow> 'b::po" |
152 assumes type: "type_definition Rep Abs {S. ideal S}" |
152 assumes type: "type_definition Rep Abs {S. ideal S}" |
153 assumes less: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y" |
153 assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y" |
154 shows "OFCLASS('b, cpo_class)" |
154 shows "OFCLASS('b, cpo_class)" |
155 by (default, rule exI, erule typedef_ideal_lub [OF type less]) |
155 by (default, rule exI, erule typedef_ideal_lub [OF type below]) |
156 |
156 |
157 end |
157 end |
158 |
158 |
159 interpretation sq_le: preorder "sq_le :: 'a::po \<Rightarrow> 'a \<Rightarrow> bool" |
159 interpretation below: preorder "below :: 'a::po \<Rightarrow> 'a \<Rightarrow> bool" |
160 apply unfold_locales |
160 apply unfold_locales |
161 apply (rule refl_less) |
161 apply (rule below_refl) |
162 apply (erule (1) trans_less) |
162 apply (erule (1) below_trans) |
163 done |
163 done |
164 |
164 |
165 subsection {* Lemmas about least upper bounds *} |
165 subsection {* Lemmas about least upper bounds *} |
166 |
166 |
167 lemma finite_directed_contains_lub: |
167 lemma finite_directed_contains_lub: |
227 apply (drule rep_contlub) |
227 apply (drule rep_contlub) |
228 apply (simp only: thelubI [OF lub_bin_chain]) |
228 apply (simp only: thelubI [OF lub_bin_chain]) |
229 apply (rule subsetI, rule UN_I [where a=0], simp_all) |
229 apply (rule subsetI, rule UN_I [where a=0], simp_all) |
230 done |
230 done |
231 |
231 |
232 lemma less_def: "x \<sqsubseteq> y \<longleftrightarrow> rep x \<subseteq> rep y" |
232 lemma below_def: "x \<sqsubseteq> y \<longleftrightarrow> rep x \<subseteq> rep y" |
233 by (rule iffI [OF rep_mono subset_repD]) |
233 by (rule iffI [OF rep_mono subset_repD]) |
234 |
234 |
235 lemma rep_eq: "rep x = {a. principal a \<sqsubseteq> x}" |
235 lemma rep_eq: "rep x = {a. principal a \<sqsubseteq> x}" |
236 unfolding less_def rep_principal |
236 unfolding below_def rep_principal |
237 apply safe |
237 apply safe |
238 apply (erule (1) idealD3 [OF ideal_rep]) |
238 apply (erule (1) idealD3 [OF ideal_rep]) |
239 apply (erule subsetD, simp add: r_refl) |
239 apply (erule subsetD, simp add: r_refl) |
240 done |
240 done |
241 |
241 |
242 lemma mem_rep_iff_principal_less: "a \<in> rep x \<longleftrightarrow> principal a \<sqsubseteq> x" |
242 lemma mem_rep_iff_principal_below: "a \<in> rep x \<longleftrightarrow> principal a \<sqsubseteq> x" |
243 by (simp add: rep_eq) |
243 by (simp add: rep_eq) |
244 |
244 |
245 lemma principal_less_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x" |
245 lemma principal_below_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x" |
246 by (simp add: rep_eq) |
246 by (simp add: rep_eq) |
247 |
247 |
248 lemma principal_less_iff [simp]: "principal a \<sqsubseteq> principal b \<longleftrightarrow> a \<preceq> b" |
248 lemma principal_below_iff [simp]: "principal a \<sqsubseteq> principal b \<longleftrightarrow> a \<preceq> b" |
249 by (simp add: principal_less_iff_mem_rep rep_principal) |
249 by (simp add: principal_below_iff_mem_rep rep_principal) |
250 |
250 |
251 lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> a \<preceq> b \<and> b \<preceq> a" |
251 lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> a \<preceq> b \<and> b \<preceq> a" |
252 unfolding po_eq_conv [where 'a='b] principal_less_iff .. |
252 unfolding po_eq_conv [where 'a='b] principal_below_iff .. |
253 |
253 |
254 lemma repD: "a \<in> rep x \<Longrightarrow> principal a \<sqsubseteq> x" |
254 lemma repD: "a \<in> rep x \<Longrightarrow> principal a \<sqsubseteq> x" |
255 by (simp add: rep_eq) |
255 by (simp add: rep_eq) |
256 |
256 |
257 lemma principal_mono: "a \<preceq> b \<Longrightarrow> principal a \<sqsubseteq> principal b" |
257 lemma principal_mono: "a \<preceq> b \<Longrightarrow> principal a \<sqsubseteq> principal b" |
258 by (simp only: principal_less_iff) |
258 by (simp only: principal_below_iff) |
259 |
259 |
260 lemma lessI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u" |
260 lemma belowI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u" |
261 unfolding principal_less_iff_mem_rep |
261 unfolding principal_below_iff_mem_rep |
262 by (simp add: less_def subset_eq) |
262 by (simp add: below_def subset_eq) |
263 |
263 |
264 lemma lub_principal_rep: "principal ` rep x <<| x" |
264 lemma lub_principal_rep: "principal ` rep x <<| x" |
265 apply (rule is_lubI) |
265 apply (rule is_lubI) |
266 apply (rule ub_imageI) |
266 apply (rule ub_imageI) |
267 apply (erule repD) |
267 apply (erule repD) |
268 apply (subst less_def) |
268 apply (subst below_def) |
269 apply (rule subsetI) |
269 apply (rule subsetI) |
270 apply (drule (1) ub_imageD) |
270 apply (drule (1) ub_imageD) |
271 apply (simp add: rep_eq) |
271 apply (simp add: rep_eq) |
272 done |
272 done |
273 |
273 |
311 shows "f ` rep x <<| (\<Squnion>i. lub (f ` take i ` rep x))" |
311 shows "f ` rep x <<| (\<Squnion>i. lub (f ` take i ` rep x))" |
312 apply (rule is_lubI) |
312 apply (rule is_lubI) |
313 apply (rule ub_imageI, rename_tac a) |
313 apply (rule ub_imageI, rename_tac a) |
314 apply (cut_tac a=a in take_covers, erule exE, rename_tac i) |
314 apply (cut_tac a=a in take_covers, erule exE, rename_tac i) |
315 apply (erule subst) |
315 apply (erule subst) |
316 apply (rule rev_trans_less) |
316 apply (rule rev_below_trans) |
317 apply (rule_tac x=i in is_ub_thelub) |
317 apply (rule_tac x=i in is_ub_thelub) |
318 apply (rule basis_fun_lemma1, erule f_mono) |
318 apply (rule basis_fun_lemma1, erule f_mono) |
319 apply (rule is_ub_thelub0) |
319 apply (rule is_ub_thelub0) |
320 apply (rule basis_fun_lemma0, erule f_mono) |
320 apply (rule basis_fun_lemma0, erule f_mono) |
321 apply simp |
321 apply simp |
322 apply (rule is_lub_thelub [OF _ ub_rangeI]) |
322 apply (rule is_lub_thelub [OF _ ub_rangeI]) |
323 apply (rule basis_fun_lemma1, erule f_mono) |
323 apply (rule basis_fun_lemma1, erule f_mono) |
324 apply (rule is_lub_thelub0) |
324 apply (rule is_lub_thelub0) |
325 apply (rule basis_fun_lemma0, erule f_mono) |
325 apply (rule basis_fun_lemma0, erule f_mono) |
326 apply (rule is_ubI, clarsimp, rename_tac a) |
326 apply (rule is_ubI, clarsimp, rename_tac a) |
327 apply (rule trans_less [OF f_mono [OF take_less]]) |
327 apply (rule below_trans [OF f_mono [OF take_less]]) |
328 apply (erule (1) ub_imageD) |
328 apply (erule (1) ub_imageD) |
329 done |
329 done |
330 |
330 |
331 lemma basis_fun_lemma: |
331 lemma basis_fun_lemma: |
332 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
332 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
365 done |
365 done |
366 |
366 |
367 lemma basis_fun_mono: |
367 lemma basis_fun_mono: |
368 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
368 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
369 assumes g_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> g a \<sqsubseteq> g b" |
369 assumes g_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> g a \<sqsubseteq> g b" |
370 assumes less: "\<And>a. f a \<sqsubseteq> g a" |
370 assumes below: "\<And>a. f a \<sqsubseteq> g a" |
371 shows "basis_fun f \<sqsubseteq> basis_fun g" |
371 shows "basis_fun f \<sqsubseteq> basis_fun g" |
372 apply (rule less_cfun_ext) |
372 apply (rule below_cfun_ext) |
373 apply (simp only: basis_fun_beta f_mono g_mono) |
373 apply (simp only: basis_fun_beta f_mono g_mono) |
374 apply (rule is_lub_thelub0) |
374 apply (rule is_lub_thelub0) |
375 apply (rule basis_fun_lemma, erule f_mono) |
375 apply (rule basis_fun_lemma, erule f_mono) |
376 apply (rule ub_imageI, rename_tac a) |
376 apply (rule ub_imageI, rename_tac a) |
377 apply (rule trans_less [OF less]) |
377 apply (rule below_trans [OF below]) |
378 apply (rule is_ub_thelub0) |
378 apply (rule is_ub_thelub0) |
379 apply (rule basis_fun_lemma, erule g_mono) |
379 apply (rule basis_fun_lemma, erule g_mono) |
380 apply (erule imageI) |
380 apply (erule imageI) |
381 done |
381 done |
382 |
382 |
383 lemma compact_principal [simp]: "compact (principal a)" |
383 lemma compact_principal [simp]: "compact (principal a)" |
384 by (rule compactI2, simp add: principal_less_iff_mem_rep rep_contlub) |
384 by (rule compactI2, simp add: principal_below_iff_mem_rep rep_contlub) |
385 |
385 |
386 subsection {* Bifiniteness of ideal completions *} |
386 subsection {* Bifiniteness of ideal completions *} |
387 |
387 |
388 definition |
388 definition |
389 completion_approx :: "nat \<Rightarrow> 'b \<rightarrow> 'b" where |
389 completion_approx :: "nat \<Rightarrow> 'b \<rightarrow> 'b" where |