src/HOLCF/LowerPD.thy
author huffman
Thu Jun 26 17:54:05 2008 +0200 (2008-06-26)
changeset 27373 5794a0e3e26c
parent 27310 d0229bc6c461
child 27405 785f5dbec8f4
permissions -rw-r--r--
remove cset theory; define ideal completions using typedef instead of cpodef
huffman@25904
     1
(*  Title:      HOLCF/LowerPD.thy
huffman@25904
     2
    ID:         $Id$
huffman@25904
     3
    Author:     Brian Huffman
huffman@25904
     4
*)
huffman@25904
     5
huffman@25904
     6
header {* Lower powerdomain *}
huffman@25904
     7
huffman@25904
     8
theory LowerPD
huffman@25904
     9
imports CompactBasis
huffman@25904
    10
begin
huffman@25904
    11
huffman@25904
    12
subsection {* Basis preorder *}
huffman@25904
    13
huffman@25904
    14
definition
huffman@25904
    15
  lower_le :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> bool" (infix "\<le>\<flat>" 50) where
huffman@26420
    16
  "lower_le = (\<lambda>u v. \<forall>x\<in>Rep_pd_basis u. \<exists>y\<in>Rep_pd_basis v. x \<sqsubseteq> y)"
huffman@25904
    17
huffman@25904
    18
lemma lower_le_refl [simp]: "t \<le>\<flat> t"
huffman@26420
    19
unfolding lower_le_def by fast
huffman@25904
    20
huffman@25904
    21
lemma lower_le_trans: "\<lbrakk>t \<le>\<flat> u; u \<le>\<flat> v\<rbrakk> \<Longrightarrow> t \<le>\<flat> v"
huffman@25904
    22
unfolding lower_le_def
huffman@25904
    23
apply (rule ballI)
huffman@25904
    24
apply (drule (1) bspec, erule bexE)
huffman@25904
    25
apply (drule (1) bspec, erule bexE)
huffman@25904
    26
apply (erule rev_bexI)
huffman@26420
    27
apply (erule (1) trans_less)
huffman@25904
    28
done
huffman@25904
    29
huffman@25904
    30
interpretation lower_le: preorder [lower_le]
huffman@25904
    31
by (rule preorder.intro, rule lower_le_refl, rule lower_le_trans)
huffman@25904
    32
huffman@25904
    33
lemma lower_le_minimal [simp]: "PDUnit compact_bot \<le>\<flat> t"
huffman@25904
    34
unfolding lower_le_def Rep_PDUnit
huffman@25904
    35
by (simp, rule Rep_pd_basis_nonempty [folded ex_in_conv])
huffman@25904
    36
huffman@26420
    37
lemma PDUnit_lower_mono: "x \<sqsubseteq> y \<Longrightarrow> PDUnit x \<le>\<flat> PDUnit y"
huffman@25904
    38
unfolding lower_le_def Rep_PDUnit by fast
huffman@25904
    39
huffman@25904
    40
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
    41
unfolding lower_le_def Rep_PDPlus by fast
huffman@25904
    42
huffman@25904
    43
lemma PDPlus_lower_less: "t \<le>\<flat> PDPlus t u"
huffman@26420
    44
unfolding lower_le_def Rep_PDPlus by fast
huffman@25904
    45
huffman@25904
    46
lemma lower_le_PDUnit_PDUnit_iff [simp]:
huffman@26420
    47
  "(PDUnit a \<le>\<flat> PDUnit b) = a \<sqsubseteq> b"
huffman@25904
    48
unfolding lower_le_def Rep_PDUnit by fast
huffman@25904
    49
huffman@25904
    50
lemma lower_le_PDUnit_PDPlus_iff:
huffman@25904
    51
  "(PDUnit a \<le>\<flat> PDPlus t u) = (PDUnit a \<le>\<flat> t \<or> PDUnit a \<le>\<flat> u)"
huffman@25904
    52
unfolding lower_le_def Rep_PDPlus Rep_PDUnit by fast
huffman@25904
    53
huffman@25904
    54
lemma lower_le_PDPlus_iff: "(PDPlus t u \<le>\<flat> v) = (t \<le>\<flat> v \<and> u \<le>\<flat> v)"
huffman@25904
    55
unfolding lower_le_def Rep_PDPlus by fast
huffman@25904
    56
huffman@25904
    57
