src/HOLCF/LowerPD.thy
author huffman
Mon May 11 08:28:09 2009 -0700 (2009-05-11)
changeset 31095 b79d140f6d0b
parent 31076 99fe356cbbc2
child 33585 8d39394fe5cf
permissions -rw-r--r--
simplify fixrec proofs for mutually-recursive definitions; generate better fixpoint induction rules
huffman@25904
     1
(*  Title:      HOLCF/LowerPD.thy
huffman@25904
     2
    Author:     Brian Huffman
huffman@25904
     3
*)
huffman@25904
     4
huffman@25904
     5
header {* Lower powerdomain *}
huffman@25904
     6
huffman@25904
     7
theory LowerPD
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
  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@26420
    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@27405
    74
lemma pd_take_lower_chain:
huffman@27405
    75
  "pd_take n t \<le>\<flat> pd_take (Suc n) t"
huffman@25904
    76
apply (induct t rule: pd_basis_induct)
huffman@27289
    77
apply (simp add: compact_basis.take_chain)
huffman@25904
    78
apply (simp add: PDPlus_lower_mono)
huffman@25904
    79
done
huffman@25904
    80
huffman@27405
    81
lemma pd_take_lower_le: "pd_take i t \<le>\<flat> t"
huffman@25904
    82
apply (induct t rule: pd_basis_induct)
huffman@27289
    83
apply (simp add: compact_basis.take_less)
huffman@25904
    84
apply (simp add: PDPlus_lower_mono)
huffman@25904
    85
done
huffman@25904
    86
huffman@27405
    87
lemma pd_take_lower_mono:
huffman@27405
    88
  "t \<le>\<flat> u \<Longrightarrow> pd_take n t \<le>\<flat> pd_take n u"
huffman@25904
    89
apply (erule lower_le_induct)
huffman@27289
    90
apply (simp add: compact_basis.take_mono)
huffman@25904
    91
apply (simp add: lower_le_PDUnit_PDPlus_iff)
huffman@25904
    92
apply (simp add: lower_le_PDPlus_iff)
huffman@25904
    93
done
huffman@25904
    94
huffman@25904
    95
huffman@25904
    96
subsection {* Type definition *}
huffman@25904
    97
huffman@27373
    98
typedef (open) 'a lower_pd =
huffman@27373
    99
  "{S::'a pd_basis set. lower_le.ideal S}"
huffman@27373
   100
by (fast intro: lower_le.ideal_principal)
huffman@27373
   101
huffman@31076
   102
instantiation lower_pd :: (profinite) below
huffman@27373
   103
begin
huffman@27373
   104
huffman@27373
   105
definition
huffman@27373
   106
  "x \<sqsubseteq> y \<longleftrightarrow> Rep_lower_pd x \<subseteq> Rep_lower_pd y"
huffman@27373
   107
huffman@27373
   108
instance ..
huffman@27373
   109
end
huffman@25904
   110
huffman@27373
   111
instance lower_pd :: (profinite) po
huffman@27373
   112
by (rule lower_le.typedef_ideal_po
huffman@31076
   113
    [OF type_definition_lower_pd below_lower_pd_def])
huffman@27373
   114
huffman@27373
   115
instance lower_pd :: (profinite) cpo
huffman@27373
   116
by (rule lower_le.typedef_ideal_cpo
huffman@31076
   117
    [OF type_definition_lower_pd below_lower_pd_def])
huffman@27373
   118
huffman@27373
   119
lemma Rep_lower_pd_lub:
huffman@27373
   120
  "chain Y \<Longrightarrow> Rep_lower_pd (\<Squnion>i. Y i) = (\<Union>i. Rep_lower_pd (Y i))"
huffman@27373
   121
by (rule lower_le.typedef_ideal_rep_contlub
huffman@31076
   122
    [OF type_definition_lower_pd below_lower_pd_def])
huffman@27373
   123
huffman@27373
   124
lemma ideal_Rep_lower_pd: "lower_le.ideal (Rep_lower_pd xs)"
huffman@26927
   125
by (rule Rep_lower_pd [unfolded mem_Collect_eq])
huffman@25904
   126
huffman@25904
   127
definition
huffman@25904
   128
  lower_principal :: "'a pd_basis \<Rightarrow> 'a lower_pd" where
