src/HOLCF/UpperPD.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/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@25904
    72
huffman@25904
    73
subsection {* Type definition *}
huffman@25904
    74
huffman@27373
    75
typedef (open) 'a upper_pd =
huffman@27373
    76
  "{S::'a pd_basis set. upper_le.ideal S}"
huffman@27373
    77
by (fast intro: upper_le.ideal_principal)
huffman@27373
    78
huffman@39986
    79
instantiation upper_pd :: (bifinite) below
huffman@27373
    80
begin
huffman@27373
    81
huffman@27373
    82
definition
huffman@27373
    83
  "x \<sqsubseteq> y \<longleftrightarrow> Rep_upper_pd x \<subseteq> Rep_upper_pd y"
huffman@27373
    84
huffman@27373
    85
instance ..
huffman@27373
    86
end
huffman@25904
    87
huffman@39986
    88
instance upper_pd :: (bifinite) po
huffman@39974
    89
using type_definition_upper_pd below_upper_pd_def
huffman@39974
    90
by (rule upper_le.typedef_ideal_po)
huffman@27373
    91
huffman@39986
    92
instance upper_pd :: (bifinite) cpo
huffman@39974
    93
using type_definition_upper_pd below_upper_pd_def
huffman@39974
    94
by (rule upper_le.typedef_ideal_cpo)
huffman@27373
    95
huffman@25904
    96
definition
huffman@25904
    97
  upper_principal :: "'a pd_basis \<Rightarrow> 'a upper_pd" where
huffman@27373
    98
  "upper_principal t = Abs_upper_pd {u. u \<le>\<sharp> t}"
huffman@25904
    99
wenzelm@30729
   100
interpretation upper_pd:
huffman@39974
   101
  ideal_completion upper_le upper_principal Rep_upper_pd
huffman@39984
   102
using type_definition_upper_pd below_upper_pd_def
huffman@39984
   103
using upper_principal_def pd_basis_countable
huffman@39984
   104
by (rule upper_le.typedef_ideal_completion)
huffman@25904
   105
huffman@27289
   106
text {* Upper powerdomain is pointed *}
huffman@25904
   107
huffman@25904
   108
lemma upper_pd_minimal: "upper_principal (PDUnit compact_bot) \<sqsubseteq> ys"
huffman@25904
   109
by (induct ys rule: upper_pd.principal_induct, simp, simp)
huffman@25904
   110
huffman@39986
   111
instance upper_pd :: (bifinite) pcpo
huffman@26927
   112
by intro_classes (fast intro: upper_pd_minimal)
huffman@25904
   113
huffman@25904
   114
lemma inst_upper_pd_pcpo: "\<bottom> = upper_principal (PDUnit compact_bot)"
huffman@25904
   115
by (rule upper_pd_minimal [THEN UU_I, symmetric])
huffman@25904
   116
huffman@25904
   117
huffman@26927
   118
subsection {* Monadic unit and plus *}
huffman@25904
   119
huffman@25904
   120
definition
huffman@25904
   121
  upper_unit :: "'a \<rightarrow> 'a upper_pd" where
huffman@25904
   122
  "upper_unit = compact_basis.basis_fun (\<lambda>a. upper_principal (PDUnit a))"
huffman@25904
   123
huffman@25904
   124
definition
huffman@25904
   125
  upper_plus :: "'a upper_pd \<rightarrow> 'a upper_pd \<rightarrow> 'a upper_pd" where
huffman@25904
   126
  "upper_plus = upper_pd.basis_fun (\<lambda>t. upper_pd.basis_fun (\<lambda>u.
huffman@25904
   127
      upper_principal (PDPlus t u)))"
huffman@25904
   128
huffman@25904
   129
abbreviation
huffman@25904
   130
  upper_add :: "'a upper_pd \<Rightarrow> 'a upper_pd \<Rightarrow> 'a upper_pd"
huffman@25904
   131
    (infixl "+\<sharp>" 65) where
huffman@25904
   132
  "xs +\<sharp> ys == upper_plus\<cdot>xs\<cdot>ys"
huffman@25904
   133
huffman@26927
   134
syntax
huffman@26927
   135
  "_upper_pd" :: "args \<Rightarrow> 'a upper_pd" ("{_}\<sharp>")
huffman@26927
   136
huffman@26927
   137
translations
huffman@26927
   138
  "{x,xs}\<sharp>" == "{x}\<sharp> +\<sharp> {xs}\<sharp>"