lemma lower_le_induct [induct set: lower_le]:
huffman@25904
    58
  assumes le: "t \<le>\<flat> u"
huffman@26420
    59
  assumes 1: "\<And>a b. a \<sqsubseteq> b \<Longrightarrow> P (PDUnit a) (PDUnit b)"
huffman@25904
    60
  assumes 2: "\<And>t u a. P (PDUnit a) t \<Longrightarrow> P (PDUnit a) (PDPlus t u)"
huffman@25904
    61
  assumes 3: "\<And>t u v. \<lbrakk>P t v; P u v\<rbrakk> \<Longrightarrow> P (PDPlus t u) v"
huffman@25904
    62
  shows "P t u"
huffman@25904
    63
using le
huffman@25904
    64
apply (induct t arbitrary: u rule: pd_basis_induct)
huffman@25904
    65
apply (erule rev_mp)
huffman@25904
    66
apply (induct_tac u rule: pd_basis_induct)
huffman@25904
    67
apply (simp add: 1)
huffman@25904
    68
apply (simp add: lower_le_PDUnit_PDPlus_iff)
huffman@25904
    69
apply (simp add: 2)
huffman@25904
    70
apply (subst PDPlus_commute)
huffman@25904
    71
apply (simp add: 2)
huffman@25904
    72
apply (simp add: lower_le_PDPlus_iff 3)
huffman@25904
    73
done
huffman@25904
    74
huffman@27289
    75
lemma approx_pd_lower_chain:
huffman@27289
    76
  "approx_pd n t \<le>\<flat> approx_pd (Suc n) t"
huffman@25904
    77
apply (induct t rule: pd_basis_induct)
huffman@27289
    78
apply (simp add: compact_basis.take_chain)
huffman@25904
    79
apply (simp add: PDPlus_lower_mono)
huffman@25904
    80
done
huffman@25904
    81
huffman@25904
    82
lemma approx_pd_lower_le: "approx_pd i t \<le>\<flat> t"
huffman@25904
    83
apply (induct t rule: pd_basis_induct)
huffman@27289
    84
apply (simp add: compact_basis.take_less)
huffman@25904
    85
apply (simp add: PDPlus_lower_mono)
huffman@25904
    86
done
huffman@25904
    87
huffman@25904
    88
lemma approx_pd_lower_mono:
huffman@25904
    89
  "t \<le>\<flat> u \<Longrightarrow> approx_pd n t \<le>\<flat> approx_pd n u"
huffman@25904
    90
apply (erule lower_le_induct)
huffman@27289
    91
apply (simp add: compact_basis.take_mono)
huffman@25904
    92
apply (simp add: lower_le_PDUnit_PDPlus_iff)
huffman@25904
    93
apply (simp add: lower_le_PDPlus_iff)
huffman@25904
    94
done
huffman@25904
    95
huffman@25904
    96
huffman@25904
    97
subsection {* Type definition *}
huffman@25904
    98
huffman@27373
    99
typedef (open) 'a lower_pd =
huffman@27373
   100
  "{S::'a pd_basis set. lower_le.ideal S}"
huffman@27373
   101
by (fast intro: lower_le.ideal_principal)
huffman@27373
   102
huffman@27373
   103
instantiation lower_pd :: (profinite) sq_ord
huffman@27373
   104
begin
huffman@27373
   105
huffman@27373
   106
definition
huffman@27373
   107
  "x \<sqsubseteq> y \<longleftrightarrow> Rep_lower_pd x \<subseteq> Rep_lower_pd y"
huffman@27373
   108
huffman@27373
   109
instance ..
huffman@27373
   110
end
huffman@25904
   111
huffman@27373
   112
instance lower_pd :: (profinite) po
huffman@27373
   113
by (rule lower_le.typedef_ideal_po
huffman@27373
   114
    [OF type_definition_lower_pd sq_le_lower_pd_def])
huffman@27373
   115
huffman@27373
   116
instance lower_pd :: (profinite) cpo
huffman@27373
   117
by (rule lower_le.typedef_ideal_cpo
huffman@27373
   118
    [OF type_definition_lower_pd sq_le_lower_pd_def])
huffman@27373
   119
huffman@27373
   120
lemma Rep_lower_pd_lub:
huffman@27373
   121
  "chain Y \<Longrightarrow> Rep_lower_pd (\<Squnion>i. Y i) = (\<Union>i. Rep_lower_pd (Y i))"
huffman@27373
   122
