src/HOL/HOLCF/LowerPD.thy
author blanchet
Tue Nov 07 15:16:42 2017 +0100 (20 months ago)
changeset 67022 49309fe530fd
parent 62175 8ffc4d0e652d
child 67682 00c436488398
permissions -rw-r--r--
more robust parsing for THF proofs (esp. polymorphic Leo-III proofs)
wenzelm@42151
     1
(*  Title:      HOL/HOLCF/LowerPD.thy
huffman@25904
     2
    Author:     Brian Huffman
huffman@25904
     3
*)
huffman@25904
     4
wenzelm@62175
     5
section \<open>Lower powerdomain\<close>
huffman@25904
     6
huffman@25904
     7
theory LowerPD
huffman@41284
     8
imports Compact_Basis
huffman@25904
     9
begin
huffman@25904
    10
wenzelm@62175
    11
subsection \<open>Basis preorder\<close>
huffman@25904
    12
huffman@25904
    13
definition
huffman@25904
    14
  lower_le :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> bool" (infix "\<le>\<flat>" 50) where
huffman@26420
    15
  "lower_le = (\<lambda>u v. \<forall>x\<in>Rep_pd_basis u. \<exists>y\<in>Rep_pd_basis v. x \<sqsubseteq> y)"
huffman@25904
    16
huffman@25904
    17
lemma lower_le_refl [simp]: "t \<le>\<flat> t"
huffman@26420
    18
unfolding lower_le_def by fast
huffman@25904
    19
huffman@25904
    20
lemma lower_le_trans: "\<lbrakk>t \<le>\<flat> u; u \<le>\<flat> v\<rbrakk> \<Longrightarrow> t \<le>\<flat> v"
huffman@25904
    21
unfolding lower_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 lower_le: preorder lower_le
huffman@25904
    30
by (rule preorder.intro, rule lower_le_refl, rule lower_le_trans)
huffman@25904
    31
huffman@25904
    32
lemma lower_le_minimal [simp]: "PDUnit compact_bot \<le>\<flat> t"
huffman@25904
    33
unfolding lower_le_def Rep_PDUnit
huffman@25904
    34
by (simp, rule Rep_pd_basis_nonempty [folded ex_in_conv])
huffman@25904
    35
huffman@26420
    36
lemma PDUnit_lower_mono: "x \<sqsubseteq> y \<Longrightarrow> PDUnit x \<le>\<flat> PDUnit y"
huffman@25904
    37
unfolding lower_le_def Rep_PDUnit by fast
huffman@25904
    38
huffman@25904
    39
lemma PDPlus_lower_mono: "\<lbrakk>s \<le>\<flat> t; u \<le>\<flat> v\<rbrakk> \<Longrightarrow> PDPlus s u \<le>\<flat> PDPlus t v"
huffman@25904
    40
unfolding lower_le_def Rep_PDPlus by fast
huffman@25904
    41
huffman@31076
    42
lemma PDPlus_lower_le: "t \<le>\<flat> PDPlus t u"
huffman@26420
    43
unfolding lower_le_def Rep_PDPlus by fast
huffman@25904
    44
huffman@25904
    45
lemma lower_le_PDUnit_PDUnit_iff [simp]:
huffman@40436
    46
  "(PDUnit a \<le>\<flat> PDUnit b) = (a \<sqsubseteq> b)"
huffman@25904
    47
unfolding lower_le_def Rep_PDUnit by fast
huffman@25904
    48
huffman@25904
    49
lemma lower_le_PDUnit_PDPlus_iff:
huffman@25904
    50
  "(PDUnit a \<le>\<flat> PDPlus t u) = (PDUnit a \<le>\<flat> t \<or> PDUnit a \<le>\<flat> u)"
huffman@25904
    51
unfolding lower_le_def Rep_PDPlus Rep_PDUnit by fast
huffman@25904
    52
huffman@25904
    53
lemma lower_le_PDPlus_iff: "(PDPlus t u \<le>\<flat> v) = (t \<le>\<flat> v \<and> u \<le>\<flat> v)"
huffman@25904
    54
unfolding lower_le_def Rep_PDPlus by fast
huffman@25904
    55
huffman@25904
    56
lemma lower_le_induct [induct set: lower_le]:
huffman@25904
    57
  assumes le: "t \<le>\<flat> 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 (PDUnit a) t \<Longrightarrow> P (PDUnit a) (PDPlus t u)"
huffman@25904
    60
  assumes 3: "\<And>t u v. \<lbrakk>P t v; P u v\<rbrakk> \<Longrightarrow> P (PDPlus t u) v"
