src/HOLCF/LowerPD.thy
author huffman
Mon, 14 Jan 2008 19:26:41 +0100
changeset 25904 8161f137b0e9
child 25925 3dc4acca4388
permissions -rw-r--r--
new theory of powerdomains
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     1
(*  Title:      HOLCF/LowerPD.thy
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     2
    ID:         $Id$
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     3
    Author:     Brian Huffman
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     4
*)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     5
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     6
header {* Lower powerdomain *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     7
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     8
theory LowerPD
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     9
imports CompactBasis
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    10
begin
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    11
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    12
subsection {* Basis preorder *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    13
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    14
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    15
  lower_le :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> bool" (infix "\<le>\<flat>" 50) where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    16
  "lower_le = (\<lambda>u v. \<forall>x\<in>Rep_pd_basis u. \<exists>y\<in>Rep_pd_basis v. compact_le x y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    17
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    18
lemma lower_le_refl [simp]: "t \<le>\<flat> t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    19
unfolding lower_le_def by (fast intro: compact_le_refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    20
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    21
lemma lower_le_trans: "\<lbrakk>t \<le>\<flat> u; u \<le>\<flat> v\<rbrakk> \<Longrightarrow> t \<le>\<flat> v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    22
unfolding lower_le_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    23
apply (rule ballI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    24
apply (drule (1) bspec, erule bexE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    25
apply (drule (1) bspec, erule bexE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    26
apply (erule rev_bexI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    27
apply (erule (1) compact_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    28
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    29
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    30
interpretation lower_le: preorder [lower_le]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    31
by (rule preorder.intro, rule lower_le_refl, rule lower_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    32
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    33
lemma lower_le_minimal [simp]: "PDUnit compact_bot \<le>\<flat> t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    34
unfolding lower_le_def Rep_PDUnit
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    35
by (simp, rule Rep_pd_basis_nonempty [folded ex_in_conv])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    36
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    37
lemma PDUnit_lower_mono: "compact_le x y \<Longrightarrow> PDUnit x \<le>\<flat> PDUnit y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    38
unfolding lower_le_def Rep_PDUnit by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    39
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    40
lemma PDPlus_lower_mono: "\<lbrakk>s \<le>\<flat> t; u \<le>\<flat> v\<rbrakk> \<Longrightarrow> PDPlus s u \<le>\<flat> PDPlus t v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    41
unfolding lower_le_def Rep_PDPlus by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    42
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    43
lemma PDPlus_lower_less: "t \<le>\<flat> PDPlus t u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    44
unfolding lower_le_def Rep_PDPlus by (fast intro: compact_le_refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    45
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    46
lemma lower_le_PDUnit_PDUnit_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    47
  "(PDUnit a \<le>\<flat> PDUnit b) = compact_le a b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    48
unfolding lower_le_def Rep_PDUnit by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    49
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    50
lemma lower_le_PDUnit_PDPlus_iff:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    51
  "(PDUnit a \<le>\<flat> PDPlus t u) = (PDUnit a \<le>\<flat> t \<or> PDUnit a \<le>\<flat> u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    52
unfolding lower_le_def Rep_PDPlus Rep_PDUnit by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    53
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    54
lemma lower_le_PDPlus_iff: "(PDPlus t u \<le>\<flat> v) = (t \<le>\<flat> v \<and> u \<le>\<flat> v)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    55
unfolding lower_le_def Rep_PDPlus by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    56
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    57
lemma lower_le_induct [induct set: lower_le]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    58
  assumes le: "t \<le>\<flat> u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    59
  assumes 1: "\<And>a b. compact_le a b \<Longrightarrow> P (PDUnit a) (PDUnit b)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    60
  assumes 2: "\<And>t u a. P (PDUnit a) t \<Longrightarrow> P (PDUnit a) (PDPlus t u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    61
  assumes 3: "\<And>t u v. \<lbrakk>P t v; P u v\<rbrakk> \<Longrightarrow> P (PDPlus t u) v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    62
  shows "P t u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    63
using le
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    64
apply (induct t arbitrary: u rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    65
apply (erule rev_mp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    66
apply (induct_tac u rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    67
apply (simp add: 1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    68
apply (simp add: lower_le_PDUnit_PDPlus_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    69
apply (simp add: 2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    70
apply (subst PDPlus_commute)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    71
apply (simp add: 2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    72
apply (simp add: lower_le_PDPlus_iff 3)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    73
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    74
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    75
lemma approx_pd_lower_mono1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    76
  "i \<le> j \<Longrightarrow> approx_pd i t \<le>\<flat> approx_pd j t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    77
apply (induct t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    78
apply (simp add: compact_approx_mono1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    79
apply (simp add: PDPlus_lower_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    80
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    81
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    82
lemma approx_pd_lower_le: "approx_pd i t \<le>\<flat> t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    83
apply (induct t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    84
apply (simp add: compact_approx_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    85
apply (simp add: PDPlus_lower_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    86
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    87
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    88
lemma approx_pd_lower_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    89
  "t \<le>\<flat> u \<Longrightarrow> approx_pd n t \<le>\<flat> approx_pd n u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    90
apply (erule lower_le_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    91
apply (simp add: compact_approx_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    92
apply (simp add: lower_le_PDUnit_PDPlus_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    93
apply (simp add: lower_le_PDPlus_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    94
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    95
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    96
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    97
subsection {* Type definition *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    98
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    99
cpodef (open) 'a lower_pd =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   100
  "{S::'a::bifinite pd_basis set. lower_le.ideal S}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   101
apply (simp add: lower_le.adm_ideal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   102
apply (fast intro: lower_le.ideal_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   103
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   104
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   105
lemma ideal_Rep_lower_pd: "lower_le.ideal (Rep_lower_pd x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   106
by (rule Rep_lower_pd [simplified])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   107
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   108
lemma Rep_lower_pd_mono: "x \<sqsubseteq> y \<Longrightarrow> Rep_lower_pd x \<subseteq> Rep_lower_pd y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   109
unfolding less_lower_pd_def less_set_def .
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   110
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   111
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   112
subsection {* Principal ideals *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   113
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   114
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   115
  lower_principal :: "'a pd_basis \<Rightarrow> 'a lower_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   116
  "lower_principal t = Abs_lower_pd {u. u \<le>\<flat> t}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   117
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   118
lemma Rep_lower_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   119
  "Rep_lower_pd (lower_principal t) = {u. u \<le>\<flat> t}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   120
unfolding lower_principal_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   121
apply (rule Abs_lower_pd_inverse [simplified])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   122
apply (rule lower_le.ideal_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   123
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   124
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   125
interpretation lower_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   126
  bifinite_basis [lower_le lower_principal Rep_lower_pd approx_pd]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   127
apply unfold_locales
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   128
apply (rule ideal_Rep_lower_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   129
apply (rule cont_Rep_lower_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   130
apply (rule Rep_lower_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   131
apply (simp only: less_lower_pd_def less_set_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   132
apply (rule approx_pd_lower_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   133
apply (rule approx_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   134
apply (erule approx_pd_lower_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   135
apply (rule approx_pd_lower_mono1, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   136
apply (rule finite_range_approx_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   137
apply (rule ex_approx_pd_eq)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   138
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   139
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   140
lemma lower_principal_less_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   141
  "(lower_principal t \<sqsubseteq> lower_principal u) = (t \<le>\<flat> u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   142
unfolding less_lower_pd_def Rep_lower_principal less_set_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   143
by (fast intro: lower_le_refl elim: lower_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   144
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   145
lemma lower_principal_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   146
  "t \<le>\<flat> u \<Longrightarrow> lower_principal t \<sqsubseteq> lower_principal u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   147
by (rule lower_principal_less_iff [THEN iffD2])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   148
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   149
lemma compact_lower_principal: "compact (lower_principal t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   150
apply (rule compactI2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   151
apply (simp add: less_lower_pd_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   152
apply (simp add: cont2contlubE [OF cont_Rep_lower_pd])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   153
apply (simp add: Rep_lower_principal set_cpo_simps)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   154
apply (simp add: subset_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   155
apply (drule spec, drule mp, rule lower_le_refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   156
apply (erule exE, rename_tac i)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   157
apply (rule_tac x=i in exI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   158
apply clarify
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   159
apply (erule (1) lower_le.idealD3 [OF ideal_Rep_lower_pd])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   160
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   161
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   162
lemma lower_pd_minimal: "lower_principal (PDUnit compact_bot) \<sqsubseteq> ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   163
by (induct ys rule: lower_pd.principal_induct, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   164
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   165
instance lower_pd :: (bifinite) pcpo
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   166
by (intro_classes, fast intro: lower_pd_minimal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   167
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   168
lemma inst_lower_pd_pcpo: "\<bottom> = lower_principal (PDUnit compact_bot)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   169
by (rule lower_pd_minimal [THEN UU_I, symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   170
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   171
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   172
subsection {* Approximation *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   173
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   174
instance lower_pd :: (bifinite) approx ..
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   175
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   176
defs (overloaded)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   177
  approx_lower_pd_def:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   178
    "approx \<equiv> (\<lambda>n. lower_pd.basis_fun (\<lambda>t. lower_principal (approx_pd n t)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   179
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   180
lemma approx_lower_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   181
  "approx n\<cdot>(lower_principal t) = lower_principal (approx_pd n t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   182
unfolding approx_lower_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   183
apply (rule lower_pd.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   184
apply (erule lower_principal_mono [OF approx_pd_lower_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   185
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   186
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   187
lemma chain_approx_lower_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   188
  "chain (approx :: nat \<Rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   189
unfolding approx_lower_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   190
by (rule lower_pd.chain_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   191
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   192
lemma lub_approx_lower_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   193
  "(\<Squnion>i. approx i\<cdot>xs) = (xs::'a lower_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   194
unfolding approx_lower_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   195
by (rule lower_pd.lub_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   196
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   197
lemma approx_lower_pd_idem:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   198
  "approx n\<cdot>(approx n\<cdot>xs) = approx n\<cdot>(xs::'a lower_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   199
apply (induct xs rule: lower_pd.principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   200
apply (simp add: approx_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   201
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   202
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   203
lemma approx_eq_lower_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   204
  "\<exists>t\<in>Rep_lower_pd xs. approx n\<cdot>xs = lower_principal (approx_pd n t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   205
unfolding approx_lower_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   206
by (rule lower_pd.basis_fun_take_eq_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   207
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   208
lemma finite_fixes_approx_lower_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   209
  "finite {xs::'a lower_pd. approx n\<cdot>xs = xs}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   210
unfolding approx_lower_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   211
by (rule lower_pd.finite_fixes_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   212
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   213
instance lower_pd :: (bifinite) bifinite
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   214
apply intro_classes
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   215
apply (simp add: chain_approx_lower_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   216
apply (rule lub_approx_lower_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   217
apply (rule approx_lower_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   218
apply (rule finite_fixes_approx_lower_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   219
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   220
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   221
lemma compact_imp_lower_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   222
  "compact xs \<Longrightarrow> \<exists>t. xs = lower_principal t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   223
apply (drule bifinite_compact_eq_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   224
apply (erule exE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   225
apply (erule subst)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   226
apply (cut_tac n=i and xs=xs in approx_eq_lower_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   227
apply fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   228
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   229
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   230
lemma lower_principal_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   231
  "\<lbrakk>adm P; \<And>t. P (lower_principal t)\<rbrakk> \<Longrightarrow> P xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   232
apply (erule approx_induct, rename_tac xs)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   233
apply (cut_tac n=n and xs=xs in approx_eq_lower_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   234
apply (clarify, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   235
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   236
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   237
lemma lower_principal_induct2:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   238
  "\<lbrakk>\<And>ys. adm (\<lambda>xs. P xs ys); \<And>xs. adm (\<lambda>ys. P xs ys);
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   239
    \<And>t u. P (lower_principal t) (lower_principal u)\<rbrakk> \<Longrightarrow> P xs ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   240
apply (rule_tac x=ys in spec)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   241
apply (rule_tac xs=xs in lower_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   242
apply (rule allI, rename_tac ys)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   243
apply (rule_tac xs=ys in lower_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   244
apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   245
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   246
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   247
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   248
subsection {* Monadic unit *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   249
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   250
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   251
  lower_unit :: "'a \<rightarrow> 'a lower_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   252
  "lower_unit = compact_basis.basis_fun (\<lambda>a. lower_principal (PDUnit a))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   253
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   254
lemma lower_unit_Rep_compact_basis [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   255
  "lower_unit\<cdot>(Rep_compact_basis a) = lower_principal (PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   256
unfolding lower_unit_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   257
apply (rule compact_basis.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   258
apply (rule lower_principal_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   259
apply (erule PDUnit_lower_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   260
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   261
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   262
lemma lower_unit_strict [simp]: "lower_unit\<cdot>\<bottom> = \<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   263
unfolding inst_lower_pd_pcpo Rep_compact_bot [symmetric] by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   264
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   265
lemma approx_lower_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   266
  "approx n\<cdot>(lower_unit\<cdot>x) = lower_unit\<cdot>(approx n\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   267
apply (induct x rule: compact_basis_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   268
apply (simp add: approx_Rep_compact_basis)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   269
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   270
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   271
lemma lower_unit_less_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   272
  "(lower_unit\<cdot>x \<sqsubseteq> lower_unit\<cdot>y) = (x \<sqsubseteq> y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   273
 apply (rule iffI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   274
  apply (rule bifinite_less_ext)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   275
  apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   276
  apply (cut_tac x="approx i\<cdot>x" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   277
  apply (cut_tac x="approx i\<cdot>y" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   278
  apply (clarify, simp add: compact_le_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   279
 apply (erule monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   280
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   281
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   282
lemma lower_unit_eq_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   283
  "(lower_unit\<cdot>x = lower_unit\<cdot>y) = (x = y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   284
unfolding po_eq_conv by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   285
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   286
lemma lower_unit_strict_iff [simp]: "(lower_unit\<cdot>x = \<bottom>) = (x = \<bottom>)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   287
unfolding lower_unit_strict [symmetric] by (rule lower_unit_eq_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   288
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   289
lemma compact_lower_unit_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   290
  "compact (lower_unit\<cdot>x) = compact x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   291
unfolding bifinite_compact_iff by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   292
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   293
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   294
subsection {* Monadic plus *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   295
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   296
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   297
  lower_plus :: "'a lower_pd \<rightarrow> 'a lower_pd \<rightarrow> 'a lower_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   298
  "lower_plus = lower_pd.basis_fun (\<lambda>t. lower_pd.basis_fun (\<lambda>u.
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   299
      lower_principal (PDPlus t u)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   300
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   301
abbreviation
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   302
  lower_add :: "'a lower_pd \<Rightarrow> 'a lower_pd \<Rightarrow> 'a lower_pd"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   303
    (infixl "+\<flat>" 65) where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   304
  "xs +\<flat> ys == lower_plus\<cdot>xs\<cdot>ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   305
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   306
lemma lower_plus_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   307
  "lower_plus\<cdot>(lower_principal t)\<cdot>(lower_principal u) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   308
   lower_principal (PDPlus t u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   309
unfolding lower_plus_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   310
by (simp add: lower_pd.basis_fun_principal
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   311
    lower_pd.basis_fun_mono PDPlus_lower_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   312
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   313
lemma approx_lower_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   314
  "approx n\<cdot>(lower_plus\<cdot>xs\<cdot>ys) = lower_plus\<cdot>(approx n\<cdot>xs)\<cdot>(approx n\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   315
by (induct xs ys rule: lower_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   316
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   317
lemma lower_plus_commute: "lower_plus\<cdot>xs\<cdot>ys = lower_plus\<cdot>ys\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   318
apply (induct xs ys rule: lower_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   319
apply (simp add: PDPlus_commute)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   320
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   321
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   322
lemma lower_plus_assoc:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   323
  "lower_plus\<cdot>(lower_plus\<cdot>xs\<cdot>ys)\<cdot>zs = lower_plus\<cdot>xs\<cdot>(lower_plus\<cdot>ys\<cdot>zs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   324
apply (induct xs ys arbitrary: zs rule: lower_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   325
apply (rule_tac xs=zs in lower_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   326
apply (simp add: PDPlus_assoc)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   327
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   328
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   329
lemma lower_plus_absorb: "lower_plus\<cdot>xs\<cdot>xs = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   330
apply (induct xs rule: lower_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   331
apply (simp add: PDPlus_absorb)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   332
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   333
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   334
lemma lower_plus_less1: "xs \<sqsubseteq> lower_plus\<cdot>xs\<cdot>ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   335
apply (induct xs ys rule: lower_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   336
apply (simp add: PDPlus_lower_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   337
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   338
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   339
lemma lower_plus_less2: "ys \<sqsubseteq> lower_plus\<cdot>xs\<cdot>ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   340
by (subst lower_plus_commute, rule lower_plus_less1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   341
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   342
lemma lower_plus_least: "\<lbrakk>xs \<sqsubseteq> zs; ys \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> lower_plus\<cdot>xs\<cdot>ys \<sqsubseteq> zs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   343
apply (subst lower_plus_absorb [of zs, symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   344
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   345
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   346
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   347
lemma lower_plus_less_iff:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   348
  "(lower_plus\<cdot>xs\<cdot>ys \<sqsubseteq> zs) = (xs \<sqsubseteq> zs \<and> ys \<sqsubseteq> zs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   349
apply safe
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   350
apply (erule trans_less [OF lower_plus_less1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   351
apply (erule trans_less [OF lower_plus_less2])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   352
apply (erule (1) lower_plus_least)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   353
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   354
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   355
lemma lower_plus_strict_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   356
  "(lower_plus\<cdot>xs\<cdot>ys = \<bottom>) = (xs = \<bottom> \<and> ys = \<bottom>)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   357
apply safe
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   358
apply (rule UU_I, erule subst, rule lower_plus_less1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   359
apply (rule UU_I, erule subst, rule lower_plus_less2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   360
apply (rule lower_plus_absorb)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   361
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   362
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   363
lemma lower_plus_strict1 [simp]: "lower_plus\<cdot>\<bottom>\<cdot>ys = ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   364
apply (rule antisym_less [OF _ lower_plus_less2])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   365
apply (simp add: lower_plus_least)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   366
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   367
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   368
lemma lower_plus_strict2 [simp]: "lower_plus\<cdot>xs\<cdot>\<bottom> = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   369
apply (rule antisym_less [OF _ lower_plus_less1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   370
apply (simp add: lower_plus_least)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   371
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   372
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   373
lemma lower_unit_less_plus_iff:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   374
  "(lower_unit\<cdot>x \<sqsubseteq> lower_plus\<cdot>ys\<cdot>zs) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   375
    (lower_unit\<cdot>x \<sqsubseteq> ys \<or> lower_unit\<cdot>x \<sqsubseteq> zs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   376
 apply (rule iffI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   377
  apply (subgoal_tac
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   378
    "adm (\<lambda>f. f\<cdot>(lower_unit\<cdot>x) \<sqsubseteq> f\<cdot>ys \<or> f\<cdot>(lower_unit\<cdot>x) \<sqsubseteq> f\<cdot>zs)")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   379
   apply (drule admD [rule_format], rule chain_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   380
    apply (drule_tac f="approx i" in monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   381
    apply (cut_tac x="approx i\<cdot>x" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   382
    apply (cut_tac xs="approx i\<cdot>ys" in compact_imp_lower_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   383
    apply (cut_tac xs="approx i\<cdot>zs" in compact_imp_lower_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   384
    apply (clarify, simp add: lower_le_PDUnit_PDPlus_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   385
   apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   386
  apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   387
 apply (erule disjE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   388
  apply (erule trans_less [OF _ lower_plus_less1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   389
 apply (erule trans_less [OF _ lower_plus_less2])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   390
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   391
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   392
lemmas lower_pd_less_simps =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   393
  lower_unit_less_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   394
  lower_plus_less_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   395
  lower_unit_less_plus_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   396
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   397
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   398
subsection {* Induction rules *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   399
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   400
lemma lower_pd_induct1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   401
  assumes P: "adm P"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   402
  assumes unit: "\<And>x. P (lower_unit\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   403
  assumes insert:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   404
    "\<And>x ys. \<lbrakk>P (lower_unit\<cdot>x); P ys\<rbrakk> \<Longrightarrow> P (lower_plus\<cdot>(lower_unit\<cdot>x)\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   405
  shows "P (xs::'a lower_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   406
apply (induct xs rule: lower_principal_induct, rule P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   407
apply (induct_tac t rule: pd_basis_induct1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   408
apply (simp only: lower_unit_Rep_compact_basis [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   409
apply (rule unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   410
apply (simp only: lower_unit_Rep_compact_basis [symmetric]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   411
                  lower_plus_principal [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   412
apply (erule insert [OF unit])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   413
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   414
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   415
lemma lower_pd_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   416
  assumes P: "adm P"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   417
  assumes unit: "\<And>x. P (lower_unit\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   418
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (lower_plus\<cdot>xs\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   419
  shows "P (xs::'a lower_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   420
apply (induct xs rule: lower_principal_induct, rule P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   421
apply (induct_tac t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   422
apply (simp only: lower_unit_Rep_compact_basis [symmetric] unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   423
apply (simp only: lower_plus_principal [symmetric] plus)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   424
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   425
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   426
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   427
subsection {* Monadic bind *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   428
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   429
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   430
  lower_bind_basis ::
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   431
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   432
  "lower_bind_basis = fold_pd
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   433
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   434
    (\<lambda>x y. \<Lambda> f. lower_plus\<cdot>(x\<cdot>f)\<cdot>(y\<cdot>f))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   435
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   436
lemma ACI_lower_bind: "ACIf (\<lambda>x y. \<Lambda> f. lower_plus\<cdot>(x\<cdot>f)\<cdot>(y\<cdot>f))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   437
apply unfold_locales
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   438
apply (simp add: lower_plus_commute)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   439
apply (simp add: lower_plus_assoc)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   440
apply (simp add: lower_plus_absorb eta_cfun)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   441
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   442
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   443
lemma lower_bind_basis_simps [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   444
  "lower_bind_basis (PDUnit a) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   445
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   446
  "lower_bind_basis (PDPlus t u) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   447
    (\<Lambda> f. lower_plus\<cdot>(lower_bind_basis t\<cdot>f)\<cdot>(lower_bind_basis u\<cdot>f))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   448
unfolding lower_bind_basis_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   449
apply -
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   450
apply (rule ACIf.fold_pd_PDUnit [OF ACI_lower_bind])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   451
apply (rule ACIf.fold_pd_PDPlus [OF ACI_lower_bind])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   452
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   453
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   454
lemma lower_bind_basis_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   455
  "t \<le>\<flat> u \<Longrightarrow> lower_bind_basis t \<sqsubseteq> lower_bind_basis u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   456
unfolding expand_cfun_less
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   457
apply (erule lower_le_induct, safe)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   458
apply (simp add: compact_le_def monofun_cfun)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   459
apply (simp add: rev_trans_less [OF lower_plus_less1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   460
apply (simp add: lower_plus_less_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   461
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   462
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   463
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   464
  lower_bind :: "'a lower_pd \<rightarrow> ('a \<rightarrow> 'b lower_pd) \<rightarrow> 'b lower_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   465
  "lower_bind = lower_pd.basis_fun lower_bind_basis"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   466
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   467
lemma lower_bind_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   468
  "lower_bind\<cdot>(lower_principal t) = lower_bind_basis t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   469
unfolding lower_bind_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   470
apply (rule lower_pd.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   471
apply (erule lower_bind_basis_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   472
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   473
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   474
lemma lower_bind_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   475
  "lower_bind\<cdot>(lower_unit\<cdot>x)\<cdot>f = f\<cdot>x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   476
by (induct x rule: compact_basis_induct, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   477
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   478
lemma lower_bind_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   479
  "lower_bind\<cdot>(lower_plus\<cdot>xs\<cdot>ys)\<cdot>f =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   480
   lower_plus\<cdot>(lower_bind\<cdot>xs\<cdot>f)\<cdot>(lower_bind\<cdot>ys\<cdot>f)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   481
by (induct xs ys rule: lower_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   482
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   483
lemma lower_bind_strict [simp]: "lower_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   484
unfolding lower_unit_strict [symmetric] by (rule lower_bind_unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   485
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   486
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   487
subsection {* Map and join *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   488
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   489
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   490
  lower_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a lower_pd \<rightarrow> 'b lower_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   491
  "lower_map = (\<Lambda> f xs. lower_bind\<cdot>xs\<cdot>(\<Lambda> x. lower_unit\<cdot>(f\<cdot>x)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   492
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   493
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   494
  lower_join :: "'a lower_pd lower_pd \<rightarrow> 'a lower_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   495
  "lower_join = (\<Lambda> xss. lower_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   496
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   497
lemma lower_map_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   498
  "lower_map\<cdot>f\<cdot>(lower_unit\<cdot>x) = lower_unit\<cdot>(f\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   499
unfolding lower_map_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   500
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   501
lemma lower_map_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   502
  "lower_map\<cdot>f\<cdot>(lower_plus\<cdot>xs\<cdot>ys) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   503
   lower_plus\<cdot>(lower_map\<cdot>f\<cdot>xs)\<cdot>(lower_map\<cdot>f\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   504
unfolding lower_map_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   505
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   506
lemma lower_join_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   507
  "lower_join\<cdot>(lower_unit\<cdot>xs) = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   508
unfolding lower_join_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   509
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   510
lemma lower_join_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   511
  "lower_join\<cdot>(lower_plus\<cdot>xss\<cdot>yss) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   512
   lower_plus\<cdot>(lower_join\<cdot>xss)\<cdot>(lower_join\<cdot>yss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   513
unfolding lower_join_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   514
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   515
lemma lower_map_ident: "lower_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   516
by (induct xs rule: lower_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   517
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   518
lemma lower_map_map:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   519
  "lower_map\<cdot>f\<cdot>(lower_map\<cdot>g\<cdot>xs) = lower_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   520
by (induct xs rule: lower_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   521
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   522
lemma lower_join_map_unit:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   523
  "lower_join\<cdot>(lower_map\<cdot>lower_unit\<cdot>xs) = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   524
by (induct xs rule: lower_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   525
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   526
lemma lower_join_map_join:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   527
  "lower_join\<cdot>(lower_map\<cdot>lower_join\<cdot>xsss) = lower_join\<cdot>(lower_join\<cdot>xsss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   528
by (induct xsss rule: lower_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   529
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   530
lemma lower_join_map_map:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   531
  "lower_join\<cdot>(lower_map\<cdot>(lower_map\<cdot>f)\<cdot>xss) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   532
   lower_map\<cdot>f\<cdot>(lower_join\<cdot>xss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   533
by (induct xss rule: lower_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   534
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   535
lemma lower_map_approx: "lower_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   536
by (induct xs rule: lower_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   537
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   538
end