| author | wenzelm | 
| Tue, 28 Jul 2009 18:17:35 +0200 | |
| changeset 32256 | 8721c74c5382 | 
| parent 31076 | 99fe356cbbc2 | 
| child 39967 | 1c6dce3ef477 | 
| permissions | -rw-r--r-- | 
| 27404 | 1  | 
(* Title: HOLCF/Completion.thy  | 
2  | 
Author: Brian Huffman  | 
|
3  | 
*)  | 
|
4  | 
||
5  | 
header {* Defining bifinite domains by ideal completion *}
 | 
|
6  | 
||
7  | 
theory Completion  | 
|
8  | 
imports Bifinite  | 
|
9  | 
begin  | 
|
10  | 
||
11  | 
subsection {* Ideals over a preorder *}
 | 
|
12  | 
||
13  | 
locale preorder =  | 
|
14  | 
fixes r :: "'a::type \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<preceq>" 50)  | 
|
15  | 
assumes r_refl: "x \<preceq> x"  | 
|
16  | 
assumes r_trans: "\<lbrakk>x \<preceq> y; y \<preceq> z\<rbrakk> \<Longrightarrow> x \<preceq> z"  | 
|
17  | 
begin  | 
|
18  | 
||
19  | 
definition  | 
|
20  | 
ideal :: "'a set \<Rightarrow> bool" where  | 
|
21  | 
"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>  | 
|
22  | 
(\<forall>x y. x \<preceq> y \<longrightarrow> y \<in> A \<longrightarrow> x \<in> A))"  | 
|
23  | 
||
24  | 
lemma idealI:  | 
|
25  | 
assumes "\<exists>x. x \<in> A"  | 
|
26  | 
assumes "\<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z"  | 
|
27  | 
assumes "\<And>x y. \<lbrakk>x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"  | 
|
28  | 
shows "ideal A"  | 
|
29  | 
unfolding ideal_def using prems by fast  | 
|
30  | 
||
31  | 
lemma idealD1:  | 
|
32  | 
"ideal A \<Longrightarrow> \<exists>x. x \<in> A"  | 
|
33  | 
unfolding ideal_def by fast  | 
|
34  | 
||
35  | 
lemma idealD2:  | 
|
36  | 
"\<lbrakk>ideal A; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z"  | 
|
37  | 
unfolding ideal_def by fast  | 
|
38  | 
||
39  | 
lemma idealD3:  | 
|
40  | 
"\<lbrakk>ideal A; x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"  | 
|
41  | 
unfolding ideal_def by fast  | 
|
42  | 
||
43  | 
lemma ideal_directed_finite:  | 
|
44  | 
assumes A: "ideal A"  | 
|
45  | 
shows "\<lbrakk>finite U; U \<subseteq> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. \<forall>x\<in>U. x \<preceq> z"  | 
|
46  | 
apply (induct U set: finite)  | 
|
47  | 
apply (simp add: idealD1 [OF A])  | 
|
48  | 
apply (simp, clarify, rename_tac y)  | 
|
49  | 
apply (drule (1) idealD2 [OF A])  | 
|
50  | 
apply (clarify, erule_tac x=z in rev_bexI)  | 
|
51  | 
apply (fast intro: r_trans)  | 
|
52  | 
done  | 
|
53  | 
||
54  | 
lemma ideal_principal: "ideal {x. x \<preceq> z}"
 | 
