author  huffman 
Mon, 19 May 2008 23:49:20 +0200  
changeset 26962  c8b20f615d6c 
parent 26407  562a1d615336 
child 27186  416d66c36d8f 
permissions  rwrr 
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 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

12 
subsection {* Omegaprofinite and bifinite domains *} 
25903  13 

26962
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

14 
class profinite = cpo + 
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

15 
fixes approx :: "nat \<Rightarrow> 'a \<rightarrow> 'a" 
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

16 
assumes chain_approx_app: "chain (\<lambda>i. approx i\<cdot>x)" 
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

17 
assumes lub_approx_app [simp]: "(\<Squnion>i. approx i\<cdot>x) = x" 
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

18 
assumes approx_idem: "approx i\<cdot>(approx i\<cdot>x) = approx i\<cdot>x" 
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

19 
assumes finite_fixes_approx: "finite {x. approx i\<cdot>x = x}" 
25903  20 

26962
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

21 
class bifinite = profinite + pcpo 
25909
6b96b9392873
add class bifinite_cpo for possiblyunpointed bifinite domains
huffman
parents:
25903
diff
changeset

22 

25903  23 
lemma finite_range_imp_finite_fixes: 
24 
"finite {x. \<exists>y. x = f y} \<Longrightarrow> finite {x. f x = x}" 

25 
apply (subgoal_tac "{x. f x = x} \<subseteq> {x. \<exists>y. x = f y}") 

26 
apply (erule (1) finite_subset) 

27 
apply (clarify, erule subst, rule exI, rule refl) 

28 
done 

29 

30 
lemma chain_approx [simp]: 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

31 
"chain (approx :: nat \<Rightarrow> 'a::profinite \<rightarrow> 'a)" 
25903  32 
apply (rule chainI) 
33 
apply (rule less_cfun_ext) 

34 
apply (rule chainE) 

35 
apply (rule chain_approx_app) 

36 
done 

37 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

38 
lemma lub_approx [simp]: "(\<Squnion>i. approx i) = (\<Lambda>(x::'a::profinite). x)" 
25903  39 
by (rule ext_cfun, simp add: contlub_cfun_fun) 
40 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

41 
lemma approx_less: "approx i\<cdot>x \<sqsubseteq> (x::'a::profinite)" 
25903  42 
apply (subgoal_tac "approx i\<cdot>x \<sqsubseteq> (\<Squnion>i. approx i\<cdot>x)", simp) 
43 
apply (rule is_ub_thelub, simp) 

44 
done 

45 

46 
lemma approx_strict [simp]: "approx i\<cdot>(\<bottom>::'a::bifinite) = \<bottom>" 

47 
by (rule UU_I, rule approx_less) 

48 

49 
lemma approx_approx1: 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

50 
"i \<le> j \<Longrightarrow> approx i\<cdot>(approx j\<cdot>x) = approx i\<cdot>(x::'a::profinite)" 
25903  51 
apply (rule antisym_less) 
52 
apply (rule monofun_cfun_arg [OF approx_less]) 

53 
apply (rule sq_ord_eq_less_trans [OF approx_idem [symmetric]]) 

54 
apply (rule monofun_cfun_arg) 

55 
apply (rule monofun_cfun_fun) 

25922
cb04d05e95fb
rename lemma chain_mono3 > chain_mono, chain_mono > chain_mono_less
huffman
parents:
25909
diff
changeset

56 
apply (erule chain_mono [OF chain_approx]) 
25903  57 
done 
58 

59 
lemma approx_approx2: 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

60 
"j \<le> i \<Longrightarrow> approx i\<cdot>(approx j\<cdot>x) = approx j\<cdot>(x::'a::profinite)" 
25903  61 
apply (rule antisym_less) 
62 
apply (rule approx_less) 

63 
apply (rule sq_ord_eq_less_trans [OF approx_idem [symmetric]]) 

64 
apply (rule monofun_cfun_fun) 

25922
cb04d05e95fb
rename lemma chain_mono3 > chain_mono, chain_mono > chain_mono_less
huffman
parents:
25909
diff
changeset

