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