huffman@25904
    61
  shows "P t u"
huffman@25904
    62
using le
huffman@25904
    63
apply (induct t arbitrary: u rule: pd_basis_induct)
huffman@25904
    64
apply (erule rev_mp)
huffman@25904
    65
apply (induct_tac u rule: pd_basis_induct)
huffman@25904
    66
apply (simp add: 1)
huffman@25904
    67
apply (simp add: lower_le_PDUnit_PDPlus_iff)
huffman@25904
    68
apply (simp add: 2)
huffman@25904
    69
apply (subst PDPlus_commute)
huffman@25904
    70
apply (simp add: 2)
huffman@25904
    71
apply (simp add: lower_le_PDPlus_iff 3)
huffman@25904
    72
done
huffman@25904
    73
huffman@25904
    74
wenzelm@62175
    75
subsection \<open>Type definition\<close>
huffman@25904
    76
wenzelm@61998
    77
typedef 'a lower_pd  ("('(_')\<flat>)") =
huffman@27373
    78
  "{S::'a pd_basis set. lower_le.ideal S}"
huffman@40888
    79
by (rule lower_le.ex_ideal)
huffman@27373
    80
huffman@41288
    81
instantiation lower_pd :: (bifinite) below
huffman@27373
    82
begin
huffman@27373
    83
huffman@27373
    84
definition
huffman@27373
    85
  "x \<sqsubseteq> y \<longleftrightarrow> Rep_lower_pd x \<subseteq> Rep_lower_pd y"
huffman@27373
    86
huffman@27373
    87
instance ..
huffman@27373
    88
end
huffman@25904
    89
huffman@41288
    90
instance lower_pd :: (bifinite) po
huffman@39984
    91
using type_definition_lower_pd below_lower_pd_def
huffman@39984
    92
by (rule lower_le.typedef_ideal_po)
huffman@27373
    93
huffman@41288
    94
instance lower_pd :: (bifinite) cpo
huffman@39984
    95
using type_definition_lower_pd below_lower_pd_def
huffman@39984
    96
by (rule lower_le.typedef_ideal_cpo)
huffman@25904
    97
huffman@25904
    98
definition
huffman@25904
    99
  lower_principal :: "'a pd_basis \<Rightarrow> 'a lower_pd" where
huffman@27373
   100
  "lower_principal t = Abs_lower_pd {u. u \<le>\<flat> t}"
huffman@25904
   101
wenzelm@30729
   102
interpretation lower_pd:
huffman@39974
   103
  ideal_completion lower_le lower_principal Rep_lower_pd
huffman@39984
   104
using type_definition_lower_pd below_lower_pd_def
huffman@39984
   105
using lower_principal_def pd_basis_countable
huffman@39984
   106
by (rule lower_le.typedef_ideal_completion)
huffman@25904
   107
wenzelm@62175
   108
text \<open>Lower powerdomain is pointed\<close>
huffman@25904
   109
huffman@25904
   110
lemma lower_pd_minimal: "lower_principal (PDUnit compact_bot) \<sqsubseteq> ys"
huffman@25904
   111
by (induct ys rule: lower_pd.principal_induct, simp, simp)
huffman@25904
   112
huffman@41288
   113
instance lower_pd :: (bifinite) pcpo
huffman@26927
   114
by intro_classes (fast intro: lower_pd_minimal)
huffman@25904
   115
huffman@25904
   116
lemma inst_lower_pd_pcpo: "\<bottom> = lower_principal (PDUnit compact_bot)"
huffman@41430
   117
by (rule lower_pd_minimal [THEN bottomI, symmetric])
huffman@25904
   118
huffman@25904
   119
wenzelm@62175
   120
subsection \<open>Monadic unit and plus\<close>
huffman@25904
   121
huffman@25904
   122
definition
huffman@25904
   123
  lower_unit :: "'a \<rightarrow> 'a lower_pd" where
huffman@41394
   124
  "lower_unit = compact_basis.extension (\<lambda>a. lower_principal (PDUnit a))"
huffman@25904
   125
huffman@25904
   126
definition
huffman@25904
   127
  lower_plus :: "'a lower_pd \<rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd" where
huffman@41394
   128
  "lower_plus = lower_pd.extension (\<lambda>t. lower_pd.extension (\<lambda>u.
huffman@25904
   129
      lower_principal (PDPlus t u)))"
huffman@25904
   130
huffman@25904
   131