huffman@27373
   129
  "lower_principal t = Abs_lower_pd {u. u \<le>\<flat> t}"
huffman@25904
   130
huffman@25904
   131
lemma Rep_lower_principal:
huffman@27373
   132
  "Rep_lower_pd (lower_principal t) = {u. u \<le>\<flat> t}"
huffman@25904
   133
unfolding lower_principal_def
huffman@27297
   134
by (simp add: Abs_lower_pd_inverse lower_le.ideal_principal)
huffman@25904
   135
wenzelm@30729
   136
interpretation lower_pd:
ballarin@29237
   137
  ideal_completion lower_le pd_take lower_principal Rep_lower_pd
huffman@25904
   138
apply unfold_locales
huffman@27405
   139
apply (rule pd_take_lower_le)
huffman@27405
   140
apply (rule pd_take_idem)
huffman@27405
   141
apply (erule pd_take_lower_mono)
huffman@27405
   142
apply (rule pd_take_lower_chain)
huffman@27405
   143
apply (rule finite_range_pd_take)
huffman@27405
   144
apply (rule pd_take_covers)
huffman@26420
   145
apply (rule ideal_Rep_lower_pd)
huffman@27373
   146
apply (erule Rep_lower_pd_lub)
huffman@26420
   147
apply (rule Rep_lower_principal)
huffman@31076
   148
apply (simp only: below_lower_pd_def)
huffman@25904
   149
done
huffman@25904
   150
huffman@27289
   151
text {* Lower powerdomain is pointed *}
huffman@25904
   152
huffman@25904
   153
lemma lower_pd_minimal: "lower_principal (PDUnit compact_bot) \<sqsubseteq> ys"
huffman@25904
   154
by (induct ys rule: lower_pd.principal_induct, simp, simp)
huffman@25904
   155
huffman@25904
   156
instance lower_pd :: (bifinite) pcpo
huffman@26927
   157
by intro_classes (fast intro: lower_pd_minimal)
huffman@25904
   158
huffman@25904
   159
lemma inst_lower_pd_pcpo: "\<bottom> = lower_principal (PDUnit compact_bot)"
huffman@25904
   160
by (rule lower_pd_minimal [THEN UU_I, symmetric])
huffman@25904
   161
huffman@27289
   162
text {* Lower powerdomain is profinite *}
huffman@25904
   163
huffman@26962
   164
instantiation lower_pd :: (profinite) profinite
huffman@26962
   165
begin
huffman@25904
   166
huffman@26962
   167
definition
huffman@26962
   168
  approx_lower_pd_def: "approx = lower_pd.completion_approx"
huffman@26927
   169
huffman@26962
   170
instance
huffman@26927
   171
apply (intro_classes, unfold approx_lower_pd_def)
huffman@27310
   172
apply (rule lower_pd.chain_completion_approx)
huffman@26927
   173
apply (rule lower_pd.lub_completion_approx)
huffman@26927
   174
apply (rule lower_pd.completion_approx_idem)
huffman@26927
   175
apply (rule lower_pd.finite_fixes_completion_approx)
huffman@26927
   176
done
huffman@26927
   177
huffman@26962
   178
end
huffman@26962
   179
huffman@26927
   180
instance lower_pd :: (bifinite) bifinite ..
huffman@25904
   181
huffman@25904
   182
lemma approx_lower_principal [simp]:
huffman@27405
   183
  "approx n\<cdot>(lower_principal t) = lower_principal (pd_take n t)"
huffman@25904
   184
unfolding approx_lower_pd_def
huffman@26927
   185
by (rule lower_pd.completion_approx_principal)
huffman@25904
   186
huffman@25904
   187
lemma approx_eq_lower_principal:
huffman@27405
   188
  "\<exists>t\<in>Rep_lower_pd xs. approx n\<cdot>xs = lower_principal (pd_take n t)"
huffman@25904
   189
unfolding approx_lower_pd_def
huffman@26927
   190
by (rule lower_pd.completion_approx_eq_principal)
huffman@26407
   191
huffman@25904
   192
huffman@26927
   193
subsection {* Monadic unit and plus *}
huffman@25904
   194
huffman@25904
   195
definition
huffman@25904
   196
  lower_unit :: "'a \<rightarrow> 'a lower_pd" where