by (rule lower_le.typedef_ideal_rep_contlub
huffman@27373
   123
    [OF type_definition_lower_pd sq_le_lower_pd_def])
huffman@27373
   124
huffman@27373
   125
lemma ideal_Rep_lower_pd: "lower_le.ideal (Rep_lower_pd xs)"
huffman@26927
   126
by (rule Rep_lower_pd [unfolded mem_Collect_eq])
huffman@25904
   127
huffman@25904
   128
definition
huffman@25904
   129
  lower_principal :: "'a pd_basis \<Rightarrow> 'a lower_pd" where
huffman@27373
   130
  "lower_principal t = Abs_lower_pd {u. u \<le>\<flat> t}"
huffman@25904
   131
huffman@25904
   132
lemma Rep_lower_principal:
huffman@27373
   133
  "Rep_lower_pd (lower_principal t) = {u. u \<le>\<flat> t}"
huffman@25904
   134
unfolding lower_principal_def
huffman@27297
   135
by (simp add: Abs_lower_pd_inverse lower_le.ideal_principal)
huffman@25904
   136
huffman@25904
   137
interpretation lower_pd:
huffman@27373
   138
  ideal_completion [lower_le approx_pd lower_principal Rep_lower_pd]
huffman@25904
   139
apply unfold_locales
huffman@25904
   140
apply (rule approx_pd_lower_le)
huffman@25904
   141
apply (rule approx_pd_idem)
huffman@25904
   142
apply (erule approx_pd_lower_mono)
huffman@27289
   143
apply (rule approx_pd_lower_chain)
huffman@25904
   144
apply (rule finite_range_approx_pd)
huffman@27289
   145
apply (rule approx_pd_covers)
huffman@26420
   146
apply (rule ideal_Rep_lower_pd)
huffman@27373
   147
apply (erule Rep_lower_pd_lub)
huffman@26420
   148
apply (rule Rep_lower_principal)
huffman@27373
   149
apply (simp only: sq_le_lower_pd_def)
huffman@25904
   150
done
huffman@25904
   151
huffman@27289
   152
text {* Lower powerdomain is pointed *}
huffman@25904
   153
huffman@25904
   154
lemma lower_pd_minimal: "lower_principal (PDUnit compact_bot) \<sqsubseteq> ys"
huffman@25904
   155
by (induct ys rule: lower_pd.principal_induct, simp, simp)
huffman@25904
   156
huffman@25904
   157
instance lower_pd :: (bifinite) pcpo
huffman@26927
   158
by intro_classes (fast intro: lower_pd_minimal)
huffman@25904
   159
huffman@25904
   160
lemma inst_lower_pd_pcpo: "\<bottom> = lower_principal (PDUnit compact_bot)"
huffman@25904
   161
by (rule lower_pd_minimal [THEN UU_I, symmetric])
huffman@25904
   162
huffman@27289
   163
text {* Lower powerdomain is profinite *}
huffman@25904
   164
huffman@26962
   165
instantiation lower_pd :: (profinite) profinite
huffman@26962
   166
begin
huffman@25904
   167
huffman@26962
   168
definition
huffman@26962
   169
  approx_lower_pd_def: "approx = lower_pd.completion_approx"
huffman@26927
   170
huffman@26962
   171
instance
huffman@26927
   172
apply (intro_classes, unfold approx_lower_pd_def)
huffman@27310
   173
apply (rule lower_pd.chain_completion_approx)
huffman@26927
   174
apply (rule lower_pd.lub_completion_approx)
huffman@26927
   175
apply (rule lower_pd.completion_approx_idem)
huffman@26927
   176
apply (rule lower_pd.finite_fixes_completion_approx)
huffman@26927
   177
done
huffman@26927
   178
huffman@26962
   179
end
huffman@26962
   180
huffman@26927
   181
instance lower_pd :: (bifinite) bifinite ..
huffman@25904
   182
huffman@25904
   183
lemma approx_lower_principal [simp]:
huffman@25904
   184
  "approx n\<cdot>(lower_principal t) = lower_principal (approx_pd n t)"
huffman@25904
   185
unfolding approx_lower_pd_def
huffman@26927
   186
by (rule lower_pd.completion_approx_principal)
huffman@25904
   187
huffman@25904
   188
lemma approx_eq_lower_principal:
huffman@27373
   189
  "\<exists>t\<in>Rep_lower_pd xs. approx n\<cdot>xs = lower_principal (approx_pd n t)"