abbreviation
huffman@25904
   132
  lower_add :: "'a lower_pd \<Rightarrow> 'a lower_pd \<Rightarrow> 'a lower_pd"
huffman@41399
   133
    (infixl "\<union>\<flat>" 65) where
huffman@41399
   134
  "xs \<union>\<flat> ys == lower_plus\<cdot>xs\<cdot>ys"
huffman@25904
   135
huffman@26927
   136
syntax
huffman@41479
   137
  "_lower_pd" :: "args \<Rightarrow> logic" ("{_}\<flat>")
huffman@26927
   138
huffman@26927
   139
translations
huffman@41399
   140
  "{x,xs}\<flat>" == "{x}\<flat> \<union>\<flat> {xs}\<flat>"
huffman@26927
   141
  "{x}\<flat>" == "CONST lower_unit\<cdot>x"
huffman@26927
   142
huffman@26927
   143
lemma lower_unit_Rep_compact_basis [simp]:
huffman@26927
   144
  "{Rep_compact_basis a}\<flat> = lower_principal (PDUnit a)"
huffman@26927
   145
unfolding lower_unit_def
huffman@41394
   146
by (simp add: compact_basis.extension_principal PDUnit_lower_mono)
huffman@26927
   147
huffman@25904
   148
lemma lower_plus_principal [simp]:
huffman@41399
   149
  "lower_principal t \<union>\<flat> lower_principal u = lower_principal (PDPlus t u)"
huffman@25904
   150
unfolding lower_plus_def
huffman@41394
   151
by (simp add: lower_pd.extension_principal
huffman@41394
   152
    lower_pd.extension_mono PDPlus_lower_mono)
huffman@25904
   153
haftmann@37770
   154
interpretation lower_add: semilattice lower_add proof
haftmann@34973
   155
  fix xs ys zs :: "'a lower_pd"
huffman@41399
   156
  show "(xs \<union>\<flat> ys) \<union>\<flat> zs = xs \<union>\<flat> (ys \<union>\<flat> zs)"
huffman@41402
   157
    apply (induct xs rule: lower_pd.principal_induct, simp)
huffman@41402
   158
    apply (induct ys rule: lower_pd.principal_induct, simp)
huffman@41402
   159
    apply (induct zs rule: lower_pd.principal_induct, simp)
haftmann@34973
   160
    apply (simp add: PDPlus_assoc)
haftmann@34973
   161
    done
huffman@41399
   162
  show "xs \<union>\<flat> ys = ys \<union>\<flat> xs"
huffman@41402
   163
    apply (induct xs rule: lower_pd.principal_induct, simp)
huffman@41402
   164
    apply (induct ys rule: lower_pd.principal_induct, simp)
haftmann@34973
   165
    apply (simp add: PDPlus_commute)
haftmann@34973
   166
    done
huffman@41399
   167
  show "xs \<union>\<flat> xs = xs"