|
55  | 
apply (rule idealI)  | 
|
56  | 
apply (rule_tac x=z in exI)  | 
|
57  | 
apply (fast intro: r_refl)  | 
|
58  | 
apply (rule_tac x=z in bexI, fast)  | 
|
59  | 
apply (fast intro: r_refl)  | 
|
60  | 
apply (fast intro: r_trans)  | 
|
61  | 
done  | 
|
62  | 
||
63  | 
lemma ex_ideal: "\<exists>A. ideal A"  | 
|
64  | 
by (rule exI, rule ideal_principal)  | 
|
65  | 
||
66  | 
lemma directed_image_ideal:  | 
|
67  | 
assumes A: "ideal A"  | 
|
68  | 
assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y"  | 
|
69  | 
shows "directed (f ` A)"  | 
|
70  | 
apply (rule directedI)  | 
|
71  | 
apply (cut_tac idealD1 [OF A], fast)  | 
|
72  | 
apply (clarify, rename_tac a b)  | 
|
73  | 
apply (drule (1) idealD2 [OF A])  | 
|
74  | 
apply (clarify, rename_tac c)  | 
|
75  | 
apply (rule_tac x="f c" in rev_bexI)  | 
|
76  | 
apply (erule imageI)  | 
|
77  | 
apply (simp add: f)  | 
|
78  | 
done  | 
|
79  | 
||
80  | 
lemma lub_image_principal:  | 
|
81  | 
assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y"  | 
|
82  | 
  shows "(\<Squnion>x\<in>{x. x \<preceq> y}. f x) = f y"
 | 
|
83  | 
apply (rule thelubI)  | 
|
84  | 
apply (rule is_lub_maximal)  | 
|
85  | 
apply (rule ub_imageI)  | 
|
86  | 
apply (simp add: f)  | 
|
87  | 
apply (rule imageI)  | 
|
88  | 
apply (simp add: r_refl)  | 
|
89  | 
done  | 
|
90  | 
||
91  | 
text {* The set of ideals is a cpo *}
 | 
|
92  | 
||
93  | 
lemma ideal_UN:  | 
|
94  | 
fixes A :: "nat \<Rightarrow> 'a set"  | 
|
95  | 
assumes ideal_A: "\<And>i. ideal (A i)"  | 
|
96  | 
assumes chain_A: "\<And>i j. i \<le> j \<Longrightarrow> A i \<subseteq> A j"  | 
|
97  | 
shows "ideal (\<Union>i. A i)"  | 
|
98  | 
apply (rule idealI)  | 
|
99  | 
apply (cut_tac idealD1 [OF ideal_A], fast)  | 
|
100  | 
apply (clarify, rename_tac i j)  | 
|
101  | 
apply (drule subsetD [OF chain_A [OF le_maxI1]])  | 
|
102  | 
apply (drule subsetD [OF chain_A [OF le_maxI2]])  | 
|
103  | 
apply (drule (1) idealD2 [OF ideal_A])  | 
|
104  | 
apply blast  | 
|
105  | 
apply clarify  | 
|
106  | 
apply (drule (1) idealD3 [OF ideal_A])  | 
|
107  | 
apply fast  | 
|
108  | 
done  | 
|
109  | 
||
110  | 
lemma typedef_ideal_po:  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
111  | 
fixes Abs :: "'a set \<Rightarrow> 'b::below"  | 
| 27404 | 112  | 
  assumes type: "type_definition Rep Abs {S. ideal S}"
 | 
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
113  | 
assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"  | 
| 27404 | 114  | 
  shows "OFCLASS('b, po_class)"
 | 
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
115  | 
apply (intro_classes, unfold below)  | 
| 27404 | 116  | 
apply (rule subset_refl)  | 
117  | 
apply (erule (1) subset_trans)  | 
|
118  | 
apply (rule type_definition.Rep_inject [OF type, THEN iffD1])  | 
|
119  | 
apply (erule (1) subset_antisym)  | 
|
120  | 
done  | 
|
121  | 
||
122  | 
lemma  | 
|
123  | 
fixes Abs :: "'a set \<Rightarrow> 'b::po"  | 
|
124  | 
  assumes type: "type_definition Rep Abs {S. ideal S}"
 | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
