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