| author | bulwahn | 
| Wed, 29 Sep 2010 10:33:15 +0200 | |
| changeset 39785 | 05c4e9ecf5f6 | 
| parent 35479 | dffffe36344a | 
| child 39973 | c62b4ff97bfc | 
| permissions | -rw-r--r-- | 
| 35473 | 1 | (* Title: HOLCF/Powerdomains.thy | 
| 2 | Author: Brian Huffman | |
| 3 | *) | |
| 4 | ||
| 5 | header {* Powerdomains *}
 | |
| 6 | ||
| 7 | theory Powerdomains | |
| 8 | imports Representable ConvexPD | |
| 9 | begin | |
| 10 | ||
| 11 | subsection {* Powerdomains are representable *}
 | |
| 12 | ||
| 13 | text "Upper powerdomain of a representable type is representable." | |
| 14 | ||
| 15 | instantiation upper_pd :: (rep) rep | |
| 16 | begin | |
| 17 | ||
| 18 | definition emb_upper_pd_def: "emb = udom_emb oo upper_map\<cdot>emb" | |
| 19 | definition prj_upper_pd_def: "prj = upper_map\<cdot>prj oo udom_prj" | |
| 20 | ||
| 21 | instance | |
| 22 | apply (intro_classes, unfold emb_upper_pd_def prj_upper_pd_def) | |
| 23 | apply (intro ep_pair_comp ep_pair_upper_map ep_pair_emb_prj ep_pair_udom) | |
| 24 | done | |
| 25 | ||
| 26 | end | |
| 27 | ||
| 28 | text "Lower powerdomain of a representable type is representable." | |
| 29 | ||
| 30 | instantiation lower_pd :: (rep) rep | |
| 31 | begin | |
| 32 | ||
| 33 | definition emb_lower_pd_def: "emb = udom_emb oo lower_map\<cdot>emb" | |
| 34 | definition prj_lower_pd_def: "prj = lower_map\<cdot>prj oo udom_prj" | |
| 35 | ||
| 36 | instance | |
| 37 | apply (intro_classes, unfold emb_lower_pd_def prj_lower_pd_def) | |
| 38 | apply (intro ep_pair_comp ep_pair_lower_map ep_pair_emb_prj ep_pair_udom) | |
| 39 | done | |
| 40 | ||
| 41 | end | |
| 42 | ||
| 43 | text "Convex powerdomain of a representable type is representable." | |
| 44 | ||
| 45 | instantiation convex_pd :: (rep) rep | |
| 46 | begin | |
| 47 | ||
| 48 | definition emb_convex_pd_def: "emb = udom_emb oo convex_map\<cdot>emb" | |
| 49 | definition prj_convex_pd_def: "prj = convex_map\<cdot>prj oo udom_prj" | |
| 50 | ||
| 51 | instance | |
| 52 | apply (intro_classes, unfold emb_convex_pd_def prj_convex_pd_def) | |
| 53 | apply (intro ep_pair_comp ep_pair_convex_map ep_pair_emb_prj ep_pair_udom) | |
| 54 | done | |
| 55 | ||
| 56 | end | |
| 57 | ||
| 58 | subsection {* Finite deflation lemmas *}
 | |
| 59 | ||
| 60 | text "TODO: move these lemmas somewhere else" | |
| 61 | ||
| 62 | lemma finite_compact_range_imp_finite_range: | |
| 63 | fixes d :: "'a::profinite \<rightarrow> 'b::cpo" | |
| 64 |   assumes "finite ((\<lambda>x. d\<cdot>x) ` {x. compact x})"
 | |
