src/HOLCF/LowerPD.thy
author huffman
Mon May 19 23:49:20 2008 +0200 (2008-05-19)
changeset 26962 c8b20f615d6c
parent 26927 8684b5240f11
child 27267 5ebfb7f25ebb
permissions -rw-r--r--
use new class package for classes profinite, bifinite; remove approx class
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@25904
    75
lemma approx_pd_lower_mono1:
huffman@25904
    76
  "i \<le> j \<Longrightarrow> approx_pd i t \<le>\<flat> approx_pd j t"
huffman@25904
    77
apply (induct t rule: pd_basis_induct)
huffman@25904
    78
apply (simp add: compact_approx_mono1)
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@25904
    84
apply (simp add: compact_approx_le)
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@25904
    91
apply (simp add: compact_approx_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@25904
    99
cpodef (open) 'a lower_pd =
huffman@26407
   100
  "{S::'a::profinite pd_basis set. lower_le.ideal S}"
huffman@25904
   101
apply (simp add: lower_le.adm_ideal)
huffman@25904
   102
apply (fast intro: lower_le.ideal_principal)
huffman@25904
   103
done
huffman@25904
   104
huffman@25904
   105
lemma ideal_Rep_lower_pd: "lower_le.ideal (Rep_lower_pd x)"
huffman@26927
   106
by (rule Rep_lower_pd [unfolded mem_Collect_eq])
huffman@25904
   107
huffman@25904
   108
definition
huffman@25904
   109
  lower_principal :: "'a pd_basis \<Rightarrow> 'a lower_pd" where
huffman@25904
   110
  "lower_principal t = Abs_lower_pd {u. u \<le>\<flat> t}"
huffman@25904
   111
huffman@25904
   112
lemma Rep_lower_principal:
huffman@25904
   113
  "Rep_lower_pd (lower_principal t) = {u. u \<le>\<flat> t}"
huffman@25904
   114
unfolding lower_principal_def
huffman@25904
   115
apply (rule Abs_lower_pd_inverse [simplified])
huffman@25904
   116
apply (rule lower_le.ideal_principal)
huffman@25904
   117
done
huffman@25904
   118
huffman@25904
   119
interpretation lower_pd:
huffman@26927
   120
  ideal_completion [lower_le approx_pd lower_principal Rep_lower_pd]
huffman@25904
   121
apply unfold_locales
huffman@25904
   122
apply (rule approx_pd_lower_le)
huffman@25904
   123
apply (rule approx_pd_idem)
huffman@25904
   124
apply (erule approx_pd_lower_mono)
huffman@25904
   125
apply (rule approx_pd_lower_mono1, simp)
huffman@25904
   126
apply (rule finite_range_approx_pd)
huffman@25904
   127
apply (rule ex_approx_pd_eq)
huffman@26420
   128
apply (rule ideal_Rep_lower_pd)
huffman@26420
   129
apply (rule cont_Rep_lower_pd)
huffman@26420
   130
apply (rule Rep_lower_principal)
berghofe@26806
   131
apply (simp only: less_lower_pd_def less_set_eq)
huffman@25904
   132
done
huffman@25904
   133
huffman@25904
   134
lemma lower_principal_less_iff [simp]:
huffman@26927
   135
  "lower_principal t \<sqsubseteq> lower_principal u \<longleftrightarrow> t \<le>\<flat> u"
huffman@26927
   136
by (rule lower_pd.principal_less_iff)
huffman@26927
   137
huffman@26927
   138
lemma lower_principal_eq_iff:
huffman@26927
   139
  "lower_principal t = lower_principal u \<longleftrightarrow> t \<le>\<flat> u \<and> u \<le>\<flat> t"
huffman@26927
   140
by (rule lower_pd.principal_eq_iff)
huffman@25904
   141
huffman@25904
   142
lemma lower_principal_mono:
huffman@25904
   143
  "t \<le>\<flat> u \<Longrightarrow> lower_principal t \<sqsubseteq> lower_principal u"
huffman@26927
   144
by (rule lower_pd.principal_mono)
huffman@25904
   145
huffman@25904
   146
lemma compact_lower_principal: "compact (lower_principal t)"
huffman@26927
   147
by (rule lower_pd.compact_principal)
huffman@25904
   148
huffman@25904
   149
lemma lower_pd_minimal: "lower_principal (PDUnit compact_bot) \<sqsubseteq> ys"
huffman@25904
   150
by (induct ys rule: lower_pd.principal_induct, simp, simp)
huffman@25904
   151
huffman@25904
   152
instance lower_pd :: (bifinite) pcpo
huffman@26927
   153
by intro_classes (fast intro: lower_pd_minimal)
huffman@25904
   154
huffman@25904
   155
lemma inst_lower_pd_pcpo: "\<bottom> = lower_principal (PDUnit compact_bot)"
huffman@25904
   156
by (rule lower_pd_minimal [THEN UU_I, symmetric])
huffman@25904
   157
huffman@25904
   158
huffman@25904
   159
subsection {* Approximation *}
huffman@25904
   160
huffman@26962
   161
instantiation lower_pd :: (profinite) profinite
huffman@26962
   162
begin
huffman@25904
   163
huffman@26962
   164
definition
huffman@26962
   165
  approx_lower_pd_def: "approx = lower_pd.completion_approx"
huffman@26927
   166
huffman@26962
   167
instance
huffman@26927
   168
apply (intro_classes, unfold approx_lower_pd_def)
huffman@26927
   169
apply (simp add: lower_pd.chain_completion_approx)
huffman@26927
   170
apply (rule lower_pd.lub_completion_approx)
huffman@26927
   171
apply (rule lower_pd.completion_approx_idem)
huffman@26927
   172
apply (rule lower_pd.finite_fixes_completion_approx)
huffman@26927
   173
done
huffman@26927
   174
huffman@26962
   175
end
huffman@26962
   176
huffman@26927
   177
instance lower_pd :: (bifinite) bifinite ..
huffman@25904
   178
huffman@25904
   179
lemma approx_lower_principal [simp]:
huffman@25904
   180
  "approx n\<cdot>(lower_principal t) = lower_principal (approx_pd n t)"
huffman@25904
   181
unfolding approx_lower_pd_def
huffman@26927
   182
by (rule lower_pd.completion_approx_principal)
huffman@25904
   183
huffman@25904
   184
lemma approx_eq_lower_principal:
huffman@25904
   185
  "\<exists>t\<in>Rep_lower_pd xs. approx n\<cdot>xs = lower_principal (approx_pd n t)"
huffman@25904
   186
unfolding approx_lower_pd_def
huffman@26927
   187
by (rule lower_pd.completion_approx_eq_principal)
huffman@26407
   188
huffman@25904
   189
lemma compact_imp_lower_principal:
huffman@25904
   190
  "compact xs \<Longrightarrow> \<exists>t. xs = lower_principal t"
huffman@25904
   191
apply (drule bifinite_compact_eq_approx)
huffman@25904
   192
apply (erule exE)
huffman@25904
   193
apply (erule subst)
huffman@25904
   194
apply (cut_tac n=i and xs=xs in approx_eq_lower_principal)
huffman@25904
   195
apply fast
huffman@25904
   196
done
huffman@25904
   197
huffman@25904
   198
lemma lower_principal_induct:
huffman@25904
   199
  "\<lbrakk>adm P; \<And>t. P (lower_principal t)\<rbrakk> \<Longrightarrow> P xs"
huffman@26927
   200
by (rule lower_pd.principal_induct)
huffman@25904
   201
huffman@25904
   202
lemma lower_principal_induct2:
huffman@25904
   203
  "\<lbrakk>\<And>ys. adm (\<lambda>xs. P xs ys); \<And>xs. adm (\<lambda>ys. P xs ys);
huffman@25904
   204
    \<And>t u. P (lower_principal t) (lower_principal u)\<rbrakk> \<Longrightarrow> P xs ys"
huffman@25904
   205
apply (rule_tac x=ys in spec)
huffman@25904
   206
apply (rule_tac xs=xs in lower_principal_induct, simp)
huffman@25904
   207
apply (rule allI, rename_tac ys)
huffman@25904
   208
apply (rule_tac xs=ys in lower_principal_induct, simp)
huffman@25904
   209
apply simp
huffman@25904
   210
done
huffman@25904
   211
huffman@25904
   212
huffman@26927
   213
subsection {* Monadic unit and plus *}
huffman@25904
   214
huffman@25904
   215
definition
huffman@25904
   216
  lower_unit :: "'a \<rightarrow> 'a lower_pd" where
huffman@25904
   217
  "lower_unit = compact_basis.basis_fun (\<lambda>a. lower_principal (PDUnit a))"
huffman@25904
   218
huffman@25904
   219
definition
huffman@25904
   220
  lower_plus :: "'a lower_pd \<rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd" where
huffman@25904
   221
  "lower_plus = lower_pd.basis_fun (\<lambda>t. lower_pd.basis_fun (\<lambda>u.
huffman@25904
   222
      lower_principal (PDPlus t u)))"