125  | 
assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"  | 
| 27404 | 126  | 
assumes S: "chain S"  | 
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))"  | 
|
129  | 
proof -  | 
|
130  | 
have 1: "ideal (\<Union>i. Rep (S i))"  | 
|
131  | 
apply (rule ideal_UN)  | 
|
132  | 
apply (rule type_definition.Rep [OF type, unfolded mem_Collect_eq])  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
133  | 
apply (subst below [symmetric])  | 
| 27404 | 134  | 
apply (erule chain_mono [OF S])  | 
135  | 
done  | 
|
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])  | 
|
138  | 
show 3: "range S <<| Abs (\<Union>i. Rep (S i))"  | 
|
139  | 
apply (rule is_lubI)  | 
|
140  | 
apply (rule is_ubI)  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
141  | 
apply (simp add: below 2, fast)  | 
| 
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
142  | 
apply (simp add: below 2 is_ub_def, fast)  | 
| 27404 | 143  | 
done  | 
144  | 
hence 4: "(\<Squnion>i. S i) = Abs (\<Union>i. Rep (S i))"  | 
|
145  | 
by (rule thelubI)  | 
|
146  | 
show 5: "Rep (\<Squnion>i. S i) = (\<Union>i. Rep (S i))"  | 
|
147  | 
by (simp add: 4 2)  | 
|
148  | 
qed  | 
|
149  | 
||
150  | 
lemma typedef_ideal_cpo:  | 
|
151  | 
fixes Abs :: "'a set \<Rightarrow> 'b::po"  | 
|
152  | 
  assumes type: "type_definition Rep Abs {S. ideal S}"
 | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
153  | 
assumes below: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"  | 
| 27404 | 154  | 
  shows "OFCLASS('b, cpo_class)"
 | 
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
155  | 
by (default, rule exI, erule typedef_ideal_lub [OF type below])  | 
| 27404 | 156  | 
|
157  | 
end  | 
|
158  | 
||
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
159  | 
interpretation below: preorder "below :: 'a::po \<Rightarrow> 'a \<Rightarrow> bool"  | 
| 27404 | 160  | 
apply unfold_locales  | 
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
161  | 
apply (rule below_refl)  | 
| 
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
162  | 
apply (erule (1) below_trans)  | 
| 27404 | 163  | 
done  | 
164  | 
||
| 28133 | 165  | 
subsection {* Lemmas about least upper bounds *}
 | 
| 27404 | 166  | 
|
167  | 
lemma finite_directed_contains_lub:  | 
|
168  | 
"\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u\<in>S. S <<| u"  | 
|
169  | 
apply (drule (1) directed_finiteD, rule subset_refl)  | 
|
170  | 
apply (erule bexE)  | 
|
171  | 
apply (rule rev_bexI, assumption)  | 
|
172  | 
apply (erule (1) is_lub_maximal)  | 
|
173  | 
done  | 
|
174  | 
||
175  | 
lemma lub_finite_directed_in_self:  | 
|
176  | 
"\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> lub S \<in> S"  | 
|
177  | 
apply (drule (1) finite_directed_contains_lub, clarify)  | 
|
178  | 
apply (drule thelubI, simp)  | 
|
179  | 
done  | 
|
180  | 
||
181  | 
lemma finite_directed_has_lub: "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u. S <<| u"  | 
|
182  | 
by (drule (1) finite_directed_contains_lub, fast)  | 
|
183  | 
||
184  | 
lemma is_ub_thelub0: "\<lbrakk>\<exists>u. S <<| u; x \<in> S\<rbrakk> \<Longrightarrow> x \<sqsubseteq> lub S"  | 
|
185  | 
apply (erule exE, drule lubI)  | 
|
186  | 
apply (drule is_lubD1)  | 
|
187  | 
apply (erule (1) is_ubD)  | 
|
188  | 
done  | 
|
189  | 
||
190  | 
lemma is_lub_thelub0: "\<lbrakk>\<exists>u. S <<| u; S <| x\<rbrakk> \<Longrightarrow> lub S \<sqsubseteq> x"  | 
|
191  | 
by (erule exE, drule lubI, erule is_lub_lub)  | 
|
192  | 
||
| 28133 | 193  | 
subsection {* Locale for ideal completion *}
 | 