| 65 | shows "finite (range (\<lambda>x. d\<cdot>x))" | |
| 66 | proof (rule finite_subset [OF _ prems]) | |
| 67 |   {
 | |
| 68 | fix x :: 'a | |
| 69 |     have "range (\<lambda>i. d\<cdot>(approx i\<cdot>x)) \<subseteq> (\<lambda>x. d\<cdot>x) ` {x. compact x}"
 | |
| 70 | by auto | |
| 71 | hence "finite (range (\<lambda>i. d\<cdot>(approx i\<cdot>x)))" | |
| 72 | using prems by (rule finite_subset) | |
| 73 | hence "finite_chain (\<lambda>i. d\<cdot>(approx i\<cdot>x))" | |
| 74 | by (simp add: finite_range_imp_finch) | |
| 75 | hence "\<exists>i. (\<Squnion>i. d\<cdot>(approx i\<cdot>x)) = d\<cdot>(approx i\<cdot>x)" | |
| 76 | by (simp add: finite_chain_def maxinch_is_thelub) | |
| 77 | hence "\<exists>i. d\<cdot>x = d\<cdot>(approx i\<cdot>x)" | |
| 78 | by (simp add: lub_distribs) | |
| 79 |     hence "d\<cdot>x \<in> (\<lambda>x. d\<cdot>x) ` {x. compact x}"
 | |
| 80 | by auto | |
| 81 | } | |
| 82 |   thus "range (\<lambda>x. d\<cdot>x) \<subseteq> (\<lambda>x. d\<cdot>x) ` {x. compact x}"
 | |
| 83 | by clarsimp | |
| 84 | qed | |
| 85 | ||
| 86 | lemma finite_deflation_upper_map: | |
| 87 | assumes "finite_deflation d" shows "finite_deflation (upper_map\<cdot>d)" | |
| 88 | proof (intro finite_deflation.intro finite_deflation_axioms.intro) | |
| 89 | interpret d: finite_deflation d by fact | |
| 90 | have "deflation d" by fact | |
| 91 | thus "deflation (upper_map\<cdot>d)" by (rule deflation_upper_map) | |
| 92 | have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range) | |
| 93 | hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))" | |
| 94 | by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject) | |
| 95 | hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp | |
| 96 | hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" | |
| 97 | by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject) | |
| 98 | hence "finite (upper_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp | |
| 99 | hence "finite ((\<lambda>xs. upper_map\<cdot>d\<cdot>xs) ` range upper_principal)" | |
| 100 | apply (rule finite_subset [COMP swap_prems_rl]) | |
| 101 | apply (clarsimp, rename_tac t) | |
| 102 | apply (induct_tac t rule: pd_basis_induct) | |
| 103 | apply (simp only: upper_unit_Rep_compact_basis [symmetric] upper_map_unit) | |
| 104 | apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b") | |
| 105 | apply clarsimp | |
| 106 | apply (rule imageI) | |
| 107 | apply (rule vimageI2) | |
| 108 | apply (simp add: Rep_PDUnit) | |
| 109 | apply (rule image_eqI) | |
| 110 | apply (erule sym) | |
| 111 | apply simp | |
| 112 | apply (rule exI) | |
| 113 | apply (rule Abs_compact_basis_inverse [symmetric]) | |
| 114 | apply (simp add: d.compact) | |
| 115 | apply (simp only: upper_plus_principal [symmetric] upper_map_plus) | |
| 116 | apply clarsimp | |
| 117 | apply (rule imageI) | |
| 118 | apply (rule vimageI2) | |
| 119 | apply (simp add: Rep_PDPlus) | |
| 120 | done | |
| 121 |   moreover have "{xs::'a upper_pd. compact xs} = range upper_principal"
 | |
| 122 | by (auto dest: upper_pd.compact_imp_principal) | |
| 123 |   ultimately have "finite ((\<lambda>xs. upper_map\<cdot>d\<cdot>xs) ` {xs::'a upper_pd. compact xs})"
 | |
| 124 | by simp | |
| 125 | hence "finite (range (\<lambda>xs. upper_map\<cdot>d\<cdot>xs))" | |
| 126 | by (rule finite_compact_range_imp_finite_range) | |
| 127 |   thus "finite {xs. upper_map\<cdot>d\<cdot>xs = xs}"
 | |