huffman@25904
   223
huffman@25904
   224
abbreviation
huffman@25904
   225
  lower_add :: "'a lower_pd \<Rightarrow> 'a lower_pd \<Rightarrow> 'a lower_pd"
huffman@25904
   226
    (infixl "+\<flat>" 65) where
huffman@25904
   227
  "xs +\<flat> ys == lower_plus\<cdot>xs\<cdot>ys"
huffman@25904
   228
huffman@26927
   229
syntax
huffman@26927
   230
  "_lower_pd" :: "args \<Rightarrow> 'a lower_pd" ("{_}\<flat>")
huffman@26927
   231
huffman@26927
   232
translations
huffman@26927
   233
  "{x,xs}\<flat>" == "{x}\<flat> +\<flat> {xs}\<flat>"
huffman@26927
   234
  "{x}\<flat>" == "CONST lower_unit\<cdot>x"
huffman@26927
   235
huffman@26927
   236
lemma lower_unit_Rep_compact_basis [simp]:
huffman@26927
   237
  "{Rep_compact_basis a}\<flat> = lower_principal (PDUnit a)"
huffman@26927
   238
unfolding lower_unit_def
huffman@26927
   239
by (simp add: compact_basis.basis_fun_principal
huffman@26927
   240
    lower_principal_mono PDUnit_lower_mono)
