25903
|
1 |
(* Title: HOLCF/Bifinite.thy
|
|
2 |
ID: $Id$
|
|
3 |
Author: Brian Huffman
|
|
4 |
*)
|
|
5 |
|
|
6 |
header {* Bifinite domains and approximation *}
|
|
7 |
|
|
8 |
theory Bifinite
|
|
9 |
imports Cfun
|
|
10 |
begin
|
|
11 |
|
|
12 |
subsection {* Bifinite domains *}
|
|
13 |
|
|
14 |
axclass approx < pcpo
|
|
15 |
|
|
16 |
consts approx :: "nat \<Rightarrow> 'a::approx \<rightarrow> 'a"
|
|
17 |
|
|
18 |
axclass bifinite < approx
|
|
19 |
chain_approx_app: "chain (\<lambda>i. approx i\<cdot>x)"
|
|
20 |
lub_approx_app [simp]: "(\<Squnion>i. approx i\<cdot>x) = x"
|
|
21 |
approx_idem: "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x"
|
|
22 |
finite_fixes_approx: "finite {x. approx i\<cdot>x = x}"
|
|
23 |
|
|
24 |
lemma finite_range_imp_finite_fixes:
|
|
25 |
"finite {x. \<exists>y. x = f y} \<Longrightarrow> finite {x. f x = x}"
|
|
26 |
apply (subgoal_tac "{x. f x = x} \<subseteq> {x. \<exists>y. x = f y}")
|
|
27 |
apply (erule (1) finite_subset)
|
|
28 |
apply (clarify, erule subst, rule exI, rule refl)
|
|
29 |
done
|
|
30 |
|
|
31 |
lemma chain_approx [simp]:
|
|
32 |
"chain (approx :: nat \<Rightarrow> 'a::bifinite \<rightarrow> 'a)"
|
|
33 |
apply (rule chainI)
|
|
34 |
apply (rule less_cfun_ext)
|
|
35 |
apply (rule chainE)
|
|
36 |
apply (rule chain_approx_app)
|
|
37 |
done
|
|
38 |
|
|
39 |
lemma lub_approx [simp]: "(\<Squnion>i. approx i) = (\<Lambda>(x::'a::bifinite). x)"
|
|
40 |
by (rule ext_cfun, simp add: contlub_cfun_fun)
|
|
41 |
|
|
42 |
lemma approx_less: "approx i\<cdot>x \<sqsubseteq> (x::'a::bifinite)"
|
|
43 |
apply (subgoal_tac "approx i\<cdot>x \<sqsubseteq> (\<Squnion>i. approx i\<cdot>x)", simp)
|
|
44 |
apply (rule is_ub_thelub, simp)
|
|
45 |
done
|
|
46 |
|
|
47 |
lemma approx_strict [simp]: "approx i\<cdot>(\<bottom>::'a::bifinite) = \<bottom>"
|
|
48 |
by (rule UU_I, rule approx_less)
|
|
49 |
|
|
50 |
lemma approx_approx1:
|
|
51 |
"i \<le> j \<Longrightarrow> approx i\<cdot>(approx j\<cdot>x) = approx i\<cdot>(x::'a::bifinite)"
|
|
52 |
apply (rule antisym_less)
|
|
53 |
apply (rule monofun_cfun_arg [OF approx_less])
|
|
54 |
apply (rule sq_ord_eq_less_trans [OF approx_idem [symmetric]])
|
|
55 |
apply (rule monofun_cfun_arg)
|
|
56 |
apply (rule monofun_cfun_fun)
|
|
57 |
apply (erule chain_mono3 [OF chain_approx])
|
|
58 |
done
|
|
59 |
|
|
60 |
lemma approx_approx2:
|
|
61 |
"j \<le> i \<Longrightarrow> approx i\<cdot>(approx j\<cdot>x) = approx j\<cdot>(x::'a::bifinite)"
|
|
62 |
apply (rule antisym_less)
|
|
63 |
apply (rule approx_less)
|
|
64 |
apply (rule sq_ord_eq_less_trans [OF approx_idem [symmetric]])
|
|
65 |
apply (rule monofun_cfun_fun)
|
|
66 |
apply (erule chain_mono3 [OF chain_approx])
|
|
67 |
done
|
|
68 |
|
|
69 |
lemma approx_approx [simp]:
|
|
70 |
"approx i\<cdot>(approx j\<cdot>x) = approx (min i j)\<cdot>(x::'a::bifinite)"
|
|
71 |
apply (rule_tac x=i and y=j in linorder_le_cases)
|
|
72 |
apply (simp add: approx_approx1 min_def)
|
|
73 |
apply (simp add: approx_approx2 min_def)
|
|
74 |
done
|
|
75 |
|
|
76 |
lemma idem_fixes_eq_range:
|
|
77 |
"\<forall>x. f (f x) = f x \<Longrightarrow> {x. f x = x} = {y. \<exists>x. y = f x}"
|
|
78 |
by (auto simp add: eq_sym_conv)
|
|
79 |
|
|
80 |
lemma finite_approx: "finite {y::'a::bifinite. \<exists>x. y = approx n\<cdot>x}"
|
|
81 |
using finite_fixes_approx by (simp add: idem_fixes_eq_range)
|
|
82 |
|
|
83 |
lemma finite_range_approx:
|
|
84 |
"finite (range (\<lambda>x::'a::bifinite. approx n\<cdot>x))"
|
|
85 |
by (simp add: image_def finite_approx)
|
|
86 |
|
|
87 |
lemma compact_approx [simp]:
|
|
88 |
fixes x :: "'a::bifinite"
|
|
89 |
shows "compact (approx n\<cdot>x)"
|
|
90 |
proof (rule compactI2)
|
|
91 |
fix Y::"nat \<Rightarrow> 'a"
|
|
92 |
assume Y: "chain Y"
|
|
93 |
have "finite_chain (\<lambda>i. approx n\<cdot>(Y i))"
|
|
94 |
proof (rule finite_range_imp_finch)
|
|
95 |
show "chain (\<lambda>i. approx n\<cdot>(Y i))"
|
|
96 |
using Y by simp
|
|
97 |
have "range (\<lambda>i. approx n\<cdot>(Y i)) \<subseteq> {x. approx n\<cdot>x = x}"
|
|
98 |
by clarsimp
|
|
99 |
thus "finite (range (\<lambda>i. approx n\<cdot>(Y i)))"
|
|
100 |
using finite_fixes_approx by (rule finite_subset)
|
|
101 |
qed
|
|
102 |
hence "\<exists>j. (\<Squnion>i. approx n\<cdot>(Y i)) = approx n\<cdot>(Y j)"
|
|
103 |
by (simp add: finite_chain_def maxinch_is_thelub Y)
|
|
104 |
then obtain j where j: "(\<Squnion>i. approx n\<cdot>(Y i)) = approx n\<cdot>(Y j)" ..
|
|
105 |
|
|
106 |
assume "approx n\<cdot>x \<sqsubseteq> (\<Squnion>i. Y i)"
|
|
107 |
hence "approx n\<cdot>(approx n\<cdot>x) \<sqsubseteq> approx n\<cdot>(\<Squnion>i. Y i)"
|
|
108 |
by (rule monofun_cfun_arg)
|
|
109 |
hence "approx n\<cdot>x \<sqsubseteq> (\<Squnion>i. approx n\<cdot>(Y i))"
|
|
110 |
by (simp add: contlub_cfun_arg Y)
|
|
111 |
hence "approx n\<cdot>x \<sqsubseteq> approx n\<cdot>(Y j)"
|
|
112 |
using j by simp
|
|
113 |
hence "approx n\<cdot>x \<sqsubseteq> Y j"
|
|
114 |
using approx_less by (rule trans_less)
|
|
115 |
thus "\<exists>j. approx n\<cdot>x \<sqsubseteq> Y j" ..
|
|
116 |
qed
|
|
117 |
|
|
118 |
lemma bifinite_compact_eq_approx:
|
|
119 |
fixes x :: "'a::bifinite"
|
|
120 |
assumes x: "compact x"
|
|
121 |
shows "\<exists>i. approx i\<cdot>x = x"
|
|
122 |
proof -
|
|
123 |
have chain: "chain (\<lambda>i. approx i\<cdot>x)" by simp
|
|
124 |
have less: "x \<sqsubseteq> (\<Squnion>i. approx i\<cdot>x)" by simp
|
|
125 |
obtain i where i: "x \<sqsubseteq> approx i\<cdot>x"
|
|
126 |
using compactD2 [OF x chain less] ..
|
|
127 |
with approx_less have "approx i\<cdot>x = x"
|
|
128 |
by (rule antisym_less)
|
|
129 |
thus "\<exists>i. approx i\<cdot>x = x" ..
|
|
130 |
qed
|
|
131 |
|
|
132 |
lemma bifinite_compact_iff:
|
|
133 |
"compact (x::'a::bifinite) = (\<exists>n. approx n\<cdot>x = x)"
|
|
134 |
apply (rule iffI)
|
|
135 |
apply (erule bifinite_compact_eq_approx)
|
|
136 |
apply (erule exE)
|
|
137 |
apply (erule subst)
|
|
138 |
apply (rule compact_approx)
|
|
139 |
done
|
|
140 |
|
|
141 |
lemma approx_induct:
|
|
142 |
assumes adm: "adm P" and P: "\<And>n x. P (approx n\<cdot>x)"
|
|
143 |
shows "P (x::'a::bifinite)"
|
|
144 |
proof -
|
|
145 |
have "P (\<Squnion>n. approx n\<cdot>x)"
|
|
146 |
by (rule admD [OF adm], simp, simp add: P)
|
|
147 |
thus "P x" by simp
|
|
148 |
qed
|
|
149 |
|
|
150 |
lemma bifinite_less_ext:
|
|
151 |
fixes x y :: "'a::bifinite"
|
|
152 |
shows "(\<And>i. approx i\<cdot>x \<sqsubseteq> approx i\<cdot>y) \<Longrightarrow> x \<sqsubseteq> y"
|
|
153 |
apply (subgoal_tac "(\<Squnion>i. approx i\<cdot>x) \<sqsubseteq> (\<Squnion>i. approx i\<cdot>y)", simp)
|
|
154 |
apply (rule lub_mono [rule_format], simp, simp, simp)
|
|
155 |
done
|
|
156 |
|
|
157 |
subsection {* Instance for continuous function space *}
|
|
158 |
|
|
159 |
lemma finite_range_lemma:
|
|
160 |
fixes h :: "'a::cpo \<rightarrow> 'b::cpo"
|
|
161 |
fixes k :: "'c::cpo \<rightarrow> 'd::cpo"
|
|
162 |
shows "\<lbrakk>finite {y. \<exists>x. y = h\<cdot>x}; finite {y. \<exists>x. y = k\<cdot>x}\<rbrakk>
|
|
163 |
\<Longrightarrow> finite {g. \<exists>f. g = (\<Lambda> x. k\<cdot>(f\<cdot>(h\<cdot>x)))}"
|
|
164 |
apply (rule_tac f="\<lambda>g. {(h\<cdot>x, y) |x y. y = g\<cdot>x}" in finite_imageD)
|
|
165 |
apply (rule_tac B="Pow ({y. \<exists>x. y = h\<cdot>x} \<times> {y. \<exists>x. y = k\<cdot>x})"
|
|
166 |
in finite_subset)
|
|
167 |
apply (rule image_subsetI)
|
|
168 |
apply (clarsimp, fast)
|
|
169 |
apply simp
|
|
170 |
apply (rule inj_onI)
|
|
171 |
apply (clarsimp simp add: expand_set_eq)
|
|
172 |
apply (rule ext_cfun, simp)
|
|
173 |
apply (drule_tac x="h\<cdot>x" in spec)
|
|
174 |
apply (drule_tac x="k\<cdot>(f\<cdot>(h\<cdot>x))" in spec)
|
|
175 |
apply (drule iffD1, fast)
|
|
176 |
apply clarsimp
|
|
177 |
done
|
|
178 |
|
|
179 |
instance "->" :: (bifinite, bifinite) approx ..
|
|
180 |
|
|
181 |
defs (overloaded)
|
|
182 |
approx_cfun_def:
|
|
183 |
"approx \<equiv> \<lambda>n. \<Lambda> f x. approx n\<cdot>(f\<cdot>(approx n\<cdot>x))"
|
|
184 |
|
|
185 |
instance "->" :: (bifinite, bifinite) bifinite
|
|
186 |
apply (intro_classes, unfold approx_cfun_def)
|
|
187 |
apply simp
|
|
188 |
apply (simp add: lub_distribs eta_cfun)
|
|
189 |
apply simp
|
|
190 |
apply simp
|
|
191 |
apply (rule finite_range_imp_finite_fixes)
|
|
192 |
apply (intro finite_range_lemma finite_approx)
|
|
193 |
done
|
|
194 |
|
|
195 |
lemma approx_cfun: "approx n\<cdot>f\<cdot>x = approx n\<cdot>(f\<cdot>(approx n\<cdot>x))"
|
|
196 |
by (simp add: approx_cfun_def)
|
|
197 |
|
|
198 |
end
|