huffman@26927
   139
  "{x}\<sharp>" == "CONST upper_unit\<cdot>x"
huffman@26927
   140
huffman@26927
   141
lemma upper_unit_Rep_compact_basis [simp]:
huffman@26927
   142
  "{Rep_compact_basis a}\<sharp> = upper_principal (PDUnit a)"
huffman@26927
   143
unfolding upper_unit_def
huffman@27289
   144
by (simp add: compact_basis.basis_fun_principal PDUnit_upper_mono)
huffman@26927
   145
huffman@25904
   146
lemma upper_plus_principal [simp]:
huffman@26927
   147
  "upper_principal t +\<sharp> upper_principal u = upper_principal (PDPlus t u)"
huffman@25904
   148
unfolding upper_plus_def
huffman@25904
   149
by (simp add: upper_pd.basis_fun_principal
huffman@25904
   150
    upper_pd.basis_fun_mono PDPlus_upper_mono)
huffman@25904
   151
haftmann@37770
   152
interpretation upper_add: semilattice upper_add proof
haftmann@34973
   153
  fix xs ys zs :: "'a upper_pd"
haftmann@34973
   154
  show "(xs +\<sharp> ys) +\<sharp> zs = xs +\<sharp> (ys +\<sharp> zs)"
haftmann@34973
   155
    apply (induct xs ys arbitrary: zs rule: upper_pd.principal_induct2, simp, simp)
haftmann@34973
   156
    apply (rule_tac x=zs in upper_pd.principal_induct, simp)
haftmann@34973
   157
    apply (simp add: PDPlus_assoc)
haftmann@34973
   158
    done
haftmann@34973
   159
  show "xs +\<sharp> ys = ys +\<sharp> xs"
haftmann@34973
   160
    apply (induct xs ys rule: upper_pd.principal_induct2, simp, simp)
haftmann@34973
   161
    apply (simp add: PDPlus_commute)
haftmann@34973
   162
    done
haftmann@34973
   163
  show "xs +\<sharp> xs = xs"
haftmann@34973
   164
    apply (induct xs rule: upper_pd.principal_induct, simp)
haftmann@34973
   165
    apply (simp add: PDPlus_absorb)
haftmann@34973
   166
    done
haftmann@34973
   167
qed
huffman@26927
   168
haftmann@34973
   169
lemmas upper_plus_assoc = upper_add.assoc
haftmann@34973
   170
lemmas upper_plus_commute = upper_add.commute
haftmann@34973
   171
lemmas upper_plus_absorb = upper_add.idem
haftmann@34973
   172
lemmas upper_plus_left_commute = upper_add.left_commute
haftmann@34973
   173
lemmas upper_plus_left_absorb = upper_add.left_idem
huffman@26927
   174
huffman@29990
   175
text {* Useful for @{text "simp add: upper_plus_ac"} *}
huffman@29990
   176
lemmas upper_plus_ac =
huffman@29990
   177
  upper_plus_assoc upper_plus_commute upper_plus_left_commute
huffman@29990
   178
huffman@29990
   179
text {* Useful for @{text "simp only: upper_plus_aci"} *}
huffman@29990
   180
lemmas upper_plus_aci =
huffman@29990
   181
  upper_plus_ac upper_plus_absorb upper_plus_left_absorb
huffman@29990
   182
huffman@31076
   183
lemma upper_plus_below1: "xs +\<sharp> ys \<sqsubseteq> xs"
huffman@27289
   184
apply (induct xs ys rule: upper_pd.principal_induct2, simp, simp)
huffman@31076
   185
apply (simp add: PDPlus_upper_le)
huffman@25904
   186
done
huffman@25904
   187
huffman@31076
   188
lemma upper_plus_below2: "xs +\<sharp> ys \<sqsubseteq> ys"
huffman@31076
   189
by (subst upper_plus_commute, rule upper_plus_below1)
huffman@25904
   190
huffman@26927
   191
lemma upper_plus_greatest: "\<lbrakk>xs \<sqsubseteq> ys; xs \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs \<sqsubseteq> ys +\<sharp> zs"
huffman@25904
   192
apply (subst upper_plus_absorb [of xs, symmetric])
huffman@25904
   193
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
huffman@25904
   194
done
huffman@25904
   195
huffman@31076
   196