huffman@25904
   190
unfolding approx_lower_pd_def
huffman@26927
   191
by (rule lower_pd.completion_approx_eq_principal)
huffman@26407
   192
huffman@25904
   193
huffman@26927
   194
subsection {* Monadic unit and plus *}
huffman@25904
   195
huffman@25904
   196
definition
huffman@25904
   197
  lower_unit :: "'a \<rightarrow> 'a lower_pd" where
huffman@25904
   198
  "lower_unit = compact_basis.basis_fun (\<lambda>a. lower_principal (PDUnit a))"
huffman@25904
   199
huffman@25904
   200
definition
huffman@25904
   201
  lower_plus :: "'a lower_pd \<rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd" where
huffman@25904
   202
  "lower_plus = lower_pd.basis_fun (\<lambda>t. lower_pd.basis_fun (\<lambda>u.
huffman@25904
   203
      lower_principal (PDPlus t u)))"
huffman@25904
   204
huffman@25904
   205
abbreviation
huffman@25904
   206
  lower_add :: "'a lower_pd \<Rightarrow> 'a lower_pd \<Rightarrow> 'a lower_pd"
huffman@25904
   207
    (infixl "+\<flat>" 65) where
huffman@25904
   208
  "xs +\<flat> ys == lower_plus\<cdot>xs\<cdot>ys"
huffman@25904
   209
huffman@26927
   210
syntax
huffman@26927
   211
  "_lower_pd" :: "args \<Rightarrow> 'a lower_pd" ("{_}\<flat>")
huffman@26927
   212
huffman@26927
   213
translations
huffman@26927
   214
  "{x,xs}\<flat>" == "{x}\<flat> +\<flat> {xs}\<flat>"
huffman@26927
   215
  "{x}\<flat>" == "CONST lower_unit\<cdot>x"
huffman@26927
   216
huffman@26927
   217
lemma lower_unit_Rep_compact_basis [simp]:
huffman@26927
   218
  "{Rep_compact_basis a}\<flat> = lower_principal (PDUnit a)"
huffman@26927
   219
unfolding lower_unit_def
huffman@27289
   220
by (simp add: compact_basis.basis_fun_principal PDUnit_lower_mono)
huffman@26927
   221
huffman@25904
   222
lemma lower_plus_principal [simp]:
huffman@26927
   223
  "lower_principal t +\<flat> lower_principal u = lower_principal (PDPlus t u)"
huffman@25904
   224
unfolding lower_plus_def
huffman@25904
   225
by (simp add: lower_pd.basis_fun_principal
huffman@25904
   226
    lower_pd.basis_fun_mono PDPlus_lower_mono)
huffman@25904
   227
huffman@26927
   228
lemma approx_lower_unit [simp]:
huffman@26927
   229
  "approx n\<cdot>{x}\<flat> = {approx n\<cdot>x}\<flat>"
huffman@27289
   230
apply (induct x rule: compact_basis.principal_induct, simp)
huffman@26927
   231
apply (simp add: approx_Rep_compact_basis)
huffman@26927
   232
done
huffman@26927
   233
huffman@25904
   234
lemma approx_lower_plus [simp]:
huffman@26927
   235
  "approx n\<cdot>(xs +\<flat> ys) = (approx n\<cdot>xs) +\<flat> (approx n\<cdot>ys)"
huffman@27289
   236
by (induct xs ys rule: lower_pd.principal_induct2, simp, simp, simp)
huffman@25904
   237
huffman@26927
   238
lemma lower_plus_assoc: "(xs +\<flat> ys) +\<flat> zs = xs +\<flat> (ys +\<flat> zs)"
huffman@27289
   239
apply (induct xs ys arbitrary: zs rule: lower_pd.principal_induct2, simp, simp)
huffman@27289
   240
apply (rule_tac x=zs in lower_pd.principal_induct, simp)
huffman@25904
   241
apply (simp add: PDPlus_assoc)
huffman@25904
   242
done
huffman@25904
   243
huffman@26927
   244
lemma lower_plus_commute: "xs +\<flat> ys = ys +\<flat> xs"
huffman@27289
   245
apply (induct xs ys rule: lower_pd.principal_induct2, simp, simp)
huffman@26927
   246
apply (simp add: PDPlus_commute)
huffman@26927
   247
done
huffman@26927
   248
huffman@26927
   249