194  | 
||
| 27404 | 195  | 
locale basis_take = preorder +  | 
196  | 
fixes take :: "nat \<Rightarrow> 'a::type \<Rightarrow> 'a"  | 
|
197  | 
assumes take_less: "take n a \<preceq> a"  | 
|
198  | 
assumes take_take: "take n (take n a) = take n a"  | 
|
199  | 
assumes take_mono: "a \<preceq> b \<Longrightarrow> take n a \<preceq> take n b"  | 
|
200  | 
assumes take_chain: "take n a \<preceq> take (Suc n) a"  | 
|
201  | 
assumes finite_range_take: "finite (range (take n))"  | 
|
202  | 
assumes take_covers: "\<exists>n. take n a = a"  | 
|
203  | 
begin  | 
|
204  | 
||
205  | 
lemma take_chain_less: "m < n \<Longrightarrow> take m a \<preceq> take n a"  | 
|
206  | 
by (erule less_Suc_induct, rule take_chain, erule (1) r_trans)  | 
|
207  | 
||
208  | 
lemma take_chain_le: "m \<le> n \<Longrightarrow> take m a \<preceq> take n a"  | 
|
209  | 
by (cases "m = n", simp add: r_refl, simp add: take_chain_less)  | 
|
210  | 
||
211  | 
end  | 
|
212  | 
||
213  | 
locale ideal_completion = basis_take +  | 
|
214  | 
fixes principal :: "'a::type \<Rightarrow> 'b::cpo"  | 
|
215  | 
fixes rep :: "'b::cpo \<Rightarrow> 'a::type set"  | 
|
216  | 
assumes ideal_rep: "\<And>x. preorder.ideal r (rep x)"  | 
|
217  | 
assumes rep_contlub: "\<And>Y. chain Y \<Longrightarrow> rep (\<Squnion>i. Y i) = (\<Union>i. rep (Y i))"  | 
|
218  | 
  assumes rep_principal: "\<And>a. rep (principal a) = {b. b \<preceq> a}"
 | 
|
219  | 
assumes subset_repD: "\<And>x y. rep x \<subseteq> rep y \<Longrightarrow> x \<sqsubseteq> y"  | 
|
220  | 
begin  | 
|
221  | 
||
222  | 
lemma finite_take_rep: "finite (take n ` rep x)"  | 
|
223  | 
by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range_take])  | 
|
224  | 
||
| 28133 | 225  | 
lemma rep_mono: "x \<sqsubseteq> y \<Longrightarrow> rep x \<subseteq> rep y"  | 
226  | 
apply (frule bin_chain)  | 
|
227  | 
apply (drule rep_contlub)  | 
|
228  | 
apply (simp only: thelubI [OF lub_bin_chain])  | 
|
229  | 
apply (rule subsetI, rule UN_I [where a=0], simp_all)  | 
|
230  | 
done  | 
|
231  | 
||
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
232  | 
lemma below_def: "x \<sqsubseteq> y \<longleftrightarrow> rep x \<subseteq> rep y"  | 
| 28133 | 233  | 
by (rule iffI [OF rep_mono subset_repD])  | 
234  | 
||
235  | 
lemma rep_eq: "rep x = {a. principal a \<sqsubseteq> x}"
 | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
