src/HOLCF/CompactBasis.thy
author huffman
Mon, 14 Jan 2008 19:26:41 +0100
changeset 25904 8161f137b0e9
child 25922 cb04d05e95fb
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/CompactBasis.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 {* Compact bases of domains *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     7
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     8
theory CompactBasis
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
     9
imports Bifinite SetPcpo
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 {* Ideals over a preorder *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    13
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    14
locale preorder =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    15
  fixes r :: "'a::type \<Rightarrow> 'a \<Rightarrow> bool"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    16
  assumes refl: "r x x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    17
  assumes trans: "\<lbrakk>r x y; r y z\<rbrakk> \<Longrightarrow> r x z"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    18
begin
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    19
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    20
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    21
  ideal :: "'a set \<Rightarrow> bool" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    22
  "ideal A = ((\<exists>x. x \<in> A) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. \<exists>z\<in>A. r x z \<and> r y z) \<and>
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    23
    (\<forall>x y. r x y \<longrightarrow> y \<in> A \<longrightarrow> x \<in> A))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    24
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    25
lemma idealI:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    26
  assumes "\<exists>x. x \<in> A"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    27
  assumes "\<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. r x z \<and> r y z"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    28
  assumes "\<And>x y. \<lbrakk>r x y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    29
  shows "ideal A"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    30
unfolding ideal_def using prems by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    31
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    32
lemma idealD1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    33
  "ideal A \<Longrightarrow> \<exists>x. x \<in> A"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    34
unfolding ideal_def by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    35
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    36
lemma idealD2:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    37
  "\<lbrakk>ideal A; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. r x z \<and> r y z"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    38
unfolding ideal_def by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    39
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    40
lemma idealD3:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    41
  "\<lbrakk>ideal A; r x y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    42
unfolding ideal_def by fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    43
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    44
lemma ideal_directed_finite:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    45
  assumes A: "ideal A"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    46
  shows "\<lbrakk>finite U; U \<subseteq> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. \<forall>x\<in>U. r x z"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    47
apply (induct U set: finite)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    48
apply (simp add: idealD1 [OF A])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    49
apply (simp, clarify, rename_tac y)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    50
apply (drule (1) idealD2 [OF A])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    51
apply (clarify, erule_tac x=z in rev_bexI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    52
apply (fast intro: trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    53
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    54
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    55
lemma ideal_principal: "ideal {x. r x z}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    56
apply (rule idealI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    57
apply (rule_tac x=z in exI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    58
apply (fast intro: refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    59
apply (rule_tac x=z in bexI, fast)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    60
apply (fast intro: refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    61
apply (fast intro: trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    62
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    63
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    64
lemma directed_image_ideal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    65
  assumes A: "ideal A"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    66
  assumes f: "\<And>x y. r x y \<Longrightarrow> f x \<sqsubseteq> f y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    67
  shows "directed (f ` A)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    68
apply (rule directedI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    69
apply (cut_tac idealD1 [OF A], fast)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    70
apply (clarify, rename_tac a b)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    71
apply (drule (1) idealD2 [OF A])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    72
apply (clarify, rename_tac c)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    73
apply (rule_tac x="f c" in rev_bexI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    74
apply (erule imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    75
apply (simp add: f)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    76
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    77
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    78
lemma adm_ideal: "adm (\<lambda>A. ideal A)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    79
unfolding ideal_def by (intro adm_lemmas adm_set_lemmas)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    80
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    81
end
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    82
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    83
subsection {* Defining functions in terms of basis elements *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    84
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    85
lemma (in preorder) lub_image_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    86
  assumes f: "\<And>x y. r x y \<Longrightarrow> f x \<sqsubseteq> f y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    87
  shows "(\<Squnion>x\<in>{x. r x y}. f x) = f y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    88
apply (rule thelubI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    89
apply (rule is_lub_maximal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    90
apply (rule ub_imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    91
apply (simp add: f)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    92
apply (rule imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    93
apply (simp add: refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    94
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    95
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    96
lemma finite_directed_has_lub: "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u. S <<| u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    97
apply (drule (1) directed_finiteD, rule subset_refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    98
apply (erule bexE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    99
apply (rule_tac x=z in exI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   100
apply (erule (1) is_lub_maximal)
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 is_ub_thelub0: "\<lbrakk>\<exists>u. S <<| u; x \<in> S\<rbrakk> \<Longrightarrow> x \<sqsubseteq> lub S"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   104
apply (erule exE, drule lubI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   105
apply (drule is_lubD1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   106
apply (erule (1) is_ubD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   107
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   108
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   109
lemma is_lub_thelub0: "\<lbrakk>\<exists>u. S <<| u; S <| x\<rbrakk> \<Longrightarrow> lub S \<sqsubseteq> x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   110
by (erule exE, drule lubI, erule is_lub_lub)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   111
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   112
locale bifinite_basis = preorder +
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   113
  fixes principal :: "'a::type \<Rightarrow> 'b::cpo"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   114
  fixes approxes :: "'b::cpo \<Rightarrow> 'a::type set"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   115
  assumes ideal_approxes: "\<And>x. preorder.ideal r (approxes x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   116
  assumes cont_approxes: "cont approxes"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   117
  assumes approxes_principal: "\<And>a. approxes (principal a) = {b. r b a}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   118
  assumes subset_approxesD: "\<And>x y. approxes x \<subseteq> approxes y \<Longrightarrow> x \<sqsubseteq> y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   119
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   120
  fixes take :: "nat \<Rightarrow> 'a::type \<Rightarrow> 'a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   121
  assumes take_less: "r (take n a) a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   122
  assumes take_take: "take n (take n a) = take n a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   123
  assumes take_mono: "r a b \<Longrightarrow> r (take n a) (take n b)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   124
  assumes take_chain: "r (take n a) (take (Suc n) a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   125
  assumes finite_range_take: "finite (range (take n))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   126
  assumes take_covers: "\<exists>n. take n a = a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   127
begin
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   128
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   129
lemma finite_take_approxes: "finite (take n ` approxes x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   130
by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range_take])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   131
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   132
lemma basis_fun_lemma0:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   133
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   134
  assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   135
  shows "\<exists>u. f ` take i ` approxes x <<| u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   136
apply (rule finite_directed_has_lub)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   137
apply (rule finite_imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   138
apply (rule finite_take_approxes)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   139
apply (subst image_image)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   140
apply (rule directed_image_ideal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   141
apply (rule ideal_approxes)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   142
apply (rule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   143
apply (erule take_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   144
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   145
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   146
lemma basis_fun_lemma1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   147
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   148
  assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   149
  shows "chain (\<lambda>i. lub (f ` take i ` approxes x))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   150
 apply (rule chainI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   151
 apply (rule is_lub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   152
  apply (rule basis_fun_lemma0, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   153
 apply (rule is_ubI, clarsimp, rename_tac a)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   154
 apply (rule trans_less [OF f_mono [OF take_chain]])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   155
 apply (rule is_ub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   156
  apply (rule basis_fun_lemma0, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   157
 apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   158
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   159
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   160
lemma basis_fun_lemma2:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   161
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   162
  assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   163
  shows "f ` approxes x <<| (\<Squnion>i. lub (f ` take i ` approxes x))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   164
 apply (rule is_lubI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   165
 apply (rule ub_imageI, rename_tac a)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   166
  apply (cut_tac a=a in take_covers, erule exE, rename_tac i)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   167
  apply (erule subst)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   168
  apply (rule rev_trans_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   169
   apply (rule_tac x=i in is_ub_thelub)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   170
   apply (rule basis_fun_lemma1, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   171
  apply (rule is_ub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   172
   apply (rule basis_fun_lemma0, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   173
  apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   174
 apply (rule is_lub_thelub [OF _ ub_rangeI])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   175
  apply (rule basis_fun_lemma1, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   176
 apply (rule is_lub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   177
  apply (rule basis_fun_lemma0, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   178
 apply (rule is_ubI, clarsimp, rename_tac a)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   179
 apply (rule trans_less [OF f_mono [OF take_less]])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   180
 apply (erule (1) ub_imageD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   181
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   182
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   183
lemma basis_fun_lemma:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   184
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   185
  assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   186
  shows "\<exists>u. f ` approxes x <<| u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   187
by (rule exI, rule basis_fun_lemma2, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   188
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   189
lemma approxes_mono: "x \<sqsubseteq> y \<Longrightarrow> approxes x \<subseteq> approxes y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   190
apply (drule cont_approxes [THEN cont2mono, THEN monofunE])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   191
apply (simp add: set_cpo_simps)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   192
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   193
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   194
lemma approxes_contlub:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   195
  "chain Y \<Longrightarrow> approxes (\<Squnion>i. Y i) = (\<Union>i. approxes (Y i))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   196
by (simp add: cont2contlubE [OF cont_approxes] set_cpo_simps)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   197
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   198
lemma less_def: "(x \<sqsubseteq> y) = (approxes x \<subseteq> approxes y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   199
by (rule iffI [OF approxes_mono subset_approxesD])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   200
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   201
lemma approxes_eq: "approxes x = {a. principal a \<sqsubseteq> x}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   202
unfolding less_def approxes_principal
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   203
apply safe
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   204
apply (erule (1) idealD3 [OF ideal_approxes])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   205
apply (erule subsetD, simp add: refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   206
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   207
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   208
lemma mem_approxes_iff: "(a \<in> approxes x) = (principal a \<sqsubseteq> x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   209
by (simp add: approxes_eq)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   210
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   211
lemma principal_less_iff: "(principal a \<sqsubseteq> x) = (a \<in> approxes x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   212
by (simp add: approxes_eq)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   213
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   214
lemma approxesD: "a \<in> approxes x \<Longrightarrow> principal a \<sqsubseteq> x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   215
by (simp add: approxes_eq)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   216
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   217
lemma principal_mono: "r a b \<Longrightarrow> principal a \<sqsubseteq> principal b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   218
by (rule approxesD, simp add: approxes_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   219
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   220
lemma lessI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   221
unfolding principal_less_iff
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   222
by (simp add: less_def subset_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   223
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   224
lemma lub_principal_approxes: "principal ` approxes x <<| x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   225
apply (rule is_lubI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   226
apply (rule ub_imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   227
apply (erule approxesD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   228
apply (subst less_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   229
apply (rule subsetI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   230
apply (drule (1) ub_imageD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   231
apply (simp add: approxes_eq)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   232
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   233
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   234
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   235
  basis_fun :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   236
  "basis_fun = (\<lambda>f. (\<Lambda> x. lub (f ` approxes x)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   237
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   238
lemma basis_fun_beta:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   239
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   240
  assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   241
  shows "basis_fun f\<cdot>x = lub (f ` approxes x)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   242
unfolding basis_fun_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   243
proof (rule beta_cfun)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   244
  have lub: "\<And>x. \<exists>u. f ` approxes x <<| u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   245
    using f_mono by (rule basis_fun_lemma)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   246
  show cont: "cont (\<lambda>x. lub (f ` approxes x))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   247
    apply (rule contI2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   248
     apply (rule monofunI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   249
     apply (rule is_lub_thelub0 [OF lub ub_imageI])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   250
     apply (rule is_ub_thelub0 [OF lub imageI])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   251
     apply (erule (1) subsetD [OF approxes_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   252
    apply (rule is_lub_thelub0 [OF lub ub_imageI])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   253
    apply (simp add: approxes_contlub, clarify)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   254
    apply (erule rev_trans_less [OF is_ub_thelub])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   255
    apply (erule is_ub_thelub0 [OF lub imageI])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   256
    done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   257
qed
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   258
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   259
lemma basis_fun_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   260
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   261
  assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   262
  shows "basis_fun f\<cdot>(principal a) = f a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   263
apply (subst basis_fun_beta, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   264
apply (subst approxes_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   265
apply (rule lub_image_principal, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   266
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   267
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   268
lemma basis_fun_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   269
  assumes f_mono: "\<And>a b. r a b \<Longrightarrow> f a \<sqsubseteq> f b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   270
  assumes g_mono: "\<And>a b. r a b \<Longrightarrow> g a \<sqsubseteq> g b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   271
  assumes less: "\<And>a. f a \<sqsubseteq> g a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   272
  shows "basis_fun f \<sqsubseteq> basis_fun g"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   273
 apply (rule less_cfun_ext)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   274
 apply (simp only: basis_fun_beta f_mono g_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   275
 apply (rule is_lub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   276
  apply (rule basis_fun_lemma, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   277
 apply (rule ub_imageI, rename_tac a)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   278
 apply (rule trans_less [OF less])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   279
 apply (rule is_ub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   280
  apply (rule basis_fun_lemma, erule g_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   281
 apply (erule imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   282
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   283
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   284
lemma compact_principal: "compact (principal a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   285
by (rule compactI2, simp add: principal_less_iff approxes_contlub)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   286
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   287
lemma chain_basis_fun_take:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   288
  "chain (\<lambda>i. basis_fun (\<lambda>a. principal (take i a)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   289
apply (rule chainI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   290
apply (rule basis_fun_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   291
apply (erule principal_mono [OF take_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   292
apply (erule principal_mono [OF take_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   293
apply (rule principal_mono [OF take_chain])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   294
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   295
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   296
lemma lub_basis_fun_take:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   297
  "(\<Squnion>i. basis_fun (\<lambda>a. principal (take i a))\<cdot>x) = x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   298
 apply (simp add: basis_fun_beta principal_mono take_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   299
 apply (subst image_image [where f=principal, symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   300
 apply (rule unique_lub [OF _ lub_principal_approxes])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   301
 apply (rule basis_fun_lemma2, erule principal_mono)
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 finite_directed_contains_lub:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   305
  "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u\<in>S. S <<| u"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   306
apply (drule (1) directed_finiteD, rule subset_refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   307
apply (erule bexE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   308
apply (rule rev_bexI, assumption)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   309
apply (erule (1) is_lub_maximal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   310
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   311
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   312
lemma lub_finite_directed_in_self:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   313
  "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> lub S \<in> S"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   314
apply (drule (1) directed_finiteD, rule subset_refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   315
apply (erule bexE)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   316
apply (drule (1) is_lub_maximal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   317
apply (drule thelubI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   318
apply simp
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 basis_fun_take_eq_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   322
  "\<exists>a\<in>approxes x.
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   323
    basis_fun (\<lambda>a. principal (take i a))\<cdot>x = principal (take i a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   324
 apply (simp add: basis_fun_beta principal_mono take_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   325
 apply (subst image_image [where f=principal, symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   326
 apply (subgoal_tac "finite (principal ` take i ` approxes x)")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   327
  apply (subgoal_tac "directed (principal ` take i ` approxes x)")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   328
   apply (drule (1) lub_finite_directed_in_self, fast)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   329
  apply (subst image_image)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   330
  apply (rule directed_image_ideal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   331
   apply (rule ideal_approxes)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   332
  apply (erule principal_mono [OF take_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   333
 apply (rule finite_imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   334
 apply (rule finite_take_approxes)
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 principal_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   338
  assumes adm: "adm P"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   339
  assumes P: "\<And>a. P (principal a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   340
  shows "P x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   341
 apply (subgoal_tac "P (\<Squnion>i. basis_fun (\<lambda>a. principal (take i a))\<cdot>x)")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   342
 apply (simp add: lub_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   343
 apply (rule admD [rule_format, OF adm])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   344
  apply (simp add: chain_basis_fun_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   345
 apply (cut_tac x=x and i=i in basis_fun_take_eq_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   346
 apply (clarify, simp add: P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   347
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   348
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   349
lemma finite_fixes_basis_fun_take:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   350
  "finite {x. basis_fun (\<lambda>a. principal (take i a))\<cdot>x = x}" (is "finite ?S")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   351
apply (subgoal_tac "?S \<subseteq> principal ` range (take i)")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   352
apply (erule finite_subset)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   353
apply (rule finite_imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   354
apply (rule finite_range_take)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   355
apply (clarify, erule subst)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   356
apply (cut_tac x=x and i=i in basis_fun_take_eq_principal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   357
apply fast
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   358
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   359
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   360
end
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   361
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   362
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   363
subsection {* Compact bases of bifinite domains *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   364
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   365
defaultsort bifinite
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   366
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   367
typedef (open) 'a compact_basis = "{x::'a::bifinite. compact x}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   368
by (fast intro: compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   369
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   370
lemma compact_Rep_compact_basis [simp]: "compact (Rep_compact_basis a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   371
by (rule Rep_compact_basis [simplified])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   372
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   373
lemma Rep_Abs_compact_basis_approx [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   374
  "Rep_compact_basis (Abs_compact_basis (approx n\<cdot>x)) = approx n\<cdot>x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   375
by (rule Abs_compact_basis_inverse, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   376
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   377
lemma compact_imp_Rep_compact_basis:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   378
  "compact x \<Longrightarrow> \<exists>y. x = Rep_compact_basis y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   379
by (rule exI, rule Abs_compact_basis_inverse [symmetric], simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   380
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   381
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   382
  compact_le :: "'a compact_basis \<Rightarrow> 'a compact_basis \<Rightarrow> bool" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   383
  "compact_le = (\<lambda>x y. Rep_compact_basis x \<sqsubseteq> Rep_compact_basis y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   384
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   385
lemma compact_le_refl: "compact_le x x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   386
unfolding compact_le_def by (rule refl_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   387
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   388
lemma compact_le_trans: "\<lbrakk>compact_le x y; compact_le y z\<rbrakk> \<Longrightarrow> compact_le x z"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   389
unfolding compact_le_def by (rule trans_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   390
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   391
lemma compact_le_antisym: "\<lbrakk>compact_le x y; compact_le y x\<rbrakk> \<Longrightarrow> x = y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   392
unfolding compact_le_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   393
apply (rule Rep_compact_basis_inject [THEN iffD1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   394
apply (erule (1) antisym_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   395
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   396
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   397
interpretation compact_le: preorder [compact_le]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   398
by (rule preorder.intro, rule compact_le_refl, rule compact_le_trans)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   399
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   400
text {* minimal compact element *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   401
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   402
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   403
  compact_bot :: "'a compact_basis" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   404
  "compact_bot = Abs_compact_basis \<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   405
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   406
lemma Rep_compact_bot: "Rep_compact_basis compact_bot = \<bottom>"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   407
unfolding compact_bot_def by (simp add: Abs_compact_basis_inverse)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   408
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   409
lemma compact_minimal [simp]: "compact_le compact_bot a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   410
unfolding compact_le_def Rep_compact_bot by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   411
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   412
text {* compacts *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   413
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   414
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   415
  compacts :: "'a \<Rightarrow> 'a compact_basis set" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   416
  "compacts = (\<lambda>x. {a. Rep_compact_basis a \<sqsubseteq> x})"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   417
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   418
lemma ideal_compacts: "compact_le.ideal (compacts w)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   419
unfolding compacts_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   420
 apply (rule compact_le.idealI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   421
   apply (rule_tac x="Abs_compact_basis (approx 0\<cdot>w)" in exI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   422
   apply (simp add: approx_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   423
  apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   424
  apply (cut_tac a=x in compact_Rep_compact_basis)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   425
  apply (cut_tac a=y in compact_Rep_compact_basis)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   426
  apply (drule bifinite_compact_eq_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   427
  apply (drule bifinite_compact_eq_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   428
  apply (clarify, rename_tac i j)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   429
  apply (rule_tac x="Abs_compact_basis (approx (max i j)\<cdot>w)" in exI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   430
  apply (simp add: approx_less compact_le_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   431
  apply (erule subst, erule subst)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   432
  apply (simp add: monofun_cfun chain_mono3 [OF chain_approx])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   433
 apply (simp add: compact_le_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   434
 apply (erule (1) trans_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   435
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   436
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   437
lemma compacts_Rep_compact_basis:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   438
  "compacts (Rep_compact_basis b) = {a. compact_le a b}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   439
unfolding compacts_def compact_le_def ..
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   440
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   441
lemma cont_compacts: "cont compacts"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   442
unfolding compacts_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   443
apply (rule contI2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   444
apply (rule monofunI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   445
apply (simp add: set_cpo_simps)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   446
apply (fast intro: trans_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   447
apply (simp add: set_cpo_simps)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   448
apply clarify
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   449
apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   450
apply (erule (1) compactD2 [OF compact_Rep_compact_basis])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   451
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   452
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   453
lemma compacts_lessD: "compacts x \<subseteq> compacts y \<Longrightarrow> x \<sqsubseteq> y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   454
apply (subgoal_tac "(\<Squnion>i. approx i\<cdot>x) \<sqsubseteq> y", simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   455
apply (rule admD [rule_format], simp, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   456
apply (drule_tac c="Abs_compact_basis (approx i\<cdot>x)" in subsetD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   457
apply (simp add: compacts_def Abs_compact_basis_inverse approx_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   458
apply (simp add: compacts_def Abs_compact_basis_inverse)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   459
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   460
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   461
lemma compacts_mono: "x \<sqsubseteq> y \<Longrightarrow> compacts x \<subseteq> compacts y"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   462
unfolding compacts_def by (fast intro: trans_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   463
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   464
lemma less_compact_basis_iff: "(x \<sqsubseteq> y) = (compacts x \<subseteq> compacts y)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   465
by (rule iffI [OF compacts_mono compacts_lessD])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   466
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   467
lemma compact_basis_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   468
  "\<lbrakk>adm P; \<And>a. P (Rep_compact_basis a)\<rbrakk> \<Longrightarrow> P x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   469
apply (erule approx_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   470
apply (drule_tac x="Abs_compact_basis (approx n\<cdot>x)" in meta_spec)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   471
apply (simp add: Abs_compact_basis_inverse)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   472
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   473
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   474
text {* approximation on compact bases *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   475
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   476
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   477
  compact_approx :: "nat \<Rightarrow> 'a compact_basis \<Rightarrow> 'a compact_basis" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   478
  "compact_approx = (\<lambda>n a. Abs_compact_basis (approx n\<cdot>(Rep_compact_basis a)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   479
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   480
lemma Rep_compact_approx:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   481
  "Rep_compact_basis (compact_approx n a) = approx n\<cdot>(Rep_compact_basis a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   482
unfolding compact_approx_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   483
by (simp add: Abs_compact_basis_inverse)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   484
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   485
lemmas approx_Rep_compact_basis = Rep_compact_approx [symmetric]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   486
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   487
lemma compact_approx_le:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   488
  "compact_le (compact_approx n a) a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   489
unfolding compact_le_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   490
by (simp add: Rep_compact_approx approx_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   491
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   492
lemma compact_approx_mono1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   493
  "i \<le> j \<Longrightarrow> compact_le (compact_approx i a) (compact_approx j a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   494
unfolding compact_le_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   495
apply (simp add: Rep_compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   496
apply (rule chain_mono3, simp, assumption)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   497
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   498
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   499
lemma compact_approx_mono:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   500
  "compact_le a b \<Longrightarrow> compact_le (compact_approx n a) (compact_approx n b)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   501
unfolding compact_le_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   502
apply (simp add: Rep_compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   503
apply (erule monofun_cfun_arg)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   504
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   505
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   506
lemma ex_compact_approx_eq: "\<exists>n. compact_approx n a = a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   507
apply (simp add: Rep_compact_basis_inject [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   508
apply (simp add: Rep_compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   509
apply (rule bifinite_compact_eq_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   510
apply (rule compact_Rep_compact_basis)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   511
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   512
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   513
lemma compact_approx_idem:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   514
  "compact_approx n (compact_approx n a) = compact_approx n a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   515
apply (rule Rep_compact_basis_inject [THEN iffD1])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   516
apply (simp add: Rep_compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   517
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   518
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   519
lemma finite_fixes_compact_approx: "finite {a. compact_approx n a = a}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   520
apply (subgoal_tac "finite (Rep_compact_basis ` {a. compact_approx n a = a})")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   521
apply (erule finite_imageD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   522
apply (rule inj_onI, simp add: Rep_compact_basis_inject)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   523
apply (rule finite_subset [OF _ finite_fixes_approx [where i=n]])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   524
apply (rule subsetI, clarify, rename_tac a)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   525
apply (simp add: Rep_compact_basis_inject [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   526
apply (simp add: Rep_compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   527
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   528
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   529
lemma finite_range_compact_approx: "finite (range (compact_approx n))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   530
apply (cut_tac n=n in finite_fixes_compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   531
apply (simp add: idem_fixes_eq_range compact_approx_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   532
apply (simp add: image_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   533
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   534
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   535
interpretation compact_basis:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   536
  bifinite_basis [compact_le Rep_compact_basis compacts compact_approx]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   537
apply unfold_locales
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   538
apply (rule ideal_compacts)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   539
apply (rule cont_compacts)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   540
apply (rule compacts_Rep_compact_basis)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   541
apply (erule compacts_lessD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   542
apply (rule compact_approx_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   543
apply (rule compact_approx_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   544
apply (erule compact_approx_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   545
apply (rule compact_approx_mono1, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   546
apply (rule finite_range_compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   547
apply (rule ex_compact_approx_eq)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   548
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   549
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   550
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   551
subsection {* A compact basis for powerdomains *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   552
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   553
typedef 'a pd_basis =
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   554
  "{S::'a::bifinite compact_basis set. finite S \<and> S \<noteq> {}}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   555
by (rule_tac x="{arbitrary}" in exI, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   556
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   557
lemma finite_Rep_pd_basis [simp]: "finite (Rep_pd_basis u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   558
by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   559
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   560
lemma Rep_pd_basis_nonempty [simp]: "Rep_pd_basis u \<noteq> {}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   561
by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   562
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   563
text {* unit and plus *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   564
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   565
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   566
  PDUnit :: "'a compact_basis \<Rightarrow> 'a pd_basis" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   567
  "PDUnit = (\<lambda>x. Abs_pd_basis {x})"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   568
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   569
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   570
  PDPlus :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> 'a pd_basis" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   571
  "PDPlus t u = Abs_pd_basis (Rep_pd_basis t \<union> Rep_pd_basis u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   572
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   573
lemma Rep_PDUnit:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   574
  "Rep_pd_basis (PDUnit x) = {x}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   575
unfolding PDUnit_def by (rule Abs_pd_basis_inverse) (simp add: pd_basis_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   576
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   577
lemma Rep_PDPlus:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   578
  "Rep_pd_basis (PDPlus u v) = Rep_pd_basis u \<union> Rep_pd_basis v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   579
unfolding PDPlus_def by (rule Abs_pd_basis_inverse) (simp add: pd_basis_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   580
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   581
lemma PDUnit_inject [simp]: "(PDUnit a = PDUnit b) = (a = b)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   582
unfolding Rep_pd_basis_inject [symmetric] Rep_PDUnit by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   583
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   584
lemma PDPlus_assoc: "PDPlus (PDPlus t u) v = PDPlus t (PDPlus u v)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   585
unfolding Rep_pd_basis_inject [symmetric] Rep_PDPlus by (rule Un_assoc)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   586
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   587
lemma PDPlus_commute: "PDPlus t u = PDPlus u t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   588
unfolding Rep_pd_basis_inject [symmetric] Rep_PDPlus by (rule Un_commute)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   589
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   590
lemma PDPlus_absorb: "PDPlus t t = t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   591
unfolding Rep_pd_basis_inject [symmetric] Rep_PDPlus by (rule Un_absorb)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   592
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   593
lemma pd_basis_induct1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   594
  assumes PDUnit: "\<And>a. P (PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   595
  assumes PDPlus: "\<And>a t. P t \<Longrightarrow> P (PDPlus (PDUnit a) t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   596
  shows "P x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   597
apply (induct x, unfold pd_basis_def, clarify)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   598
apply (erule (1) finite_ne_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   599
apply (cut_tac a=x in PDUnit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   600
apply (simp add: PDUnit_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   601
apply (drule_tac a=x in PDPlus)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   602
apply (simp add: PDUnit_def PDPlus_def Abs_pd_basis_inverse [unfolded pd_basis_def])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   603
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   604
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   605
lemma pd_basis_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   606
  assumes PDUnit: "\<And>a. P (PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   607
  assumes PDPlus: "\<And>t u. \<lbrakk>P t; P u\<rbrakk> \<Longrightarrow> P (PDPlus t u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   608
  shows "P x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   609
apply (induct x rule: pd_basis_induct1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   610
apply (rule PDUnit, erule PDPlus [OF PDUnit])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   611
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   612
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   613
text {* fold-pd *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   614
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   615
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   616
  fold_pd ::
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   617
    "('a compact_basis \<Rightarrow> 'b::type) \<Rightarrow> ('b \<Rightarrow> 'b \<Rightarrow> 'b) \<Rightarrow> 'a pd_basis \<Rightarrow> 'b"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   618
  where "fold_pd g f t = fold1 f (g ` Rep_pd_basis t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   619
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   620
lemma (in ACIf) fold_pd_PDUnit:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   621
  "fold_pd g f (PDUnit x) = g x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   622
unfolding fold_pd_def Rep_PDUnit by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   623
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   624
lemma (in ACIf) fold_pd_PDPlus:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   625
  "fold_pd g f (PDPlus t u) = f (fold_pd g f t) (fold_pd g f u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   626
unfolding fold_pd_def Rep_PDPlus by (simp add: image_Un fold1_Un2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   627
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   628
text {* approx-pd *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   629
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   630
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   631
  approx_pd :: "nat \<Rightarrow> 'a pd_basis \<Rightarrow> 'a pd_basis" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   632
  "approx_pd n = (\<lambda>t. Abs_pd_basis (compact_approx n ` Rep_pd_basis t))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   633
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   634
lemma Rep_approx_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   635
  "Rep_pd_basis (approx_pd n t) = compact_approx n ` Rep_pd_basis t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   636
unfolding approx_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   637
apply (rule Abs_pd_basis_inverse)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   638
apply (simp add: pd_basis_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   639
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   640
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   641
lemma approx_pd_simps [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   642
  "approx_pd n (PDUnit a) = PDUnit (compact_approx n a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   643
  "approx_pd n (PDPlus t u) = PDPlus (approx_pd n t) (approx_pd n u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   644
apply (simp_all add: Rep_pd_basis_inject [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   645
apply (simp_all add: Rep_approx_pd Rep_PDUnit Rep_PDPlus image_Un)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   646
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   647
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   648
lemma approx_pd_idem: "approx_pd n (approx_pd n t) = approx_pd n t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   649
apply (induct t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   650
apply (simp add: compact_approx_idem)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   651
apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   652
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   653
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   654
lemma range_image_f: "range (image f) = Pow (range f)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   655
apply (safe, fast)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   656
apply (rule_tac x="f -` x" in range_eqI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   657
apply (simp, fast)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   658
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   659
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   660
lemma finite_range_approx_pd: "finite (range (approx_pd n))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   661
apply (subgoal_tac "finite (Rep_pd_basis ` range (approx_pd n))")
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   662
apply (erule finite_imageD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   663
apply (rule inj_onI, simp add: Rep_pd_basis_inject)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   664
apply (subst image_image)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   665
apply (subst Rep_approx_pd)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   666
apply (simp only: range_composition)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   667
apply (rule finite_subset [OF image_mono [OF subset_UNIV]])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   668
apply (simp add: range_image_f)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   669
apply (rule finite_range_compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   670
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   671
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   672
lemma ex_approx_pd_eq: "\<exists>n. approx_pd n t = t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   673
apply (subgoal_tac "\<exists>n. \<forall>m\<ge>n. approx_pd m t = t", fast)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   674
apply (induct t rule: pd_basis_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   675
apply (cut_tac a=a in ex_compact_approx_eq)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   676
apply (clarify, rule_tac x=n in exI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   677
apply (clarify, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   678
apply (rule compact_le_antisym)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   679
apply (rule compact_approx_le)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   680
apply (drule_tac a=a in compact_approx_mono1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   681
apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   682
apply (clarify, rename_tac i j)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   683
apply (rule_tac x="max i j" in exI, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   684
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   685
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   686
end