huffman@25904
   197
  "lower_unit = compact_basis.basis_fun (\<lambda>a. lower_principal (PDUnit a))"
huffman@25904
   198
huffman@25904
   199
definition
huffman@25904
   200
  lower_plus :: "'a lower_pd \<rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd" where
huffman@25904
   201
  "lower_plus = lower_pd.basis_fun (\<lambda>t. lower_pd.basis_fun (\<lambda>u.
huffman@25904
   202
      lower_principal (PDPlus t u)))"
huffman@25904
   203
huffman@25904
   204
abbreviation
huffman@25904
   205
  lower_add :: "'a lower_pd \<Rightarrow> 'a lower_pd \<Rightarrow> 'a lower_pd"
huffman@25904
   206
    (infixl "+\<flat>" 65) where
huffman@25904
   207
  "xs +\<flat> ys == lower_plus\<cdot>xs\<cdot>ys"
huffman@25904
   208
huffman@26927
   209
syntax
huffman@26927
   210
  "_lower_pd" :: "args \<Rightarrow> 'a lower_pd" ("{_}\<flat>")
huffman@26927
   211
huffman@26927
   212
translations
huffman@26927
   213
  "{x,xs}\<flat>" == "{x}\<flat> +\<flat> {xs}\<flat>"
huffman@26927
   214
  "{x}\<flat>" == "CONST lower_unit\<cdot>x"
huffman@26927
   215
huffman@26927
   216
lemma lower_unit_Rep_compact_basis [simp]:
huffman@26927
   217
  "{Rep_compact_basis a}\<flat> = lower_principal (PDUnit a)"
huffman@26927
   218
unfolding lower_unit_def
huffman@27289
   219
by (simp add: compact_basis.basis_fun_principal PDUnit_lower_mono)
huffman@26927
   220
huffman@25904
   221
lemma lower_plus_principal [simp]:
huffman@26927
   222
  "lower_principal t +\<flat> lower_principal u = lower_principal (PDPlus t u)"
huffman@25904
   223
unfolding lower_plus_def
huffman@25904
   224
by (simp add: lower_pd.basis_fun_principal
huffman@25904
   225
    lower_pd.basis_fun_mono PDPlus_lower_mono)
huffman@25904
   226
huffman@26927
   227
lemma approx_lower_unit [simp]:
huffman@26927
   228
  "approx n\<cdot>{x}\<flat> = {approx n\<cdot>x}\<flat>"
huffman@27289
   229
apply (induct x rule: compact_basis.principal_induct, simp)
huffman@26927
   230
apply (simp add: approx_Rep_compact_basis)
huffman@26927
   231
done
huffman@26927
   232
huffman@25904
   233
lemma approx_lower_plus [simp]:
huffman@26927
   234
  "approx n\<cdot>(xs +\<flat> ys) = (approx n\<cdot>xs) +\<flat> (approx n\<cdot>ys)"
huffman@27289
   235
by (induct xs ys rule: lower_pd.principal_induct2, simp, simp, simp)
huffman@25904
   236
huffman@26927
   237
lemma lower_plus_assoc: "(xs +\<flat> ys) +\<flat> zs = xs +\<flat> (ys +\<flat> zs)"
huffman@27289
   238
apply (induct xs ys arbitrary: zs rule: lower_pd.principal_induct2, simp, simp)
huffman@27289
   239
apply (rule_tac x=zs in lower_pd.principal_induct, simp)
huffman@25904
   240
apply (simp add: PDPlus_assoc)
huffman@25904
   241
done
huffman@25904
   242
huffman@26927
   243
lemma lower_plus_commute: "xs +\<flat> ys = ys +\<flat> xs"
huffman@27289
   244
apply (induct xs ys rule: lower_pd.principal_induct2, simp, simp)
huffman@26927
   245
apply (simp add: PDPlus_commute)
huffman@26927
   246
done
huffman@26927
   247
huffman@29990
   248
lemma lower_plus_absorb [simp]: "xs +\<flat> xs = xs"
huffman@27289
   249
apply (induct xs rule: lower_pd.principal_induct, simp)
huffman@25904
   250
apply (simp add: PDPlus_absorb)
huffman@25904
   251
done
huffman@25904
   252
