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