huffman@26927
   241
huffman@25904
   242
lemma lower_plus_principal [simp]:
huffman@26927
   243
  "lower_principal t +\<flat> lower_principal u = lower_principal (PDPlus t u)"
huffman@25904
   244
unfolding lower_plus_def
huffman@25904
   245
by (simp add: lower_pd.basis_fun_principal
huffman@25904
   246
    lower_pd.basis_fun_mono PDPlus_lower_mono)
huffman@25904
   247
huffman@26927
   248
lemma approx_lower_unit [simp]:
huffman@26927
   249
  "approx n\<cdot>{x}\<flat> = {approx n\<cdot>x}\<flat>"
huffman@26927
   250
apply (induct x rule: compact_basis_induct, simp)
huffman@26927
   251
apply (simp add: approx_Rep_compact_basis)
huffman@26927
   252
done
huffman@26927
   253
huffman@25904
   254
lemma approx_lower_plus [simp]:
huffman@26927
   255
  "approx n\<cdot>(xs +\<flat> ys) = (approx n\<cdot>xs) +\<flat> (approx n\<cdot>ys)"
huffman@25904
   256
by (induct xs ys rule: lower_principal_induct2, simp, simp, simp)
huffman@25904
   257
huffman@26927
   258
lemma lower_plus_assoc: "(xs +\<flat> ys) +\<flat> zs = xs +\<flat> (ys +\<flat> zs)"
huffman@25904
   259
apply (induct xs ys arbitrary: zs rule: lower_principal_induct2, simp, simp)
huffman@25904
   260
apply (rule_tac xs=zs in lower_principal_induct, simp)
huffman@25904
   261
apply (simp add: PDPlus_assoc)
huffman@25904
   262
done
huffman@25904
   263
huffman@26927
   264
lemma lower_plus_commute: "xs +\<flat> ys = ys +\<flat> xs"
huffman@26927
   265
apply (induct xs ys rule: lower_principal_induct2, simp, simp)
huffman@26927
   266
apply (simp add: PDPlus_commute)
huffman@26927
   267
done
huffman@26927
   268
huffman@26927
   269
lemma lower_plus_absorb: "xs +\<flat> xs = xs"
huffman@25904
   270
apply (induct xs rule: lower_principal_induct, simp)
huffman@25904
   271
