src/HOLCF/UpperPD.thy
author huffman
Mon May 19 23:49:20 2008 +0200 (2008-05-19)
changeset 26962 c8b20f615d6c
parent 26927 8684b5240f11
child 27267 5ebfb7f25ebb
permissions -rw-r--r--
use new class package for classes profinite, bifinite; remove approx class
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@25904
    73
lemma approx_pd_upper_mono1:
huffman@25904
    74
  "i \<le> j \<Longrightarrow> approx_pd i t \<le>\<sharp> approx_pd j t"
huffman@25904
    75
apply (induct t rule: pd_basis_induct)
huffman@25904
    76
apply (simp add: compact_approx_mono1)
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@25904
    82
apply (simp add: compact_approx_le)
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@25904
    89
apply (simp add: compact_approx_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@25904
    97
cpodef (open) 'a upper_pd =
huffman@26407
    98
  "{S::'a::profinite pd_basis set. upper_le.ideal S}"
huffman@25904
    99
apply (simp add: upper_le.adm_ideal)
huffman@25904
   100
apply (fast intro: upper_le.ideal_principal)
huffman@25904
   101
done
huffman@25904
   102
huffman@25904
   103
lemma ideal_Rep_upper_pd: "upper_le.ideal (Rep_upper_pd x)"
huffman@26927
   104
by (rule Rep_upper_pd [unfolded mem_Collect_eq])
huffman@25904
   105
huffman@25904
   106
definition
huffman@25904
   107
  upper_principal :: "'a pd_basis \<Rightarrow> 'a upper_pd" where
huffman@25904
   108
  "upper_principal t = Abs_upper_pd {u. u \<le>\<sharp> t}"
huffman@25904
   109
huffman@25904
   110
lemma Rep_upper_principal:
huffman@25904
   111
  "Rep_upper_pd (upper_principal t) = {u. u \<le>\<sharp> t}"
huffman@25904
   112
unfolding upper_principal_def
huffman@26927
   113
apply (rule Abs_upper_pd_inverse [unfolded mem_Collect_eq])
huffman@25904
   114
apply (rule upper_le.ideal_principal)
huffman@25904
   115
done
huffman@25904
   116
huffman@25904
   117
interpretation upper_pd:
huffman@26927
   118
  ideal_completion [upper_le approx_pd upper_principal Rep_upper_pd]
huffman@25904
   119
apply unfold_locales
huffman@25904
   120
apply (rule approx_pd_upper_le)
huffman@25904
   121
apply (rule approx_pd_idem)
huffman@25904
   122
apply (erule approx_pd_upper_mono)
huffman@25904
   123
apply (rule approx_pd_upper_mono1, simp)
huffman@25904
   124
apply (rule finite_range_approx_pd)
huffman@25904
   125
apply (rule ex_approx_pd_eq)
huffman@26420
   126
apply (rule ideal_Rep_upper_pd)
huffman@26420
   127
apply (rule cont_Rep_upper_pd)
huffman@26420
   128
apply (rule Rep_upper_principal)
berghofe@26806
   129
apply (simp only: less_upper_pd_def less_set_eq)
huffman@25904
   130
done
huffman@25904
   131
huffman@25904
   132
lemma upper_principal_less_iff [simp]:
huffman@26927
   133
  "upper_principal t \<sqsubseteq> upper_principal u \<longleftrightarrow> t \<le>\<sharp> u"
huffman@26927
   134
by (rule upper_pd.principal_less_iff)
huffman@26927
   135
huffman@26927
   136
lemma upper_principal_eq_iff:
huffman@26927
   137
  "upper_principal t = upper_principal u \<longleftrightarrow> t \<le>\<sharp> u \<and> u \<le>\<sharp> t"
huffman@26927
   138
by (rule upper_pd.principal_eq_iff)
huffman@25904
   139
huffman@25904
   140
lemma upper_principal_mono:
huffman@25904
   141
  "t \<le>\<sharp> u \<Longrightarrow> upper_principal t \<sqsubseteq> upper_principal u"
huffman@25904
   142
by (rule upper_pd.principal_mono)
huffman@25904
   143
huffman@25904
   144
lemma compact_upper_principal: "compact (upper_principal t)"
huffman@25904
   145
by (rule upper_pd.compact_principal)
huffman@25904
   146
huffman@25904
   147
lemma upper_pd_minimal: "upper_principal (PDUnit compact_bot) \<sqsubseteq> ys"
huffman@25904
   148
by (induct ys rule: upper_pd.principal_induct, simp, simp)
huffman@25904
   149
huffman@25904
   150
instance upper_pd :: (bifinite) pcpo
huffman@26927
   151
by intro_classes (fast intro: upper_pd_minimal)
huffman@25904
   152
huffman@25904
   153
lemma inst_upper_pd_pcpo: "\<bottom> = upper_principal (PDUnit compact_bot)"
huffman@25904
   154
by (rule upper_pd_minimal [THEN UU_I, symmetric])
huffman@25904
   155
huffman@25904
   156
huffman@25904
   157
subsection {* Approximation *}
huffman@25904
   158
huffman@26962
   159
instantiation upper_pd :: (profinite) profinite
huffman@26962
   160
begin
huffman@25904
   161
huffman@26962
   162
definition
huffman@26962
   163
  approx_upper_pd_def: "approx = upper_pd.completion_approx"
huffman@26927
   164
huffman@26962
   165
instance
huffman@26927
   166
apply (intro_classes, unfold approx_upper_pd_def)
huffman@26927
   167
apply (simp add: upper_pd.chain_completion_approx)
huffman@26927
   168
apply (rule upper_pd.lub_completion_approx)
huffman@26927
   169
apply (rule upper_pd.completion_approx_idem)
huffman@26927
   170
apply (rule upper_pd.finite_fixes_completion_approx)
huffman@26927
   171
done
huffman@26927
   172
huffman@26962
   173
end
huffman@26962
   174
huffman@26927
   175
instance upper_pd :: (bifinite) bifinite ..
huffman@25904
   176
huffman@25904
   177
lemma approx_upper_principal [simp]:
huffman@25904
   178
  "approx n\<cdot>(upper_principal t) = upper_principal (approx_pd n t)"
huffman@25904
   179
unfolding approx_upper_pd_def
huffman@26927
   180
by (rule upper_pd.completion_approx_principal)
huffman@25904
   181
huffman@25904
   182
lemma approx_eq_upper_principal:
huffman@25904
   183
  "\<exists>t\<in>Rep_upper_pd xs. approx n\<cdot>xs = upper_principal (approx_pd n t)"
huffman@25904
   184
unfolding approx_upper_pd_def
huffman@26927
   185
by (rule upper_pd.completion_approx_eq_principal)
huffman@26407
   186
huffman@25904
   187
lemma compact_imp_upper_principal:
huffman@25904
   188
  "compact xs \<Longrightarrow> \<exists>t. xs = upper_principal t"
huffman@25904
   189
apply (drule bifinite_compact_eq_approx)
huffman@25904
   190
apply (erule exE)
huffman@25904
   191
apply (erule subst)
huffman@25904
   192
apply (cut_tac n=i and xs=xs in approx_eq_upper_principal)
huffman@25904
   193
apply fast
huffman@25904
   194
done
huffman@25904
   195
huffman@25904
   196
lemma upper_principal_induct:
huffman@25904
   197
  "\<lbrakk>adm P; \<And>t. P (upper_principal t)\<rbrakk> \<Longrightarrow> P xs"
huffman@26927
   198
by (rule upper_pd.principal_induct)
huffman@25904
   199
huffman@25904
   200
lemma upper_principal_induct2:
huffman@25904
   201
  "\<lbrakk>\<And>ys. adm (\<lambda>xs. P xs ys); \<And>xs. adm (\<lambda>ys. P xs ys);
huffman@25904
   202
    \<And>t u. P (upper_principal t) (upper_principal u)\<rbrakk> \<Longrightarrow> P xs ys"
huffman@25904
   203
apply (rule_tac x=ys in spec)
huffman@25904
   204
apply (rule_tac xs=xs in upper_principal_induct, simp)
huffman@25904
   205
apply (rule allI, rename_tac ys)
huffman@25904
   206
apply (rule_tac xs=ys in upper_principal_induct, simp)
huffman@25904
   207
apply simp
huffman@25904
   208
done
huffman@25904
   209
huffman@25904
   210
huffman@26927
   211
subsection {* Monadic unit and plus *}
huffman@25904
   212
huffman@25904
   213
definition
huffman@25904
   214
  upper_unit :: "'a \<rightarrow> 'a upper_pd" where
huffman@25904
   215
  "upper_unit = compact_basis.basis_fun (\<lambda>a. upper_principal (PDUnit a))"
huffman@25904
   216
huffman@25904
   217
definition
huffman@25904
   218
  upper_plus :: "'a upper_pd \<rightarrow> 'a upper_pd \<rightarrow> 'a upper_pd" where
huffman@25904
   219
  "upper_plus = upper_pd.basis_fun (\<lambda>t. upper_pd.basis_fun (\<lambda>u.
huffman@25904
   220
      upper_principal (PDPlus t u)))"
