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