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