src/HOL/HOLCF/LowerPD.thy
author wenzelm
Tue Sep 26 20:54:40 2017 +0200 (23 months ago)
changeset 66695 91500c024c7f
parent 62175 8ffc4d0e652d
child 67682 00c436488398
permissions -rw-r--r--
tuned;
     1 (*  Title:      HOL/HOLCF/LowerPD.thy
     2     Author:     Brian Huffman
     3 *)
     4 
     5 section \<open>Lower powerdomain\<close>
     6 
     7 theory LowerPD
     8 imports Compact_Basis
     9 begin
    10 
    11 subsection \<open>Basis preorder\<close>
    12 
    13 definition
    14   lower_le :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> bool" (infix "\<le>\<flat>" 50) where
    15   "lower_le = (\<lambda>u v. \<forall>x\<in>Rep_pd_basis u. \<exists>y\<in>Rep_pd_basis v. x \<sqsubseteq> y)"
    16 
    17 lemma lower_le_refl [simp]: "t \<le>\<flat> t"
    18 unfolding lower_le_def by fast
    19 
    20 lemma lower_le_trans: "\<lbrakk>t \<le>\<flat> u; u \<le>\<flat> v\<rbrakk> \<Longrightarrow> t \<le>\<flat> v"
    21 unfolding lower_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 lower_le: preorder lower_le
    30 by (rule preorder.intro, rule lower_le_refl, rule lower_le_trans)
    31 
    32 lemma lower_le_minimal [simp]: "PDUnit compact_bot \<le>\<flat> t"
    33 unfolding lower_le_def Rep_PDUnit
    34 by (simp, rule Rep_pd_basis_nonempty [folded ex_in_conv])
    35 
    36 lemma PDUnit_lower_mono: "x \<sqsubseteq> y \<Longrightarrow> PDUnit x \<le>\<flat> PDUnit y"
    37 unfolding lower_le_def Rep_PDUnit by fast
    38 
    39 lemma PDPlus_lower_mono: "\<lbrakk>s \<le>\<flat> t; u \<le>\<flat> v\<rbrakk> \<Longrightarrow> PDPlus s u \<le>\<flat> PDPlus t v"
    40 unfolding lower_le_def Rep_PDPlus by fast
    41 
    42 lemma PDPlus_lower_le: "t \<le>\<flat> PDPlus t u"
    43 unfolding lower_le_def Rep_PDPlus by fast
    44 
    45 lemma lower_le_PDUnit_PDUnit_iff [simp]:
    46   "(PDUnit a \<le>\<flat> PDUnit b) = (a \<sqsubseteq> b)"
    47 unfolding lower_le_def Rep_PDUnit by fast
    48 
    49 lemma lower_le_PDUnit_PDPlus_iff:
    50   "(PDUnit a \<le>\<flat> PDPlus t u) = (PDUnit a \<le>\<flat> t \<or> PDUnit a \<le>\<flat> u)"
    51 unfolding lower_le_def Rep_PDPlus Rep_PDUnit by fast
    52 
    53 lemma lower_le_PDPlus_iff: "(PDPlus t u \<le>\<flat> v) = (t \<le>\<flat> v \<and> u \<le>\<flat> v)"
    54 unfolding lower_le_def Rep_PDPlus by fast
    55 
    56 lemma lower_le_induct [induct set: lower_le]:
    57   assumes le: "t \<le>\<flat> u"
    58   assumes 1: "\<And>a b. a \<sqsubseteq> b \<Longrightarrow> P (PDUnit a) (PDUnit b)"
    59   assumes 2: "\<And>t u a. P (PDUnit a) t \<Longrightarrow> P (PDUnit a) (PDPlus t u)"
    60   assumes 3: "\<And>t u v. \<lbrakk>P t v; P u v\<rbrakk> \<Longrightarrow> P (PDPlus t u) v"
    61   shows "P t u"
    62 using le
    63 apply (induct t arbitrary: u rule: pd_basis_induct)
    64 apply (erule rev_mp)
    65 apply (induct_tac u rule: pd_basis_induct)
    66 apply (simp add: 1)
    67 apply (simp add: lower_le_PDUnit_PDPlus_iff)
    68 apply (simp add: 2)
    69 apply (subst PDPlus_commute)
    70 apply (simp add: 2)
    71 apply (simp add: lower_le_PDPlus_iff 3)
    72 done
    73 
    74 
    75 subsection \<open>Type definition\<close>
    76 
    77 typedef 'a lower_pd  ("('(_')\<flat>)") =
    78   "{S::'a pd_basis set. lower_le.ideal S}"
    79 by (rule lower_le.ex_ideal)
    80 
    81 instantiation lower_pd :: (bifinite) below
    82 begin
    83 
    84 definition
    85   "x \<sqsubseteq> y \<longleftrightarrow> Rep_lower_pd x \<subseteq> Rep_lower_pd y"
    86 
    87 instance ..
    88 end
    89 
    90 instance lower_pd :: (bifinite) po
    91 using type_definition_lower_pd below_lower_pd_def
    92 by (rule lower_le.typedef_ideal_po)
    93 
    94 instance lower_pd :: (bifinite) cpo
    95 using type_definition_lower_pd below_lower_pd_def
    96 by (rule lower_le.typedef_ideal_cpo)
    97 
    98 definition
    99   lower_principal :: "'a pd_basis \<Rightarrow> 'a lower_pd" where
   100   "lower_principal t = Abs_lower_pd {u. u \<le>\<flat> t}"
   101 
   102 interpretation lower_pd:
   103   ideal_completion lower_le lower_principal Rep_lower_pd
   104 using type_definition_lower_pd below_lower_pd_def
   105 using lower_principal_def pd_basis_countable
   106 by (rule lower_le.typedef_ideal_completion)
   107 
   108 text \<open>Lower powerdomain is pointed\<close>
   109 
   110 lemma lower_pd_minimal: "lower_principal (PDUnit compact_bot) \<sqsubseteq> ys"
   111 by (induct ys rule: lower_pd.principal_induct, simp, simp)
   112 
   113 instance lower_pd :: (bifinite) pcpo
   114 by intro_classes (fast intro: lower_pd_minimal)
   115 
   116 lemma inst_lower_pd_pcpo: "\<bottom> = lower_principal (PDUnit compact_bot)"
   117 by (rule lower_pd_minimal [THEN bottomI, symmetric])
   118 
   119 
   120 subsection \<open>Monadic unit and plus\<close>
   121 
   122 definition
   123   lower_unit :: "'a \<rightarrow> 'a lower_pd" where
   124   "lower_unit = compact_basis.extension (\<lambda>a. lower_principal (PDUnit a))"
   125 
   126 definition
   127   lower_plus :: "'a lower_pd \<rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd" where
   128   "lower_plus = lower_pd.extension (\<lambda>t. lower_pd.extension (\<lambda>u.
   129       lower_principal (PDPlus t u)))"
   130 
   131 abbreviation
   132   lower_add :: "'a lower_pd \<Rightarrow> 'a lower_pd \<Rightarrow> 'a lower_pd"
   133     (infixl "\<union>\<flat>" 65) where
   134   "xs \<union>\<flat> ys == lower_plus\<cdot>xs\<cdot>ys"
   135 
   136 syntax
   137   "_lower_pd" :: "args \<Rightarrow> logic" ("{_}\<flat>")
   138 
   139 translations
   140   "{x,xs}\<flat>" == "{x}\<flat> \<union>\<flat> {xs}\<flat>"
   141   "{x}\<flat>" == "CONST lower_unit\<cdot>x"
   142 
   143 lemma lower_unit_Rep_compact_basis [simp]:
   144   "{Rep_compact_basis a}\<flat> = lower_principal (PDUnit a)"
   145 unfolding lower_unit_def
   146 by (simp add: compact_basis.extension_principal PDUnit_lower_mono)
   147 
   148 lemma lower_plus_principal [simp]:
   149   "lower_principal t \<union>\<flat> lower_principal u = lower_principal (PDPlus t u)"
   150 unfolding lower_plus_def
   151 by (simp add: lower_pd.extension_principal
   152     lower_pd.extension_mono PDPlus_lower_mono)
   153 
   154 interpretation lower_add: semilattice lower_add proof
   155   fix xs ys zs :: "'a lower_pd"
   156   show "(xs \<union>\<flat> ys) \<union>\<flat> zs = xs \<union>\<flat> (ys \<union>\<flat> zs)"
   157     apply (induct xs rule: lower_pd.principal_induct, simp)
   158     apply (induct ys rule: lower_pd.principal_induct, simp)
   159     apply (induct zs rule: lower_pd.principal_induct, simp)
   160     apply (simp add: PDPlus_assoc)
   161     done
   162   show "xs \<union>\<flat> ys = ys \<union>\<flat> xs"
   163     apply (induct xs rule: lower_pd.principal_induct, simp)
   164     apply (induct ys rule: lower_pd.principal_induct, simp)
   165     apply (simp add: PDPlus_commute)
   166     done
   167   show "xs \<union>\<flat> xs = xs"
   168     apply (induct xs rule: lower_pd.principal_induct, simp)
   169     apply (simp add: PDPlus_absorb)
   170     done
   171 qed
   172 
   173 lemmas lower_plus_assoc = lower_add.assoc
   174 lemmas lower_plus_commute = lower_add.commute
   175 lemmas lower_plus_absorb = lower_add.idem
   176 lemmas lower_plus_left_commute = lower_add.left_commute
   177 lemmas lower_plus_left_absorb = lower_add.left_idem
   178 
   179 text \<open>Useful for \<open>simp add: lower_plus_ac\<close>\<close>
   180 lemmas lower_plus_ac =
   181   lower_plus_assoc lower_plus_commute lower_plus_left_commute
   182 
   183 text \<open>Useful for \<open>simp only: lower_plus_aci\<close>\<close>
   184 lemmas lower_plus_aci =
   185   lower_plus_ac lower_plus_absorb lower_plus_left_absorb
   186 
   187 lemma lower_plus_below1: "xs \<sqsubseteq> xs \<union>\<flat> ys"
   188 apply (induct xs rule: lower_pd.principal_induct, simp)
   189 apply (induct ys rule: lower_pd.principal_induct, simp)
   190 apply (simp add: PDPlus_lower_le)
   191 done
   192 
   193 lemma lower_plus_below2: "ys \<sqsubseteq> xs \<union>\<flat> ys"
   194 by (subst lower_plus_commute, rule lower_plus_below1)
   195 
   196 lemma lower_plus_least: "\<lbrakk>xs \<sqsubseteq> zs; ys \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs \<union>\<flat> ys \<sqsubseteq> zs"
   197 apply (subst lower_plus_absorb [of zs, symmetric])
   198 apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
   199 done
   200 
   201 lemma lower_plus_below_iff [simp]:
   202   "xs \<union>\<flat> ys \<sqsubseteq> zs \<longleftrightarrow> xs \<sqsubseteq> zs \<and> ys \<sqsubseteq> zs"
   203 apply safe
   204 apply (erule below_trans [OF lower_plus_below1])
   205 apply (erule below_trans [OF lower_plus_below2])
   206 apply (erule (1) lower_plus_least)
   207 done
   208 
   209 lemma lower_unit_below_plus_iff [simp]:
   210   "{x}\<flat> \<sqsubseteq> ys \<union>\<flat> zs \<longleftrightarrow> {x}\<flat> \<sqsubseteq> ys \<or> {x}\<flat> \<sqsubseteq> zs"
   211 apply (induct x rule: compact_basis.principal_induct, simp)
   212 apply (induct ys rule: lower_pd.principal_induct, simp)
   213 apply (induct zs rule: lower_pd.principal_induct, simp)
   214 apply (simp add: lower_le_PDUnit_PDPlus_iff)
   215 done
   216 
   217 lemma lower_unit_below_iff [simp]: "{x}\<flat> \<sqsubseteq> {y}\<flat> \<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 lower_pd_below_simps =
   224   lower_unit_below_iff
   225   lower_plus_below_iff
   226   lower_unit_below_plus_iff
   227 
   228 lemma lower_unit_eq_iff [simp]: "{x}\<flat> = {y}\<flat> \<longleftrightarrow> x = y"
   229 by (simp add: po_eq_conv)
   230 
   231 lemma lower_unit_strict [simp]: "{\<bottom>}\<flat> = \<bottom>"
   232 using lower_unit_Rep_compact_basis [of compact_bot]
   233 by (simp add: inst_lower_pd_pcpo)
   234 
   235 lemma lower_unit_bottom_iff [simp]: "{x}\<flat> = \<bottom> \<longleftrightarrow> x = \<bottom>"
   236 unfolding lower_unit_strict [symmetric] by (rule lower_unit_eq_iff)
   237 
   238 lemma lower_plus_bottom_iff [simp]:
   239   "xs \<union>\<flat> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<and> ys = \<bottom>"
   240 apply safe
   241 apply (rule bottomI, erule subst, rule lower_plus_below1)
   242 apply (rule bottomI, erule subst, rule lower_plus_below2)
   243 apply (rule lower_plus_absorb)
   244 done
   245 
   246 lemma lower_plus_strict1 [simp]: "\<bottom> \<union>\<flat> ys = ys"
   247 apply (rule below_antisym [OF _ lower_plus_below2])
   248 apply (simp add: lower_plus_least)
   249 done
   250 
   251 lemma lower_plus_strict2 [simp]: "xs \<union>\<flat> \<bottom> = xs"
   252 apply (rule below_antisym [OF _ lower_plus_below1])
   253 apply (simp add: lower_plus_least)
   254 done
   255 
   256 lemma compact_lower_unit: "compact x \<Longrightarrow> compact {x}\<flat>"
   257 by (auto dest!: compact_basis.compact_imp_principal)
   258 
   259 lemma compact_lower_unit_iff [simp]: "compact {x}\<flat> \<longleftrightarrow> compact x"
   260 apply (safe elim!: compact_lower_unit)
   261 apply (simp only: compact_def lower_unit_below_iff [symmetric])
   262 apply (erule adm_subst [OF cont_Rep_cfun2])
   263 done
   264 
   265 lemma compact_lower_plus [simp]:
   266   "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs \<union>\<flat> ys)"
   267 by (auto dest!: lower_pd.compact_imp_principal)
   268 
   269 
   270 subsection \<open>Induction rules\<close>
   271 
   272 lemma lower_pd_induct1:
   273   assumes P: "adm P"
   274   assumes unit: "\<And>x. P {x}\<flat>"
   275   assumes insert:
   276     "\<And>x ys. \<lbrakk>P {x}\<flat>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<flat> \<union>\<flat> ys)"
   277   shows "P (xs::'a lower_pd)"
   278 apply (induct xs rule: lower_pd.principal_induct, rule P)
   279 apply (induct_tac a rule: pd_basis_induct1)
   280 apply (simp only: lower_unit_Rep_compact_basis [symmetric])
   281 apply (rule unit)
   282 apply (simp only: lower_unit_Rep_compact_basis [symmetric]
   283                   lower_plus_principal [symmetric])
   284 apply (erule insert [OF unit])
   285 done
   286 
   287 lemma lower_pd_induct
   288   [case_names adm lower_unit lower_plus, induct type: lower_pd]:
   289   assumes P: "adm P"
   290   assumes unit: "\<And>x. P {x}\<flat>"
   291   assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs \<union>\<flat> ys)"
   292   shows "P (xs::'a lower_pd)"
   293 apply (induct xs rule: lower_pd.principal_induct, rule P)
   294 apply (induct_tac a rule: pd_basis_induct)
   295 apply (simp only: lower_unit_Rep_compact_basis [symmetric] unit)
   296 apply (simp only: lower_plus_principal [symmetric] plus)
   297 done
   298 
   299 
   300 subsection \<open>Monadic bind\<close>
   301 
   302 definition
   303   lower_bind_basis ::
   304   "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
   305   "lower_bind_basis = fold_pd
   306     (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
   307     (\<lambda>x y. \<Lambda> f. x\<cdot>f \<union>\<flat> y\<cdot>f)"
   308 
   309 lemma ACI_lower_bind:
   310   "semilattice (\<lambda>x y. \<Lambda> f. x\<cdot>f \<union>\<flat> y\<cdot>f)"
   311 apply unfold_locales
   312 apply (simp add: lower_plus_assoc)
   313 apply (simp add: lower_plus_commute)
   314 apply (simp add: eta_cfun)
   315 done
   316 
   317 lemma lower_bind_basis_simps [simp]:
   318   "lower_bind_basis (PDUnit a) =
   319     (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
   320   "lower_bind_basis (PDPlus t u) =
   321     (\<Lambda> f. lower_bind_basis t\<cdot>f \<union>\<flat> lower_bind_basis u\<cdot>f)"
   322 unfolding lower_bind_basis_def
   323 apply -
   324 apply (rule fold_pd_PDUnit [OF ACI_lower_bind])
   325 apply (rule fold_pd_PDPlus [OF ACI_lower_bind])
   326 done
   327 
   328 lemma lower_bind_basis_mono:
   329   "t \<le>\<flat> u \<Longrightarrow> lower_bind_basis t \<sqsubseteq> lower_bind_basis u"
   330 unfolding cfun_below_iff
   331 apply (erule lower_le_induct, safe)
   332 apply (simp add: monofun_cfun)
   333 apply (simp add: rev_below_trans [OF lower_plus_below1])
   334 apply simp
   335 done
   336 
   337 definition
   338   lower_bind :: "'a lower_pd \<rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
   339   "lower_bind = lower_pd.extension lower_bind_basis"
   340 
   341 syntax
   342   "_lower_bind" :: "[logic, logic, logic] \<Rightarrow> logic"
   343     ("(3\<Union>\<flat>_\<in>_./ _)" [0, 0, 10] 10)
   344 
   345 translations
   346   "\<Union>\<flat>x\<in>xs. e" == "CONST lower_bind\<cdot>xs\<cdot>(\<Lambda> x. e)"
   347 
   348 lemma lower_bind_principal [simp]:
   349   "lower_bind\<cdot>(lower_principal t) = lower_bind_basis t"
   350 unfolding lower_bind_def
   351 apply (rule lower_pd.extension_principal)
   352 apply (erule lower_bind_basis_mono)
   353 done
   354 
   355 lemma lower_bind_unit [simp]:
   356   "lower_bind\<cdot>{x}\<flat>\<cdot>f = f\<cdot>x"
   357 by (induct x rule: compact_basis.principal_induct, simp, simp)
   358 
   359 lemma lower_bind_plus [simp]:
   360   "lower_bind\<cdot>(xs \<union>\<flat> ys)\<cdot>f = lower_bind\<cdot>xs\<cdot>f \<union>\<flat> lower_bind\<cdot>ys\<cdot>f"
   361 by (induct xs rule: lower_pd.principal_induct, simp,
   362     induct ys rule: lower_pd.principal_induct, simp, simp)
   363 
   364 lemma lower_bind_strict [simp]: "lower_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
   365 unfolding lower_unit_strict [symmetric] by (rule lower_bind_unit)
   366 
   367 lemma lower_bind_bind:
   368   "lower_bind\<cdot>(lower_bind\<cdot>xs\<cdot>f)\<cdot>g = lower_bind\<cdot>xs\<cdot>(\<Lambda> x. lower_bind\<cdot>(f\<cdot>x)\<cdot>g)"
   369 by (induct xs, simp_all)
   370 
   371 
   372 subsection \<open>Map\<close>
   373 
   374 definition
   375   lower_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a lower_pd \<rightarrow> 'b lower_pd" where
   376   "lower_map = (\<Lambda> f xs. lower_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<flat>))"
   377 
   378 lemma lower_map_unit [simp]:
   379   "lower_map\<cdot>f\<cdot>{x}\<flat> = {f\<cdot>x}\<flat>"
   380 unfolding lower_map_def by simp
   381 
   382 lemma lower_map_plus [simp]:
   383   "lower_map\<cdot>f\<cdot>(xs \<union>\<flat> ys) = lower_map\<cdot>f\<cdot>xs \<union>\<flat> lower_map\<cdot>f\<cdot>ys"
   384 unfolding lower_map_def by simp
   385 
   386 lemma lower_map_bottom [simp]: "lower_map\<cdot>f\<cdot>\<bottom> = {f\<cdot>\<bottom>}\<flat>"
   387 unfolding lower_map_def by simp
   388 
   389 lemma lower_map_ident: "lower_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
   390 by (induct xs rule: lower_pd_induct, simp_all)
   391 
   392 lemma lower_map_ID: "lower_map\<cdot>ID = ID"
   393 by (simp add: cfun_eq_iff ID_def lower_map_ident)
   394 
   395 lemma lower_map_map:
   396   "lower_map\<cdot>f\<cdot>(lower_map\<cdot>g\<cdot>xs) = lower_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
   397 by (induct xs rule: lower_pd_induct, simp_all)
   398 
   399 lemma lower_bind_map:
   400   "lower_bind\<cdot>(lower_map\<cdot>f\<cdot>xs)\<cdot>g = lower_bind\<cdot>xs\<cdot>(\<Lambda> x. g\<cdot>(f\<cdot>x))"
   401 by (simp add: lower_map_def lower_bind_bind)
   402 
   403 lemma lower_map_bind:
   404   "lower_map\<cdot>f\<cdot>(lower_bind\<cdot>xs\<cdot>g) = lower_bind\<cdot>xs\<cdot>(\<Lambda> x. lower_map\<cdot>f\<cdot>(g\<cdot>x))"
   405 by (simp add: lower_map_def lower_bind_bind)
   406 
   407 lemma ep_pair_lower_map: "ep_pair e p \<Longrightarrow> ep_pair (lower_map\<cdot>e) (lower_map\<cdot>p)"
   408 apply standard
   409 apply (induct_tac x rule: lower_pd_induct, simp_all add: ep_pair.e_inverse)
   410 apply (induct_tac y rule: lower_pd_induct)
   411 apply (simp_all add: ep_pair.e_p_below monofun_cfun del: lower_plus_below_iff)
   412 done
   413 
   414 lemma deflation_lower_map: "deflation d \<Longrightarrow> deflation (lower_map\<cdot>d)"
   415 apply standard
   416 apply (induct_tac x rule: lower_pd_induct, simp_all add: deflation.idem)
   417 apply (induct_tac x rule: lower_pd_induct)
   418 apply (simp_all add: deflation.below monofun_cfun del: lower_plus_below_iff)
   419 done
   420 
   421 (* FIXME: long proof! *)
   422 lemma finite_deflation_lower_map:
   423   assumes "finite_deflation d" shows "finite_deflation (lower_map\<cdot>d)"
   424 proof (rule finite_deflation_intro)
   425   interpret d: finite_deflation d by fact
   426   have "deflation d" by fact
   427   thus "deflation (lower_map\<cdot>d)" by (rule deflation_lower_map)
   428   have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range)
   429   hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))"
   430     by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject)
   431   hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp
   432   hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))"
   433     by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject)
   434   hence *: "finite (lower_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp
   435   hence "finite (range (\<lambda>xs. lower_map\<cdot>d\<cdot>xs))"
   436     apply (rule rev_finite_subset)
   437     apply clarsimp
   438     apply (induct_tac xs rule: lower_pd.principal_induct)
   439     apply (simp add: adm_mem_finite *)
   440     apply (rename_tac t, induct_tac t rule: pd_basis_induct)
   441     apply (simp only: lower_unit_Rep_compact_basis [symmetric] lower_map_unit)
   442     apply simp
   443     apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b")
   444     apply clarsimp
   445     apply (rule imageI)
   446     apply (rule vimageI2)
   447     apply (simp add: Rep_PDUnit)
   448     apply (rule range_eqI)
   449     apply (erule sym)
   450     apply (rule exI)
   451     apply (rule Abs_compact_basis_inverse [symmetric])
   452     apply (simp add: d.compact)
   453     apply (simp only: lower_plus_principal [symmetric] lower_map_plus)
   454     apply clarsimp
   455     apply (rule imageI)
   456     apply (rule vimageI2)
   457     apply (simp add: Rep_PDPlus)
   458     done
   459   thus "finite {xs. lower_map\<cdot>d\<cdot>xs = xs}"
   460     by (rule finite_range_imp_finite_fixes)
   461 qed
   462 
   463 subsection \<open>Lower powerdomain is bifinite\<close>
   464 
   465 lemma approx_chain_lower_map:
   466   assumes "approx_chain a"
   467   shows "approx_chain (\<lambda>i. lower_map\<cdot>(a i))"
   468   using assms unfolding approx_chain_def
   469   by (simp add: lub_APP lower_map_ID finite_deflation_lower_map)
   470 
   471 instance lower_pd :: (bifinite) bifinite
   472 proof
   473   show "\<exists>(a::nat \<Rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd). approx_chain a"
   474     using bifinite [where 'a='a]
   475     by (fast intro!: approx_chain_lower_map)
   476 qed
   477 
   478 subsection \<open>Join\<close>
   479 
   480 definition
   481   lower_join :: "'a lower_pd lower_pd \<rightarrow> 'a lower_pd" where
   482   "lower_join = (\<Lambda> xss. lower_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
   483 
   484 lemma lower_join_unit [simp]:
   485   "lower_join\<cdot>{xs}\<flat> = xs"
   486 unfolding lower_join_def by simp
   487 
   488 lemma lower_join_plus [simp]:
   489   "lower_join\<cdot>(xss \<union>\<flat> yss) = lower_join\<cdot>xss \<union>\<flat> lower_join\<cdot>yss"
   490 unfolding lower_join_def by simp
   491 
   492 lemma lower_join_bottom [simp]: "lower_join\<cdot>\<bottom> = \<bottom>"
   493 unfolding lower_join_def by simp
   494 
   495 lemma lower_join_map_unit:
   496   "lower_join\<cdot>(lower_map\<cdot>lower_unit\<cdot>xs) = xs"
   497 by (induct xs rule: lower_pd_induct, simp_all)
   498 
   499 lemma lower_join_map_join:
   500   "lower_join\<cdot>(lower_map\<cdot>lower_join\<cdot>xsss) = lower_join\<cdot>(lower_join\<cdot>xsss)"
   501 by (induct xsss rule: lower_pd_induct, simp_all)
   502 
   503 lemma lower_join_map_map:
   504   "lower_join\<cdot>(lower_map\<cdot>(lower_map\<cdot>f)\<cdot>xss) =
   505    lower_map\<cdot>f\<cdot>(lower_join\<cdot>xss)"
   506 by (induct xss rule: lower_pd_induct, simp_all)
   507 
   508 end