236  | 
unfolding below_def rep_principal  | 
| 28133 | 237  | 
apply safe  | 
238  | 
apply (erule (1) idealD3 [OF ideal_rep])  | 
|
239  | 
apply (erule subsetD, simp add: r_refl)  | 
|
240  | 
done  | 
|
241  | 
||
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
242  | 
lemma mem_rep_iff_principal_below: "a \<in> rep x \<longleftrightarrow> principal a \<sqsubseteq> x"  | 
| 28133 | 243  | 
by (simp add: rep_eq)  | 
244  | 
||
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
245  | 
lemma principal_below_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x"  | 
| 28133 | 246  | 
by (simp add: rep_eq)  | 
247  | 
||
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
248  | 
lemma principal_below_iff [simp]: "principal a \<sqsubseteq> principal b \<longleftrightarrow> a \<preceq> b"  | 
| 
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
249  | 
by (simp add: principal_below_iff_mem_rep rep_principal)  | 
| 28133 | 250  | 
|
251  | 
lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> a \<preceq> b \<and> b \<preceq> a"  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
252  | 
unfolding po_eq_conv [where 'a='b] principal_below_iff ..  | 
| 28133 | 253  | 
|
254  | 
lemma repD: "a \<in> rep x \<Longrightarrow> principal a \<sqsubseteq> x"  | 
|
255  | 
by (simp add: rep_eq)  | 
|
256  | 
||
257  | 
lemma principal_mono: "a \<preceq> b \<Longrightarrow> principal a \<sqsubseteq> principal b"  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
258  | 
by (simp only: principal_below_iff)  | 
| 28133 | 259  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
260  | 
lemma belowI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u"  | 
| 
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
261  | 
unfolding principal_below_iff_mem_rep  | 
| 
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
262  | 
by (simp add: below_def subset_eq)  | 
| 28133 | 263  | 
|
264  | 
lemma lub_principal_rep: "principal ` rep x <<| x"  | 
|
265  | 
apply (rule is_lubI)  | 
|
266  | 
apply (rule ub_imageI)  | 
|
267  | 
apply (erule repD)  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
268  | 
apply (subst below_def)  | 
| 28133 | 269  | 
apply (rule subsetI)  | 
270  | 
apply (drule (1) ub_imageD)  | 
|
271  | 
apply (simp add: rep_eq)  | 
|
272  | 
done  | 
|
273  | 
||
274  | 
subsection {* Defining functions in terms of basis elements *}
 | 
|
275  | 
||
276  | 
definition  | 
|
277  | 
  basis_fun :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where
 | 
