src/HOLCF/UpperPD.thy
author huffman
Mon May 11 08:28:09 2009 -0700 (2009-05-11)
changeset 31095 b79d140f6d0b
parent 31076 99fe356cbbc2
child 33585 8d39394fe5cf
permissions -rw-r--r--
simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman@25904
     1
(*  Title:      HOLCF/UpperPD.thy
huffman@25904
     2
    Author:     Brian Huffman
huffman@25904
     3
*)
huffman@25904
     4
huffman@25904
     5
header {* Upper powerdomain *}
huffman@25904
     6
huffman@25904
     7
theory UpperPD
huffman@25904
     8
imports CompactBasis
huffman@25904
     9
begin
huffman@25904
    10
huffman@25904
    11
subsection {* Basis preorder *}
huffman@25904
    12
huffman@25904
    13
definition
huffman@25904
    14
  upper_le :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> bool" (infix "\<le>\<sharp>" 50) where
huffman@26420
    15
  "upper_le = (\<lambda>u v. \<forall>y\<in>Rep_pd_basis v. \<exists>x\<in>Rep_pd_basis u. x \<sqsubseteq> y)"
huffman@25904
    16
huffman@25904
    17
lemma upper_le_refl [simp]: "t \<le>\<sharp> t"
huffman@26420
    18
unfolding upper_le_def by fast
huffman@25904
    19
huffman@25904
    20
lemma upper_le_trans: "\<lbrakk>t \<le>\<sharp> u; u \<le>\<sharp> v\<rbrakk> \<Longrightarrow> t \<le>\<sharp> v"
huffman@25904
    21
unfolding upper_le_def
huffman@25904
    22
apply (rule ballI)
huffman@25904
    23
apply (drule (1) bspec, erule bexE)
huffman@25904
    24
apply (drule (1) bspec, erule bexE)
huffman@25904
    25
apply (erule rev_bexI)
huffman@31076
    26
apply (erule (1) below_trans)
huffman@25904
    27
done
huffman@25904
    28
wenzelm@30729
    29
interpretation upper_le: preorder upper_le
huffman@25904
    30
by (rule preorder.intro, rule upper_le_refl, rule upper_le_trans)
huffman@25904
    31
huffman@25904
    32
lemma upper_le_minimal [simp]: "PDUnit compact_bot \<le>\<sharp> t"
huffman@25904
    33
unfolding upper_le_def Rep_PDUnit by simp
huffman@25904
    34
huffman@26420
    35
lemma PDUnit_upper_mono: "x \<sqsubseteq> y \<Longrightarrow> PDUnit x \<le>\<sharp> PDUnit y"
huffman@25904
    36
unfolding upper_le_def Rep_PDUnit by simp
huffman@25904
    37
huffman@25904
    38
lemma PDPlus_upper_mono: "\<lbrakk>s \<le>\<sharp> t; u \<le>\<sharp> v\<rbrakk> \<Longrightarrow> PDPlus s u \<le>\<sharp> PDPlus t v"
huffman@25904
    39
unfolding upper_le_def Rep_PDPlus by fast
huffman@25904
    40
huffman@31076
    41
lemma PDPlus_upper_le: "PDPlus t u \<le>\<sharp> t"
huffman@26420
    42
unfolding upper_le_def Rep_PDPlus by fast
huffman@25904
    43
huffman@25904
    44
lemma upper_le_PDUnit_PDUnit_iff [simp]:
huffman@26420
    45
  "(PDUnit a \<le>\<sharp> PDUnit b) = a \<sqsubseteq> b"
huffman@25904
    46
unfolding upper_le_def Rep_PDUnit by fast
huffman@25904
    47
huffman@25904
    48
lemma upper_le_PDPlus_PDUnit_iff:
huffman@25904
    49
  "(PDPlus t u \<le>\<sharp> PDUnit a) = (t \<le>\<sharp> PDUnit a \<or> u \<le>\<sharp> PDUnit a)"
huffman@25904
    50
unfolding upper_le_def Rep_PDPlus Rep_PDUnit by fast
huffman@25904
    51
huffman@25904
    52
lemma upper_le_PDPlus_iff: "(t \<le>\<sharp> PDPlus u v) = (t \<le>\<sharp> u \<and> t \<le>\<sharp> v)"
huffman@25904
    53
unfolding upper_le_def Rep_PDPlus by fast
huffman@25904
    54