huffman@25904
   221
huffman@25904
   222
abbreviation
huffman@25904
   223
  upper_add :: "'a upper_pd \<Rightarrow> 'a upper_pd \<Rightarrow> 'a upper_pd"
huffman@25904
   224
    (infixl "+\<sharp>" 65) where
huffman@25904
   225
  "xs +\<sharp> ys == upper_plus\<cdot>xs\<cdot>ys"
huffman@25904
   226
huffman@26927
   227
syntax
huffman@26927
   228
  "_upper_pd" :: "args \<Rightarrow> 'a upper_pd" ("{_}\<sharp>")
huffman@26927
   229
huffman@26927
   230
translations
huffman@26927
   231
  "{x,xs}\<sharp>" == "{x}\<sharp> +\<sharp> {xs}\<sharp>"
huffman@26927
   232
  "{x}\<sharp>" == "CONST upper_unit\<cdot>x"
huffman@26927
   233
huffman@26927
   234
lemma upper_unit_Rep_compact_basis [simp]:
huffman@26927
   235
  "{Rep_compact_basis a}\<sharp> = upper_principal (PDUnit a)"
huffman@26927
   236
unfolding upper_unit_def
huffman@26927
   237
by (simp add: compact_basis.basis_fun_principal
huffman@26927
   238
    upper_principal_mono PDUnit_upper_mono)
