author | haftmann |
Tue, 10 Jun 2008 14:32:58 +0200 | |
changeset 27101 | 864d29f11c9d |
parent 26420 | 57a626f64875 |
child 27296 | eec7a1889ca5 |
permissions | -rw-r--r-- |
16697 | 1 |
(* Title: HOLCF/Pcpodef.thy |
2 |
ID: $Id$ |
|
3 |
Author: Brian Huffman |
|
4 |
*) |
|
5 |
||
6 |
header {* Subtypes of pcpos *} |
|
7 |
||
8 |
theory Pcpodef |
|
9 |
imports Adm |
|
23152 | 10 |
uses ("Tools/pcpodef_package.ML") |
16697 | 11 |
begin |
12 |
||
13 |
subsection {* Proving a subtype is a partial order *} |
|
14 |
||
15 |
text {* |
|
16 |
A subtype of a partial order is itself a partial order, |
|
17 |
if the ordering is defined in the standard way. |
|
18 |
*} |
|
19 |
||
20 |
theorem typedef_po: |
|
21 |
fixes Abs :: "'a::po \<Rightarrow> 'b::sq_ord" |
|
22 |
assumes type: "type_definition Rep Abs A" |
|
23 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
24 |
shows "OFCLASS('b, po_class)" |
|
25 |
apply (intro_classes, unfold less) |
|
26 |
apply (rule refl_less) |
|
26420
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26027
diff
changeset
|
27 |
apply (erule (1) trans_less) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26027
diff
changeset
|
28 |
apply (rule type_definition.Rep_inject [OF type, THEN iffD1]) |
57a626f64875
make preorder locale into a superclass of class po
huffman
parents:
26027
diff
changeset
|
29 |
apply (erule (1) antisym_less) |
16697 | 30 |
done |
31 |
||
25827
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
32 |
subsection {* Proving a subtype is finite *} |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
33 |
|
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
34 |
context type_definition |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
35 |
begin |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
36 |
|
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
37 |
lemma Abs_image: |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
38 |
shows "Abs ` A = UNIV" |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
39 |
proof |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
40 |
show "Abs ` A <= UNIV" by simp |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
41 |
show "UNIV <= Abs ` A" |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
42 |
proof |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
43 |
fix x |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
44 |
have "x = Abs (Rep x)" by (rule Rep_inverse [symmetric]) |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
45 |
thus "x : Abs ` A" using Rep by (rule image_eqI) |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
46 |
qed |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
47 |
qed |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
48 |
|
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
49 |
lemma finite_UNIV: "finite A \<Longrightarrow> finite (UNIV :: 'b set)" |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
50 |
proof - |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
51 |
assume "finite A" |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
52 |
hence "finite (Abs ` A)" by (rule finite_imageI) |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
53 |
thus "finite (UNIV :: 'b set)" by (simp only: Abs_image) |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
54 |
qed |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
55 |
|
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
56 |
end |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
57 |
|
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
58 |
theorem typedef_finite_po: |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
59 |
fixes Abs :: "'a::finite_po \<Rightarrow> 'b::po" |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
60 |
assumes type: "type_definition Rep Abs A" |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
61 |
shows "OFCLASS('b, finite_po_class)" |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
62 |
apply (intro_classes) |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
63 |
apply (rule type_definition.finite_UNIV [OF type]) |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
64 |
apply (rule finite) |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
65 |
done |
c2adeb1bae5c
new instance proofs for classes finite_po, chfin, flat
huffman
parents:
23152
diff
changeset
|
66 |
|
17812 | 67 |
subsection {* Proving a subtype is chain-finite *} |
68 |
||
69 |
lemma monofun_Rep: |
|
70 |
assumes less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
71 |
shows "monofun Rep" |
|
72 |
by (rule monofunI, unfold less) |
|
73 |
||
74 |
lemmas ch2ch_Rep = ch2ch_monofun [OF monofun_Rep] |
|
75 |
lemmas ub2ub_Rep = ub2ub_monofun [OF monofun_Rep] |
|
76 |
||
77 |
theorem typedef_chfin: |
|
78 |
fixes Abs :: "'a::chfin \<Rightarrow> 'b::po" |
|
79 |
assumes type: "type_definition Rep Abs A" |
|
80 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
81 |
shows "OFCLASS('b, chfin_class)" |
|
25921 | 82 |
apply intro_classes |
17812 | 83 |
apply (drule ch2ch_Rep [OF less]) |
25921 | 84 |
apply (drule chfin) |
17812 | 85 |
apply (unfold max_in_chain_def) |
86 |
apply (simp add: type_definition.Rep_inject [OF type]) |
|
87 |
done |
|
88 |
||
16697 | 89 |
subsection {* Proving a subtype is complete *} |
90 |
||
91 |
text {* |
|
92 |
A subtype of a cpo is itself a cpo if the ordering is |
|
93 |
defined in the standard way, and the defining subset |
|
94 |
is closed with respect to limits of chains. A set is |
|
95 |
closed if and only if membership in the set is an |
|
96 |
admissible predicate. |
|
97 |
*} |
|
98 |
||
16918 | 99 |
lemma Abs_inverse_lub_Rep: |
16697 | 100 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::po" |
101 |
assumes type: "type_definition Rep Abs A" |
|
102 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
103 |
and adm: "adm (\<lambda>x. x \<in> A)" |
|
16918 | 104 |
shows "chain S \<Longrightarrow> Rep (Abs (\<Squnion>i. Rep (S i))) = (\<Squnion>i. Rep (S i))" |
105 |
apply (rule type_definition.Abs_inverse [OF type]) |
|
25925 | 106 |
apply (erule admD [OF adm ch2ch_Rep [OF less]]) |
16697 | 107 |
apply (rule type_definition.Rep [OF type]) |
108 |
done |
|
109 |
||
16918 | 110 |
theorem typedef_lub: |
16697 | 111 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::po" |
112 |
assumes type: "type_definition Rep Abs A" |
|
113 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
114 |
and adm: "adm (\<lambda>x. x \<in> A)" |
|
16918 | 115 |
shows "chain S \<Longrightarrow> range S <<| Abs (\<Squnion>i. Rep (S i))" |
116 |
apply (frule ch2ch_Rep [OF less]) |
|
16697 | 117 |
apply (rule is_lubI) |
118 |
apply (rule ub_rangeI) |
|
16918 | 119 |
apply (simp only: less Abs_inverse_lub_Rep [OF type less adm]) |
120 |
apply (erule is_ub_thelub) |
|
121 |
apply (simp only: less Abs_inverse_lub_Rep [OF type less adm]) |
|
122 |
apply (erule is_lub_thelub) |
|
123 |
apply (erule ub2ub_Rep [OF less]) |
|
16697 | 124 |
done |
125 |
||
16918 | 126 |
lemmas typedef_thelub = typedef_lub [THEN thelubI, standard] |
127 |
||
16697 | 128 |
theorem typedef_cpo: |
129 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::po" |
|
130 |
assumes type: "type_definition Rep Abs A" |
|
131 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
132 |
and adm: "adm (\<lambda>x. x \<in> A)" |
|
133 |
shows "OFCLASS('b, cpo_class)" |
|
16918 | 134 |
proof |
135 |
fix S::"nat \<Rightarrow> 'b" assume "chain S" |
|
136 |
hence "range S <<| Abs (\<Squnion>i. Rep (S i))" |
|
137 |
by (rule typedef_lub [OF type less adm]) |
|
138 |
thus "\<exists>x. range S <<| x" .. |
|
139 |
qed |
|
16697 | 140 |
|
141 |
subsubsection {* Continuity of @{term Rep} and @{term Abs} *} |
|
142 |
||
143 |
text {* For any sub-cpo, the @{term Rep} function is continuous. *} |
|
144 |
||
145 |
theorem typedef_cont_Rep: |
|
146 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo" |
|
147 |
assumes type: "type_definition Rep Abs A" |
|
148 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
149 |
and adm: "adm (\<lambda>x. x \<in> A)" |
|
150 |
shows "cont Rep" |
|
151 |
apply (rule contI) |
|
16918 | 152 |
apply (simp only: typedef_thelub [OF type less adm]) |
153 |
apply (simp only: Abs_inverse_lub_Rep [OF type less adm]) |
|
26027 | 154 |
apply (rule cpo_lubI) |
16918 | 155 |
apply (erule ch2ch_Rep [OF less]) |
16697 | 156 |
done |
157 |
||
158 |
text {* |
|
159 |
For a sub-cpo, we can make the @{term Abs} function continuous |
|
160 |
only if we restrict its domain to the defining subset by |
|
161 |
composing it with another continuous function. |
|
162 |
*} |
|
163 |
||
16918 | 164 |
theorem typedef_is_lubI: |
165 |
assumes less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
166 |
shows "range (\<lambda>i. Rep (S i)) <<| Rep x \<Longrightarrow> range S <<| x" |
|
167 |
apply (rule is_lubI) |
|
168 |
apply (rule ub_rangeI) |
|
169 |
apply (subst less) |
|
170 |
apply (erule is_ub_lub) |
|
171 |
apply (subst less) |
|
172 |
apply (erule is_lub_lub) |
|
173 |
apply (erule ub2ub_Rep [OF less]) |
|
174 |
done |
|
175 |
||
16697 | 176 |
theorem typedef_cont_Abs: |
177 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo" |
|
178 |
fixes f :: "'c::cpo \<Rightarrow> 'a::cpo" |
|
179 |
assumes type: "type_definition Rep Abs A" |
|
180 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
16918 | 181 |
and adm: "adm (\<lambda>x. x \<in> A)" (* not used *) |
16697 | 182 |
and f_in_A: "\<And>x. f x \<in> A" |
183 |
and cont_f: "cont f" |
|
184 |
shows "cont (\<lambda>x. Abs (f x))" |
|
185 |
apply (rule contI) |
|
16918 | 186 |
apply (rule typedef_is_lubI [OF less]) |
187 |
apply (simp only: type_definition.Abs_inverse [OF type f_in_A]) |
|
188 |
apply (erule cont_f [THEN contE]) |
|
16697 | 189 |
done |
190 |
||
17833 | 191 |
subsection {* Proving subtype elements are compact *} |
192 |
||
193 |
theorem typedef_compact: |
|
194 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo" |
|
195 |
assumes type: "type_definition Rep Abs A" |
|
196 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
197 |
and adm: "adm (\<lambda>x. x \<in> A)" |
|
198 |
shows "compact (Rep k) \<Longrightarrow> compact k" |
|
199 |
proof (unfold compact_def) |
|
200 |
have cont_Rep: "cont Rep" |
|
201 |
by (rule typedef_cont_Rep [OF type less adm]) |
|
202 |
assume "adm (\<lambda>x. \<not> Rep k \<sqsubseteq> x)" |
|
203 |
with cont_Rep have "adm (\<lambda>x. \<not> Rep k \<sqsubseteq> Rep x)" by (rule adm_subst) |
|
204 |
thus "adm (\<lambda>x. \<not> k \<sqsubseteq> x)" by (unfold less) |
|
205 |
qed |
|
206 |
||
16697 | 207 |
subsection {* Proving a subtype is pointed *} |
208 |
||
209 |
text {* |
|
210 |
A subtype of a cpo has a least element if and only if |
|
211 |
the defining subset has a least element. |
|
212 |
*} |
|
213 |
||
16918 | 214 |
theorem typedef_pcpo_generic: |
16697 | 215 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo" |
216 |
assumes type: "type_definition Rep Abs A" |
|
217 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
218 |
and z_in_A: "z \<in> A" |
|
219 |
and z_least: "\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x" |
|
220 |
shows "OFCLASS('b, pcpo_class)" |
|
221 |
apply (intro_classes) |
|
222 |
apply (rule_tac x="Abs z" in exI, rule allI) |
|
223 |
apply (unfold less) |
|
224 |
apply (subst type_definition.Abs_inverse [OF type z_in_A]) |
|
225 |
apply (rule z_least [OF type_definition.Rep [OF type]]) |
|
226 |
done |
|
227 |
||
228 |
text {* |
|
229 |
As a special case, a subtype of a pcpo has a least element |
|
230 |
if the defining subset contains @{term \<bottom>}. |
|
231 |
*} |
|
232 |
||
16918 | 233 |
theorem typedef_pcpo: |
16697 | 234 |
fixes Abs :: "'a::pcpo \<Rightarrow> 'b::cpo" |
235 |
assumes type: "type_definition Rep Abs A" |
|
236 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
237 |
and UU_in_A: "\<bottom> \<in> A" |
|
238 |
shows "OFCLASS('b, pcpo_class)" |
|
16918 | 239 |
by (rule typedef_pcpo_generic [OF type less UU_in_A], rule minimal) |
16697 | 240 |
|
241 |
subsubsection {* Strictness of @{term Rep} and @{term Abs} *} |
|
242 |
||
243 |
text {* |
|
244 |
For a sub-pcpo where @{term \<bottom>} is a member of the defining |
|
245 |
subset, @{term Rep} and @{term Abs} are both strict. |
|
246 |
*} |
|
247 |
||
248 |
theorem typedef_Abs_strict: |
|
249 |
assumes type: "type_definition Rep Abs A" |
|
250 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
251 |
and UU_in_A: "\<bottom> \<in> A" |
|
252 |
shows "Abs \<bottom> = \<bottom>" |
|
253 |
apply (rule UU_I, unfold less) |
|
254 |
apply (simp add: type_definition.Abs_inverse [OF type UU_in_A]) |
|
255 |
done |
|
256 |
||
257 |
theorem typedef_Rep_strict: |
|
258 |
assumes type: "type_definition Rep Abs A" |
|
259 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
260 |
and UU_in_A: "\<bottom> \<in> A" |
|
261 |
shows "Rep \<bottom> = \<bottom>" |
|
262 |
apply (rule typedef_Abs_strict [OF type less UU_in_A, THEN subst]) |
|
263 |
apply (rule type_definition.Abs_inverse [OF type UU_in_A]) |
|
264 |
done |
|
265 |
||
25926 | 266 |
theorem typedef_Abs_strict_iff: |
267 |
assumes type: "type_definition Rep Abs A" |
|
268 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
269 |
and UU_in_A: "\<bottom> \<in> A" |
|
270 |
shows "x \<in> A \<Longrightarrow> (Abs x = \<bottom>) = (x = \<bottom>)" |
|
271 |
apply (rule typedef_Abs_strict [OF type less UU_in_A, THEN subst]) |
|
272 |
apply (simp add: type_definition.Abs_inject [OF type] UU_in_A) |
|
273 |
done |
|
274 |
||
275 |
theorem typedef_Rep_strict_iff: |
|
276 |
assumes type: "type_definition Rep Abs A" |
|
277 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
278 |
and UU_in_A: "\<bottom> \<in> A" |
|
279 |
shows "(Rep x = \<bottom>) = (x = \<bottom>)" |
|
280 |
apply (rule typedef_Rep_strict [OF type less UU_in_A, THEN subst]) |
|
281 |
apply (simp add: type_definition.Rep_inject [OF type]) |
|
282 |
done |
|
283 |
||
16697 | 284 |
theorem typedef_Abs_defined: |
285 |
assumes type: "type_definition Rep Abs A" |
|
286 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
287 |
and UU_in_A: "\<bottom> \<in> A" |
|
288 |
shows "\<lbrakk>x \<noteq> \<bottom>; x \<in> A\<rbrakk> \<Longrightarrow> Abs x \<noteq> \<bottom>" |
|
25926 | 289 |
by (simp add: typedef_Abs_strict_iff [OF type less UU_in_A]) |
16697 | 290 |
|
291 |
theorem typedef_Rep_defined: |
|
292 |
assumes type: "type_definition Rep Abs A" |
|
293 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
294 |
and UU_in_A: "\<bottom> \<in> A" |
|
295 |
shows "x \<noteq> \<bottom> \<Longrightarrow> Rep x \<noteq> \<bottom>" |
|
25926 | 296 |
by (simp add: typedef_Rep_strict_iff [OF type less UU_in_A]) |
16697 | 297 |
|
19519 | 298 |
subsection {* Proving a subtype is flat *} |
299 |
||
300 |
theorem typedef_flat: |
|
301 |
fixes Abs :: "'a::flat \<Rightarrow> 'b::pcpo" |
|
302 |
assumes type: "type_definition Rep Abs A" |
|
303 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y" |
|
304 |
and UU_in_A: "\<bottom> \<in> A" |
|
305 |
shows "OFCLASS('b, flat_class)" |
|
306 |
apply (intro_classes) |
|
307 |
apply (unfold less) |
|
308 |
apply (simp add: type_definition.Rep_inject [OF type, symmetric]) |
|
309 |
apply (simp add: typedef_Rep_strict [OF type less UU_in_A]) |
|
310 |
apply (simp add: ax_flat) |
|
311 |
done |
|
312 |
||
16697 | 313 |
subsection {* HOLCF type definition package *} |
314 |
||
23152 | 315 |
use "Tools/pcpodef_package.ML" |
16697 | 316 |
|
317 |
end |