apply (simp add: PDPlus_absorb)
huffman@25904
   272
done
huffman@25904
   273
huffman@26927
   274
interpretation aci_lower_plus: ab_semigroup_idem_mult ["op +\<flat>"]
huffman@26927
   275
  by unfold_locales
huffman@26927
   276
    (rule lower_plus_assoc lower_plus_commute lower_plus_absorb)+
huffman@26927
   277
huffman@26927
   278
lemma lower_plus_left_commute: "xs +\<flat> (ys +\<flat> zs) = ys +\<flat> (xs +\<flat> zs)"
huffman@26927
   279
by (rule aci_lower_plus.mult_left_commute)
huffman@26927
   280
huffman@26927
   281
lemma lower_plus_left_absorb: "xs +\<flat> (xs +\<flat> ys) = xs +\<flat> ys"
huffman@26927
   282
by (rule aci_lower_plus.mult_left_idem)
huffman@26927
   283
huffman@26927
   284
lemmas lower_plus_aci = aci_lower_plus.mult_ac_idem
huffman@26927
   285
huffman@26927
   286
lemma lower_plus_less1: "xs \<sqsubseteq> xs +\<flat> ys"
huffman@25904
   287
apply (induct xs ys rule: lower_principal_induct2, simp, simp)
huffman@25904
   288
apply (simp add: PDPlus_lower_less)
huffman@25904
   289
done
huffman@25904
   290
huffman@26927
   291
lemma lower_plus_less2: "ys \<sqsubseteq> xs +\<flat> ys"
huffman@25904
   292
by (subst lower_plus_commute, rule lower_plus_less1)
huffman@25904
   293
huffman@26927
   294
lemma lower_plus_least: "\<lbrakk>xs \<sqsubseteq> zs; ys \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs +\<flat> ys \<sqsubseteq> zs"
huffman@25904
   295
apply (subst lower_plus_absorb [of zs, symmetric])
huffman@25904
   296
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
huffman@25904
   297
done
huffman@25904
   298
huffman@25904
   299
lemma lower_plus_less_iff:
huffman@26927
   300
  "xs +\<flat> ys \<sqsubseteq> zs \<longleftrightarrow> xs \<sqsubseteq> zs \<and> ys \<sqsubseteq> zs"
huffman@25904
   301
apply safe
huffman@25904
   302
apply (erule trans_less [OF lower_plus_less1])
huffman@25904
   303
apply (erule trans_less [OF lower_plus_less2])
huffman@25904
   304
apply (erule (1) lower_plus_least)
huffman@25904
   305
done
huffman@25904
   306
huffman@25904
   307
lemma lower_unit_less_plus_iff:
huffman@26927
   308
  "{x}\<flat> \<sqsubseteq> ys +\<flat> zs \<longleftrightarrow> {x}\<flat> \<sqsubseteq> ys \<or> {x}\<flat> \<sqsubseteq> zs"
huffman@25904
   309
 apply (rule iffI)
huffman@25904
   310
  apply (subgoal_tac
huffman@26927
   311
    "adm (\<lambda>f. f\<cdot>{x}\<flat> \<sqsubseteq> f\<cdot>ys \<or> f\<cdot>{x}\<flat> \<sqsubseteq> f\<cdot>zs)")
huffman@25925
   312
   apply (drule admD, rule chain_approx)
huffman@25904
   313
    apply (drule_tac f="approx i" in monofun_cfun_arg)
huffman@25904
   314
    apply (cut_tac x="approx i\<cdot>x" in compact_imp_Rep_compact_basis, simp)
huffman@25904
   315
    apply (cut_tac xs="approx i\<cdot>ys" in compact_imp_lower_principal, simp)
huffman@25904
   316
    apply (cut_tac xs="approx i\<cdot>zs" in compact_imp_lower_principal, simp)
huffman@25904
   317
    apply (clarify, simp add: lower_le_PDUnit_PDPlus_iff)
huffman@25904
   318
   apply simp
huffman@25904
   319
  apply simp
huffman@25904
   320
 apply (erule disjE)
huffman@25904
   321
  apply (erule trans_less [OF _ lower_plus_less1])
huffman@25904
   322
 apply (erule trans_less [OF _ lower_plus_less2])
huffman@25904
   323
done
huffman@25904
   324
