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