| 128 | by (rule finite_range_imp_finite_fixes) | |
| 129 | qed | |
| 130 | ||
| 131 | lemma finite_deflation_lower_map: | |
| 132 | assumes "finite_deflation d" shows "finite_deflation (lower_map\<cdot>d)" | |
| 133 | proof (intro finite_deflation.intro finite_deflation_axioms.intro) | |
| 134 | interpret d: finite_deflation d by fact | |
| 135 | have "deflation d" by fact | |
| 136 | thus "deflation (lower_map\<cdot>d)" by (rule deflation_lower_map) | |
| 137 | have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range) | |
| 138 | hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))" | |
| 139 | by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject) | |
| 140 | hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp | |
| 141 | hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" | |
| 142 | by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject) | |
| 143 | hence "finite (lower_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp | |
| 144 | hence "finite ((\<lambda>xs. lower_map\<cdot>d\<cdot>xs) ` range lower_principal)" | |
| 145 | apply (rule finite_subset [COMP swap_prems_rl]) | |
| 146 | apply (clarsimp, rename_tac t) | |
| 147 | apply (induct_tac t rule: pd_basis_induct) | |
| 148 | apply (simp only: lower_unit_Rep_compact_basis [symmetric] lower_map_unit) | |
| 149 | apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b") | |
| 150 | apply clarsimp | |
| 151 | apply (rule imageI) | |
| 152 | apply (rule vimageI2) | |
| 153 | apply (simp add: Rep_PDUnit) | |
| 154 | apply (rule image_eqI) | |
| 155 | apply (erule sym) | |
| 156 | apply simp | |
| 157 | apply (rule exI) | |
| 158 | apply (rule Abs_compact_basis_inverse [symmetric]) | |
| 159 | apply (simp add: d.compact) | |
| 160 | apply (simp only: lower_plus_principal [symmetric] lower_map_plus) | |
| 161 | apply clarsimp | |
| 162 | apply (rule imageI) | |
| 163 | apply (rule vimageI2) | |
| 164 | apply (simp add: Rep_PDPlus) | |
| 165 | done | |
| 166 |   moreover have "{xs::'a lower_pd. compact xs} = range lower_principal"
 | |
| 167 | by (auto dest: lower_pd.compact_imp_principal) | |
| 168 |   ultimately have "finite ((\<lambda>xs. lower_map\<cdot>d\<cdot>xs) ` {xs::'a lower_pd. compact xs})"
 | |
| 169 | by simp | |
| 170 | hence "finite (range (\<lambda>xs. lower_map\<cdot>d\<cdot>xs))" | |
| 171 | by (rule finite_compact_range_imp_finite_range) | |
| 172 |   thus "finite {xs. lower_map\<cdot>d\<cdot>xs = xs}"
 | |
| 173 | by (rule finite_range_imp_finite_fixes) | |
| 174 | qed | |
| 175 | ||
| 176 | lemma finite_deflation_convex_map: | |
| 177 | assumes "finite_deflation d" shows "finite_deflation (convex_map\<cdot>d)" | |
| 178 | proof (intro finite_deflation.intro finite_deflation_axioms.intro) | |
| 179 | interpret d: finite_deflation d by fact | |
| 180 | have "deflation d" by fact | |
| 181 | thus "deflation (convex_map\<cdot>d)" by (rule deflation_convex_map) | |
| 182 | have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range) | |
| 183 | hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))" | |
| 184 | by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject) | |
| 185 | hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp | |
| 186 | hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" | |
| 187 | by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject) | |
| 188 | hence "finite (convex_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp | |
| 189 | hence "finite ((\<lambda>xs. convex_map\<cdot>d\<cdot>xs) ` range convex_principal)" | |
| 190 | apply (rule finite_subset [COMP swap_prems_rl]) | |
| 191 | apply (clarsimp, rename_tac t) | |
| 192 | apply (induct_tac t rule: pd_basis_induct) | |
| 193 | apply (simp only: convex_unit_Rep_compact_basis [symmetric] convex_map_unit) | |
| 194 | apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b") | |
| 195 | apply clarsimp | |
| 196 | apply (rule imageI) | |
| 197 | apply (rule vimageI2) | |
| 198 | apply (simp add: Rep_PDUnit) | |
| 199 | apply (rule image_eqI) | |
| 200 | apply (erule sym) | |
| 201 | apply simp | |
| 202 | apply (rule exI) | |
| 203 | apply (rule Abs_compact_basis_inverse [symmetric]) | |
| 204 | apply (simp add: d.compact) | |
| 205 | apply (simp only: convex_plus_principal [symmetric] convex_map_plus) | |
| 206 | apply clarsimp | |
| 207 | apply (rule imageI) | |
| 208 | apply (rule vimageI2) | |
| 209 | apply (simp add: Rep_PDPlus) | |
| 210 | done | |
| 211 |   moreover have "{xs::'a convex_pd. compact xs} = range convex_principal"
 | |