huffman@26927
   325
lemma lower_unit_less_iff [simp]: "{x}\<flat> \<sqsubseteq> {y}\<flat> \<longleftrightarrow> x \<sqsubseteq> y"
huffman@26927
   326
 apply (rule iffI)
huffman@26927
   327
  apply (rule bifinite_less_ext)
huffman@26927
   328
  apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
huffman@26927
   329
  apply (cut_tac x="approx i\<cdot>x" in compact_imp_Rep_compact_basis, simp)
huffman@26927
   330
  apply (cut_tac x="approx i\<cdot>y" in compact_imp_Rep_compact_basis, simp)
huffman@26927
   331
  apply (clarify, simp add: compact_le_def)
huffman@26927
   332
 apply (erule monofun_cfun_arg)
huffman@26927
   333
done
huffman@26927
   334
huffman@25904
   335
lemmas lower_pd_less_simps =
huffman@25904
   336
  lower_unit_less_iff
huffman@25904
   337
  lower_plus_less_iff
huffman@25904
   338
  lower_unit_less_plus_iff
huffman@25904
   339
huffman@26927
   340
lemma lower_unit_eq_iff [simp]: "{x}\<flat> = {y}\<flat> \<longleftrightarrow> x = y"
huffman@26927
   341
unfolding po_eq_conv by simp
huffman@26927
   342
huffman@26927
   343
lemma lower_unit_strict [simp]: "{\<bottom>}\<flat> = \<bottom>"
huffman@26927
   344
unfolding inst_lower_pd_pcpo Rep_compact_bot [symmetric] by simp
huffman@26927
   345
huffman@26927
   346
lemma lower_unit_strict_iff [simp]: "{x}\<flat> = \<bottom> \<longleftrightarrow> x = \<bottom>"
huffman@26927
   347
unfolding lower_unit_strict [symmetric] by (rule lower_unit_eq_iff)
huffman@26927
   348
huffman@26927
   349
lemma lower_plus_strict_iff [simp]:
huffman@26927
   350
  "xs +\<flat> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<and> ys = \<bottom>"
huffman@26927
   351
apply safe
huffman@26927
   352
apply (rule UU_I, erule subst, rule lower_plus_less1)
huffman@26927
   353
apply (rule UU_I, erule subst, rule lower_plus_less2)
huffman@26927
   354
apply (rule lower_plus_absorb)
huffman@26927
   355
done
huffman@26927
   356
huffman@26927
   357
lemma lower_plus_strict1 [simp]: "\<bottom> +\<flat> ys = ys"
huffman@26927
   358
apply (rule antisym_less [OF _ lower_plus_less2])
huffman@26927
   359
apply (simp add: lower_plus_least)
huffman@26927
   360
done
huffman@26927
   361
huffman@26927
   362
lemma lower_plus_strict2 [simp]: "xs +\<flat> \<bottom> = xs"
huffman@26927
   363
apply (rule antisym_less [OF _ lower_plus_less1])
huffman@26927
   364
apply (simp add: lower_plus_least)
huffman@26927
   365
done
huffman@26927
   366
huffman@26927
   367
lemma compact_lower_unit_iff [simp]: "compact {x}\<flat> \<longleftrightarrow> compact x"
huffman@26927
   368
unfolding bifinite_compact_iff by simp
huffman@26927
   369
huffman@26927
   370
lemma compact_lower_plus [simp]:
huffman@26927
   371
  "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs +\<flat> ys)"
huffman@26927
   372
apply (drule compact_imp_lower_principal)+
huffman@26927
   373
apply (auto simp add: compact_lower_principal)
huffman@26927
   374
done
huffman@26927
   375
huffman@25904
   376
huffman@25904
   377
subsection {* Induction rules *}
huffman@25904
   378
huffman@25904
   379
lemma lower_pd_induct1:
huffman@25904
   380
  assumes P: "adm P"
huffman@26927
   381
  assumes unit: "\<And>x. P {x}\<flat>"
huffman@25904
   382
  assumes insert:
huffman@26927
   383
    "\<And>x ys. \<lbrakk>P {x}\<flat>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<flat> +\<flat> ys)"
huffman@25904
   384
  shows "P (xs::'a lower_pd)"
huffman@25904
   385
