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