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