author | huffman |
Wed, 06 Oct 2010 10:49:27 -0700 | |
changeset 39974 | b525988432e9 |
parent 36452 | d37c6eed8117 |
child 39984 | 0300d5170622 |
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 |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
8 |
imports Completion Deflation 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 |
|
15 |
types ubasis = nat |
|
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}" |
|
202 |
by (fast intro: udom.ideal_principal) |
|
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 |
lemma Rep_udom_lub: |
|
222 |
"chain Y \<Longrightarrow> Rep_udom (\<Squnion>i. Y i) = (\<Union>i. Rep_udom (Y i))" |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
223 |
using type_definition_udom below_udom_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
224 |
by (rule udom.typedef_ideal_rep_contlub) |
27411 | 225 |
|
226 |
lemma ideal_Rep_udom: "udom.ideal (Rep_udom xs)" |
|
227 |
by (rule Rep_udom [unfolded mem_Collect_eq]) |
|
228 |
||
229 |
definition |
|
230 |
udom_principal :: "nat \<Rightarrow> udom" where |
|
231 |
"udom_principal t = Abs_udom {u. ubasis_le u t}" |
|
232 |
||
233 |
lemma Rep_udom_principal: |
|
234 |
"Rep_udom (udom_principal t) = {u. ubasis_le u t}" |
|
235 |
unfolding udom_principal_def |
|
236 |
by (simp add: Abs_udom_inverse udom.ideal_principal) |
|
237 |
||
30729
461ee3e49ad3
interpretation/interpret: prefixes are mandatory by default;
wenzelm
parents:
30561
diff
changeset
|
238 |
interpretation udom: |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
239 |
ideal_completion ubasis_le udom_principal Rep_udom |
27411 | 240 |
apply unfold_locales |
241 |
apply (rule ideal_Rep_udom) |
|
242 |
apply (erule Rep_udom_lub) |
|
243 |
apply (rule Rep_udom_principal) |
|
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
|
244 |
apply (simp only: below_udom_def) |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
245 |
apply (rule exI, rule inj_on_id) |
27411 | 246 |
done |
247 |
||
248 |
text {* Universal domain is pointed *} |
|
249 |
||
250 |
lemma udom_minimal: "udom_principal 0 \<sqsubseteq> x" |
|
251 |
apply (induct x rule: udom.principal_induct) |
|
252 |
apply (simp, simp add: ubasis_le_minimal) |
|
253 |
done |
|
254 |
||
255 |
instance udom :: pcpo |
|
256 |
by intro_classes (fast intro: udom_minimal) |
|
257 |
||
258 |
lemma inst_udom_pcpo: "\<bottom> = udom_principal 0" |
|
259 |
by (rule udom_minimal [THEN UU_I, symmetric]) |
|
260 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
261 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
262 |
subsection {* Compact bases of domains *} |
27411 | 263 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
264 |
typedef (open) 'a compact_basis = "{x::'a::pcpo. compact x}" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
265 |
by auto |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
266 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
267 |
lemma compact_Rep_compact_basis: "compact (Rep_compact_basis a)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
268 |
by (rule Rep_compact_basis [unfolded mem_Collect_eq]) |
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 |
instantiation compact_basis :: (pcpo) below |
27411 | 271 |
begin |
272 |
||
273 |
definition |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
274 |
compact_le_def: |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
275 |
"(op \<sqsubseteq>) \<equiv> (\<lambda>x y. Rep_compact_basis x \<sqsubseteq> Rep_compact_basis y)" |
27411 | 276 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
277 |
instance .. |
27411 | 278 |
end |
279 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
280 |
instance compact_basis :: (pcpo) po |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
281 |
using type_definition_compact_basis compact_le_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
282 |
by (rule typedef_po) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
283 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
284 |
definition |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
285 |
approximants :: "'a \<Rightarrow> 'a compact_basis set" where |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
286 |
"approximants = (\<lambda>x. {a. Rep_compact_basis a \<sqsubseteq> x})" |
27411 | 287 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
288 |
definition |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
289 |
compact_bot :: "'a::pcpo compact_basis" where |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
290 |
"compact_bot = Abs_compact_basis \<bottom>" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
291 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
292 |
lemma Rep_compact_bot [simp]: "Rep_compact_basis compact_bot = \<bottom>" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
293 |
unfolding compact_bot_def by (simp add: Abs_compact_basis_inverse) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
294 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
295 |
lemma compact_bot_minimal [simp]: "compact_bot \<sqsubseteq> a" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
296 |
unfolding compact_le_def Rep_compact_bot by simp |
27411 | 297 |
|
298 |
||
35900
aa5dfb03eb1e
remove LaTeX hyperref warnings by avoiding antiquotations within section headings
huffman
parents:
35794
diff
changeset
|
299 |
subsection {* Universality of \emph{udom} *} |
27411 | 300 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
301 |
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
|
302 |
of approx functions on the type to be embedded. *} |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
303 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
304 |
locale approx_chain = |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
305 |
fixes approx :: "nat \<Rightarrow> 'a::pcpo \<rightarrow> 'a" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
306 |
assumes chain_approx [simp]: "chain (\<lambda>i. approx i)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
307 |
assumes lub_approx [simp]: "(\<Squnion>i. approx i) = ID" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
308 |
assumes finite_deflation_approx: "\<And>i. finite_deflation (approx i)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
309 |
begin |
27411 | 310 |
|
311 |
subsubsection {* Choosing a maximal element from a finite set *} |
|
312 |
||
313 |
lemma finite_has_maximal: |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
314 |
fixes A :: "'a compact_basis set" |
27411 | 315 |
shows "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> \<exists>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y" |
316 |
proof (induct rule: finite_ne_induct) |
|
317 |
case (singleton x) |
|
318 |
show ?case by simp |
|
319 |
next |
|
320 |
case (insert a A) |
|
321 |
from `\<exists>x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y` |
|
322 |
obtain x where x: "x \<in> A" |
|
323 |
and x_eq: "\<And>y. \<lbrakk>y \<in> A; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> x = y" by fast |
|
324 |
show ?case |
|
325 |
proof (intro bexI ballI impI) |
|
326 |
fix y |
|
327 |
assume "y \<in> insert a A" and "(if x \<sqsubseteq> a then a else x) \<sqsubseteq> y" |
|
328 |
thus "(if x \<sqsubseteq> a then a else x) = y" |
|
329 |
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
|
330 |
apply (frule (1) below_trans) |
27411 | 331 |
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
|
332 |
apply (rule below_antisym, assumption) |
27411 | 333 |
apply simp |
334 |
apply (erule (1) x_eq) |
|
335 |
done |
|
336 |
next |
|
337 |
show "(if x \<sqsubseteq> a then a else x) \<in> insert a A" |
|
338 |
by (simp add: x) |
|
339 |
qed |
|
340 |
qed |
|
341 |
||
342 |
definition |
|
343 |
choose :: "'a compact_basis set \<Rightarrow> 'a compact_basis" |
|
344 |
where |
|
345 |
"choose A = (SOME x. x \<in> {x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y})" |
|
346 |
||
347 |
lemma choose_lemma: |
|
348 |
"\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> choose A \<in> {x\<in>A. \<forall>y\<in>A. x \<sqsubseteq> y \<longrightarrow> x = y}" |
|
349 |
unfolding choose_def |
|
350 |
apply (rule someI_ex) |
|
351 |
apply (frule (1) finite_has_maximal, fast) |
|
352 |
done |
|
353 |
||
354 |
lemma maximal_choose: |
|
355 |
"\<lbrakk>finite A; y \<in> A; choose A \<sqsubseteq> y\<rbrakk> \<Longrightarrow> choose A = y" |
|
356 |
apply (cases "A = {}", simp) |
|
357 |
apply (frule (1) choose_lemma, simp) |
|
358 |
done |
|
359 |
||
360 |
lemma choose_in: "\<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> choose A \<in> A" |
|
361 |
by (frule (1) choose_lemma, simp) |
|
362 |
||
363 |
function |
|
364 |
choose_pos :: "'a compact_basis set \<Rightarrow> 'a compact_basis \<Rightarrow> nat" |
|
365 |
where |
|
366 |
"choose_pos A x = |
|
367 |
(if finite A \<and> x \<in> A \<and> x \<noteq> choose A |
|
368 |
then Suc (choose_pos (A - {choose A}) x) else 0)" |
|
369 |
by auto |
|
370 |
||
371 |
termination choose_pos |
|
372 |
apply (relation "measure (card \<circ> fst)", simp) |
|
373 |
apply clarsimp |
|
374 |
apply (rule card_Diff1_less) |
|
375 |
apply assumption |
|
376 |
apply (erule choose_in) |
|
377 |
apply clarsimp |
|
378 |
done |
|
379 |
||
380 |
declare choose_pos.simps [simp del] |
|
381 |
||
382 |
lemma choose_pos_choose: "finite A \<Longrightarrow> choose_pos A (choose A) = 0" |
|
383 |
by (simp add: choose_pos.simps) |
|
384 |
||
385 |
lemma inj_on_choose_pos [OF refl]: |
|
386 |
"\<lbrakk>card A = n; finite A\<rbrakk> \<Longrightarrow> inj_on (choose_pos A) A" |
|
387 |
apply (induct n arbitrary: A) |
|
388 |
apply simp |
|
389 |
apply (case_tac "A = {}", simp) |
|
390 |
apply (frule (1) choose_in) |
|
391 |
apply (rule inj_onI) |
|
392 |
apply (drule_tac x="A - {choose A}" in meta_spec, simp) |
|
393 |
apply (simp add: choose_pos.simps) |
|
394 |
apply (simp split: split_if_asm) |
|
395 |
apply (erule (1) inj_onD, simp, simp) |
|
396 |
done |
|
397 |
||
398 |
lemma choose_pos_bounded [OF refl]: |
|
399 |
"\<lbrakk>card A = n; finite A; x \<in> A\<rbrakk> \<Longrightarrow> choose_pos A x < n" |
|
400 |
apply (induct n arbitrary: A) |
|
401 |
apply simp |
|
402 |
apply (case_tac "A = {}", simp) |
|
403 |
apply (frule (1) choose_in) |
|
404 |
apply (subst choose_pos.simps) |
|
405 |
apply simp |
|
406 |
done |
|
407 |
||
408 |
lemma choose_pos_lessD: |
|
409 |
"\<lbrakk>choose_pos A x < choose_pos A y; finite A; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<not> x \<sqsubseteq> y" |
|
410 |
apply (induct A x arbitrary: y rule: choose_pos.induct) |
|
411 |
apply simp |
|
412 |
apply (case_tac "x = choose A") |
|
413 |
apply simp |
|
414 |
apply (rule notI) |
|
415 |
apply (frule (2) maximal_choose) |
|
416 |
apply simp |
|
417 |
apply (case_tac "y = choose A") |
|
418 |
apply (simp add: choose_pos_choose) |
|
419 |
apply (drule_tac x=y in meta_spec) |
|
420 |
apply simp |
|
421 |
apply (erule meta_mp) |
|
422 |
apply (simp add: choose_pos.simps) |
|
423 |
done |
|
424 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
425 |
subsubsection {* Properties of approx function *} |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
426 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
427 |
lemma deflation_approx: "deflation (approx i)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
428 |
using finite_deflation_approx by (rule finite_deflation_imp_deflation) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
429 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
430 |
lemma approx_idem: "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
431 |
using deflation_approx by (rule deflation.idem) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
432 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
433 |
lemma approx_below: "approx i\<cdot>x \<sqsubseteq> x" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
434 |
using deflation_approx by (rule deflation.below) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
435 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
436 |
lemma finite_range_approx: "finite (range (\<lambda>x. approx i\<cdot>x))" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
437 |
apply (rule finite_deflation.finite_range) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
438 |
apply (rule finite_deflation_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
439 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
440 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
441 |
lemma compact_approx: "compact (approx n\<cdot>x)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
442 |
apply (rule finite_deflation.compact) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
443 |
apply (rule finite_deflation_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
444 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
445 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
446 |
lemma compact_eq_approx: "compact x \<Longrightarrow> \<exists>i. approx i\<cdot>x = x" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
447 |
by (rule admD2, simp_all) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
448 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
449 |
subsubsection {* Compact basis take function *} |
27411 | 450 |
|
451 |
primrec |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
452 |
cb_take :: "nat \<Rightarrow> 'a compact_basis \<Rightarrow> 'a compact_basis" where |
27411 | 453 |
"cb_take 0 = (\<lambda>x. compact_bot)" |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
454 |
| "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
|
455 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
456 |
declare cb_take.simps [simp del] |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
457 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
458 |
lemma cb_take_zero [simp]: "cb_take 0 a = compact_bot" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
459 |
by (simp only: cb_take.simps) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
460 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
461 |
lemma Rep_cb_take: |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
462 |
"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
|
463 |
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
|
464 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
465 |
lemmas approx_Rep_compact_basis = Rep_cb_take [symmetric] |
27411 | 466 |
|
467 |
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
|
468 |
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
|
469 |
apply (simp add: Rep_compact_basis_inject [symmetric]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
470 |
apply (simp add: Rep_cb_take) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
471 |
apply (rule compact_eq_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
472 |
apply (rule compact_Rep_compact_basis) |
27411 | 473 |
done |
474 |
||
475 |
lemma cb_take_less: "cb_take n x \<sqsubseteq> x" |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
476 |
unfolding compact_le_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
477 |
by (cases n, simp, simp add: Rep_cb_take approx_below) |
27411 | 478 |
|
479 |
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
|
480 |
unfolding Rep_compact_basis_inject [symmetric] |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
481 |
by (cases n, simp, simp add: Rep_cb_take approx_idem) |
27411 | 482 |
|
483 |
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
|
484 |
unfolding compact_le_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
485 |
by (cases n, simp, simp add: Rep_cb_take monofun_cfun_arg) |
27411 | 486 |
|
487 |
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
|
488 |
unfolding compact_le_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
489 |
apply (cases m, simp, cases n, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
490 |
apply (simp add: Rep_cb_take, rule chain_mono, simp, simp) |
27411 | 491 |
done |
492 |
||
493 |
lemma finite_range_cb_take: "finite (range (cb_take n))" |
|
494 |
apply (cases n) |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
495 |
apply (subgoal_tac "range (cb_take 0) = {compact_bot}", simp, force) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
496 |
apply (rule finite_imageD [where f="Rep_compact_basis"]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
497 |
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
|
498 |
apply (clarsimp simp add: Rep_cb_take) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
499 |
apply (rule finite_range_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
500 |
apply (rule inj_onI, simp add: Rep_compact_basis_inject) |
27411 | 501 |
done |
502 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
503 |
subsubsection {* Rank of basis elements *} |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
504 |
|
27411 | 505 |
definition |
506 |
rank :: "'a compact_basis \<Rightarrow> nat" |
|
507 |
where |
|
508 |
"rank x = (LEAST n. cb_take n x = x)" |
|
509 |
||
510 |
lemma compact_approx_rank: "cb_take (rank x) x = x" |
|
511 |
unfolding rank_def |
|
512 |
apply (rule LeastI_ex) |
|
513 |
apply (rule cb_take_covers) |
|
514 |
done |
|
515 |
||
516 |
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
|
517 |
apply (rule below_antisym [OF cb_take_less]) |
27411 | 518 |
apply (subst compact_approx_rank [symmetric]) |
519 |
apply (erule cb_take_chain_le) |
|
520 |
done |
|
521 |
||
522 |
lemma rank_leI: "cb_take n x = x \<Longrightarrow> rank x \<le> n" |
|
523 |
unfolding rank_def by (rule Least_le) |
|
524 |
||
525 |
lemma rank_le_iff: "rank x \<le> n \<longleftrightarrow> cb_take n x = x" |
|
526 |
by (rule iffI [OF rank_leD rank_leI]) |
|
527 |
||
30505 | 528 |
lemma rank_compact_bot [simp]: "rank compact_bot = 0" |
529 |
using rank_leI [of 0 compact_bot] by simp |
|
530 |
||
531 |
lemma rank_eq_0_iff [simp]: "rank x = 0 \<longleftrightarrow> x = compact_bot" |
|
532 |
using rank_le_iff [of x 0] by auto |
|
533 |
||
27411 | 534 |
definition |
535 |
rank_le :: "'a compact_basis \<Rightarrow> 'a compact_basis set" |
|
536 |
where |
|
537 |
"rank_le x = {y. rank y \<le> rank x}" |
|
538 |
||
539 |
definition |
|
540 |
rank_lt :: "'a compact_basis \<Rightarrow> 'a compact_basis set" |
|
541 |
where |
|
542 |
"rank_lt x = {y. rank y < rank x}" |
|
543 |
||
544 |
definition |
|
545 |
rank_eq :: "'a compact_basis \<Rightarrow> 'a compact_basis set" |
|
546 |
where |
|
547 |
"rank_eq x = {y. rank y = rank x}" |
|
548 |
||
549 |
lemma rank_eq_cong: "rank x = rank y \<Longrightarrow> rank_eq x = rank_eq y" |
|
550 |
unfolding rank_eq_def by simp |
|
551 |
||
552 |
lemma rank_lt_cong: "rank x = rank y \<Longrightarrow> rank_lt x = rank_lt y" |
|
553 |
unfolding rank_lt_def by simp |
|
554 |
||
555 |
lemma rank_eq_subset: "rank_eq x \<subseteq> rank_le x" |
|
556 |
unfolding rank_eq_def rank_le_def by auto |
|
557 |
||
558 |
lemma rank_lt_subset: "rank_lt x \<subseteq> rank_le x" |
|
559 |
unfolding rank_lt_def rank_le_def by auto |
|
560 |
||
561 |
lemma finite_rank_le: "finite (rank_le x)" |
|
562 |
unfolding rank_le_def |
|
563 |
apply (rule finite_subset [where B="range (cb_take (rank x))"]) |
|
564 |
apply clarify |
|
565 |
apply (rule range_eqI) |
|
566 |
apply (erule rank_leD [symmetric]) |
|
567 |
apply (rule finite_range_cb_take) |
|
568 |
done |
|
569 |
||
570 |
lemma finite_rank_eq: "finite (rank_eq x)" |
|
571 |
by (rule finite_subset [OF rank_eq_subset finite_rank_le]) |
|
572 |
||
573 |
lemma finite_rank_lt: "finite (rank_lt x)" |
|
574 |
by (rule finite_subset [OF rank_lt_subset finite_rank_le]) |
|
575 |
||
576 |
lemma rank_lt_Int_rank_eq: "rank_lt x \<inter> rank_eq x = {}" |
|
577 |
unfolding rank_lt_def rank_eq_def rank_le_def by auto |
|
578 |
||
579 |
lemma rank_lt_Un_rank_eq: "rank_lt x \<union> rank_eq x = rank_le x" |
|
580 |
unfolding rank_lt_def rank_eq_def rank_le_def by auto |
|
581 |
||
30505 | 582 |
subsubsection {* Sequencing basis elements *} |
27411 | 583 |
|
584 |
definition |
|
30505 | 585 |
place :: "'a compact_basis \<Rightarrow> nat" |
27411 | 586 |
where |
30505 | 587 |
"place x = card (rank_lt x) + choose_pos (rank_eq x) x" |
27411 | 588 |
|
30505 | 589 |
lemma place_bounded: "place x < card (rank_le x)" |
590 |
unfolding place_def |
|
27411 | 591 |
apply (rule ord_less_eq_trans) |
592 |
apply (rule add_strict_left_mono) |
|
593 |
apply (rule choose_pos_bounded) |
|
594 |
apply (rule finite_rank_eq) |
|
595 |
apply (simp add: rank_eq_def) |
|
596 |
apply (subst card_Un_disjoint [symmetric]) |
|
597 |
apply (rule finite_rank_lt) |
|
598 |
apply (rule finite_rank_eq) |
|
599 |
apply (rule rank_lt_Int_rank_eq) |
|
600 |
apply (simp add: rank_lt_Un_rank_eq) |
|
601 |
done |
|
602 |
||
30505 | 603 |
lemma place_ge: "card (rank_lt x) \<le> place x" |
604 |
unfolding place_def by simp |
|
27411 | 605 |
|
30505 | 606 |
lemma place_rank_mono: |
27411 | 607 |
fixes x y :: "'a compact_basis" |
30505 | 608 |
shows "rank x < rank y \<Longrightarrow> place x < place y" |
609 |
apply (rule less_le_trans [OF place_bounded]) |
|
610 |
apply (rule order_trans [OF _ place_ge]) |
|
27411 | 611 |
apply (rule card_mono) |
612 |
apply (rule finite_rank_lt) |
|
613 |
apply (simp add: rank_le_def rank_lt_def subset_eq) |
|
614 |
done |
|
615 |
||
30505 | 616 |
lemma place_eqD: "place x = place y \<Longrightarrow> x = y" |
27411 | 617 |
apply (rule linorder_cases [where x="rank x" and y="rank y"]) |
30505 | 618 |
apply (drule place_rank_mono, simp) |
619 |
apply (simp add: place_def) |
|
27411 | 620 |
apply (rule inj_on_choose_pos [where A="rank_eq x", THEN inj_onD]) |
621 |
apply (rule finite_rank_eq) |
|
622 |
apply (simp cong: rank_lt_cong rank_eq_cong) |
|
623 |
apply (simp add: rank_eq_def) |
|
624 |
apply (simp add: rank_eq_def) |
|
30505 | 625 |
apply (drule place_rank_mono, simp) |
27411 | 626 |
done |
627 |
||
30505 | 628 |
lemma inj_place: "inj place" |
629 |
by (rule inj_onI, erule place_eqD) |
|
27411 | 630 |
|
631 |
subsubsection {* Embedding and projection on basis elements *} |
|
632 |
||
30505 | 633 |
definition |
634 |
sub :: "'a compact_basis \<Rightarrow> 'a compact_basis" |
|
635 |
where |
|
636 |
"sub x = (case rank x of 0 \<Rightarrow> compact_bot | Suc k \<Rightarrow> cb_take k x)" |
|
637 |
||
638 |
lemma rank_sub_less: "x \<noteq> compact_bot \<Longrightarrow> rank (sub x) < rank x" |
|
639 |
unfolding sub_def |
|
640 |
apply (cases "rank x", simp) |
|
641 |
apply (simp add: less_Suc_eq_le) |
|
642 |
apply (rule rank_leI) |
|
643 |
apply (rule cb_take_idem) |
|
644 |
done |
|
645 |
||
646 |
lemma place_sub_less: "x \<noteq> compact_bot \<Longrightarrow> place (sub x) < place x" |
|
647 |
apply (rule place_rank_mono) |
|
648 |
apply (erule rank_sub_less) |
|
649 |
done |
|
650 |
||
651 |
lemma sub_below: "sub x \<sqsubseteq> x" |
|
652 |
unfolding sub_def by (cases "rank x", simp_all add: cb_take_less) |
|
653 |
||
654 |
lemma rank_less_imp_below_sub: "\<lbrakk>x \<sqsubseteq> y; rank x < rank y\<rbrakk> \<Longrightarrow> x \<sqsubseteq> sub y" |
|
655 |
unfolding sub_def |
|
656 |
apply (cases "rank y", simp) |
|
657 |
apply (simp add: less_Suc_eq_le) |
|
658 |
apply (subgoal_tac "cb_take nat x \<sqsubseteq> cb_take nat y") |
|
659 |
apply (simp add: rank_leD) |
|
660 |
apply (erule cb_take_mono) |
|
661 |
done |
|
662 |
||
27411 | 663 |
function |
664 |
basis_emb :: "'a compact_basis \<Rightarrow> ubasis" |
|
665 |
where |
|
666 |
"basis_emb x = (if x = compact_bot then 0 else |
|
30505 | 667 |
node (place x) (basis_emb (sub x)) |
668 |
(basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y}))" |
|
27411 | 669 |
by auto |
670 |
||
671 |
termination basis_emb |
|
30505 | 672 |
apply (relation "measure place", simp) |
673 |
apply (simp add: place_sub_less) |
|
27411 | 674 |
apply simp |
675 |
done |
|
676 |
||
677 |
declare basis_emb.simps [simp del] |
|
678 |
||
679 |
lemma basis_emb_compact_bot [simp]: "basis_emb compact_bot = 0" |
|
680 |
by (simp add: basis_emb.simps) |
|
681 |
||
30505 | 682 |
lemma fin1: "finite {y. place y < place x \<and> x \<sqsubseteq> y}" |
27411 | 683 |
apply (subst Collect_conj_eq) |
684 |
apply (rule finite_Int) |
|
685 |
apply (rule disjI1) |
|
30505 | 686 |
apply (subgoal_tac "finite (place -` {n. n < place x})", simp) |
687 |
apply (rule finite_vimageI [OF _ inj_place]) |
|
27411 | 688 |
apply (simp add: lessThan_def [symmetric]) |
689 |
done |
|
690 |
||
30505 | 691 |
lemma fin2: "finite (basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y})" |
27411 | 692 |
by (rule finite_imageI [OF fin1]) |
693 |
||
30505 | 694 |
lemma rank_place_mono: |
695 |
"\<lbrakk>place x < place y; x \<sqsubseteq> y\<rbrakk> \<Longrightarrow> rank x < rank y" |
|
696 |
apply (rule linorder_cases, assumption) |
|
697 |
apply (simp add: place_def cong: rank_lt_cong rank_eq_cong) |
|
698 |
apply (drule choose_pos_lessD) |
|
699 |
apply (rule finite_rank_eq) |
|
700 |
apply (simp add: rank_eq_def) |
|
701 |
apply (simp add: rank_eq_def) |
|
702 |
apply simp |
|
703 |
apply (drule place_rank_mono, simp) |
|
704 |
done |
|
705 |
||
706 |
lemma basis_emb_mono: |
|
707 |
"x \<sqsubseteq> y \<Longrightarrow> ubasis_le (basis_emb x) (basis_emb y)" |
|
34915 | 708 |
proof (induct "max (place x) (place y)" arbitrary: x y rule: less_induct) |
709 |
case less |
|
30505 | 710 |
show ?case proof (rule linorder_cases) |
711 |
assume "place x < place y" |
|
712 |
then have "rank x < rank y" |
|
713 |
using `x \<sqsubseteq> y` by (rule rank_place_mono) |
|
714 |
with `place x < place y` show ?case |
|
715 |
apply (case_tac "y = compact_bot", simp) |
|
716 |
apply (simp add: basis_emb.simps [of y]) |
|
717 |
apply (rule ubasis_le_trans [OF _ ubasis_le_lower [OF fin2]]) |
|
34915 | 718 |
apply (rule less) |
30505 | 719 |
apply (simp add: less_max_iff_disj) |
720 |
apply (erule place_sub_less) |
|
721 |
apply (erule rank_less_imp_below_sub [OF `x \<sqsubseteq> y`]) |
|
27411 | 722 |
done |
30505 | 723 |
next |
724 |
assume "place x = place y" |
|
725 |
hence "x = y" by (rule place_eqD) |
|
726 |
thus ?case by (simp add: ubasis_le_refl) |
|
727 |
next |
|
728 |
assume "place x > place y" |
|
729 |
with `x \<sqsubseteq> y` show ?case |
|
730 |
apply (case_tac "x = compact_bot", simp add: ubasis_le_minimal) |
|
731 |
apply (simp add: basis_emb.simps [of x]) |
|
732 |
apply (rule ubasis_le_upper [OF fin2], simp) |
|
34915 | 733 |
apply (rule less) |
30505 | 734 |
apply (simp add: less_max_iff_disj) |
735 |
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
|
736 |
apply (erule rev_below_trans) |
30505 | 737 |
apply (rule sub_below) |
738 |
done |
|
27411 | 739 |
qed |
740 |
qed |
|
741 |
||
742 |
lemma inj_basis_emb: "inj basis_emb" |
|
743 |
apply (rule inj_onI) |
|
744 |
apply (case_tac "x = compact_bot") |
|
745 |
apply (case_tac [!] "y = compact_bot") |
|
746 |
apply simp |
|
747 |
apply (simp add: basis_emb.simps) |
|
748 |
apply (simp add: basis_emb.simps) |
|
749 |
apply (simp add: basis_emb.simps) |
|
30505 | 750 |
apply (simp add: fin2 inj_eq [OF inj_place]) |
27411 | 751 |
done |
752 |
||
753 |
definition |
|
30505 | 754 |
basis_prj :: "ubasis \<Rightarrow> 'a compact_basis" |
27411 | 755 |
where |
756 |
"basis_prj x = inv basis_emb |
|
30505 | 757 |
(ubasis_until (\<lambda>x. x \<in> range (basis_emb :: 'a compact_basis \<Rightarrow> ubasis)) x)" |
27411 | 758 |
|
759 |
lemma basis_prj_basis_emb: "\<And>x. basis_prj (basis_emb x) = x" |
|
760 |
unfolding basis_prj_def |
|
761 |
apply (subst ubasis_until_same) |
|
762 |
apply (rule rangeI) |
|
763 |
apply (rule inv_f_f) |
|
764 |
apply (rule inj_basis_emb) |
|
765 |
done |
|
766 |
||
767 |
lemma basis_prj_node: |
|
30505 | 768 |
"\<lbrakk>finite S; node i a S \<notin> range (basis_emb :: 'a compact_basis \<Rightarrow> nat)\<rbrakk> |
769 |
\<Longrightarrow> basis_prj (node i a S) = (basis_prj a :: 'a compact_basis)" |
|
27411 | 770 |
unfolding basis_prj_def by simp |
771 |
||
772 |
lemma basis_prj_0: "basis_prj 0 = compact_bot" |
|
773 |
apply (subst basis_emb_compact_bot [symmetric]) |
|
774 |
apply (rule basis_prj_basis_emb) |
|
775 |
done |
|
776 |
||
30505 | 777 |
lemma node_eq_basis_emb_iff: |
778 |
"finite S \<Longrightarrow> node i a S = basis_emb x \<longleftrightarrow> |
|
779 |
x \<noteq> compact_bot \<and> i = place x \<and> a = basis_emb (sub x) \<and> |
|
780 |
S = basis_emb ` {y. place y < place x \<and> x \<sqsubseteq> y}" |
|
781 |
apply (cases "x = compact_bot", simp) |
|
782 |
apply (simp add: basis_emb.simps [of x]) |
|
783 |
apply (simp add: fin2) |
|
27411 | 784 |
done |
785 |
||
30505 | 786 |
lemma basis_prj_mono: "ubasis_le a b \<Longrightarrow> basis_prj a \<sqsubseteq> basis_prj b" |
787 |
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
|
788 |
case (ubasis_le_refl a) show ?case by (rule below_refl) |
30505 | 789 |
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
|
790 |
case (ubasis_le_trans a b c) thus ?case by - (rule below_trans) |
30505 | 791 |
next |
792 |
case (ubasis_le_lower S a i) thus ?case |
|
30561 | 793 |
apply (cases "node i a S \<in> range (basis_emb :: 'a compact_basis \<Rightarrow> nat)") |
30505 | 794 |
apply (erule rangeE, rename_tac x) |
795 |
apply (simp add: basis_prj_basis_emb) |
|
796 |
apply (simp add: node_eq_basis_emb_iff) |
|
797 |
apply (simp add: basis_prj_basis_emb) |
|
798 |
apply (rule sub_below) |
|
799 |
apply (simp add: basis_prj_node) |
|
800 |
done |
|
801 |
next |
|
802 |
case (ubasis_le_upper S b a i) thus ?case |
|
30561 | 803 |
apply (cases "node i a S \<in> range (basis_emb :: 'a compact_basis \<Rightarrow> nat)") |
30505 | 804 |
apply (erule rangeE, rename_tac x) |
805 |
apply (simp add: basis_prj_basis_emb) |
|
806 |
apply (clarsimp simp add: node_eq_basis_emb_iff) |
|
807 |
apply (simp add: basis_prj_basis_emb) |
|
808 |
apply (simp add: basis_prj_node) |
|
809 |
done |
|
810 |
qed |
|
811 |
||
27411 | 812 |
lemma basis_emb_prj_less: "ubasis_le (basis_emb (basis_prj x)) x" |
813 |
unfolding basis_prj_def |
|
33071
362f59fe5092
renamed f_inv_onto_f to f_inv_into_f (cf. 764547b68538);
wenzelm
parents:
32997
diff
changeset
|
814 |
apply (subst f_inv_into_f [where f=basis_emb]) |
27411 | 815 |
apply (rule ubasis_until) |
816 |
apply (rule range_eqI [where x=compact_bot]) |
|
817 |
apply simp |
|
818 |
apply (rule ubasis_until_less) |
|
819 |
done |
|
820 |
||
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
821 |
end |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
822 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
823 |
sublocale approx_chain \<subseteq> compact_basis!: |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
824 |
ideal_completion below Rep_compact_basis |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
825 |
"approximants :: 'a \<Rightarrow> 'a compact_basis set" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
826 |
proof |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
827 |
fix w :: "'a" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
828 |
show "below.ideal (approximants w)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
829 |
proof (rule below.idealI) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
830 |
show "\<exists>x. x \<in> approximants w" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
831 |
unfolding approximants_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
832 |
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
|
833 |
apply (simp add: Abs_compact_basis_inverse approx_below compact_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
834 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
835 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
836 |
fix x y :: "'a compact_basis" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
837 |
assume "x \<in> approximants w" "y \<in> approximants w" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
838 |
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
|
839 |
unfolding approximants_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
840 |
apply simp |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
841 |
apply (cut_tac a=x in compact_Rep_compact_basis) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
842 |
apply (cut_tac a=y in compact_Rep_compact_basis) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
843 |
apply (drule compact_eq_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
844 |
apply (drule compact_eq_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
845 |
apply (clarify, rename_tac i j) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
846 |
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
|
847 |
apply (simp add: compact_le_def) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
848 |
apply (simp add: Abs_compact_basis_inverse approx_below compact_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
849 |
apply (erule subst, erule subst) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
850 |
apply (simp add: monofun_cfun chain_mono [OF chain_approx]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
851 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
852 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
853 |
fix x y :: "'a compact_basis" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
854 |
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
|
855 |
unfolding approximants_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
856 |
apply simp |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
857 |
apply (simp add: compact_le_def) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
858 |
apply (erule (1) below_trans) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
859 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
860 |
qed |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
861 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
862 |
fix Y :: "nat \<Rightarrow> 'a" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
863 |
assume Y: "chain Y" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
864 |
show "approximants (\<Squnion>i. Y i) = (\<Union>i. approximants (Y i))" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
865 |
unfolding approximants_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
866 |
apply safe |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
867 |
apply (simp add: compactD2 [OF compact_Rep_compact_basis Y]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
868 |
apply (erule below_trans, rule is_ub_thelub [OF Y]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
869 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
870 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
871 |
fix a :: "'a compact_basis" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
872 |
show "approximants (Rep_compact_basis a) = {b. b \<sqsubseteq> a}" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
873 |
unfolding approximants_def compact_le_def .. |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
874 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
875 |
fix x y :: "'a" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
876 |
assume "approximants x \<subseteq> approximants y" thus "x \<sqsubseteq> y" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
877 |
apply (subgoal_tac "(\<Squnion>i. approx i\<cdot>x) \<sqsubseteq> y") |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
878 |
apply (simp add: lub_distribs) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
879 |
apply (rule admD, simp, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
880 |
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
|
881 |
apply (simp add: approximants_def Abs_compact_basis_inverse |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
882 |
approx_below compact_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
883 |
apply (simp add: approximants_def Abs_compact_basis_inverse compact_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
884 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
885 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
886 |
show "\<exists>f::'a compact_basis \<Rightarrow> nat. inj f" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
887 |
by (rule exI, rule inj_place) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
888 |
qed |
27411 | 889 |
|
35900
aa5dfb03eb1e
remove LaTeX hyperref warnings by avoiding antiquotations within section headings
huffman
parents:
35794
diff
changeset
|
890 |
subsubsection {* EP-pair from any bifinite domain into \emph{udom} *} |
27411 | 891 |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
892 |
context approx_chain begin |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
893 |
|
27411 | 894 |
definition |
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
895 |
udom_emb :: "'a \<rightarrow> udom" |
27411 | 896 |
where |
897 |
"udom_emb = compact_basis.basis_fun (\<lambda>x. udom_principal (basis_emb x))" |
|
898 |
||
899 |
definition |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
900 |
udom_prj :: "udom \<rightarrow> 'a" |
27411 | 901 |
where |
902 |
"udom_prj = udom.basis_fun (\<lambda>x. Rep_compact_basis (basis_prj x))" |
|
903 |
||
904 |
lemma udom_emb_principal: |
|
905 |
"udom_emb\<cdot>(Rep_compact_basis x) = udom_principal (basis_emb x)" |
|
906 |
unfolding udom_emb_def |
|
907 |
apply (rule compact_basis.basis_fun_principal) |
|
908 |
apply (rule udom.principal_mono) |
|
909 |
apply (erule basis_emb_mono) |
|
910 |
done |
|
911 |
||
912 |
lemma udom_prj_principal: |
|
913 |
"udom_prj\<cdot>(udom_principal x) = Rep_compact_basis (basis_prj x)" |
|
914 |
unfolding udom_prj_def |
|
915 |
apply (rule udom.basis_fun_principal) |
|
916 |
apply (rule compact_basis.principal_mono) |
|
917 |
apply (erule basis_prj_mono) |
|
918 |
done |
|
919 |
||
920 |
lemma ep_pair_udom: "ep_pair udom_emb udom_prj" |
|
921 |
apply default |
|
922 |
apply (rule compact_basis.principal_induct, simp) |
|
923 |
apply (simp add: udom_emb_principal udom_prj_principal) |
|
924 |
apply (simp add: basis_prj_basis_emb) |
|
925 |
apply (rule udom.principal_induct, simp) |
|
926 |
apply (simp add: udom_emb_principal udom_prj_principal) |
|
927 |
apply (rule basis_emb_prj_less) |
|
928 |
done |
|
929 |
||
930 |
end |
|
39974
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
931 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
932 |
abbreviation "udom_emb \<equiv> approx_chain.udom_emb" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
933 |
abbreviation "udom_prj \<equiv> approx_chain.udom_prj" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
934 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
935 |
lemmas ep_pair_udom = approx_chain.ep_pair_udom |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
936 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
937 |
subsection {* Chain of approx functions for type \emph{udom} *} |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
938 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
939 |
definition |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
940 |
udom_approx :: "nat \<Rightarrow> udom \<rightarrow> udom" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
941 |
where |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
942 |
"udom_approx i = |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
943 |
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
|
944 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
945 |
lemma udom_approx_mono: |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
946 |
"ubasis_le a b \<Longrightarrow> |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
947 |
udom_principal (ubasis_until (\<lambda>y. y \<le> i) a) \<sqsubseteq> |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
948 |
udom_principal (ubasis_until (\<lambda>y. y \<le> i) b)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
949 |
apply (rule udom.principal_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
950 |
apply (rule ubasis_until_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
951 |
apply (frule (2) order_less_le_trans [OF node_gt2]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
952 |
apply (erule order_less_imp_le) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
953 |
apply assumption |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
954 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
955 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
956 |
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
|
957 |
by (erule adm_subst, induct set: finite, simp_all) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
958 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
959 |
lemma udom_approx_principal: |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
960 |
"udom_approx i\<cdot>(udom_principal x) = |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
961 |
udom_principal (ubasis_until (\<lambda>y. y \<le> i) x)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
962 |
unfolding udom_approx_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
963 |
apply (rule udom.basis_fun_principal) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
964 |
apply (erule udom_approx_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
965 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
966 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
967 |
lemma finite_deflation_udom_approx: "finite_deflation (udom_approx i)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
968 |
proof |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
969 |
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
|
970 |
by (induct x rule: udom.principal_induct, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
971 |
(simp add: udom_approx_principal ubasis_until_idem) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
972 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
973 |
fix x show "udom_approx i\<cdot>x \<sqsubseteq> x" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
974 |
by (induct x rule: udom.principal_induct, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
975 |
(simp add: udom_approx_principal ubasis_until_less) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
976 |
next |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
977 |
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
|
978 |
apply (subst range_composition [where f=udom_principal]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
979 |
apply (simp add: finite_range_ubasis_until) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
980 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
981 |
show "finite {x. udom_approx i\<cdot>x = x}" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
982 |
apply (rule finite_range_imp_finite_fixes) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
983 |
apply (rule rev_finite_subset [OF *]) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
984 |
apply (clarsimp, rename_tac x) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
985 |
apply (induct_tac x rule: udom.principal_induct) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
986 |
apply (simp add: adm_mem_finite *) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
987 |
apply (simp add: udom_approx_principal) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
988 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
989 |
qed |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
990 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
991 |
interpretation udom_approx: finite_deflation "udom_approx i" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
992 |
by (rule finite_deflation_udom_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
993 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
994 |
lemma chain_udom_approx [simp]: "chain (\<lambda>i. udom_approx i)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
995 |
unfolding udom_approx_def |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
996 |
apply (rule chainI) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
997 |
apply (rule udom.basis_fun_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
998 |
apply (erule udom_approx_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
999 |
apply (erule udom_approx_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1000 |
apply (rule udom.principal_mono) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1001 |
apply (rule ubasis_until_chain, simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1002 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1003 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1004 |
lemma lub_udom_approx [simp]: "(\<Squnion>i. udom_approx i) = ID" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1005 |
apply (rule ext_cfun, simp add: contlub_cfun_fun) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1006 |
apply (rule below_antisym) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1007 |
apply (rule is_lub_thelub) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1008 |
apply (simp) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1009 |
apply (rule ub_rangeI) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1010 |
apply (rule udom_approx.below) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1011 |
apply (rule_tac x=x in udom.principal_induct) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1012 |
apply (simp add: lub_distribs) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1013 |
apply (rule rev_below_trans) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1014 |
apply (rule_tac x=a in is_ub_thelub) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1015 |
apply simp |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1016 |
apply (simp add: udom_approx_principal) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1017 |
apply (simp add: ubasis_until_same ubasis_le_refl) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1018 |
done |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1019 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1020 |
lemma udom_approx: "approx_chain udom_approx" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1021 |
proof |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1022 |
show "chain (\<lambda>i. udom_approx i)" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1023 |
by (rule chain_udom_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1024 |
show "(\<Squnion>i. udom_approx i) = ID" |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1025 |
by (rule lub_udom_approx) |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1026 |
qed |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1027 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1028 |
hide_const (open) node |
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1029 |
|
b525988432e9
major reorganization/simplification of HOLCF type classes:
huffman
parents:
36452
diff
changeset
|
1030 |
end |