lemma upper_below_plus_iff:
huffman@26927
   197
  "xs \<sqsubseteq> ys +\<sharp> zs \<longleftrightarrow> xs \<sqsubseteq> ys \<and> xs \<sqsubseteq> zs"
huffman@25904
   198
apply safe
huffman@31076
   199
apply (erule below_trans [OF _ upper_plus_below1])
huffman@31076
   200
apply (erule below_trans [OF _ upper_plus_below2])
huffman@25904
   201
apply (erule (1) upper_plus_greatest)
huffman@25904
   202
done
huffman@25904
   203
huffman@31076
   204
lemma upper_plus_below_unit_iff:
huffman@26927
   205
  "xs +\<sharp> ys \<sqsubseteq> {z}\<sharp> \<longleftrightarrow> xs \<sqsubseteq> {z}\<sharp> \<or> ys \<sqsubseteq> {z}\<sharp>"
brianh@39970
   206
apply (induct xs rule: upper_pd.principal_induct, simp)
brianh@39970
   207
apply (induct ys rule: upper_pd.principal_induct, simp)
brianh@39970
   208
apply (induct z rule: compact_basis.principal_induct, simp)
brianh@39970
   209
apply (simp add: upper_le_PDPlus_PDUnit_iff)
huffman@25904
   210
done
huffman@25904
   211
huffman@31076
   212
lemma upper_unit_below_iff [simp]: "{x}\<sharp> \<sqsubseteq> {y}\<sharp> \<longleftrightarrow> x \<sqsubseteq> y"
brianh@39970
   213
apply (induct x rule: compact_basis.principal_induct, simp)
brianh@39970
   214
apply (induct y rule: compact_basis.principal_induct, simp)
brianh@39970
   215
apply simp
huffman@26927
   216
done
huffman@26927
   217
huffman@31076
   218
lemmas upper_pd_below_simps =
huffman@31076
   219
  upper_unit_below_iff
huffman@31076
   220
  upper_below_plus_iff
huffman@31076
   221
  upper_plus_below_unit_iff
huffman@25904
   222
huffman@26927
   223
lemma upper_unit_eq_iff [simp]: "{x}\<sharp> = {y}\<sharp> \<longleftrightarrow> x = y"
huffman@26927
   224
unfolding po_eq_conv by simp
huffman@26927
   225
huffman@26927
   226
lemma upper_unit_strict [simp]: "{\<bottom>}\<sharp> = \<bottom>"
huffman@39974
   227
using upper_unit_Rep_compact_basis [of compact_bot]
huffman@39974
   228
by (simp add: inst_upper_pd_pcpo)
huffman@26927
   229
huffman@26927
   230
lemma upper_plus_strict1 [simp]: "\<bottom> +\<sharp> ys = \<bottom>"
huffman@31076
   231
by (rule UU_I, rule upper_plus_below1)
huffman@26927
   232
huffman@26927
   233
lemma upper_plus_strict2 [simp]: "xs +\<sharp> \<bottom> = \<bottom>"
huffman@31076
   234
by (rule UU_I, rule upper_plus_below2)
huffman@26927
   235
huffman@26927
   236
lemma upper_unit_strict_iff [simp]: "{x}\<sharp> = \<bottom> \<longleftrightarrow> x = \<bottom>"
huffman@26927
   237
unfolding upper_unit_strict [symmetric] by (rule upper_unit_eq_iff)
huffman@26927
   238
huffman@26927
   239
lemma upper_plus_strict_iff [simp]:
huffman@26927
   240
  "xs +\<sharp> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<or> ys = \<bottom>"
huffman@26927
   241
apply (rule iffI)
huffman@26927
   242
apply (erule rev_mp)
huffman@27289
   243
apply (rule upper_pd.principal_induct2 [where x=xs and y=ys], simp, simp)
huffman@27289
   244
apply (simp add: inst_upper_pd_pcpo upper_pd.principal_eq_iff
huffman@26927
   245
                 upper_le_PDPlus_PDUnit_iff)
huffman@26927
   246
apply auto
huffman@26927
   247
done
huffman@26927
   248
huffman@39974
   249
lemma compact_upper_unit: "compact x \<Longrightarrow> compact {x}\<sharp>"
huffman@39974
   250
by (auto dest!: compact_basis.compact_imp_principal)
huffman@39974
   251
huffman@26927
   252
lemma compact_upper_unit_iff [simp]: "compact {x}\<sharp> \<longleftrightarrow> compact x"
huffman@39974
   253