huffman@25904
    55
lemma upper_le_induct [induct set: upper_le]:
huffman@25904
    56
  assumes le: "t \<le>\<sharp> u"
huffman@26420
    57
  assumes 1: "\<And>a b. a \<sqsubseteq> b \<Longrightarrow> P (PDUnit a) (PDUnit b)"
huffman@25904
    58
  assumes 2: "\<And>t u a. P t (PDUnit a) \<Longrightarrow> P (PDPlus t u) (PDUnit a)"
huffman@25904
    59
  assumes 3: "\<And>t u v. \<lbrakk>P t u; P t v\<rbrakk> \<Longrightarrow> P t (PDPlus u v)"
huffman@25904
    60
  shows "P t u"
huffman@25904
    61
using le apply (induct u arbitrary: t rule: pd_basis_induct)
huffman@25904
    62
apply (erule rev_mp)
huffman@25904
    63
apply (induct_tac t rule: pd_basis_induct)
huffman@25904
    64
apply (simp add: 1)
huffman@25904
    65
apply (simp add: upper_le_PDPlus_PDUnit_iff)
huffman@25904
    66
apply (simp add: 2)
huffman@25904
    67
apply (subst PDPlus_commute)
huffman@25904
    68
apply (simp add: 2)
huffman@25904
    69
apply (simp add: upper_le_PDPlus_iff 3)
huffman@25904
    70
done
huffman@25904
    71
huffman@27405
    72
lemma pd_take_upper_chain:
huffman@27405
    73
  "pd_take n t \<le>\<sharp> pd_take (Suc n) t"
huffman@25904
    74
apply (induct t rule: pd_basis_induct)
huffman@27289
    75
apply (simp add: compact_basis.take_chain)
huffman@25904
    76
apply (simp add: PDPlus_upper_mono)
huffman@25904
    77
done
huffman@25904
    78
huffman@27405
    79
lemma pd_take_upper_le: "pd_take i t \<le>\<sharp> t"
huffman@25904
    80
apply (induct t rule: pd_basis_induct)
huffman@27289
    81
apply (simp add: compact_basis.take_less)
huffman@25904
    82
apply (simp add: PDPlus_upper_mono)
huffman@25904
    83
done
huffman@25904
    84
huffman@27405
    85
lemma pd_take_upper_mono:
huffman@27405
    86
  "t \<le>\<sharp> u \<Longrightarrow> pd_take n t \<le>\<sharp> pd_take n u"
huffman@25904
    87
apply (erule upper_le_induct)
huffman@27289
    88
apply (simp add: compact_basis.take_mono)
huffman@25904
    89
apply (simp add: upper_le_PDPlus_PDUnit_iff)
huffman@25904
    90
apply (simp add: upper_le_PDPlus_iff)
huffman@25904
    91
done
huffman@25904
    92
huffman@25904
    93
huffman@25904
    94
subsection {* Type definition *}
huffman@25904
    95
huffman@27373
    96
typedef (open) 'a upper_pd =
huffman@27373
    97
  "{S::'a pd_basis set. upper_le.ideal S}"
huffman@27373
    98
by (fast intro: upper_le.ideal_principal)
huffman@27373
    99
huffman@31076
   100
instantiation upper_pd :: (profinite) below
huffman@27373
   101
begin
huffman@27373
   102
huffman@27373
   103
definition
huffman@27373
   104
  "x \<sqsubseteq> y \<longleftrightarrow> Rep_upper_pd x \<subseteq> Rep_upper_pd y"
huffman@27373
   105
huffman@27373
   106
instance ..
huffman@27373
   107
end
huffman@25904
   108
huffman@27373
   109
instance upper_pd :: (profinite) po
huffman@27373
   110
by (rule upper_le.typedef_ideal_po
huffman@31076
   111
    [OF type_definition_upper_pd below_upper_pd_def])
huffman@27373
   112
huffman@27373
   113
instance upper_pd :: (profinite) cpo
huffman@27373
   114
by (rule upper_le.typedef_ideal_cpo
huffman@31076
   115
    [OF type_definition_upper_pd below_upper_pd_def])
huffman@27373
   116
huffman@27373
   117
lemma Rep_upper_pd_lub:
huffman@27373
   118
  "chain Y \<Longrightarrow> Rep_upper_pd (\<Squnion>i. Y i) = (\<Union>i. Rep_upper_pd (Y i))"
huffman@27373
   119
