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
|
|
10 |
uses ("pcpodef_package.ML")
|
|
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 |
|
|
33 |
subsection {* Proving a subtype is complete *}
|
|
34 |
|
|
35 |
text {*
|
|
36 |
A subtype of a cpo is itself a cpo if the ordering is
|
|
37 |
defined in the standard way, and the defining subset
|
|
38 |
is closed with respect to limits of chains. A set is
|
|
39 |
closed if and only if membership in the set is an
|
|
40 |
admissible predicate.
|
|
41 |
*}
|
|
42 |
|
16918
|
43 |
lemma monofun_Rep:
|
16697
|
44 |
assumes less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
16918
|
45 |
shows "monofun Rep"
|
|
46 |
by (rule monofunI, unfold less)
|
16697
|
47 |
|
16918
|
48 |
lemmas ch2ch_Rep = ch2ch_monofun [OF monofun_Rep]
|
|
49 |
lemmas ub2ub_Rep = ub2ub_monofun [OF monofun_Rep]
|
|
50 |
|
|
51 |
lemma Abs_inverse_lub_Rep:
|
16697
|
52 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
|
|
53 |
assumes type: "type_definition Rep Abs A"
|
|
54 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
55 |
and adm: "adm (\<lambda>x. x \<in> A)"
|
16918
|
56 |
shows "chain S \<Longrightarrow> Rep (Abs (\<Squnion>i. Rep (S i))) = (\<Squnion>i. Rep (S i))"
|
|
57 |
apply (rule type_definition.Abs_inverse [OF type])
|
|
58 |
apply (erule admD [OF adm ch2ch_Rep [OF less], rule_format])
|
16697
|
59 |
apply (rule type_definition.Rep [OF type])
|
|
60 |
done
|
|
61 |
|
16918
|
62 |
theorem typedef_lub:
|
16697
|
63 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
|
|
64 |
assumes type: "type_definition Rep Abs A"
|
|
65 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
66 |
and adm: "adm (\<lambda>x. x \<in> A)"
|
16918
|
67 |
shows "chain S \<Longrightarrow> range S <<| Abs (\<Squnion>i. Rep (S i))"
|
|
68 |
apply (frule ch2ch_Rep [OF less])
|
16697
|
69 |
apply (rule is_lubI)
|
|
70 |
apply (rule ub_rangeI)
|
16918
|
71 |
apply (simp only: less Abs_inverse_lub_Rep [OF type less adm])
|
|
72 |
apply (erule is_ub_thelub)
|
|
73 |
apply (simp only: less Abs_inverse_lub_Rep [OF type less adm])
|
|
74 |
apply (erule is_lub_thelub)
|
|
75 |
apply (erule ub2ub_Rep [OF less])
|
16697
|
76 |
done
|
|
77 |
|
16918
|
78 |
lemmas typedef_thelub = typedef_lub [THEN thelubI, standard]
|
|
79 |
|
16697
|
80 |
theorem typedef_cpo:
|
|
81 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
|
|
82 |
assumes type: "type_definition Rep Abs A"
|
|
83 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
84 |
and adm: "adm (\<lambda>x. x \<in> A)"
|
|
85 |
shows "OFCLASS('b, cpo_class)"
|
16918
|
86 |
proof
|
|
87 |
fix S::"nat \<Rightarrow> 'b" assume "chain S"
|
|
88 |
hence "range S <<| Abs (\<Squnion>i. Rep (S i))"
|
|
89 |
by (rule typedef_lub [OF type less adm])
|
|
90 |
thus "\<exists>x. range S <<| x" ..
|
|
91 |
qed
|
16697
|
92 |
|
|
93 |
|
|
94 |
subsubsection {* Continuity of @{term Rep} and @{term Abs} *}
|
|
95 |
|
|
96 |
text {* For any sub-cpo, the @{term Rep} function is continuous. *}
|
|
97 |
|
|
98 |
theorem typedef_cont_Rep:
|
|
99 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
|
|
100 |
assumes type: "type_definition Rep Abs A"
|
|
101 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
102 |
and adm: "adm (\<lambda>x. x \<in> A)"
|
|
103 |
shows "cont Rep"
|
|
104 |
apply (rule contI)
|
16918
|
105 |
apply (simp only: typedef_thelub [OF type less adm])
|
|
106 |
apply (simp only: Abs_inverse_lub_Rep [OF type less adm])
|
16697
|
107 |
apply (rule thelubE [OF _ refl])
|
16918
|
108 |
apply (erule ch2ch_Rep [OF less])
|
16697
|
109 |
done
|
|
110 |
|
|
111 |
text {*
|
|
112 |
For a sub-cpo, we can make the @{term Abs} function continuous
|
|
113 |
only if we restrict its domain to the defining subset by
|
|
114 |
composing it with another continuous function.
|
|
115 |
*}
|
|
116 |
|
16918
|
117 |
theorem typedef_is_lubI:
|
|
118 |
assumes less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
119 |
shows "range (\<lambda>i. Rep (S i)) <<| Rep x \<Longrightarrow> range S <<| x"
|
|
120 |
apply (rule is_lubI)
|
|
121 |
apply (rule ub_rangeI)
|
|
122 |
apply (subst less)
|
|
123 |
apply (erule is_ub_lub)
|
|
124 |
apply (subst less)
|
|
125 |
apply (erule is_lub_lub)
|
|
126 |
apply (erule ub2ub_Rep [OF less])
|
|
127 |
done
|
|
128 |
|
16697
|
129 |
theorem typedef_cont_Abs:
|
|
130 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
|
|
131 |
fixes f :: "'c::cpo \<Rightarrow> 'a::cpo"
|
|
132 |
assumes type: "type_definition Rep Abs A"
|
|
133 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
16918
|
134 |
and adm: "adm (\<lambda>x. x \<in> A)" (* not used *)
|
16697
|
135 |
and f_in_A: "\<And>x. f x \<in> A"
|
|
136 |
and cont_f: "cont f"
|
|
137 |
shows "cont (\<lambda>x. Abs (f x))"
|
|
138 |
apply (rule contI)
|
16918
|
139 |
apply (rule typedef_is_lubI [OF less])
|
|
140 |
apply (simp only: type_definition.Abs_inverse [OF type f_in_A])
|
|
141 |
apply (erule cont_f [THEN contE])
|
16697
|
142 |
done
|
|
143 |
|
|
144 |
subsection {* Proving a subtype is pointed *}
|
|
145 |
|
|
146 |
text {*
|
|
147 |
A subtype of a cpo has a least element if and only if
|
|
148 |
the defining subset has a least element.
|
|
149 |
*}
|
|
150 |
|
16918
|
151 |
theorem typedef_pcpo_generic:
|
16697
|
152 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
|
|
153 |
assumes type: "type_definition Rep Abs A"
|
|
154 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
155 |
and z_in_A: "z \<in> A"
|
|
156 |
and z_least: "\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x"
|
|
157 |
shows "OFCLASS('b, pcpo_class)"
|
|
158 |
apply (intro_classes)
|
|
159 |
apply (rule_tac x="Abs z" in exI, rule allI)
|
|
160 |
apply (unfold less)
|
|
161 |
apply (subst type_definition.Abs_inverse [OF type z_in_A])
|
|
162 |
apply (rule z_least [OF type_definition.Rep [OF type]])
|
|
163 |
done
|
|
164 |
|
|
165 |
text {*
|
|
166 |
As a special case, a subtype of a pcpo has a least element
|
|
167 |
if the defining subset contains @{term \<bottom>}.
|
|
168 |
*}
|
|
169 |
|
16918
|
170 |
theorem typedef_pcpo:
|
16697
|
171 |
fixes Abs :: "'a::pcpo \<Rightarrow> 'b::cpo"
|
|
172 |
assumes type: "type_definition Rep Abs A"
|
|
173 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
174 |
and UU_in_A: "\<bottom> \<in> A"
|
|
175 |
shows "OFCLASS('b, pcpo_class)"
|
16918
|
176 |
by (rule typedef_pcpo_generic [OF type less UU_in_A], rule minimal)
|
16697
|
177 |
|
|
178 |
subsubsection {* Strictness of @{term Rep} and @{term Abs} *}
|
|
179 |
|
|
180 |
text {*
|
|
181 |
For a sub-pcpo where @{term \<bottom>} is a member of the defining
|
|
182 |
subset, @{term Rep} and @{term Abs} are both strict.
|
|
183 |
*}
|
|
184 |
|
|
185 |
theorem typedef_Abs_strict:
|
|
186 |
assumes type: "type_definition Rep Abs A"
|
|
187 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
188 |
and UU_in_A: "\<bottom> \<in> A"
|
|
189 |
shows "Abs \<bottom> = \<bottom>"
|
|
190 |
apply (rule UU_I, unfold less)
|
|
191 |
apply (simp add: type_definition.Abs_inverse [OF type UU_in_A])
|
|
192 |
done
|
|
193 |
|
|
194 |
theorem typedef_Rep_strict:
|
|
195 |
assumes type: "type_definition Rep Abs A"
|
|
196 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
197 |
and UU_in_A: "\<bottom> \<in> A"
|
|
198 |
shows "Rep \<bottom> = \<bottom>"
|
|
199 |
apply (rule typedef_Abs_strict [OF type less UU_in_A, THEN subst])
|
|
200 |
apply (rule type_definition.Abs_inverse [OF type UU_in_A])
|
|
201 |
done
|
|
202 |
|
|
203 |
theorem typedef_Abs_defined:
|
|
204 |
assumes type: "type_definition Rep Abs A"
|
|
205 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
206 |
and UU_in_A: "\<bottom> \<in> A"
|
|
207 |
shows "\<lbrakk>x \<noteq> \<bottom>; x \<in> A\<rbrakk> \<Longrightarrow> Abs x \<noteq> \<bottom>"
|
|
208 |
apply (rule typedef_Abs_strict [OF type less UU_in_A, THEN subst])
|
|
209 |
apply (simp add: type_definition.Abs_inject [OF type] UU_in_A)
|
|
210 |
done
|
|
211 |
|
|
212 |
theorem typedef_Rep_defined:
|
|
213 |
assumes type: "type_definition Rep Abs A"
|
|
214 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
215 |
and UU_in_A: "\<bottom> \<in> A"
|
|
216 |
shows "x \<noteq> \<bottom> \<Longrightarrow> Rep x \<noteq> \<bottom>"
|
|
217 |
apply (rule typedef_Rep_strict [OF type less UU_in_A, THEN subst])
|
|
218 |
apply (simp add: type_definition.Rep_inject [OF type])
|
|
219 |
done
|
|
220 |
|
|
221 |
subsection {* HOLCF type definition package *}
|
|
222 |
|
|
223 |
use "pcpodef_package.ML"
|
|
224 |
|
|
225 |
end
|