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