apply (safe elim!: compact_upper_unit)
huffman@39974
   254
apply (simp only: compact_def upper_unit_below_iff [symmetric])
huffman@39974
   255
apply (erule adm_subst [OF cont_Rep_CFun2])
huffman@39974
   256
done
huffman@26927
   257
huffman@26927
   258
lemma compact_upper_plus [simp]:
huffman@26927
   259
  "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs +\<sharp> ys)"
huffman@27289
   260
by (auto dest!: upper_pd.compact_imp_principal)
huffman@26927
   261
huffman@25904
   262
huffman@25904
   263
subsection {* Induction rules *}
huffman@25904
   264
huffman@25904
   265
lemma upper_pd_induct1:
huffman@25904
   266
  assumes P: "adm P"
huffman@26927
   267
  assumes unit: "\<And>x. P {x}\<sharp>"
huffman@26927
   268
  assumes insert: "\<And>x ys. \<lbrakk>P {x}\<sharp>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<sharp> +\<sharp> ys)"
huffman@25904
   269
  shows "P (xs::'a upper_pd)"
huffman@27289
   270
apply (induct xs rule: upper_pd.principal_induct, rule P)
huffman@27289
   271
apply (induct_tac a rule: pd_basis_induct1)
huffman@25904
   272
apply (simp only: upper_unit_Rep_compact_basis [symmetric])
huffman@25904
   273
apply (rule unit)
huffman@25904
   274
apply (simp only: upper_unit_Rep_compact_basis [symmetric]
huffman@25904
   275
                  upper_plus_principal [symmetric])
huffman@25904
   276
apply (erule insert [OF unit])
huffman@25904
   277
done
huffman@25904
   278
huffman@25904
   279
lemma upper_pd_induct:
huffman@25904
   280
  assumes P: "adm P"
huffman@26927
   281
  assumes unit: "\<And>x. P {x}\<sharp>"
huffman@26927
   282
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs +\<sharp> ys)"
huffman@25904
   283
  shows "P (xs::'a upper_pd)"
huffman@27289
   284
apply (induct xs rule: upper_pd.principal_induct, rule P)
huffman@27289
   285
apply (induct_tac a rule: pd_basis_induct)
huffman@25904
   286
apply (simp only: upper_unit_Rep_compact_basis [symmetric] unit)
huffman@25904
   287
apply (simp only: upper_plus_principal [symmetric] plus)
huffman@25904
   288
done
huffman@25904
   289
huffman@25904
   290
huffman@25904
   291
subsection {* Monadic bind *}
huffman@25904
   292
huffman@25904
   293
definition
huffman@25904
   294
  upper_bind_basis ::
huffman@25904
   295
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
huffman@25904
   296
  "upper_bind_basis = fold_pd
huffman@25904
   297
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
huffman@26927
   298
    (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<sharp> y\<cdot>f)"
huffman@25904
   299
huffman@26927
   300
lemma ACI_upper_bind:
haftmann@36635
   301
  "class.ab_semigroup_idem_mult (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<sharp> y\<cdot>f)"
huffman@25904
   302
apply unfold_locales
haftmann@26041
   303
apply (simp add: upper_plus_assoc)
huffman@25904
   304
apply (simp add: upper_plus_commute)
huffman@29990
   305
apply (simp add: eta_cfun)
huffman@25904
   306
done
huffman@25904
   307
huffman@25904
   308
lemma upper_bind_basis_simps [simp]:
huffman@25904
   309
  "upper_bind_basis (PDUnit a) =
huffman@25904
   310
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
huffman@25904
   311
  "upper_bind_basis (PDPlus t u) =
huffman@26927
   312
    (\<Lambda> f. upper_bind_basis t\<cdot>f +\<sharp> upper_bind_basis u\<cdot>f)"
huffman@25904
   313
unfolding upper_bind_basis_def
huffman@25904
   314
apply -
huffman@26927
   315
apply (rule fold_pd_PDUnit [OF ACI_upper_bind])
huffman@26927
   316
apply (rule fold_pd_PDPlus [OF ACI_upper_bind])
huffman@25904
   317
done
huffman@25904
   318
huffman@25904
   319
lemma upper_bind_basis_mono:
huffman@25904
   320
  "t \<le>\<sharp> u \<Longrightarrow> upper_bind_basis t \<sqsubseteq> upper_bind_basis u"
huffman@40002
   321
unfolding cfun_below_iff
huffman@25904
   322