huffman@29990
   253
lemma lower_plus_left_commute: "xs +\<flat> (ys +\<flat> zs) = ys +\<flat> (xs +\<flat> zs)"
huffman@29990
   254
by (rule mk_left_commute [of "op +\<flat>", OF lower_plus_assoc lower_plus_commute])
huffman@26927
   255
huffman@29990
   256
lemma lower_plus_left_absorb [simp]: "xs +\<flat> (xs +\<flat> ys) = xs +\<flat> ys"
huffman@29990
   257
by (simp only: lower_plus_assoc [symmetric] lower_plus_absorb)
huffman@26927
   258
huffman@29990
   259
text {* Useful for @{text "simp add: lower_plus_ac"} *}
huffman@29990
   260
lemmas lower_plus_ac =
huffman@29990
   261
  lower_plus_assoc lower_plus_commute lower_plus_left_commute
huffman@29990
   262
huffman@29990
   263
text {* Useful for @{text "simp only: lower_plus_aci"} *}
huffman@29990
   264
lemmas lower_plus_aci =
huffman@29990
   265
  lower_plus_ac lower_plus_absorb lower_plus_left_absorb
huffman@29990
   266
huffman@31076
   267
lemma lower_plus_below1: "xs \<sqsubseteq> xs +\<flat> ys"
huffman@27289
   268
apply (induct xs ys rule: lower_pd.principal_induct2, simp, simp)
huffman@31076
   269
apply (simp add: PDPlus_lower_le)
huffman@25904
   270
done
huffman@25904
   271
huffman@31076
   272
lemma lower_plus_below2: "ys \<sqsubseteq> xs +\<flat> ys"
huffman@31076
   273
by (subst lower_plus_commute, rule lower_plus_below1)
huffman@25904
   274
huffman@26927
   275
lemma lower_plus_least: "\<lbrakk>xs \<sqsubseteq> zs; ys \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs +\<flat> ys \<sqsubseteq> zs"
huffman@25904
   276
apply (subst lower_plus_absorb [of zs, symmetric])
huffman@25904
   277
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
huffman@25904
   278
done
huffman@25904
   279
huffman@31076
   280
lemma lower_plus_below_iff:
huffman@26927
   281
  "xs +\<flat> ys \<sqsubseteq> zs \<longleftrightarrow> xs \<sqsubseteq> zs \<and> ys \<sqsubseteq> zs"
huffman@25904
   282
apply safe
huffman@31076
   283
apply (erule below_trans [OF lower_plus_below1])
huffman@31076
   284
apply (erule below_trans [OF lower_plus_below2])
huffman@25904
   285
apply (erule (1) lower_plus_least)
huffman@25904
   286
done
huffman@25904
   287
huffman@31076
   288
lemma lower_unit_below_plus_iff:
huffman@26927
   289
  "{x}\<flat> \<sqsubseteq> ys +\<flat> zs \<longleftrightarrow> {x}\<flat> \<sqsubseteq> ys \<or> {x}\<flat> \<sqsubseteq> zs"
huffman@25904
   290
 apply (rule iffI)
huffman@25904
   291
  apply (subgoal_tac
huffman@26927
   292
    "adm (\<lambda>f. f\<cdot>{x}\<flat> \<sqsubseteq> f\<cdot>ys \<or> f\<cdot>{x}\<flat> \<sqsubseteq> f\<cdot>zs)")
huffman@25925
   293
   apply (drule admD, rule chain_approx)
huffman@25904
   294
    apply (drule_tac f="approx i" in monofun_cfun_arg)
huffman@27289
   295
    apply (cut_tac x="approx i\<cdot>x" in compact_basis.compact_imp_principal, simp)
huffman@27289
   296
    apply (cut_tac x="approx i\<cdot>ys" in lower_pd.compact_imp_principal, simp)
huffman@27289
   297
    apply (cut_tac x="approx i\<cdot>zs" in lower_pd.compact_imp_principal, simp)
huffman@25904
   298
    apply (clarify, simp add: lower_le_PDUnit_PDPlus_iff)
huffman@25904
   299
   apply simp
huffman@25904
   300
  apply simp
huffman@25904
   301
 apply (erule disjE)
huffman@31076
   302
  apply (erule below_trans [OF _ lower_plus_below1])