lemma lower_plus_absorb: "xs +\<flat> xs = xs"
huffman@27289
   250
apply (induct xs rule: lower_pd.principal_induct, simp)
huffman@25904
   251
apply (simp add: PDPlus_absorb)
huffman@25904
   252
done
huffman@25904
   253
huffman@26927
   254
interpretation aci_lower_plus: ab_semigroup_idem_mult ["op +\<flat>"]
huffman@26927
   255
  by unfold_locales
huffman@26927
   256
    (rule lower_plus_assoc lower_plus_commute lower_plus_absorb)+
huffman@26927
   257
huffman@26927
   258
lemma lower_plus_left_commute: "xs +\<flat> (ys +\<flat> zs) = ys +\<flat> (xs +\<flat> zs)"
huffman@26927
   259
by (rule aci_lower_plus.mult_left_commute)
huffman@26927
   260
huffman@26927
   261
lemma lower_plus_left_absorb: "xs +\<flat> (xs +\<flat> ys) = xs +\<flat> ys"
huffman@26927
   262
by (rule aci_lower_plus.mult_left_idem)
huffman@26927
   263
huffman@26927
   264
lemmas lower_plus_aci = aci_lower_plus.mult_ac_idem
huffman@26927
   265
huffman@26927
   266
lemma lower_plus_less1: "xs \<sqsubseteq> xs +\<flat> ys"
huffman@27289
   267
apply (induct xs ys rule: lower_pd.principal_induct2, simp, simp)
huffman@25904
   268
apply (simp add: PDPlus_lower_less)
huffman@25904
   269
done
huffman@25904
   270
huffman@26927
   271
lemma lower_plus_less2: "ys \<sqsubseteq> xs +\<flat> ys"
huffman@25904
   272
by (subst lower_plus_commute, rule lower_plus_less1)
huffman@25904
   273
huffman@26927
   274
lemma lower_plus_least: "\<lbrakk>xs \<sqsubseteq> zs; ys \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs +\<flat> ys \<sqsubseteq> zs"
huffman@25904
   275
apply (subst lower_plus_absorb [of zs, symmetric])
huffman@25904
   276
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
huffman@25904
   277
done
huffman@25904
   278
huffman@25904
   279
lemma lower_plus_less_iff:
huffman@26927
   280
  "xs +\<flat> ys \<sqsubseteq> zs \<longleftrightarrow> xs \<sqsubseteq> zs \<and> ys \<sqsubseteq> zs"
huffman@25904
   281
apply safe
huffman@25904
   282
apply (erule trans_less [OF lower_plus_less1])
huffman@25904
   283
apply (erule trans_less [OF lower_plus_less2])
huffman@25904
   284
apply (erule (1) lower_plus_least)
huffman@25904
   285
done
huffman@25904
   286
huffman@25904
   287
lemma lower_unit_less_plus_iff:
huffman@26927
   288
  "{x}\<flat> \<sqsubseteq> ys +\<flat> zs \<longleftrightarrow> {x}\<flat> \<sqsubseteq> ys \<or> {x}\<flat> \<sqsubseteq> zs"
huffman@25904
   289
 apply (rule iffI)
huffman@25904
   290
  apply (subgoal_tac
huffman@26927
   291
    "adm (\<lambda>f. f\<cdot>{x}\<flat> \<sqsubseteq> f\<cdot>ys \<or> f\<cdot>{x}\<flat> \<sqsubseteq> f\<cdot>zs)")
huffman@25925
   292
   apply (drule admD, rule chain_approx)
huffman@25904
   293
    apply (drule_tac f="approx i" in monofun_cfun_arg)
huffman@27289
   294
    apply (cut_tac x="approx i\<cdot>x" in compact_basis.compact_imp_principal, simp)
huffman@27289
   295
    apply (cut_tac x="approx i\<cdot>ys" in lower_pd.compact_imp_principal, simp)
huffman@27289
   296
    apply (cut_tac x="approx i\<cdot>zs" in lower_pd.compact_imp_principal, simp)
huffman@25904
   297
    apply (clarify, simp add: lower_le_PDUnit_PDPlus_iff)
huffman@25904
   298
   apply simp
huffman@25904
   299
  apply simp
huffman@25904
   300
 apply (erule disjE)
huffman@25904
   301
  apply (erule trans_less [OF _ lower_plus_less1])
huffman@25904
   302
 apply (erule trans_less [OF _ lower_plus_less2])