haftmann@34973
   168
    apply (induct xs rule: lower_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 lower_plus_assoc = lower_add.assoc
haftmann@34973
   174
lemmas lower_plus_commute = lower_add.commute
haftmann@34973
   175
lemmas lower_plus_absorb = lower_add.idem
haftmann@34973
   176
lemmas lower_plus_left_commute = lower_add.left_commute
haftmann@34973
   177
lemmas lower_plus_left_absorb = lower_add.left_idem
huffman@26927
   178
wenzelm@62175
   179
text \<open>Useful for \<open>simp add: lower_plus_ac\<close>\<close>
huffman@29990
   180
lemmas lower_plus_ac =
huffman@29990
   181
  lower_plus_assoc lower_plus_commute lower_plus_left_commute
huffman@29990
   182
wenzelm@62175
   183
text \<open>Useful for \<open>simp only: lower_plus_aci\<close>\<close>
huffman@29990
   184
lemmas lower_plus_aci =
huffman@29990
   185
  lower_plus_ac lower_plus_absorb lower_plus_left_absorb
huffman@29990
   186
huffman@41399
   187
lemma lower_plus_below1: "xs \<sqsubseteq> xs \<union>\<flat> ys"
huffman@41402
   188
apply (induct xs rule: lower_pd.principal_induct, simp)
huffman@41402
   189
apply (induct ys rule: lower_pd.principal_induct, simp)
huffman@31076
   190
apply (simp add: PDPlus_lower_le)
huffman@25904
   191
done
huffman@25904
   192
huffman@41399
   193
lemma lower_plus_below2: "ys \<sqsubseteq> xs \<union>\<flat> ys"
huffman@31076
   194
by (subst lower_plus_commute, rule lower_plus_below1)
huffman@25904
   195
huffman@41399
   196
lemma lower_plus_least: "\<lbrakk>xs \<sqsubseteq> zs; ys \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs \<union>\<flat> ys \<sqsubseteq> zs"
huffman@25904
   197
apply (subst lower_plus_absorb [of zs, symmetric])
huffman@25904
   198
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
huffman@25904
   199
done
huffman@25904
   200
huffman@40734
   201
lemma lower_plus_below_iff [simp]:
huffman@41399
   202
  "xs \<union>\<flat> ys \<sqsubseteq> zs \<longleftrightarrow> xs \<sqsubseteq> zs \<and> ys \<sqsubseteq> zs"
huffman@25904
   203
apply safe
huffman@31076
   204
apply (erule below_trans [OF lower_plus_below1])
huffman@31076
   205
apply (erule below_trans [OF lower_plus_below2])
huffman@25904
   206
apply (erule (1) lower_plus_least)
huffman@25904
   207
done
huffman@25904
   208
huffman@40734
   209
lemma lower_unit_below_plus_iff [simp]:
huffman@41399
   210
  "{x}\<flat> \<sqsubseteq> ys \<union>\<flat> zs \<longleftrightarrow> {x}\<flat> \<sqsubseteq> ys \<or> {x}\<flat> \<sqsubseteq> zs"
brianh@39970
   211
apply (induct x rule: compact_basis.principal_induct, simp)
brianh@39970
   212
apply (induct ys rule: lower_pd.principal_induct, simp)
brianh@39970
   213
apply (induct zs rule: lower_pd.principal_induct, simp)
brianh@39970
   214
apply (simp add: lower_le_PDUnit_PDPlus_iff)
huffman@25904
   215
done
huffman@25904
   216
huffman@31076
   217
lemma lower_unit_below_iff [simp]: "{x}\<flat> \<sqsubseteq> {y}\<flat> \<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 lower_pd_below_simps =
huffman@31076
   224
  lower_unit_below_iff
huffman@31076
   225
  lower_plus_below_iff
huffman@31076
   226
  lower_unit_below_plus_iff
huffman@25904
   227
huffman@26927
   228
lemma lower_unit_eq_iff [simp]: "{x}\<flat> = {y}\<flat> \<longleftrightarrow> x = y"
huffman@29990
   229
by (simp add: po_eq_conv)
huffman@26927
   230
huffman@26927
   231
lemma lower_unit_strict [simp]: "{\<bottom>}\<flat> = \<bottom>"
huffman@39974
   232
using lower_unit_Rep_compact_basis [of compact_bot]
huffman@39974
   233
by (simp add: inst_lower_pd_pcpo)
huffman@26927
   234
huffman@40321
   235
lemma lower_unit_bottom_iff [simp]: "{x}\<flat> = \<bottom> \<longleftrightarrow> x = \<bottom>"
huffman@26927
   236
unfolding lower_unit_strict [symmetric] by (rule lower_unit_eq_iff)
huffman@26927
   237
huffman@40321
   238
lemma lower_plus_bottom_iff [simp]:
huffman@41399
   239
  "xs \<union>\<flat> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<and> ys = \<bottom>"
huffman@26927
   240
apply safe
huffman@41430
   241
apply (rule bottomI, erule subst, rule lower_plus_below1)
huffman@41430
   242
apply (rule bottomI, erule subst, rule lower_plus_below2)
huffman@26927
   243
apply (rule lower_plus_absorb)
huffman@26927
   244
done
huffman@26927
   245
huffman@41399
   246
lemma lower_plus_strict1 [simp]: "\<bottom> \<union>\<flat> ys = ys"
huffman@31076
   247
apply (rule below_antisym [OF _ lower_plus_below2])
huffman@26927
   248
apply (simp add: lower_plus_least)
huffman@26927
   249
done
huffman@26927
   250
huffman@41399
   251
lemma lower_plus_strict2 [simp]: "xs \<union>\<flat> \<bottom> = xs"
huffman@31076
   252
apply (rule below_antisym [OF _ lower_plus_below1])
huffman@26927
   253
apply (simp add: lower_plus_least)
huffman@26927
   254
done
huffman@26927
   255
huffman@39974
   256
lemma compact_lower_unit: "compact x \<Longrightarrow> compact {x}\<flat>"
huffman@39974
   257
by (auto dest!: compact_basis.compact_imp_principal)
huffman@39974
   258
huffman@26927
   259
lemma compact_lower_unit_iff [simp]: "compact {x}\<flat> \<longleftrightarrow> compact x"
huffman@39974
   260
apply (safe elim!: compact_lower_unit)
huffman@39974
   261
apply (simp only: compact_def lower_unit_below_iff [symmetric])
huffman@40327
   262
apply (erule adm_subst [OF cont_Rep_cfun2])
huffman@39974
   263
done
huffman@26927
   264
huffman@26927
   265
lemma compact_lower_plus [simp]:
huffman@41399
   266
  "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs \<union>\<flat> ys)"
huffman@27289
   267
by (auto dest!: lower_pd.compact_imp_principal)
huffman@26927
   268
huffman@25904
   269
wenzelm@62175
   270
subsection \<open>Induction rules\<close>
huffman@25904
   271
huffman@25904
   272
lemma lower_pd_induct1:
huffman@25904
   273
  assumes P: "adm P"
huffman@26927
   274
  assumes unit: "\<And>x. P {x}\<flat>"
huffman@25904
   275
  assumes insert:
huffman@41399
   276
    "\<And>x ys. \<lbrakk>P {x}\<flat>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<flat> \<union>\<flat> ys)"
huffman@25904
   277
  shows "P (xs::'a lower_pd)"
huffman@27289
   278
apply (induct xs rule: lower_pd.principal_induct, rule P)
huffman@27289
   279
apply (induct_tac a rule: pd_basis_induct1)
huffman@25904
   280
apply (simp only: lower_unit_Rep_compact_basis [symmetric])
huffman@25904
   281
apply (rule unit)
huffman@25904
   282
apply (simp only: lower_unit_Rep_compact_basis [symmetric]
huffman@25904
   283
                  lower_plus_principal [symmetric])
huffman@25904
   284
apply (erule insert [OF unit])
huffman@25904
   285
done
huffman@25904
   286
huffman@40576
   287
lemma lower_pd_induct
huffman@40576
   288
  [case_names adm lower_unit lower_plus, induct type: lower_pd]:
huffman@25904
   289
  assumes P: "adm P"
huffman@26927
   290
  assumes unit: "\<And>x. P {x}\<flat>"
huffman@41399
   291
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs \<union>\<flat> ys)"
huffman@25904
   292
  shows "P (xs::'a lower_pd)"