| 212 | by (auto dest: convex_pd.compact_imp_principal) | |
| 213 |   ultimately have "finite ((\<lambda>xs. convex_map\<cdot>d\<cdot>xs) ` {xs::'a convex_pd. compact xs})"
 | |
| 214 | by simp | |
| 215 | hence "finite (range (\<lambda>xs. convex_map\<cdot>d\<cdot>xs))" | |
| 216 | by (rule finite_compact_range_imp_finite_range) | |
| 217 |   thus "finite {xs. convex_map\<cdot>d\<cdot>xs = xs}"
 | |
| 218 | by (rule finite_range_imp_finite_fixes) | |
| 219 | qed | |
| 220 | ||
| 221 | subsection {* Deflation combinators *}
 | |
| 222 | ||
| 223 | definition "upper_defl = TypeRep_fun1 upper_map" | |
| 224 | definition "lower_defl = TypeRep_fun1 lower_map" | |
| 225 | definition "convex_defl = TypeRep_fun1 convex_map" | |
| 226 | ||
| 227 | lemma cast_upper_defl: | |
| 228 | "cast\<cdot>(upper_defl\<cdot>A) = udom_emb oo upper_map\<cdot>(cast\<cdot>A) oo udom_prj" | |
| 229 | unfolding upper_defl_def | |
| 230 | apply (rule cast_TypeRep_fun1) | |
| 231 | apply (erule finite_deflation_upper_map) | |
| 232 | done | |
| 233 | ||
| 234 | lemma cast_lower_defl: | |
| 235 | "cast\<cdot>(lower_defl\<cdot>A) = udom_emb oo lower_map\<cdot>(cast\<cdot>A) oo udom_prj" | |
| 236 | unfolding lower_defl_def | |
| 237 | apply (rule cast_TypeRep_fun1) | |
| 238 | apply (erule finite_deflation_lower_map) | |
| 239 | done | |
| 240 | ||
| 241 | lemma cast_convex_defl: | |
| 242 | "cast\<cdot>(convex_defl\<cdot>A) = udom_emb oo convex_map\<cdot>(cast\<cdot>A) oo udom_prj" | |
| 243 | unfolding convex_defl_def | |
| 244 | apply (rule cast_TypeRep_fun1) | |
| 245 | apply (erule finite_deflation_convex_map) | |
| 246 | done | |
| 247 | ||
| 248 | lemma REP_upper: "REP('a upper_pd) = upper_defl\<cdot>REP('a)"
 | |
| 249 | apply (rule cast_eq_imp_eq, rule ext_cfun) | |
| 250 | apply (simp add: cast_REP cast_upper_defl) | |
| 251 | apply (simp add: prj_upper_pd_def) | |
| 252 | apply (simp add: emb_upper_pd_def) | |
| 253 | apply (simp add: upper_map_map cfcomp1) | |
| 254 | done | |
| 255 | ||
| 256 | lemma REP_lower: "REP('a lower_pd) = lower_defl\<cdot>REP('a)"
 | |
| 257 | apply (rule cast_eq_imp_eq, rule ext_cfun) | |
| 258 | apply (simp add: cast_REP cast_lower_defl) | |
| 259 | apply (simp add: prj_lower_pd_def) | |
| 260 | apply (simp add: emb_lower_pd_def) | |
| 261 | apply (simp add: lower_map_map cfcomp1) | |
| 262 | done | |
| 263 | ||
| 264 | lemma REP_convex: "REP('a convex_pd) = convex_defl\<cdot>REP('a)"
 | |
