src/HOLCF/ConvexPD.thy
author ballarin
Tue, 30 Dec 2008 11:10:01 +0100
changeset 29252 ea97aa6aeba2
parent 29244 95d591908d8d
parent 29138 661a8db7e647
child 29511 7071b017cb35
permissions -rw-r--r--
Merged.
     1 (*  Title:      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 lemma pd_take_convex_chain:
   120   "pd_take n t \<le>\<natural> pd_take (Suc n) t"
   121 apply (induct t rule: pd_basis_induct)
   122 apply (simp add: compact_basis.take_chain)
   123 apply (simp add: PDPlus_convex_mono)
   124 done
   125 
   126 lemma pd_take_convex_le: "pd_take i t \<le>\<natural> t"
   127 apply (induct t rule: pd_basis_induct)
   128 apply (simp add: compact_basis.take_less)
   129 apply (simp add: PDPlus_convex_mono)
   130 done
   131 
   132 lemma pd_take_convex_mono:
   133   "t \<le>\<natural> u \<Longrightarrow> pd_take n t \<le>\<natural> pd_take n u"
   134 apply (erule convex_le_induct)
   135 apply (erule (1) convex_le_trans)
   136 apply (simp add: compact_basis.take_mono)
   137 apply (simp add: PDPlus_convex_mono)
   138 done
   139 
   140 
   141 subsection {* Type definition *}
   142 
   143 typedef (open) 'a convex_pd =
   144   "{S::'a pd_basis set. convex_le.ideal S}"
   145 by (fast intro: convex_le.ideal_principal)
   146 
   147 instantiation convex_pd :: (profinite) sq_ord
   148 begin
   149 
   150 definition
   151   "x \<sqsubseteq> y \<longleftrightarrow> Rep_convex_pd x \<subseteq> Rep_convex_pd y"
   152 
   153 instance ..
   154 end
   155 
   156 instance convex_pd :: (profinite) po
   157 by (rule convex_le.typedef_ideal_po
   158     [OF type_definition_convex_pd sq_le_convex_pd_def])
   159 
   160 instance convex_pd :: (profinite) cpo
   161 by (rule convex_le.typedef_ideal_cpo
   162     [OF type_definition_convex_pd sq_le_convex_pd_def])
   163 
   164 lemma Rep_convex_pd_lub:
   165   "chain Y \<Longrightarrow> Rep_convex_pd (\<Squnion>i. Y i) = (\<Union>i. Rep_convex_pd (Y i))"
   166 by (rule convex_le.typedef_ideal_rep_contlub
   167     [OF type_definition_convex_pd sq_le_convex_pd_def])
   168 
   169 lemma ideal_Rep_convex_pd: "convex_le.ideal (Rep_convex_pd xs)"
   170 by (rule Rep_convex_pd [unfolded mem_Collect_eq])
   171 
   172 definition
   173   convex_principal :: "'a pd_basis \<Rightarrow> 'a convex_pd" where
   174   "convex_principal t = Abs_convex_pd {u. u \<le>\<natural> t}"
   175 
   176 lemma Rep_convex_principal:
   177   "Rep_convex_pd (convex_principal t) = {u. u \<le>\<natural> t}"
   178 unfolding convex_principal_def
   179 by (simp add: Abs_convex_pd_inverse convex_le.ideal_principal)
   180 
   181 interpretation convex_pd!:
   182   ideal_completion convex_le pd_take convex_principal Rep_convex_pd
   183 apply unfold_locales
   184 apply (rule pd_take_convex_le)
   185 apply (rule pd_take_idem)
   186 apply (erule pd_take_convex_mono)
   187 apply (rule pd_take_convex_chain)
   188 apply (rule finite_range_pd_take)
   189 apply (rule pd_take_covers)
   190 apply (rule ideal_Rep_convex_pd)
   191 apply (erule Rep_convex_pd_lub)
   192 apply (rule Rep_convex_principal)
   193 apply (simp only: sq_le_convex_pd_def)
   194 done
   195 
   196 text {* Convex powerdomain is pointed *}
   197 
   198 lemma convex_pd_minimal: "convex_principal (PDUnit compact_bot) \<sqsubseteq> ys"
   199 by (induct ys rule: convex_pd.principal_induct, simp, simp)
   200 
   201 instance convex_pd :: (bifinite) pcpo
   202 by intro_classes (fast intro: convex_pd_minimal)
   203 
   204 lemma inst_convex_pd_pcpo: "\<bottom> = convex_principal (PDUnit compact_bot)"
   205 by (rule convex_pd_minimal [THEN UU_I, symmetric])
   206 
   207 text {* Convex powerdomain is profinite *}
   208 
   209 instantiation convex_pd :: (profinite) profinite
   210 begin
   211 
   212 definition
   213   approx_convex_pd_def: "approx = convex_pd.completion_approx"
   214 
   215 instance
   216 apply (intro_classes, unfold approx_convex_pd_def)
   217 apply (rule convex_pd.chain_completion_approx)
   218 apply (rule convex_pd.lub_completion_approx)
   219 apply (rule convex_pd.completion_approx_idem)
   220 apply (rule convex_pd.finite_fixes_completion_approx)
   221 done
   222 
   223 end
   224 
   225 instance convex_pd :: (bifinite) bifinite ..
   226 
   227 lemma approx_convex_principal [simp]:
   228   "approx n\<cdot>(convex_principal t) = convex_principal (pd_take n t)"
   229 unfolding approx_convex_pd_def
   230 by (rule convex_pd.completion_approx_principal)
   231 
   232 lemma approx_eq_convex_principal:
   233   "\<exists>t\<in>Rep_convex_pd xs. approx n\<cdot>xs = convex_principal (pd_take n t)"
   234 unfolding approx_convex_pd_def
   235 by (rule convex_pd.completion_approx_eq_principal)
   236 
   237 
   238 subsection {* Monadic unit and plus *}
   239 
   240 definition
   241   convex_unit :: "'a \<rightarrow> 'a convex_pd" where
   242   "convex_unit = compact_basis.basis_fun (\<lambda>a. convex_principal (PDUnit a))"
   243 
   244 definition
   245   convex_plus :: "'a convex_pd \<rightarrow> 'a convex_pd \<rightarrow> 'a convex_pd" where
   246   "convex_plus = convex_pd.basis_fun (\<lambda>t. convex_pd.basis_fun (\<lambda>u.
   247       convex_principal (PDPlus t u)))"
   248 
   249 abbreviation
   250   convex_add :: "'a convex_pd \<Rightarrow> 'a convex_pd \<Rightarrow> 'a convex_pd"
   251     (infixl "+\<natural>" 65) where
   252   "xs +\<natural> ys == convex_plus\<cdot>xs\<cdot>ys"
   253 
   254 syntax
   255   "_convex_pd" :: "args \<Rightarrow> 'a convex_pd" ("{_}\<natural>")
   256 
   257 translations
   258   "{x,xs}\<natural>" == "{x}\<natural> +\<natural> {xs}\<natural>"
   259   "{x}\<natural>" == "CONST convex_unit\<cdot>x"
   260 
   261 lemma convex_unit_Rep_compact_basis [simp]:
   262   "{Rep_compact_basis a}\<natural> = convex_principal (PDUnit a)"
   263 unfolding convex_unit_def
   264 by (simp add: compact_basis.basis_fun_principal PDUnit_convex_mono)
   265 
   266 lemma convex_plus_principal [simp]:
   267   "convex_principal t +\<natural> convex_principal u = convex_principal (PDPlus t u)"
   268 unfolding convex_plus_def
   269 by (simp add: convex_pd.basis_fun_principal
   270     convex_pd.basis_fun_mono PDPlus_convex_mono)
   271 
   272 lemma approx_convex_unit [simp]:
   273   "approx n\<cdot>{x}\<natural> = {approx n\<cdot>x}\<natural>"
   274 apply (induct x rule: compact_basis.principal_induct, simp)
   275 apply (simp add: approx_Rep_compact_basis)
   276 done
   277 
   278 lemma approx_convex_plus [simp]:
   279   "approx n\<cdot>(xs +\<natural> ys) = approx n\<cdot>xs +\<natural> approx n\<cdot>ys"
   280 by (induct xs ys rule: convex_pd.principal_induct2, simp, simp, simp)
   281 
   282 lemma convex_plus_assoc:
   283   "(xs +\<natural> ys) +\<natural> zs = xs +\<natural> (ys +\<natural> zs)"
   284 apply (induct xs ys arbitrary: zs rule: convex_pd.principal_induct2, simp, simp)
   285 apply (rule_tac x=zs in convex_pd.principal_induct, simp)
   286 apply (simp add: PDPlus_assoc)
   287 done
   288 
   289 lemma convex_plus_commute: "xs +\<natural> ys = ys +\<natural> xs"
   290 apply (induct xs ys rule: convex_pd.principal_induct2, simp, simp)
   291 apply (simp add: PDPlus_commute)
   292 done
   293 
   294 lemma convex_plus_absorb: "xs +\<natural> xs = xs"
   295 apply (induct xs rule: convex_pd.principal_induct, simp)
   296 apply (simp add: PDPlus_absorb)
   297 done
   298 
   299 class_interpretation aci_convex_plus: ab_semigroup_idem_mult ["op +\<natural>"]
   300   by unfold_locales
   301     (rule convex_plus_assoc convex_plus_commute convex_plus_absorb)+
   302 
   303 lemma convex_plus_left_commute: "xs +\<natural> (ys +\<natural> zs) = ys +\<natural> (xs +\<natural> zs)"
   304 by (rule aci_convex_plus.mult_left_commute)
   305 
   306 lemma convex_plus_left_absorb: "xs +\<natural> (xs +\<natural> ys) = xs +\<natural> ys"
   307 by (rule aci_convex_plus.mult_left_idem)
   308 
   309 lemmas convex_plus_aci = aci_convex_plus.mult_ac_idem
   310 
   311 lemma convex_unit_less_plus_iff [simp]:
   312   "{x}\<natural> \<sqsubseteq> ys +\<natural> zs \<longleftrightarrow> {x}\<natural> \<sqsubseteq> ys \<and> {x}\<natural> \<sqsubseteq> zs"
   313  apply (rule iffI)
   314   apply (subgoal_tac
   315     "adm (\<lambda>f. f\<cdot>{x}\<natural> \<sqsubseteq> f\<cdot>ys \<and> f\<cdot>{x}\<natural> \<sqsubseteq> f\<cdot>zs)")
   316    apply (drule admD, rule chain_approx)
   317     apply (drule_tac f="approx i" in monofun_cfun_arg)
   318     apply (cut_tac x="approx i\<cdot>x" in compact_basis.compact_imp_principal, simp)
   319     apply (cut_tac x="approx i\<cdot>ys" in convex_pd.compact_imp_principal, simp)
   320     apply (cut_tac x="approx i\<cdot>zs" in convex_pd.compact_imp_principal, simp)
   321     apply (clarify, simp)
   322    apply simp
   323   apply simp
   324  apply (erule conjE)
   325  apply (subst convex_plus_absorb [of "{x}\<natural>", symmetric])
   326  apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
   327 done
   328 
   329 lemma convex_plus_less_unit_iff [simp]:
   330   "xs +\<natural> ys \<sqsubseteq> {z}\<natural> \<longleftrightarrow> xs \<sqsubseteq> {z}\<natural> \<and> ys \<sqsubseteq> {z}\<natural>"
   331  apply (rule iffI)
   332   apply (subgoal_tac
   333     "adm (\<lambda>f. f\<cdot>xs \<sqsubseteq> f\<cdot>{z}\<natural> \<and> f\<cdot>ys \<sqsubseteq> f\<cdot>{z}\<natural>)")
   334    apply (drule admD, rule chain_approx)
   335     apply (drule_tac f="approx i" in monofun_cfun_arg)
   336     apply (cut_tac x="approx i\<cdot>xs" in convex_pd.compact_imp_principal, simp)
   337     apply (cut_tac x="approx i\<cdot>ys" in convex_pd.compact_imp_principal, simp)
   338     apply (cut_tac x="approx i\<cdot>z" in compact_basis.compact_imp_principal, simp)
   339     apply (clarify, simp)
   340    apply simp
   341   apply simp
   342  apply (erule conjE)
   343  apply (subst convex_plus_absorb [of "{z}\<natural>", symmetric])
   344  apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
   345 done
   346 
   347 lemma convex_unit_less_iff [simp]: "{x}\<natural> \<sqsubseteq> {y}\<natural> \<longleftrightarrow> x \<sqsubseteq> y"
   348  apply (rule iffI)
   349   apply (rule profinite_less_ext)
   350   apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
   351   apply (cut_tac x="approx i\<cdot>x" in compact_basis.compact_imp_principal, simp)
   352   apply (cut_tac x="approx i\<cdot>y" in compact_basis.compact_imp_principal, simp)
   353   apply clarsimp
   354  apply (erule monofun_cfun_arg)
   355 done
   356 
   357 lemma convex_unit_eq_iff [simp]: "{x}\<natural> = {y}\<natural> \<longleftrightarrow> x = y"
   358 unfolding po_eq_conv by simp
   359 
   360 lemma convex_unit_strict [simp]: "{\<bottom>}\<natural> = \<bottom>"
   361 unfolding inst_convex_pd_pcpo Rep_compact_bot [symmetric] by simp
   362 
   363 lemma convex_unit_strict_iff [simp]: "{x}\<natural> = \<bottom> \<longleftrightarrow> x = \<bottom>"
   364 unfolding convex_unit_strict [symmetric] by (rule convex_unit_eq_iff)
   365 
   366 lemma compact_convex_unit_iff [simp]:
   367   "compact {x}\<natural> \<longleftrightarrow> compact x"
   368 unfolding profinite_compact_iff by simp
   369 
   370 lemma compact_convex_plus [simp]:
   371   "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs +\<natural> ys)"
   372 by (auto dest!: convex_pd.compact_imp_principal)
   373 
   374 
   375 subsection {* Induction rules *}
   376 
   377 lemma convex_pd_induct1:
   378   assumes P: "adm P"
   379   assumes unit: "\<And>x. P {x}\<natural>"
   380   assumes insert: "\<And>x ys. \<lbrakk>P {x}\<natural>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<natural> +\<natural> ys)"
   381   shows "P (xs::'a convex_pd)"
   382 apply (induct xs rule: convex_pd.principal_induct, rule P)
   383 apply (induct_tac a rule: pd_basis_induct1)
   384 apply (simp only: convex_unit_Rep_compact_basis [symmetric])
   385 apply (rule unit)
   386 apply (simp only: convex_unit_Rep_compact_basis [symmetric]
   387                   convex_plus_principal [symmetric])
   388 apply (erule insert [OF unit])
   389 done
   390 
   391 lemma convex_pd_induct:
   392   assumes P: "adm P"
   393   assumes unit: "\<And>x. P {x}\<natural>"
   394   assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs +\<natural> ys)"
   395   shows "P (xs::'a convex_pd)"
   396 apply (induct xs rule: convex_pd.principal_induct, rule P)
   397 apply (induct_tac a rule: pd_basis_induct)
   398 apply (simp only: convex_unit_Rep_compact_basis [symmetric] unit)
   399 apply (simp only: convex_plus_principal [symmetric] plus)
   400 done
   401 
   402 
   403 subsection {* Monadic bind *}
   404 
   405 definition
   406   convex_bind_basis ::
   407   "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b convex_pd) \<rightarrow> 'b convex_pd" where
   408   "convex_bind_basis = fold_pd
   409     (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
   410     (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<natural> y\<cdot>f)"
   411 
   412 lemma ACI_convex_bind:
   413   "ab_semigroup_idem_mult (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<natural> y\<cdot>f)"
   414 apply unfold_locales
   415 apply (simp add: convex_plus_assoc)
   416 apply (simp add: convex_plus_commute)
   417 apply (simp add: convex_plus_absorb eta_cfun)
   418 done
   419 
   420 lemma convex_bind_basis_simps [simp]:
   421   "convex_bind_basis (PDUnit a) =
   422     (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
   423   "convex_bind_basis (PDPlus t u) =
   424     (\<Lambda> f. convex_bind_basis t\<cdot>f +\<natural> convex_bind_basis u\<cdot>f)"
   425 unfolding convex_bind_basis_def
   426 apply -
   427 apply (rule fold_pd_PDUnit [OF ACI_convex_bind])
   428 apply (rule fold_pd_PDPlus [OF ACI_convex_bind])
   429 done
   430 
   431 lemma monofun_LAM:
   432   "\<lbrakk>cont f; cont g; \<And>x. f x \<sqsubseteq> g x\<rbrakk> \<Longrightarrow> (\<Lambda> x. f x) \<sqsubseteq> (\<Lambda> x. g x)"
   433 by (simp add: expand_cfun_less)
   434 
   435 lemma convex_bind_basis_mono:
   436   "t \<le>\<natural> u \<Longrightarrow> convex_bind_basis t \<sqsubseteq> convex_bind_basis u"
   437 apply (erule convex_le_induct)
   438 apply (erule (1) trans_less)
   439 apply (simp add: monofun_LAM monofun_cfun)
   440 apply (simp add: monofun_LAM monofun_cfun)
   441 done
   442 
   443 definition
   444   convex_bind :: "'a convex_pd \<rightarrow> ('a \<rightarrow> 'b convex_pd) \<rightarrow> 'b convex_pd" where
   445   "convex_bind = convex_pd.basis_fun convex_bind_basis"
   446 
   447 lemma convex_bind_principal [simp]:
   448   "convex_bind\<cdot>(convex_principal t) = convex_bind_basis t"
   449 unfolding convex_bind_def
   450 apply (rule convex_pd.basis_fun_principal)
   451 apply (erule convex_bind_basis_mono)
   452 done
   453 
   454 lemma convex_bind_unit [simp]:
   455   "convex_bind\<cdot>{x}\<natural>\<cdot>f = f\<cdot>x"
   456 by (induct x rule: compact_basis.principal_induct, simp, simp)
   457 
   458 lemma convex_bind_plus [simp]:
   459   "convex_bind\<cdot>(xs +\<natural> ys)\<cdot>f = convex_bind\<cdot>xs\<cdot>f +\<natural> convex_bind\<cdot>ys\<cdot>f"
   460 by (induct xs ys rule: convex_pd.principal_induct2, simp, simp, simp)
   461 
   462 lemma convex_bind_strict [simp]: "convex_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
   463 unfolding convex_unit_strict [symmetric] by (rule convex_bind_unit)
   464 
   465 
   466 subsection {* Map and join *}
   467 
   468 definition
   469   convex_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a convex_pd \<rightarrow> 'b convex_pd" where
   470   "convex_map = (\<Lambda> f xs. convex_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<natural>))"
   471 
   472 definition
   473   convex_join :: "'a convex_pd convex_pd \<rightarrow> 'a convex_pd" where
   474   "convex_join = (\<Lambda> xss. convex_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
   475 
   476 lemma convex_map_unit [simp]:
   477   "convex_map\<cdot>f\<cdot>(convex_unit\<cdot>x) = convex_unit\<cdot>(f\<cdot>x)"
   478 unfolding convex_map_def by simp
   479 
   480 lemma convex_map_plus [simp]:
   481   "convex_map\<cdot>f\<cdot>(xs +\<natural> ys) = convex_map\<cdot>f\<cdot>xs +\<natural> convex_map\<cdot>f\<cdot>ys"
   482 unfolding convex_map_def by simp
   483 
   484 lemma convex_join_unit [simp]:
   485   "convex_join\<cdot>{xs}\<natural> = xs"
   486 unfolding convex_join_def by simp
   487 
   488 lemma convex_join_plus [simp]:
   489   "convex_join\<cdot>(xss +\<natural> yss) = convex_join\<cdot>xss +\<natural> convex_join\<cdot>yss"
   490 unfolding convex_join_def by simp
   491 
   492 lemma convex_map_ident: "convex_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
   493 by (induct xs rule: convex_pd_induct, simp_all)
   494 
   495 lemma convex_map_map:
   496   "convex_map\<cdot>f\<cdot>(convex_map\<cdot>g\<cdot>xs) = convex_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
   497 by (induct xs rule: convex_pd_induct, simp_all)
   498 
   499 lemma convex_join_map_unit:
   500   "convex_join\<cdot>(convex_map\<cdot>convex_unit\<cdot>xs) = xs"
   501 by (induct xs rule: convex_pd_induct, simp_all)
   502 
   503 lemma convex_join_map_join:
   504   "convex_join\<cdot>(convex_map\<cdot>convex_join\<cdot>xsss) = convex_join\<cdot>(convex_join\<cdot>xsss)"
   505 by (induct xsss rule: convex_pd_induct, simp_all)
   506 
   507 lemma convex_join_map_map:
   508   "convex_join\<cdot>(convex_map\<cdot>(convex_map\<cdot>f)\<cdot>xss) =
   509    convex_map\<cdot>f\<cdot>(convex_join\<cdot>xss)"
   510 by (induct xss rule: convex_pd_induct, simp_all)
   511 
   512 lemma convex_map_approx: "convex_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
   513 by (induct xs rule: convex_pd_induct, simp_all)
   514 
   515 
   516 subsection {* Conversions to other powerdomains *}
   517 
   518 text {* Convex to upper *}
   519 
   520 lemma convex_le_imp_upper_le: "t \<le>\<natural> u \<Longrightarrow> t \<le>\<sharp> u"
   521 unfolding convex_le_def by simp
   522 
   523 definition
   524   convex_to_upper :: "'a convex_pd \<rightarrow> 'a upper_pd" where
   525   "convex_to_upper = convex_pd.basis_fun upper_principal"
   526 
   527 lemma convex_to_upper_principal [simp]:
   528   "convex_to_upper\<cdot>(convex_principal t) = upper_principal t"
   529 unfolding convex_to_upper_def
   530 apply (rule convex_pd.basis_fun_principal)
   531 apply (rule upper_pd.principal_mono)
   532 apply (erule convex_le_imp_upper_le)
   533 done
   534 
   535 lemma convex_to_upper_unit [simp]:
   536   "convex_to_upper\<cdot>{x}\<natural> = {x}\<sharp>"
   537 by (induct x rule: compact_basis.principal_induct, simp, simp)
   538 
   539 lemma convex_to_upper_plus [simp]:
   540   "convex_to_upper\<cdot>(xs +\<natural> ys) = convex_to_upper\<cdot>xs +\<sharp> convex_to_upper\<cdot>ys"
   541 by (induct xs ys rule: convex_pd.principal_induct2, simp, simp, simp)
   542 
   543 lemma approx_convex_to_upper:
   544   "approx i\<cdot>(convex_to_upper\<cdot>xs) = convex_to_upper\<cdot>(approx i\<cdot>xs)"
   545 by (induct xs rule: convex_pd_induct, simp, simp, simp)
   546 
   547 lemma convex_to_upper_bind [simp]:
   548   "convex_to_upper\<cdot>(convex_bind\<cdot>xs\<cdot>f) =
   549     upper_bind\<cdot>(convex_to_upper\<cdot>xs)\<cdot>(convex_to_upper oo f)"
   550 by (induct xs rule: convex_pd_induct, simp, simp, simp)
   551 
   552 lemma convex_to_upper_map [simp]:
   553   "convex_to_upper\<cdot>(convex_map\<cdot>f\<cdot>xs) = upper_map\<cdot>f\<cdot>(convex_to_upper\<cdot>xs)"
   554 by (simp add: convex_map_def upper_map_def cfcomp_LAM)
   555 
   556 lemma convex_to_upper_join [simp]:
   557   "convex_to_upper\<cdot>(convex_join\<cdot>xss) =
   558     upper_bind\<cdot>(convex_to_upper\<cdot>xss)\<cdot>convex_to_upper"
   559 by (simp add: convex_join_def upper_join_def cfcomp_LAM eta_cfun)
   560 
   561 text {* Convex to lower *}
   562 
   563 lemma convex_le_imp_lower_le: "t \<le>\<natural> u \<Longrightarrow> t \<le>\<flat> u"
   564 unfolding convex_le_def by simp
   565 
   566 definition
   567   convex_to_lower :: "'a convex_pd \<rightarrow> 'a lower_pd" where
   568   "convex_to_lower = convex_pd.basis_fun lower_principal"
   569 
   570 lemma convex_to_lower_principal [simp]:
   571   "convex_to_lower\<cdot>(convex_principal t) = lower_principal t"
   572 unfolding convex_to_lower_def
   573 apply (rule convex_pd.basis_fun_principal)
   574 apply (rule lower_pd.principal_mono)
   575 apply (erule convex_le_imp_lower_le)
   576 done
   577 
   578 lemma convex_to_lower_unit [simp]:
   579   "convex_to_lower\<cdot>{x}\<natural> = {x}\<flat>"
   580 by (induct x rule: compact_basis.principal_induct, simp, simp)
   581 
   582 lemma convex_to_lower_plus [simp]:
   583   "convex_to_lower\<cdot>(xs +\<natural> ys) = convex_to_lower\<cdot>xs +\<flat> convex_to_lower\<cdot>ys"
   584 by (induct xs ys rule: convex_pd.principal_induct2, simp, simp, simp)
   585 
   586 lemma approx_convex_to_lower:
   587   "approx i\<cdot>(convex_to_lower\<cdot>xs) = convex_to_lower\<cdot>(approx i\<cdot>xs)"
   588 by (induct xs rule: convex_pd_induct, simp, simp, simp)
   589 
   590 lemma convex_to_lower_bind [simp]:
   591   "convex_to_lower\<cdot>(convex_bind\<cdot>xs\<cdot>f) =
   592     lower_bind\<cdot>(convex_to_lower\<cdot>xs)\<cdot>(convex_to_lower oo f)"
   593 by (induct xs rule: convex_pd_induct, simp, simp, simp)
   594 
   595 lemma convex_to_lower_map [simp]:
   596   "convex_to_lower\<cdot>(convex_map\<cdot>f\<cdot>xs) = lower_map\<cdot>f\<cdot>(convex_to_lower\<cdot>xs)"
   597 by (simp add: convex_map_def lower_map_def cfcomp_LAM)
   598 
   599 lemma convex_to_lower_join [simp]:
   600   "convex_to_lower\<cdot>(convex_join\<cdot>xss) =
   601     lower_bind\<cdot>(convex_to_lower\<cdot>xss)\<cdot>convex_to_lower"
   602 by (simp add: convex_join_def lower_join_def cfcomp_LAM eta_cfun)
   603 
   604 text {* Ordering property *}
   605 
   606 lemma convex_pd_less_iff:
   607   "(xs \<sqsubseteq> ys) =
   608     (convex_to_upper\<cdot>xs \<sqsubseteq> convex_to_upper\<cdot>ys \<and>
   609      convex_to_lower\<cdot>xs \<sqsubseteq> convex_to_lower\<cdot>ys)"
   610  apply (safe elim!: monofun_cfun_arg)
   611  apply (rule profinite_less_ext)
   612  apply (drule_tac f="approx i" in monofun_cfun_arg)
   613  apply (drule_tac f="approx i" in monofun_cfun_arg)
   614  apply (cut_tac x="approx i\<cdot>xs" in convex_pd.compact_imp_principal, simp)
   615  apply (cut_tac x="approx i\<cdot>ys" in convex_pd.compact_imp_principal, simp)
   616  apply clarify
   617  apply (simp add: approx_convex_to_upper approx_convex_to_lower convex_le_def)
   618 done
   619 
   620 lemmas convex_plus_less_plus_iff =
   621   convex_pd_less_iff [where xs="xs +\<natural> ys" and ys="zs +\<natural> ws", standard]
   622 
   623 lemmas convex_pd_less_simps =
   624   convex_unit_less_plus_iff
   625   convex_plus_less_unit_iff
   626   convex_plus_less_plus_iff
   627   convex_unit_less_iff
   628   convex_to_upper_unit
   629   convex_to_upper_plus
   630   convex_to_lower_unit
   631   convex_to_lower_plus
   632   upper_pd_less_simps
   633   lower_pd_less_simps
   634 
   635 end