|
278  | 
"basis_fun = (\<lambda>f. (\<Lambda> x. lub (f ` rep x)))"  | 
|
279  | 
||
| 27404 | 280  | 
lemma basis_fun_lemma0:  | 
281  | 
fixes f :: "'a::type \<Rightarrow> 'c::cpo"  | 
|
282  | 
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"  | 
|
283  | 
shows "\<exists>u. f ` take i ` rep x <<| u"  | 
|
284  | 
apply (rule finite_directed_has_lub)  | 
|
285  | 
apply (rule finite_imageI)  | 
|
286  | 
apply (rule finite_take_rep)  | 
|
287  | 
apply (subst image_image)  | 
|
288  | 
apply (rule directed_image_ideal)  | 
|
289  | 
apply (rule ideal_rep)  | 
|
290  | 
apply (rule f_mono)  | 
|
291  | 
apply (erule take_mono)  | 
|
292  | 
done  | 
|
293  | 
||
294  | 
lemma basis_fun_lemma1:  | 
|
295  | 
fixes f :: "'a::type \<Rightarrow> 'c::cpo"  | 
|
296  | 
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"  | 
|
297  | 
shows "chain (\<lambda>i. lub (f ` take i ` rep x))"  | 
|
298  | 
apply (rule chainI)  | 
|
299  | 
apply (rule is_lub_thelub0)  | 
|
300  | 
apply (rule basis_fun_lemma0, erule f_mono)  | 
|
301  | 
apply (rule is_ubI, clarsimp, rename_tac a)  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
302  | 
apply (rule below_trans [OF f_mono [OF take_chain]])  | 
| 27404 | 303  | 
apply (rule is_ub_thelub0)  | 
304  | 
apply (rule basis_fun_lemma0, erule f_mono)  | 
|
305  | 
apply simp  | 
|
306  | 
done  | 
|
307  | 
||
308  | 
lemma basis_fun_lemma2:  | 
|
309  | 
fixes f :: "'a::type \<Rightarrow> 'c::cpo"  | 
|
310  | 
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"  | 
|
311  | 
shows "f ` rep x <<| (\<Squnion>i. lub (f ` take i ` rep x))"  | 
|
312  | 
apply (rule is_lubI)  | 
|
313  | 
apply (rule ub_imageI, rename_tac a)  | 
|
314  | 
apply (cut_tac a=a in take_covers, erule exE, rename_tac i)  | 
|
315  | 
apply (erule subst)  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
316  | 
apply (rule rev_below_trans)  | 
| 27404 | 317  | 
apply (rule_tac x=i in is_ub_thelub)  | 
318  | 
apply (rule basis_fun_lemma1, erule f_mono)  | 
|
319  | 
apply (rule is_ub_thelub0)  | 
|
320  | 
apply (rule basis_fun_lemma0, erule f_mono)  | 
|
321  | 
apply simp  | 
|
322  | 
apply (rule is_lub_thelub [OF _ ub_rangeI])  | 
|
323  | 
apply (rule basis_fun_lemma1, erule f_mono)  | 
|
324  | 
apply (rule is_lub_thelub0)  | 
|
325  | 
apply (rule basis_fun_lemma0, erule f_mono)  | 
|
326  | 
apply (rule is_ubI, clarsimp, rename_tac a)  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
327  | 
apply (rule below_trans [OF f_mono [OF take_less]])  | 
| 27404 | 328  | 
apply (erule (1) ub_imageD)  | 
329  | 
done  | 
|
330  | 
||
331  | 
lemma basis_fun_lemma:  | 
|
332  | 
fixes f :: "'a::type \<Rightarrow> 'c::cpo"  | 
|
333  | 
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"  | 
|
334  | 
shows "\<exists>u. f ` rep x <<| u"  | 
|
335  | 
by (rule exI, rule basis_fun_lemma2, erule f_mono)  | 
|
336  | 
||
337  | 
lemma basis_fun_beta:  | 
|
338  | 
fixes f :: "'a::type \<Rightarrow> 'c::cpo"  | 
|
339  | 
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"  | 
|
340  | 
shows "basis_fun f\<cdot>x = lub (f ` rep x)"  | 
|
341  | 
unfolding basis_fun_def  | 
|
342  | 
proof (rule beta_cfun)  | 
|
343  | 
have lub: "\<And>x. \<exists>u. f ` rep x <<| u"  | 
|
344  | 
using f_mono by (rule basis_fun_lemma)  | 
|
345  | 
show cont: "cont (\<lambda>x. lub (f ` rep x))"  | 
|
346  | 
apply (rule contI2)  | 
|
347  | 
apply (rule monofunI)  | 
|
348  | 
apply (rule is_lub_thelub0 [OF lub ub_imageI])  | 
|
349  | 
apply (rule is_ub_thelub0 [OF lub imageI])  | 
|
350  | 
apply (erule (1) subsetD [OF rep_mono])  | 
|
351  | 
apply (rule is_lub_thelub0 [OF lub ub_imageI])  | 
|
352  | 
apply (simp add: rep_contlub, clarify)  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
353  | 
apply (erule rev_below_trans [OF is_ub_thelub])  | 
| 27404 | 354  | 
apply (erule is_ub_thelub0 [OF lub imageI])  | 
355  | 
done  | 
|
356  | 
qed  | 
|
357  | 
||
358  | 
lemma basis_fun_principal:  | 
|
359  | 
fixes f :: "'a::type \<Rightarrow> 'c::cpo"  | 
|
360  | 
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"  | 
|
361  | 
shows "basis_fun f\<cdot>(principal a) = f a"  | 
|
362  | 
apply (subst basis_fun_beta, erule f_mono)  | 
|
363  | 
apply (subst rep_principal)  | 
|
364  | 
apply (rule lub_image_principal, erule f_mono)  | 
|
365  | 
done  | 
|
366  | 
||
367  | 
lemma basis_fun_mono:  | 
|
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"  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
370  | 
assumes below: "\<And>a. f a \<sqsubseteq> g a"  | 
| 27404 | 371  | 
shows "basis_fun f \<sqsubseteq> basis_fun g"  | 
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
372  | 
apply (rule below_cfun_ext)  | 
| 27404 | 373  | 
apply (simp only: basis_fun_beta f_mono g_mono)  | 
374  | 
apply (rule is_lub_thelub0)  | 
|
375  | 
apply (rule basis_fun_lemma, erule f_mono)  | 
|
376  | 
apply (rule ub_imageI, rename_tac a)  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
377  | 
apply (rule below_trans [OF below])  | 
| 27404 | 378  | 
apply (rule is_ub_thelub0)  | 
379  | 
apply (rule basis_fun_lemma, erule g_mono)  | 
|
380  | 
apply (erule imageI)  | 
|
381  | 
done  | 
|
382  | 
||
383  | 
lemma compact_principal [simp]: "compact (principal a)"  | 
|
| 
31076
 
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
 
