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