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