huffman@26927
   239
huffman@25904
   240
lemma upper_plus_principal [simp]:
huffman@26927
   241
  "upper_principal t +\<sharp> upper_principal u = upper_principal (PDPlus t u)"
huffman@25904
   242
unfolding upper_plus_def
huffman@25904
   243
by (simp add: upper_pd.basis_fun_principal
huffman@25904
   244
    upper_pd.basis_fun_mono PDPlus_upper_mono)
huffman@25904
   245
huffman@26927
   246
lemma approx_upper_unit [simp]:
huffman@26927
   247
  "approx n\<cdot>{x}\<sharp> = {approx n\<cdot>x}\<sharp>"
huffman@26927
   248
apply (induct x rule: compact_basis_induct, simp)
huffman@26927
   249
apply (simp add: approx_Rep_compact_basis)
huffman@26927
   250
done
huffman@26927
   251
huffman@25904
   252
lemma approx_upper_plus [simp]:
huffman@26927
   253
  "approx n\<cdot>(xs +\<sharp> ys) = (approx n\<cdot>xs) +\<sharp> (approx n\<cdot>ys)"
huffman@25904
   254
by (induct xs ys rule: upper_principal_induct2, simp, simp, simp)
huffman@25904
   255
huffman@26927
   256
lemma upper_plus_assoc: "(xs +\<sharp> ys) +\<sharp> zs = xs +\<sharp> (ys +\<sharp> zs)"
huffman@25904
   257
apply (induct xs ys arbitrary: zs rule: upper_principal_induct2, simp, simp)
huffman@25904
   258
apply (rule_tac xs=zs in upper_principal_induct, simp)
huffman@25904
   259
apply (simp add: PDPlus_assoc)
huffman@25904
   260
done
huffman@25904
   261
huffman@26927
   262
lemma upper_plus_commute: "xs +\<sharp> ys = ys +\<sharp> xs"
huffman@26927
   263
apply (induct xs ys rule: upper_principal_induct2, simp, simp)
huffman@26927
   264
apply (simp add: PDPlus_commute)
huffman@26927
   265
done
huffman@26927
   266
huffman@26927
   267
lemma upper_plus_absorb: "xs +\<sharp> xs = xs"
huffman@25904
   268