65 
apply (erule chain_mono [OF chain_approx]) 
25903  66 
done 
67 

68 
lemma approx_approx [simp]: 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

69 
"approx i\<cdot>(approx j\<cdot>x) = approx (min i j)\<cdot>(x::'a::profinite)" 
25903  70 
apply (rule_tac x=i and y=j in linorder_le_cases) 
71 
apply (simp add: approx_approx1 min_def) 

72 
apply (simp add: approx_approx2 min_def) 

73 
done 

74 

75 
lemma idem_fixes_eq_range: 

76 
"\<forall>x. f (f x) = f x \<Longrightarrow> {x. f x = x} = {y. \<exists>x. y = f x}" 

77 
by (auto simp add: eq_sym_conv) 

78 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

79 
lemma finite_approx: "finite {y::'a::profinite. \<exists>x. y = approx n\<cdot>x}" 
25903  80 
using finite_fixes_approx by (simp add: idem_fixes_eq_range) 
81 

82 
lemma finite_range_approx: 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

83 
"finite (range (\<lambda>x::'a::profinite. approx n\<cdot>x))" 
25903  84 
by (simp add: image_def finite_approx) 
85 

86 
lemma compact_approx [simp]: 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

87 
fixes x :: "'a::profinite" 
25903  88 
shows "compact (approx n\<cdot>x)" 
89 
proof (rule compactI2) 

90 
fix Y::"nat \<Rightarrow> 'a" 

91 
assume Y: "chain Y" 

92 
have "finite_chain (\<lambda>i. approx n\<cdot>(Y i))" 

93 
proof (rule finite_range_imp_finch) 

94 
show "chain (\<lambda>i. approx n\<cdot>(Y i))" 

95 
using Y by simp 

96 
have "range (\<lambda>i. approx n\<cdot>(Y i)) \<subseteq> {x. approx n\<cdot>x = x}" 

97 
by clarsimp 

98 
thus "finite (range (\<lambda>i. approx n\<cdot>(Y i)))" 

99 
using finite_fixes_approx by (rule finite_subset) 

100 
qed 

101 
hence "\<exists>j. (\<Squnion>i. approx n\<cdot>(Y i)) = approx n\<cdot>(Y j)" 

102 
by (simp add: finite_chain_def maxinch_is_thelub Y) 

103 
then obtain j where j: "(\<Squnion>i. approx n\<cdot>(Y i)) = approx n\<cdot>(Y j)" .. 

104 

105 
assume "approx n\<cdot>x \<sqsubseteq> (\<Squnion>i. Y i)" 

106 
hence "approx n\<cdot>(approx n\<cdot>x) \<sqsubseteq> approx n\<cdot>(\<Squnion>i. Y i)" 

107 
by (rule monofun_cfun_arg) 

108 
hence "approx n\<cdot>x \<sqsubseteq> (\<Squnion>i. approx n\<cdot>(Y i))" 

109 
by (simp add: contlub_cfun_arg Y) 

110 
hence "approx n\<cdot>x \<sqsubseteq> approx n\<cdot>(Y j)" 

111 
using j by simp 

112 
hence "approx n\<cdot>x \<sqsubseteq> Y j" 

113 
using approx_less by (rule trans_less) 

114 
thus "\<exists>j. approx n\<cdot>x \<sqsubseteq> Y j" .. 

115 
qed 

116 

117 
lemma bifinite_compact_eq_approx: 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

118 
fixes x :: "'a::profinite" 
25903  119 
assumes x: "compact x" 
120 
shows "\<exists>i. approx i\<cdot>x = x" 

121 
proof  

122 
have chain: "chain (\<lambda>i. approx i\<cdot>x)" by simp 

123 
have less: "x \<sqsubseteq> (\<Squnion>i. approx i\<cdot>x)" by simp 

124 
obtain i where i: "x \<sqsubseteq> approx i\<cdot>x" 

125 
using compactD2 [OF x chain less] .. 

126 
with approx_less have "approx i\<cdot>x = x" 

127 
by (rule antisym_less) 