huffman@31076
   303
 apply (erule below_trans [OF _ lower_plus_below2])
huffman@25904
   304
done
huffman@25904
   305
huffman@31076
   306
lemma lower_unit_below_iff [simp]: "{x}\<flat> \<sqsubseteq> {y}\<flat> \<longleftrightarrow> x \<sqsubseteq> y"
huffman@26927
   307
 apply (rule iffI)
huffman@31076
   308
  apply (rule profinite_below_ext)
huffman@26927
   309
  apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
huffman@27289
   310
  apply (cut_tac x="approx i\<cdot>x" in compact_basis.compact_imp_principal, simp)
huffman@27289
   311
  apply (cut_tac x="approx i\<cdot>y" in compact_basis.compact_imp_principal, simp)
huffman@27289
   312
  apply clarsimp
huffman@26927
   313
 apply (erule monofun_cfun_arg)
huffman@26927
   314
done
huffman@26927
   315
huffman@31076
   316
lemmas lower_pd_below_simps =
huffman@31076
   317
  lower_unit_below_iff
huffman@31076
   318
  lower_plus_below_iff
huffman@31076
   319
  lower_unit_below_plus_iff
huffman@25904
   320
huffman@26927
   321
lemma lower_unit_eq_iff [simp]: "{x}\<flat> = {y}\<flat> \<longleftrightarrow> x = y"
huffman@29990
   322
by (simp add: po_eq_conv)
huffman@26927
   323
huffman@26927
   324
lemma lower_unit_strict [simp]: "{\<bottom>}\<flat> = \<bottom>"
huffman@26927
   325
unfolding inst_lower_pd_pcpo Rep_compact_bot [symmetric] by simp
huffman@26927
   326
huffman@26927
   327
lemma lower_unit_strict_iff [simp]: "{x}\<flat> = \<bottom> \<longleftrightarrow> x = \<bottom>"
huffman@26927
   328
unfolding lower_unit_strict [symmetric] by (rule lower_unit_eq_iff)
huffman@26927
   329
huffman@26927
   330
lemma lower_plus_strict_iff [simp]:
huffman@26927
   331
  "xs +\<flat> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<and> ys = \<bottom>"
huffman@26927
   332
apply safe
huffman@31076
   333
apply (rule UU_I, erule subst, rule lower_plus_below1)
huffman@31076
   334
apply (rule UU_I, erule subst, rule lower_plus_below2)
huffman@26927
   335
apply (rule lower_plus_absorb)
huffman@26927
   336
done
huffman@26927
   337
huffman@26927
   338
lemma lower_plus_strict1 [simp]: "\<bottom> +\<flat> ys = ys"
huffman@31076
   339
apply (rule below_antisym [OF _ lower_plus_below2])
huffman@26927
   340
apply (simp add: lower_plus_least)
huffman@26927
   341
done
huffman@26927
   342
huffman@26927
   343
lemma lower_plus_strict2 [simp]: "xs +\<flat> \<bottom> = xs"
huffman@31076
   344
apply (rule below_antisym [OF _ lower_plus_below1])
huffman@26927
   345
apply (simp add: lower_plus_least)
huffman@26927
   346
done
huffman@26927
   347
huffman@26927
   348
lemma compact_lower_unit_iff [simp]: "compact {x}\<flat> \<longleftrightarrow> compact x"
huffman@27309
   349
unfolding profinite_compact_iff by simp
huffman@26927
   350
huffman@26927
   351
lemma compact_lower_plus [simp]:
huffman@26927
   352
  "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs +\<flat> ys)"
huffman@27289
   353
by (auto dest!: lower_pd.compact_imp_principal)
huffman@26927
   354
huffman@25904
   355
huffman@25904
   356
subsection {* Induction rules *}
huffman@25904
   357
huffman@25904
   358
lemma lower_pd_induct1:
huffman@25904
   359
  assumes P: "adm P"
huffman@26927
   360
  assumes unit: "\<And>x. P {x}\<flat>"
huffman@25904
   361
  assumes insert:
huffman@26927
   362
    "\<And>x ys. \<lbrakk>P {x}\<flat>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<flat> +\<flat> ys)"
huffman@25904
   363
  shows "P (xs::'a lower_pd)"