huffman@25904
   303
done
huffman@25904
   304
huffman@26927
   305
lemma lower_unit_less_iff [simp]: "{x}\<flat> \<sqsubseteq> {y}\<flat> \<longleftrightarrow> x \<sqsubseteq> y"
huffman@26927
   306
 apply (rule iffI)
huffman@27309
   307
  apply (rule profinite_less_ext)
huffman@26927
   308
  apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
huffman@27289
   309
  apply (cut_tac x="approx i\<cdot>x" in compact_basis.compact_imp_principal, simp)
huffman@27289
   310
  apply (cut_tac x="approx i\<cdot>y" in compact_basis.compact_imp_principal, simp)
huffman@27289
   311
  apply clarsimp
huffman@26927
   312
 apply (erule monofun_cfun_arg)
huffman@26927
   313
done
huffman@26927
   314
huffman@25904
   315
lemmas lower_pd_less_simps =
huffman@25904
   316
  lower_unit_less_iff
huffman@25904
   317
  lower_plus_less_iff
huffman@25904
   318
  lower_unit_less_plus_iff
huffman@25904
   319
huffman@27289
   320
lemma fooble:
huffman@27289
   321
  fixes f :: "'a::po \<Rightarrow> 'b::po"
huffman@27289
   322
  assumes f: "\<And>x y. f x \<sqsubseteq> f y \<longleftrightarrow> x \<sqsubseteq> y"
huffman@27289
   323
  shows "f x = f y \<longleftrightarrow> x = y"
huffman@27289
   324
unfolding po_eq_conv by (simp add: f)
huffman@27289
   325
huffman@26927
   326
lemma lower_unit_eq_iff [simp]: "{x}\<flat> = {y}\<flat> \<longleftrightarrow> x = y"
huffman@27289
   327
by (rule lower_unit_less_iff [THEN fooble])
huffman@26927
   328
huffman@26927
   329
lemma lower_unit_strict [simp]: "{\<bottom>}\<flat> = \<bottom>"
huffman@26927
   330
unfolding inst_lower_pd_pcpo Rep_compact_bot [symmetric] by simp
huffman@26927
   331
huffman@26927
   332
lemma lower_unit_strict_iff [simp]: "{x}\<flat> = \<bottom> \<longleftrightarrow> x = \<bottom>"
huffman@26927
   333
unfolding lower_unit_strict [symmetric] by (rule lower_unit_eq_iff)
huffman@26927
   334
huffman@26927
   335
lemma lower_plus_strict_iff [simp]:
huffman@26927
   336
  "xs +\<flat> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<and> ys = \<bottom>"
huffman@26927
   337
apply safe
huffman@26927
   338
apply (rule UU_I, erule subst, rule lower_plus_less1)
huffman@26927
   339
apply (rule UU_I, erule subst, rule lower_plus_less2)
huffman@26927
   340
apply (rule lower_plus_absorb)
huffman@26927
   341
done
huffman@26927
   342
huffman@26927
   343
lemma lower_plus_strict1 [simp]: "\<bottom> +\<flat> ys = ys"
huffman@26927
   344
apply (rule antisym_less [OF _ lower_plus_less2])
huffman@26927
   345
apply (simp add: lower_plus_least)
huffman@26927
   346
done
huffman@26927
   347
huffman@26927
   348
lemma lower_plus_strict2 [simp]: "xs +\<flat> \<bottom> = xs"
huffman@26927
   349
apply (rule antisym_less [OF _ lower_plus_less1])
huffman@26927
   350
apply (simp add: lower_plus_least)
huffman@26927
   351
done
huffman@26927
   352
huffman@26927
   353
lemma compact_lower_unit_iff [simp]: "compact {x}\<flat> \<longleftrightarrow> compact x"
huffman@27309
   354
unfolding profinite_compact_iff by simp
huffman@26927
   355
huffman@26927
   356
lemma compact_lower_plus [simp]:
huffman@26927
   357
  "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs +\<flat> ys)"
huffman@27289
   358
by (auto dest!: lower_pd.compact_imp_principal)
huffman@26927
   359
huffman@25904
   360
huffman@25904
   361
subsection {* Induction rules *}
huffman@25904
   362
huffman@25904
   363
lemma lower_pd_induct1:
huffman@25904
   364
  assumes P: "adm P"
huffman@26927
   365
  assumes unit: "\<And>x. P {x}\<flat>"
