src/HOL/HOLCF/ConvexPD.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/ConvexPD.thy
     2     Author:     Brian Huffman
     3 *)
     4 
     5 header {* Convex powerdomain *}
     6 
     7 theory ConvexPD
     8 imports UpperPD LowerPD
     9 begin
    10 
    11 subsection {* Basis preorder *}
    12 
    13 definition
    14   convex_le :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> bool" (infix "\<le>\<natural>" 50) where
    15   "convex_le = (\<lambda>u v. u \<le>\<sharp> v \<and> u \<le>\<flat> v)"
    16 
    17 lemma convex_le_refl [simp]: "t \<le>\<natural> t"
    18 unfolding convex_le_def by (fast intro: upper_le_refl lower_le_refl)
    19 
    20 lemma convex_le_trans: "\<lbrakk>t \<le>\<natural> u; u \<le>\<natural> v\<rbrakk> \<Longrightarrow> t \<le>\<natural> v"
    21 unfolding convex_le_def by (fast intro: upper_le_trans lower_le_trans)
    22 
    23 interpretation convex_le: preorder convex_le
    24 by (rule preorder.intro, rule convex_le_refl, rule convex_le_trans)
    25 
    26 lemma upper_le_minimal [simp]: "PDUnit compact_bot \<le>\<natural> t"
    27 unfolding convex_le_def Rep_PDUnit by simp
    28 
    29 lemma PDUnit_convex_mono: "x \<sqsubseteq> y \<Longrightarrow> PDUnit x \<le>\<natural> PDUnit y"
    30 unfolding convex_le_def by (fast intro: PDUnit_upper_mono PDUnit_lower_mono)
    31 
    32 lemma PDPlus_convex_mono: "\<lbrakk>s \<le>\<natural> t; u \<le>\<natural> v\<rbrakk> \<Longrightarrow> PDPlus s u \<le>\<natural> PDPlus t v"
    33 unfolding convex_le_def by (fast intro: PDPlus_upper_mono PDPlus_lower_mono)
    34 
    35 lemma convex_le_PDUnit_PDUnit_iff [simp]:
    36   "(PDUnit a \<le>\<natural> PDUnit b) = (a \<sqsubseteq> b)"
    37 unfolding convex_le_def upper_le_def lower_le_def Rep_PDUnit by fast
    38 
    39 lemma convex_le_PDUnit_lemma1:
    40   "(PDUnit a \<le>\<natural> t) = (\<forall>b\<in>Rep_pd_basis t. a \<sqsubseteq> b)"
    41 unfolding convex_le_def upper_le_def lower_le_def Rep_PDUnit
    42 using Rep_pd_basis_nonempty [of t, folded ex_in_conv] by fast
    43 
    44 lemma convex_le_PDUnit_PDPlus_iff [simp]:
    45   "(PDUnit a \<le>\<natural> PDPlus t u) = (PDUnit a \<le>\<natural> t \<and> PDUnit a \<le>\<natural> u)"
    46 unfolding convex_le_PDUnit_lemma1 Rep_PDPlus by fast
    47 
    48 lemma convex_le_PDUnit_lemma2:
    49   "(t \<le>\<natural> PDUnit b) = (\<forall>a\<in>Rep_pd_basis t. a \<sqsubseteq> b)"
    50 unfolding convex_le_def upper_le_def lower_le_def Rep_PDUnit
    51 using Rep_pd_basis_nonempty [of t, folded ex_in_conv] by fast
    52 
    53 lemma convex_le_PDPlus_PDUnit_iff [simp]:
    54   "(PDPlus t u \<le>\<natural> PDUnit a) = (t \<le>\<natural> PDUnit a \<and> u \<le>\<natural> PDUnit a)"
    55 unfolding convex_le_PDUnit_lemma2 Rep_PDPlus by fast
    56 
    57 lemma convex_le_PDPlus_lemma:
    58   assumes z: "PDPlus t u \<le>\<natural> z"
    59   shows "\<exists>v w. z = PDPlus v w \<and> t \<le>\<natural> v \<and> u \<le>\<natural> w"
    60 proof (intro exI conjI)
    61   let ?A = "{b\<in>Rep_pd_basis z. \<exists>a\<in>Rep_pd_basis t. a \<sqsubseteq> b}"
    62   let ?B = "{b\<in>Rep_pd_basis z. \<exists>a\<in>Rep_pd_basis u. a \<sqsubseteq> b}"
    63   let ?v = "Abs_pd_basis ?A"
    64   let ?w = "Abs_pd_basis ?B"
    65   have Rep_v: "Rep_pd_basis ?v = ?A"
    66     apply (rule Abs_pd_basis_inverse)
    67     apply (rule Rep_pd_basis_nonempty [of t, folded ex_in_conv, THEN exE])
    68     apply (cut_tac z, simp only: convex_le_def lower_le_def, clarify)
    69     apply (drule_tac x=x in bspec, simp add: Rep_PDPlus, erule bexE)
    70     apply (simp add: pd_basis_def)
    71     apply fast
    72     done
    73   have Rep_w: "Rep_pd_basis ?w = ?B"
    74     apply (rule Abs_pd_basis_inverse)
    75     apply (rule Rep_pd_basis_nonempty [of u, folded ex_in_conv, THEN exE])
    76     apply (cut_tac z, simp only: convex_le_def lower_le_def, clarify)
    77     apply (drule_tac x=x in bspec, simp add: Rep_PDPlus, erule bexE)
    78     apply (simp add: pd_basis_def)
    79     apply fast
    80     done
    81   show "z = PDPlus ?v ?w"
    82     apply (insert z)
    83     apply (simp add: convex_le_def, erule conjE)
    84     apply (simp add: Rep_pd_basis_inject [symmetric] Rep_PDPlus)
    85     apply (simp add: Rep_v Rep_w)
    86     apply (rule equalityI)
    87      apply (rule subsetI)
    88      apply (simp only: upper_le_def)
    89      apply (drule (1) bspec, erule bexE)
    90      apply (simp add: Rep_PDPlus)
    91      apply fast
    92     apply fast
    93     done
    94   show "t \<le>\<natural> ?v" "u \<le>\<natural> ?w"
    95    apply (insert z)
    96    apply (simp_all add: convex_le_def upper_le_def lower_le_def Rep_PDPlus Rep_v Rep_w)
    97    apply fast+
    98    done
    99 qed
   100 
   101 lemma convex_le_induct [induct set: convex_le]:
   102   assumes le: "t \<le>\<natural> u"
   103   assumes 2: "\<And>t u v. \<lbrakk>P t u; P u v\<rbrakk> \<Longrightarrow> P t v"
   104   assumes 3: "\<And>a b. a \<sqsubseteq> b \<Longrightarrow> P (PDUnit a) (PDUnit b)"
   105   assumes 4: "\<And>t u v w. \<lbrakk>P t v; P u w\<rbrakk> \<Longrightarrow> P (PDPlus t u) (PDPlus v w)"
   106   shows "P t u"
   107 using le apply (induct t arbitrary: u rule: pd_basis_induct)
   108 apply (erule rev_mp)
   109 apply (induct_tac u rule: pd_basis_induct1)
   110 apply (simp add: 3)
   111 apply (simp, clarify, rename_tac a b t)
   112 apply (subgoal_tac "P (PDPlus (PDUnit a) (PDUnit a)) (PDPlus (PDUnit b) t)")
   113 apply (simp add: PDPlus_absorb)
   114 apply (erule (1) 4 [OF 3])
   115 apply (drule convex_le_PDPlus_lemma, clarify)
   116 apply (simp add: 4)
   117 done
   118 
   119 
   120 subsection {* Type definition *}
   121 
   122 typedef 'a convex_pd =
   123   "{S::'a pd_basis set. convex_le.ideal S}"
   124 by (rule convex_le.ex_ideal)
   125 
   126 type_notation (xsymbols) convex_pd ("('(_')\<natural>)")
   127 
   128 instantiation convex_pd :: (bifinite) below
   129 begin
   130 
   131 definition
   132   "x \<sqsubseteq> y \<longleftrightarrow> Rep_convex_pd x \<subseteq> Rep_convex_pd y"
   133 
   134 instance ..
   135 end
   136 
   137 instance convex_pd :: (bifinite) po
   138 using type_definition_convex_pd below_convex_pd_def
   139 by (rule convex_le.typedef_ideal_po)
   140 
   141 instance convex_pd :: (bifinite) cpo
   142 using type_definition_convex_pd below_convex_pd_def
   143 by (rule convex_le.typedef_ideal_cpo)
   144 
   145 definition
   146   convex_principal :: "'a pd_basis \<Rightarrow> 'a convex_pd" where
   147   "convex_principal t = Abs_convex_pd {u. u \<le>\<natural> t}"
   148 
   149 interpretation convex_pd:
   150   ideal_completion convex_le convex_principal Rep_convex_pd
   151 using type_definition_convex_pd below_convex_pd_def
   152 using convex_principal_def pd_basis_countable
   153 by (rule convex_le.typedef_ideal_completion)
   154 
   155 text {* Convex powerdomain is pointed *}
   156 
   157 lemma convex_pd_minimal: "convex_principal (PDUnit compact_bot) \<sqsubseteq> ys"
   158 by (induct ys rule: convex_pd.principal_induct, simp, simp)
   159 
   160 instance convex_pd :: (bifinite) pcpo
   161 by intro_classes (fast intro: convex_pd_minimal)
   162 
   163 lemma inst_convex_pd_pcpo: "\<bottom> = convex_principal (PDUnit compact_bot)"
   164 by (rule convex_pd_minimal [THEN bottomI, symmetric])
   165 
   166 
   167 subsection {* Monadic unit and plus *}
   168 
   169 definition
   170   convex_unit :: "'a \<rightarrow> 'a convex_pd" where
   171   "convex_unit = compact_basis.extension (\<lambda>a. convex_principal (PDUnit a))"
   172 
   173 definition
   174   convex_plus :: "'a convex_pd \<rightarrow> 'a convex_pd \<rightarrow> 'a convex_pd" where
   175   "convex_plus = convex_pd.extension (\<lambda>t. convex_pd.extension (\<lambda>u.
   176       convex_principal (PDPlus t u)))"
   177 
   178 abbreviation
   179   convex_add :: "'a convex_pd \<Rightarrow> 'a convex_pd \<Rightarrow> 'a convex_pd"
   180     (infixl "\<union>\<natural>" 65) where
   181   "xs \<union>\<natural> ys == convex_plus\<cdot>xs\<cdot>ys"
   182 
   183 syntax
   184   "_convex_pd" :: "args \<Rightarrow> logic" ("{_}\<natural>")
   185 
   186 translations
   187   "{x,xs}\<natural>" == "{x}\<natural> \<union>\<natural> {xs}\<natural>"
   188   "{x}\<natural>" == "CONST convex_unit\<cdot>x"
   189 
   190 lemma convex_unit_Rep_compact_basis [simp]:
   191   "{Rep_compact_basis a}\<natural> = convex_principal (PDUnit a)"
   192 unfolding convex_unit_def
   193 by (simp add: compact_basis.extension_principal PDUnit_convex_mono)
   194 
   195 lemma convex_plus_principal [simp]:
   196   "convex_principal t \<union>\<natural> convex_principal u = convex_principal (PDPlus t u)"
   197 unfolding convex_plus_def
   198 by (simp add: convex_pd.extension_principal
   199     convex_pd.extension_mono PDPlus_convex_mono)
   200 
   201 interpretation convex_add: semilattice convex_add proof
   202   fix xs ys zs :: "'a convex_pd"
   203   show "(xs \<union>\<natural> ys) \<union>\<natural> zs = xs \<union>\<natural> (ys \<union>\<natural> zs)"
   204     apply (induct xs rule: convex_pd.principal_induct, simp)
   205     apply (induct ys rule: convex_pd.principal_induct, simp)
   206     apply (induct zs rule: convex_pd.principal_induct, simp)
   207     apply (simp add: PDPlus_assoc)
   208     done
   209   show "xs \<union>\<natural> ys = ys \<union>\<natural> xs"
   210     apply (induct xs rule: convex_pd.principal_induct, simp)
   211     apply (induct ys rule: convex_pd.principal_induct, simp)
   212     apply (simp add: PDPlus_commute)
   213     done
   214   show "xs \<union>\<natural> xs = xs"
   215     apply (induct xs rule: convex_pd.principal_induct, simp)
   216     apply (simp add: PDPlus_absorb)
   217     done
   218 qed
   219 
   220 lemmas convex_plus_assoc = convex_add.assoc
   221 lemmas convex_plus_commute = convex_add.commute
   222 lemmas convex_plus_absorb = convex_add.idem
   223 lemmas convex_plus_left_commute = convex_add.left_commute
   224 lemmas convex_plus_left_absorb = convex_add.left_idem
   225 
   226 text {* Useful for @{text "simp add: convex_plus_ac"} *}
   227 lemmas convex_plus_ac =
   228   convex_plus_assoc convex_plus_commute convex_plus_left_commute
   229 
   230 text {* Useful for @{text "simp only: convex_plus_aci"} *}
   231 lemmas convex_plus_aci =
   232   convex_plus_ac convex_plus_absorb convex_plus_left_absorb
   233 
   234 lemma convex_unit_below_plus_iff [simp]:
   235   "{x}\<natural> \<sqsubseteq> ys \<union>\<natural> zs \<longleftrightarrow> {x}\<natural> \<sqsubseteq> ys \<and> {x}\<natural> \<sqsubseteq> zs"
   236 apply (induct x rule: compact_basis.principal_induct, simp)
   237 apply (induct ys rule: convex_pd.principal_induct, simp)
   238 apply (induct zs rule: convex_pd.principal_induct, simp)
   239 apply simp
   240 done
   241 
   242 lemma convex_plus_below_unit_iff [simp]:
   243   "xs \<union>\<natural> ys \<sqsubseteq> {z}\<natural> \<longleftrightarrow> xs \<sqsubseteq> {z}\<natural> \<and> ys \<sqsubseteq> {z}\<natural>"
   244 apply (induct xs rule: convex_pd.principal_induct, simp)
   245 apply (induct ys rule: convex_pd.principal_induct, simp)
   246 apply (induct z rule: compact_basis.principal_induct, simp)
   247 apply simp
   248 done
   249 
   250 lemma convex_unit_below_iff [simp]: "{x}\<natural> \<sqsubseteq> {y}\<natural> \<longleftrightarrow> x \<sqsubseteq> y"
   251 apply (induct x rule: compact_basis.principal_induct, simp)
   252 apply (induct y rule: compact_basis.principal_induct, simp)
   253 apply simp
   254 done
   255 
   256 lemma convex_unit_eq_iff [simp]: "{x}\<natural> = {y}\<natural> \<longleftrightarrow> x = y"
   257 unfolding po_eq_conv by simp
   258 
   259 lemma convex_unit_strict [simp]: "{\<bottom>}\<natural> = \<bottom>"
   260 using convex_unit_Rep_compact_basis [of compact_bot]
   261 by (simp add: inst_convex_pd_pcpo)
   262 
   263 lemma convex_unit_bottom_iff [simp]: "{x}\<natural> = \<bottom> \<longleftrightarrow> x = \<bottom>"
   264 unfolding convex_unit_strict [symmetric] by (rule convex_unit_eq_iff)
   265 
   266 lemma compact_convex_unit: "compact x \<Longrightarrow> compact {x}\<natural>"
   267 by (auto dest!: compact_basis.compact_imp_principal)
   268 
   269 lemma compact_convex_unit_iff [simp]: "compact {x}\<natural> \<longleftrightarrow> compact x"
   270 apply (safe elim!: compact_convex_unit)
   271 apply (simp only: compact_def convex_unit_below_iff [symmetric])
   272 apply (erule adm_subst [OF cont_Rep_cfun2])
   273 done
   274 
   275 lemma compact_convex_plus [simp]:
   276   "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs \<union>\<natural> ys)"
   277 by (auto dest!: convex_pd.compact_imp_principal)
   278 
   279 
   280 subsection {* Induction rules *}
   281 
   282 lemma convex_pd_induct1:
   283   assumes P: "adm P"
   284   assumes unit: "\<And>x. P {x}\<natural>"
   285   assumes insert: "\<And>x ys. \<lbrakk>P {x}\<natural>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<natural> \<union>\<natural> ys)"
   286   shows "P (xs::'a convex_pd)"
   287 apply (induct xs rule: convex_pd.principal_induct, rule P)
   288 apply (induct_tac a rule: pd_basis_induct1)
   289 apply (simp only: convex_unit_Rep_compact_basis [symmetric])
   290 apply (rule unit)
   291 apply (simp only: convex_unit_Rep_compact_basis [symmetric]
   292                   convex_plus_principal [symmetric])
   293 apply (erule insert [OF unit])
   294 done
   295 
   296 lemma convex_pd_induct
   297   [case_names adm convex_unit convex_plus, induct type: convex_pd]:
   298   assumes P: "adm P"
   299   assumes unit: "\<And>x. P {x}\<natural>"
   300   assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs \<union>\<natural> ys)"
   301   shows "P (xs::'a convex_pd)"
   302 apply (induct xs rule: convex_pd.principal_induct, rule P)
   303 apply (induct_tac a rule: pd_basis_induct)
   304 apply (simp only: convex_unit_Rep_compact_basis [symmetric] unit)
   305 apply (simp only: convex_plus_principal [symmetric] plus)
   306 done
   307 
   308 
   309 subsection {* Monadic bind *}
   310 
   311 definition
   312   convex_bind_basis ::
   313   "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b convex_pd) \<rightarrow> 'b convex_pd" where
   314   "convex_bind_basis = fold_pd
   315     (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
   316     (\<lambda>x y. \<Lambda> f. x\<cdot>f \<union>\<natural> y\<cdot>f)"
   317 
   318 lemma ACI_convex_bind:
   319   "semilattice (\<lambda>x y. \<Lambda> f. x\<cdot>f \<union>\<natural> y\<cdot>f)"
   320 apply unfold_locales
   321 apply (simp add: convex_plus_assoc)
   322 apply (simp add: convex_plus_commute)
   323 apply (simp add: eta_cfun)
   324 done
   325 
   326 lemma convex_bind_basis_simps [simp]:
   327   "convex_bind_basis (PDUnit a) =
   328     (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
   329   "convex_bind_basis (PDPlus t u) =
   330     (\<Lambda> f. convex_bind_basis t\<cdot>f \<union>\<natural> convex_bind_basis u\<cdot>f)"
   331 unfolding convex_bind_basis_def
   332 apply -
   333 apply (rule fold_pd_PDUnit [OF ACI_convex_bind])
   334 apply (rule fold_pd_PDPlus [OF ACI_convex_bind])
   335 done
   336 
   337 lemma convex_bind_basis_mono:
   338   "t \<le>\<natural> u \<Longrightarrow> convex_bind_basis t \<sqsubseteq> convex_bind_basis u"
   339 apply (erule convex_le_induct)
   340 apply (erule (1) below_trans)
   341 apply (simp add: monofun_LAM monofun_cfun)
   342 apply (simp add: monofun_LAM monofun_cfun)
   343 done
   344 
   345 definition
   346   convex_bind :: "'a convex_pd \<rightarrow> ('a \<rightarrow> 'b convex_pd) \<rightarrow> 'b convex_pd" where
   347   "convex_bind = convex_pd.extension convex_bind_basis"
   348 
   349 syntax
   350   "_convex_bind" :: "[logic, logic, logic] \<Rightarrow> logic"
   351     ("(3\<Union>\<natural>_\<in>_./ _)" [0, 0, 10] 10)
   352 
   353 translations
   354   "\<Union>\<natural>x\<in>xs. e" == "CONST convex_bind\<cdot>xs\<cdot>(\<Lambda> x. e)"
   355 
   356 lemma convex_bind_principal [simp]:
   357   "convex_bind\<cdot>(convex_principal t) = convex_bind_basis t"
   358 unfolding convex_bind_def
   359 apply (rule convex_pd.extension_principal)
   360 apply (erule convex_bind_basis_mono)
   361 done
   362 
   363 lemma convex_bind_unit [simp]:
   364   "convex_bind\<cdot>{x}\<natural>\<cdot>f = f\<cdot>x"
   365 by (induct x rule: compact_basis.principal_induct, simp, simp)
   366 
   367 lemma convex_bind_plus [simp]:
   368   "convex_bind\<cdot>(xs \<union>\<natural> ys)\<cdot>f = convex_bind\<cdot>xs\<cdot>f \<union>\<natural> convex_bind\<cdot>ys\<cdot>f"
   369 by (induct xs rule: convex_pd.principal_induct, simp,
   370     induct ys rule: convex_pd.principal_induct, simp, simp)
   371 
   372 lemma convex_bind_strict [simp]: "convex_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
   373 unfolding convex_unit_strict [symmetric] by (rule convex_bind_unit)
   374 
   375 lemma convex_bind_bind:
   376   "convex_bind\<cdot>(convex_bind\<cdot>xs\<cdot>f)\<cdot>g =
   377     convex_bind\<cdot>xs\<cdot>(\<Lambda> x. convex_bind\<cdot>(f\<cdot>x)\<cdot>g)"
   378 by (induct xs, simp_all)
   379 
   380 
   381 subsection {* Map *}
   382 
   383 definition
   384   convex_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a convex_pd \<rightarrow> 'b convex_pd" where
   385   "convex_map = (\<Lambda> f xs. convex_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<natural>))"
   386 
   387 lemma convex_map_unit [simp]:
   388   "convex_map\<cdot>f\<cdot>{x}\<natural> = {f\<cdot>x}\<natural>"
   389 unfolding convex_map_def by simp
   390 
   391 lemma convex_map_plus [simp]:
   392   "convex_map\<cdot>f\<cdot>(xs \<union>\<natural> ys) = convex_map\<cdot>f\<cdot>xs \<union>\<natural> convex_map\<cdot>f\<cdot>ys"
   393 unfolding convex_map_def by simp
   394 
   395 lemma convex_map_bottom [simp]: "convex_map\<cdot>f\<cdot>\<bottom> = {f\<cdot>\<bottom>}\<natural>"
   396 unfolding convex_map_def by simp
   397 
   398 lemma convex_map_ident: "convex_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
   399 by (induct xs rule: convex_pd_induct, simp_all)
   400 
   401 lemma convex_map_ID: "convex_map\<cdot>ID = ID"
   402 by (simp add: cfun_eq_iff ID_def convex_map_ident)
   403 
   404 lemma convex_map_map:
   405   "convex_map\<cdot>f\<cdot>(convex_map\<cdot>g\<cdot>xs) = convex_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
   406 by (induct xs rule: convex_pd_induct, simp_all)
   407 
   408 lemma convex_bind_map:
   409   "convex_bind\<cdot>(convex_map\<cdot>f\<cdot>xs)\<cdot>g = convex_bind\<cdot>xs\<cdot>(\<Lambda> x. g\<cdot>(f\<cdot>x))"
   410 by (simp add: convex_map_def convex_bind_bind)
   411 
   412 lemma convex_map_bind:
   413   "convex_map\<cdot>f\<cdot>(convex_bind\<cdot>xs\<cdot>g) = convex_bind\<cdot>xs\<cdot>(\<Lambda> x. convex_map\<cdot>f\<cdot>(g\<cdot>x))"
   414 by (simp add: convex_map_def convex_bind_bind)
   415 
   416 lemma ep_pair_convex_map: "ep_pair e p \<Longrightarrow> ep_pair (convex_map\<cdot>e) (convex_map\<cdot>p)"
   417 apply default
   418 apply (induct_tac x rule: convex_pd_induct, simp_all add: ep_pair.e_inverse)
   419 apply (induct_tac y rule: convex_pd_induct)
   420 apply (simp_all add: ep_pair.e_p_below monofun_cfun)
   421 done
   422 
   423 lemma deflation_convex_map: "deflation d \<Longrightarrow> deflation (convex_map\<cdot>d)"
   424 apply default
   425 apply (induct_tac x rule: convex_pd_induct, simp_all add: deflation.idem)
   426 apply (induct_tac x rule: convex_pd_induct)
   427 apply (simp_all add: deflation.below monofun_cfun)
   428 done
   429 
   430 (* FIXME: long proof! *)
   431 lemma finite_deflation_convex_map:
   432   assumes "finite_deflation d" shows "finite_deflation (convex_map\<cdot>d)"
   433 proof (rule finite_deflation_intro)
   434   interpret d: finite_deflation d by fact
   435   have "deflation d" by fact
   436   thus "deflation (convex_map\<cdot>d)" by (rule deflation_convex_map)
   437   have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range)
   438   hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))"
   439     by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject)
   440   hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp
   441   hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))"
   442     by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject)
   443   hence *: "finite (convex_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp
   444   hence "finite (range (\<lambda>xs. convex_map\<cdot>d\<cdot>xs))"
   445     apply (rule rev_finite_subset)
   446     apply clarsimp
   447     apply (induct_tac xs rule: convex_pd.principal_induct)
   448     apply (simp add: adm_mem_finite *)
   449     apply (rename_tac t, induct_tac t rule: pd_basis_induct)
   450     apply (simp only: convex_unit_Rep_compact_basis [symmetric] convex_map_unit)
   451     apply simp
   452     apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b")
   453     apply clarsimp
   454     apply (rule imageI)
   455     apply (rule vimageI2)
   456     apply (simp add: Rep_PDUnit)
   457     apply (rule range_eqI)
   458     apply (erule sym)
   459     apply (rule exI)
   460     apply (rule Abs_compact_basis_inverse [symmetric])
   461     apply (simp add: d.compact)
   462     apply (simp only: convex_plus_principal [symmetric] convex_map_plus)
   463     apply clarsimp
   464     apply (rule imageI)
   465     apply (rule vimageI2)
   466     apply (simp add: Rep_PDPlus)
   467     done
   468   thus "finite {xs. convex_map\<cdot>d\<cdot>xs = xs}"
   469     by (rule finite_range_imp_finite_fixes)
   470 qed
   471 
   472 subsection {* Convex powerdomain is bifinite *}
   473 
   474 lemma approx_chain_convex_map:
   475   assumes "approx_chain a"
   476   shows "approx_chain (\<lambda>i. convex_map\<cdot>(a i))"
   477   using assms unfolding approx_chain_def
   478   by (simp add: lub_APP convex_map_ID finite_deflation_convex_map)
   479 
   480 instance convex_pd :: (bifinite) bifinite
   481 proof
   482   show "\<exists>(a::nat \<Rightarrow> 'a convex_pd \<rightarrow> 'a convex_pd). approx_chain a"
   483     using bifinite [where 'a='a]
   484     by (fast intro!: approx_chain_convex_map)
   485 qed
   486 
   487 subsection {* Join *}
   488 
   489 definition
   490   convex_join :: "'a convex_pd convex_pd \<rightarrow> 'a convex_pd" where
   491   "convex_join = (\<Lambda> xss. convex_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
   492 
   493 lemma convex_join_unit [simp]:
   494   "convex_join\<cdot>{xs}\<natural> = xs"
   495 unfolding convex_join_def by simp
   496 
   497 lemma convex_join_plus [simp]:
   498   "convex_join\<cdot>(xss \<union>\<natural> yss) = convex_join\<cdot>xss \<union>\<natural> convex_join\<cdot>yss"
   499 unfolding convex_join_def by simp
   500 
   501 lemma convex_join_bottom [simp]: "convex_join\<cdot>\<bottom> = \<bottom>"
   502 unfolding convex_join_def by simp
   503 
   504 lemma convex_join_map_unit:
   505   "convex_join\<cdot>(convex_map\<cdot>convex_unit\<cdot>xs) = xs"
   506 by (induct xs rule: convex_pd_induct, simp_all)
   507 
   508 lemma convex_join_map_join:
   509   "convex_join\<cdot>(convex_map\<cdot>convex_join\<cdot>xsss) = convex_join\<cdot>(convex_join\<cdot>xsss)"
   510 by (induct xsss rule: convex_pd_induct, simp_all)
   511 
   512 lemma convex_join_map_map:
   513   "convex_join\<cdot>(convex_map\<cdot>(convex_map\<cdot>f)\<cdot>xss) =
   514    convex_map\<cdot>f\<cdot>(convex_join\<cdot>xss)"
   515 by (induct xss rule: convex_pd_induct, simp_all)
   516 
   517 
   518 subsection {* Conversions to other powerdomains *}
   519 
   520 text {* Convex to upper *}
   521 
   522 lemma convex_le_imp_upper_le: "t \<le>\<natural> u \<Longrightarrow> t \<le>\<sharp> u"
   523 unfolding convex_le_def by simp
   524 
   525 definition
   526   convex_to_upper :: "'a convex_pd \<rightarrow> 'a upper_pd" where
   527   "convex_to_upper = convex_pd.extension upper_principal"
   528 
   529 lemma convex_to_upper_principal [simp]:
   530   "convex_to_upper\<cdot>(convex_principal t) = upper_principal t"
   531 unfolding convex_to_upper_def
   532 apply (rule convex_pd.extension_principal)
   533 apply (rule upper_pd.principal_mono)
   534 apply (erule convex_le_imp_upper_le)
   535 done
   536 
   537 lemma convex_to_upper_unit [simp]:
   538   "convex_to_upper\<cdot>{x}\<natural> = {x}\<sharp>"
   539 by (induct x rule: compact_basis.principal_induct, simp, simp)
   540 
   541 lemma convex_to_upper_plus [simp]:
   542   "convex_to_upper\<cdot>(xs \<union>\<natural> ys) = convex_to_upper\<cdot>xs \<union>\<sharp> convex_to_upper\<cdot>ys"
   543 by (induct xs rule: convex_pd.principal_induct, simp,
   544     induct ys rule: convex_pd.principal_induct, simp, simp)
   545 
   546 lemma convex_to_upper_bind [simp]:
   547   "convex_to_upper\<cdot>(convex_bind\<cdot>xs\<cdot>f) =
   548     upper_bind\<cdot>(convex_to_upper\<cdot>xs)\<cdot>(convex_to_upper oo f)"
   549 by (induct xs rule: convex_pd_induct, simp, simp, simp)
   550 
   551 lemma convex_to_upper_map [simp]:
   552   "convex_to_upper\<cdot>(convex_map\<cdot>f\<cdot>xs) = upper_map\<cdot>f\<cdot>(convex_to_upper\<cdot>xs)"
   553 by (simp add: convex_map_def upper_map_def cfcomp_LAM)
   554 
   555 lemma convex_to_upper_join [simp]:
   556   "convex_to_upper\<cdot>(convex_join\<cdot>xss) =
   557     upper_bind\<cdot>(convex_to_upper\<cdot>xss)\<cdot>convex_to_upper"
   558 by (simp add: convex_join_def upper_join_def cfcomp_LAM eta_cfun)
   559 
   560 text {* Convex to lower *}
   561 
   562 lemma convex_le_imp_lower_le: "t \<le>\<natural> u \<Longrightarrow> t \<le>\<flat> u"
   563 unfolding convex_le_def by simp
   564 
   565 definition
   566   convex_to_lower :: "'a convex_pd \<rightarrow> 'a lower_pd" where
   567   "convex_to_lower = convex_pd.extension lower_principal"
   568 
   569 lemma convex_to_lower_principal [simp]:
   570   "convex_to_lower\<cdot>(convex_principal t) = lower_principal t"
   571 unfolding convex_to_lower_def
   572 apply (rule convex_pd.extension_principal)
   573 apply (rule lower_pd.principal_mono)
   574 apply (erule convex_le_imp_lower_le)
   575 done
   576 
   577 lemma convex_to_lower_unit [simp]:
   578   "convex_to_lower\<cdot>{x}\<natural> = {x}\<flat>"
   579 by (induct x rule: compact_basis.principal_induct, simp, simp)
   580 
   581 lemma convex_to_lower_plus [simp]:
   582   "convex_to_lower\<cdot>(xs \<union>\<natural> ys) = convex_to_lower\<cdot>xs \<union>\<flat> convex_to_lower\<cdot>ys"
   583 by (induct xs rule: convex_pd.principal_induct, simp,
   584     induct ys rule: convex_pd.principal_induct, simp, simp)
   585 
   586 lemma convex_to_lower_bind [simp]:
   587   "convex_to_lower\<cdot>(convex_bind\<cdot>xs\<cdot>f) =
   588     lower_bind\<cdot>(convex_to_lower\<cdot>xs)\<cdot>(convex_to_lower oo f)"
   589 by (induct xs rule: convex_pd_induct, simp, simp, simp)
   590 
   591 lemma convex_to_lower_map [simp]:
   592   "convex_to_lower\<cdot>(convex_map\<cdot>f\<cdot>xs) = lower_map\<cdot>f\<cdot>(convex_to_lower\<cdot>xs)"
   593 by (simp add: convex_map_def lower_map_def cfcomp_LAM)
   594 
   595 lemma convex_to_lower_join [simp]:
   596   "convex_to_lower\<cdot>(convex_join\<cdot>xss) =
   597     lower_bind\<cdot>(convex_to_lower\<cdot>xss)\<cdot>convex_to_lower"
   598 by (simp add: convex_join_def lower_join_def cfcomp_LAM eta_cfun)
   599 
   600 text {* Ordering property *}
   601 
   602 lemma convex_pd_below_iff:
   603   "(xs \<sqsubseteq> ys) =
   604     (convex_to_upper\<cdot>xs \<sqsubseteq> convex_to_upper\<cdot>ys \<and>
   605      convex_to_lower\<cdot>xs \<sqsubseteq> convex_to_lower\<cdot>ys)"
   606 apply (induct xs rule: convex_pd.principal_induct, simp)
   607 apply (induct ys rule: convex_pd.principal_induct, simp)
   608 apply (simp add: convex_le_def)
   609 done
   610 
   611 lemmas convex_plus_below_plus_iff =
   612   convex_pd_below_iff [where xs="xs \<union>\<natural> ys" and ys="zs \<union>\<natural> ws"]
   613   for xs ys zs ws
   614 
   615 lemmas convex_pd_below_simps =
   616   convex_unit_below_plus_iff
   617   convex_plus_below_unit_iff
   618   convex_plus_below_plus_iff
   619   convex_unit_below_iff
   620   convex_to_upper_unit
   621   convex_to_upper_plus
   622   convex_to_lower_unit
   623   convex_to_lower_plus
   624   upper_pd_below_simps
   625   lower_pd_below_simps
   626 
   627 end