huffman@27289
   293
apply (induct xs rule: lower_pd.principal_induct, rule P)
huffman@27289
   294
apply (induct_tac a rule: pd_basis_induct)
huffman@25904
   295
apply (simp only: lower_unit_Rep_compact_basis [symmetric] unit)
huffman@25904
   296
apply (simp only: lower_plus_principal [symmetric] plus)
huffman@25904
   297
done
huffman@25904
   298
huffman@25904
   299
wenzelm@62175
   300
subsection \<open>Monadic bind\<close>
huffman@25904
   301
huffman@25904
   302
definition
huffman@25904
   303
  lower_bind_basis ::
huffman@25904
   304
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
huffman@25904
   305
  "lower_bind_basis = fold_pd
huffman@25904
   306
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
huffman@41399
   307
    (\<lambda>x y. \<Lambda> f. x\<cdot>f \<union>\<flat> y\<cdot>f)"
huffman@25904
   308
huffman@26927
   309
lemma ACI_lower_bind:
haftmann@51489
   310
  "semilattice (\<lambda>x y. \<Lambda> f. x\<cdot>f \<union>\<flat> y\<cdot>f)"
huffman@25904
   311
apply unfold_locales
haftmann@26041
   312
apply (simp add: lower_plus_assoc)
huffman@25904
   313
apply (simp add: lower_plus_commute)
huffman@29990
   314
apply (simp add: eta_cfun)
huffman@25904
   315
done
huffman@25904
   316
huffman@25904
   317
lemma lower_bind_basis_simps [simp]:
huffman@25904
   318
  "lower_bind_basis (PDUnit a) =
huffman@25904
   319
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
huffman@25904
   320
  "lower_bind_basis (PDPlus t u) =
huffman@41399
   321
    (\<Lambda> f. lower_bind_basis t\<cdot>f \<union>\<flat> lower_bind_basis u\<cdot>f)"
huffman@25904
   322
unfolding lower_bind_basis_def
huffman@25904
   323
apply -
huffman@26927
   324
apply (rule fold_pd_PDUnit [OF ACI_lower_bind])
huffman@26927
   325
apply (rule fold_pd_PDPlus [OF ACI_lower_bind])
huffman@25904
   326
done
huffman@25904
   327
huffman@25904
   328