huffman@25904
   366
  assumes insert:
huffman@26927
   367
    "\<And>x ys. \<lbrakk>P {x}\<flat>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<flat> +\<flat> ys)"
huffman@25904
   368
  shows "P (xs::'a lower_pd)"
huffman@27289
   369
apply (induct xs rule: lower_pd.principal_induct, rule P)
huffman@27289
   370
apply (induct_tac a rule: pd_basis_induct1)
huffman@25904
   371
apply (simp only: lower_unit_Rep_compact_basis [symmetric])
huffman@25904
   372
apply (rule unit)
huffman@25904
   373
apply (simp only: lower_unit_Rep_compact_basis [symmetric]
huffman@25904
   374
                  lower_plus_principal [symmetric])
huffman@25904
   375
apply (erule insert [OF unit])
huffman@25904
   376
done
huffman@25904
   377
huffman@25904
   378
lemma lower_pd_induct:
huffman@25904
   379
  assumes P: "adm P"
huffman@26927
   380
  assumes unit: "\<And>x. P {x}\<flat>"
huffman@26927
   381
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs +\<flat> ys)"
huffman@25904
   382
  shows "P (xs::'a lower_pd)"
huffman@27289
   383
apply (induct xs rule: lower_pd.principal_induct, rule P)
huffman@27289
   384
apply (induct_tac a rule: pd_basis_induct)
huffman@25904
   385
apply (simp only: lower_unit_Rep_compact_basis [symmetric] unit)
huffman@25904
   386
apply (simp only: lower_plus_principal [symmetric] plus)
huffman@25904
   387
done
huffman@25904
   388
huffman@25904
   389
huffman@25904
   390
subsection {* Monadic bind *}
huffman@25904
   391
huffman@25904
   392
definition
huffman@25904
   393
  lower_bind_basis ::
huffman@25904
   394
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
huffman@25904
   395
  "lower_bind_basis = fold_pd
huffman@25904
   396
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
huffman@26927
   397
    (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<flat> y\<cdot>f)"
huffman@25904
   398
huffman@26927
   399
lemma ACI_lower_bind:
huffman@26927
   400
  "ab_semigroup_idem_mult (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<flat> y\<cdot>f)"
huffman@25904
   401
apply unfold_locales
haftmann@26041
   402
apply (simp add: lower_plus_assoc)
huffman@25904
   403
apply (simp add: lower_plus_commute)
huffman@25904
   404
apply (simp add: lower_plus_absorb eta_cfun)
huffman@25904
   405
done
huffman@25904
   406
huffman@25904
   407
lemma lower_bind_basis_simps [simp]:
huffman@25904
   408
  "lower_bind_basis (PDUnit a) =
huffman@25904
   409
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
huffman@25904
   410
  "lower_bind_basis (PDPlus t u) =
huffman@26927
   411
    (\<Lambda> f. lower_bind_basis t\<cdot>f +\<flat> lower_bind_basis u\<cdot>f)"
huffman@25904
   412
unfolding lower_bind_basis_def
huffman@25904
   413
apply -
huffman@26927
   414
apply (rule fold_pd_PDUnit [OF ACI_lower_bind])
huffman@26927
   415
apply (rule fold_pd_PDPlus [OF ACI_lower_bind])
huffman@25904
   416
done
huffman@25904
   417
huffman@25904
   418
lemma lower_bind_basis_mono:
huffman@25904
   419
  "t \<le>\<flat> u \<Longrightarrow> lower_bind_basis t \<sqsubseteq> lower_bind_basis u"
huffman@25904
   420
unfolding expand_cfun_less
huffman@25904
   421
apply (erule lower_le_induct, safe)
huffman@27289
   422
apply (simp add: monofun_cfun)
huffman@25904
   423
apply (simp add: rev_trans_less [OF lower_plus_less1])
huffman@25904
   424
apply (simp add: lower_plus_less_iff)
huffman@25904
   425
done
huffman@25904
   426
huffman@25904
   427
definition
huffman@25904
   428
  lower_bind :: "'a lower_pd \<rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
huffman@25904
   429
  "lower_bind = lower_pd.basis_fun lower_bind_basis"
huffman@25904
   430
huffman@25904
   431
lemma lower_bind_principal [simp]:
huffman@25904
   432
  "lower_bind\<cdot>(lower_principal t) = lower_bind_basis t"
huffman@25904
   433
