src/HOL/HOLCF/LowerPD.thy
author huffman
Sun Dec 19 05:15:31 2010 -0800 (2010-12-19)
changeset 41286 3d7685a4a5ff
parent 41284 6d66975b711f
child 41287 029a6fc1bfb8
permissions -rw-r--r--
reintroduce 'bifinite' class, now with existentially-quantified approx function (cf. b525988432e9)
     1 (*  Title:      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 (open) '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 :: ("domain") 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 :: ("domain") po
    93 using type_definition_lower_pd below_lower_pd_def
    94 by (rule lower_le.typedef_ideal_po)
    95 
    96 instance lower_pd :: ("domain") 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 :: ("domain") 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 UU_I, 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.basis_fun (\<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.basis_fun (\<lambda>t. lower_pd.basis_fun (\<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 "+\<flat>" 65) where
   136   "xs +\<flat> ys == lower_plus\<cdot>xs\<cdot>ys"
   137 
   138 syntax
   139   "_lower_pd" :: "args \<Rightarrow> 'a lower_pd" ("{_}\<flat>")
   140 
   141 translations
   142   "{x,xs}\<flat>" == "{x}\<flat> +\<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.basis_fun_principal PDUnit_lower_mono)
   149 
   150 lemma lower_plus_principal [simp]:
   151   "lower_principal t +\<flat> lower_principal u = lower_principal (PDPlus t u)"
   152 unfolding lower_plus_def
   153 by (simp add: lower_pd.basis_fun_principal
   154     lower_pd.basis_fun_mono PDPlus_lower_mono)
   155 
   156 interpretation lower_add: semilattice lower_add proof
   157   fix xs ys zs :: "'a lower_pd"
   158   show "(xs +\<flat> ys) +\<flat> zs = xs +\<flat> (ys +\<flat> zs)"
   159     apply (induct xs ys arbitrary: zs rule: lower_pd.principal_induct2, simp, simp)
   160     apply (rule_tac x=zs in lower_pd.principal_induct, simp)
   161     apply (simp add: PDPlus_assoc)
   162     done
   163   show "xs +\<flat> ys = ys +\<flat> xs"
   164     apply (induct xs ys rule: lower_pd.principal_induct2, simp, simp)
   165     apply (simp add: PDPlus_commute)
   166     done
   167   show "xs +\<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 {* Useful for @{text "simp add: lower_plus_ac"} *}
   180 lemmas lower_plus_ac =
   181   lower_plus_assoc lower_plus_commute lower_plus_left_commute
   182 
   183 text {* Useful for @{text "simp only: lower_plus_aci"} *}
   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 +\<flat> ys"
   188 apply (induct xs ys rule: lower_pd.principal_induct2, simp, simp)
   189 apply (simp add: PDPlus_lower_le)
   190 done
   191 
   192 lemma lower_plus_below2: "ys \<sqsubseteq> xs +\<flat> ys"
   193 by (subst lower_plus_commute, rule lower_plus_below1)
   194 
   195 lemma lower_plus_least: "\<lbrakk>xs \<sqsubseteq> zs; ys \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs +\<flat> ys \<sqsubseteq> zs"
   196 apply (subst lower_plus_absorb [of zs, symmetric])
   197 apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
   198 done
   199 
   200 lemma lower_plus_below_iff [simp]:
   201   "xs +\<flat> ys \<sqsubseteq> zs \<longleftrightarrow> xs \<sqsubseteq> zs \<and> ys \<sqsubseteq> zs"
   202 apply safe
   203 apply (erule below_trans [OF lower_plus_below1])
   204 apply (erule below_trans [OF lower_plus_below2])
   205 apply (erule (1) lower_plus_least)
   206 done
   207 
   208 lemma lower_unit_below_plus_iff [simp]:
   209   "{x}\<flat> \<sqsubseteq> ys +\<flat> zs \<longleftrightarrow> {x}\<flat> \<sqsubseteq> ys \<or> {x}\<flat> \<sqsubseteq> zs"
   210 apply (induct x rule: compact_basis.principal_induct, simp)
   211 apply (induct ys rule: lower_pd.principal_induct, simp)
   212 apply (induct zs rule: lower_pd.principal_induct, simp)
   213 apply (simp add: lower_le_PDUnit_PDPlus_iff)
   214 done
   215 
   216 lemma lower_unit_below_iff [simp]: "{x}\<flat> \<sqsubseteq> {y}\<flat> \<longleftrightarrow> x \<sqsubseteq> y"
   217 apply (induct x rule: compact_basis.principal_induct, simp)
   218 apply (induct y rule: compact_basis.principal_induct, simp)
   219 apply simp
   220 done
   221 
   222 lemmas lower_pd_below_simps =
   223   lower_unit_below_iff
   224   lower_plus_below_iff
   225   lower_unit_below_plus_iff
   226 
   227 lemma lower_unit_eq_iff [simp]: "{x}\<flat> = {y}\<flat> \<longleftrightarrow> x = y"
   228 by (simp add: po_eq_conv)
   229 
   230 lemma lower_unit_strict [simp]: "{\<bottom>}\<flat> = \<bottom>"
   231 using lower_unit_Rep_compact_basis [of compact_bot]
   232 by (simp add: inst_lower_pd_pcpo)
   233 
   234 lemma lower_unit_bottom_iff [simp]: "{x}\<flat> = \<bottom> \<longleftrightarrow> x = \<bottom>"
   235 unfolding lower_unit_strict [symmetric] by (rule lower_unit_eq_iff)
   236 
   237 lemma lower_plus_bottom_iff [simp]:
   238   "xs +\<flat> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<and> ys = \<bottom>"
   239 apply safe
   240 apply (rule UU_I, erule subst, rule lower_plus_below1)
   241 apply (rule UU_I, erule subst, rule lower_plus_below2)
   242 apply (rule lower_plus_absorb)
   243 done
   244 
   245 lemma lower_plus_strict1 [simp]: "\<bottom> +\<flat> ys = ys"
   246 apply (rule below_antisym [OF _ lower_plus_below2])
   247 apply (simp add: lower_plus_least)
   248 done
   249 
   250 lemma lower_plus_strict2 [simp]: "xs +\<flat> \<bottom> = xs"
   251 apply (rule below_antisym [OF _ lower_plus_below1])
   252 apply (simp add: lower_plus_least)
   253 done
   254 
   255 lemma compact_lower_unit: "compact x \<Longrightarrow> compact {x}\<flat>"
   256 by (auto dest!: compact_basis.compact_imp_principal)
   257 
   258 lemma compact_lower_unit_iff [simp]: "compact {x}\<flat> \<longleftrightarrow> compact x"
   259 apply (safe elim!: compact_lower_unit)
   260 apply (simp only: compact_def lower_unit_below_iff [symmetric])
   261 apply (erule adm_subst [OF cont_Rep_cfun2])
   262 done
   263 
   264 lemma compact_lower_plus [simp]:
   265   "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs +\<flat> ys)"
   266 by (auto dest!: lower_pd.compact_imp_principal)
   267 
   268 
   269 subsection {* Induction rules *}
   270 
   271 lemma lower_pd_induct1:
   272   assumes P: "adm P"
   273   assumes unit: "\<And>x. P {x}\<flat>"
   274   assumes insert:
   275     "\<And>x ys. \<lbrakk>P {x}\<flat>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<flat> +\<flat> ys)"
   276   shows "P (xs::'a lower_pd)"
   277 apply (induct xs rule: lower_pd.principal_induct, rule P)
   278 apply (induct_tac a rule: pd_basis_induct1)
   279 apply (simp only: lower_unit_Rep_compact_basis [symmetric])
   280 apply (rule unit)
   281 apply (simp only: lower_unit_Rep_compact_basis [symmetric]
   282                   lower_plus_principal [symmetric])
   283 apply (erule insert [OF unit])
   284 done
   285 
   286 lemma lower_pd_induct
   287   [case_names adm lower_unit lower_plus, induct type: lower_pd]:
   288   assumes P: "adm P"
   289   assumes unit: "\<And>x. P {x}\<flat>"
   290   assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs +\<flat> ys)"
   291   shows "P (xs::'a lower_pd)"
   292 apply (induct xs rule: lower_pd.principal_induct, rule P)
   293 apply (induct_tac a rule: pd_basis_induct)
   294 apply (simp only: lower_unit_Rep_compact_basis [symmetric] unit)
   295 apply (simp only: lower_plus_principal [symmetric] plus)
   296 done
   297 
   298 
   299 subsection {* Monadic bind *}
   300 
   301 definition
   302   lower_bind_basis ::
   303   "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
   304   "lower_bind_basis = fold_pd
   305     (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
   306     (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<flat> y\<cdot>f)"
   307 
   308 lemma ACI_lower_bind:
   309   "class.ab_semigroup_idem_mult (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<flat> y\<cdot>f)"
   310 apply unfold_locales
   311 apply (simp add: lower_plus_assoc)
   312 apply (simp add: lower_plus_commute)
   313 apply (simp add: eta_cfun)
   314 done
   315 
   316 lemma lower_bind_basis_simps [simp]:
   317   "lower_bind_basis (PDUnit a) =
   318     (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
   319   "lower_bind_basis (PDPlus t u) =
   320     (\<Lambda> f. lower_bind_basis t\<cdot>f +\<flat> lower_bind_basis u\<cdot>f)"
   321 unfolding lower_bind_basis_def
   322 apply -
   323 apply (rule fold_pd_PDUnit [OF ACI_lower_bind])
   324 apply (rule fold_pd_PDPlus [OF ACI_lower_bind])
   325 done
   326 
   327 lemma lower_bind_basis_mono:
   328   "t \<le>\<flat> u \<Longrightarrow> lower_bind_basis t \<sqsubseteq> lower_bind_basis u"
   329 unfolding cfun_below_iff
   330 apply (erule lower_le_induct, safe)
   331 apply (simp add: monofun_cfun)
   332 apply (simp add: rev_below_trans [OF lower_plus_below1])
   333 apply simp
   334 done
   335 
   336 definition
   337   lower_bind :: "'a lower_pd \<rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
   338   "lower_bind = lower_pd.basis_fun lower_bind_basis"
   339 
   340 syntax
   341   "_lower_bind" :: "[logic, logic, logic] \<Rightarrow> logic"
   342     ("(3\<Union>\<flat>_\<in>_./ _)" [0, 0, 10] 10)
   343 
   344 translations
   345   "\<Union>\<flat>x\<in>xs. e" == "CONST lower_bind\<cdot>xs\<cdot>(\<Lambda> x. e)"
   346 
   347 lemma lower_bind_principal [simp]:
   348   "lower_bind\<cdot>(lower_principal t) = lower_bind_basis t"
   349 unfolding lower_bind_def
   350 apply (rule lower_pd.basis_fun_principal)
   351 apply (erule lower_bind_basis_mono)
   352 done
   353 
   354 lemma lower_bind_unit [simp]:
   355   "lower_bind\<cdot>{x}\<flat>\<cdot>f = f\<cdot>x"
   356 by (induct x rule: compact_basis.principal_induct, simp, simp)
   357 
   358 lemma lower_bind_plus [simp]:
   359   "lower_bind\<cdot>(xs +\<flat> ys)\<cdot>f = lower_bind\<cdot>xs\<cdot>f +\<flat> lower_bind\<cdot>ys\<cdot>f"
   360 by (induct xs ys rule: lower_pd.principal_induct2, simp, simp, simp)
   361 
   362 lemma lower_bind_strict [simp]: "lower_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
   363 unfolding lower_unit_strict [symmetric] by (rule lower_bind_unit)
   364 
   365 lemma lower_bind_bind:
   366   "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)"
   367 by (induct xs, simp_all)
   368 
   369 
   370 subsection {* Map *}
   371 
   372 definition
   373   lower_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a lower_pd \<rightarrow> 'b lower_pd" where
   374   "lower_map = (\<Lambda> f xs. lower_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<flat>))"
   375 
   376 lemma lower_map_unit [simp]:
   377   "lower_map\<cdot>f\<cdot>{x}\<flat> = {f\<cdot>x}\<flat>"
   378 unfolding lower_map_def by simp
   379 
   380 lemma lower_map_plus [simp]:
   381   "lower_map\<cdot>f\<cdot>(xs +\<flat> ys) = lower_map\<cdot>f\<cdot>xs +\<flat> lower_map\<cdot>f\<cdot>ys"
   382 unfolding lower_map_def by simp
   383 
   384 lemma lower_map_bottom [simp]: "lower_map\<cdot>f\<cdot>\<bottom> = {f\<cdot>\<bottom>}\<flat>"
   385 unfolding lower_map_def by simp
   386 
   387 lemma lower_map_ident: "lower_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
   388 by (induct xs rule: lower_pd_induct, simp_all)
   389 
   390 lemma lower_map_ID: "lower_map\<cdot>ID = ID"
   391 by (simp add: cfun_eq_iff ID_def lower_map_ident)
   392 
   393 lemma lower_map_map:
   394   "lower_map\<cdot>f\<cdot>(lower_map\<cdot>g\<cdot>xs) = lower_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
   395 by (induct xs rule: lower_pd_induct, simp_all)
   396 
   397 lemma lower_bind_map:
   398   "lower_bind\<cdot>(lower_map\<cdot>f\<cdot>xs)\<cdot>g = lower_bind\<cdot>xs\<cdot>(\<Lambda> x. g\<cdot>(f\<cdot>x))"
   399 by (simp add: lower_map_def lower_bind_bind)
   400 
   401 lemma lower_map_bind:
   402   "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))"
   403 by (simp add: lower_map_def lower_bind_bind)
   404 
   405 lemma ep_pair_lower_map: "ep_pair e p \<Longrightarrow> ep_pair (lower_map\<cdot>e) (lower_map\<cdot>p)"
   406 apply default
   407 apply (induct_tac x rule: lower_pd_induct, simp_all add: ep_pair.e_inverse)
   408 apply (induct_tac y rule: lower_pd_induct)
   409 apply (simp_all add: ep_pair.e_p_below monofun_cfun del: lower_plus_below_iff)
   410 done
   411 
   412 lemma deflation_lower_map: "deflation d \<Longrightarrow> deflation (lower_map\<cdot>d)"
   413 apply default
   414 apply (induct_tac x rule: lower_pd_induct, simp_all add: deflation.idem)
   415 apply (induct_tac x rule: lower_pd_induct)
   416 apply (simp_all add: deflation.below monofun_cfun del: lower_plus_below_iff)
   417 done
   418 
   419 (* FIXME: long proof! *)
   420 lemma finite_deflation_lower_map:
   421   assumes "finite_deflation d" shows "finite_deflation (lower_map\<cdot>d)"
   422 proof (rule finite_deflation_intro)
   423   interpret d: finite_deflation d by fact
   424   have "deflation d" by fact
   425   thus "deflation (lower_map\<cdot>d)" by (rule deflation_lower_map)
   426   have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range)
   427   hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))"
   428     by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject)
   429   hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp
   430   hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))"
   431     by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject)
   432   hence *: "finite (lower_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp
   433   hence "finite (range (\<lambda>xs. lower_map\<cdot>d\<cdot>xs))"
   434     apply (rule rev_finite_subset)
   435     apply clarsimp
   436     apply (induct_tac xs rule: lower_pd.principal_induct)
   437     apply (simp add: adm_mem_finite *)
   438     apply (rename_tac t, induct_tac t rule: pd_basis_induct)
   439     apply (simp only: lower_unit_Rep_compact_basis [symmetric] lower_map_unit)
   440     apply simp
   441     apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b")
   442     apply clarsimp
   443     apply (rule imageI)
   444     apply (rule vimageI2)
   445     apply (simp add: Rep_PDUnit)
   446     apply (rule range_eqI)
   447     apply (erule sym)
   448     apply (rule exI)
   449     apply (rule Abs_compact_basis_inverse [symmetric])
   450     apply (simp add: d.compact)
   451     apply (simp only: lower_plus_principal [symmetric] lower_map_plus)
   452     apply clarsimp
   453     apply (rule imageI)
   454     apply (rule vimageI2)
   455     apply (simp add: Rep_PDPlus)
   456     done
   457   thus "finite {xs. lower_map\<cdot>d\<cdot>xs = xs}"
   458     by (rule finite_range_imp_finite_fixes)
   459 qed
   460 
   461 subsection {* Lower powerdomain is a domain *}
   462 
   463 lemma approx_chain_lower_map:
   464   assumes "approx_chain a"
   465   shows "approx_chain (\<lambda>i. lower_map\<cdot>(a i))"
   466   using assms unfolding approx_chain_def
   467   by (simp add: lub_APP lower_map_ID finite_deflation_lower_map)
   468 
   469 instance lower_pd :: ("domain") bifinite
   470 proof
   471   show "\<exists>(a::nat \<Rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd). approx_chain a"
   472     using bifinite [where 'a='a]
   473     by (fast intro!: approx_chain_lower_map)
   474 qed
   475 
   476 definition
   477   lower_approx :: "nat \<Rightarrow> udom lower_pd \<rightarrow> udom lower_pd"
   478 where
   479   "lower_approx = (\<lambda>i. lower_map\<cdot>(udom_approx i))"
   480 
   481 lemma lower_approx: "approx_chain lower_approx"
   482 using lower_map_ID finite_deflation_lower_map
   483 unfolding lower_approx_def by (rule approx_chain_lemma1)
   484 
   485 definition lower_defl :: "defl \<rightarrow> defl"
   486 where "lower_defl = defl_fun1 lower_approx lower_map"
   487 
   488 lemma cast_lower_defl:
   489   "cast\<cdot>(lower_defl\<cdot>A) =
   490     udom_emb lower_approx oo lower_map\<cdot>(cast\<cdot>A) oo udom_prj lower_approx"
   491 using lower_approx finite_deflation_lower_map
   492 unfolding lower_defl_def by (rule cast_defl_fun1)
   493 
   494 instantiation lower_pd :: ("domain") liftdomain
   495 begin
   496 
   497 definition
   498   "emb = udom_emb lower_approx oo lower_map\<cdot>emb"
   499 
   500 definition
   501   "prj = lower_map\<cdot>prj oo udom_prj lower_approx"
   502 
   503 definition
   504   "defl (t::'a lower_pd itself) = lower_defl\<cdot>DEFL('a)"
   505 
   506 definition
   507   "(liftemb :: 'a lower_pd u \<rightarrow> udom) = udom_emb u_approx oo u_map\<cdot>emb"
   508 
   509 definition
   510   "(liftprj :: udom \<rightarrow> 'a lower_pd u) = u_map\<cdot>prj oo udom_prj u_approx"
   511 
   512 definition
   513   "liftdefl (t::'a lower_pd itself) = u_defl\<cdot>DEFL('a lower_pd)"
   514 
   515 instance
   516 using liftemb_lower_pd_def liftprj_lower_pd_def liftdefl_lower_pd_def
   517 proof (rule liftdomain_class_intro)
   518   show "ep_pair emb (prj :: udom \<rightarrow> 'a lower_pd)"
   519     unfolding emb_lower_pd_def prj_lower_pd_def
   520     using ep_pair_udom [OF lower_approx]
   521     by (intro ep_pair_comp ep_pair_lower_map ep_pair_emb_prj)
   522 next
   523   show "cast\<cdot>DEFL('a lower_pd) = emb oo (prj :: udom \<rightarrow> 'a lower_pd)"
   524     unfolding emb_lower_pd_def prj_lower_pd_def defl_lower_pd_def cast_lower_defl
   525     by (simp add: cast_DEFL oo_def cfun_eq_iff lower_map_map)
   526 qed
   527 
   528 end
   529 
   530 lemma DEFL_lower: "DEFL('a lower_pd) = lower_defl\<cdot>DEFL('a)"
   531 by (rule defl_lower_pd_def)
   532 
   533 
   534 subsection {* Join *}
   535 
   536 definition
   537   lower_join :: "'a lower_pd lower_pd \<rightarrow> 'a lower_pd" where
   538   "lower_join = (\<Lambda> xss. lower_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
   539 
   540 lemma lower_join_unit [simp]:
   541   "lower_join\<cdot>{xs}\<flat> = xs"
   542 unfolding lower_join_def by simp
   543 
   544 lemma lower_join_plus [simp]:
   545   "lower_join\<cdot>(xss +\<flat> yss) = lower_join\<cdot>xss +\<flat> lower_join\<cdot>yss"
   546 unfolding lower_join_def by simp
   547 
   548 lemma lower_join_bottom [simp]: "lower_join\<cdot>\<bottom> = \<bottom>"
   549 unfolding lower_join_def by simp
   550 
   551 lemma lower_join_map_unit:
   552   "lower_join\<cdot>(lower_map\<cdot>lower_unit\<cdot>xs) = xs"
   553 by (induct xs rule: lower_pd_induct, simp_all)
   554 
   555 lemma lower_join_map_join:
   556   "lower_join\<cdot>(lower_map\<cdot>lower_join\<cdot>xsss) = lower_join\<cdot>(lower_join\<cdot>xsss)"
   557 by (induct xsss rule: lower_pd_induct, simp_all)
   558 
   559 lemma lower_join_map_map:
   560   "lower_join\<cdot>(lower_map\<cdot>(lower_map\<cdot>f)\<cdot>xss) =
   561    lower_map\<cdot>f\<cdot>(lower_join\<cdot>xss)"
   562 by (induct xss rule: lower_pd_induct, simp_all)
   563 
   564 end