by (rule upper_le.typedef_ideal_rep_contlub
huffman@31076
   120
    [OF type_definition_upper_pd below_upper_pd_def])
huffman@27373
   121
huffman@27373
   122
lemma ideal_Rep_upper_pd: "upper_le.ideal (Rep_upper_pd xs)"
huffman@26927
   123
by (rule Rep_upper_pd [unfolded mem_Collect_eq])
huffman@25904
   124
huffman@25904
   125
definition
huffman@25904
   126
  upper_principal :: "'a pd_basis \<Rightarrow> 'a upper_pd" where
huffman@27373
   127
  "upper_principal t = Abs_upper_pd {u. u \<le>\<sharp> t}"
huffman@25904
   128
huffman@25904
   129
lemma Rep_upper_principal:
huffman@27373
   130
  "Rep_upper_pd (upper_principal t) = {u. u \<le>\<sharp> t}"
huffman@25904
   131
unfolding upper_principal_def
huffman@27297
   132
by (simp add: Abs_upper_pd_inverse upper_le.ideal_principal)
huffman@25904
   133
wenzelm@30729
   134
interpretation upper_pd:
ballarin@29237
   135
  ideal_completion upper_le pd_take upper_principal Rep_upper_pd
huffman@25904
   136
apply unfold_locales
huffman@27405
   137
apply (rule pd_take_upper_le)
huffman@27405
   138
apply (rule pd_take_idem)
huffman@27405
   139
apply (erule pd_take_upper_mono)
huffman@27405
   140
apply (rule pd_take_upper_chain)
huffman@27405
   141
apply (rule finite_range_pd_take)
huffman@27405
   142
apply (rule pd_take_covers)
huffman@26420
   143
apply (rule ideal_Rep_upper_pd)
huffman@27373
   144
apply (erule Rep_upper_pd_lub)
huffman@26420
   145
apply (rule Rep_upper_principal)
huffman@31076
   146
apply (simp only: below_upper_pd_def)
huffman@25904
   147
done
huffman@25904
   148
huffman@27289
   149
text {* Upper powerdomain is pointed *}
huffman@25904
   150
huffman@25904
   151
lemma upper_pd_minimal: "upper_principal (PDUnit compact_bot) \<sqsubseteq> ys"
huffman@25904
   152
by (induct ys rule: upper_pd.principal_induct, simp, simp)
huffman@25904
   153
huffman@25904
   154
instance upper_pd :: (bifinite) pcpo
huffman@26927
   155
by intro_classes (fast intro: upper_pd_minimal)
huffman@25904
   156
huffman@25904
   157
lemma inst_upper_pd_pcpo: "\<bottom> = upper_principal (PDUnit compact_bot)"
huffman@25904
   158
by (rule upper_pd_minimal [THEN UU_I, symmetric])
huffman@25904
   159
huffman@27289
   160
text {* Upper powerdomain is profinite *}
huffman@25904
   161
huffman@26962
   162
instantiation upper_pd :: (profinite) profinite
huffman@26962
   163
begin
huffman@25904
   164
huffman@26962
   165
definition
huffman@26962
   166
  approx_upper_pd_def: "approx = upper_pd.completion_approx"
huffman@26927
   167
huffman@26962
   168
instance
huffman@26927
   169
apply (intro_classes, unfold approx_upper_pd_def)
huffman@27310
   170
apply (rule upper_pd.chain_completion_approx)
huffman@26927
   171
apply (rule upper_pd.lub_completion_approx)
huffman@26927
   172
apply (rule upper_pd.completion_approx_idem)
huffman@26927
   173
apply (rule upper_pd.finite_fixes_completion_approx)
huffman@26927
   174
done
huffman@26927
   175
huffman@26962
   176
end
huffman@26962
   177
huffman@26927
   178
instance upper_pd :: (bifinite) bifinite ..
huffman@25904
   179
huffman@25904
   180
lemma approx_upper_principal [simp]:
huffman@27405
   181
  "approx n\<cdot>(upper_principal t) = upper_principal (pd_take n t)"
huffman@25904
   182
unfolding approx_upper_pd_def
huffman@26927
   183
by (rule upper_pd.completion_approx_principal)
huffman@25904
   184
huffman@25904
   185
lemma approx_eq_upper_principal:
huffman@27405
   186
  "\<exists>t\<in>Rep_upper_pd xs. approx n\<cdot>xs = upper_principal (pd_take n t)"