apply (induct xs rule: upper_principal_induct, simp)
huffman@25904
   269
apply (simp add: PDPlus_absorb)
huffman@25904
   270
done
huffman@25904
   271
huffman@26927
   272
interpretation aci_upper_plus: ab_semigroup_idem_mult ["op +\<sharp>"]
huffman@26927
   273
  by unfold_locales
huffman@26927
   274
    (rule upper_plus_assoc upper_plus_commute upper_plus_absorb)+
huffman@26927
   275
huffman@26927
   276
lemma upper_plus_left_commute: "xs +\<sharp> (ys +\<sharp> zs) = ys +\<sharp> (xs +\<sharp> zs)"
huffman@26927
   277
by (rule aci_upper_plus.mult_left_commute)
huffman@26927
   278
huffman@26927
   279
lemma upper_plus_left_absorb: "xs +\<sharp> (xs +\<sharp> ys) = xs +\<sharp> ys"
huffman@26927
   280
by (rule aci_upper_plus.mult_left_idem)
huffman@26927
   281
huffman@26927
   282
lemmas upper_plus_aci = aci_upper_plus.mult_ac_idem
huffman@26927
   283
huffman@26927
   284
lemma upper_plus_less1: "xs +\<sharp> ys \<sqsubseteq> xs"
huffman@25904
   285
apply (induct xs ys rule: upper_principal_induct2, simp, simp)
huffman@25904
   286
apply (simp add: PDPlus_upper_less)
huffman@25904
   287
done
huffman@25904
   288
huffman@26927
   289
lemma upper_plus_less2: "xs +\<sharp> ys \<sqsubseteq> ys"
huffman@25904
   290
by (subst upper_plus_commute, rule upper_plus_less1)
huffman@25904
   291
huffman@26927
   292
lemma upper_plus_greatest: "\<lbrakk>xs \<sqsubseteq> ys; xs \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs \<sqsubseteq> ys +\<sharp> zs"
huffman@25904
   293
apply (subst upper_plus_absorb [of xs, symmetric])
huffman@25904
   294
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
huffman@25904
   295
done
huffman@25904
   296
huffman@25904
   297
lemma upper_less_plus_iff:
huffman@26927
   298
  "xs \<sqsubseteq> ys +\<sharp> zs \<longleftrightarrow> xs \<sqsubseteq> ys \<and> xs \<sqsubseteq> zs"
huffman@25904
   299
apply safe
huffman@25904
   300
apply (erule trans_less [OF _ upper_plus_less1])
huffman@25904
   301
apply (erule trans_less [OF _ upper_plus_less2])
huffman@25904
   302
apply (erule (1) upper_plus_greatest)
huffman@25904
   303
done
huffman@25904
   304
huffman@25904
   305
lemma upper_plus_less_unit_iff:
huffman@26927
   306
  "xs +\<sharp> ys \<sqsubseteq> {z}\<sharp> \<longleftrightarrow> xs \<sqsubseteq> {z}\<sharp> \<or> ys \<sqsubseteq> {z}\<sharp>"
huffman@25904
   307
 apply (rule iffI)
huffman@25904
   308
  apply (subgoal_tac
huffman@26927
   309
    "adm (\<lambda>f. f\<cdot>xs \<sqsubseteq> f\<cdot>{z}\<sharp> \<or> f\<cdot>ys \<sqsubseteq> f\<cdot>{z}\<sharp>)")
huffman@25925
   310
   apply (drule admD, rule chain_approx)
huffman@25904
   311
    apply (drule_tac f="approx i" in monofun_cfun_arg)
huffman@25904
   312
    apply (cut_tac xs="approx i\<cdot>xs" in compact_imp_upper_principal, simp)
huffman@25904
   313
    apply (cut_tac xs="approx i\<cdot>ys" in compact_imp_upper_principal, simp)
huffman@25904
   314
    apply (cut_tac x="approx i\<cdot>z" in compact_imp_Rep_compact_basis, simp)
huffman@25904
   315
    apply (clarify, simp add: upper_le_PDPlus_PDUnit_iff)
huffman@25904
   316
   apply simp
huffman@25904
   317
  apply simp
huffman@25904
   318
 apply (erule disjE)
huffman@25904
   319
  apply (erule trans_less [OF upper_plus_less1])