apply (induct xs rule: lower_principal_induct, rule P)
huffman@25904
   386
apply (induct_tac t rule: pd_basis_induct1)
huffman@25904
   387
apply (simp only: lower_unit_Rep_compact_basis [symmetric])
huffman@25904
   388
apply (rule unit)
huffman@25904
   389
apply (simp only: lower_unit_Rep_compact_basis [symmetric]
huffman@25904
   390
                  lower_plus_principal [symmetric])
huffman@25904
   391
apply (erule insert [OF unit])
huffman@25904
   392
done
huffman@25904
   393
huffman@25904
   394
lemma lower_pd_induct:
huffman@25904
   395
  assumes P: "adm P"
huffman@26927
   396
  assumes unit: "\<And>x. P {x}\<flat>"
huffman@26927
   397
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs +\<flat> ys)"
huffman@25904
   398
  shows "P (xs::'a lower_pd)"
huffman@25904
   399
apply (induct xs rule: lower_principal_induct, rule P)
huffman@25904
   400
apply (induct_tac t rule: pd_basis_induct)
huffman@25904
   401
apply (simp only: lower_unit_Rep_compact_basis [symmetric] unit)
huffman@25904
   402
apply (simp only: lower_plus_principal [symmetric] plus)
huffman@25904
   403
done
huffman@25904
   404
huffman@25904
   405
huffman@25904
   406
subsection {* Monadic bind *}
huffman@25904
   407
huffman@25904
   408
definition
huffman@25904
   409
  lower_bind_basis ::
huffman@25904
   410
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
huffman@25904
   411
  "lower_bind_basis = fold_pd
huffman@25904
   412
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
huffman@26927
   413
    (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<flat> y\<cdot>f)"
huffman@25904
   414
huffman@26927
   415
lemma ACI_lower_bind:
huffman@26927
   416
  "ab_semigroup_idem_mult (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<flat> y\<cdot>f)"
huffman@25904
   417
apply unfold_locales
haftmann@26041
   418
apply (simp add: lower_plus_assoc)
huffman@25904
   419
apply (simp add: lower_plus_commute)
huffman@25904
   420
apply (simp add: lower_plus_absorb eta_cfun)
huffman@25904
   421
done
huffman@25904
   422
huffman@25904
   423
lemma lower_bind_basis_simps [simp]:
huffman@25904
   424
  "lower_bind_basis (PDUnit a) =
huffman@25904
   425
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
huffman@25904
   426
  "lower_bind_basis (PDPlus t u) =
huffman@26927
   427
    (\<Lambda> f. lower_bind_basis t\<cdot>f +\<flat> lower_bind_basis u\<cdot>f)"
huffman@25904
   428
unfolding lower_bind_basis_def
huffman@25904
   429
apply -
huffman@26927
   430
apply (rule fold_pd_PDUnit [OF ACI_lower_bind])
huffman@26927
   431
apply (rule fold_pd_PDPlus [OF ACI_lower_bind])
huffman@25904
   432
done
huffman@25904
   433
huffman@25904
   434
lemma lower_bind_basis_mono:
huffman@25904
   435
  "t \<le>\<flat> u \<Longrightarrow> lower_bind_basis t \<sqsubseteq> lower_bind_basis u"
huffman@25904
   436
unfolding expand_cfun_less
huffman@25904
   437
apply (erule lower_le_induct, safe)
huffman@25904
   438
apply (simp add: compact_le_def monofun_cfun)
huffman@25904
   439
apply (simp add: rev_trans_less [OF lower_plus_less1])
huffman@25904
   440
apply (simp add: lower_plus_less_iff)
huffman@25904
   441
done
huffman@25904
   442
huffman@25904
   443
definition
huffman@25904
   444
  lower_bind :: "'a lower_pd \<rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
huffman@25904
   445
  "lower_bind = lower_pd.basis_fun lower_bind_basis"
huffman@25904
   446
huffman@25904
   447
lemma lower_bind_principal [simp]:
huffman@25904
   448
  "lower_bind\<cdot>(lower_principal t) = lower_bind_basis t"
huffman@25904
   449
unfolding lower_bind_def
huffman@25904
   450
apply (rule lower_pd.basis_fun_principal)
huffman@25904
   451
apply (erule lower_bind_basis_mono)
huffman@25904
   452