huffman@25904
   187
unfolding approx_upper_pd_def
huffman@26927
   188
by (rule upper_pd.completion_approx_eq_principal)
huffman@26407
   189
huffman@25904
   190
huffman@26927
   191
subsection {* Monadic unit and plus *}
huffman@25904
   192
huffman@25904
   193
definition
huffman@25904
   194
  upper_unit :: "'a \<rightarrow> 'a upper_pd" where
huffman@25904
   195
  "upper_unit = compact_basis.basis_fun (\<lambda>a. upper_principal (PDUnit a))"
huffman@25904
   196
huffman@25904
   197
definition
huffman@25904
   198
  upper_plus :: "'a upper_pd \<rightarrow> 'a upper_pd \<rightarrow> 'a upper_pd" where
huffman@25904
   199
  "upper_plus = upper_pd.basis_fun (\<lambda>t. upper_pd.basis_fun (\<lambda>u.
huffman@25904
   200
      upper_principal (PDPlus t u)))"
huffman@25904
   201
huffman@25904
   202
abbreviation
huffman@25904
   203
  upper_add :: "'a upper_pd \<Rightarrow> 'a upper_pd \<Rightarrow> 'a upper_pd"
huffman@25904
   204
    (infixl "+\<sharp>" 65) where
huffman@25904
   205
  "xs +\<sharp> ys == upper_plus\<cdot>xs\<cdot>ys"
huffman@25904
   206
huffman@26927
   207
syntax
huffman@26927
   208
  "_upper_pd" :: "args \<Rightarrow> 'a upper_pd" ("{_}\<sharp>")
huffman@26927
   209
huffman@26927
   210
translations
huffman@26927
   211
  "{x,xs}\<sharp>" == "{x}\<sharp> +\<sharp> {xs}\<sharp>"
huffman@26927
   212
  "{x}\<sharp>" == "CONST upper_unit\<cdot>x"
huffman@26927
   213
huffman@26927
   214
lemma upper_unit_Rep_compact_basis [simp]:
huffman@26927
   215
  "{Rep_compact_basis a}\<sharp> = upper_principal (PDUnit a)"
huffman@26927
   216
unfolding upper_unit_def
huffman@27289
   217
by (simp add: compact_basis.basis_fun_principal PDUnit_upper_mono)
huffman@26927
   218
huffman@25904
   219
lemma upper_plus_principal [simp]:
huffman@26927
   220
  "upper_principal t +\<sharp> upper_principal u = upper_principal (PDPlus t u)"
huffman@25904
   221
unfolding upper_plus_def
huffman@25904
   222
by (simp add: upper_pd.basis_fun_principal
huffman@25904
   223
    upper_pd.basis_fun_mono PDPlus_upper_mono)
huffman@25904
   224
huffman@26927
   225
lemma approx_upper_unit [simp]:
huffman@26927
   226
  "approx n\<cdot>{x}\<sharp> = {approx n\<cdot>x}\<sharp>"
huffman@27289
   227
apply (induct x rule: compact_basis.principal_induct, simp)
huffman@26927
   228
apply (simp add: approx_Rep_compact_basis)
huffman@26927
   229
done
huffman@26927
   230
huffman@25904
   231
lemma approx_upper_plus [simp]:
huffman@26927
   232
  "approx n\<cdot>(xs +\<sharp> ys) = (approx n\<cdot>xs) +\<sharp> (approx n\<cdot>ys)"
huffman@27289
   233
by (induct xs ys rule: upper_pd.principal_induct2, simp, simp, simp)
huffman@25904
   234
huffman@26927
   235
lemma upper_plus_assoc: "(xs +\<sharp> ys) +\<sharp> zs = xs +\<sharp> (ys +\<sharp> zs)"
huffman@27289
   236
apply (induct xs ys arbitrary: zs rule: upper_pd.principal_induct2, simp, simp)
huffman@27289
   237
apply (rule_tac x=zs in upper_pd.principal_induct, simp)
huffman@25904
   238
apply (simp add: PDPlus_assoc)
huffman@25904
   239
done
huffman@25904
   240
huffman@26927
   241
lemma upper_plus_commute: "xs +\<sharp> ys = ys +\<sharp> xs"
huffman@27289
   242
apply (induct xs ys rule: upper_pd.principal_induct2, simp, simp)
huffman@26927
   243