huffman@25904
   320
 apply (erule trans_less [OF upper_plus_less2])
huffman@25904
   321
done
huffman@25904
   322
huffman@26927
   323
lemma upper_unit_less_iff [simp]: "{x}\<sharp> \<sqsubseteq> {y}\<sharp> \<longleftrightarrow> x \<sqsubseteq> y"
huffman@26927
   324
 apply (rule iffI)
huffman@26927
   325
  apply (rule bifinite_less_ext)
huffman@26927
   326
  apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
huffman@26927
   327
  apply (cut_tac x="approx i\<cdot>x" in compact_imp_Rep_compact_basis, simp)
huffman@26927
   328
  apply (cut_tac x="approx i\<cdot>y" in compact_imp_Rep_compact_basis, simp)
huffman@26927
   329
  apply (clarify, simp add: compact_le_def)
huffman@26927
   330
 apply (erule monofun_cfun_arg)
huffman@26927
   331
done
huffman@26927
   332
huffman@25904
   333
lemmas upper_pd_less_simps =
huffman@25904
   334
  upper_unit_less_iff
huffman@25904
   335
  upper_less_plus_iff
huffman@25904
   336
  upper_plus_less_unit_iff
huffman@25904
   337
huffman@26927
   338
lemma upper_unit_eq_iff [simp]: "{x}\<sharp> = {y}\<sharp> \<longleftrightarrow> x = y"
huffman@26927
   339
unfolding po_eq_conv by simp
huffman@26927
   340
huffman@26927
   341
lemma upper_unit_strict [simp]: "{\<bottom>}\<sharp> = \<bottom>"
huffman@26927
   342
unfolding inst_upper_pd_pcpo Rep_compact_bot [symmetric] by simp
huffman@26927
   343
huffman@26927
   344
lemma upper_plus_strict1 [simp]: "\<bottom> +\<sharp> ys = \<bottom>"
huffman@26927
   345
by (rule UU_I, rule upper_plus_less1)
huffman@26927
   346
huffman@26927
   347
lemma upper_plus_strict2 [simp]: "xs +\<sharp> \<bottom> = \<bottom>"
huffman@26927
   348
by (rule UU_I, rule upper_plus_less2)
huffman@26927
   349
huffman@26927
   350
lemma upper_unit_strict_iff [simp]: "{x}\<sharp> = \<bottom> \<longleftrightarrow> x = \<bottom>"
huffman@26927
   351
unfolding upper_unit_strict [symmetric] by (rule upper_unit_eq_iff)
huffman@26927
   352
huffman@26927
   353
lemma upper_plus_strict_iff [simp]:
huffman@26927
   354
  "xs +\<sharp> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<or> ys = \<bottom>"
huffman@26927
   355
apply (rule iffI)
huffman@26927
   356
apply (erule rev_mp)
huffman@26927
   357
apply (rule upper_principal_induct2 [where xs=xs and ys=ys], simp, simp)
huffman@26927
   358
apply (simp add: inst_upper_pd_pcpo upper_principal_eq_iff
huffman@26927
   359
                 upper_le_PDPlus_PDUnit_iff)
huffman@26927
   360
apply auto
huffman@26927
   361
done
huffman@26927
   362
huffman@26927
   363
lemma compact_upper_unit_iff [simp]: "compact {x}\<sharp> \<longleftrightarrow> compact x"
huffman@26927
   364
unfolding bifinite_compact_iff by simp
huffman@26927
   365
huffman@26927
   366
lemma compact_upper_plus [simp]:
huffman@26927
   367
  "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs +\<sharp> ys)"
huffman@26927
   368
apply (drule compact_imp_upper_principal)+
huffman@26927
   369
apply (auto simp add: compact_upper_principal)
huffman@26927
   370
done
huffman@26927
   371
huffman@25904
   372
huffman@25904
   373
subsection {* Induction rules *}
huffman@25904
   374
huffman@25904
   375
lemma upper_pd_induct1:
huffman@25904
   376
  assumes P: "adm P"
huffman@26927
   377
  assumes unit: "\<And>x. P {x}\<sharp>"
huffman@26927
   378
  assumes insert: "\<And>x ys. \<lbrakk>P {x}\<sharp>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<sharp> +\<sharp> ys)"
huffman@25904
   379
  shows "P (xs::'a upper_pd)"