huffman 
parents: 
30729 
diff
changeset
 | 
384  | 
by (rule compactI2, simp add: principal_below_iff_mem_rep rep_contlub)  | 
| 27404 | 385  | 
|
| 28133 | 386  | 
subsection {* Bifiniteness of ideal completions *}
 | 
387  | 
||
| 27404 | 388  | 
definition  | 
389  | 
completion_approx :: "nat \<Rightarrow> 'b \<rightarrow> 'b" where  | 
|
390  | 
"completion_approx = (\<lambda>i. basis_fun (\<lambda>a. principal (take i a)))"  | 
|
391  | 
||
392  | 
lemma completion_approx_beta:  | 
|
393  | 
"completion_approx i\<cdot>x = (\<Squnion>a\<in>rep x. principal (take i a))"  | 
|
394  | 
unfolding completion_approx_def  | 
|
395  | 
by (simp add: basis_fun_beta principal_mono take_mono)  | 
|
396  | 
||
397  | 
lemma completion_approx_principal:  | 
|
398  | 
"completion_approx i\<cdot>(principal a) = principal (take i a)"  | 
|
399  | 
unfolding completion_approx_def  | 
|
400  | 
by (simp add: basis_fun_principal principal_mono take_mono)  | 
|
401  | 
||
402  | 
lemma chain_completion_approx: "chain completion_approx"  | 
|
403  | 
unfolding completion_approx_def  | 
|
404  | 
apply (rule chainI)  | 
|
405  | 
apply (rule basis_fun_mono)  | 
|
406  | 
apply (erule principal_mono [OF take_mono])  | 
|
407  | 
apply (erule principal_mono [OF take_mono])  | 
|
408  | 
apply (rule principal_mono [OF take_chain])  | 
|
409  | 
done  | 
|
410  | 
||
411  | 
lemma lub_completion_approx: "(\<Squnion>i. completion_approx i\<cdot>x) = x"  | 
|
412  | 
unfolding completion_approx_beta  | 
|
413  | 
apply (subst image_image [where f=principal, symmetric])  | 
|
414  | 
apply (rule unique_lub [OF _ lub_principal_rep])  | 
|
415  | 
apply (rule basis_fun_lemma2, erule principal_mono)  | 
|
416  | 
done  | 
|
417  | 
||
418  | 
lemma completion_approx_eq_principal:  | 
|
419  | 
"\<exists>a\<in>rep x. completion_approx i\<cdot>x = principal (take i a)"  | 
|
420  | 
unfolding completion_approx_beta  | 
|
421  | 
apply (subst image_image [where f=principal, symmetric])  | 
|
422  | 
apply (subgoal_tac "finite (principal ` take i ` rep x)")  | 
|
423  | 
apply (subgoal_tac "directed (principal ` take i ` rep x)")  | 
|
424  | 
apply (drule (1) lub_finite_directed_in_self, fast)  | 
|
425  | 
apply (subst image_image)  | 
|
426  | 
apply (rule directed_image_ideal)  | 
|
427  | 
apply (rule ideal_rep)  | 
|
428  | 
apply (erule principal_mono [OF take_mono])  | 
|
429  | 
apply (rule finite_imageI)  | 
|
430  | 
apply (rule finite_take_rep)  | 
|
431  | 
done  | 
|
432  | 
||
433  | 
lemma completion_approx_idem:  | 
|
434  | 
"completion_approx i\<cdot>(completion_approx i\<cdot>x) = completion_approx i\<cdot>x"  | 
|
435  | 
using completion_approx_eq_principal [where i=i and x=x]  | 
|
436  | 
by (auto simp add: completion_approx_principal take_take)  | 
|
437  | 
||
438  | 
lemma finite_fixes_completion_approx:  | 
|
439  | 
  "finite {x. completion_approx i\<cdot>x = x}" (is "finite ?S")
 | 