unfolding lower_bind_def
huffman@25904
   434
apply (rule lower_pd.basis_fun_principal)
huffman@25904
   435
apply (erule lower_bind_basis_mono)
huffman@25904
   436
done
huffman@25904
   437
huffman@25904
   438
lemma lower_bind_unit [simp]:
huffman@26927
   439
  "lower_bind\<cdot>{x}\<flat>\<cdot>f = f\<cdot>x"
huffman@27289
   440
by (induct x rule: compact_basis.principal_induct, simp, simp)
huffman@25904
   441
huffman@25904
   442
lemma lower_bind_plus [simp]:
huffman@26927
   443
  "lower_bind\<cdot>(xs +\<flat> ys)\<cdot>f = lower_bind\<cdot>xs\<cdot>f +\<flat> lower_bind\<cdot>ys\<cdot>f"
huffman@27289
   444
by (induct xs ys rule: lower_pd.principal_induct2, simp, simp, simp)
huffman@25904
   445
huffman@25904
   446
lemma lower_bind_strict [simp]: "lower_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
huffman@25904
   447
unfolding lower_unit_strict [symmetric] by (rule lower_bind_unit)
huffman@25904
   448
huffman@25904
   449
huffman@25904
   450
subsection {* Map and join *}
huffman@25904
   451
huffman@25904
   452
definition
huffman@25904
   453
  lower_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a lower_pd \<rightarrow> 'b lower_pd" where
huffman@26927
   454
  "lower_map = (\<Lambda> f xs. lower_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<flat>))"
huffman@25904
   455
huffman@25904
   456
definition
huffman@25904
   457
  lower_join :: "'a lower_pd lower_pd \<rightarrow> 'a lower_pd" where
huffman@25904
   458
  "lower_join = (\<Lambda> xss. lower_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
huffman@25904
   459
huffman@25904
   460
lemma lower_map_unit [simp]:
huffman@26927
   461
  "lower_map\<cdot>f\<cdot>{x}\<flat> = {f\<cdot>x}\<flat>"
huffman@25904
   462
unfolding lower_map_def by simp
huffman@25904
   463
huffman@25904
   464
lemma lower_map_plus [simp]:
huffman@26927
   465
  "lower_map\<cdot>f\<cdot>(xs +\<flat> ys) = lower_map\<cdot>f\<cdot>xs +\<flat> lower_map\<cdot>f\<cdot>ys"
huffman@25904
   466
unfolding lower_map_def by simp
huffman@25904
   467
huffman@25904
   468
lemma lower_join_unit [simp]:
huffman@26927
   469
  "lower_join\<cdot>{xs}\<flat> = xs"
huffman@25904
   470
unfolding lower_join_def by simp
huffman@25904
   471
huffman@25904
   472
lemma lower_join_plus [simp]:
huffman@26927
   473
  "lower_join\<cdot>(xss +\<flat> yss) = lower_join\<cdot>xss +\<flat> lower_join\<cdot>yss"
huffman@25904
   474
unfolding lower_join_def by simp
huffman@25904
   475
huffman@25904
   476
lemma lower_map_ident: "lower_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
huffman@25904
   477
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   478
huffman@25904
   479
lemma lower_map_map:
huffman@25904
   480
  "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
   481
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   482
huffman@25904
   483
lemma lower_join_map_unit:
huffman@25904
   484
  "lower_join\<cdot>(lower_map\<cdot>lower_unit\<cdot>xs) = xs"
huffman@25904
   485
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   486
huffman@25904
   487
lemma lower_join_map_join:
huffman@25904
   488
  "lower_join\<cdot>(lower_map\<cdot>lower_join\<cdot>xsss) = lower_join\<cdot>(lower_join\<cdot>xsss)"
huffman@25904
   489
by (induct xsss rule: lower_pd_induct, simp_all)
huffman@25904
   490
huffman@25904
   491
lemma lower_join_map_map:
huffman@25904
   492
  "lower_join\<cdot>(lower_map\<cdot>(lower_map\<cdot>f)\<cdot>xss) =
huffman@25904
   493
   lower_map\<cdot>f\<cdot>(lower_join\<cdot>xss)"
huffman@25904
   494
by (induct xss rule: lower_pd_induct, simp_all)
huffman@25904
   495
huffman@25904
   496
lemma lower_map_approx: "lower_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
huffman@25904
   497
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   498
huffman@25904
   499
end