src/HOLCF/UpperPD.thy
author wenzelm
Thu, 19 Jun 2008 20:48:01 +0200
changeset 27277 7b7ce2d7fafe
parent 27267 5ebfb7f25ebb
child 27289 c49d427867aa
permissions -rw-r--r--
export read_typ/cert_typ -- version with regular context operations;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     1
(*  Title:      HOLCF/UpperPD.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 {* Upper powerdomain *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     7
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     8
theory UpperPD
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
  upper_le :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> bool" (infix "\<le>\<sharp>" 50) where
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
    16
  "upper_le = (\<lambda>u v. \<forall>y\<in>Rep_pd_basis v. \<exists>x\<in>Rep_pd_basis u. 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 upper_le_refl [simp]: "t \<le>\<sharp> t"
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
    19
unfolding upper_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 upper_le_trans: "\<lbrakk>t \<le>\<sharp> u; u \<le>\<sharp> v\<rbrakk> \<Longrightarrow> t \<le>\<sharp> v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    22
unfolding upper_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 upper_le: preorder [upper_le]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    31
by (rule preorder.intro, rule upper_le_refl, rule upper_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    32
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    33
lemma upper_le_minimal [simp]: "PDUnit compact_bot \<le>\<sharp> t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    34
unfolding upper_le_def Rep_PDUnit by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    35
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
    36
lemma PDUnit_upper_mono: "x \<sqsubseteq> y \<Longrightarrow> PDUnit x \<le>\<sharp> PDUnit y"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    37
unfolding upper_le_def Rep_PDUnit by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    38
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    39
lemma PDPlus_upper_mono: "\<lbrakk>s \<le>\<sharp> t; u \<le>\<sharp> v\<rbrakk> \<Longrightarrow> PDPlus s u \<le>\<sharp> PDPlus t v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    40
unfolding upper_le_def Rep_PDPlus by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    41
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    42
lemma PDPlus_upper_less: "PDPlus t u \<le>\<sharp> t"
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
    43
unfolding upper_le_def Rep_PDPlus by fast
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    44
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    45
lemma upper_le_PDUnit_PDUnit_iff [simp]:
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
    46
  "(PDUnit a \<le>\<sharp> PDUnit b) = a \<sqsubseteq> b"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    47
unfolding upper_le_def Rep_PDUnit by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    48
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    49
lemma upper_le_PDPlus_PDUnit_iff:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    50
  "(PDPlus t u \<le>\<sharp> PDUnit a) = (t \<le>\<sharp> PDUnit a \<or> u \<le>\<sharp> PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    51
unfolding upper_le_def Rep_PDPlus Rep_PDUnit by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    52
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    53
lemma upper_le_PDPlus_iff: "(t \<le>\<sharp> PDPlus u v) = (t \<le>\<sharp> u \<and> t \<le>\<sharp> v)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    54
unfolding upper_le_def Rep_PDPlus by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    55
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    56
lemma upper_le_induct [induct set: upper_le]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    57
  assumes le: "t \<le>\<sharp> u"
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
    58
  assumes 1: "\<And>a b. a \<sqsubseteq> b \<Longrightarrow> P (PDUnit a) (PDUnit b)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    59
  assumes 2: "\<And>t u a. P t (PDUnit a) \<Longrightarrow> P (PDPlus t u) (PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    60
  assumes 3: "\<And>t u v. \<lbrakk>P t u; P t v\<rbrakk> \<Longrightarrow> P t (PDPlus u v)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    61
  shows "P t u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    62
using le apply (induct u arbitrary: t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    63
apply (erule rev_mp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    64
apply (induct_tac t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    65
apply (simp add: 1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    66
apply (simp add: upper_le_PDPlus_PDUnit_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    67
apply (simp add: 2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    68
apply (subst PDPlus_commute)
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 (simp add: upper_le_PDPlus_iff 3)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    71
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    72
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    73
lemma approx_pd_upper_mono1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    74
  "i \<le> j \<Longrightarrow> approx_pd i t \<le>\<sharp> approx_pd j t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    75
apply (induct t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    76
apply (simp add: compact_approx_mono1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    77
apply (simp add: PDPlus_upper_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    78
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    79
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    80
lemma approx_pd_upper_le: "approx_pd i t \<le>\<sharp> t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    81
apply (induct t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    82
apply (simp add: compact_approx_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    83
apply (simp add: PDPlus_upper_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    84
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    85
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    86
lemma approx_pd_upper_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    87
  "t \<le>\<sharp> u \<Longrightarrow> approx_pd n t \<le>\<sharp> approx_pd n u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    88
apply (erule upper_le_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    89
apply (simp add: compact_approx_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    90
apply (simp add: upper_le_PDPlus_PDUnit_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    91
apply (simp add: upper_le_PDPlus_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    92
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    93
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    94
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    95
subsection {* Type definition *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    96
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    97
cpodef (open) 'a upper_pd =
26407
562a1d615336 rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents: 26041
diff changeset
    98
  "{S::'a::profinite pd_basis set. upper_le.ideal S}"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    99
apply (simp add: upper_le.adm_ideal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   100
apply (fast intro: upper_le.ideal_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   101
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   102
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   103
lemma ideal_Rep_upper_pd: "upper_le.ideal (Rep_upper_pd x)"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   104
by (rule Rep_upper_pd [unfolded mem_Collect_eq])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   105
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   106
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   107
  upper_principal :: "'a pd_basis \<Rightarrow> 'a upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   108
  "upper_principal t = Abs_upper_pd {u. u \<le>\<sharp> t}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   109
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   110
lemma Rep_upper_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   111
  "Rep_upper_pd (upper_principal t) = {u. u \<le>\<sharp> t}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   112
unfolding upper_principal_def
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   113
apply (rule Abs_upper_pd_inverse [unfolded mem_Collect_eq])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   114
apply (rule upper_le.ideal_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   115
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   116
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   117
interpretation upper_pd:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   118
  ideal_completion [upper_le approx_pd upper_principal Rep_upper_pd]
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   119
apply unfold_locales
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   120
apply (rule approx_pd_upper_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   121
apply (rule approx_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   122
apply (erule approx_pd_upper_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   123
apply (rule approx_pd_upper_mono1, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   124
apply (rule finite_range_approx_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   125
apply (rule ex_approx_pd_eq)
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   126
apply (rule ideal_Rep_upper_pd)
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   127
apply (rule cont_Rep_upper_pd)
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   128
apply (rule Rep_upper_principal)
26806
40b411ec05aa Adapted to encoding of sets as predicates
berghofe
parents: 26420
diff changeset
   129
apply (simp only: less_upper_pd_def less_set_eq)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   130
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   131
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   132
lemma upper_principal_less_iff [simp]:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   133
  "upper_principal t \<sqsubseteq> upper_principal u \<longleftrightarrow> t \<le>\<sharp> u"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   134
by (rule upper_pd.principal_less_iff)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   135
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   136
lemma upper_principal_eq_iff:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   137
  "upper_principal t = upper_principal u \<longleftrightarrow> t \<le>\<sharp> u \<and> u \<le>\<sharp> t"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   138
by (rule upper_pd.principal_eq_iff)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   139
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   140
lemma upper_principal_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   141
  "t \<le>\<sharp> u \<Longrightarrow> upper_principal t \<sqsubseteq> upper_principal u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   142
by (rule upper_pd.principal_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   143
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   144
lemma compact_upper_principal: "compact (upper_principal t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   145
by (rule upper_pd.compact_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   146
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   147
lemma upper_pd_minimal: "upper_principal (PDUnit compact_bot) \<sqsubseteq> ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   148
by (induct ys rule: upper_pd.principal_induct, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   149
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   150
instance upper_pd :: (bifinite) pcpo
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   151
by intro_classes (fast intro: upper_pd_minimal)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   152
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   153
lemma inst_upper_pd_pcpo: "\<bottom> = upper_principal (PDUnit compact_bot)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   154
by (rule upper_pd_minimal [THEN UU_I, symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   155
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   156
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   157
subsection {* Approximation *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   158
26962
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26927
diff changeset
   159
instantiation upper_pd :: (profinite) profinite
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26927
diff changeset
   160
begin
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   161
26962
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26927
diff changeset
   162
definition
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26927
diff changeset
   163
  approx_upper_pd_def: "approx = upper_pd.completion_approx"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   164
26962
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26927
diff changeset
   165
instance
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   166
apply (intro_classes, unfold approx_upper_pd_def)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   167
apply (simp add: upper_pd.chain_completion_approx)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   168
apply (rule upper_pd.lub_completion_approx)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   169
apply (rule upper_pd.completion_approx_idem)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   170
apply (rule upper_pd.finite_fixes_completion_approx)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   171
done
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   172
26962
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26927
diff changeset
   173
end
c8b20f615d6c use new class package for classes profinite, bifinite; remove approx class
huffman
parents: 26927
diff changeset
   174
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   175
instance upper_pd :: (bifinite) bifinite ..
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   176
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   177
lemma approx_upper_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   178
  "approx n\<cdot>(upper_principal t) = upper_principal (approx_pd n t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   179
unfolding approx_upper_pd_def
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   180
by (rule upper_pd.completion_approx_principal)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   181
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   182
lemma approx_eq_upper_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   183
  "\<exists>t\<in>Rep_upper_pd xs. approx n\<cdot>xs = upper_principal (approx_pd n t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   184
unfolding approx_upper_pd_def
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   185
by (rule upper_pd.completion_approx_eq_principal)
26407
562a1d615336 rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents: 26041
diff changeset
   186
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   187
lemma compact_imp_upper_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   188
  "compact xs \<Longrightarrow> \<exists>t. xs = upper_principal t"
27267
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26962
diff changeset
   189
by (rule upper_pd.compact_imp_principal)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   190
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   191
lemma upper_principal_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   192
  "\<lbrakk>adm P; \<And>t. P (upper_principal t)\<rbrakk> \<Longrightarrow> P xs"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   193
by (rule upper_pd.principal_induct)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   194
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   195
lemma upper_principal_induct2:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   196
  "\<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
   197
    \<And>t u. P (upper_principal t) (upper_principal u)\<rbrakk> \<Longrightarrow> P xs ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   198
apply (rule_tac x=ys in spec)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   199
apply (rule_tac xs=xs in upper_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   200
apply (rule allI, rename_tac ys)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   201
apply (rule_tac xs=ys in upper_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   202
apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   203
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   204
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   205
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   206
subsection {* Monadic unit and plus *}
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   207
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   208
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   209
  upper_unit :: "'a \<rightarrow> 'a upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   210
  "upper_unit = compact_basis.basis_fun (\<lambda>a. upper_principal (PDUnit a))"
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
  upper_plus :: "'a upper_pd \<rightarrow> 'a upper_pd \<rightarrow> 'a upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   214
  "upper_plus = upper_pd.basis_fun (\<lambda>t. upper_pd.basis_fun (\<lambda>u.
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   215
      upper_principal (PDPlus t u)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   216
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   217
abbreviation
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   218
  upper_add :: "'a upper_pd \<Rightarrow> 'a upper_pd \<Rightarrow> 'a upper_pd"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   219
    (infixl "+\<sharp>" 65) where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   220
  "xs +\<sharp> ys == upper_plus\<cdot>xs\<cdot>ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   221
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   222
syntax
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   223
  "_upper_pd" :: "args \<Rightarrow> 'a upper_pd" ("{_}\<sharp>")
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   224
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   225
translations
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   226
  "{x,xs}\<sharp>" == "{x}\<sharp> +\<sharp> {xs}\<sharp>"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   227
  "{x}\<sharp>" == "CONST upper_unit\<cdot>x"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   228
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   229
lemma upper_unit_Rep_compact_basis [simp]:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   230
  "{Rep_compact_basis a}\<sharp> = upper_principal (PDUnit a)"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   231
unfolding upper_unit_def
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   232
by (simp add: compact_basis.basis_fun_principal
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   233
    upper_principal_mono PDUnit_upper_mono)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   234
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   235
lemma upper_plus_principal [simp]:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   236
  "upper_principal t +\<sharp> upper_principal u = upper_principal (PDPlus t u)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   237
unfolding upper_plus_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   238
by (simp add: upper_pd.basis_fun_principal
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   239
    upper_pd.basis_fun_mono PDPlus_upper_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   240
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   241
lemma approx_upper_unit [simp]:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   242
  "approx n\<cdot>{x}\<sharp> = {approx n\<cdot>x}\<sharp>"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   243
apply (induct x rule: compact_basis_induct, simp)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   244
apply (simp add: approx_Rep_compact_basis)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   245
done
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   246
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   247
lemma approx_upper_plus [simp]:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   248
  "approx n\<cdot>(xs +\<sharp> ys) = (approx n\<cdot>xs) +\<sharp> (approx n\<cdot>ys)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   249
by (induct xs ys rule: upper_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   250
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   251
lemma upper_plus_assoc: "(xs +\<sharp> ys) +\<sharp> zs = xs +\<sharp> (ys +\<sharp> zs)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   252
apply (induct xs ys arbitrary: zs rule: upper_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   253
apply (rule_tac xs=zs in upper_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   254
apply (simp add: PDPlus_assoc)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   255
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   256
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   257
lemma upper_plus_commute: "xs +\<sharp> ys = ys +\<sharp> xs"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   258
apply (induct xs ys rule: upper_principal_induct2, simp, simp)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   259
apply (simp add: PDPlus_commute)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   260
done
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   261
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   262
lemma upper_plus_absorb: "xs +\<sharp> xs = xs"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   263
apply (induct xs rule: upper_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   264
apply (simp add: PDPlus_absorb)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   265
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   266
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   267
interpretation aci_upper_plus: ab_semigroup_idem_mult ["op +\<sharp>"]
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   268
  by unfold_locales
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   269
    (rule upper_plus_assoc upper_plus_commute upper_plus_absorb)+
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   270
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   271
lemma upper_plus_left_commute: "xs +\<sharp> (ys +\<sharp> zs) = ys +\<sharp> (xs +\<sharp> zs)"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   272
by (rule aci_upper_plus.mult_left_commute)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   273
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   274
lemma upper_plus_left_absorb: "xs +\<sharp> (xs +\<sharp> ys) = xs +\<sharp> ys"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   275
by (rule aci_upper_plus.mult_left_idem)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   276
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   277
lemmas upper_plus_aci = aci_upper_plus.mult_ac_idem
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   278
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   279
lemma upper_plus_less1: "xs +\<sharp> ys \<sqsubseteq> xs"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   280
apply (induct xs ys rule: upper_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   281
apply (simp add: PDPlus_upper_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   282
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   283
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   284
lemma upper_plus_less2: "xs +\<sharp> ys \<sqsubseteq> ys"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   285
by (subst upper_plus_commute, rule upper_plus_less1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   286
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   287
lemma upper_plus_greatest: "\<lbrakk>xs \<sqsubseteq> ys; xs \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs \<sqsubseteq> ys +\<sharp> zs"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   288
apply (subst upper_plus_absorb [of xs, symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   289
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   290
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   291
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   292
lemma upper_less_plus_iff:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   293
  "xs \<sqsubseteq> ys +\<sharp> zs \<longleftrightarrow> xs \<sqsubseteq> ys \<and> xs \<sqsubseteq> zs"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   294
apply safe
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   295
apply (erule trans_less [OF _ upper_plus_less1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   296
apply (erule trans_less [OF _ upper_plus_less2])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   297
apply (erule (1) upper_plus_greatest)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   298
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   299
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   300
lemma upper_plus_less_unit_iff:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   301
  "xs +\<sharp> ys \<sqsubseteq> {z}\<sharp> \<longleftrightarrow> xs \<sqsubseteq> {z}\<sharp> \<or> ys \<sqsubseteq> {z}\<sharp>"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   302
 apply (rule iffI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   303
  apply (subgoal_tac
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   304
    "adm (\<lambda>f. f\<cdot>xs \<sqsubseteq> f\<cdot>{z}\<sharp> \<or> f\<cdot>ys \<sqsubseteq> f\<cdot>{z}\<sharp>)")
25925
3dc4acca4388 change lemma admD to rule_format
huffman
parents: 25904
diff changeset
   305
   apply (drule admD, rule chain_approx)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   306
    apply (drule_tac f="approx i" in monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   307
    apply (cut_tac xs="approx i\<cdot>xs" in compact_imp_upper_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   308
    apply (cut_tac xs="approx i\<cdot>ys" in compact_imp_upper_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   309
    apply (cut_tac x="approx i\<cdot>z" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   310
    apply (clarify, simp add: upper_le_PDPlus_PDUnit_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   311
   apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   312
  apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   313
 apply (erule disjE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   314
  apply (erule trans_less [OF upper_plus_less1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   315
 apply (erule trans_less [OF upper_plus_less2])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   316
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   317
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   318
lemma upper_unit_less_iff [simp]: "{x}\<sharp> \<sqsubseteq> {y}\<sharp> \<longleftrightarrow> x \<sqsubseteq> y"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   319
 apply (rule iffI)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   320
  apply (rule bifinite_less_ext)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   321
  apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   322
  apply (cut_tac x="approx i\<cdot>x" in compact_imp_Rep_compact_basis, simp)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   323
  apply (cut_tac x="approx i\<cdot>y" in compact_imp_Rep_compact_basis, simp)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   324
  apply (clarify, simp add: compact_le_def)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   325
 apply (erule monofun_cfun_arg)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   326
done
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   327
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   328
lemmas upper_pd_less_simps =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   329
  upper_unit_less_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   330
  upper_less_plus_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   331
  upper_plus_less_unit_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   332
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   333
lemma upper_unit_eq_iff [simp]: "{x}\<sharp> = {y}\<sharp> \<longleftrightarrow> x = y"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   334
unfolding po_eq_conv by simp
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   335
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   336
lemma upper_unit_strict [simp]: "{\<bottom>}\<sharp> = \<bottom>"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   337
unfolding inst_upper_pd_pcpo Rep_compact_bot [symmetric] by simp
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   338
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   339
lemma upper_plus_strict1 [simp]: "\<bottom> +\<sharp> ys = \<bottom>"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   340
by (rule UU_I, rule upper_plus_less1)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   341
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   342
lemma upper_plus_strict2 [simp]: "xs +\<sharp> \<bottom> = \<bottom>"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   343
by (rule UU_I, rule upper_plus_less2)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   344
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   345
lemma upper_unit_strict_iff [simp]: "{x}\<sharp> = \<bottom> \<longleftrightarrow> x = \<bottom>"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   346
unfolding upper_unit_strict [symmetric] by (rule upper_unit_eq_iff)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   347
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   348
lemma upper_plus_strict_iff [simp]:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   349
  "xs +\<sharp> ys = \<bottom> \<longleftrightarrow> xs = \<bottom> \<or> ys = \<bottom>"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   350
apply (rule iffI)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   351
apply (erule rev_mp)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   352
apply (rule upper_principal_induct2 [where xs=xs and ys=ys], simp, simp)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   353
apply (simp add: inst_upper_pd_pcpo upper_principal_eq_iff
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   354
                 upper_le_PDPlus_PDUnit_iff)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   355
apply auto
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   356
done
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   357
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   358
lemma compact_upper_unit_iff [simp]: "compact {x}\<sharp> \<longleftrightarrow> compact x"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   359
unfolding bifinite_compact_iff by simp
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   360
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   361
lemma compact_upper_plus [simp]:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   362
  "\<lbrakk>compact xs; compact ys\<rbrakk> \<Longrightarrow> compact (xs +\<sharp> ys)"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   363
apply (drule compact_imp_upper_principal)+
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   364
apply (auto simp add: compact_upper_principal)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   365
done
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   366
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   367
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   368
subsection {* Induction rules *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   369
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   370
lemma upper_pd_induct1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   371
  assumes P: "adm P"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   372
  assumes unit: "\<And>x. P {x}\<sharp>"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   373
  assumes insert: "\<And>x ys. \<lbrakk>P {x}\<sharp>; P ys\<rbrakk> \<Longrightarrow> P ({x}\<sharp> +\<sharp> ys)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   374
  shows "P (xs::'a upper_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   375
apply (induct xs rule: upper_principal_induct, rule P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   376
apply (induct_tac t rule: pd_basis_induct1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   377
apply (simp only: upper_unit_Rep_compact_basis [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   378
apply (rule unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   379
apply (simp only: upper_unit_Rep_compact_basis [symmetric]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   380
                  upper_plus_principal [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   381
apply (erule insert [OF unit])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   382
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   383
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   384
lemma upper_pd_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   385
  assumes P: "adm P"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   386
  assumes unit: "\<And>x. P {x}\<sharp>"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   387
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (xs +\<sharp> ys)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   388
  shows "P (xs::'a upper_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   389
apply (induct xs rule: upper_principal_induct, rule P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   390
apply (induct_tac t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   391
apply (simp only: upper_unit_Rep_compact_basis [symmetric] unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   392
apply (simp only: upper_plus_principal [symmetric] plus)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   393
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   394
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   395
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   396
subsection {* Monadic bind *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   397
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   398
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   399
  upper_bind_basis ::
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   400
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   401
  "upper_bind_basis = fold_pd
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   402
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   403
    (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<sharp> y\<cdot>f)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   404
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   405
lemma ACI_upper_bind:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   406
  "ab_semigroup_idem_mult (\<lambda>x y. \<Lambda> f. x\<cdot>f +\<sharp> y\<cdot>f)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   407
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
   408
apply (simp add: upper_plus_assoc)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   409
apply (simp add: upper_plus_commute)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   410
apply (simp add: upper_plus_absorb eta_cfun)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   411
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   412
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   413
lemma upper_bind_basis_simps [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   414
  "upper_bind_basis (PDUnit a) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   415
    (\<Lambda> f. f\<cdot>(Rep_compact_basis a))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   416
  "upper_bind_basis (PDPlus t u) =
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   417
    (\<Lambda> f. upper_bind_basis t\<cdot>f +\<sharp> upper_bind_basis u\<cdot>f)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   418
unfolding upper_bind_basis_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   419
apply -
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   420
apply (rule fold_pd_PDUnit [OF ACI_upper_bind])
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   421
apply (rule fold_pd_PDPlus [OF ACI_upper_bind])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   422
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   423
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   424
lemma upper_bind_basis_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   425
  "t \<le>\<sharp> u \<Longrightarrow> upper_bind_basis t \<sqsubseteq> upper_bind_basis u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   426
unfolding expand_cfun_less
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   427
apply (erule upper_le_induct, safe)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   428
apply (simp add: compact_le_def monofun_cfun)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   429
apply (simp add: trans_less [OF upper_plus_less1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   430
apply (simp add: upper_less_plus_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   431
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   432
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   433
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   434
  upper_bind :: "'a upper_pd \<rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   435
  "upper_bind = upper_pd.basis_fun upper_bind_basis"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   436
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   437
lemma upper_bind_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   438
  "upper_bind\<cdot>(upper_principal t) = upper_bind_basis t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   439
unfolding upper_bind_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   440
apply (rule upper_pd.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   441
apply (erule upper_bind_basis_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   442
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   443
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   444
lemma upper_bind_unit [simp]:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   445
  "upper_bind\<cdot>{x}\<sharp>\<cdot>f = f\<cdot>x"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   446
by (induct x rule: compact_basis_induct, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   447
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   448
lemma upper_bind_plus [simp]:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   449
  "upper_bind\<cdot>(xs +\<sharp> ys)\<cdot>f = upper_bind\<cdot>xs\<cdot>f +\<sharp> upper_bind\<cdot>ys\<cdot>f"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   450
by (induct xs ys rule: upper_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   451
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   452
lemma upper_bind_strict [simp]: "upper_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   453
unfolding upper_unit_strict [symmetric] by (rule upper_bind_unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   454
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   455
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   456
subsection {* Map and join *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   457
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   458
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   459
  upper_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a upper_pd \<rightarrow> 'b upper_pd" where
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   460
  "upper_map = (\<Lambda> f xs. upper_bind\<cdot>xs\<cdot>(\<Lambda> x. {f\<cdot>x}\<sharp>))"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   461
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   462
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   463
  upper_join :: "'a upper_pd upper_pd \<rightarrow> 'a upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   464
  "upper_join = (\<Lambda> xss. upper_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   465
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   466
lemma upper_map_unit [simp]:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   467
  "upper_map\<cdot>f\<cdot>{x}\<sharp> = {f\<cdot>x}\<sharp>"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   468
unfolding upper_map_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   469
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   470
lemma upper_map_plus [simp]:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   471
  "upper_map\<cdot>f\<cdot>(xs +\<sharp> ys) = upper_map\<cdot>f\<cdot>xs +\<sharp> upper_map\<cdot>f\<cdot>ys"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   472
unfolding upper_map_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   473
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   474
lemma upper_join_unit [simp]:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   475
  "upper_join\<cdot>{xs}\<sharp> = xs"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   476
unfolding upper_join_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   477
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   478
lemma upper_join_plus [simp]:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   479
  "upper_join\<cdot>(xss +\<sharp> yss) = upper_join\<cdot>xss +\<sharp> upper_join\<cdot>yss"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   480
unfolding upper_join_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   481
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   482
lemma upper_map_ident: "upper_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   483
by (induct xs rule: upper_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   484
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   485
lemma upper_map_map:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   486
  "upper_map\<cdot>f\<cdot>(upper_map\<cdot>g\<cdot>xs) = upper_map\<cdot>(\<Lambda> x. f\<cdot>(g\<cdot>x))\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   487
by (induct xs rule: upper_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   488
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   489
lemma upper_join_map_unit:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   490
  "upper_join\<cdot>(upper_map\<cdot>upper_unit\<cdot>xs) = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   491
by (induct xs rule: upper_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   492
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   493
lemma upper_join_map_join:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   494
  "upper_join\<cdot>(upper_map\<cdot>upper_join\<cdot>xsss) = upper_join\<cdot>(upper_join\<cdot>xsss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   495
by (induct xsss rule: upper_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   496
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   497
lemma upper_join_map_map:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   498
  "upper_join\<cdot>(upper_map\<cdot>(upper_map\<cdot>f)\<cdot>xss) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   499
   upper_map\<cdot>f\<cdot>(upper_join\<cdot>xss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   500
by (induct xss rule: upper_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   501
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   502
lemma upper_map_approx: "upper_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   503
by (induct xs rule: upper_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   504
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   505
end