lemma lower_bind_basis_mono:
huffman@25904
   329
  "t \<le>\<flat> u \<Longrightarrow> lower_bind_basis t \<sqsubseteq> lower_bind_basis u"
huffman@40002
   330
unfolding cfun_below_iff
huffman@25904
   331
apply (erule lower_le_induct, safe)
huffman@27289
   332
apply (simp add: monofun_cfun)
huffman@31076
   333
apply (simp add: rev_below_trans [OF lower_plus_below1])
huffman@40734
   334
apply simp
huffman@25904
   335
done
huffman@25904
   336
huffman@25904
   337
definition
huffman@25904
   338
  lower_bind :: "'a lower_pd \<rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
huffman@41394
   339
  "lower_bind = lower_pd.extension lower_bind_basis"
huffman@25904
   340
huffman@41036
   341
syntax
huffman@41036
   342
  "_lower_bind" :: "[logic, logic, logic] \<Rightarrow> logic"
huffman@41036
   343
    ("(3\<Union>\<flat>_\<in>_./ _)" [0, 0, 10] 10)
huffman@41036
   344
huffman@41036
   345
translations
huffman@41036
   346
  "\<Union>\<flat>x\<in>xs. e" == "CONST lower_bind\<cdot>xs\<cdot>(\<Lambda> x. e)"
huffman@41036
   347
huffman@25904
   348
lemma lower_bind_principal [simp]:
huffman@25904
   349
  "lower_bind\<cdot>(lower_principal t) = lower_bind_basis t"
huffman@25904
   350
unfolding lower_bind_def
huffman@41394
   351
apply (rule lower_pd.extension_principal)
huffman@25904
   352
apply (erule lower_bind_basis_mono)
huffman@25904
   353
done
huffman@25904
   354
huffman@25904
   355
lemma lower_bind_unit [simp]:
huffman@26927
   356
  "lower_bind\<cdot>{x}\<flat>\<cdot>f = f\<cdot>x"
huffman@27289
   357
by (induct x rule: compact_basis.principal_induct, simp, simp)
huffman@25904
   358
huffman@25904
   359
lemma lower_bind_plus [simp]:
huffman@41399
   360
  "lower_bind\<cdot>(xs \<union>\<flat> ys)\<cdot>f = lower_bind\<cdot>xs\<cdot>f \<union>\<flat> lower_bind\<cdot>ys\<cdot>f"
huffman@41402
   361
by (induct xs rule: lower_pd.principal_induct, simp,
huffman@41402
   362
    induct ys rule: lower_pd.principal_induct, simp, simp)
huffman@25904
   363
huffman@25904
   364
lemma lower_bind_strict [simp]: "lower_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
huffman@25904
   365
unfolding lower_unit_strict [symmetric] by (rule lower_bind_unit)
huffman@25904
   366
huffman@40589
   367
lemma lower_bind_bind:
huffman@40589
   368
  "lower_bind\<cdot>(lower_bind\<cdot>xs\<cdot>f)\<cdot>g = lower_bind\<cdot>xs\<cdot>(\<Lambda> x. lower_bind\<cdot>(f\<cdot>x)\<cdot>g)"
huffman@40589
   369
by (induct xs, simp_all)
huffman@40589
   370
huffman@25904
   371
wenzelm@62175
   372
subsection \<open>Map\<close>
huffman@25904
   373
huffman@25904
   374
definition
huffman@25904
   375
  lower_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a lower_pd \<rightarrow> 'b lower_pd" where
huffman@26927
   376
  "lower_map = (\<Lambda> f xs. lower_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<flat>))"
huffman@25904
   377
huffman@25904
   378
lemma lower_map_unit [simp]:
huffman@26927
   379
  "lower_map\<cdot>f\<cdot>{x}\<flat> = {f\<cdot>x}\<flat>"
huffman@25904
   380
unfolding lower_map_def by simp
huffman@25904
   381
huffman@25904
   382
lemma lower_map_plus [simp]:
huffman@41399
   383
  "lower_map\<cdot>f\<cdot>(xs \<union>\<flat> ys) = lower_map\<cdot>f\<cdot>xs \<union>\<flat> lower_map\<cdot>f\<cdot>ys"
huffman@25904
   384
unfolding lower_map_def by simp
huffman@25904
   385
huffman@40577
   386
lemma lower_map_bottom [simp]: "lower_map\<cdot>f\<cdot>\<bottom> = {f\<cdot>\<bottom>}\<flat>"
huffman@40577
   387
unfolding lower_map_def by simp
huffman@40577
   388