apply (erule upper_le_induct, safe)
huffman@27289
   323
apply (simp add: monofun_cfun)
huffman@31076
   324
apply (simp add: below_trans [OF upper_plus_below1])
huffman@31076
   325
apply (simp add: upper_below_plus_iff)
huffman@25904
   326
done
huffman@25904
   327
huffman@25904
   328
definition
huffman@25904
   329
  upper_bind :: "'a upper_pd \<rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
huffman@25904
   330
  "upper_bind = upper_pd.basis_fun upper_bind_basis"
huffman@25904
   331
huffman@25904
   332
lemma upper_bind_principal [simp]:
huffman@25904
   333
  "upper_bind\<cdot>(upper_principal t) = upper_bind_basis t"
huffman@25904
   334
unfolding upper_bind_def
huffman@25904
   335
apply (rule upper_pd.basis_fun_principal)
huffman@25904
   336
apply (erule upper_bind_basis_mono)
huffman@25904
   337
done
huffman@25904
   338
huffman@25904
   339
lemma upper_bind_unit [simp]:
huffman@26927
   340
  "upper_bind\<cdot>{x}\<sharp>\<cdot>f = f\<cdot>x"
huffman@27289
   341
by (induct x rule: compact_basis.principal_induct, simp, simp)
huffman@25904
   342
huffman@25904
   343
lemma upper_bind_plus [simp]:
huffman@26927
   344
  "upper_bind\<cdot>(xs +\<sharp> ys)\<cdot>f = upper_bind\<cdot>xs\<cdot>f +\<sharp> upper_bind\<cdot>ys\<cdot>f"
huffman@27289
   345
by (induct xs ys rule: upper_pd.principal_induct2, simp, simp, simp)
huffman@25904
   346
huffman@25904
   347
lemma upper_bind_strict [simp]: "upper_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
huffman@25904
   348
unfolding upper_unit_strict [symmetric] by (rule upper_bind_unit)
huffman@25904
   349
huffman@25904
   350
huffman@39974
   351
subsection {* Map *}
huffman@25904
   352
huffman@25904
   353
definition
huffman@25904
   354
  upper_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a upper_pd \<rightarrow> 'b upper_pd" where
huffman@26927
   355
  "upper_map = (\<Lambda> f xs. upper_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<sharp>))"
huffman@25904
   356
huffman@25904
   357
lemma upper_map_unit [simp]:
huffman@26927
   358
  "upper_map\<cdot>f\<cdot>{x}\<sharp> = {f\<cdot>x}\<sharp>"
huffman@25904
   359
unfolding upper_map_def by simp
huffman@25904
   360
huffman@25904
   361
lemma upper_map_plus [simp]:
huffman@26927
   362
  "upper_map\<cdot>f\<cdot>(xs +\<sharp> ys) = upper_map\<cdot>f\<cdot>xs +\<sharp> upper_map\<cdot>f\<cdot>ys"
huffman@25904
   363
unfolding upper_map_def by simp
huffman@25904
   364
huffman@25904
   365
lemma upper_map_ident: "upper_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
huffman@25904
   366
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   367
huffman@33808
   368
lemma upper_map_ID: "upper_map\<cdot>ID = ID"
huffman@40002
   369
by (simp add: cfun_eq_iff ID_def upper_map_ident)
huffman@33808
   370
huffman@25904
   371
lemma upper_map_map:
huffman@25904
   372
  "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
   373
by (induct xs rule: upper_pd_induct, simp_all)
huffman@25904
   374
huffman@33585
   375
lemma ep_pair_upper_map: "ep_pair e p \<Longrightarrow> ep_pair (upper_map\<cdot>e) (upper_map\<cdot>p)"
huffman@33585
   376
apply default
huffman@33585
   377
apply (induct_tac x rule: upper_pd_induct, simp_all add: ep_pair.e_inverse)
huffman@35901
   378
apply (induct_tac y rule: upper_pd_induct)
huffman@35901
   379
apply (simp_all add: ep_pair.e_p_below monofun_cfun)
huffman@33585
   380
done
huffman@33585
   381
huffman@33585
   382
lemma deflation_upper_map: "deflation d \<Longrightarrow> deflation (upper_map\<cdot>d)"
huffman@33585
   383
apply default
huffman@33585
   384
apply (induct_tac x rule: upper_pd_induct, simp_all add: deflation.idem)
huffman@35901
   385