128 
thus "\<exists>i. approx i\<cdot>x = x" .. 

129 
qed 

130 

131 
lemma bifinite_compact_iff: 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

132 
"compact (x::'a::profinite) = (\<exists>n. approx n\<cdot>x = x)" 
25903  133 
apply (rule iffI) 
134 
apply (erule bifinite_compact_eq_approx) 

135 
apply (erule exE) 

136 
apply (erule subst) 

137 
apply (rule compact_approx) 

138 
done 

139 

140 
lemma approx_induct: 

141 
assumes adm: "adm P" and P: "\<And>n x. P (approx n\<cdot>x)" 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

142 
shows "P (x::'a::profinite)" 
25903  143 
proof  
144 
have "P (\<Squnion>n. approx n\<cdot>x)" 

145 
by (rule admD [OF adm], simp, simp add: P) 

146 
thus "P x" by simp 

147 
qed 

148 

149 
lemma bifinite_less_ext: 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

150 
fixes x y :: "'a::profinite" 
25903  151 
shows "(\<And>i. approx i\<cdot>x \<sqsubseteq> approx i\<cdot>y) \<Longrightarrow> x \<sqsubseteq> y" 
152 
apply (subgoal_tac "(\<Squnion>i. approx i\<cdot>x) \<sqsubseteq> (\<Squnion>i. approx i\<cdot>y)", simp) 

25923  153 
apply (rule lub_mono, simp, simp, simp) 
25903  154 
done 
155 

156 
subsection {* Instance for continuous function space *} 

157 

158 
lemma finite_range_lemma: 

159 
fixes h :: "'a::cpo \<rightarrow> 'b::cpo" 

160 
fixes k :: "'c::cpo \<rightarrow> 'd::cpo" 

161 
shows "\<lbrakk>finite {y. \<exists>x. y = h\<cdot>x}; finite {y. \<exists>x. y = k\<cdot>x}\<rbrakk> 

162 
\<Longrightarrow> finite {g. \<exists>f. g = (\<Lambda> x. k\<cdot>(f\<cdot>(h\<cdot>x)))}" 

163 
apply (rule_tac f="\<lambda>g. {(h\<cdot>x, y) x y. y = g\<cdot>x}" in finite_imageD) 

164 
apply (rule_tac B="Pow ({y. \<exists>x. y = h\<cdot>x} \<times> {y. \<exists>x. y = k\<cdot>x})" 

165 
in finite_subset) 

166 
apply (rule image_subsetI) 

167 
apply (clarsimp, fast) 

168 
apply simp 

169 
apply (rule inj_onI) 

170 
apply (clarsimp simp add: expand_set_eq) 

171 
apply (rule ext_cfun, simp) 

172 
apply (drule_tac x="h\<cdot>x" in spec) 

173 
apply (drule_tac x="k\<cdot>(f\<cdot>(h\<cdot>x))" in spec) 

174 
apply (drule iffD1, fast) 

175 
apply clarsimp 

176 
done 

177 

26962
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

178 
instantiation ">" :: (profinite, profinite) profinite 
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

179 
begin 
25903  180 

26962
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

181 
definition 
25903  182 
approx_cfun_def: 
26962
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

183 
"approx = (\<lambda>n. \<Lambda> f x. approx n\<cdot>(f\<cdot>(approx n\<cdot>x)))" 
25903  184 

26962
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

185 
instance 
25903  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 

26962
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

195 
end 
c8b20f615d6c
use new class package for classes profinite, bifinite; remove approx class
huffman
parents:
26407
diff
changeset

196 

26407
562a1d615336
rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents:
25923
diff
changeset

197 
instance ">" :: (profinite, bifinite) bifinite .. 
25909
6b96b9392873
add class bifinite_cpo for possiblyunpointed bifinite domains
huffman
parents:
25903
diff
changeset

198 

25903  199 
lemma approx_cfun: "approx n\<cdot>f\<cdot>x = approx n\<cdot>(f\<cdot>(approx n\<cdot>x))" 
200 
by (simp add: approx_cfun_def) 

201 

202 
end 