author | huffman |
Thu, 19 Jun 2008 22:43:59 +0200 | |
changeset 27288 | 274b80691259 |
parent 27268 | 1d8c6703c7b1 |
child 27289 | c49d427867aa |
permissions | -rw-r--r-- |
25904 | 1 |
(* Title: HOLCF/CompactBasis.thy |
2 |
ID: $Id$ |
|
3 |
Author: Brian Huffman |
|
4 |
*) |
|
5 |
||
6 |
header {* Compact bases of domains *} |
|
7 |
||
8 |
theory CompactBasis |
|
9 |
imports Bifinite SetPcpo |
|
10 |
begin |
|
11 |
||
12 |
subsection {* Ideals over a preorder *} |
|
13 |
||
27268 | 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" |
|
25904 | 18 |
begin |
19 |
||
20 |
definition |
|
21 |
ideal :: "'a set \<Rightarrow> bool" where |
|
27268 | 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> |
23 |
(\<forall>x y. x \<preceq> y \<longrightarrow> y \<in> A \<longrightarrow> x \<in> A))" |
|
25904 | 24 |
|
25 |
lemma idealI: |
|
26 |
assumes "\<exists>x. x \<in> A" |
|
27268 | 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" |
28 |
assumes "\<And>x y. \<lbrakk>x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A" |
|
25904 | 29 |
shows "ideal A" |
30 |
unfolding ideal_def using prems by fast |
|
31 |
||
32 |
lemma idealD1: |
|
33 |
"ideal A \<Longrightarrow> \<exists>x. x \<in> A" |
|
34 |
unfolding ideal_def by fast |
|
35 |
||
36 |
lemma idealD2: |
|
27268 | 37 |
"\<lbrakk>ideal A; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z" |
25904 | 38 |
unfolding ideal_def by fast |
39 |
||
40 |
lemma idealD3: |
|
27268 | 41 |
"\<lbrakk>ideal A; x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A" |
25904 | 42 |
unfolding ideal_def by fast |
43 |
||
44 |
lemma ideal_directed_finite: |
|
45 |
assumes A: "ideal A" |
|
27268 | 46 |
shows "\<lbrakk>finite U; U \<subseteq> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. \<forall>x\<in>U. x \<preceq> z" |
25904 | 47 |
apply (induct U set: finite) |
48 |
apply (simp add: idealD1 [OF A]) |
|
49 |
apply (simp, clarify, rename_tac y) |
|
50 |
apply (drule (1) idealD2 [OF A]) |
|
51 |
apply (clarify, erule_tac x=z in rev_bexI) |
|
27268 | 52 |
apply (fast intro: r_trans) |
25904 | 53 |
done |
54 |
||
27268 | 55 |
lemma ideal_principal: "ideal {x. x \<preceq> z}" |
25904 | 56 |
apply (rule idealI) |
57 |
apply (rule_tac x=z in exI) |
|
27268 | 58 |
apply (fast intro: r_refl) |
25904 | 59 |
apply (rule_tac x=z in bexI, fast) |
27268 | 60 |
apply (fast intro: r_refl) |
61 |
apply (fast intro: r_trans) |
|
25904 | 62 |
done |
63 |
||
27268 | 64 |
lemma ex_ideal: "\<exists>A. ideal A" |
65 |
by (rule exI, rule ideal_principal) |
|
66 |
||
25904 | 67 |
lemma directed_image_ideal: |
68 |
assumes A: "ideal A" |
|
27268 | 69 |
assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y" |
25904 | 70 |
shows "directed (f ` A)" |
71 |
apply (rule directedI) |
|
72 |
apply (cut_tac idealD1 [OF A], fast) |
|
73 |
apply (clarify, rename_tac a b) |
|
74 |
apply (drule (1) idealD2 [OF A]) |
|
75 |
apply (clarify, rename_tac c) |
|
76 |
apply (rule_tac x="f c" in rev_bexI) |
|
77 |
apply (erule imageI) |
|
78 |
apply (simp add: f) |
|
79 |
done |
|
80 |
||
81 |
lemma adm_ideal: "adm (\<lambda>A. ideal A)" |
|
82 |
unfolding ideal_def by (intro adm_lemmas adm_set_lemmas) |
|
83 |
||
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
84 |
lemma lub_image_principal: |
27268 | 85 |
assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y" |
86 |
shows "(\<Squnion>x\<in>{x. x \<preceq> y}. f x) = f y" |
|
25904 | 87 |
apply (rule thelubI) |
88 |
apply (rule is_lub_maximal) |
|
89 |
apply (rule ub_imageI) |
|
90 |
apply (simp add: f) |
|
91 |
apply (rule imageI) |
|
27268 | 92 |
apply (simp add: r_refl) |
25904 | 93 |
done |
94 |
||
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
95 |
end |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
96 |
|
27268 | 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 |
|
102 |
||
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
103 |
subsection {* Defining functions in terms of basis elements *} |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
104 |
|
26034 | 105 |
lemma finite_directed_contains_lub: |
106 |
"\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u\<in>S. S <<| u" |
|
25904 | 107 |
apply (drule (1) directed_finiteD, rule subset_refl) |
108 |
apply (erule bexE) |
|
26034 | 109 |
apply (rule rev_bexI, assumption) |
25904 | 110 |
apply (erule (1) is_lub_maximal) |
111 |
done |
|
112 |
||
26034 | 113 |
lemma lub_finite_directed_in_self: |
114 |
"\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> lub S \<in> S" |
|
115 |
apply (drule (1) finite_directed_contains_lub, clarify) |
|
116 |
apply (drule thelubI, simp) |
|
117 |
done |
|
118 |
||
119 |
lemma finite_directed_has_lub: "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u. S <<| u" |
|
120 |
by (drule (1) finite_directed_contains_lub, fast) |
|
121 |
||
25904 | 122 |
lemma is_ub_thelub0: "\<lbrakk>\<exists>u. S <<| u; x \<in> S\<rbrakk> \<Longrightarrow> x \<sqsubseteq> lub S" |
123 |
apply (erule exE, drule lubI) |
|
124 |
apply (drule is_lubD1) |
|
125 |
apply (erule (1) is_ubD) |
|
126 |
done |
|
127 |
||
128 |
lemma is_lub_thelub0: "\<lbrakk>\<exists>u. S <<| u; S <| x\<rbrakk> \<Longrightarrow> lub S \<sqsubseteq> x" |
|
129 |
by (erule exE, drule lubI, erule is_lub_lub) |
|
130 |
||
27268 | 131 |
locale basis_take = preorder + |
25904 | 132 |
fixes take :: "nat \<Rightarrow> 'a::type \<Rightarrow> 'a" |
27268 | 133 |
assumes take_less: "take n a \<preceq> a" |
25904 | 134 |
assumes take_take: "take n (take n a) = take n a" |
27268 | 135 |
assumes take_mono: "a \<preceq> b \<Longrightarrow> take n a \<preceq> take n b" |
136 |
assumes take_chain: "take n a \<preceq> take (Suc n) a" |
|
25904 | 137 |
assumes finite_range_take: "finite (range (take n))" |
138 |
assumes take_covers: "\<exists>n. take n a = a" |
|
27288 | 139 |
begin |
140 |
||
141 |
lemma take_chain_less: "m < n \<Longrightarrow> take m a \<preceq> take n a" |
|
142 |
by (erule less_Suc_induct, rule take_chain, erule (1) r_trans) |
|
143 |
||
144 |
lemma take_chain_le: "m \<le> n \<Longrightarrow> take m a \<preceq> take n a" |
|
145 |
by (cases "m = n", simp add: r_refl, simp add: take_chain_less) |
|
146 |
||
147 |
end |
|
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
148 |
|
27268 | 149 |
locale ideal_completion = basis_take + |
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
150 |
fixes principal :: "'a::type \<Rightarrow> 'b::cpo" |
26927 | 151 |
fixes rep :: "'b::cpo \<Rightarrow> 'a::type set" |
152 |
assumes ideal_rep: "\<And>x. preorder.ideal r (rep x)" |
|
153 |
assumes cont_rep: "cont rep" |
|
27268 | 154 |
assumes rep_principal: "\<And>a. rep (principal a) = {b. b \<preceq> a}" |
26927 | 155 |
assumes subset_repD: "\<And>x y. rep x \<subseteq> rep y \<Longrightarrow> x \<sqsubseteq> y" |
25904 | 156 |
begin |
157 |
||
26927 | 158 |
lemma finite_take_rep: "finite (take n ` rep x)" |
25904 | 159 |
by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range_take]) |
160 |
||
161 |
lemma basis_fun_lemma0: |
|
162 |
fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
|
27268 | 163 |
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
26927 | 164 |
shows "\<exists>u. f ` take i ` rep x <<| u" |
25904 | 165 |
apply (rule finite_directed_has_lub) |
166 |
apply (rule finite_imageI) |
|
26927 | 167 |
apply (rule finite_take_rep) |
25904 | 168 |
apply (subst image_image) |
169 |
apply (rule directed_image_ideal) |
|
26927 | 170 |
apply (rule ideal_rep) |
25904 | 171 |
apply (rule f_mono) |
172 |
apply (erule take_mono) |
|
173 |
done |
|
174 |
||
175 |
lemma basis_fun_lemma1: |
|
176 |
fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
|
27268 | 177 |
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
26927 | 178 |
shows "chain (\<lambda>i. lub (f ` take i ` rep x))" |
25904 | 179 |
apply (rule chainI) |
180 |
apply (rule is_lub_thelub0) |
|
181 |
apply (rule basis_fun_lemma0, erule f_mono) |
|
182 |
apply (rule is_ubI, clarsimp, rename_tac a) |
|
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
183 |
apply (rule sq_le.trans_less [OF f_mono [OF take_chain]]) |
25904 | 184 |
apply (rule is_ub_thelub0) |
185 |
apply (rule basis_fun_lemma0, erule f_mono) |
|
186 |
apply simp |
|
187 |
done |
|
188 |
||
189 |
lemma basis_fun_lemma2: |
|
190 |
fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
|
27268 | 191 |
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
26927 | 192 |
shows "f ` rep x <<| (\<Squnion>i. lub (f ` take i ` rep x))" |
25904 | 193 |
apply (rule is_lubI) |
194 |
apply (rule ub_imageI, rename_tac a) |
|
195 |
apply (cut_tac a=a in take_covers, erule exE, rename_tac i) |
|
196 |
apply (erule subst) |
|
197 |
apply (rule rev_trans_less) |
|
198 |
apply (rule_tac x=i in is_ub_thelub) |
|
199 |
apply (rule basis_fun_lemma1, erule f_mono) |
|
200 |
apply (rule is_ub_thelub0) |
|
201 |
apply (rule basis_fun_lemma0, erule f_mono) |
|
202 |
apply simp |
|
203 |
apply (rule is_lub_thelub [OF _ ub_rangeI]) |
|
204 |
apply (rule basis_fun_lemma1, erule f_mono) |
|
205 |
apply (rule is_lub_thelub0) |
|
206 |
apply (rule basis_fun_lemma0, erule f_mono) |
|
207 |
apply (rule is_ubI, clarsimp, rename_tac a) |
|
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
208 |
apply (rule sq_le.trans_less [OF f_mono [OF take_less]]) |
25904 | 209 |
apply (erule (1) ub_imageD) |
210 |
done |
|
211 |
||
212 |
lemma basis_fun_lemma: |
|
213 |
fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
|
27268 | 214 |
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
26927 | 215 |
shows "\<exists>u. f ` rep x <<| u" |
25904 | 216 |
by (rule exI, rule basis_fun_lemma2, erule f_mono) |
217 |
||
26927 | 218 |
lemma rep_mono: "x \<sqsubseteq> y \<Longrightarrow> rep x \<subseteq> rep y" |
219 |
apply (drule cont_rep [THEN cont2mono, THEN monofunE]) |
|
25904 | 220 |
apply (simp add: set_cpo_simps) |
221 |
done |
|
222 |
||
26927 | 223 |
lemma rep_contlub: |
224 |
"chain Y \<Longrightarrow> rep (\<Squnion>i. Y i) = (\<Union>i. rep (Y i))" |
|
225 |
by (simp add: cont2contlubE [OF cont_rep] set_cpo_simps) |
|
25904 | 226 |
|
26927 | 227 |
lemma less_def: "x \<sqsubseteq> y \<longleftrightarrow> rep x \<subseteq> rep y" |
228 |
by (rule iffI [OF rep_mono subset_repD]) |
|
25904 | 229 |
|
26927 | 230 |
lemma rep_eq: "rep x = {a. principal a \<sqsubseteq> x}" |
231 |
unfolding less_def rep_principal |
|
25904 | 232 |
apply safe |
26927 | 233 |
apply (erule (1) idealD3 [OF ideal_rep]) |
27268 | 234 |
apply (erule subsetD, simp add: r_refl) |
25904 | 235 |
done |
236 |
||
26927 | 237 |
lemma mem_rep_iff_principal_less: "a \<in> rep x \<longleftrightarrow> principal a \<sqsubseteq> x" |
238 |
by (simp add: rep_eq) |
|
239 |
||
240 |
lemma principal_less_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x" |
|
241 |
by (simp add: rep_eq) |
|
25904 | 242 |
|
27268 | 243 |
lemma principal_less_iff: "principal a \<sqsubseteq> principal b \<longleftrightarrow> a \<preceq> b" |
26927 | 244 |
by (simp add: principal_less_iff_mem_rep rep_principal) |
25904 | 245 |
|
27268 | 246 |
lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> a \<preceq> b \<and> b \<preceq> a" |
26927 | 247 |
unfolding po_eq_conv [where 'a='b] principal_less_iff .. |
248 |
||
249 |
lemma repD: "a \<in> rep x \<Longrightarrow> principal a \<sqsubseteq> x" |
|
250 |
by (simp add: rep_eq) |
|
25904 | 251 |
|
27268 | 252 |
lemma principal_mono: "a \<preceq> b \<Longrightarrow> principal a \<sqsubseteq> principal b" |
26927 | 253 |
by (simp add: principal_less_iff) |
25904 | 254 |
|
255 |
lemma lessI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u" |
|
26927 | 256 |
unfolding principal_less_iff_mem_rep |
26806 | 257 |
by (simp add: less_def subset_eq) |
25904 | 258 |
|
26927 | 259 |
lemma lub_principal_rep: "principal ` rep x <<| x" |
25904 | 260 |
apply (rule is_lubI) |
261 |
apply (rule ub_imageI) |
|
26927 | 262 |
apply (erule repD) |
25904 | 263 |
apply (subst less_def) |
264 |
apply (rule subsetI) |
|
265 |
apply (drule (1) ub_imageD) |
|
26927 | 266 |
apply (simp add: rep_eq) |
25904 | 267 |
done |
268 |
||
269 |
definition |
|
270 |
basis_fun :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where |
|
26927 | 271 |
"basis_fun = (\<lambda>f. (\<Lambda> x. lub (f ` rep x)))" |
25904 | 272 |
|
273 |
lemma basis_fun_beta: |
|
274 |
fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
|
27268 | 275 |
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
26927 | 276 |
shows "basis_fun f\<cdot>x = lub (f ` rep x)" |
25904 | 277 |
unfolding basis_fun_def |
278 |
proof (rule beta_cfun) |
|
26927 | 279 |
have lub: "\<And>x. \<exists>u. f ` rep x <<| u" |
25904 | 280 |
using f_mono by (rule basis_fun_lemma) |
26927 | 281 |
show cont: "cont (\<lambda>x. lub (f ` rep x))" |
25904 | 282 |
apply (rule contI2) |
283 |
apply (rule monofunI) |
|
284 |
apply (rule is_lub_thelub0 [OF lub ub_imageI]) |
|
285 |
apply (rule is_ub_thelub0 [OF lub imageI]) |
|
26927 | 286 |
apply (erule (1) subsetD [OF rep_mono]) |
25904 | 287 |
apply (rule is_lub_thelub0 [OF lub ub_imageI]) |
26927 | 288 |
apply (simp add: rep_contlub, clarify) |
25904 | 289 |
apply (erule rev_trans_less [OF is_ub_thelub]) |
290 |
apply (erule is_ub_thelub0 [OF lub imageI]) |
|
291 |
done |
|
292 |
qed |
|
293 |
||
294 |
lemma basis_fun_principal: |
|
295 |
fixes f :: "'a::type \<Rightarrow> 'c::cpo" |
|
27268 | 296 |
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
25904 | 297 |
shows "basis_fun f\<cdot>(principal a) = f a" |
298 |
apply (subst basis_fun_beta, erule f_mono) |
|
26927 | 299 |
apply (subst rep_principal) |
25904 | 300 |
apply (rule lub_image_principal, erule f_mono) |
301 |
done |
|
302 |
||
303 |
lemma basis_fun_mono: |
|
27268 | 304 |
assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b" |
305 |
assumes g_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> g a \<sqsubseteq> g b" |
|
25904 | 306 |
assumes less: "\<And>a. f a \<sqsubseteq> g a" |
307 |
shows "basis_fun f \<sqsubseteq> basis_fun g" |
|
308 |
apply (rule less_cfun_ext) |
|
309 |
apply (simp only: basis_fun_beta f_mono g_mono) |
|
310 |
apply (rule is_lub_thelub0) |
|
311 |
apply (rule basis_fun_lemma, erule f_mono) |
|
312 |
apply (rule ub_imageI, rename_tac a) |
|
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
313 |
apply (rule sq_le.trans_less [OF less]) |
25904 | 314 |
apply (rule is_ub_thelub0) |
315 |
apply (rule basis_fun_lemma, erule g_mono) |
|
316 |
apply (erule imageI) |
|
317 |
done |
|
318 |
||
319 |
lemma compact_principal: "compact (principal a)" |
|
26927 | 320 |
by (rule compactI2, simp add: principal_less_iff_mem_rep rep_contlub) |
321 |
||
322 |
definition |
|
323 |
completion_approx :: "nat \<Rightarrow> 'b \<rightarrow> 'b" where |
|
324 |
"completion_approx = (\<lambda>i. basis_fun (\<lambda>a. principal (take i a)))" |
|
25904 | 325 |
|
26927 | 326 |
lemma completion_approx_beta: |
327 |
"completion_approx i\<cdot>x = (\<Squnion>a\<in>rep x. principal (take i a))" |
|
328 |
unfolding completion_approx_def |
|
329 |
by (simp add: basis_fun_beta principal_mono take_mono) |
|
330 |
||
331 |
lemma completion_approx_principal: |
|
332 |
"completion_approx i\<cdot>(principal a) = principal (take i a)" |
|
333 |
unfolding completion_approx_def |
|
334 |
by (simp add: basis_fun_principal principal_mono take_mono) |
|
335 |
||
336 |
lemma chain_completion_approx: "chain completion_approx" |
|
337 |
unfolding completion_approx_def |
|
25904 | 338 |
apply (rule chainI) |
339 |
apply (rule basis_fun_mono) |
|
340 |
apply (erule principal_mono [OF take_mono]) |
|
341 |
apply (erule principal_mono [OF take_mono]) |
|
342 |
apply (rule principal_mono [OF take_chain]) |
|
343 |
done |
|
344 |
||
26927 | 345 |
lemma lub_completion_approx: "(\<Squnion>i. completion_approx i\<cdot>x) = x" |
346 |
unfolding completion_approx_beta |
|
25904 | 347 |
apply (subst image_image [where f=principal, symmetric]) |
26927 | 348 |
apply (rule unique_lub [OF _ lub_principal_rep]) |
25904 | 349 |
apply (rule basis_fun_lemma2, erule principal_mono) |
350 |
done |
|
351 |
||
26927 | 352 |
lemma completion_approx_eq_principal: |
353 |
"\<exists>a\<in>rep x. completion_approx i\<cdot>x = principal (take i a)" |
|
354 |
unfolding completion_approx_beta |
|
25904 | 355 |
apply (subst image_image [where f=principal, symmetric]) |
26927 | 356 |
apply (subgoal_tac "finite (principal ` take i ` rep x)") |
357 |
apply (subgoal_tac "directed (principal ` take i ` rep x)") |
|
25904 | 358 |
apply (drule (1) lub_finite_directed_in_self, fast) |
359 |
apply (subst image_image) |
|
360 |
apply (rule directed_image_ideal) |
|
26927 | 361 |
apply (rule ideal_rep) |
25904 | 362 |
apply (erule principal_mono [OF take_mono]) |
363 |
apply (rule finite_imageI) |
|
26927 | 364 |
apply (rule finite_take_rep) |
365 |
done |
|
366 |
||
367 |
lemma completion_approx_idem: |
|
368 |
"completion_approx i\<cdot>(completion_approx i\<cdot>x) = completion_approx i\<cdot>x" |
|
369 |
using completion_approx_eq_principal [where i=i and x=x] |
|
370 |
by (auto simp add: completion_approx_principal take_take) |
|
371 |
||
372 |
lemma finite_fixes_completion_approx: |
|
373 |
"finite {x. completion_approx i\<cdot>x = x}" (is "finite ?S") |
|
374 |
apply (subgoal_tac "?S \<subseteq> principal ` range (take i)") |
|
375 |
apply (erule finite_subset) |
|
376 |
apply (rule finite_imageI) |
|
377 |
apply (rule finite_range_take) |
|
378 |
apply (clarify, erule subst) |
|
379 |
apply (cut_tac x=x and i=i in completion_approx_eq_principal) |
|
380 |
apply fast |
|
25904 | 381 |
done |
382 |
||
383 |
lemma principal_induct: |
|
384 |
assumes adm: "adm P" |
|
385 |
assumes P: "\<And>a. P (principal a)" |
|
386 |
shows "P x" |
|
26927 | 387 |
apply (subgoal_tac "P (\<Squnion>i. completion_approx i\<cdot>x)") |
388 |
apply (simp add: lub_completion_approx) |
|
25925 | 389 |
apply (rule admD [OF adm]) |
26927 | 390 |
apply (simp add: chain_completion_approx) |
391 |
apply (cut_tac x=x and i=i in completion_approx_eq_principal) |
|
25904 | 392 |
apply (clarify, simp add: P) |
393 |
done |
|
394 |
||
27267
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
395 |
lemma compact_imp_principal: "compact x \<Longrightarrow> \<exists>a. x = principal a" |
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
396 |
apply (drule adm_compact_neq [OF _ cont_id]) |
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
397 |
apply (drule admD2 [where Y="\<lambda>n. completion_approx n\<cdot>x"]) |
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
398 |
apply (simp add: chain_completion_approx) |
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
399 |
apply (simp add: lub_completion_approx) |
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
400 |
apply (erule exE, erule ssubst) |
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
401 |
apply (cut_tac i=i and x=x in completion_approx_eq_principal) |
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
402 |
apply (clarify, erule exI) |
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
403 |
done |
5ebfb7f25ebb
add lemma compact_imp_principal to locale ideal_completion
huffman
parents:
26927
diff
changeset
|
404 |
|
25904 | 405 |
end |
406 |
||
407 |
||
408 |
subsection {* Compact bases of bifinite domains *} |
|
409 |
||
26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
26041
diff
changeset
|
410 |
defaultsort profinite |
25904 | 411 |
|
26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
26041
diff
changeset
|
412 |
typedef (open) 'a compact_basis = "{x::'a::profinite. compact x}" |
25904 | 413 |
by (fast intro: compact_approx) |
414 |
||
415 |
lemma compact_Rep_compact_basis [simp]: "compact (Rep_compact_basis a)" |
|
26927 | 416 |
by (rule Rep_compact_basis [unfolded mem_Collect_eq]) |
25904 | 417 |
|
418 |
lemma Rep_Abs_compact_basis_approx [simp]: |
|
419 |
"Rep_compact_basis (Abs_compact_basis (approx n\<cdot>x)) = approx n\<cdot>x" |
|
420 |
by (rule Abs_compact_basis_inverse, simp) |
|
421 |
||
422 |
lemma compact_imp_Rep_compact_basis: |
|
423 |
"compact x \<Longrightarrow> \<exists>y. x = Rep_compact_basis y" |
|
424 |
by (rule exI, rule Abs_compact_basis_inverse [symmetric], simp) |
|
425 |
||
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
426 |
instantiation compact_basis :: (profinite) sq_ord |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
427 |
begin |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
428 |
|
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
429 |
definition |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
430 |
compact_le_def: |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
431 |
"(op \<sqsubseteq>) \<equiv> (\<lambda>x y. Rep_compact_basis x \<sqsubseteq> Rep_compact_basis y)" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
432 |
|
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
433 |
instance .. |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
434 |
|
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
435 |
end |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
436 |
|
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
437 |
instance compact_basis :: (profinite) po |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
438 |
by (rule typedef_po |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
439 |
[OF type_definition_compact_basis compact_le_def]) |
25904 | 440 |
|
441 |
text {* minimal compact element *} |
|
442 |
||
443 |
definition |
|
26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
26041
diff
changeset
|
444 |
compact_bot :: "'a::bifinite compact_basis" where |
25904 | 445 |
"compact_bot = Abs_compact_basis \<bottom>" |
446 |
||
447 |
lemma Rep_compact_bot: "Rep_compact_basis compact_bot = \<bottom>" |
|
448 |
unfolding compact_bot_def by (simp add: Abs_compact_basis_inverse) |
|
449 |
||
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
450 |
lemma compact_minimal [simp]: "compact_bot \<sqsubseteq> a" |
25904 | 451 |
unfolding compact_le_def Rep_compact_bot by simp |
452 |
||
453 |
text {* compacts *} |
|
454 |
||
455 |
definition |
|
456 |
compacts :: "'a \<Rightarrow> 'a compact_basis set" where |
|
457 |
"compacts = (\<lambda>x. {a. Rep_compact_basis a \<sqsubseteq> x})" |
|
458 |
||
27268 | 459 |
lemma ideal_compacts: "sq_le.ideal (compacts w)" |
25904 | 460 |
unfolding compacts_def |
27268 | 461 |
apply (rule sq_le.idealI) |
25904 | 462 |
apply (rule_tac x="Abs_compact_basis (approx 0\<cdot>w)" in exI) |
463 |
apply (simp add: approx_less) |
|
464 |
apply simp |
|
465 |
apply (cut_tac a=x in compact_Rep_compact_basis) |
|
466 |
apply (cut_tac a=y in compact_Rep_compact_basis) |
|
467 |
apply (drule bifinite_compact_eq_approx) |
|
468 |
apply (drule bifinite_compact_eq_approx) |
|
469 |
apply (clarify, rename_tac i j) |
|
470 |
apply (rule_tac x="Abs_compact_basis (approx (max i j)\<cdot>w)" in exI) |
|
471 |
apply (simp add: approx_less compact_le_def) |
|
472 |
apply (erule subst, erule subst) |
|
25922
cb04d05e95fb
rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents:
25904
diff
changeset
|
473 |
apply (simp add: monofun_cfun chain_mono [OF chain_approx]) |
25904 | 474 |
apply (simp add: compact_le_def) |
475 |
apply (erule (1) trans_less) |
|
476 |
done |
|
477 |
||
478 |
lemma compacts_Rep_compact_basis: |
|
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
479 |
"compacts (Rep_compact_basis b) = {a. a \<sqsubseteq> b}" |
25904 | 480 |
unfolding compacts_def compact_le_def .. |
481 |
||
482 |
lemma cont_compacts: "cont compacts" |
|
483 |
unfolding compacts_def |
|
484 |
apply (rule contI2) |
|
485 |
apply (rule monofunI) |
|
486 |
apply (simp add: set_cpo_simps) |
|
487 |
apply (fast intro: trans_less) |
|
488 |
apply (simp add: set_cpo_simps) |
|
489 |
apply clarify |
|
490 |
apply simp |
|
491 |
apply (erule (1) compactD2 [OF compact_Rep_compact_basis]) |
|
492 |
done |
|
493 |
||
494 |
lemma compacts_lessD: "compacts x \<subseteq> compacts y \<Longrightarrow> x \<sqsubseteq> y" |
|
495 |
apply (subgoal_tac "(\<Squnion>i. approx i\<cdot>x) \<sqsubseteq> y", simp) |
|
25925 | 496 |
apply (rule admD, simp, simp) |
25904 | 497 |
apply (drule_tac c="Abs_compact_basis (approx i\<cdot>x)" in subsetD) |
498 |
apply (simp add: compacts_def Abs_compact_basis_inverse approx_less) |
|
499 |
apply (simp add: compacts_def Abs_compact_basis_inverse) |
|
500 |
done |
|
501 |
||
502 |
lemma compacts_mono: "x \<sqsubseteq> y \<Longrightarrow> compacts x \<subseteq> compacts y" |
|
503 |
unfolding compacts_def by (fast intro: trans_less) |
|
504 |
||
505 |
lemma less_compact_basis_iff: "(x \<sqsubseteq> y) = (compacts x \<subseteq> compacts y)" |
|
506 |
by (rule iffI [OF compacts_mono compacts_lessD]) |
|
507 |
||
508 |
lemma compact_basis_induct: |
|
509 |
"\<lbrakk>adm P; \<And>a. P (Rep_compact_basis a)\<rbrakk> \<Longrightarrow> P x" |
|
510 |
apply (erule approx_induct) |
|
511 |
apply (drule_tac x="Abs_compact_basis (approx n\<cdot>x)" in meta_spec) |
|
512 |
apply (simp add: Abs_compact_basis_inverse) |
|
513 |
done |
|
514 |
||
515 |
text {* approximation on compact bases *} |
|
516 |
||
517 |
definition |
|
518 |
compact_approx :: "nat \<Rightarrow> 'a compact_basis \<Rightarrow> 'a compact_basis" where |
|
519 |
"compact_approx = (\<lambda>n a. Abs_compact_basis (approx n\<cdot>(Rep_compact_basis a)))" |
|
520 |
||
521 |
lemma Rep_compact_approx: |
|
522 |
"Rep_compact_basis (compact_approx n a) = approx n\<cdot>(Rep_compact_basis a)" |
|
523 |
unfolding compact_approx_def |
|
524 |
by (simp add: Abs_compact_basis_inverse) |
|
525 |
||
526 |
lemmas approx_Rep_compact_basis = Rep_compact_approx [symmetric] |
|
527 |
||
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
528 |
lemma compact_approx_le: "compact_approx n a \<sqsubseteq> a" |
25904 | 529 |
unfolding compact_le_def |
530 |
by (simp add: Rep_compact_approx approx_less) |
|
531 |
||
532 |
lemma compact_approx_mono1: |
|
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
533 |
"i \<le> j \<Longrightarrow> compact_approx i a \<sqsubseteq> compact_approx j a" |
25904 | 534 |
unfolding compact_le_def |
535 |
apply (simp add: Rep_compact_approx) |
|
25922
cb04d05e95fb
rename lemma chain_mono3 -> chain_mono, chain_mono -> chain_mono_less
huffman
parents:
25904
diff
changeset
|
536 |
apply (rule chain_mono, simp, assumption) |
25904 | 537 |
done |
538 |
||
539 |
lemma compact_approx_mono: |
|
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
540 |
"a \<sqsubseteq> b \<Longrightarrow> compact_approx n a \<sqsubseteq> compact_approx n b" |
25904 | 541 |
unfolding compact_le_def |
542 |
apply (simp add: Rep_compact_approx) |
|
543 |
apply (erule monofun_cfun_arg) |
|
544 |
done |
|
545 |
||
546 |
lemma ex_compact_approx_eq: "\<exists>n. compact_approx n a = a" |
|
547 |
apply (simp add: Rep_compact_basis_inject [symmetric]) |
|
548 |
apply (simp add: Rep_compact_approx) |
|
549 |
apply (rule bifinite_compact_eq_approx) |
|
550 |
apply (rule compact_Rep_compact_basis) |
|
551 |
done |
|
552 |
||
553 |
lemma compact_approx_idem: |
|
554 |
"compact_approx n (compact_approx n a) = compact_approx n a" |
|
555 |
apply (rule Rep_compact_basis_inject [THEN iffD1]) |
|
556 |
apply (simp add: Rep_compact_approx) |
|
557 |
done |
|
558 |
||
559 |
lemma finite_fixes_compact_approx: "finite {a. compact_approx n a = a}" |
|
560 |
apply (subgoal_tac "finite (Rep_compact_basis ` {a. compact_approx n a = a})") |
|
561 |
apply (erule finite_imageD) |
|
562 |
apply (rule inj_onI, simp add: Rep_compact_basis_inject) |
|
563 |
apply (rule finite_subset [OF _ finite_fixes_approx [where i=n]]) |
|
564 |
apply (rule subsetI, clarify, rename_tac a) |
|
565 |
apply (simp add: Rep_compact_basis_inject [symmetric]) |
|
566 |
apply (simp add: Rep_compact_approx) |
|
567 |
done |
|
568 |
||
569 |
lemma finite_range_compact_approx: "finite (range (compact_approx n))" |
|
570 |
apply (cut_tac n=n in finite_fixes_compact_approx) |
|
571 |
apply (simp add: idem_fixes_eq_range compact_approx_idem) |
|
572 |
apply (simp add: image_def) |
|
573 |
done |
|
574 |
||
575 |
interpretation compact_basis: |
|
26927 | 576 |
ideal_completion [sq_le compact_approx Rep_compact_basis compacts] |
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
577 |
proof (unfold_locales) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
578 |
fix n :: nat and a b :: "'a compact_basis" and x :: "'a" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
579 |
show "compact_approx n a \<sqsubseteq> a" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
580 |
by (rule compact_approx_le) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
581 |
show "compact_approx n (compact_approx n a) = compact_approx n a" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
582 |
by (rule compact_approx_idem) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
583 |
show "compact_approx n a \<sqsubseteq> compact_approx (Suc n) a" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
584 |
by (rule compact_approx_mono1, simp) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
585 |
show "finite (range (compact_approx n))" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
586 |
by (rule finite_range_compact_approx) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
587 |
show "\<exists>n\<Colon>nat. compact_approx n a = a" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
588 |
by (rule ex_compact_approx_eq) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
589 |
show "preorder.ideal sq_le (compacts x)" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
590 |
by (rule ideal_compacts) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
591 |
show "cont compacts" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
592 |
by (rule cont_compacts) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
593 |
show "compacts (Rep_compact_basis a) = {b. b \<sqsubseteq> a}" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
594 |
by (rule compacts_Rep_compact_basis) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
595 |
next |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
596 |
fix n :: nat and a b :: "'a compact_basis" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
597 |
assume "a \<sqsubseteq> b" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
598 |
thus "compact_approx n a \<sqsubseteq> compact_approx n b" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
599 |
by (rule compact_approx_mono) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
600 |
next |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
601 |
fix x y :: "'a" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
602 |
assume "compacts x \<subseteq> compacts y" thus "x \<sqsubseteq> y" |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
603 |
by (rule compacts_lessD) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
604 |
qed |
25904 | 605 |
|
606 |
||
607 |
subsection {* A compact basis for powerdomains *} |
|
608 |
||
609 |
typedef 'a pd_basis = |
|
26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
26041
diff
changeset
|
610 |
"{S::'a::profinite compact_basis set. finite S \<and> S \<noteq> {}}" |
25904 | 611 |
by (rule_tac x="{arbitrary}" in exI, simp) |
612 |
||
613 |
lemma finite_Rep_pd_basis [simp]: "finite (Rep_pd_basis u)" |
|
614 |
by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp |
|
615 |
||
616 |
lemma Rep_pd_basis_nonempty [simp]: "Rep_pd_basis u \<noteq> {}" |
|
617 |
by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp |
|
618 |
||
619 |
text {* unit and plus *} |
|
620 |
||
621 |
definition |
|
622 |
PDUnit :: "'a compact_basis \<Rightarrow> 'a pd_basis" where |
|
623 |
"PDUnit = (\<lambda>x. Abs_pd_basis {x})" |
|
624 |
||
625 |
definition |
|
626 |
PDPlus :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> 'a pd_basis" where |
|
627 |
"PDPlus t u = Abs_pd_basis (Rep_pd_basis t \<union> Rep_pd_basis u)" |
|
628 |
||
629 |
lemma Rep_PDUnit: |
|
630 |
"Rep_pd_basis (PDUnit x) = {x}" |
|
631 |
unfolding PDUnit_def by (rule Abs_pd_basis_inverse) (simp add: pd_basis_def) |
|
632 |
||
633 |
lemma Rep_PDPlus: |
|
634 |
"Rep_pd_basis (PDPlus u v) = Rep_pd_basis u \<union> Rep_pd_basis v" |
|
635 |
unfolding PDPlus_def by (rule Abs_pd_basis_inverse) (simp add: pd_basis_def) |
|
636 |
||
637 |
lemma PDUnit_inject [simp]: "(PDUnit a = PDUnit b) = (a = b)" |
|
638 |
unfolding Rep_pd_basis_inject [symmetric] Rep_PDUnit by simp |
|
639 |
||
640 |
lemma PDPlus_assoc: "PDPlus (PDPlus t u) v = PDPlus t (PDPlus u v)" |
|
641 |
unfolding Rep_pd_basis_inject [symmetric] Rep_PDPlus by (rule Un_assoc) |
|
642 |
||
643 |
lemma PDPlus_commute: "PDPlus t u = PDPlus u t" |
|
644 |
unfolding Rep_pd_basis_inject [symmetric] Rep_PDPlus by (rule Un_commute) |
|
645 |
||
646 |
lemma PDPlus_absorb: "PDPlus t t = t" |
|
647 |
unfolding Rep_pd_basis_inject [symmetric] Rep_PDPlus by (rule Un_absorb) |
|
648 |
||
649 |
lemma pd_basis_induct1: |
|
650 |
assumes PDUnit: "\<And>a. P (PDUnit a)" |
|
651 |
assumes PDPlus: "\<And>a t. P t \<Longrightarrow> P (PDPlus (PDUnit a) t)" |
|
652 |
shows "P x" |
|
653 |
apply (induct x, unfold pd_basis_def, clarify) |
|
654 |
apply (erule (1) finite_ne_induct) |
|
655 |
apply (cut_tac a=x in PDUnit) |
|
656 |
apply (simp add: PDUnit_def) |
|
657 |
apply (drule_tac a=x in PDPlus) |
|
658 |
apply (simp add: PDUnit_def PDPlus_def Abs_pd_basis_inverse [unfolded pd_basis_def]) |
|
659 |
done |
|
660 |
||
661 |
lemma pd_basis_induct: |
|
662 |
assumes PDUnit: "\<And>a. P (PDUnit a)" |
|
663 |
assumes PDPlus: "\<And>t u. \<lbrakk>P t; P u\<rbrakk> \<Longrightarrow> P (PDPlus t u)" |
|
664 |
shows "P x" |
|
665 |
apply (induct x rule: pd_basis_induct1) |
|
666 |
apply (rule PDUnit, erule PDPlus [OF PDUnit]) |
|
667 |
done |
|
668 |
||
669 |
text {* fold-pd *} |
|
670 |
||
671 |
definition |
|
672 |
fold_pd :: |
|
673 |
"('a compact_basis \<Rightarrow> 'b::type) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a pd_basis \<Rightarrow> 'b" |
|
674 |
where "fold_pd g f t = fold1 f (g ` Rep_pd_basis t)" |
|
675 |
||
26927 | 676 |
lemma fold_pd_PDUnit: |
677 |
includes ab_semigroup_idem_mult f |
|
678 |
shows "fold_pd g f (PDUnit x) = g x" |
|
25904 | 679 |
unfolding fold_pd_def Rep_PDUnit by simp |
680 |
||
26927 | 681 |
lemma fold_pd_PDPlus: |
682 |
includes ab_semigroup_idem_mult f |
|
683 |
shows "fold_pd g f (PDPlus t u) = f (fold_pd g f t) (fold_pd g f u)" |
|
25904 | 684 |
unfolding fold_pd_def Rep_PDPlus by (simp add: image_Un fold1_Un2) |
685 |
||
686 |
text {* approx-pd *} |
|
687 |
||
688 |
definition |
|
689 |
approx_pd :: "nat \<Rightarrow> 'a pd_basis \<Rightarrow> 'a pd_basis" where |
|
690 |
"approx_pd n = (\<lambda>t. Abs_pd_basis (compact_approx n ` Rep_pd_basis t))" |
|
691 |
||
692 |
lemma Rep_approx_pd: |
|
693 |
"Rep_pd_basis (approx_pd n t) = compact_approx n ` Rep_pd_basis t" |
|
694 |
unfolding approx_pd_def |
|
695 |
apply (rule Abs_pd_basis_inverse) |
|
696 |
apply (simp add: pd_basis_def) |
|
697 |
done |
|
698 |
||
699 |
lemma approx_pd_simps [simp]: |
|
700 |
"approx_pd n (PDUnit a) = PDUnit (compact_approx n a)" |
|
701 |
"approx_pd n (PDPlus t u) = PDPlus (approx_pd n t) (approx_pd n u)" |
|
702 |
apply (simp_all add: Rep_pd_basis_inject [symmetric]) |
|
703 |
apply (simp_all add: Rep_approx_pd Rep_PDUnit Rep_PDPlus image_Un) |
|
704 |
done |
|
705 |
||
706 |
lemma approx_pd_idem: "approx_pd n (approx_pd n t) = approx_pd n t" |
|
707 |
apply (induct t rule: pd_basis_induct) |
|
708 |
apply (simp add: compact_approx_idem) |
|
709 |
apply simp |
|
710 |
done |
|
711 |
||
712 |
lemma range_image_f: "range (image f) = Pow (range f)" |
|
713 |
apply (safe, fast) |
|
714 |
apply (rule_tac x="f -` x" in range_eqI) |
|
715 |
apply (simp, fast) |
|
716 |
done |
|
717 |
||
718 |
lemma finite_range_approx_pd: "finite (range (approx_pd n))" |
|
719 |
apply (subgoal_tac "finite (Rep_pd_basis ` range (approx_pd n))") |
|
720 |
apply (erule finite_imageD) |
|
721 |
apply (rule inj_onI, simp add: Rep_pd_basis_inject) |
|
722 |
apply (subst image_image) |
|
723 |
apply (subst Rep_approx_pd) |
|
724 |
apply (simp only: range_composition) |
|
725 |
apply (rule finite_subset [OF image_mono [OF subset_UNIV]]) |
|
726 |
apply (simp add: range_image_f) |
|
727 |
apply (rule finite_range_compact_approx) |
|
728 |
done |
|
729 |
||
730 |
lemma ex_approx_pd_eq: "\<exists>n. approx_pd n t = t" |
|
731 |
apply (subgoal_tac "\<exists>n. \<forall>m\<ge>n. approx_pd m t = t", fast) |
|
732 |
apply (induct t rule: pd_basis_induct) |
|
733 |
apply (cut_tac a=a in ex_compact_approx_eq) |
|
734 |
apply (clarify, rule_tac x=n in exI) |
|
735 |
apply (clarify, simp) |
|
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26407
diff
changeset
|
736 |
apply (rule antisym_less) |
25904 | 737 |
apply (rule compact_approx_le) |
738 |
apply (drule_tac a=a in compact_approx_mono1) |
|
739 |
apply simp |
|
740 |
apply (clarify, rename_tac i j) |
|
741 |
apply (rule_tac x="max i j" in exI, simp) |
|
742 |
done |
|
743 |
||
744 |
end |