apply (simp add: PDPlus_commute)
huffman@26927
   244
done
huffman@26927
   245
huffman@29990
   246
lemma upper_plus_absorb [simp]: "xs +\<sharp> xs = xs"
huffman@27289
   247
apply (induct xs rule: upper_pd.principal_induct, simp)
huffman@25904
   248
apply (simp add: PDPlus_absorb)
huffman@25904
   249
done
huffman@25904
   250
huffman@29990
   251
lemma upper_plus_left_commute: "xs +\<sharp> (ys +\<sharp> zs) = ys +\<sharp> (xs +\<sharp> zs)"
huffman@29990
   252
by (rule mk_left_commute [of "op +\<sharp>", OF upper_plus_assoc upper_plus_commute])
huffman@26927
   253
huffman@29990
   254
lemma upper_plus_left_absorb [simp]: "xs +\<sharp> (xs +\<sharp> ys) = xs +\<sharp> ys"
huffman@29990
   255
by (simp only: upper_plus_assoc [symmetric] upper_plus_absorb)
huffman@26927
   256
huffman@29990
   257
text {* Useful for @{text "simp add: upper_plus_ac"} *}
huffman@29990
   258
lemmas upper_plus_ac =
huffman@29990
   259
  upper_plus_assoc upper_plus_commute upper_plus_left_commute
huffman@29990
   260
huffman@29990
   261
text {* Useful for @{text "simp only: upper_plus_aci"} *}
huffman@29990
   262
lemmas upper_plus_aci =
huffman@29990
   263
  upper_plus_ac upper_plus_absorb upper_plus_left_absorb
huffman@29990
   264
huffman@31076
   265
lemma upper_plus_below1: "xs +\<sharp> ys \<sqsubseteq> xs"
huffman@27289
   266
apply (induct xs ys rule: upper_pd.principal_induct2, simp, simp)
huffman@31076
   267
apply (simp add: PDPlus_upper_le)
huffman@25904
   268
done
huffman@25904
   269
huffman@31076
   270
lemma upper_plus_below2: "xs +\<sharp> ys \<sqsubseteq> ys"
huffman@31076
   271
by (subst upper_plus_commute, rule upper_plus_below1)
huffman@25904
   272
huffman@26927
   273
lemma upper_plus_greatest: "\<lbrakk>xs \<sqsubseteq> ys; xs \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs \<sqsubseteq> ys +\<sharp> zs"
huffman@25904
   274
apply (subst upper_plus_absorb [of xs, symmetric])
huffman@25904
   275
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
huffman@25904
   276
done
huffman@25904
   277
huffman@31076
   278
lemma upper_below_plus_iff:
huffman@26927
   279
  "xs \<sqsubseteq> ys +\<sharp> zs \<longleftrightarrow> xs \<sqsubseteq> ys \<and> xs \<sqsubseteq> zs"
huffman@25904
   280
apply safe
huffman@31076
   281
apply (erule below_trans [OF _ upper_plus_below1])
huffman@31076
   282
apply (erule below_trans [OF _ upper_plus_below2])
huffman@25904
   283
apply (erule (1) upper_plus_greatest)
huffman@25904
   284
done
huffman@25904
   285
huffman@31076
   286
lemma upper_plus_below_unit_iff:
huffman@26927
   287
  "xs +\<sharp> ys \<sqsubseteq> {z}\<sharp> \<longleftrightarrow> xs \<sqsubseteq> {z}\<sharp> \<or> ys \<sqsubseteq> {z}\<sharp>"
huffman@25904
   288
 apply (rule iffI)
huffman@25904
   289
  apply (subgoal_tac
huffman@26927
   290
    "adm (\<lambda>f. f\<cdot>xs \<sqsubseteq> f\<cdot>{z}\<sharp> \<or> f\<cdot>ys \<sqsubseteq> f\<cdot>{z}\<sharp>)")
huffman@25925
   291
   apply (drule admD, rule chain_approx)
huffman@25904
   292
    apply (drule_tac f="approx i" in monofun_cfun_arg)
huffman@27289
   293
    apply (cut_tac x="approx i\<cdot>xs" in upper_pd.compact_imp_principal, simp)
huffman@27289
   294
    apply (cut_tac x="approx i\<cdot>ys" in upper_pd.compact_imp_principal, simp)
huffman@27289
   295
    apply (cut_tac x="approx i\<cdot>z" in compact_basis.compact_imp_principal, simp)
