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