huffman@27289
   364
apply (induct xs rule: lower_pd.principal_induct, rule P)
huffman@27289
   365
apply (induct_tac a rule: pd_basis_induct1)
huffman@25904
   366
apply (simp only: lower_unit_Rep_compact_basis [symmetric])
huffman@25904
   367
apply (rule unit)
huffman@25904
   368
apply (simp only: lower_unit_Rep_compact_basis [symmetric]
huffman@25904
   369
                  lower_plus_principal [symmetric])
huffman@25904
   370
apply (erule insert [OF unit])
huffman@25904
   371
done
huffman@25904
   372
huffman@25904
   373
lemma lower_pd_induct:
huffman@25904
   374
  assumes P: "adm P"
huffman@26927
   375
  assumes unit: "\<And>x. P {x}\<flat>"
huffman@26927
   376
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs +\<flat> ys)"
huffman@25904
   377
  shows "P (xs::'a lower_pd)"
huffman@27289
   378
apply (induct xs rule: lower_pd.principal_induct, rule P)
huffman@27289
   379
apply (induct_tac a rule: pd_basis_induct)
huffman@25904
   380
apply (simp only: lower_unit_Rep_compact_basis [symmetric] unit)
huffman@25904
   381
apply (simp only: lower_plus_principal [symmetric] plus)
huffman@25904
   382
done
huffman@25904
   383
huffman@25904
   384
huffman@25904
   385
subsection {* Monadic bind *}
huffman@25904
   386
huffman@25904
   387
definition
huffman@25904
   388
  lower_bind_basis ::
huffman@25904
   389
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
huffman@25904
   390
  "lower_bind_basis = fold_pd
huffman@25904
   391
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
huffman@26927
   392
    (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<flat> y\<cdot>f)"
huffman@25904
   393
huffman@26927
   394
lemma ACI_lower_bind:
huffman@26927
   395
  "ab_semigroup_idem_mult (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<flat> y\<cdot>f)"
huffman@25904
   396
apply unfold_locales
haftmann@26041
   397
apply (simp add: lower_plus_assoc)
huffman@25904
   398
apply (simp add: lower_plus_commute)
huffman@29990
   399
apply (simp add: eta_cfun)
huffman@25904
   400
done
huffman@25904
   401
huffman@25904
   402
lemma lower_bind_basis_simps [simp]:
huffman@25904
   403
  "lower_bind_basis (PDUnit a) =
huffman@25904
   404
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
huffman@25904
   405
  "lower_bind_basis (PDPlus t u) =
huffman@26927
   406
    (\<Lambda> f. lower_bind_basis t\<cdot>f +\<flat> lower_bind_basis u\<cdot>f)"
huffman@25904
   407
unfolding lower_bind_basis_def
huffman@25904
   408
apply -
huffman@26927
   409
apply (rule fold_pd_PDUnit [OF ACI_lower_bind])
huffman@26927
   410
apply (rule fold_pd_PDPlus [OF ACI_lower_bind])
huffman@25904
   411
done
huffman@25904
   412
huffman@25904
   413
lemma lower_bind_basis_mono:
huffman@25904
   414
  "t \<le>\<flat> u \<Longrightarrow> lower_bind_basis t \<sqsubseteq> lower_bind_basis u"
huffman@31076
   415
unfolding expand_cfun_below
huffman@25904
   416
apply (erule lower_le_induct, safe)
huffman@27289
   417
apply (simp add: monofun_cfun)
huffman@31076
   418
apply (simp add: rev_below_trans [OF lower_plus_below1])
huffman@31076
   419
apply (simp add: lower_plus_below_iff)
huffman@25904
   420
done
huffman@25904
   421
huffman@25904
   422
definition
huffman@25904
   423
  lower_bind :: "'a lower_pd \<rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
huffman@25904
   424
  "lower_bind = lower_pd.basis_fun lower_bind_basis"
huffman@25904
   425
huffman@25904
   426
lemma lower_bind_principal [simp]:
huffman@25904
   427
  "lower_bind\<cdot>(lower_principal t) = lower_bind_basis t"
huffman@25904
   428
unfolding lower_bind_def
huffman@25904
   429
apply (rule lower_pd.basis_fun_principal)
huffman@25904
   430