huffman@25904
   296
    apply (clarify, simp add: upper_le_PDPlus_PDUnit_iff)
huffman@25904
   297
   apply simp
huffman@25904
   298
  apply simp
huffman@25904
   299
 apply (erule disjE)
huffman@31076
   300
  apply (erule below_trans [OF upper_plus_below1])
huffman@31076
   301
 apply (erule below_trans [OF upper_plus_below2])
huffman@25904
   302
done
huffman@25904
   303
huffman@31076
   304
lemma upper_unit_below_iff [simp]: "{x}\<sharp> \<sqsubseteq> {y}\<sharp> \<longleftrightarrow> x \<sqsubseteq> y"
huffman@26927
   305
 apply (rule iffI)
huffman@31076
   306
  apply (rule profinite_below_ext)
huffman@26927
   307
  apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
huffman@27289
   308
  apply (cut_tac x="approx i\<cdot>x" in compact_basis.compact_imp_principal, simp)
huffman@27289
   309
  apply (cut_tac x="approx i\<cdot>y" in compact_basis.compact_imp_principal, simp)
huffman@27289
   310
  apply clarsimp
huffman@26927
   311
 apply (erule monofun_cfun_arg)
huffman@26927
   312
done
huffman@26927
   313
huffman@31076
   314
lemmas upper_pd_below_simps =
huffman@31076
   315
  upper_unit_below_iff
huffman@31076
   316
  upper_below_plus_iff
huffman@31076
   317
  upper_plus_below_unit_iff
huffman@25904
   318
huffman@26927
   319
lemma upper_unit_eq_iff [simp]: "{x}\<sharp> = {y}\<sharp> \<longleftrightarrow> x = y"
huffman@26927
   320
unfolding po_eq_conv by simp
huffman@26927
   321
huffman@26927
   322
lemma upper_unit_strict [simp]: "{\<bottom>}\<sharp> = \<bottom>"
huffman@26927
   323
unfolding inst_upper_pd_pcpo Rep_compact_bot [symmetric] by simp
huffman@26927
   324
huffman@26927
   325
lemma upper_plus_strict1 [simp]: "\<bottom> +\<sharp> ys = \<bottom>"
huffman@31076
   326
by (rule UU_I, rule upper_plus_below1)
huffman@26927
   327
huffman@26927
   328
lemma upper_plus_strict2 [simp]: "xs +\<sharp> \<bottom> = \<bottom>"
huffman@31076
   329
by (rule UU_I, rule upper_plus_below2)
huffman@26927
   330
huffman@26927
   331
lemma upper_unit_strict_iff [simp]: "{x}\<sharp> = \<bottom> \<longleftrightarrow> x = \<bottom>"
huffman@26927
   332
unfolding upper_unit_strict [symmetric] by (rule upper_unit_eq_iff)
huffman@26927
   333
huffman@26927
   334
lemma upper_plus_strict_iff [simp]:
huffman@26927
   335
  "xs +\<sharp> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<or> ys = \<bottom>"
huffman@26927
   336
apply (rule iffI)
huffman@26927
   337
apply (erule rev_mp)
huffman@27289
   338
apply (rule upper_pd.principal_induct2 [where x=xs and y=ys], simp, simp)
huffman@27289
   339
apply (simp add: inst_upper_pd_pcpo upper_pd.principal_eq_iff
huffman@26927
   340
                 upper_le_PDPlus_PDUnit_iff)
huffman@26927
   341
apply auto
huffman@26927
   342
done
huffman@26927
   343
huffman@26927
   344
lemma compact_upper_unit_iff [simp]: "compact {x}\<sharp> \<longleftrightarrow> compact x"
huffman@27309
   345
unfolding profinite_compact_iff by simp
huffman@26927
   346
huffman@26927
   347
lemma compact_upper_plus [simp]:
huffman@26927
   348
  "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs +\<sharp> ys)"
huffman@27289
   349
by (auto dest!: upper_pd.compact_imp_principal)
huffman@26927
   350
huffman@25904
   351
huffman@25904
   352
subsection {* Induction rules *}
huffman@25904
   353
huffman@25904
   354
lemma upper_pd_induct1:
huffman@25904
   355
  assumes P: "adm P"
huffman@26927
   356
  assumes unit: "\<And>x. P {x}\<sharp>"
huffman@26927
   357
  assumes insert: "\<And>x ys. \<lbrakk>P {x}\<sharp>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<sharp> +\<sharp> ys)"
