9 imports Bifinite SetPcpo |
9 imports Bifinite SetPcpo |
10 begin |
10 begin |
11 |
11 |
12 subsection {* Ideals over a preorder *} |
12 subsection {* Ideals over a preorder *} |
13 |
13 |
14 context preorder |
14 locale preorder = |
|
15 fixes r :: "'a::type \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<preceq>" 50) |
|
16 assumes r_refl: "x \<preceq> x" |
|
17 assumes r_trans: "\<lbrakk>x \<preceq> y; y \<preceq> z\<rbrakk> \<Longrightarrow> x \<preceq> z" |
15 begin |
18 begin |
16 |
19 |
17 definition |
20 definition |
18 ideal :: "'a set \<Rightarrow> bool" where |
21 ideal :: "'a set \<Rightarrow> bool" where |
19 "ideal A = ((\<exists>x. x \<in> A) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. \<exists>z\<in>A. x \<sqsubseteq> z \<and> y \<sqsubseteq> z) \<and> |
22 "ideal A = ((\<exists>x. x \<in> A) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z) \<and> |
20 (\<forall>x y. x \<sqsubseteq> y \<longrightarrow> y \<in> A \<longrightarrow> x \<in> A))" |
23 (\<forall>x y. x \<preceq> y \<longrightarrow> y \<in> A \<longrightarrow> x \<in> A))" |
21 |
24 |
22 lemma idealI: |
25 lemma idealI: |
23 assumes "\<exists>x. x \<in> A" |
26 assumes "\<exists>x. x \<in> A" |
24 assumes "\<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<sqsubseteq> z \<and> y \<sqsubseteq> z" |
27 assumes "\<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z" |
25 assumes "\<And>x y. \<lbrakk>x \<sqsubseteq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A" |
28 assumes "\<And>x y. \<lbrakk>x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A" |
26 shows "ideal A" |
29 shows "ideal A" |
27 unfolding ideal_def using prems by fast |
30 unfolding ideal_def using prems by fast |
28 |
31 |
29 lemma idealD1: |
32 lemma idealD1: |
30 "ideal A \<Longrightarrow> \<exists>x. x \<in> A" |
33 "ideal A \<Longrightarrow> \<exists>x. x \<in> A" |
31 unfolding ideal_def by fast |
34 unfolding ideal_def by fast |
32 |
35 |
33 lemma idealD2: |
36 lemma idealD2: |
34 "\<lbrakk>ideal A; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<sqsubseteq> z \<and> y \<sqsubseteq> z" |
37 "\<lbrakk>ideal A; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z" |
35 unfolding ideal_def by fast |
38 unfolding ideal_def by fast |
36 |
39 |
37 lemma idealD3: |
40 lemma idealD3: |
38 "\<lbrakk>ideal A; x \<sqsubseteq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A" |
41 "\<lbrakk>ideal A; x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A" |
39 unfolding ideal_def by fast |
42 unfolding ideal_def by fast |
40 |
43 |
41 lemma ideal_directed_finite: |
44 lemma ideal_directed_finite: |
42 assumes A: "ideal A" |
45 assumes A: "ideal A" |
43 shows "\<lbrakk>finite U; U \<subseteq> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. \<forall>x\<in>U. x \<sqsubseteq> z" |
46 shows "\<lbrakk>finite U; U \<subseteq> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. \<forall>x\<in>U. x \<preceq> z" |
44 apply (induct U set: finite) |
47 apply (induct U set: finite) |
45 apply (simp add: idealD1 [OF A]) |
48 apply (simp add: idealD1 [OF A]) |
46 apply (simp, clarify, rename_tac y) |
49 apply (simp, clarify, rename_tac y) |
47 apply (drule (1) idealD2 [OF A]) |
50 apply (drule (1) idealD2 [OF A]) |
48 apply (clarify, erule_tac x=z in rev_bexI) |
51 apply (clarify, erule_tac x=z in rev_bexI) |
49 apply (fast intro: trans_less) |
52 apply (fast intro: r_trans) |
50 done |
53 done |
51 |
54 |
52 lemma ideal_principal: "ideal {x. x \<sqsubseteq> z}" |
55 lemma ideal_principal: "ideal {x. x \<preceq> z}" |
53 apply (rule idealI) |
56 apply (rule idealI) |
54 apply (rule_tac x=z in exI) |
57 apply (rule_tac x=z in exI) |
55 apply fast |
58 apply (fast intro: r_refl) |
56 apply (rule_tac x=z in bexI, fast) |
59 apply (rule_tac x=z in bexI, fast) |
57 apply fast |
60 apply (fast intro: r_refl) |
58 apply (fast intro: trans_less) |
61 apply (fast intro: r_trans) |
59 done |
62 done |
|
63 |
|
64 lemma ex_ideal: "\<exists>A. ideal A" |
|
65 by (rule exI, rule ideal_principal) |
60 |
66 |
61 lemma directed_image_ideal: |
67 lemma directed_image_ideal: |
62 assumes A: "ideal A" |
68 assumes A: "ideal A" |
63 assumes f: "\<And>x y. x \<sqsubseteq> y \<Longrightarrow> f x \<sqsubseteq> f y" |
69 assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y" |
64 shows "directed (f ` A)" |
70 shows "directed (f ` A)" |
65 apply (rule directedI) |
71 apply (rule directedI) |
66 apply (cut_tac idealD1 [OF A], fast) |
72 apply (cut_tac idealD1 [OF A], fast) |
67 apply (clarify, rename_tac a b) |
73 apply (clarify, rename_tac a b) |
68 apply (drule (1) idealD2 [OF A]) |
74 apply (drule (1) idealD2 [OF A]) |
74 |
80 |
75 lemma adm_ideal: "adm (\<lambda>A. ideal A)" |
81 lemma adm_ideal: "adm (\<lambda>A. ideal A)" |
76 unfolding ideal_def by (intro adm_lemmas adm_set_lemmas) |
82 unfolding ideal_def by (intro adm_lemmas adm_set_lemmas) |
77 |
83 |
78 lemma lub_image_principal: |
84 lemma lub_image_principal: |
79 assumes f: "\<And>x y. x \<sqsubseteq> y \<Longrightarrow> f x \<sqsubseteq> f y" |
85 assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y" |
80 shows "(\<Squnion>x\<in>{x. x \<sqsubseteq> y}. f x) = f y" |
86 shows "(\<Squnion>x\<in>{x. x \<preceq> y}. f x) = f y" |
81 apply (rule thelubI) |
87 apply (rule thelubI) |
82 apply (rule is_lub_maximal) |
88 apply (rule is_lub_maximal) |
83 apply (rule ub_imageI) |
89 apply (rule ub_imageI) |
84 apply (simp add: f) |
90 apply (simp add: f) |
85 apply (rule imageI) |
91 apply (rule imageI) |
86 apply simp |
92 apply (simp add: r_refl) |
87 done |
93 done |
88 |
94 |
89 end |
95 end |
|
96 |
|
97 interpretation sq_le: preorder ["sq_le :: 'a::po \<Rightarrow> 'a \<Rightarrow> bool"] |
|
98 apply unfold_locales |
|
99 apply (rule refl_less) |
|
100 apply (erule (1) trans_less) |
|
101 done |
90 |
102 |
91 subsection {* Defining functions in terms of basis elements *} |
103 subsection {* Defining functions in terms of basis elements *} |
92 |
104 |
93 lemma finite_directed_contains_lub: |
105 lemma finite_directed_contains_lub: |
94 "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u\<in>S. S <<| u" |
106 "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u\<in>S. S <<| u" |
114 done |
126 done |
115 |
127 |
116 lemma is_lub_thelub0: "\<lbrakk>\<exists>u. S <<| u; S <| x\<rbrakk> \<Longrightarrow> lub S \<sqsubseteq> x" |
128 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) |
129 by (erule exE, drule lubI, erule is_lub_lub) |
118 |
130 |
119 locale basis_take = preorder r + |
131 locale basis_take = preorder + |
120 fixes take :: "nat \<Rightarrow> 'a::type \<Rightarrow> 'a" |
132 fixes take :: "nat \<Rightarrow> 'a::type \<Rightarrow> 'a" |
121 assumes take_less: "r (take n a) a" |
133 assumes take_less: "take n a \<preceq> a" |
122 assumes take_take: "take n (take n a) = take n a" |
134 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)" |
135 assumes take_mono: "a \<preceq> b \<Longrightarrow> take n a \<preceq> take n b" |
124 assumes take_chain: "r (take n a) (take (Suc n) a)" |
136 assumes take_chain: "take n a \<preceq> take (Suc n) a" |
125 assumes finite_range_take: "finite (range (take n))" |
137 assumes finite_range_take: "finite (range (take n))" |
126 assumes take_covers: "\<exists>n. take n a = a" |
138 assumes take_covers: "\<exists>n. take n a = a" |
127 |
139 |
128 locale ideal_completion = basis_take r + |
140 locale ideal_completion = basis_take + |
129 fixes principal :: "'a::type \<Rightarrow> 'b::cpo" |
141 fixes principal :: "'a::type \<Rightarrow> 'b::cpo" |
130 fixes rep :: "'b::cpo \<Rightarrow> 'a::type set" |
142 fixes rep :: "'b::cpo \<Rightarrow> 'a::type set" |
131 assumes ideal_rep: "\<And>x. preorder.ideal r (rep x)" |
143 assumes ideal_rep: "\<And>x. preorder.ideal r (rep x)" |
132 assumes cont_rep: "cont rep" |
144 assumes cont_rep: "cont rep" |
133 assumes rep_principal: "\<And>a. rep (principal a) = {b. r b a}" |
145 assumes rep_principal: "\<And>a. rep (principal a) = {b. b \<preceq> a}" |
134 assumes subset_repD: "\<And>x y. rep x \<subseteq> rep y \<Longrightarrow> x \<sqsubseteq> y" |
146 assumes subset_repD: "\<And>x y. rep x \<subseteq> rep y \<Longrightarrow> x \<sqsubseteq> y" |
135 begin |
147 begin |
136 |
148 |
137 lemma finite_take_rep: "finite (take n ` rep x)" |
149 lemma finite_take_rep: "finite (take n ` rep x)" |
138 by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range_take]) |
150 by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range_take]) |
139 |
151 |
140 lemma basis_fun_lemma0: |
152 lemma basis_fun_lemma0: |
141 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
153 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
142 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
154 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
143 shows "\<exists>u. f ` take i ` rep x <<| u" |
155 shows "\<exists>u. f ` take i ` rep x <<| u" |
144 apply (rule finite_directed_has_lub) |
156 apply (rule finite_directed_has_lub) |
145 apply (rule finite_imageI) |
157 apply (rule finite_imageI) |
146 apply (rule finite_take_rep) |
158 apply (rule finite_take_rep) |
147 apply (subst image_image) |
159 apply (subst image_image) |
151 apply (erule take_mono) |
163 apply (erule take_mono) |
152 done |
164 done |
153 |
165 |
154 lemma basis_fun_lemma1: |
166 lemma basis_fun_lemma1: |
155 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
167 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
156 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
168 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
157 shows "chain (\<lambda>i. lub (f ` take i ` rep x))" |
169 shows "chain (\<lambda>i. lub (f ` take i ` rep x))" |
158 apply (rule chainI) |
170 apply (rule chainI) |
159 apply (rule is_lub_thelub0) |
171 apply (rule is_lub_thelub0) |
160 apply (rule basis_fun_lemma0, erule f_mono) |
172 apply (rule basis_fun_lemma0, erule f_mono) |
161 apply (rule is_ubI, clarsimp, rename_tac a) |
173 apply (rule is_ubI, clarsimp, rename_tac a) |
188 apply (erule (1) ub_imageD) |
200 apply (erule (1) ub_imageD) |
189 done |
201 done |
190 |
202 |
191 lemma basis_fun_lemma: |
203 lemma basis_fun_lemma: |
192 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
204 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
193 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
205 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
194 shows "\<exists>u. f ` rep x <<| u" |
206 shows "\<exists>u. f ` rep x <<| u" |
195 by (rule exI, rule basis_fun_lemma2, erule f_mono) |
207 by (rule exI, rule basis_fun_lemma2, erule f_mono) |
196 |
208 |
197 lemma rep_mono: "x \<sqsubseteq> y \<Longrightarrow> rep x \<subseteq> rep y" |
209 lemma rep_mono: "x \<sqsubseteq> y \<Longrightarrow> rep x \<subseteq> rep y" |
198 apply (drule cont_rep [THEN cont2mono, THEN monofunE]) |
210 apply (drule cont_rep [THEN cont2mono, THEN monofunE]) |
208 |
220 |
209 lemma rep_eq: "rep x = {a. principal a \<sqsubseteq> x}" |
221 lemma rep_eq: "rep x = {a. principal a \<sqsubseteq> x}" |
210 unfolding less_def rep_principal |
222 unfolding less_def rep_principal |
211 apply safe |
223 apply safe |
212 apply (erule (1) idealD3 [OF ideal_rep]) |
224 apply (erule (1) idealD3 [OF ideal_rep]) |
213 apply (erule subsetD, simp add: refl) |
225 apply (erule subsetD, simp add: r_refl) |
214 done |
226 done |
215 |
227 |
216 lemma mem_rep_iff_principal_less: "a \<in> rep x \<longleftrightarrow> principal a \<sqsubseteq> x" |
228 lemma mem_rep_iff_principal_less: "a \<in> rep x \<longleftrightarrow> principal a \<sqsubseteq> x" |
217 by (simp add: rep_eq) |
229 by (simp add: rep_eq) |
218 |
230 |
219 lemma principal_less_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x" |
231 lemma principal_less_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x" |
220 by (simp add: rep_eq) |
232 by (simp add: rep_eq) |
221 |
233 |
222 lemma principal_less_iff: "principal a \<sqsubseteq> principal b \<longleftrightarrow> r a b" |
234 lemma principal_less_iff: "principal a \<sqsubseteq> principal b \<longleftrightarrow> a \<preceq> b" |
223 by (simp add: principal_less_iff_mem_rep rep_principal) |
235 by (simp add: principal_less_iff_mem_rep rep_principal) |
224 |
236 |
225 lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> r a b \<and> r b a" |
237 lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> a \<preceq> b \<and> b \<preceq> a" |
226 unfolding po_eq_conv [where 'a='b] principal_less_iff .. |
238 unfolding po_eq_conv [where 'a='b] principal_less_iff .. |
227 |
239 |
228 lemma repD: "a \<in> rep x \<Longrightarrow> principal a \<sqsubseteq> x" |
240 lemma repD: "a \<in> rep x \<Longrightarrow> principal a \<sqsubseteq> x" |
229 by (simp add: rep_eq) |
241 by (simp add: rep_eq) |
230 |
242 |
231 lemma principal_mono: "r a b \<Longrightarrow> principal a \<sqsubseteq> principal b" |
243 lemma principal_mono: "a \<preceq> b \<Longrightarrow> principal a \<sqsubseteq> principal b" |
232 by (simp add: principal_less_iff) |
244 by (simp add: principal_less_iff) |
233 |
245 |
234 lemma lessI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u" |
246 lemma lessI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u" |
235 unfolding principal_less_iff_mem_rep |
247 unfolding principal_less_iff_mem_rep |
236 by (simp add: less_def subset_eq) |
248 by (simp add: less_def subset_eq) |
249 basis_fun :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where |
261 basis_fun :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where |
250 "basis_fun = (\<lambda>f. (\<Lambda> x. lub (f ` rep x)))" |
262 "basis_fun = (\<lambda>f. (\<Lambda> x. lub (f ` rep x)))" |
251 |
263 |
252 lemma basis_fun_beta: |
264 lemma basis_fun_beta: |
253 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
265 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
254 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
266 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
255 shows "basis_fun f\<cdot>x = lub (f ` rep x)" |
267 shows "basis_fun f\<cdot>x = lub (f ` rep x)" |
256 unfolding basis_fun_def |
268 unfolding basis_fun_def |
257 proof (rule beta_cfun) |
269 proof (rule beta_cfun) |
258 have lub: "\<And>x. \<exists>u. f ` rep x <<| u" |
270 have lub: "\<And>x. \<exists>u. f ` rep x <<| u" |
259 using f_mono by (rule basis_fun_lemma) |
271 using f_mono by (rule basis_fun_lemma) |
270 done |
282 done |
271 qed |
283 qed |
272 |
284 |
273 lemma basis_fun_principal: |
285 lemma basis_fun_principal: |
274 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
286 fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
275 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
287 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
276 shows "basis_fun f\<cdot>(principal a) = f a" |
288 shows "basis_fun f\<cdot>(principal a) = f a" |
277 apply (subst basis_fun_beta, erule f_mono) |
289 apply (subst basis_fun_beta, erule f_mono) |
278 apply (subst rep_principal) |
290 apply (subst rep_principal) |
279 apply (rule lub_image_principal, erule f_mono) |
291 apply (rule lub_image_principal, erule f_mono) |
280 done |
292 done |
281 |
293 |
282 lemma basis_fun_mono: |
294 lemma basis_fun_mono: |
283 assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b" |
295 assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
284 assumes g_mono: "\<And>a b. r a b \<Longrightarrow> g a \<sqsubseteq> g b" |
296 assumes g_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> g a \<sqsubseteq> g b" |
285 assumes less: "\<And>a. f a \<sqsubseteq> g a" |
297 assumes less: "\<And>a. f a \<sqsubseteq> g a" |
286 shows "basis_fun f \<sqsubseteq> basis_fun g" |
298 shows "basis_fun f \<sqsubseteq> basis_fun g" |
287 apply (rule less_cfun_ext) |
299 apply (rule less_cfun_ext) |
288 apply (simp only: basis_fun_beta f_mono g_mono) |
300 apply (simp only: basis_fun_beta f_mono g_mono) |
289 apply (rule is_lub_thelub0) |
301 apply (rule is_lub_thelub0) |
433 |
445 |
434 definition |
446 definition |
435 compacts :: "'a \<Rightarrow> 'a compact_basis set" where |
447 compacts :: "'a \<Rightarrow> 'a compact_basis set" where |
436 "compacts = (\<lambda>x. {a. Rep_compact_basis a \<sqsubseteq> x})" |
448 "compacts = (\<lambda>x. {a. Rep_compact_basis a \<sqsubseteq> x})" |
437 |
449 |
438 lemma ideal_compacts: "preorder.ideal sq_le (compacts w)" |
450 lemma ideal_compacts: "sq_le.ideal (compacts w)" |
439 unfolding compacts_def |
451 unfolding compacts_def |
440 apply (rule preorder.idealI) |
452 apply (rule sq_le.idealI) |
441 apply (rule preorder_class.axioms) |
|
442 apply (rule_tac x="Abs_compact_basis (approx 0\<cdot>w)" in exI) |
453 apply (rule_tac x="Abs_compact_basis (approx 0\<cdot>w)" in exI) |
443 apply (simp add: approx_less) |
454 apply (simp add: approx_less) |
444 apply simp |
455 apply simp |
445 apply (cut_tac a=x in compact_Rep_compact_basis) |
456 apply (cut_tac a=x in compact_Rep_compact_basis) |
446 apply (cut_tac a=y in compact_Rep_compact_basis) |
457 apply (cut_tac a=y in compact_Rep_compact_basis) |