apply (erule lower_bind_basis_mono)
huffman@25904
   431
done
huffman@25904
   432
huffman@25904
   433
lemma lower_bind_unit [simp]:
huffman@26927
   434
  "lower_bind\<cdot>{x}\<flat>\<cdot>f = f\<cdot>x"
huffman@27289
   435
by (induct x rule: compact_basis.principal_induct, simp, simp)
huffman@25904
   436
huffman@25904
   437
lemma lower_bind_plus [simp]:
huffman@26927
   438
  "lower_bind\<cdot>(xs +\<flat> ys)\<cdot>f = lower_bind\<cdot>xs\<cdot>f +\<flat> lower_bind\<cdot>ys\<cdot>f"
huffman@27289
   439
by (induct xs ys rule: lower_pd.principal_induct2, simp, simp, simp)
huffman@25904
   440
huffman@25904
   441
lemma lower_bind_strict [simp]: "lower_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
huffman@25904
   442
unfolding lower_unit_strict [symmetric] by (rule lower_bind_unit)
huffman@25904
   443
huffman@25904
   444
huffman@25904
   445
subsection {* Map and join *}
huffman@25904
   446
huffman@25904
   447
definition
huffman@25904
   448
  lower_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a lower_pd \<rightarrow> 'b lower_pd" where
huffman@26927
   449
  "lower_map = (\<Lambda> f xs. lower_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<flat>))"
huffman@25904
   450
huffman@25904
   451
definition
huffman@25904
   452
  lower_join :: "'a lower_pd lower_pd \<rightarrow> 'a lower_pd" where
huffman@25904
   453
  "lower_join = (\<Lambda> xss. lower_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
huffman@25904
   454
huffman@25904
   455
lemma lower_map_unit [simp]:
huffman@26927
   456
  "lower_map\<cdot>f\<cdot>{x}\<flat> = {f\<cdot>x}\<flat>"
huffman@25904
   457
unfolding lower_map_def by simp
huffman@25904
   458
huffman@25904
   459
lemma lower_map_plus [simp]:
huffman@26927
   460
  "lower_map\<cdot>f\<cdot>(xs +\<flat> ys) = lower_map\<cdot>f\<cdot>xs +\<flat> lower_map\<cdot>f\<cdot>ys"
huffman@25904
   461
unfolding lower_map_def by simp
huffman@25904
   462
huffman@25904
   463
lemma lower_join_unit [simp]:
huffman@26927
   464
  "lower_join\<cdot>{xs}\<flat> = xs"
huffman@25904
   465
unfolding lower_join_def by simp
huffman@25904
   466
huffman@25904
   467
lemma lower_join_plus [simp]:
huffman@26927
   468
  "lower_join\<cdot>(xss +\<flat> yss) = lower_join\<cdot>xss +\<flat> lower_join\<cdot>yss"
huffman@25904
   469
unfolding lower_join_def by simp
huffman@25904
   470
huffman@25904
   471
lemma lower_map_ident: "lower_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
huffman@25904
   472
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   473
huffman@25904
   474
lemma lower_map_map:
huffman@25904
   475
  "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
   476
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   477
huffman@25904
   478
lemma lower_join_map_unit:
huffman@25904
   479
  "lower_join\<cdot>(lower_map\<cdot>lower_unit\<cdot>xs) = xs"
huffman@25904
   480
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   481
huffman@25904
   482
lemma lower_join_map_join:
huffman@25904
   483
  "lower_join\<cdot>(lower_map\<cdot>lower_join\<cdot>xsss) = lower_join\<cdot>(lower_join\<cdot>xsss)"
huffman@25904
   484
by (induct xsss rule: lower_pd_induct, simp_all)
huffman@25904
   485
huffman@25904
   486
lemma lower_join_map_map:
huffman@25904
   487
  "lower_join\<cdot>(lower_map\<cdot>(lower_map\<cdot>f)\<cdot>xss) =
huffman@25904
   488
   lower_map\<cdot>f\<cdot>(lower_join\<cdot>xss)"
huffman@25904
   489
by (induct xss rule: lower_pd_induct, simp_all)
huffman@25904
   490
huffman@25904
   491
lemma lower_map_approx: "lower_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
huffman@25904
   492
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   493
huffman@25904
   494
end