huffman@25904
   389
lemma lower_map_ident: "lower_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
huffman@25904
   390
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   391
huffman@33808
   392
lemma lower_map_ID: "lower_map\<cdot>ID = ID"
huffman@40002
   393
by (simp add: cfun_eq_iff ID_def lower_map_ident)
huffman@33808
   394
huffman@25904
   395
lemma lower_map_map:
huffman@25904
   396
  "lower_map\<cdot>f\<cdot>(lower_map\<cdot>g\<cdot>xs) = lower_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
huffman@25904
   397
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   398
huffman@41110
   399
lemma lower_bind_map:
huffman@41110
   400
  "lower_bind\<cdot>(lower_map\<cdot>f\<cdot>xs)\<cdot>g = lower_bind\<cdot>xs\<cdot>(\<Lambda> x. g\<cdot>(f\<cdot>x))"
huffman@41110
   401
by (simp add: lower_map_def lower_bind_bind)
huffman@41110
   402
huffman@41110
   403
lemma lower_map_bind:
huffman@41110
   404
  "lower_map\<cdot>f\<cdot>(lower_bind\<cdot>xs\<cdot>g) = lower_bind\<cdot>xs\<cdot>(\<Lambda> x. lower_map\<cdot>f\<cdot>(g\<cdot>x))"
huffman@41110
   405
by (simp add: lower_map_def lower_bind_bind)
huffman@41110
   406
huffman@33585
   407
lemma ep_pair_lower_map: "ep_pair e p \<Longrightarrow> ep_pair (lower_map\<cdot>e) (lower_map\<cdot>p)"
wenzelm@61169
   408
apply standard
huffman@33585
   409
apply (induct_tac x rule: lower_pd_induct, simp_all add: ep_pair.e_inverse)
huffman@35901
   410
apply (induct_tac y rule: lower_pd_induct)
huffman@40734
   411
apply (simp_all add: ep_pair.e_p_below monofun_cfun del: lower_plus_below_iff)
huffman@33585
   412
done
huffman@33585
   413
huffman@33585
   414
lemma deflation_lower_map: "deflation d \<Longrightarrow> deflation (lower_map\<cdot>d)"
wenzelm@61169
   415
apply standard
huffman@33585
   416
apply (induct_tac x rule: lower_pd_induct, simp_all add: deflation.idem)
huffman@35901
   417
apply (induct_tac x rule: lower_pd_induct)
huffman@40734
   418
apply (simp_all add: deflation.below monofun_cfun del: lower_plus_below_iff)
huffman@33585
   419
done
huffman@33585
   420
huffman@39974
   421
(* FIXME: long proof! *)
huffman@39974
   422
lemma finite_deflation_lower_map:
huffman@39974
   423
  assumes "finite_deflation d" shows "finite_deflation (lower_map\<cdot>d)"
huffman@39974
   424
proof (rule finite_deflation_intro)
huffman@39974
   425
  interpret d: finite_deflation d by fact
huffman@39974
   426
  have "deflation d" by fact
huffman@39974
   427
  thus "deflation (lower_map\<cdot>d)" by (rule deflation_lower_map)
huffman@39974
   428
  have "finite (range (\<lambda>x. d\<cdot>x))" by (rule d.finite_range)
huffman@39974
   429
  hence "finite (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))"
huffman@39974
   430
    by (rule finite_vimageI, simp add: inj_on_def Rep_compact_basis_inject)
huffman@39974
   431
  hence "finite (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x)))" by simp
huffman@39974
   432
  hence "finite (Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))"
huffman@39974
   433
    by (rule finite_vimageI, simp add: inj_on_def Rep_pd_basis_inject)
huffman@39974
   434
  hence *: "finite (lower_principal ` Rep_pd_basis -` (Pow (Rep_compact_basis -` range (\<lambda>x. d\<cdot>x))))" by simp
huffman@39974
   435
  hence "finite (range (\<lambda>xs. lower_map\<cdot>d\<cdot>xs))"
huffman@39974
   436
    apply (rule rev_finite_subset)
huffman@39974
   437
    apply clarsimp
huffman@39974
   438
    apply (induct_tac xs rule: lower_pd.principal_induct)
huffman@39974
   439
    apply (simp add: adm_mem_finite *)
huffman@39974
   440
    apply (rename_tac t, induct_tac t rule: pd_basis_induct)
huffman@39974
   441
    apply (simp only: lower_unit_Rep_compact_basis [symmetric] lower_map_unit)
huffman@39974
   442
    apply simp