huffman@25904
   358
  shows "P (xs::'a upper_pd)"
huffman@27289
   359
apply (induct xs rule: upper_pd.principal_induct, rule P)
huffman@27289
   360
apply (induct_tac a rule: pd_basis_induct1)
huffman@25904
   361
apply (simp only: upper_unit_Rep_compact_basis [symmetric])
huffman@25904
   362
apply (rule unit)
huffman@25904
   363
apply (simp only: upper_unit_Rep_compact_basis [symmetric]
huffman@25904
   364
                  upper_plus_principal [symmetric])
huffman@25904
   365
apply (erule insert [OF unit])
huffman@25904
   366
done
huffman@25904
   367
huffman@25904
   368
lemma upper_pd_induct:
huffman@25904
   369
  assumes P: "adm P"
huffman@26927
   370
  assumes unit: "\<And>x. P {x}\<sharp>"
huffman@26927
   371
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs +\<sharp> ys)"
huffman@25904
   372
  shows "P (xs::'a upper_pd)"
huffman@27289
   373
apply (induct xs rule: upper_pd.principal_induct, rule P)
huffman@27289
   374
apply (induct_tac a rule: pd_basis_induct)
huffman@25904
   375
apply (simp only: upper_unit_Rep_compact_basis [symmetric] unit)
huffman@25904
   376
apply (simp only: upper_plus_principal [symmetric] plus)
huffman@25904
   377
done
huffman@25904
   378
huffman@25904
   379
huffman@25904
   380
subsection {* Monadic bind *}
huffman@25904
   381
huffman@25904
   382
definition
huffman@25904
   383
  upper_bind_basis ::
huffman@25904
   384
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
huffman@25904
   385
  "upper_bind_basis = fold_pd
huffman@25904
   386
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
huffman@26927
   387
    (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<sharp> y\<cdot>f)"
huffman@25904
   388
huffman@26927
   389
lemma ACI_upper_bind:
huffman@26927
   390
  "ab_semigroup_idem_mult (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<sharp> y\<cdot>f)"
huffman@25904
   391
apply unfold_locales
haftmann@26041
   392
apply (simp add: upper_plus_assoc)
huffman@25904
   393
apply (simp add: upper_plus_commute)
huffman@29990
   394
apply (simp add: eta_cfun)
huffman@25904
   395
done
huffman@25904
   396
huffman@25904
   397
lemma upper_bind_basis_simps [simp]:
huffman@25904
   398
  "upper_bind_basis (PDUnit a) =
huffman@25904
   399
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
huffman@25904
   400
  "upper_bind_basis (PDPlus t u) =
huffman@26927
   401
    (\<Lambda> f. upper_bind_basis t\<cdot>f +\<sharp> upper_bind_basis u\<cdot>f)"
huffman@25904
   402
unfolding upper_bind_basis_def
huffman@25904
   403
apply -
huffman@26927
   404
apply (rule fold_pd_PDUnit [OF ACI_upper_bind])
huffman@26927
   405
apply (rule fold_pd_PDPlus [OF ACI_upper_bind])
huffman@25904
   406
done
huffman@25904
   407
huffman@25904
   408
lemma upper_bind_basis_mono:
huffman@25904
   409
  "t \<le>\<sharp> u \<Longrightarrow> upper_bind_basis t \<sqsubseteq> upper_bind_basis u"
huffman@31076
   410
unfolding expand_cfun_below
huffman@25904
   411
apply (erule upper_le_induct, safe)
huffman@27289
   412
apply (simp add: monofun_cfun)
huffman@31076
   413
apply (simp add: below_trans [OF upper_plus_below1])
huffman@31076
   414
apply (simp add: upper_below_plus_iff)
huffman@25904
   415
done
huffman@25904
   416
huffman@25904
   417
definition
huffman@25904
   418
  upper_bind :: "'a upper_pd \<rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
huffman@25904
   419
  "upper_bind = upper_pd.basis_fun upper_bind_basis"
huffman@25904
   420
huffman@25904
   421
lemma upper_bind_principal [simp]:
huffman@25904
   422
  "upper_bind\<cdot>(upper_principal t) = upper_bind_basis t"
huffman@25904
   423
unfolding upper_bind_def
huffman@25904
   424
apply (rule upper_pd.basis_fun_principal)
huffman@25904
   425
