src/HOLCF/UpperPD.thy
author huffman
Mon, 14 Jan 2008 19:26:41 +0100
changeset 25904 8161f137b0e9
child 25925 3dc4acca4388
permissions -rw-r--r--
new theory of powerdomains
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     1
(*  Title:      HOLCF/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
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    16
  "upper_le = (\<lambda>u v. \<forall>y\<in>Rep_pd_basis v. \<exists>x\<in>Rep_pd_basis u. compact_le x y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    17
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    18
lemma upper_le_refl [simp]: "t \<le>\<sharp> t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    19
unfolding upper_le_def by (fast intro: compact_le_refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    20
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    21
lemma 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)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    27
apply (erule (1) compact_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    28
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    29
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    30
interpretation 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
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    36
lemma PDUnit_upper_mono: "compact_le x y \<Longrightarrow> PDUnit x \<le>\<sharp> PDUnit y"
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"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    43
unfolding upper_le_def Rep_PDPlus by (fast intro: compact_le_refl)
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]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    46
  "(PDUnit a \<le>\<sharp> PDUnit b) = compact_le a b"
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"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    58
  assumes 1: "\<And>a b. compact_le a b \<Longrightarrow> P (PDUnit a) (PDUnit b)"
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 =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    98
  "{S::'a::bifinite pd_basis set. upper_le.ideal S}"
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)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   104
by (rule Rep_upper_pd [simplified])
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
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   113
apply (rule Abs_upper_pd_inverse [simplified])
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:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   118
  bifinite_basis [upper_le upper_principal Rep_upper_pd approx_pd]
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 ideal_Rep_upper_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   121
apply (rule cont_Rep_upper_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   122
apply (rule Rep_upper_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   123
apply (simp only: less_upper_pd_def less_set_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   124
apply (rule approx_pd_upper_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   125
apply (rule approx_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   126
apply (erule approx_pd_upper_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   127
apply (rule approx_pd_upper_mono1, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   128
apply (rule finite_range_approx_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   129
apply (rule ex_approx_pd_eq)
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]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   133
  "(upper_principal t \<sqsubseteq> upper_principal u) = (t \<le>\<sharp> u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   134
unfolding less_upper_pd_def Rep_upper_principal less_set_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   135
by (fast intro: upper_le_refl elim: upper_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   136
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   137
lemma upper_principal_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   138
  "t \<le>\<sharp> u \<Longrightarrow> upper_principal t \<sqsubseteq> upper_principal u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   139
by (rule upper_pd.principal_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   140
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   141
lemma compact_upper_principal: "compact (upper_principal t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   142
by (rule upper_pd.compact_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   143
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   144
lemma upper_pd_minimal: "upper_principal (PDUnit compact_bot) \<sqsubseteq> ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   145
by (induct ys rule: upper_pd.principal_induct, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   146
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   147
instance upper_pd :: (bifinite) pcpo
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   148
by (intro_classes, fast intro: upper_pd_minimal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   149
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   150
lemma inst_upper_pd_pcpo: "\<bottom> = upper_principal (PDUnit compact_bot)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   151
by (rule upper_pd_minimal [THEN UU_I, symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   152
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   153
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   154
subsection {* Approximation *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   155
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   156
instance upper_pd :: (bifinite) approx ..
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   157
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   158
defs (overloaded)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   159
  approx_upper_pd_def:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   160
    "approx \<equiv> (\<lambda>n. upper_pd.basis_fun (\<lambda>t. upper_principal (approx_pd n t)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   161
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   162
lemma approx_upper_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   163
  "approx n\<cdot>(upper_principal t) = upper_principal (approx_pd n t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   164
unfolding approx_upper_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   165
apply (rule upper_pd.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   166
apply (erule upper_principal_mono [OF approx_pd_upper_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   167
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   168
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   169
lemma chain_approx_upper_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   170
  "chain (approx :: nat \<Rightarrow> 'a upper_pd \<rightarrow> 'a upper_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   171
unfolding approx_upper_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   172
by (rule upper_pd.chain_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   173
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   174
lemma lub_approx_upper_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   175
  "(\<Squnion>i. approx i\<cdot>xs) = (xs::'a upper_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   176
unfolding approx_upper_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   177
by (rule upper_pd.lub_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   178
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   179
lemma approx_upper_pd_idem:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   180
  "approx n\<cdot>(approx n\<cdot>xs) = approx n\<cdot>(xs::'a upper_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   181
apply (induct xs rule: upper_pd.principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   182
apply (simp add: approx_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   183
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   184
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   185
lemma approx_eq_upper_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   186
  "\<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
   187
unfolding approx_upper_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   188
by (rule upper_pd.basis_fun_take_eq_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   189
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   190
lemma finite_fixes_approx_upper_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   191
  "finite {xs::'a upper_pd. approx n\<cdot>xs = xs}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   192
unfolding approx_upper_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   193
by (rule upper_pd.finite_fixes_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   194
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   195
instance upper_pd :: (bifinite) bifinite
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   196
apply intro_classes
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   197
apply (simp add: chain_approx_upper_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   198
apply (rule lub_approx_upper_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   199
apply (rule approx_upper_pd_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   200
apply (rule finite_fixes_approx_upper_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   201
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   202
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   203
lemma compact_imp_upper_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   204
  "compact xs \<Longrightarrow> \<exists>t. xs = upper_principal t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   205
apply (drule bifinite_compact_eq_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   206
apply (erule exE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   207
apply (erule subst)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   208
apply (cut_tac n=i and xs=xs in approx_eq_upper_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   209
apply fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   210
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   211
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   212
lemma upper_principal_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   213
  "\<lbrakk>adm P; \<And>t. P (upper_principal t)\<rbrakk> \<Longrightarrow> P xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   214
apply (erule approx_induct, rename_tac xs)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   215
apply (cut_tac n=n and xs=xs in approx_eq_upper_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   216
apply (clarify, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   217
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   218
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   219
lemma upper_principal_induct2:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   220
  "\<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
   221
    \<And>t u. P (upper_principal t) (upper_principal u)\<rbrakk> \<Longrightarrow> P xs ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   222
apply (rule_tac x=ys in spec)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   223
apply (rule_tac xs=xs in upper_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   224
apply (rule allI, rename_tac ys)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   225
apply (rule_tac xs=ys in upper_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   226
apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   227
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   228
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   229
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   230
subsection {* Monadic unit *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   231
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   232
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   233
  upper_unit :: "'a \<rightarrow> 'a upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   234
  "upper_unit = compact_basis.basis_fun (\<lambda>a. upper_principal (PDUnit a))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   235
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   236
lemma upper_unit_Rep_compact_basis [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   237
  "upper_unit\<cdot>(Rep_compact_basis a) = upper_principal (PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   238
unfolding upper_unit_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   239
apply (rule compact_basis.basis_fun_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   240
apply (rule upper_principal_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   241
apply (erule PDUnit_upper_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   242
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   243
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   244
lemma upper_unit_strict [simp]: "upper_unit\<cdot>\<bottom> = \<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   245
unfolding inst_upper_pd_pcpo Rep_compact_bot [symmetric] by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   246
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   247
lemma approx_upper_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   248
  "approx n\<cdot>(upper_unit\<cdot>x) = upper_unit\<cdot>(approx n\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   249
apply (induct x rule: compact_basis_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   250
apply (simp add: approx_Rep_compact_basis)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   251
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   252
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   253
lemma upper_unit_less_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   254
  "(upper_unit\<cdot>x \<sqsubseteq> upper_unit\<cdot>y) = (x \<sqsubseteq> y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   255
 apply (rule iffI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   256
  apply (rule bifinite_less_ext)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   257
  apply (drule_tac f="approx i" in monofun_cfun_arg, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   258
  apply (cut_tac x="approx i\<cdot>x" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   259
  apply (cut_tac x="approx i\<cdot>y" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   260
  apply (clarify, simp add: compact_le_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   261
 apply (erule monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   262
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   263
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   264
lemma upper_unit_eq_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   265
  "(upper_unit\<cdot>x = upper_unit\<cdot>y) = (x = y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   266
unfolding po_eq_conv by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   267
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   268
lemma upper_unit_strict_iff [simp]: "(upper_unit\<cdot>x = \<bottom>) = (x = \<bottom>)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   269
unfolding upper_unit_strict [symmetric] by (rule upper_unit_eq_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   270
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   271
lemma compact_upper_unit_iff [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   272
  "compact (upper_unit\<cdot>x) = compact x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   273
unfolding bifinite_compact_iff by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   274
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   275
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   276
subsection {* Monadic plus *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   277
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   278
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   279
  upper_plus :: "'a upper_pd \<rightarrow> 'a upper_pd \<rightarrow> 'a upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   280
  "upper_plus = upper_pd.basis_fun (\<lambda>t. upper_pd.basis_fun (\<lambda>u.
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   281
      upper_principal (PDPlus t u)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   282
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   283
abbreviation
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   284
  upper_add :: "'a upper_pd \<Rightarrow> 'a upper_pd \<Rightarrow> 'a upper_pd"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   285
    (infixl "+\<sharp>" 65) where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   286
  "xs +\<sharp> ys == upper_plus\<cdot>xs\<cdot>ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   287
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   288
lemma upper_plus_principal [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   289
  "upper_plus\<cdot>(upper_principal t)\<cdot>(upper_principal u) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   290
   upper_principal (PDPlus t u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   291
unfolding upper_plus_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   292
by (simp add: upper_pd.basis_fun_principal
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   293
    upper_pd.basis_fun_mono PDPlus_upper_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   294
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   295
lemma approx_upper_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   296
  "approx n\<cdot>(upper_plus\<cdot>xs\<cdot>ys) = upper_plus\<cdot>(approx n\<cdot>xs)\<cdot>(approx n\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   297
by (induct xs ys rule: upper_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   298
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   299
lemma upper_plus_commute: "upper_plus\<cdot>xs\<cdot>ys = upper_plus\<cdot>ys\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   300
apply (induct xs ys rule: upper_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   301
apply (simp add: PDPlus_commute)
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 upper_plus_assoc:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   305
  "upper_plus\<cdot>(upper_plus\<cdot>xs\<cdot>ys)\<cdot>zs = upper_plus\<cdot>xs\<cdot>(upper_plus\<cdot>ys\<cdot>zs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   306
apply (induct xs ys arbitrary: zs rule: upper_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   307
apply (rule_tac xs=zs in upper_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   308
apply (simp add: PDPlus_assoc)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   309
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   310
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   311
lemma upper_plus_absorb: "upper_plus\<cdot>xs\<cdot>xs = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   312
apply (induct xs rule: upper_principal_induct, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   313
apply (simp add: PDPlus_absorb)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   314
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   315
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   316
lemma upper_plus_less1: "upper_plus\<cdot>xs\<cdot>ys \<sqsubseteq> xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   317
apply (induct xs ys rule: upper_principal_induct2, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   318
apply (simp add: PDPlus_upper_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   319
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   320
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   321
lemma upper_plus_less2: "upper_plus\<cdot>xs\<cdot>ys \<sqsubseteq> ys"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   322
by (subst upper_plus_commute, rule upper_plus_less1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   323
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   324
lemma upper_plus_greatest: "\<lbrakk>xs \<sqsubseteq> ys; xs \<sqsubseteq> zs\<rbrakk> \<Longrightarrow> xs \<sqsubseteq> upper_plus\<cdot>ys\<cdot>zs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   325
apply (subst upper_plus_absorb [of xs, symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   326
apply (erule (1) monofun_cfun [OF monofun_cfun_arg])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   327
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   328
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   329
lemma upper_less_plus_iff:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   330
  "(xs \<sqsubseteq> upper_plus\<cdot>ys\<cdot>zs) = (xs \<sqsubseteq> ys \<and> xs \<sqsubseteq> zs)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   331
apply safe
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   332
apply (erule trans_less [OF _ upper_plus_less1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   333
apply (erule trans_less [OF _ upper_plus_less2])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   334
apply (erule (1) upper_plus_greatest)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   335
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   336
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   337
lemma upper_plus_strict1 [simp]: "upper_plus\<cdot>\<bottom>\<cdot>ys = \<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   338
by (rule UU_I, rule upper_plus_less1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   339
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   340
lemma upper_plus_strict2 [simp]: "upper_plus\<cdot>xs\<cdot>\<bottom> = \<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   341
by (rule UU_I, rule upper_plus_less2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   342
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   343
lemma upper_plus_less_unit_iff:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   344
  "(upper_plus\<cdot>xs\<cdot>ys \<sqsubseteq> upper_unit\<cdot>z) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   345
    (xs \<sqsubseteq> upper_unit\<cdot>z \<or> ys \<sqsubseteq> upper_unit\<cdot>z)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   346
 apply (rule iffI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   347
  apply (subgoal_tac
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   348
    "adm (\<lambda>f. f\<cdot>xs \<sqsubseteq> f\<cdot>(upper_unit\<cdot>z) \<or> f\<cdot>ys \<sqsubseteq> f\<cdot>(upper_unit\<cdot>z))")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   349
   apply (drule admD [rule_format], rule chain_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   350
    apply (drule_tac f="approx i" in monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   351
    apply (cut_tac xs="approx i\<cdot>xs" in compact_imp_upper_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   352
    apply (cut_tac xs="approx i\<cdot>ys" in compact_imp_upper_principal, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   353
    apply (cut_tac x="approx i\<cdot>z" in compact_imp_Rep_compact_basis, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   354
    apply (clarify, simp add: upper_le_PDPlus_PDUnit_iff)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   355
   apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   356
  apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   357
 apply (erule disjE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   358
  apply (erule trans_less [OF upper_plus_less1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   359
 apply (erule trans_less [OF upper_plus_less2])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   360
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   361
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   362
lemmas upper_pd_less_simps =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   363
  upper_unit_less_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   364
  upper_less_plus_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   365
  upper_plus_less_unit_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   366
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"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   372
  assumes unit: "\<And>x. P (upper_unit\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   373
  assumes insert:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   374
    "\<And>x ys. \<lbrakk>P (upper_unit\<cdot>x); P ys\<rbrakk> \<Longrightarrow> P (upper_plus\<cdot>(upper_unit\<cdot>x)\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   375
  shows "P (xs::'a upper_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   376
apply (induct xs rule: upper_principal_induct, rule P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   377
apply (induct_tac t rule: pd_basis_induct1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   378
apply (simp only: upper_unit_Rep_compact_basis [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   379
apply (rule unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   380
apply (simp only: upper_unit_Rep_compact_basis [symmetric]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   381
                  upper_plus_principal [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   382
apply (erule insert [OF unit])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   383
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   384
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   385
lemma upper_pd_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   386
  assumes P: "adm P"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   387
  assumes unit: "\<And>x. P (upper_unit\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   388
  assumes plus: "\<And>xs ys. \<lbrakk>P xs; P ys\<rbrakk> \<Longrightarrow> P (upper_plus\<cdot>xs\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   389
  shows "P (xs::'a upper_pd)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   390
apply (induct xs rule: upper_principal_induct, rule P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   391
apply (induct_tac t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   392
apply (simp only: upper_unit_Rep_compact_basis [symmetric] unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   393
apply (simp only: upper_plus_principal [symmetric] plus)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   394
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   395
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   396
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   397
subsection {* Monadic bind *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   398
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   399
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   400
  upper_bind_basis ::
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   401
  "'a pd_basis \<Rightarrow> ('a \<rightarrow> 'b upper_pd) \<rightarrow> 'b upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   402
  "upper_bind_basis = fold_pd
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   403
    (\<lambda>a. \<Lambda> f. f\<cdot>(Rep_compact_basis a))
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   404
    (\<lambda>x y. \<Lambda> f. upper_plus\<cdot>(x\<cdot>f)\<cdot>(y\<cdot>f))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   405
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   406
lemma ACI_upper_bind: "ACIf (\<lambda>x y. \<Lambda> f. upper_plus\<cdot>(x\<cdot>f)\<cdot>(y\<cdot>f))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   407
apply unfold_locales
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   408
apply (simp add: upper_plus_commute)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   409
apply (simp add: upper_plus_assoc)
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) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   417
    (\<Lambda> f. upper_plus\<cdot>(upper_bind_basis t\<cdot>f)\<cdot>(upper_bind_basis u\<cdot>f))"
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 -
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   420
apply (rule ACIf.fold_pd_PDUnit [OF ACI_upper_bind])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   421
apply (rule ACIf.fold_pd_PDPlus [OF ACI_upper_bind])
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]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   445
  "upper_bind\<cdot>(upper_unit\<cdot>x)\<cdot>f = f\<cdot>x"
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]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   449
  "upper_bind\<cdot>(upper_plus\<cdot>xs\<cdot>ys)\<cdot>f =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   450
   upper_plus\<cdot>(upper_bind\<cdot>xs\<cdot>f)\<cdot>(upper_bind\<cdot>ys\<cdot>f)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   451
by (induct xs ys rule: upper_principal_induct2, simp, simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   452
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   453
lemma upper_bind_strict [simp]: "upper_bind\<cdot>\<bottom>\<cdot>f = f\<cdot>\<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   454
unfolding upper_unit_strict [symmetric] by (rule upper_bind_unit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   455
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   456
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   457
subsection {* Map and join *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   458
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   459
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   460
  upper_map :: "('a \<rightarrow> 'b) \<rightarrow> 'a upper_pd \<rightarrow> 'b upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   461
  "upper_map = (\<Lambda> f xs. upper_bind\<cdot>xs\<cdot>(\<Lambda> x. upper_unit\<cdot>(f\<cdot>x)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   462
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   463
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   464
  upper_join :: "'a upper_pd upper_pd \<rightarrow> 'a upper_pd" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   465
  "upper_join = (\<Lambda> xss. upper_bind\<cdot>xss\<cdot>(\<Lambda> xs. xs))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   466
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   467
lemma upper_map_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   468
  "upper_map\<cdot>f\<cdot>(upper_unit\<cdot>x) = upper_unit\<cdot>(f\<cdot>x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   469
unfolding upper_map_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   470
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   471
lemma upper_map_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   472
  "upper_map\<cdot>f\<cdot>(upper_plus\<cdot>xs\<cdot>ys) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   473
   upper_plus\<cdot>(upper_map\<cdot>f\<cdot>xs)\<cdot>(upper_map\<cdot>f\<cdot>ys)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   474
unfolding upper_map_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   475
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   476
lemma upper_join_unit [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   477
  "upper_join\<cdot>(upper_unit\<cdot>xs) = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   478
unfolding upper_join_def by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   479
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   480
lemma upper_join_plus [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   481
  "upper_join\<cdot>(upper_plus\<cdot>xss\<cdot>yss) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   482
   upper_plus\<cdot>(upper_join\<cdot>xss)\<cdot>(upper_join\<cdot>yss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   483
unfolding upper_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 upper_map_ident: "upper_map\<cdot>(\<Lambda> x. x)\<cdot>xs = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   486
by (induct xs rule: upper_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   487
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   488
lemma upper_map_map:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   489
  "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
   490
by (induct xs rule: upper_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 upper_join_map_unit:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   493
  "upper_join\<cdot>(upper_map\<cdot>upper_unit\<cdot>xs) = xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   494
by (induct xs rule: upper_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 upper_join_map_join:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   497
  "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
   498
by (induct xsss rule: upper_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 upper_join_map_map:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   501
  "upper_join\<cdot>(upper_map\<cdot>(upper_map\<cdot>f)\<cdot>xss) =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   502
   upper_map\<cdot>f\<cdot>(upper_join\<cdot>xss)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   503
by (induct xss 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
lemma upper_map_approx: "upper_map\<cdot>(approx n)\<cdot>xs = approx n\<cdot>xs"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   506
by (induct xs rule: upper_pd_induct, simp_all)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   507
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   508
end