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