| 265 | apply (rule cast_eq_imp_eq, rule ext_cfun) | |
| 266 | apply (simp add: cast_REP cast_convex_defl) | |
| 267 | apply (simp add: prj_convex_pd_def) | |
| 268 | apply (simp add: emb_convex_pd_def) | |
| 269 | apply (simp add: convex_map_map cfcomp1) | |
| 270 | done | |
| 271 | ||
| 272 | lemma isodefl_upper: | |
| 273 | "isodefl d t \<Longrightarrow> isodefl (upper_map\<cdot>d) (upper_defl\<cdot>t)" | |
| 274 | apply (rule isodeflI) | |
| 275 | apply (simp add: cast_upper_defl cast_isodefl) | |
| 276 | apply (simp add: emb_upper_pd_def prj_upper_pd_def) | |
| 277 | apply (simp add: upper_map_map) | |
| 278 | done | |
| 279 | ||
| 280 | lemma isodefl_lower: | |
| 281 | "isodefl d t \<Longrightarrow> isodefl (lower_map\<cdot>d) (lower_defl\<cdot>t)" | |
| 282 | apply (rule isodeflI) | |
| 283 | apply (simp add: cast_lower_defl cast_isodefl) | |
| 284 | apply (simp add: emb_lower_pd_def prj_lower_pd_def) | |
| 285 | apply (simp add: lower_map_map) | |
| 286 | done | |
| 287 | ||
| 288 | lemma isodefl_convex: | |
| 289 | "isodefl d t \<Longrightarrow> isodefl (convex_map\<cdot>d) (convex_defl\<cdot>t)" | |
| 290 | apply (rule isodeflI) | |
| 291 | apply (simp add: cast_convex_defl cast_isodefl) | |
| 292 | apply (simp add: emb_convex_pd_def prj_convex_pd_def) | |
| 293 | apply (simp add: convex_map_map) | |
| 294 | done | |
| 295 | ||
| 296 | subsection {* Domain package setup for powerdomains *}
 | |
| 297 | ||
| 298 | setup {*
 | |
| 299 | fold Domain_Isomorphism.add_type_constructor | |
| 300 |     [(@{type_name "upper_pd"}, @{term upper_defl}, @{const_name upper_map},
 | |
| 35479 
dffffe36344a
store deflation thms for map functions in theory data
 huffman parents: 
35473diff
changeset | 301 |         @{thm REP_upper}, @{thm isodefl_upper}, @{thm upper_map_ID},
 | 
| 
dffffe36344a
store deflation thms for map functions in theory data
 huffman parents: 
35473diff
changeset | 302 |           @{thm deflation_upper_map}),
 | 
| 35473 | 303 | |
| 304 |      (@{type_name "lower_pd"}, @{term lower_defl}, @{const_name lower_map},
 | |
| 35479 
dffffe36344a
store deflation thms for map functions in theory data
 huffman parents: 
35473diff
changeset | 305 |         @{thm REP_lower}, @{thm isodefl_lower}, @{thm lower_map_ID},
 | 
| 
dffffe36344a
store deflation thms for map functions in theory data
 huffman parents: 
35473diff
changeset | 306 |           @{thm deflation_lower_map}),
 | 
| 35473 | 307 | |
| 308 |      (@{type_name "convex_pd"}, @{term convex_defl}, @{const_name convex_map},
 | |
| 35479 
dffffe36344a
store deflation thms for map functions in theory data
 huffman parents: 
35473diff
changeset | 309 |         @{thm REP_convex}, @{thm isodefl_convex}, @{thm convex_map_ID},
 | 
| 
dffffe36344a
store deflation thms for map functions in theory data
 huffman parents: 
35473diff
changeset | 310 |           @{thm deflation_convex_map})]
 | 
| 35473 | 311 | *} | 
| 312 | ||
| 313 | end |