|
440  | 
apply (subgoal_tac "?S \<subseteq> principal ` range (take i)")  | 
|
441  | 
apply (erule finite_subset)  | 
|
442  | 
apply (rule finite_imageI)  | 
|
443  | 
apply (rule finite_range_take)  | 
|
444  | 
apply (clarify, erule subst)  | 
|
445  | 
apply (cut_tac x=x and i=i in completion_approx_eq_principal)  | 
|
446  | 
apply fast  | 
|
447  | 
done  | 
|
448  | 
||
449  | 
lemma principal_induct:  | 
|
450  | 
assumes adm: "adm P"  | 
|
451  | 
assumes P: "\<And>a. P (principal a)"  | 
|
452  | 
shows "P x"  | 
|
453  | 
apply (subgoal_tac "P (\<Squnion>i. completion_approx i\<cdot>x)")  | 
|
454  | 
apply (simp add: lub_completion_approx)  | 
|
455  | 
apply (rule admD [OF adm])  | 
|
456  | 
apply (simp add: chain_completion_approx)  | 
|
457  | 
apply (cut_tac x=x and i=i in completion_approx_eq_principal)  | 
|
458  | 
apply (clarify, simp add: P)  | 
|
459  | 
done  | 
|
460  | 
||
461  | 
lemma principal_induct2:  | 
|
462  | 
"\<lbrakk>\<And>y. adm (\<lambda>x. P x y); \<And>x. adm (\<lambda>y. P x y);  | 
|
463  | 
\<And>a b. P (principal a) (principal b)\<rbrakk> \<Longrightarrow> P x y"  | 
|
464  | 
apply (rule_tac x=y in spec)  | 
|
465  | 
apply (rule_tac x=x in principal_induct, simp)  | 
|
466  | 
apply (rule allI, rename_tac y)  | 
|
467  | 
apply (rule_tac x=y in principal_induct, simp)  | 
|
468  | 
apply simp  | 
|
469  | 
done  | 
|
470  | 
||
471  | 
lemma compact_imp_principal: "compact x \<Longrightarrow> \<exists>a. x = principal a"  | 
|
472  | 
apply (drule adm_compact_neq [OF _ cont_id])  | 
|
473  | 
apply (drule admD2 [where Y="\<lambda>n. completion_approx n\<cdot>x"])  | 
|
474  | 
apply (simp add: chain_completion_approx)  | 
|
475  | 
apply (simp add: lub_completion_approx)  | 
|
476  | 
apply (erule exE, erule ssubst)  | 
|
477  | 
apply (cut_tac i=i and x=x in completion_approx_eq_principal)  | 
|
478  | 
apply (clarify, erule exI)  | 
|
479  | 
done  | 
|
480  | 
||
481  | 
end  | 
|
482  | 
||
483  | 
end  |