huffman@25904
   380
apply (induct xs rule: upper_principal_induct, rule P)
huffman@25904
   381
apply (induct_tac t rule: pd_basis_induct1)
huffman@25904
   382
apply (simp only: upper_unit_Rep_compact_basis [symmetric])
huffman@25904
   383
apply (rule unit)
huffman@25904
   384
apply (simp only: upper_unit_Rep_compact_basis [symmetric]
huffman@25904
   385
                  upper_plus_principal [symmetric])
huffman@25904
   386
apply (erule insert [OF unit])
huffman@25904
   387
done
huffman@25904
   388
huffman@25904
   389
lemma upper_pd_induct:
huffman@25904
   390
  assumes P: "adm P"
huffman@26927
   391
  assumes unit: "\<And>x. P {x}\<sharp>"
huffman@26927
   392
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs +\<sharp> ys)"
huffman@25904
   393
  shows "P (xs::'a upper_pd)"
huffman@25904
   394
apply (induct xs rule: upper_principal_induct, rule P)
huffman@25904
   395
apply (induct_tac t rule: pd_basis_induct)
huffman@25904
   396
apply (simp only: upper_unit_Rep_compact_basis [symmetric] unit)
huffman@25904
   397
apply (simp only: upper_plus_principal [symmetric] plus)
huffman@25904
   398
done
huffman@25904
   399
huffman@25904
   400
huffman@25904
   401
subsection {* Monadic bind *}
huffman@25904
   402
huffman@25904
   403
definition
huffman@25904
   404
  upper_bind_basis ::
huffman@25904
   405
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
huffman@25904
   406
  "upper_bind_basis = fold_pd
huffman@25904
   407
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
huffman@26927
   408
    (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<sharp> y\<cdot>f)"
huffman@25904
   409
huffman@26927
   410
lemma ACI_upper_bind:
huffman@26927
   411
  "ab_semigroup_idem_mult (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<sharp> y\<cdot>f)"
huffman@25904
   412
apply unfold_locales
haftmann@26041
   413
apply (simp add: upper_plus_assoc)
huffman@25904
   414
apply (simp add: upper_plus_commute)
huffman@25904
   415
apply (simp add: upper_plus_absorb eta_cfun)
huffman@25904
   416
done
huffman@25904
   417
huffman@25904
   418
lemma upper_bind_basis_simps [simp]:
huffman@25904
   419
  "upper_bind_basis (PDUnit a) =
huffman@25904
   420
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
huffman@25904
   421
  "upper_bind_basis (PDPlus t u) =
huffman@26927
   422
    (\<Lambda> f. upper_bind_basis t\<cdot>f +\<sharp> upper_bind_basis u\<cdot>f)"
huffman@25904
   423
unfolding upper_bind_basis_def
huffman@25904
   424
apply -
huffman@26927
   425
apply (rule fold_pd_PDUnit [OF ACI_upper_bind])
huffman@26927
   426
apply (rule fold_pd_PDPlus [OF ACI_upper_bind])
huffman@25904
   427
done
huffman@25904
   428
huffman@25904
   429
lemma upper_bind_basis_mono:
huffman@25904
   430
  "t \<le>\<sharp> u \<Longrightarrow> upper_bind_basis t \<sqsubseteq> upper_bind_basis u"
huffman@25904
   431
unfolding expand_cfun_less
huffman@25904
   432
apply (erule upper_le_induct, safe)
huffman@25904
   433
apply (simp add: compact_le_def monofun_cfun)
huffman@25904
   434
apply (simp add: trans_less [OF upper_plus_less1])
huffman@25904
   435
apply (simp add: upper_less_plus_iff)
huffman@25904
   436
done
huffman@25904
   437
huffman@25904
   438
definition
huffman@25904
   439
  upper_bind :: "'a upper_pd \<rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
huffman@25904
   440
  "upper_bind = upper_pd.basis_fun upper_bind_basis"
huffman@25904
   441
huffman@25904
   442
lemma upper_bind_principal [simp]:
huffman@25904
   443
  "upper_bind\<cdot>(upper_principal t) = upper_bind_basis t"
huffman@25904
   444
unfolding upper_bind_def
huffman@25904
   445
apply (rule upper_pd.basis_fun_principal)
huffman@25904
   446