huffman@39974
   443
    apply (subgoal_tac "\<exists>b. d\<cdot>(Rep_compact_basis a) = Rep_compact_basis b")
huffman@39974
   444
    apply clarsimp
huffman@39974
   445
    apply (rule imageI)
huffman@39974
   446
    apply (rule vimageI2)
huffman@39974
   447
    apply (simp add: Rep_PDUnit)
huffman@39974
   448
    apply (rule range_eqI)
huffman@39974
   449
    apply (erule sym)
huffman@39974
   450
    apply (rule exI)
huffman@39974
   451
    apply (rule Abs_compact_basis_inverse [symmetric])
huffman@39974
   452
    apply (simp add: d.compact)
huffman@39974
   453
    apply (simp only: lower_plus_principal [symmetric] lower_map_plus)
huffman@39974
   454
    apply clarsimp
huffman@39974
   455
    apply (rule imageI)
huffman@39974
   456
    apply (rule vimageI2)
huffman@39974
   457
    apply (simp add: Rep_PDPlus)
huffman@39974
   458
    done
huffman@39974
   459
  thus "finite {xs. lower_map\<cdot>d\<cdot>xs = xs}"
huffman@39974
   460
    by (rule finite_range_imp_finite_fixes)
huffman@39974
   461
qed
huffman@39974
   462
wenzelm@62175
   463
subsection \<open>Lower powerdomain is bifinite\<close>
huffman@39974
   464
huffman@41286
   465
lemma approx_chain_lower_map:
huffman@41286
   466
  assumes "approx_chain a"
huffman@41286
   467
  shows "approx_chain (\<lambda>i. lower_map\<cdot>(a i))"
huffman@41286
   468
  using assms unfolding approx_chain_def
huffman@41286
   469
  by (simp add: lub_APP lower_map_ID finite_deflation_lower_map)
huffman@41286
   470
huffman@41288
   471
instance lower_pd :: (bifinite) bifinite
huffman@41286
   472
proof
huffman@41286
   473
  show "\<exists>(a::nat \<Rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd). approx_chain a"
huffman@41286
   474
    using bifinite [where 'a='a]
huffman@41286
   475
    by (fast intro!: approx_chain_lower_map)
huffman@41286
   476
qed
huffman@41286
   477
wenzelm@62175
   478
subsection \<open>Join\<close>
huffman@39974
   479
huffman@39974
   480
definition
huffman@39974
   481
  lower_join :: "'a lower_pd lower_pd \<rightarrow> 'a lower_pd" where
huffman@39974
   482
  "lower_join = (\<Lambda> xss. lower_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
huffman@39974
   483
huffman@39974
   484
lemma lower_join_unit [simp]:
huffman@39974
   485
  "lower_join\<cdot>{xs}\<flat> = xs"
huffman@39974
   486
unfolding lower_join_def by simp
huffman@39974
   487
huffman@39974
   488
lemma lower_join_plus [simp]:
huffman@41399
   489
  "lower_join\<cdot>(xss \<union>\<flat> yss) = lower_join\<cdot>xss \<union>\<flat> lower_join\<cdot>yss"
huffman@39974
   490
unfolding lower_join_def by simp
huffman@39974
   491
huffman@40577
   492
lemma lower_join_bottom [simp]: "lower_join\<cdot>\<bottom> = \<bottom>"
huffman@40577
   493
unfolding lower_join_def by simp
huffman@40577
   494
huffman@39974
   495
lemma lower_join_map_unit:
huffman@39974
   496
  "lower_join\<cdot>(lower_map\<cdot>lower_unit\<cdot>xs) = xs"
huffman@39974
   497
by (induct xs rule: lower_pd_induct, simp_all)
huffman@39974
   498
huffman@39974
   499
lemma lower_join_map_join:
huffman@39974
   500
  "lower_join\<cdot>(lower_map\<cdot>lower_join\<cdot>xsss) = lower_join\<cdot>(lower_join\<cdot>xsss)"
huffman@39974
   501
by (induct xsss rule: lower_pd_induct, simp_all)
huffman@39974
   502
huffman@39974
   503
lemma lower_join_map_map:
huffman@39974
   504
  "lower_join\<cdot>(lower_map\<cdot>(lower_map\<cdot>f)\<cdot>xss) =
huffman@39974
   505
   lower_map\<cdot>f\<cdot>(lower_join\<cdot>xss)"
huffman@39974
   506
by (induct xss rule: lower_pd_induct, simp_all)
huffman@39974
   507
huffman@39974
   508
end