apply (induct_tac x rule: upper_pd_induct)
huffman@35901
   386
apply (simp_all add: deflation.below monofun_cfun)
huffman@33585
   387
done
huffman@33585
   388
huffman@39974
   389
(* FIXME: long proof! *)
huffman@39974
   390
lemma finite_deflation_upper_map:
huffman@39974
   391
  assumes "finite_deflation d" shows "finite_deflation (upper_map\<cdot>d)"
huffman@39974
   392
proof (rule finite_deflation_intro)
huffman@39974
   393
  interpret d: finite_deflation d by fact
huffman@39974
   394
  have "deflation d" by fact
huffman@39974
   395
  thus "deflation (upper_map\<cdot>d)" by (rule deflation_upper_map)
huffman@39974
   396
  have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range)
huffman@39974
   397
  hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))"
huffman@39974
   398
    by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject)
huffman@39974
   399
  hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp
huffman@39974
   400
  hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))"
huffman@39974
   401
    by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject)
huffman@39974
   402
  hence *: "finite (upper_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp
huffman@39974
   403
  hence "finite (range (\<lambda>xs. upper_map\<cdot>d\<cdot>xs))"
huffman@39974
   404
    apply (rule rev_finite_subset)
huffman@39974
   405
    apply clarsimp
huffman@39974
   406
    apply (induct_tac xs rule: upper_pd.principal_induct)
huffman@39974
   407
    apply (simp add: adm_mem_finite *)
huffman@39974
   408
    apply (rename_tac t, induct_tac t rule: pd_basis_induct)
huffman@39974
   409
    apply (simp only: upper_unit_Rep_compact_basis [symmetric] upper_map_unit)
huffman@39974
   410
    apply simp
huffman@39974
   411
    apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b")
huffman@39974
   412
    apply clarsimp
huffman@39974
   413
    apply (rule imageI)
huffman@39974
   414
    apply (rule vimageI2)
huffman@39974
   415
    apply (simp add: Rep_PDUnit)
huffman@39974
   416
    apply (rule range_eqI)
huffman@39974
   417
    apply (erule sym)
huffman@39974
   418
    apply (rule exI)
huffman@39974
   419
    apply (rule Abs_compact_basis_inverse [symmetric])
huffman@39974
   420
    apply (simp add: d.compact)
huffman@39974
   421
    apply (simp only: upper_plus_principal [symmetric] upper_map_plus)
huffman@39974
   422
    apply clarsimp
huffman@39974
   423
    apply (rule imageI)
huffman@39974
   424
    apply (rule vimageI2)
huffman@39974
   425
    apply (simp add: Rep_PDPlus)
huffman@39974
   426
    done
huffman@39974
   427
  thus "finite {xs. upper_map\<cdot>d\<cdot>xs = xs}"
huffman@39974
   428
    by (rule finite_range_imp_finite_fixes)
huffman@39974
   429
qed
huffman@39974
   430
huffman@39986
   431
subsection {* Upper powerdomain is a bifinite domain *}
huffman@39974
   432
huffman@39974
   433
definition
huffman@39974
   434
  upper_approx :: "nat \<Rightarrow> udom upper_pd \<rightarrow> udom upper_pd"
huffman@39974
   435
where
huffman@39974
   436
  "upper_approx = (\<lambda>i. upper_map\<cdot>(udom_approx i))"
huffman@39974
   437
huffman@39974
   438
lemma upper_approx: "approx_chain upper_approx"
huffman@39974
   439
proof (rule approx_chain.intro)
huffman@39974
   440
  show "chain (\<lambda>i. upper_approx i)"
huffman@39974
   441
    unfolding upper_approx_def by simp
huffman@39974
   442
  show "(\<Squnion>i. upper_approx i) = ID"
huffman@39974
   443
    unfolding upper_approx_def
huffman@39974
   444
    by (simp add: lub_distribs upper_map_ID)
huffman@39974
   445
  show "\<And>i. finite_deflation (upper_approx i)"
huffman@39974
   446
    unfolding upper_approx_def
huffman@39974
   447
    by (intro finite_deflation_upper_map finite_deflation_udom_approx)
huffman@39974
   448
qed
huffman@39974
   449
huffman@39989
   450
definition upper_defl :: "defl \<rightarrow> defl"
huffman@39989
   451
where "upper_defl = defl_fun1 upper_approx upper_map"
huffman@39974
   452
huffman@39989
   453
