16058
|
1 |
(* Title: HOLCF/TypedefPcpo.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Brian Huffman
|
|
4 |
License: GPL (GNU GENERAL PUBLIC LICENSE)
|
|
5 |
*)
|
|
6 |
|
|
7 |
header {* Subtypes of pcpos *}
|
|
8 |
|
|
9 |
theory TypedefPcpo
|
|
10 |
imports Adm
|
|
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)
|
|
27 |
apply (subst type_definition.Rep_inject [OF type, symmetric])
|
|
28 |
apply (rule antisym_less, assumption+)
|
|
29 |
apply (rule trans_less, assumption+)
|
|
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 |
|
|
43 |
lemma chain_Rep:
|
|
44 |
assumes less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
45 |
shows "chain S \<Longrightarrow> chain (\<lambda>n. Rep (S n))"
|
|
46 |
by (rule chainI, drule chainE, unfold less)
|
|
47 |
|
|
48 |
lemma lub_Rep_in_A:
|
|
49 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
|
|
50 |
assumes type: "type_definition Rep Abs A"
|
|
51 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
52 |
and adm: "adm (\<lambda>x. x \<in> A)"
|
|
53 |
shows "chain S \<Longrightarrow> (LUB n. Rep (S n)) \<in> A"
|
|
54 |
apply (erule admD [OF adm chain_Rep [OF less], rule_format])
|
|
55 |
apply (rule type_definition.Rep [OF type])
|
|
56 |
done
|
|
57 |
|
|
58 |
theorem typedef_is_lub:
|
|
59 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
|
|
60 |
assumes type: "type_definition Rep Abs A"
|
|
61 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
62 |
and adm: "adm (\<lambda>x. x \<in> A)"
|
|
63 |
shows "chain S \<Longrightarrow> range S <<| Abs (LUB n. Rep (S n))"
|
|
64 |
apply (rule is_lubI)
|
|
65 |
apply (rule ub_rangeI)
|
|
66 |
apply (subst less)
|
|
67 |
apply (subst type_definition.Abs_inverse [OF type])
|
|
68 |
apply (erule lub_Rep_in_A [OF type less adm])
|
|
69 |
apply (rule is_ub_thelub)
|
|
70 |
apply (erule chain_Rep [OF less])
|
|
71 |
apply (subst less)
|
|
72 |
apply (subst type_definition.Abs_inverse [OF type])
|
|
73 |
apply (erule lub_Rep_in_A [OF type less adm])
|
|
74 |
apply (rule is_lub_thelub)
|
|
75 |
apply (erule chain_Rep [OF less])
|
|
76 |
apply (rule ub_rangeI)
|
|
77 |
apply (drule ub_rangeD)
|
|
78 |
apply (unfold less)
|
|
79 |
apply assumption
|
|
80 |
done
|
|
81 |
|
|
82 |
theorem typedef_cpo:
|
|
83 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::po"
|
|
84 |
assumes type: "type_definition Rep Abs A"
|
|
85 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
86 |
and adm: "adm (\<lambda>x. x \<in> A)"
|
|
87 |
shows "OFCLASS('b, cpo_class)"
|
|
88 |
apply (intro_classes)
|
|
89 |
apply (rule_tac x="Abs (LUB n. Rep (S n))" in exI)
|
|
90 |
apply (erule typedef_is_lub [OF type less adm])
|
|
91 |
done
|
|
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[rule_format])
|
|
105 |
apply (simp only: typedef_is_lub [OF type less adm, THEN thelubI])
|
|
106 |
apply (subst type_definition.Abs_inverse [OF type])
|
|
107 |
apply (erule lub_Rep_in_A [OF type less adm])
|
|
108 |
apply (rule thelubE [OF _ refl])
|
|
109 |
apply (erule chain_Rep [OF less])
|
|
110 |
done
|
|
111 |
|
|
112 |
text {*
|
|
113 |
For a sub-cpo, we can make the @{term Abs} function continuous
|
|
114 |
only if we restrict its domain to the defining subset by
|
|
115 |
composing it with another continuous function.
|
|
116 |
*}
|
|
117 |
|
|
118 |
theorem typedef_cont_Abs:
|
|
119 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
|
|
120 |
fixes f :: "'c::cpo \<Rightarrow> 'a::cpo"
|
|
121 |
assumes type: "type_definition Rep Abs A"
|
|
122 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
123 |
and adm: "adm (\<lambda>x. x \<in> A)"
|
|
124 |
and f_in_A: "\<And>x. f x \<in> A"
|
|
125 |
and cont_f: "cont f"
|
|
126 |
shows "cont (\<lambda>x. Abs (f x))"
|
|
127 |
apply (rule contI[rule_format])
|
|
128 |
apply (rule is_lubI)
|
|
129 |
apply (rule ub_rangeI)
|
|
130 |
apply (simp only: less type_definition.Abs_inverse [OF type f_in_A])
|
|
131 |
apply (rule monofun_fun_arg [OF cont2mono [OF cont_f]])
|
|
132 |
apply (erule is_ub_thelub)
|
|
133 |
apply (simp only: less type_definition.Abs_inverse [OF type f_in_A])
|
|
134 |
apply (simp only: contlubE[rule_format, OF cont2contlub [OF cont_f]])
|
|
135 |
apply (rule is_lub_thelub)
|
|
136 |
apply (erule ch2ch_monofun [OF cont2mono [OF cont_f]])
|
|
137 |
apply (rule ub_rangeI)
|
|
138 |
apply (drule_tac i=i in ub_rangeD)
|
|
139 |
apply (simp only: less type_definition.Abs_inverse [OF type f_in_A])
|
|
140 |
done
|
|
141 |
|
|
142 |
lemmas typedef_cont_Abs2 =
|
|
143 |
typedef_cont_Abs [OF _ _ _ _ cont_Rep_CFun2]
|
|
144 |
|
|
145 |
|
|
146 |
subsection {* Proving a typedef is pointed *}
|
|
147 |
|
|
148 |
text {*
|
|
149 |
A subtype of a cpo has a least element if and only if
|
|
150 |
the defining subset has a least element.
|
|
151 |
*}
|
|
152 |
|
|
153 |
theorem typedef_pcpo:
|
|
154 |
fixes Abs :: "'a::cpo \<Rightarrow> 'b::cpo"
|
|
155 |
assumes type: "type_definition Rep Abs A"
|
|
156 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
157 |
and z_in_A: "z \<in> A"
|
|
158 |
and z_least: "\<And>x. x \<in> A \<Longrightarrow> z \<sqsubseteq> x"
|
|
159 |
shows "OFCLASS('b, pcpo_class)"
|
|
160 |
apply (intro_classes)
|
|
161 |
apply (rule_tac x="Abs z" in exI, rule allI)
|
|
162 |
apply (unfold less)
|
|
163 |
apply (subst type_definition.Abs_inverse [OF type z_in_A])
|
|
164 |
apply (rule z_least [OF type_definition.Rep [OF type]])
|
|
165 |
done
|
|
166 |
|
|
167 |
text {*
|
|
168 |
As a special case, a subtype of a pcpo has a least element
|
|
169 |
if the defining subset contains @{term \<bottom>}.
|
|
170 |
*}
|
|
171 |
|
|
172 |
theorem typedef_pcpo_UU:
|
|
173 |
fixes Abs :: "'a::pcpo \<Rightarrow> 'b::cpo"
|
|
174 |
assumes type: "type_definition Rep Abs A"
|
|
175 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
176 |
and UU_in_A: "\<bottom> \<in> A"
|
|
177 |
shows "OFCLASS('b, pcpo_class)"
|
|
178 |
by (rule typedef_pcpo [OF type less UU_in_A], rule minimal)
|
|
179 |
|
|
180 |
|
|
181 |
subsubsection {* Strictness of @{term Rep} and @{term Abs} *}
|
|
182 |
|
|
183 |
text {*
|
|
184 |
For a sub-pcpo where @{term \<bottom>} is a member of the defining
|
|
185 |
subset, @{term Rep} and @{term Abs} are both strict.
|
|
186 |
*}
|
|
187 |
|
|
188 |
theorem typedef_strict_Abs:
|
|
189 |
assumes type: "type_definition Rep Abs A"
|
|
190 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
191 |
and UU_in_A: "\<bottom> \<in> A"
|
|
192 |
shows "Abs \<bottom> = \<bottom>"
|
|
193 |
apply (rule UU_I, unfold less)
|
|
194 |
apply (simp add: type_definition.Abs_inverse [OF type UU_in_A])
|
|
195 |
done
|
|
196 |
|
|
197 |
theorem typedef_strict_Rep:
|
|
198 |
assumes type: "type_definition Rep Abs A"
|
|
199 |
and less: "op \<sqsubseteq> \<equiv> \<lambda>x y. Rep x \<sqsubseteq> Rep y"
|
|
200 |
and UU_in_A: "\<bottom> \<in> A"
|
|
201 |
shows "Rep \<bottom> = \<bottom>"
|
|
202 |
apply (rule typedef_strict_Abs [OF type less UU_in_A, THEN subst])
|
|
203 |
apply (rule type_definition.Abs_inverse [OF type UU_in_A])
|
|
204 |
done
|
|
205 |
|
|
206 |
end
|