author | huffman |
Sun, 19 Dec 2010 18:11:20 -0800 | |
changeset 41295 | 5b5388d4ccc9 |
parent 41286 | 3d7685a4a5ff |
child 41370 | 17b09240893c |
permissions | -rw-r--r-- |
27411 | 1 |
(* Title: HOLCF/Universal.thy |
2 |
Author: Brian Huffman |
|
3 |
*) |
|
4 |
||
35794 | 5 |
header {* A universal bifinite domain *} |
6 |
||
27411 | 7 |
theory Universal |
41286
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
8 |
imports Bifinite Completion Nat_Bijection |
27411 | 9 |
begin |
10 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
11 |
subsection {* Basis for universal domain *} |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
12 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
13 |
subsubsection {* Basis datatype *} |
27411 | 14 |
|
41295 | 15 |
type_synonym ubasis = nat |
27411 | 16 |
|
17 |
definition |
|
18 |
node :: "nat \<Rightarrow> ubasis \<Rightarrow> ubasis set \<Rightarrow> ubasis" |
|
19 |
where |
|
35701 | 20 |
"node i a S = Suc (prod_encode (i, prod_encode (a, set_encode S)))" |
27411 | 21 |
|
30505 | 22 |
lemma node_not_0 [simp]: "node i a S \<noteq> 0" |
27411 | 23 |
unfolding node_def by simp |
24 |
||
30505 | 25 |
lemma node_gt_0 [simp]: "0 < node i a S" |
27411 | 26 |
unfolding node_def by simp |
27 |
||
28 |
lemma node_inject [simp]: |
|
30505 | 29 |
"\<lbrakk>finite S; finite T\<rbrakk> |
30 |
\<Longrightarrow> node i a S = node j b T \<longleftrightarrow> i = j \<and> a = b \<and> S = T" |
|
35701 | 31 |
unfolding node_def by (simp add: prod_encode_eq set_encode_eq) |
27411 | 32 |
|
30505 | 33 |
lemma node_gt0: "i < node i a S" |
27411 | 34 |
unfolding node_def less_Suc_eq_le |
35701 | 35 |
by (rule le_prod_encode_1) |
27411 | 36 |
|
30505 | 37 |
lemma node_gt1: "a < node i a S" |
27411 | 38 |
unfolding node_def less_Suc_eq_le |
35701 | 39 |
by (rule order_trans [OF le_prod_encode_1 le_prod_encode_2]) |
27411 | 40 |
|
41 |
lemma nat_less_power2: "n < 2^n" |
|
42 |
by (induct n) simp_all |
|
43 |
||
30505 | 44 |
lemma node_gt2: "\<lbrakk>finite S; b \<in> S\<rbrakk> \<Longrightarrow> b < node i a S" |
35701 | 45 |
unfolding node_def less_Suc_eq_le set_encode_def |
46 |
apply (rule order_trans [OF _ le_prod_encode_2]) |
|
47 |
apply (rule order_trans [OF _ le_prod_encode_2]) |
|
30505 | 48 |
apply (rule order_trans [where y="setsum (op ^ 2) {b}"]) |
27411 | 49 |
apply (simp add: nat_less_power2 [THEN order_less_imp_le]) |
50 |
apply (erule setsum_mono2, simp, simp) |
|
51 |
done |
|
52 |
||
35701 | 53 |
lemma eq_prod_encode_pairI: |
54 |
"\<lbrakk>fst (prod_decode x) = a; snd (prod_decode x) = b\<rbrakk> \<Longrightarrow> x = prod_encode (a, b)" |
|
27411 | 55 |
by (erule subst, erule subst, simp) |
56 |
||
57 |
lemma node_cases: |
|
58 |
assumes 1: "x = 0 \<Longrightarrow> P" |
|
30505 | 59 |
assumes 2: "\<And>i a S. \<lbrakk>finite S; x = node i a S\<rbrakk> \<Longrightarrow> P" |
27411 | 60 |
shows "P" |
61 |
apply (cases x) |
|
62 |
apply (erule 1) |
|
63 |
apply (rule 2) |
|
35701 | 64 |
apply (rule finite_set_decode) |
27411 | 65 |
apply (simp add: node_def) |
35701 | 66 |
apply (rule eq_prod_encode_pairI [OF refl]) |
67 |
apply (rule eq_prod_encode_pairI [OF refl refl]) |
|
27411 | 68 |
done |
69 |
||
70 |
lemma node_induct: |
|
71 |
assumes 1: "P 0" |
|
30505 | 72 |
assumes 2: "\<And>i a S. \<lbrakk>P a; finite S; \<forall>b\<in>S. P b\<rbrakk> \<Longrightarrow> P (node i a S)" |
27411 | 73 |
shows "P x" |
74 |
apply (induct x rule: nat_less_induct) |
|
75 |
apply (case_tac n rule: node_cases) |
|
76 |
apply (simp add: 1) |
|
77 |
apply (simp add: 2 node_gt1 node_gt2) |
|
78 |
done |
|
79 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
80 |
subsubsection {* Basis ordering *} |
27411 | 81 |
|
82 |
inductive |
|
83 |
ubasis_le :: "nat \<Rightarrow> nat \<Rightarrow> bool" |
|
84 |
where |
|
30505 | 85 |
ubasis_le_refl: "ubasis_le a a" |
27411 | 86 |
| ubasis_le_trans: |
30505 | 87 |
"\<lbrakk>ubasis_le a b; ubasis_le b c\<rbrakk> \<Longrightarrow> ubasis_le a c" |
27411 | 88 |
| ubasis_le_lower: |
30505 | 89 |
"finite S \<Longrightarrow> ubasis_le a (node i a S)" |
27411 | 90 |
| ubasis_le_upper: |
30505 | 91 |
"\<lbrakk>finite S; b \<in> S; ubasis_le a b\<rbrakk> \<Longrightarrow> ubasis_le (node i a S) b" |
27411 | 92 |
|
93 |
lemma ubasis_le_minimal: "ubasis_le 0 x" |
|
94 |
apply (induct x rule: node_induct) |
|
95 |
apply (rule ubasis_le_refl) |
|
96 |
apply (erule ubasis_le_trans) |
|
97 |
apply (erule ubasis_le_lower) |
|
98 |
done |
|
99 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
100 |
interpretation udom: preorder ubasis_le |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
101 |
apply default |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
102 |
apply (rule ubasis_le_refl) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
103 |
apply (erule (1) ubasis_le_trans) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
104 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
105 |
|
27411 | 106 |
subsubsection {* Generic take function *} |
107 |
||
108 |
function |
|
109 |
ubasis_until :: "(ubasis \<Rightarrow> bool) \<Rightarrow> ubasis \<Rightarrow> ubasis" |
|
110 |
where |
|
111 |
"ubasis_until P 0 = 0" |
|
30505 | 112 |
| "finite S \<Longrightarrow> ubasis_until P (node i a S) = |
113 |
(if P (node i a S) then node i a S else ubasis_until P a)" |
|
27411 | 114 |
apply clarify |
115 |
apply (rule_tac x=b in node_cases) |
|
116 |
apply simp |
|
117 |
apply simp |
|
118 |
apply fast |
|
119 |
apply simp |
|
120 |
apply simp |
|
121 |
apply simp |
|
122 |
done |
|
123 |
||
124 |
termination ubasis_until |
|
125 |
apply (relation "measure snd") |
|
126 |
apply (rule wf_measure) |
|
127 |
apply (simp add: node_gt1) |
|
128 |
done |
|
129 |
||
130 |
lemma ubasis_until: "P 0 \<Longrightarrow> P (ubasis_until P x)" |
|
131 |
by (induct x rule: node_induct) simp_all |
|
132 |
||
133 |
lemma ubasis_until': "0 < ubasis_until P x \<Longrightarrow> P (ubasis_until P x)" |
|
134 |
by (induct x rule: node_induct) auto |
|
135 |
||
136 |
lemma ubasis_until_same: "P x \<Longrightarrow> ubasis_until P x = x" |
|
137 |
by (induct x rule: node_induct) simp_all |
|
138 |
||
139 |
lemma ubasis_until_idem: |
|
140 |
"P 0 \<Longrightarrow> ubasis_until P (ubasis_until P x) = ubasis_until P x" |
|
141 |
by (rule ubasis_until_same [OF ubasis_until]) |
|
142 |
||
143 |
lemma ubasis_until_0: |
|
144 |
"\<forall>x. x \<noteq> 0 \<longrightarrow> \<not> P x \<Longrightarrow> ubasis_until P x = 0" |
|
145 |
by (induct x rule: node_induct) simp_all |
|
146 |
||
147 |
lemma ubasis_until_less: "ubasis_le (ubasis_until P x) x" |
|
148 |
apply (induct x rule: node_induct) |
|
149 |
apply (simp add: ubasis_le_refl) |
|
150 |
apply (simp add: ubasis_le_refl) |
|
151 |
apply (rule impI) |
|
152 |
apply (erule ubasis_le_trans) |
|
153 |
apply (erule ubasis_le_lower) |
|
154 |
done |
|
155 |
||
156 |
lemma ubasis_until_chain: |
|
157 |
assumes PQ: "\<And>x. P x \<Longrightarrow> Q x" |
|
158 |
shows "ubasis_le (ubasis_until P x) (ubasis_until Q x)" |
|
159 |
apply (induct x rule: node_induct) |
|
160 |
apply (simp add: ubasis_le_refl) |
|
161 |
apply (simp add: ubasis_le_refl) |
|
162 |
apply (simp add: PQ) |
|
163 |
apply clarify |
|
164 |
apply (rule ubasis_le_trans) |
|
165 |
apply (rule ubasis_until_less) |
|
166 |
apply (erule ubasis_le_lower) |
|
167 |
done |
|
168 |
||
169 |
lemma ubasis_until_mono: |
|
30505 | 170 |
assumes "\<And>i a S b. \<lbrakk>finite S; P (node i a S); b \<in> S; ubasis_le a b\<rbrakk> \<Longrightarrow> P b" |
171 |
shows "ubasis_le a b \<Longrightarrow> ubasis_le (ubasis_until P a) (ubasis_until P b)" |
|
30561 | 172 |
proof (induct set: ubasis_le) |
173 |
case (ubasis_le_refl a) show ?case by (rule ubasis_le.ubasis_le_refl) |
|
174 |
next |
|
175 |
case (ubasis_le_trans a b c) thus ?case by - (rule ubasis_le.ubasis_le_trans) |
|
176 |
next |
|
177 |
case (ubasis_le_lower S a i) thus ?case |
|
178 |
apply (clarsimp simp add: ubasis_le_refl) |
|
179 |
apply (rule ubasis_le_trans [OF ubasis_until_less]) |
|
180 |
apply (erule ubasis_le.ubasis_le_lower) |
|
181 |
done |
|
182 |
next |
|
183 |
case (ubasis_le_upper S b a i) thus ?case |
|
184 |
apply clarsimp |
|
185 |
apply (subst ubasis_until_same) |
|
186 |
apply (erule (3) prems) |
|
187 |
apply (erule (2) ubasis_le.ubasis_le_upper) |
|
188 |
done |
|
189 |
qed |
|
27411 | 190 |
|
191 |
lemma finite_range_ubasis_until: |
|
192 |
"finite {x. P x} \<Longrightarrow> finite (range (ubasis_until P))" |
|
193 |
apply (rule finite_subset [where B="insert 0 {x. P x}"]) |
|
194 |
apply (clarsimp simp add: ubasis_until') |
|
195 |
apply simp |
|
196 |
done |
|
197 |
||
198 |
||
199 |
subsection {* Defining the universal domain by ideal completion *} |
|
200 |
||
201 |
typedef (open) udom = "{S. udom.ideal S}" |
|
40888
28cd51cff70c
reformulate lemma preorder.ex_ideal, and use it for typedefs
huffman
parents:
40774
diff
changeset
|
202 |
by (rule udom.ex_ideal) |
27411 | 203 |
|
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30729
diff
changeset
|
204 |
instantiation udom :: below |
27411 | 205 |
begin |
206 |
||
207 |
definition |
|
208 |
"x \<sqsubseteq> y \<longleftrightarrow> Rep_udom x \<subseteq> Rep_udom y" |
|
209 |
||
210 |
instance .. |
|
211 |
end |
|
212 |
||
213 |
instance udom :: po |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
214 |
using type_definition_udom below_udom_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
215 |
by (rule udom.typedef_ideal_po) |
27411 | 216 |
|
217 |
instance udom :: cpo |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
218 |
using type_definition_udom below_udom_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
219 |
by (rule udom.typedef_ideal_cpo) |
27411 | 220 |
|
221 |
definition |
|
222 |
udom_principal :: "nat \<Rightarrow> udom" where |
|
223 |
"udom_principal t = Abs_udom {u. ubasis_le u t}" |
|
224 |
||
39984 | 225 |
lemma ubasis_countable: "\<exists>f::ubasis \<Rightarrow> nat. inj f" |
226 |
by (rule exI, rule inj_on_id) |
|
27411 | 227 |
|
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
30561
diff
changeset
|
228 |
interpretation udom: |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
229 |
ideal_completion ubasis_le udom_principal Rep_udom |
39984 | 230 |
using type_definition_udom below_udom_def |
231 |
using udom_principal_def ubasis_countable |
|
232 |
by (rule udom.typedef_ideal_completion) |
|
27411 | 233 |
|
234 |
text {* Universal domain is pointed *} |
|
235 |
||
236 |
lemma udom_minimal: "udom_principal 0 \<sqsubseteq> x" |
|
237 |
apply (induct x rule: udom.principal_induct) |
|
238 |
apply (simp, simp add: ubasis_le_minimal) |
|
239 |
done |
|
240 |
||
241 |
instance udom :: pcpo |
|
242 |
by intro_classes (fast intro: udom_minimal) |
|
243 |
||
244 |
lemma inst_udom_pcpo: "\<bottom> = udom_principal 0" |
|
245 |
by (rule udom_minimal [THEN UU_I, symmetric]) |
|
246 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
247 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
248 |
subsection {* Compact bases of domains *} |
27411 | 249 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
250 |
typedef (open) 'a compact_basis = "{x::'a::pcpo. compact x}" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
251 |
by auto |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
252 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
253 |
lemma compact_Rep_compact_basis: "compact (Rep_compact_basis a)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
254 |
by (rule Rep_compact_basis [unfolded mem_Collect_eq]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
255 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
256 |
instantiation compact_basis :: (pcpo) below |
27411 | 257 |
begin |
258 |
||
259 |
definition |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
260 |
compact_le_def: |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
261 |
"(op \<sqsubseteq>) \<equiv> (\<lambda>x y. Rep_compact_basis x \<sqsubseteq> Rep_compact_basis y)" |
27411 | 262 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
263 |
instance .. |
27411 | 264 |
end |
265 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
266 |
instance compact_basis :: (pcpo) po |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
267 |
using type_definition_compact_basis compact_le_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
268 |
by (rule typedef_po) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
269 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
270 |
definition |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
271 |
approximants :: "'a \<Rightarrow> 'a compact_basis set" where |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
272 |
"approximants = (\<lambda>x. {a. Rep_compact_basis a \<sqsubseteq> x})" |
27411 | 273 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
274 |
definition |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
275 |
compact_bot :: "'a::pcpo compact_basis" where |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
276 |
"compact_bot = Abs_compact_basis \<bottom>" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
277 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
278 |
lemma Rep_compact_bot [simp]: "Rep_compact_basis compact_bot = \<bottom>" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
279 |
unfolding compact_bot_def by (simp add: Abs_compact_basis_inverse) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
280 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
281 |
lemma compact_bot_minimal [simp]: "compact_bot \<sqsubseteq> a" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
282 |
unfolding compact_le_def Rep_compact_bot by simp |
27411 | 283 |
|
284 |
||
35900
aa5dfb03eb1e
remove LaTeX hyperref warnings by avoiding antiquotations within section headings
huffman
parents:
35794
diff
changeset
|
285 |
subsection {* Universality of \emph{udom} *} |
27411 | 286 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
287 |
text {* We use a locale to parameterize the construction over a chain |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
288 |
of approx functions on the type to be embedded. *} |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
289 |
|
41286
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
290 |
locale bifinite_approx_chain = approx_chain + |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
291 |
constrains approx :: "nat \<Rightarrow> 'a::bifinite \<rightarrow> 'a" |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
292 |
begin |
27411 | 293 |
|
294 |
subsubsection {* Choosing a maximal element from a finite set *} |
|
295 |
||
296 |
lemma finite_has_maximal: |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
297 |
fixes A :: "'a compact_basis set" |
27411 | 298 |
shows "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y" |
299 |
proof (induct rule: finite_ne_induct) |
|
300 |
case (singleton x) |
|
301 |
show ?case by simp |
|
302 |
next |
|
303 |
case (insert a A) |
|
304 |
from `\<exists>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y` |
|
305 |
obtain x where x: "x \<in> A" |
|
306 |
and x_eq: "\<And>y. \<lbrakk>y \<in> A; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> x = y" by fast |
|
307 |
show ?case |
|
308 |
proof (intro bexI ballI impI) |
|
309 |
fix y |
|
310 |
assume "y \<in> insert a A" and "(if x \<sqsubseteq> a then a else x) \<sqsubseteq> y" |
|
311 |
thus "(if x \<sqsubseteq> a then a else x) = y" |
|
312 |
apply auto |
|
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30729
diff
changeset
|
313 |
apply (frule (1) below_trans) |
27411 | 314 |
apply (frule (1) x_eq) |
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30729
diff
changeset
|
315 |
apply (rule below_antisym, assumption) |
27411 | 316 |
apply simp |
317 |
apply (erule (1) x_eq) |
|
318 |
done |
|
319 |
next |
|
320 |
show "(if x \<sqsubseteq> a then a else x) \<in> insert a A" |
|
321 |
by (simp add: x) |
|
322 |
qed |
|
323 |
qed |
|
324 |
||
325 |
definition |
|
326 |
choose :: "'a compact_basis set \<Rightarrow> 'a compact_basis" |
|
327 |
where |
|
328 |
"choose A = (SOME x. x \<in> {x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y})" |
|
329 |
||
330 |
lemma choose_lemma: |
|
331 |
"\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> choose A \<in> {x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y}" |
|
332 |
unfolding choose_def |
|
333 |
apply (rule someI_ex) |
|
334 |
apply (frule (1) finite_has_maximal, fast) |
|
335 |
done |
|
336 |
||
337 |
lemma maximal_choose: |
|
338 |
"\<lbrakk>finite A; y \<in> A; choose A \<sqsubseteq> y\<rbrakk> \<Longrightarrow> choose A = y" |
|
339 |
apply (cases "A = {}", simp) |
|
340 |
apply (frule (1) choose_lemma, simp) |
|
341 |
done |
|
342 |
||
343 |
lemma choose_in: "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> choose A \<in> A" |
|
344 |
by (frule (1) choose_lemma, simp) |
|
345 |
||
346 |
function |
|
347 |
choose_pos :: "'a compact_basis set \<Rightarrow> 'a compact_basis \<Rightarrow> nat" |
|
348 |
where |
|
349 |
"choose_pos A x = |
|
350 |
(if finite A \<and> x \<in> A \<and> x \<noteq> choose A |
|
351 |
then Suc (choose_pos (A - {choose A}) x) else 0)" |
|
352 |
by auto |
|
353 |
||
354 |
termination choose_pos |
|
355 |
apply (relation "measure (card \<circ> fst)", simp) |
|
356 |
apply clarsimp |
|
357 |
apply (rule card_Diff1_less) |
|
358 |
apply assumption |
|
359 |
apply (erule choose_in) |
|
360 |
apply clarsimp |
|
361 |
done |
|
362 |
||
363 |
declare choose_pos.simps [simp del] |
|
364 |
||
365 |
lemma choose_pos_choose: "finite A \<Longrightarrow> choose_pos A (choose A) = 0" |
|
366 |
by (simp add: choose_pos.simps) |
|
367 |
||
368 |
lemma inj_on_choose_pos [OF refl]: |
|
369 |
"\<lbrakk>card A = n; finite A\<rbrakk> \<Longrightarrow> inj_on (choose_pos A) A" |
|
370 |
apply (induct n arbitrary: A) |
|
371 |
apply simp |
|
372 |
apply (case_tac "A = {}", simp) |
|
373 |
apply (frule (1) choose_in) |
|
374 |
apply (rule inj_onI) |
|
375 |
apply (drule_tac x="A - {choose A}" in meta_spec, simp) |
|
376 |
apply (simp add: choose_pos.simps) |
|
377 |
apply (simp split: split_if_asm) |
|
378 |
apply (erule (1) inj_onD, simp, simp) |
|
379 |
done |
|
380 |
||
381 |
lemma choose_pos_bounded [OF refl]: |
|
382 |
"\<lbrakk>card A = n; finite A; x \<in> A\<rbrakk> \<Longrightarrow> choose_pos A x < n" |
|
383 |
apply (induct n arbitrary: A) |
|
384 |
apply simp |
|
385 |
apply (case_tac "A = {}", simp) |
|
386 |
apply (frule (1) choose_in) |
|
387 |
apply (subst choose_pos.simps) |
|
388 |
apply simp |
|
389 |
done |
|
390 |
||
391 |
lemma choose_pos_lessD: |
|
41182 | 392 |
"\<lbrakk>choose_pos A x < choose_pos A y; finite A; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> x \<notsqsubseteq> y" |
27411 | 393 |
apply (induct A x arbitrary: y rule: choose_pos.induct) |
394 |
apply simp |
|
395 |
apply (case_tac "x = choose A") |
|
396 |
apply simp |
|
397 |
apply (rule notI) |
|
398 |
apply (frule (2) maximal_choose) |
|
399 |
apply simp |
|
400 |
apply (case_tac "y = choose A") |
|
401 |
apply (simp add: choose_pos_choose) |
|
402 |
apply (drule_tac x=y in meta_spec) |
|
403 |
apply simp |
|
404 |
apply (erule meta_mp) |
|
405 |
apply (simp add: choose_pos.simps) |
|
406 |
done |
|
407 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
408 |
subsubsection {* Compact basis take function *} |
27411 | 409 |
|
410 |
primrec |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
411 |
cb_take :: "nat \<Rightarrow> 'a compact_basis \<Rightarrow> 'a compact_basis" where |
27411 | 412 |
"cb_take 0 = (\<lambda>x. compact_bot)" |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
413 |
| "cb_take (Suc n) = (\<lambda>a. Abs_compact_basis (approx n\<cdot>(Rep_compact_basis a)))" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
414 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
415 |
declare cb_take.simps [simp del] |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
416 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
417 |
lemma cb_take_zero [simp]: "cb_take 0 a = compact_bot" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
418 |
by (simp only: cb_take.simps) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
419 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
420 |
lemma Rep_cb_take: |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
421 |
"Rep_compact_basis (cb_take (Suc n) a) = approx n\<cdot>(Rep_compact_basis a)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
422 |
by (simp add: Abs_compact_basis_inverse cb_take.simps(2) compact_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
423 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
424 |
lemmas approx_Rep_compact_basis = Rep_cb_take [symmetric] |
27411 | 425 |
|
426 |
lemma cb_take_covers: "\<exists>n. cb_take n x = x" |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
427 |
apply (subgoal_tac "\<exists>n. cb_take (Suc n) x = x", fast) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
428 |
apply (simp add: Rep_compact_basis_inject [symmetric]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
429 |
apply (simp add: Rep_cb_take) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
430 |
apply (rule compact_eq_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
431 |
apply (rule compact_Rep_compact_basis) |
27411 | 432 |
done |
433 |
||
434 |
lemma cb_take_less: "cb_take n x \<sqsubseteq> x" |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
435 |
unfolding compact_le_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
436 |
by (cases n, simp, simp add: Rep_cb_take approx_below) |
27411 | 437 |
|
438 |
lemma cb_take_idem: "cb_take n (cb_take n x) = cb_take n x" |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
439 |
unfolding Rep_compact_basis_inject [symmetric] |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
440 |
by (cases n, simp, simp add: Rep_cb_take approx_idem) |
27411 | 441 |
|
442 |
lemma cb_take_mono: "x \<sqsubseteq> y \<Longrightarrow> cb_take n x \<sqsubseteq> cb_take n y" |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
443 |
unfolding compact_le_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
444 |
by (cases n, simp, simp add: Rep_cb_take monofun_cfun_arg) |
27411 | 445 |
|
446 |
lemma cb_take_chain_le: "m \<le> n \<Longrightarrow> cb_take m x \<sqsubseteq> cb_take n x" |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
447 |
unfolding compact_le_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
448 |
apply (cases m, simp, cases n, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
449 |
apply (simp add: Rep_cb_take, rule chain_mono, simp, simp) |
27411 | 450 |
done |
451 |
||
452 |
lemma finite_range_cb_take: "finite (range (cb_take n))" |
|
453 |
apply (cases n) |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
454 |
apply (subgoal_tac "range (cb_take 0) = {compact_bot}", simp, force) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
455 |
apply (rule finite_imageD [where f="Rep_compact_basis"]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
456 |
apply (rule finite_subset [where B="range (\<lambda>x. approx (n - 1)\<cdot>x)"]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
457 |
apply (clarsimp simp add: Rep_cb_take) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
458 |
apply (rule finite_range_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
459 |
apply (rule inj_onI, simp add: Rep_compact_basis_inject) |
27411 | 460 |
done |
461 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
462 |
subsubsection {* Rank of basis elements *} |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
463 |
|
27411 | 464 |
definition |
465 |
rank :: "'a compact_basis \<Rightarrow> nat" |
|
466 |
where |
|
467 |
"rank x = (LEAST n. cb_take n x = x)" |
|
468 |
||
469 |
lemma compact_approx_rank: "cb_take (rank x) x = x" |
|
470 |
unfolding rank_def |
|
471 |
apply (rule LeastI_ex) |
|
472 |
apply (rule cb_take_covers) |
|
473 |
done |
|
474 |
||
475 |
lemma rank_leD: "rank x \<le> n \<Longrightarrow> cb_take n x = x" |
|
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30729
diff
changeset
|
476 |
apply (rule below_antisym [OF cb_take_less]) |
27411 | 477 |
apply (subst compact_approx_rank [symmetric]) |
478 |
apply (erule cb_take_chain_le) |
|
479 |
done |
|
480 |
||
481 |
lemma rank_leI: "cb_take n x = x \<Longrightarrow> rank x \<le> n" |
|
482 |
unfolding rank_def by (rule Least_le) |
|
483 |
||
484 |
lemma rank_le_iff: "rank x \<le> n \<longleftrightarrow> cb_take n x = x" |
|
485 |
by (rule iffI [OF rank_leD rank_leI]) |
|
486 |
||
30505 | 487 |
lemma rank_compact_bot [simp]: "rank compact_bot = 0" |
488 |
using rank_leI [of 0 compact_bot] by simp |
|
489 |
||
490 |
lemma rank_eq_0_iff [simp]: "rank x = 0 \<longleftrightarrow> x = compact_bot" |
|
491 |
using rank_le_iff [of x 0] by auto |
|
492 |
||
27411 | 493 |
definition |
494 |
rank_le :: "'a compact_basis \<Rightarrow> 'a compact_basis set" |
|
495 |
where |
|
496 |
"rank_le x = {y. rank y \<le> rank x}" |
|
497 |
||
498 |
definition |
|
499 |
rank_lt :: "'a compact_basis \<Rightarrow> 'a compact_basis set" |
|
500 |
where |
|
501 |
"rank_lt x = {y. rank y < rank x}" |
|
502 |
||
503 |
definition |
|
504 |
rank_eq :: "'a compact_basis \<Rightarrow> 'a compact_basis set" |
|
505 |
where |
|
506 |
"rank_eq x = {y. rank y = rank x}" |
|
507 |
||
508 |
lemma rank_eq_cong: "rank x = rank y \<Longrightarrow> rank_eq x = rank_eq y" |
|
509 |
unfolding rank_eq_def by simp |
|
510 |
||
511 |
lemma rank_lt_cong: "rank x = rank y \<Longrightarrow> rank_lt x = rank_lt y" |
|
512 |
unfolding rank_lt_def by simp |
|
513 |
||
514 |
lemma rank_eq_subset: "rank_eq x \<subseteq> rank_le x" |
|
515 |
unfolding rank_eq_def rank_le_def by auto |
|
516 |
||
517 |
lemma rank_lt_subset: "rank_lt x \<subseteq> rank_le x" |
|
518 |
unfolding rank_lt_def rank_le_def by auto |
|
519 |
||
520 |
lemma finite_rank_le: "finite (rank_le x)" |
|
521 |
unfolding rank_le_def |
|
522 |
apply (rule finite_subset [where B="range (cb_take (rank x))"]) |
|
523 |
apply clarify |
|
524 |
apply (rule range_eqI) |
|
525 |
apply (erule rank_leD [symmetric]) |
|
526 |
apply (rule finite_range_cb_take) |
|
527 |
done |
|
528 |
||
529 |
lemma finite_rank_eq: "finite (rank_eq x)" |
|
530 |
by (rule finite_subset [OF rank_eq_subset finite_rank_le]) |
|
531 |
||
532 |
lemma finite_rank_lt: "finite (rank_lt x)" |
|
533 |
by (rule finite_subset [OF rank_lt_subset finite_rank_le]) |
|
534 |
||
535 |
lemma rank_lt_Int_rank_eq: "rank_lt x \<inter> rank_eq x = {}" |
|
536 |
unfolding rank_lt_def rank_eq_def rank_le_def by auto |
|
537 |
||
538 |
lemma rank_lt_Un_rank_eq: "rank_lt x \<union> rank_eq x = rank_le x" |
|
539 |
unfolding rank_lt_def rank_eq_def rank_le_def by auto |
|
540 |
||
30505 | 541 |
subsubsection {* Sequencing basis elements *} |
27411 | 542 |
|
543 |
definition |
|
30505 | 544 |
place :: "'a compact_basis \<Rightarrow> nat" |
27411 | 545 |
where |
30505 | 546 |
"place x = card (rank_lt x) + choose_pos (rank_eq x) x" |
27411 | 547 |
|
30505 | 548 |
lemma place_bounded: "place x < card (rank_le x)" |
549 |
unfolding place_def |
|
27411 | 550 |
apply (rule ord_less_eq_trans) |
551 |
apply (rule add_strict_left_mono) |
|
552 |
apply (rule choose_pos_bounded) |
|
553 |
apply (rule finite_rank_eq) |
|
554 |
apply (simp add: rank_eq_def) |
|
555 |
apply (subst card_Un_disjoint [symmetric]) |
|
556 |
apply (rule finite_rank_lt) |
|
557 |
apply (rule finite_rank_eq) |
|
558 |
apply (rule rank_lt_Int_rank_eq) |
|
559 |
apply (simp add: rank_lt_Un_rank_eq) |
|
560 |
done |
|
561 |
||
30505 | 562 |
lemma place_ge: "card (rank_lt x) \<le> place x" |
563 |
unfolding place_def by simp |
|
27411 | 564 |
|
30505 | 565 |
lemma place_rank_mono: |
27411 | 566 |
fixes x y :: "'a compact_basis" |
30505 | 567 |
shows "rank x < rank y \<Longrightarrow> place x < place y" |
568 |
apply (rule less_le_trans [OF place_bounded]) |
|
569 |
apply (rule order_trans [OF _ place_ge]) |
|
27411 | 570 |
apply (rule card_mono) |
571 |
apply (rule finite_rank_lt) |
|
572 |
apply (simp add: rank_le_def rank_lt_def subset_eq) |
|
573 |
done |
|
574 |
||
30505 | 575 |
lemma place_eqD: "place x = place y \<Longrightarrow> x = y" |
27411 | 576 |
apply (rule linorder_cases [where x="rank x" and y="rank y"]) |
30505 | 577 |
apply (drule place_rank_mono, simp) |
578 |
apply (simp add: place_def) |
|
27411 | 579 |
apply (rule inj_on_choose_pos [where A="rank_eq x", THEN inj_onD]) |
580 |
apply (rule finite_rank_eq) |
|
581 |
apply (simp cong: rank_lt_cong rank_eq_cong) |
|
582 |
apply (simp add: rank_eq_def) |
|
583 |
apply (simp add: rank_eq_def) |
|
30505 | 584 |
apply (drule place_rank_mono, simp) |
27411 | 585 |
done |
586 |
||
30505 | 587 |
lemma inj_place: "inj place" |
588 |
by (rule inj_onI, erule place_eqD) |
|
27411 | 589 |
|
590 |
subsubsection {* Embedding and projection on basis elements *} |
|
591 |
||
30505 | 592 |
definition |
593 |
sub :: "'a compact_basis \<Rightarrow> 'a compact_basis" |
|
594 |
where |
|
595 |
"sub x = (case rank x of 0 \<Rightarrow> compact_bot | Suc k \<Rightarrow> cb_take k x)" |
|
596 |
||
597 |
lemma rank_sub_less: "x \<noteq> compact_bot \<Longrightarrow> rank (sub x) < rank x" |
|
598 |
unfolding sub_def |
|
599 |
apply (cases "rank x", simp) |
|
600 |
apply (simp add: less_Suc_eq_le) |
|
601 |
apply (rule rank_leI) |
|
602 |
apply (rule cb_take_idem) |
|
603 |
done |
|
604 |
||
605 |
lemma place_sub_less: "x \<noteq> compact_bot \<Longrightarrow> place (sub x) < place x" |
|
606 |
apply (rule place_rank_mono) |
|
607 |
apply (erule rank_sub_less) |
|
608 |
done |
|
609 |
||
610 |
lemma sub_below: "sub x \<sqsubseteq> x" |
|
611 |
unfolding sub_def by (cases "rank x", simp_all add: cb_take_less) |
|
612 |
||
613 |
lemma rank_less_imp_below_sub: "\<lbrakk>x \<sqsubseteq> y; rank x < rank y\<rbrakk> \<Longrightarrow> x \<sqsubseteq> sub y" |
|
614 |
unfolding sub_def |
|
615 |
apply (cases "rank y", simp) |
|
616 |
apply (simp add: less_Suc_eq_le) |
|
617 |
apply (subgoal_tac "cb_take nat x \<sqsubseteq> cb_take nat y") |
|
618 |
apply (simp add: rank_leD) |
|
619 |
apply (erule cb_take_mono) |
|
620 |
done |
|
621 |
||
27411 | 622 |
function |
623 |
basis_emb :: "'a compact_basis \<Rightarrow> ubasis" |
|
624 |
where |
|
625 |
"basis_emb x = (if x = compact_bot then 0 else |
|
30505 | 626 |
node (place x) (basis_emb (sub x)) |
627 |
(basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y}))" |
|
27411 | 628 |
by auto |
629 |
||
630 |
termination basis_emb |
|
30505 | 631 |
apply (relation "measure place", simp) |
632 |
apply (simp add: place_sub_less) |
|
27411 | 633 |
apply simp |
634 |
done |
|
635 |
||
636 |
declare basis_emb.simps [simp del] |
|
637 |
||
638 |
lemma basis_emb_compact_bot [simp]: "basis_emb compact_bot = 0" |
|
639 |
by (simp add: basis_emb.simps) |
|
640 |
||
30505 | 641 |
lemma fin1: "finite {y. place y < place x \<and> x \<sqsubseteq> y}" |
27411 | 642 |
apply (subst Collect_conj_eq) |
643 |
apply (rule finite_Int) |
|
644 |
apply (rule disjI1) |
|
30505 | 645 |
apply (subgoal_tac "finite (place -` {n. n < place x})", simp) |
646 |
apply (rule finite_vimageI [OF _ inj_place]) |
|
27411 | 647 |
apply (simp add: lessThan_def [symmetric]) |
648 |
done |
|
649 |
||
30505 | 650 |
lemma fin2: "finite (basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y})" |
27411 | 651 |
by (rule finite_imageI [OF fin1]) |
652 |
||
30505 | 653 |
lemma rank_place_mono: |
654 |
"\<lbrakk>place x < place y; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> rank x < rank y" |
|
655 |
apply (rule linorder_cases, assumption) |
|
656 |
apply (simp add: place_def cong: rank_lt_cong rank_eq_cong) |
|
657 |
apply (drule choose_pos_lessD) |
|
658 |
apply (rule finite_rank_eq) |
|
659 |
apply (simp add: rank_eq_def) |
|
660 |
apply (simp add: rank_eq_def) |
|
661 |
apply simp |
|
662 |
apply (drule place_rank_mono, simp) |
|
663 |
done |
|
664 |
||
665 |
lemma basis_emb_mono: |
|
666 |
"x \<sqsubseteq> y \<Longrightarrow> ubasis_le (basis_emb x) (basis_emb y)" |
|
34915 | 667 |
proof (induct "max (place x) (place y)" arbitrary: x y rule: less_induct) |
668 |
case less |
|
30505 | 669 |
show ?case proof (rule linorder_cases) |
670 |
assume "place x < place y" |
|
671 |
then have "rank x < rank y" |
|
672 |
using `x \<sqsubseteq> y` by (rule rank_place_mono) |
|
673 |
with `place x < place y` show ?case |
|
674 |
apply (case_tac "y = compact_bot", simp) |
|
675 |
apply (simp add: basis_emb.simps [of y]) |
|
676 |
apply (rule ubasis_le_trans [OF _ ubasis_le_lower [OF fin2]]) |
|
34915 | 677 |
apply (rule less) |
30505 | 678 |
apply (simp add: less_max_iff_disj) |
679 |
apply (erule place_sub_less) |
|
680 |
apply (erule rank_less_imp_below_sub [OF `x \<sqsubseteq> y`]) |
|
27411 | 681 |
done |
30505 | 682 |
next |
683 |
assume "place x = place y" |
|
684 |
hence "x = y" by (rule place_eqD) |
|
685 |
thus ?case by (simp add: ubasis_le_refl) |
|
686 |
next |
|
687 |
assume "place x > place y" |
|
688 |
with `x \<sqsubseteq> y` show ?case |
|
689 |
apply (case_tac "x = compact_bot", simp add: ubasis_le_minimal) |
|
690 |
apply (simp add: basis_emb.simps [of x]) |
|
691 |
apply (rule ubasis_le_upper [OF fin2], simp) |
|
34915 | 692 |
apply (rule less) |
30505 | 693 |
apply (simp add: less_max_iff_disj) |
694 |
apply (erule place_sub_less) |
|
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30729
diff
changeset
|
695 |
apply (erule rev_below_trans) |
30505 | 696 |
apply (rule sub_below) |
697 |
done |
|
27411 | 698 |
qed |
699 |
qed |
|
700 |
||
701 |
lemma inj_basis_emb: "inj basis_emb" |
|
702 |
apply (rule inj_onI) |
|
703 |
apply (case_tac "x = compact_bot") |
|
704 |
apply (case_tac [!] "y = compact_bot") |
|
705 |
apply simp |
|
706 |
apply (simp add: basis_emb.simps) |
|
707 |
apply (simp add: basis_emb.simps) |
|
708 |
apply (simp add: basis_emb.simps) |
|
30505 | 709 |
apply (simp add: fin2 inj_eq [OF inj_place]) |
27411 | 710 |
done |
711 |
||
712 |
definition |
|
30505 | 713 |
basis_prj :: "ubasis \<Rightarrow> 'a compact_basis" |
27411 | 714 |
where |
715 |
"basis_prj x = inv basis_emb |
|
30505 | 716 |
(ubasis_until (\<lambda>x. x \<in> range (basis_emb :: 'a compact_basis \<Rightarrow> ubasis)) x)" |
27411 | 717 |
|
718 |
lemma basis_prj_basis_emb: "\<And>x. basis_prj (basis_emb x) = x" |
|
719 |
unfolding basis_prj_def |
|
720 |
apply (subst ubasis_until_same) |
|
721 |
apply (rule rangeI) |
|
722 |
apply (rule inv_f_f) |
|
723 |
apply (rule inj_basis_emb) |
|
724 |
done |
|
725 |
||
726 |
lemma basis_prj_node: |
|
30505 | 727 |
"\<lbrakk>finite S; node i a S \<notin> range (basis_emb :: 'a compact_basis \<Rightarrow> nat)\<rbrakk> |
728 |
\<Longrightarrow> basis_prj (node i a S) = (basis_prj a :: 'a compact_basis)" |
|
27411 | 729 |
unfolding basis_prj_def by simp |
730 |
||
731 |
lemma basis_prj_0: "basis_prj 0 = compact_bot" |
|
732 |
apply (subst basis_emb_compact_bot [symmetric]) |
|
733 |
apply (rule basis_prj_basis_emb) |
|
734 |
done |
|
735 |
||
30505 | 736 |
lemma node_eq_basis_emb_iff: |
737 |
"finite S \<Longrightarrow> node i a S = basis_emb x \<longleftrightarrow> |
|
738 |
x \<noteq> compact_bot \<and> i = place x \<and> a = basis_emb (sub x) \<and> |
|
739 |
S = basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y}" |
|
740 |
apply (cases "x = compact_bot", simp) |
|
741 |
apply (simp add: basis_emb.simps [of x]) |
|
742 |
apply (simp add: fin2) |
|
27411 | 743 |
done |
744 |
||
30505 | 745 |
lemma basis_prj_mono: "ubasis_le a b \<Longrightarrow> basis_prj a \<sqsubseteq> basis_prj b" |
746 |
proof (induct a b rule: ubasis_le.induct) |
|
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30729
diff
changeset
|
747 |
case (ubasis_le_refl a) show ?case by (rule below_refl) |
30505 | 748 |
next |
31076
99fe356cbbc2
rename constant sq_le to below; rename class sq_ord to below; less->below in many lemma names
huffman
parents:
30729
diff
changeset
|
749 |
case (ubasis_le_trans a b c) thus ?case by - (rule below_trans) |
30505 | 750 |
next |
751 |
case (ubasis_le_lower S a i) thus ?case |
|
30561 | 752 |
apply (cases "node i a S \<in> range (basis_emb :: 'a compact_basis \<Rightarrow> nat)") |
30505 | 753 |
apply (erule rangeE, rename_tac x) |
754 |
apply (simp add: basis_prj_basis_emb) |
|
755 |
apply (simp add: node_eq_basis_emb_iff) |
|
756 |
apply (simp add: basis_prj_basis_emb) |
|
757 |
apply (rule sub_below) |
|
758 |
apply (simp add: basis_prj_node) |
|
759 |
done |
|
760 |
next |
|
761 |
case (ubasis_le_upper S b a i) thus ?case |
|
30561 | 762 |
apply (cases "node i a S \<in> range (basis_emb :: 'a compact_basis \<Rightarrow> nat)") |
30505 | 763 |
apply (erule rangeE, rename_tac x) |
764 |
apply (simp add: basis_prj_basis_emb) |
|
765 |
apply (clarsimp simp add: node_eq_basis_emb_iff) |
|
766 |
apply (simp add: basis_prj_basis_emb) |
|
767 |
apply (simp add: basis_prj_node) |
|
768 |
done |
|
769 |
qed |
|
770 |
||
27411 | 771 |
lemma basis_emb_prj_less: "ubasis_le (basis_emb (basis_prj x)) x" |
772 |
unfolding basis_prj_def |
|
33071
362f59fe5092
renamed f_inv_onto_f to f_inv_into_f (cf. 764547b68538);
wenzelm
parents:
32997
diff
changeset
|
773 |
apply (subst f_inv_into_f [where f=basis_emb]) |
27411 | 774 |
apply (rule ubasis_until) |
775 |
apply (rule range_eqI [where x=compact_bot]) |
|
776 |
apply simp |
|
777 |
apply (rule ubasis_until_less) |
|
778 |
done |
|
779 |
||
41286
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
780 |
lemma ideal_completion: |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
781 |
"ideal_completion below Rep_compact_basis (approximants :: 'a \<Rightarrow> _)" |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
782 |
proof |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
783 |
fix w :: "'a" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
784 |
show "below.ideal (approximants w)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
785 |
proof (rule below.idealI) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
786 |
show "\<exists>x. x \<in> approximants w" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
787 |
unfolding approximants_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
788 |
apply (rule_tac x="Abs_compact_basis (approx 0\<cdot>w)" in exI) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
789 |
apply (simp add: Abs_compact_basis_inverse approx_below compact_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
790 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
791 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
792 |
fix x y :: "'a compact_basis" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
793 |
assume "x \<in> approximants w" "y \<in> approximants w" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
794 |
thus "\<exists>z \<in> approximants w. x \<sqsubseteq> z \<and> y \<sqsubseteq> z" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
795 |
unfolding approximants_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
796 |
apply simp |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
797 |
apply (cut_tac a=x in compact_Rep_compact_basis) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
798 |
apply (cut_tac a=y in compact_Rep_compact_basis) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
799 |
apply (drule compact_eq_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
800 |
apply (drule compact_eq_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
801 |
apply (clarify, rename_tac i j) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
802 |
apply (rule_tac x="Abs_compact_basis (approx (max i j)\<cdot>w)" in exI) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
803 |
apply (simp add: compact_le_def) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
804 |
apply (simp add: Abs_compact_basis_inverse approx_below compact_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
805 |
apply (erule subst, erule subst) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
806 |
apply (simp add: monofun_cfun chain_mono [OF chain_approx]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
807 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
808 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
809 |
fix x y :: "'a compact_basis" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
810 |
assume "x \<sqsubseteq> y" "y \<in> approximants w" thus "x \<in> approximants w" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
811 |
unfolding approximants_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
812 |
apply simp |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
813 |
apply (simp add: compact_le_def) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
814 |
apply (erule (1) below_trans) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
815 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
816 |
qed |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
817 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
818 |
fix Y :: "nat \<Rightarrow> 'a" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
819 |
assume Y: "chain Y" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
820 |
show "approximants (\<Squnion>i. Y i) = (\<Union>i. approximants (Y i))" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
821 |
unfolding approximants_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
822 |
apply safe |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
823 |
apply (simp add: compactD2 [OF compact_Rep_compact_basis Y]) |
40500
ee9c8d36318e
add lemmas lub_below, below_lub; simplify some proofs; remove some unused lemmas
huffman
parents:
40002
diff
changeset
|
824 |
apply (erule below_lub [OF Y]) |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
825 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
826 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
827 |
fix a :: "'a compact_basis" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
828 |
show "approximants (Rep_compact_basis a) = {b. b \<sqsubseteq> a}" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
829 |
unfolding approximants_def compact_le_def .. |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
830 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
831 |
fix x y :: "'a" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
832 |
assume "approximants x \<subseteq> approximants y" thus "x \<sqsubseteq> y" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
833 |
apply (subgoal_tac "(\<Squnion>i. approx i\<cdot>x) \<sqsubseteq> y") |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
834 |
apply (simp add: lub_distribs) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
835 |
apply (rule admD, simp, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
836 |
apply (drule_tac c="Abs_compact_basis (approx i\<cdot>x)" in subsetD) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
837 |
apply (simp add: approximants_def Abs_compact_basis_inverse |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
838 |
approx_below compact_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
839 |
apply (simp add: approximants_def Abs_compact_basis_inverse compact_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
840 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
841 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
842 |
show "\<exists>f::'a compact_basis \<Rightarrow> nat. inj f" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
843 |
by (rule exI, rule inj_place) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
844 |
qed |
27411 | 845 |
|
41286
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
846 |
end |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
847 |
|
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
848 |
interpretation compact_basis!: |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
849 |
ideal_completion below Rep_compact_basis |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
850 |
"approximants :: 'a::bifinite \<Rightarrow> 'a compact_basis set" |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
851 |
proof - |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
852 |
obtain a :: "nat \<Rightarrow> 'a \<rightarrow> 'a" where "approx_chain a" |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
853 |
using bifinite .. |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
854 |
hence "bifinite_approx_chain a" |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
855 |
unfolding bifinite_approx_chain_def . |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
856 |
thus "ideal_completion below Rep_compact_basis (approximants :: 'a \<Rightarrow> _)" |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
857 |
by (rule bifinite_approx_chain.ideal_completion) |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
858 |
qed |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
859 |
|
35900
aa5dfb03eb1e
remove LaTeX hyperref warnings by avoiding antiquotations within section headings
huffman
parents:
35794
diff
changeset
|
860 |
subsubsection {* EP-pair from any bifinite domain into \emph{udom} *} |
27411 | 861 |
|
41286
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
862 |
context bifinite_approx_chain begin |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
863 |
|
27411 | 864 |
definition |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
865 |
udom_emb :: "'a \<rightarrow> udom" |
27411 | 866 |
where |
867 |
"udom_emb = compact_basis.basis_fun (\<lambda>x. udom_principal (basis_emb x))" |
|
868 |
||
869 |
definition |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
870 |
udom_prj :: "udom \<rightarrow> 'a" |
27411 | 871 |
where |
872 |
"udom_prj = udom.basis_fun (\<lambda>x. Rep_compact_basis (basis_prj x))" |
|
873 |
||
874 |
lemma udom_emb_principal: |
|
875 |
"udom_emb\<cdot>(Rep_compact_basis x) = udom_principal (basis_emb x)" |
|
876 |
unfolding udom_emb_def |
|
877 |
apply (rule compact_basis.basis_fun_principal) |
|
878 |
apply (rule udom.principal_mono) |
|
879 |
apply (erule basis_emb_mono) |
|
880 |
done |
|
881 |
||
882 |
lemma udom_prj_principal: |
|
883 |
"udom_prj\<cdot>(udom_principal x) = Rep_compact_basis (basis_prj x)" |
|
884 |
unfolding udom_prj_def |
|
885 |
apply (rule udom.basis_fun_principal) |
|
886 |
apply (rule compact_basis.principal_mono) |
|
887 |
apply (erule basis_prj_mono) |
|
888 |
done |
|
889 |
||
890 |
lemma ep_pair_udom: "ep_pair udom_emb udom_prj" |
|
891 |
apply default |
|
892 |
apply (rule compact_basis.principal_induct, simp) |
|
893 |
apply (simp add: udom_emb_principal udom_prj_principal) |
|
894 |
apply (simp add: basis_prj_basis_emb) |
|
895 |
apply (rule udom.principal_induct, simp) |
|
896 |
apply (simp add: udom_emb_principal udom_prj_principal) |
|
897 |
apply (rule basis_emb_prj_less) |
|
898 |
done |
|
899 |
||
900 |
end |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
901 |
|
41286
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
902 |
abbreviation "udom_emb \<equiv> bifinite_approx_chain.udom_emb" |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
903 |
abbreviation "udom_prj \<equiv> bifinite_approx_chain.udom_prj" |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
904 |
|
41286
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
905 |
lemmas ep_pair_udom = |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
906 |
bifinite_approx_chain.ep_pair_udom [unfolded bifinite_approx_chain_def] |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
907 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
908 |
subsection {* Chain of approx functions for type \emph{udom} *} |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
909 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
910 |
definition |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
911 |
udom_approx :: "nat \<Rightarrow> udom \<rightarrow> udom" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
912 |
where |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
913 |
"udom_approx i = |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
914 |
udom.basis_fun (\<lambda>x. udom_principal (ubasis_until (\<lambda>y. y \<le> i) x))" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
915 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
916 |
lemma udom_approx_mono: |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
917 |
"ubasis_le a b \<Longrightarrow> |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
918 |
udom_principal (ubasis_until (\<lambda>y. y \<le> i) a) \<sqsubseteq> |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
919 |
udom_principal (ubasis_until (\<lambda>y. y \<le> i) b)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
920 |
apply (rule udom.principal_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
921 |
apply (rule ubasis_until_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
922 |
apply (frule (2) order_less_le_trans [OF node_gt2]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
923 |
apply (erule order_less_imp_le) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
924 |
apply assumption |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
925 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
926 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
927 |
lemma adm_mem_finite: "\<lbrakk>cont f; finite S\<rbrakk> \<Longrightarrow> adm (\<lambda>x. f x \<in> S)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
928 |
by (erule adm_subst, induct set: finite, simp_all) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
929 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
930 |
lemma udom_approx_principal: |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
931 |
"udom_approx i\<cdot>(udom_principal x) = |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
932 |
udom_principal (ubasis_until (\<lambda>y. y \<le> i) x)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
933 |
unfolding udom_approx_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
934 |
apply (rule udom.basis_fun_principal) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
935 |
apply (erule udom_approx_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
936 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
937 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
938 |
lemma finite_deflation_udom_approx: "finite_deflation (udom_approx i)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
939 |
proof |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
940 |
fix x show "udom_approx i\<cdot>(udom_approx i\<cdot>x) = udom_approx i\<cdot>x" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
941 |
by (induct x rule: udom.principal_induct, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
942 |
(simp add: udom_approx_principal ubasis_until_idem) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
943 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
944 |
fix x show "udom_approx i\<cdot>x \<sqsubseteq> x" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
945 |
by (induct x rule: udom.principal_induct, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
946 |
(simp add: udom_approx_principal ubasis_until_less) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
947 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
948 |
have *: "finite (range (\<lambda>x. udom_principal (ubasis_until (\<lambda>y. y \<le> i) x)))" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
949 |
apply (subst range_composition [where f=udom_principal]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
950 |
apply (simp add: finite_range_ubasis_until) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
951 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
952 |
show "finite {x. udom_approx i\<cdot>x = x}" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
953 |
apply (rule finite_range_imp_finite_fixes) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
954 |
apply (rule rev_finite_subset [OF *]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
955 |
apply (clarsimp, rename_tac x) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
956 |
apply (induct_tac x rule: udom.principal_induct) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
957 |
apply (simp add: adm_mem_finite *) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
958 |
apply (simp add: udom_approx_principal) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
959 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
960 |
qed |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
961 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
962 |
interpretation udom_approx: finite_deflation "udom_approx i" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
963 |
by (rule finite_deflation_udom_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
964 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
965 |
lemma chain_udom_approx [simp]: "chain (\<lambda>i. udom_approx i)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
966 |
unfolding udom_approx_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
967 |
apply (rule chainI) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
968 |
apply (rule udom.basis_fun_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
969 |
apply (erule udom_approx_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
970 |
apply (erule udom_approx_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
971 |
apply (rule udom.principal_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
972 |
apply (rule ubasis_until_chain, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
973 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
974 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
975 |
lemma lub_udom_approx [simp]: "(\<Squnion>i. udom_approx i) = ID" |
40002
c5b5f7a3a3b1
new theorem names: fun_below_iff, fun_belowI, cfun_eq_iff, cfun_eqI, cfun_below_iff, cfun_belowI
huffman
parents:
39984
diff
changeset
|
976 |
apply (rule cfun_eqI, simp add: contlub_cfun_fun) |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
977 |
apply (rule below_antisym) |
40500
ee9c8d36318e
add lemmas lub_below, below_lub; simplify some proofs; remove some unused lemmas
huffman
parents:
40002
diff
changeset
|
978 |
apply (rule lub_below) |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
979 |
apply (simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
980 |
apply (rule udom_approx.below) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
981 |
apply (rule_tac x=x in udom.principal_induct) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
982 |
apply (simp add: lub_distribs) |
40500
ee9c8d36318e
add lemmas lub_below, below_lub; simplify some proofs; remove some unused lemmas
huffman
parents:
40002
diff
changeset
|
983 |
apply (rule_tac i=a in below_lub) |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
984 |
apply simp |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
985 |
apply (simp add: udom_approx_principal) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
986 |
apply (simp add: ubasis_until_same ubasis_le_refl) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
987 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
988 |
|
41286
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
989 |
lemma udom_approx [simp]: "approx_chain udom_approx" |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
990 |
proof |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
991 |
show "chain (\<lambda>i. udom_approx i)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
992 |
by (rule chain_udom_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
993 |
show "(\<Squnion>i. udom_approx i) = ID" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
994 |
by (rule lub_udom_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
995 |
qed |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
996 |
|
41286
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
997 |
instance udom :: bifinite |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
998 |
by default (fast intro: udom_approx) |
3d7685a4a5ff
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
huffman
parents:
41182
diff
changeset
|
999 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1000 |
hide_const (open) node |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1001 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1002 |
end |