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