apply (erule upper_bind_basis_mono)
huffman@25904
   426
done
huffman@25904
   427
huffman@25904
   428
lemma upper_bind_unit [simp]:
huffman@26927
   429
  "upper_bind\<cdot>{x}\<sharp>\<cdot>f = f\<cdot>x"
huffman@27289
   430
by (induct x rule: compact_basis.principal_induct, simp, simp)
huffman@25904
   431
huffman@25904
   432
lemma upper_bind_plus [simp]:
huffman@26927
   433
  "upper_bind\<cdot>(xs +\<sharp> ys)\<cdot>f = upper_bind\<cdot>xs\<cdot>f +\<sharp> upper_bind\<cdot>ys\<cdot>f"
huffman@27289
   434
by (induct xs ys rule: upper_pd.principal_induct2, simp, simp, simp)
huffman@25904
   435
huffman@25904
   436
lemma upper_bind_strict [simp]: "upper_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
huffman@25904
   437
unfolding upper_unit_strict [symmetric] by (rule upper_bind_unit)
huffman@25904
   438
huffman@25904
   439
huffman@25904
   440
subsection {* Map and join *}
huffman@25904
   441
huffman@25904
   442
definition
huffman@25904
   443
  upper_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a upper_pd \<rightarrow> 'b upper_pd" where
huffman@26927
   444
  "upper_map = (\<Lambda> f xs. upper_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<sharp>))"
huffman@25904
   445
huffman@25904
   446
definition
huffman@25904
   447
  upper_join :: "'a upper_pd upper_pd \<rightarrow> 'a upper_pd" where
huffman@25904
   448
  "upper_join = (\<Lambda> xss. upper_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
huffman@25904
   449
huffman@25904
   450
lemma upper_map_unit [simp]:
huffman@26927
   451
  "upper_map\<cdot>f\<cdot>{x}\<sharp> = {f\<cdot>x}\<sharp>"
huffman@25904
   452
unfolding upper_map_def by simp
huffman@25904
   453
huffman@25904
   454
lemma upper_map_plus [simp]:
huffman@26927
   455
  "upper_map\<cdot>f\<cdot>(xs +\<sharp> ys) = upper_map\<cdot>f\<cdot>xs +\<sharp> upper_map\<cdot>f\<cdot>ys"
huffman@25904
   456
unfolding upper_map_def by simp
huffman@25904
   457
huffman@25904
   458
lemma upper_join_unit [simp]:
huffman@26927
   459
  "upper_join\<cdot>{xs}\<sharp> = xs"
huffman@25904
   460
unfolding upper_join_def by simp
huffman@25904
   461
huffman@25904
   462
lemma upper_join_plus [simp]:
huffman@26927
   463
  "upper_join\<cdot>(xss +\<sharp> yss) = upper_join\<cdot>xss +\<sharp> upper_join\<cdot>yss"
huffman@25904
   464
unfolding upper_join_def by simp
huffman@25904
   465
huffman@25904
   466
lemma upper_map_ident: "upper_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
huffman@25904
   467
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   468
huffman@25904
   469
lemma upper_map_map:
huffman@25904
   470
  "upper_map\<cdot>f\<cdot>(upper_map\<cdot>g\<cdot>xs) = upper_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
huffman@25904
   471
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   472
huffman@25904
   473
lemma upper_join_map_unit:
huffman@25904
   474
  "upper_join\<cdot>(upper_map\<cdot>upper_unit\<cdot>xs) = xs"
huffman@25904
   475
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   476
huffman@25904
   477
lemma upper_join_map_join:
huffman@25904
   478
  "upper_join\<cdot>(upper_map\<cdot>upper_join\<cdot>xsss) = upper_join\<cdot>(upper_join\<cdot>xsss)"
huffman@25904
   479
by (induct xsss rule: upper_pd_induct, simp_all)
huffman@25904
   480
huffman@25904
   481
lemma upper_join_map_map:
huffman@25904
   482
  "upper_join\<cdot>(upper_map\<cdot>(upper_map\<cdot>f)\<cdot>xss) =
huffman@25904
   483
   upper_map\<cdot>f\<cdot>(upper_join\<cdot>xss)"
huffman@25904
   484
by (induct xss rule: upper_pd_induct, simp_all)
huffman@25904
   485
huffman@25904
   486
lemma upper_map_approx: "upper_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
huffman@25904
   487
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   488
huffman@25904
   489
end