apply (erule upper_bind_basis_mono)
huffman@25904
   447
done
huffman@25904
   448
huffman@25904
   449
lemma upper_bind_unit [simp]:
huffman@26927
   450
  "upper_bind\<cdot>{x}\<sharp>\<cdot>f = f\<cdot>x"
huffman@25904
   451
by (induct x rule: compact_basis_induct, simp, simp)
huffman@25904
   452
huffman@25904
   453
lemma upper_bind_plus [simp]:
huffman@26927
   454
  "upper_bind\<cdot>(xs +\<sharp> ys)\<cdot>f = upper_bind\<cdot>xs\<cdot>f +\<sharp> upper_bind\<cdot>ys\<cdot>f"
huffman@25904
   455
by (induct xs ys rule: upper_principal_induct2, simp, simp, simp)
huffman@25904
   456
huffman@25904
   457
lemma upper_bind_strict [simp]: "upper_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
huffman@25904
   458
unfolding upper_unit_strict [symmetric] by (rule upper_bind_unit)
huffman@25904
   459
huffman@25904
   460
huffman@25904
   461
subsection {* Map and join *}
huffman@25904
   462
huffman@25904
   463
definition
huffman@25904
   464
  upper_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a upper_pd \<rightarrow> 'b upper_pd" where
huffman@26927
   465
  "upper_map = (\<Lambda> f xs. upper_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<sharp>))"
huffman@25904
   466
huffman@25904
   467
definition
huffman@25904
   468
  upper_join :: "'a upper_pd upper_pd \<rightarrow> 'a upper_pd" where
huffman@25904
   469
  "upper_join = (\<Lambda> xss. upper_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
huffman@25904
   470
huffman@25904
   471
lemma upper_map_unit [simp]:
huffman@26927
   472
  "upper_map\<cdot>f\<cdot>{x}\<sharp> = {f\<cdot>x}\<sharp>"
huffman@25904
   473
unfolding upper_map_def by simp
huffman@25904
   474
huffman@25904
   475
lemma upper_map_plus [simp]:
huffman@26927
   476
  "upper_map\<cdot>f\<cdot>(xs +\<sharp> ys) = upper_map\<cdot>f\<cdot>xs +\<sharp> upper_map\<cdot>f\<cdot>ys"
huffman@25904
   477
unfolding upper_map_def by simp
huffman@25904
   478
huffman@25904
   479
lemma upper_join_unit [simp]:
huffman@26927
   480
  "upper_join\<cdot>{xs}\<sharp> = xs"
huffman@25904
   481
unfolding upper_join_def by simp
huffman@25904
   482
huffman@25904
   483
lemma upper_join_plus [simp]:
huffman@26927
   484
  "upper_join\<cdot>(xss +\<sharp> yss) = upper_join\<cdot>xss +\<sharp> upper_join\<cdot>yss"
huffman@25904
   485
unfolding upper_join_def by simp
huffman@25904
   486
huffman@25904
   487
lemma upper_map_ident: "upper_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
huffman@25904
   488
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   489
huffman@25904
   490
lemma upper_map_map:
huffman@25904
   491
  "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
   492
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   493
huffman@25904
   494
lemma upper_join_map_unit:
huffman@25904
   495
  "upper_join\<cdot>(upper_map\<cdot>upper_unit\<cdot>xs) = xs"
huffman@25904
   496
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   497
huffman@25904
   498
lemma upper_join_map_join:
huffman@25904
   499
  "upper_join\<cdot>(upper_map\<cdot>upper_join\<cdot>xsss) = upper_join\<cdot>(upper_join\<cdot>xsss)"
huffman@25904
   500
by (induct xsss rule: upper_pd_induct, simp_all)
huffman@25904
   501
huffman@25904
   502
lemma upper_join_map_map:
huffman@25904
   503
  "upper_join\<cdot>(upper_map\<cdot>(upper_map\<cdot>f)\<cdot>xss) =
huffman@25904
   504
   upper_map\<cdot>f\<cdot>(upper_join\<cdot>xss)"
huffman@25904
   505
by (induct xss rule: upper_pd_induct, simp_all)
huffman@25904
   506
huffman@25904
   507
lemma upper_map_approx: "upper_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
huffman@25904
   508
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   509
huffman@25904
   510
end