src/HOL/HOLCF/UpperPD.thy
author haftmann
Sun Jun 23 21:16:07 2013 +0200 (2013-06-23)
changeset 52435 6646bb548c6b
parent 51489 f738e6dbd844
child 58880 0baae4311a9f
permissions -rw-r--r--
migration from code_(const|type|class|instance) to code_printing and from code_module to code_identifier
     1 (*  Title:      HOL/HOLCF/UpperPD.thy
     2     Author:     Brian Huffman
     3 *)
     4 
     5 header {* Upper powerdomain *}
     6 
     7 theory UpperPD
     8 imports Compact_Basis
     9 begin
    10 
    11 subsection {* Basis preorder *}
    12 
    13 definition
    14   upper_le :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> bool" (infix "\<le>\<sharp>" 50) where
    15   "upper_le = (\<lambda>u v. \<forall>y\<in>Rep_pd_basis v. \<exists>x\<in>Rep_pd_basis u. x \<sqsubseteq> y)"
    16 
    17 lemma upper_le_refl [simp]: "t \<le>\<sharp> t"
    18 unfolding upper_le_def by fast
    19 
    20 lemma upper_le_trans: "\<lbrakk>t \<le>\<sharp> u; u \<le>\<sharp> v\<rbrakk> \<Longrightarrow> t \<le>\<sharp> v"
    21 unfolding upper_le_def
    22 apply (rule ballI)
    23 apply (drule (1) bspec, erule bexE)
    24 apply (drule (1) bspec, erule bexE)
    25 apply (erule rev_bexI)
    26 apply (erule (1) below_trans)
    27 done
    28 
    29 interpretation upper_le: preorder upper_le
    30 by (rule preorder.intro, rule upper_le_refl, rule upper_le_trans)
    31 
    32 lemma upper_le_minimal [simp]: "PDUnit compact_bot \<le>\<sharp> t"
    33 unfolding upper_le_def Rep_PDUnit by simp
    34 
    35 lemma PDUnit_upper_mono: "x \<sqsubseteq> y \<Longrightarrow> PDUnit x \<le>\<sharp> PDUnit y"
    36 unfolding upper_le_def Rep_PDUnit by simp
    37 
    38 lemma PDPlus_upper_mono: "\<lbrakk>s \<le>\<sharp> t; u \<le>\<sharp> v\<rbrakk> \<Longrightarrow> PDPlus s u \<le>\<sharp> PDPlus t v"
    39 unfolding upper_le_def Rep_PDPlus by fast
    40 
    41 lemma PDPlus_upper_le: "PDPlus t u \<le>\<sharp> t"
    42 unfolding upper_le_def Rep_PDPlus by fast
    43 
    44 lemma upper_le_PDUnit_PDUnit_iff [simp]:
    45   "(PDUnit a \<le>\<sharp> PDUnit b) = (a \<sqsubseteq> b)"
    46 unfolding upper_le_def Rep_PDUnit by fast
    47 
    48 lemma upper_le_PDPlus_PDUnit_iff:
    49   "(PDPlus t u \<le>\<sharp> PDUnit a) = (t \<le>\<sharp> PDUnit a \<or> u \<le>\<sharp> PDUnit a)"
    50 unfolding upper_le_def Rep_PDPlus Rep_PDUnit by fast
    51 
    52 lemma upper_le_PDPlus_iff: "(t \<le>\<sharp> PDPlus u v) = (t \<le>\<sharp> u \<and> t \<le>\<sharp> v)"
    53 unfolding upper_le_def Rep_PDPlus by fast
    54 
    55 lemma upper_le_induct [induct set: upper_le]:
    56   assumes le: "t \<le>\<sharp> u"
    57   assumes 1: "\<And>a b. a \<sqsubseteq> b \<Longrightarrow> P (PDUnit a) (PDUnit b)"
    58   assumes 2: "\<And>t u a. P t (PDUnit a) \<Longrightarrow> P (PDPlus t u) (PDUnit a)"
    59   assumes 3: "\<And>t u v. \<lbrakk>P t u; P t v\<rbrakk> \<Longrightarrow> P t (PDPlus u v)"
    60   shows "P t u"
    61 using le apply (induct u arbitrary: t rule: pd_basis_induct)
    62 apply (erule rev_mp)
    63 apply (induct_tac t rule: pd_basis_induct)
    64 apply (simp add: 1)
    65 apply (simp add: upper_le_PDPlus_PDUnit_iff)
    66 apply (simp add: 2)
    67 apply (subst PDPlus_commute)
    68 apply (simp add: 2)
    69 apply (simp add: upper_le_PDPlus_iff 3)
    70 done
    71 
    72 
    73 subsection {* Type definition *}
    74 
    75 typedef 'a upper_pd =
    76   "{S::'a pd_basis set. upper_le.ideal S}"
    77 by (rule upper_le.ex_ideal)
    78 
    79 type_notation (xsymbols) upper_pd ("('(_')\<sharp>)")
    80 
    81 instantiation upper_pd :: (bifinite) below
    82 begin
    83 
    84 definition
    85   "x \<sqsubseteq> y \<longleftrightarrow> Rep_upper_pd x \<subseteq> Rep_upper_pd y"
    86 
    87 instance ..
    88 end
    89 
    90 instance upper_pd :: (bifinite) po
    91 using type_definition_upper_pd below_upper_pd_def
    92 by (rule upper_le.typedef_ideal_po)
    93 
    94 instance upper_pd :: (bifinite) cpo
    95 using type_definition_upper_pd below_upper_pd_def
    96 by (rule upper_le.typedef_ideal_cpo)
    97 
    98 definition
    99   upper_principal :: "'a pd_basis \<Rightarrow> 'a upper_pd" where
   100   "upper_principal t = Abs_upper_pd {u. u \<le>\<sharp> t}"
   101 
   102 interpretation upper_pd:
   103   ideal_completion upper_le upper_principal Rep_upper_pd
   104 using type_definition_upper_pd below_upper_pd_def
   105 using upper_principal_def pd_basis_countable
   106 by (rule upper_le.typedef_ideal_completion)
   107 
   108 text {* Upper powerdomain is pointed *}
   109 
   110 lemma upper_pd_minimal: "upper_principal (PDUnit compact_bot) \<sqsubseteq> ys"
   111 by (induct ys rule: upper_pd.principal_induct, simp, simp)
   112 
   113 instance upper_pd :: (bifinite) pcpo
   114 by intro_classes (fast intro: upper_pd_minimal)
   115 
   116 lemma inst_upper_pd_pcpo: "\<bottom> = upper_principal (PDUnit compact_bot)"
   117 by (rule upper_pd_minimal [THEN bottomI, symmetric])
   118 
   119 
   120 subsection {* Monadic unit and plus *}
   121 
   122 definition
   123   upper_unit :: "'a \<rightarrow> 'a upper_pd" where
   124   "upper_unit = compact_basis.extension (\<lambda>a. upper_principal (PDUnit a))"
   125 
   126 definition
   127   upper_plus :: "'a upper_pd \<rightarrow> 'a upper_pd \<rightarrow> 'a upper_pd" where
   128   "upper_plus = upper_pd.extension (\<lambda>t. upper_pd.extension (\<lambda>u.
   129       upper_principal (PDPlus t u)))"
   130 
   131 abbreviation
   132   upper_add :: "'a upper_pd \<Rightarrow> 'a upper_pd \<Rightarrow> 'a upper_pd"
   133     (infixl "\<union>\<sharp>" 65) where
   134   "xs \<union>\<sharp> ys == upper_plus\<cdot>xs\<cdot>ys"
   135 
   136 syntax
   137   "_upper_pd" :: "args \<Rightarrow> logic" ("{_}\<sharp>")
   138 
   139 translations
   140   "{x,xs}\<sharp>" == "{x}\<sharp> \<union>\<sharp> {xs}\<sharp>"
   141   "{x}\<sharp>" == "CONST upper_unit\<cdot>x"
   142 
   143 lemma upper_unit_Rep_compact_basis [simp]:
   144   "{Rep_compact_basis a}\<sharp> = upper_principal (PDUnit a)"
   145 unfolding upper_unit_def
   146 by (simp add: compact_basis.extension_principal PDUnit_upper_mono)
   147 
   148 lemma upper_plus_principal [simp]:
   149   "upper_principal t \<union>\<sharp> upper_principal u = upper_principal (PDPlus t u)"
   150 unfolding upper_plus_def
   151 by (simp add: upper_pd.extension_principal
   152     upper_pd.extension_mono PDPlus_upper_mono)
   153 
   154 interpretation upper_add: semilattice upper_add proof
   155   fix xs ys zs :: "'a upper_pd"
   156   show "(xs \<union>\<sharp> ys) \<union>\<sharp> zs = xs \<union>\<sharp> (ys \<union>\<sharp> zs)"
   157     apply (induct xs rule: upper_pd.principal_induct, simp)
   158     apply (induct ys rule: upper_pd.principal_induct, simp)
   159     apply (induct zs rule: upper_pd.principal_induct, simp)
   160     apply (simp add: PDPlus_assoc)
   161     done
   162   show "xs \<union>\<sharp> ys = ys \<union>\<sharp> xs"
   163     apply (induct xs rule: upper_pd.principal_induct, simp)
   164     apply (induct ys rule: upper_pd.principal_induct, simp)
   165     apply (simp add: PDPlus_commute)
   166     done
   167   show "xs \<union>\<sharp> xs = xs"
   168     apply (induct xs rule: upper_pd.principal_induct, simp)
   169     apply (simp add: PDPlus_absorb)
   170     done
   171 qed
   172 
   173 lemmas upper_plus_assoc = upper_add.assoc
   174 lemmas upper_plus_commute = upper_add.commute
   175 lemmas upper_plus_absorb = upper_add.idem
   176 lemmas upper_plus_left_commute = upper_add.left_commute
   177 lemmas upper_plus_left_absorb = upper_add.left_idem
   178 
   179 text {* Useful for @{text "simp add: upper_plus_ac"} *}
   180 lemmas upper_plus_ac =
   181   upper_plus_assoc upper_plus_commute upper_plus_left_commute
   182 
   183 text {* Useful for @{text "simp only: upper_plus_aci"} *}
   184 lemmas upper_plus_aci =
   185   upper_plus_ac upper_plus_absorb upper_plus_left_absorb
   186 
   187 lemma upper_plus_below1: "xs \<union>\<sharp> ys \<sqsubseteq> xs"
   188 apply (induct xs rule: upper_pd.principal_induct, simp)
   189 apply (induct ys rule: upper_pd.principal_induct, simp)
   190 apply (simp add: PDPlus_upper_le)
   191 done
   192 
   193 lemma upper_plus_below2: "xs \<union>\<sharp> ys \<sqsubseteq> ys"
   194 by (subst upper_plus_commute, rule upper_plus_below1)
   195 
   196 lemma upper_plus_greatest: "\<lbrakk>xs \<sqsubseteq> ys; xs \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs \<sqsubseteq> ys \<union>\<sharp> zs"
   197 apply (subst upper_plus_absorb [of xs, symmetric])
   198 apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
   199 done
   200 
   201 lemma upper_below_plus_iff [simp]:
   202   "xs \<sqsubseteq> ys \<union>\<sharp> zs \<longleftrightarrow> xs \<sqsubseteq> ys \<and> xs \<sqsubseteq> zs"
   203 apply safe
   204 apply (erule below_trans [OF _ upper_plus_below1])
   205 apply (erule below_trans [OF _ upper_plus_below2])
   206 apply (erule (1) upper_plus_greatest)
   207 done
   208 
   209 lemma upper_plus_below_unit_iff [simp]:
   210   "xs \<union>\<sharp> ys \<sqsubseteq> {z}\<sharp> \<longleftrightarrow> xs \<sqsubseteq> {z}\<sharp> \<or> ys \<sqsubseteq> {z}\<sharp>"
   211 apply (induct xs rule: upper_pd.principal_induct, simp)
   212 apply (induct ys rule: upper_pd.principal_induct, simp)
   213 apply (induct z rule: compact_basis.principal_induct, simp)
   214 apply (simp add: upper_le_PDPlus_PDUnit_iff)
   215 done
   216 
   217 lemma upper_unit_below_iff [simp]: "{x}\<sharp> \<sqsubseteq> {y}\<sharp> \<longleftrightarrow> x \<sqsubseteq> y"
   218 apply (induct x rule: compact_basis.principal_induct, simp)
   219 apply (induct y rule: compact_basis.principal_induct, simp)
   220 apply simp
   221 done
   222 
   223 lemmas upper_pd_below_simps =
   224   upper_unit_below_iff
   225   upper_below_plus_iff
   226   upper_plus_below_unit_iff
   227 
   228 lemma upper_unit_eq_iff [simp]: "{x}\<sharp> = {y}\<sharp> \<longleftrightarrow> x = y"
   229 unfolding po_eq_conv by simp
   230 
   231 lemma upper_unit_strict [simp]: "{\<bottom>}\<sharp> = \<bottom>"
   232 using upper_unit_Rep_compact_basis [of compact_bot]
   233 by (simp add: inst_upper_pd_pcpo)
   234 
   235 lemma upper_plus_strict1 [simp]: "\<bottom> \<union>\<sharp> ys = \<bottom>"
   236 by (rule bottomI, rule upper_plus_below1)
   237 
   238 lemma upper_plus_strict2 [simp]: "xs \<union>\<sharp> \<bottom> = \<bottom>"
   239 by (rule bottomI, rule upper_plus_below2)
   240 
   241 lemma upper_unit_bottom_iff [simp]: "{x}\<sharp> = \<bottom> \<longleftrightarrow> x = \<bottom>"
   242 unfolding upper_unit_strict [symmetric] by (rule upper_unit_eq_iff)
   243 
   244 lemma upper_plus_bottom_iff [simp]:
   245   "xs \<union>\<sharp> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<or> ys = \<bottom>"
   246 apply (induct xs rule: upper_pd.principal_induct, simp)
   247 apply (induct ys rule: upper_pd.principal_induct, simp)
   248 apply (simp add: inst_upper_pd_pcpo upper_pd.principal_eq_iff
   249                  upper_le_PDPlus_PDUnit_iff)
   250 done
   251 
   252 lemma compact_upper_unit: "compact x \<Longrightarrow> compact {x}\<sharp>"
   253 by (auto dest!: compact_basis.compact_imp_principal)
   254 
   255 lemma compact_upper_unit_iff [simp]: "compact {x}\<sharp> \<longleftrightarrow> compact x"
   256 apply (safe elim!: compact_upper_unit)
   257 apply (simp only: compact_def upper_unit_below_iff [symmetric])
   258 apply (erule adm_subst [OF cont_Rep_cfun2])
   259 done
   260 
   261 lemma compact_upper_plus [simp]:
   262   "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs \<union>\<sharp> ys)"
   263 by (auto dest!: upper_pd.compact_imp_principal)
   264 
   265 
   266 subsection {* Induction rules *}
   267 
   268 lemma upper_pd_induct1:
   269   assumes P: "adm P"
   270   assumes unit: "\<And>x. P {x}\<sharp>"
   271   assumes insert: "\<And>x ys. \<lbrakk>P {x}\<sharp>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<sharp> \<union>\<sharp> ys)"
   272   shows "P (xs::'a upper_pd)"
   273 apply (induct xs rule: upper_pd.principal_induct, rule P)
   274 apply (induct_tac a rule: pd_basis_induct1)
   275 apply (simp only: upper_unit_Rep_compact_basis [symmetric])
   276 apply (rule unit)
   277 apply (simp only: upper_unit_Rep_compact_basis [symmetric]
   278                   upper_plus_principal [symmetric])
   279 apply (erule insert [OF unit])
   280 done
   281 
   282 lemma upper_pd_induct
   283   [case_names adm upper_unit upper_plus, induct type: upper_pd]:
   284   assumes P: "adm P"
   285   assumes unit: "\<And>x. P {x}\<sharp>"
   286   assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs \<union>\<sharp> ys)"
   287   shows "P (xs::'a upper_pd)"
   288 apply (induct xs rule: upper_pd.principal_induct, rule P)
   289 apply (induct_tac a rule: pd_basis_induct)
   290 apply (simp only: upper_unit_Rep_compact_basis [symmetric] unit)
   291 apply (simp only: upper_plus_principal [symmetric] plus)
   292 done
   293 
   294 
   295 subsection {* Monadic bind *}
   296 
   297 definition
   298   upper_bind_basis ::
   299   "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
   300   "upper_bind_basis = fold_pd
   301     (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
   302     (\<lambda>x y. \<Lambda> f. x\<cdot>f \<union>\<sharp> y\<cdot>f)"
   303 
   304 lemma ACI_upper_bind:
   305   "semilattice (\<lambda>x y. \<Lambda> f. x\<cdot>f \<union>\<sharp> y\<cdot>f)"
   306 apply unfold_locales
   307 apply (simp add: upper_plus_assoc)
   308 apply (simp add: upper_plus_commute)
   309 apply (simp add: eta_cfun)
   310 done
   311 
   312 lemma upper_bind_basis_simps [simp]:
   313   "upper_bind_basis (PDUnit a) =
   314     (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
   315   "upper_bind_basis (PDPlus t u) =
   316     (\<Lambda> f. upper_bind_basis t\<cdot>f \<union>\<sharp> upper_bind_basis u\<cdot>f)"
   317 unfolding upper_bind_basis_def
   318 apply -
   319 apply (rule fold_pd_PDUnit [OF ACI_upper_bind])
   320 apply (rule fold_pd_PDPlus [OF ACI_upper_bind])
   321 done
   322 
   323 lemma upper_bind_basis_mono:
   324   "t \<le>\<sharp> u \<Longrightarrow> upper_bind_basis t \<sqsubseteq> upper_bind_basis u"
   325 unfolding cfun_below_iff
   326 apply (erule upper_le_induct, safe)
   327 apply (simp add: monofun_cfun)
   328 apply (simp add: below_trans [OF upper_plus_below1])
   329 apply simp
   330 done
   331 
   332 definition
   333   upper_bind :: "'a upper_pd \<rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
   334   "upper_bind = upper_pd.extension upper_bind_basis"
   335 
   336 syntax
   337   "_upper_bind" :: "[logic, logic, logic] \<Rightarrow> logic"
   338     ("(3\<Union>\<sharp>_\<in>_./ _)" [0, 0, 10] 10)
   339 
   340 translations
   341   "\<Union>\<sharp>x\<in>xs. e" == "CONST upper_bind\<cdot>xs\<cdot>(\<Lambda> x. e)"
   342 
   343 lemma upper_bind_principal [simp]:
   344   "upper_bind\<cdot>(upper_principal t) = upper_bind_basis t"
   345 unfolding upper_bind_def
   346 apply (rule upper_pd.extension_principal)
   347 apply (erule upper_bind_basis_mono)
   348 done
   349 
   350 lemma upper_bind_unit [simp]:
   351   "upper_bind\<cdot>{x}\<sharp>\<cdot>f = f\<cdot>x"
   352 by (induct x rule: compact_basis.principal_induct, simp, simp)
   353 
   354 lemma upper_bind_plus [simp]:
   355   "upper_bind\<cdot>(xs \<union>\<sharp> ys)\<cdot>f = upper_bind\<cdot>xs\<cdot>f \<union>\<sharp> upper_bind\<cdot>ys\<cdot>f"
   356 by (induct xs rule: upper_pd.principal_induct, simp,
   357     induct ys rule: upper_pd.principal_induct, simp, simp)
   358 
   359 lemma upper_bind_strict [simp]: "upper_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
   360 unfolding upper_unit_strict [symmetric] by (rule upper_bind_unit)
   361 
   362 lemma upper_bind_bind:
   363   "upper_bind\<cdot>(upper_bind\<cdot>xs\<cdot>f)\<cdot>g = upper_bind\<cdot>xs\<cdot>(\<Lambda> x. upper_bind\<cdot>(f\<cdot>x)\<cdot>g)"
   364 by (induct xs, simp_all)
   365 
   366 
   367 subsection {* Map *}
   368 
   369 definition
   370   upper_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a upper_pd \<rightarrow> 'b upper_pd" where
   371   "upper_map = (\<Lambda> f xs. upper_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<sharp>))"
   372 
   373 lemma upper_map_unit [simp]:
   374   "upper_map\<cdot>f\<cdot>{x}\<sharp> = {f\<cdot>x}\<sharp>"
   375 unfolding upper_map_def by simp
   376 
   377 lemma upper_map_plus [simp]:
   378   "upper_map\<cdot>f\<cdot>(xs \<union>\<sharp> ys) = upper_map\<cdot>f\<cdot>xs \<union>\<sharp> upper_map\<cdot>f\<cdot>ys"
   379 unfolding upper_map_def by simp
   380 
   381 lemma upper_map_bottom [simp]: "upper_map\<cdot>f\<cdot>\<bottom> = {f\<cdot>\<bottom>}\<sharp>"
   382 unfolding upper_map_def by simp
   383 
   384 lemma upper_map_ident: "upper_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
   385 by (induct xs rule: upper_pd_induct, simp_all)
   386 
   387 lemma upper_map_ID: "upper_map\<cdot>ID = ID"
   388 by (simp add: cfun_eq_iff ID_def upper_map_ident)
   389 
   390 lemma upper_map_map:
   391   "upper_map\<cdot>f\<cdot>(upper_map\<cdot>g\<cdot>xs) = upper_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
   392 by (induct xs rule: upper_pd_induct, simp_all)
   393 
   394 lemma upper_bind_map:
   395   "upper_bind\<cdot>(upper_map\<cdot>f\<cdot>xs)\<cdot>g = upper_bind\<cdot>xs\<cdot>(\<Lambda> x. g\<cdot>(f\<cdot>x))"
   396 by (simp add: upper_map_def upper_bind_bind)
   397 
   398 lemma upper_map_bind:
   399   "upper_map\<cdot>f\<cdot>(upper_bind\<cdot>xs\<cdot>g) = upper_bind\<cdot>xs\<cdot>(\<Lambda> x. upper_map\<cdot>f\<cdot>(g\<cdot>x))"
   400 by (simp add: upper_map_def upper_bind_bind)
   401 
   402 lemma ep_pair_upper_map: "ep_pair e p \<Longrightarrow> ep_pair (upper_map\<cdot>e) (upper_map\<cdot>p)"
   403 apply default
   404 apply (induct_tac x rule: upper_pd_induct, simp_all add: ep_pair.e_inverse)
   405 apply (induct_tac y rule: upper_pd_induct)
   406 apply (simp_all add: ep_pair.e_p_below monofun_cfun del: upper_below_plus_iff)
   407 done
   408 
   409 lemma deflation_upper_map: "deflation d \<Longrightarrow> deflation (upper_map\<cdot>d)"
   410 apply default
   411 apply (induct_tac x rule: upper_pd_induct, simp_all add: deflation.idem)
   412 apply (induct_tac x rule: upper_pd_induct)
   413 apply (simp_all add: deflation.below monofun_cfun del: upper_below_plus_iff)
   414 done
   415 
   416 (* FIXME: long proof! *)
   417 lemma finite_deflation_upper_map:
   418   assumes "finite_deflation d" shows "finite_deflation (upper_map\<cdot>d)"
   419 proof (rule finite_deflation_intro)
   420   interpret d: finite_deflation d by fact
   421   have "deflation d" by fact
   422   thus "deflation (upper_map\<cdot>d)" by (rule deflation_upper_map)
   423   have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range)
   424   hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))"
   425     by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject)
   426   hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp
   427   hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))"
   428     by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject)
   429   hence *: "finite (upper_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp
   430   hence "finite (range (\<lambda>xs. upper_map\<cdot>d\<cdot>xs))"
   431     apply (rule rev_finite_subset)
   432     apply clarsimp
   433     apply (induct_tac xs rule: upper_pd.principal_induct)
   434     apply (simp add: adm_mem_finite *)
   435     apply (rename_tac t, induct_tac t rule: pd_basis_induct)
   436     apply (simp only: upper_unit_Rep_compact_basis [symmetric] upper_map_unit)
   437     apply simp
   438     apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b")
   439     apply clarsimp
   440     apply (rule imageI)
   441     apply (rule vimageI2)
   442     apply (simp add: Rep_PDUnit)
   443     apply (rule range_eqI)
   444     apply (erule sym)
   445     apply (rule exI)
   446     apply (rule Abs_compact_basis_inverse [symmetric])
   447     apply (simp add: d.compact)
   448     apply (simp only: upper_plus_principal [symmetric] upper_map_plus)
   449     apply clarsimp
   450     apply (rule imageI)
   451     apply (rule vimageI2)
   452     apply (simp add: Rep_PDPlus)
   453     done
   454   thus "finite {xs. upper_map\<cdot>d\<cdot>xs = xs}"
   455     by (rule finite_range_imp_finite_fixes)
   456 qed
   457 
   458 subsection {* Upper powerdomain is bifinite *}
   459 
   460 lemma approx_chain_upper_map:
   461   assumes "approx_chain a"
   462   shows "approx_chain (\<lambda>i. upper_map\<cdot>(a i))"
   463   using assms unfolding approx_chain_def
   464   by (simp add: lub_APP upper_map_ID finite_deflation_upper_map)
   465 
   466 instance upper_pd :: (bifinite) bifinite
   467 proof
   468   show "\<exists>(a::nat \<Rightarrow> 'a upper_pd \<rightarrow> 'a upper_pd). approx_chain a"
   469     using bifinite [where 'a='a]
   470     by (fast intro!: approx_chain_upper_map)
   471 qed
   472 
   473 subsection {* Join *}
   474 
   475 definition
   476   upper_join :: "'a upper_pd upper_pd \<rightarrow> 'a upper_pd" where
   477   "upper_join = (\<Lambda> xss. upper_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
   478 
   479 lemma upper_join_unit [simp]:
   480   "upper_join\<cdot>{xs}\<sharp> = xs"
   481 unfolding upper_join_def by simp
   482 
   483 lemma upper_join_plus [simp]:
   484   "upper_join\<cdot>(xss \<union>\<sharp> yss) = upper_join\<cdot>xss \<union>\<sharp> upper_join\<cdot>yss"
   485 unfolding upper_join_def by simp
   486 
   487 lemma upper_join_bottom [simp]: "upper_join\<cdot>\<bottom> = \<bottom>"
   488 unfolding upper_join_def by simp
   489 
   490 lemma upper_join_map_unit:
   491   "upper_join\<cdot>(upper_map\<cdot>upper_unit\<cdot>xs) = xs"
   492 by (induct xs rule: upper_pd_induct, simp_all)
   493 
   494 lemma upper_join_map_join:
   495   "upper_join\<cdot>(upper_map\<cdot>upper_join\<cdot>xsss) = upper_join\<cdot>(upper_join\<cdot>xsss)"
   496 by (induct xsss rule: upper_pd_induct, simp_all)
   497 
   498 lemma upper_join_map_map:
   499   "upper_join\<cdot>(upper_map\<cdot>(upper_map\<cdot>f)\<cdot>xss) =
   500    upper_map\<cdot>f\<cdot>(upper_join\<cdot>xss)"
   501 by (induct xss rule: upper_pd_induct, simp_all)
   502 
   503 end