done
huffman@25904
   453
huffman@25904
   454
lemma lower_bind_unit [simp]:
huffman@26927
   455
  "lower_bind\<cdot>{x}\<flat>\<cdot>f = f\<cdot>x"
huffman@25904
   456
by (induct x rule: compact_basis_induct, simp, simp)
huffman@25904
   457
huffman@25904
   458
lemma lower_bind_plus [simp]:
huffman@26927
   459
  "lower_bind\<cdot>(xs +\<flat> ys)\<cdot>f = lower_bind\<cdot>xs\<cdot>f +\<flat> lower_bind\<cdot>ys\<cdot>f"
huffman@25904
   460
by (induct xs ys rule: lower_principal_induct2, simp, simp, simp)
huffman@25904
   461
huffman@25904
   462
lemma lower_bind_strict [simp]: "lower_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
huffman@25904
   463
unfolding lower_unit_strict [symmetric] by (rule lower_bind_unit)
huffman@25904
   464
huffman@25904
   465
huffman@25904
   466
subsection {* Map and join *}
huffman@25904
   467
huffman@25904
   468
definition
huffman@25904
   469
  lower_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a lower_pd \<rightarrow> 'b lower_pd" where
huffman@26927
   470
  "lower_map = (\<Lambda> f xs. lower_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<flat>))"
huffman@25904
   471
huffman@25904
   472
definition
huffman@25904
   473
  lower_join :: "'a lower_pd lower_pd \<rightarrow> 'a lower_pd" where
huffman@25904
   474
  "lower_join = (\<Lambda> xss. lower_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
huffman@25904
   475
huffman@25904
   476
lemma lower_map_unit [simp]:
huffman@26927
   477
  "lower_map\<cdot>f\<cdot>{x}\<flat> = {f\<cdot>x}\<flat>"
huffman@25904
   478
unfolding lower_map_def by simp
huffman@25904
   479
huffman@25904
   480
lemma lower_map_plus [simp]:
huffman@26927
   481
  "lower_map\<cdot>f\<cdot>(xs +\<flat> ys) = lower_map\<cdot>f\<cdot>xs +\<flat> lower_map\<cdot>f\<cdot>ys"
huffman@25904
   482
unfolding lower_map_def by simp
huffman@25904
   483
huffman@25904
   484
lemma lower_join_unit [simp]:
huffman@26927
   485
  "lower_join\<cdot>{xs}\<flat> = xs"
huffman@25904
   486
unfolding lower_join_def by simp
huffman@25904
   487
huffman@25904
   488
lemma lower_join_plus [simp]:
huffman@26927
   489
  "lower_join\<cdot>(xss +\<flat> yss) = lower_join\<cdot>xss +\<flat> lower_join\<cdot>yss"
huffman@25904
   490
unfolding lower_join_def by simp
huffman@25904
   491
huffman@25904
   492
lemma lower_map_ident: "lower_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
huffman@25904
   493
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   494
huffman@25904
   495
lemma lower_map_map:
huffman@25904
   496
  "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
   497
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   498
huffman@25904
   499
lemma lower_join_map_unit:
huffman@25904
   500
  "lower_join\<cdot>(lower_map\<cdot>lower_unit\<cdot>xs) = xs"
huffman@25904
   501
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   502
huffman@25904
   503
lemma lower_join_map_join:
huffman@25904
   504
  "lower_join\<cdot>(lower_map\<cdot>lower_join\<cdot>xsss) = lower_join\<cdot>(lower_join\<cdot>xsss)"
huffman@25904
   505
by (induct xsss rule: lower_pd_induct, simp_all)
huffman@25904
   506
huffman@25904
   507
lemma lower_join_map_map:
huffman@25904
   508
  "lower_join\<cdot>(lower_map\<cdot>(lower_map\<cdot>f)\<cdot>xss) =
huffman@25904
   509
   lower_map\<cdot>f\<cdot>(lower_join\<cdot>xss)"
huffman@25904
   510
by (induct xss rule: lower_pd_induct, simp_all)
huffman@25904
   511
huffman@25904
   512
lemma lower_map_approx: "lower_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
huffman@25904
   513
by (induct xs rule: lower_pd_induct, simp_all)
huffman@25904
   514
huffman@25904
   515
end