lemma cast_upper_defl:
huffman@39989
   454
  "cast\<cdot>(upper_defl\<cdot>A) =
huffman@39974
   455
    udom_emb upper_approx oo upper_map\<cdot>(cast\<cdot>A) oo udom_prj upper_approx"
huffman@39989
   456
unfolding upper_defl_def
huffman@39989
   457
apply (rule cast_defl_fun1 [OF upper_approx])
huffman@39974
   458
apply (erule finite_deflation_upper_map)
huffman@39974
   459
done
huffman@39974
   460
huffman@39986
   461
instantiation upper_pd :: (bifinite) bifinite
huffman@39974
   462
begin
huffman@39974
   463
huffman@39974
   464
definition
huffman@39974
   465
  "emb = udom_emb upper_approx oo upper_map\<cdot>emb"
huffman@39974
   466
huffman@39974
   467
definition
huffman@39974
   468
  "prj = upper_map\<cdot>prj oo udom_prj upper_approx"
huffman@39974
   469
huffman@39974
   470
definition
huffman@39989
   471
  "defl (t::'a upper_pd itself) = upper_defl\<cdot>DEFL('a)"
huffman@39974
   472
huffman@39974
   473
instance proof
huffman@39974
   474
  show "ep_pair emb (prj :: udom \<rightarrow> 'a upper_pd)"
huffman@39974
   475
    unfolding emb_upper_pd_def prj_upper_pd_def
huffman@39974
   476
    using ep_pair_udom [OF upper_approx]
huffman@39974
   477
    by (intro ep_pair_comp ep_pair_upper_map ep_pair_emb_prj)
huffman@39974
   478
next
huffman@39989
   479
  show "cast\<cdot>DEFL('a upper_pd) = emb oo (prj :: udom \<rightarrow> 'a upper_pd)"
huffman@39989
   480
    unfolding emb_upper_pd_def prj_upper_pd_def defl_upper_pd_def cast_upper_defl
huffman@40002
   481
    by (simp add: cast_DEFL oo_def cfun_eq_iff upper_map_map)
huffman@39974
   482
qed
huffman@39974
   483
huffman@25904
   484
end
huffman@39974
   485
huffman@39989
   486
lemma DEFL_upper: "DEFL('a upper_pd) = upper_defl\<cdot>DEFL('a)"
huffman@39989
   487
by (rule defl_upper_pd_def)
huffman@39974
   488
huffman@39974
   489
huffman@39974
   490
subsection {* Join *}
huffman@39974
   491
huffman@39974
   492
definition
huffman@39974
   493
  upper_join :: "'a upper_pd upper_pd \<rightarrow> 'a upper_pd" where
huffman@39974
   494
  "upper_join = (\<Lambda> xss. upper_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
huffman@39974
   495
huffman@39974
   496
lemma upper_join_unit [simp]:
huffman@39974
   497
  "upper_join\<cdot>{xs}\<sharp> = xs"
huffman@39974
   498
unfolding upper_join_def by simp
huffman@39974
   499
huffman@39974
   500
lemma upper_join_plus [simp]:
huffman@39974
   501
  "upper_join\<cdot>(xss +\<sharp> yss) = upper_join\<cdot>xss +\<sharp> upper_join\<cdot>yss"
huffman@39974
   502
unfolding upper_join_def by simp
huffman@39974
   503
huffman@39974
   504
lemma upper_join_map_unit:
huffman@39974
   505
  "upper_join\<cdot>(upper_map\<cdot>upper_unit\<cdot>xs) = xs"
huffman@39974
   506
by (induct xs rule: upper_pd_induct, simp_all)
huffman@39974
   507
huffman@39974
   508
lemma upper_join_map_join:
huffman@39974
   509
  "upper_join\<cdot>(upper_map\<cdot>upper_join\<cdot>xsss) = upper_join\<cdot>(upper_join\<cdot>xsss)"
huffman@39974
   510
by (induct xsss rule: upper_pd_induct, simp_all)
huffman@39974
   511
huffman@39974
   512
lemma upper_join_map_map:
huffman@39974
   513
  "upper_join\<cdot>(upper_map\<cdot>(upper_map\<cdot>f)\<cdot>xss) =
huffman@39974
   514
   upper_map\<cdot>f\<cdot>(upper_join\<cdot>xss)"
huffman@39974
   515
by (induct xss rule: upper_pd_induct, simp_all)
huffman@39974
   516
huffman@39974
   517
end