src/HOLCF/CompactBasis.thy
author huffman
Fri, 20 Jun 2008 22:51:50 +0200
changeset 27309 c74270fd72a8
parent 27297 2c42b1505f25
child 27373 5794a0e3e26c
permissions -rw-r--r--
clean up and rename some profinite lemmas
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
27297
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
     9
imports Bifinite Cset
25904
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
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    14
locale preorder =
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    15
  fixes r :: "'a::type \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<preceq>" 50)
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    16
  assumes r_refl: "x \<preceq> x"
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    17
  assumes r_trans: "\<lbrakk>x \<preceq> y; y \<preceq> z\<rbrakk> \<Longrightarrow> x \<preceq> z"
25904
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
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    22
  "ideal A = ((\<exists>x. x \<in> A) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z) \<and>
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    23
    (\<forall>x y. x \<preceq> y \<longrightarrow> y \<in> A \<longrightarrow> x \<in> A))"
25904
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"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    27
  assumes "\<And>x y. \<lbrakk>x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z"
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    28
  assumes "\<And>x y. \<lbrakk>x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"
25904
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:
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    37
  "\<lbrakk>ideal A; x \<in> A; y \<in> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z"
25904
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:
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    41
  "\<lbrakk>ideal A; x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"
25904
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"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    46
  shows "\<lbrakk>finite U; U \<subseteq> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. \<forall>x\<in>U. x \<preceq> z"
25904
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)
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    52
apply (fast intro: r_trans)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    53
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    54
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    55
lemma ideal_principal: "ideal {x. x \<preceq> z}"
25904
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)
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    58
apply (fast intro: r_refl)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    59
apply (rule_tac x=z in bexI, fast)
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    60
apply (fast intro: r_refl)
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    61
apply (fast intro: r_trans)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    62
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    63
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    64
lemma ex_ideal: "\<exists>A. ideal A"
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    65
by (rule exI, rule ideal_principal)
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    66
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    67
lemma directed_image_ideal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    68
  assumes A: "ideal A"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    69
  assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    70
  shows "directed (f ` A)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    71
apply (rule directedI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    72
apply (cut_tac idealD1 [OF A], fast)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    73
apply (clarify, rename_tac a b)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    74
apply (drule (1) idealD2 [OF A])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    75
apply (clarify, rename_tac c)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    76
apply (rule_tac x="f c" in rev_bexI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    77
apply (erule imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    78
apply (simp add: f)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    79
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    80
27297
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
    81
lemma adm_ideal: "adm (\<lambda>A. ideal (Rep_cset A))"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    82
unfolding ideal_def by (intro adm_lemmas adm_set_lemmas)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    83
27297
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
    84
lemma cpodef_ideal_lemma:
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
    85
  "(\<exists>x. x \<in> {S. ideal (Rep_cset S)}) \<and> adm (\<lambda>x. x \<in> {S. ideal (Rep_cset S)})"
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
    86
apply (simp add: adm_ideal)
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
    87
apply (rule exI [where x="Abs_cset {x. x \<preceq> arbitrary}"])
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
    88
apply (simp add: ideal_principal)
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
    89
done
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
    90
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
    91
lemma lub_image_principal:
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    92
  assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y"
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    93
  shows "(\<Squnion>x\<in>{x. x \<preceq> y}. f x) = f y"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    94
apply (rule thelubI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    95
apply (rule is_lub_maximal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    96
apply (rule ub_imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    97
apply (simp add: f)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
    98
apply (rule imageI)
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
    99
apply (simp add: r_refl)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   100
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   101
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   102
end
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   103
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   104
interpretation sq_le: preorder ["sq_le :: 'a::po \<Rightarrow> 'a \<Rightarrow> bool"]
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   105
apply unfold_locales
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   106
apply (rule refl_less)
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   107
apply (erule (1) trans_less)
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   108
done
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   109
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   110
subsection {* Defining functions in terms of basis elements *}
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   111
26034
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   112
lemma finite_directed_contains_lub:
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   113
  "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u\<in>S. S <<| u"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   114
apply (drule (1) directed_finiteD, rule subset_refl)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   115
apply (erule bexE)
26034
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   116
apply (rule rev_bexI, assumption)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   117
apply (erule (1) is_lub_maximal)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   118
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   119
26034
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   120
lemma lub_finite_directed_in_self:
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   121
  "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> lub S \<in> S"
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   122
apply (drule (1) finite_directed_contains_lub, clarify)
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   123
apply (drule thelubI, simp)
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   124
done
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   125
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   126
lemma finite_directed_has_lub: "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u. S <<| u"
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   127
by (drule (1) finite_directed_contains_lub, fast)
97d00128072b cleaned up
huffman
parents: 25925
diff changeset
   128
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   129
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
   130
apply (erule exE, drule lubI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   131
apply (drule is_lubD1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   132
apply (erule (1) is_ubD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   133
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   134
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   135
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
   136
by (erule exE, drule lubI, erule is_lub_lub)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   137
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   138
locale basis_take = preorder +
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   139
  fixes take :: "nat \<Rightarrow> 'a::type \<Rightarrow> 'a"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   140
  assumes take_less: "take n a \<preceq> a"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   141
  assumes take_take: "take n (take n a) = take n a"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   142
  assumes take_mono: "a \<preceq> b \<Longrightarrow> take n a \<preceq> take n b"
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   143
  assumes take_chain: "take n a \<preceq> take (Suc n) a"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   144
  assumes finite_range_take: "finite (range (take n))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   145
  assumes take_covers: "\<exists>n. take n a = a"
27288
274b80691259 add lemmas take_chain_less and take_chain_le
huffman
parents: 27268
diff changeset
   146
begin
274b80691259 add lemmas take_chain_less and take_chain_le
huffman
parents: 27268
diff changeset
   147
274b80691259 add lemmas take_chain_less and take_chain_le
huffman
parents: 27268
diff changeset
   148
lemma take_chain_less: "m < n \<Longrightarrow> take m a \<preceq> take n a"
274b80691259 add lemmas take_chain_less and take_chain_le
huffman
parents: 27268
diff changeset
   149
by (erule less_Suc_induct, rule take_chain, erule (1) r_trans)
274b80691259 add lemmas take_chain_less and take_chain_le
huffman
parents: 27268
diff changeset
   150
274b80691259 add lemmas take_chain_less and take_chain_le
huffman
parents: 27268
diff changeset
   151
lemma take_chain_le: "m \<le> n \<Longrightarrow> take m a \<preceq> take n a"
274b80691259 add lemmas take_chain_less and take_chain_le
huffman
parents: 27268
diff changeset
   152
by (cases "m = n", simp add: r_refl, simp add: take_chain_less)
274b80691259 add lemmas take_chain_less and take_chain_le
huffman
parents: 27268
diff changeset
   153
274b80691259 add lemmas take_chain_less and take_chain_le
huffman
parents: 27268
diff changeset
   154
end
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   155
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   156
locale ideal_completion = basis_take +
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   157
  fixes principal :: "'a::type \<Rightarrow> 'b::cpo"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   158
  fixes rep :: "'b::cpo \<Rightarrow> 'a::type set"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   159
  assumes ideal_rep: "\<And>x. preorder.ideal r (rep x)"
27297
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   160
  assumes rep_contlub: "\<And>Y. chain Y \<Longrightarrow> rep (\<Squnion>i. Y i) = (\<Union>i. rep (Y i))"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   161
  assumes rep_principal: "\<And>a. rep (principal a) = {b. b \<preceq> a}"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   162
  assumes subset_repD: "\<And>x y. rep x \<subseteq> rep y \<Longrightarrow> x \<sqsubseteq> y"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   163
begin
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   164
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   165
lemma finite_take_rep: "finite (take n ` rep x)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   166
by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range_take])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   167
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   168
lemma basis_fun_lemma0:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   169
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   170
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   171
  shows "\<exists>u. f ` take i ` rep x <<| u"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   172
apply (rule finite_directed_has_lub)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   173
apply (rule finite_imageI)
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   174
apply (rule finite_take_rep)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   175
apply (subst image_image)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   176
apply (rule directed_image_ideal)
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   177
apply (rule ideal_rep)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   178
apply (rule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   179
apply (erule take_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   180
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   181
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   182
lemma basis_fun_lemma1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   183
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   184
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   185
  shows "chain (\<lambda>i. lub (f ` take i ` rep x))"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   186
 apply (rule chainI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   187
 apply (rule is_lub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   188
  apply (rule basis_fun_lemma0, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   189
 apply (rule is_ubI, clarsimp, rename_tac a)
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   190
 apply (rule sq_le.trans_less [OF f_mono [OF take_chain]])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   191
 apply (rule is_ub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   192
  apply (rule basis_fun_lemma0, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   193
 apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   194
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   195
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   196
lemma basis_fun_lemma2:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   197
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   198
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   199
  shows "f ` rep x <<| (\<Squnion>i. lub (f ` take i ` rep x))"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   200
 apply (rule is_lubI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   201
 apply (rule ub_imageI, rename_tac a)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   202
  apply (cut_tac a=a in take_covers, erule exE, rename_tac i)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   203
  apply (erule subst)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   204
  apply (rule rev_trans_less)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   205
   apply (rule_tac x=i in is_ub_thelub)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   206
   apply (rule basis_fun_lemma1, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   207
  apply (rule is_ub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   208
   apply (rule basis_fun_lemma0, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   209
  apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   210
 apply (rule is_lub_thelub [OF _ ub_rangeI])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   211
  apply (rule basis_fun_lemma1, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   212
 apply (rule is_lub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   213
  apply (rule basis_fun_lemma0, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   214
 apply (rule is_ubI, clarsimp, rename_tac a)
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   215
 apply (rule sq_le.trans_less [OF f_mono [OF take_less]])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   216
 apply (erule (1) ub_imageD)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   217
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   218
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   219
lemma basis_fun_lemma:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   220
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   221
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   222
  shows "\<exists>u. f ` rep x <<| u"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   223
by (rule exI, rule basis_fun_lemma2, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   224
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   225
lemma rep_mono: "x \<sqsubseteq> y \<Longrightarrow> rep x \<subseteq> rep y"
27297
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   226
apply (frule bin_chain)
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   227
apply (drule rep_contlub)
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   228
apply (simp only: thelubI [OF lub_bin_chain])
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   229
apply (rule subsetI, rule UN_I [where a=0], simp_all)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   230
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   231
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   232
lemma less_def: "x \<sqsubseteq> y \<longleftrightarrow> rep x \<subseteq> rep y"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   233
by (rule iffI [OF rep_mono subset_repD])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   234
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   235
lemma rep_eq: "rep x = {a. principal a \<sqsubseteq> x}"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   236
unfolding less_def rep_principal
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   237
apply safe
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   238
apply (erule (1) idealD3 [OF ideal_rep])
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   239
apply (erule subsetD, simp add: r_refl)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   240
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   241
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   242
lemma mem_rep_iff_principal_less: "a \<in> rep x \<longleftrightarrow> principal a \<sqsubseteq> x"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   243
by (simp add: rep_eq)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   244
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   245
lemma principal_less_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   246
by (simp add: rep_eq)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   247
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   248
lemma principal_less_iff [simp]: "principal a \<sqsubseteq> principal b \<longleftrightarrow> a \<preceq> b"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   249
by (simp add: principal_less_iff_mem_rep rep_principal)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   250
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   251
lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> a \<preceq> b \<and> b \<preceq> a"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   252
unfolding po_eq_conv [where 'a='b] principal_less_iff ..
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   253
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   254
lemma repD: "a \<in> rep x \<Longrightarrow> principal a \<sqsubseteq> x"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   255
by (simp add: rep_eq)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   256
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   257
lemma principal_mono: "a \<preceq> b \<Longrightarrow> principal a \<sqsubseteq> principal b"
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   258
by (simp only: principal_less_iff)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   259
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   260
lemma lessI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   261
unfolding principal_less_iff_mem_rep
26806
40b411ec05aa Adapted to encoding of sets as predicates
berghofe
parents: 26454
diff changeset
   262
by (simp add: less_def subset_eq)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   263
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   264
lemma lub_principal_rep: "principal ` rep x <<| x"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   265
apply (rule is_lubI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   266
apply (rule ub_imageI)
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   267
apply (erule repD)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   268
apply (subst less_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   269
apply (rule subsetI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   270
apply (drule (1) ub_imageD)
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   271
apply (simp add: rep_eq)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   272
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   273
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   274
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   275
  basis_fun :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   276
  "basis_fun = (\<lambda>f. (\<Lambda> x. lub (f ` rep x)))"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   277
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   278
lemma basis_fun_beta:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   279
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   280
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   281
  shows "basis_fun f\<cdot>x = lub (f ` rep x)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   282
unfolding basis_fun_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   283
proof (rule beta_cfun)
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   284
  have lub: "\<And>x. \<exists>u. f ` rep x <<| u"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   285
    using f_mono by (rule basis_fun_lemma)
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   286
  show cont: "cont (\<lambda>x. lub (f ` rep x))"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   287
    apply (rule contI2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   288
     apply (rule monofunI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   289
     apply (rule is_lub_thelub0 [OF lub ub_imageI])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   290
     apply (rule is_ub_thelub0 [OF lub imageI])
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   291
     apply (erule (1) subsetD [OF rep_mono])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   292
    apply (rule is_lub_thelub0 [OF lub ub_imageI])
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   293
    apply (simp add: rep_contlub, clarify)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   294
    apply (erule rev_trans_less [OF is_ub_thelub])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   295
    apply (erule is_ub_thelub0 [OF lub imageI])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   296
    done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   297
qed
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   298
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   299
lemma basis_fun_principal:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   300
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   301
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   302
  shows "basis_fun f\<cdot>(principal a) = f a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   303
apply (subst basis_fun_beta, erule f_mono)
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   304
apply (subst rep_principal)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   305
apply (rule lub_image_principal, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   306
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   307
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   308
lemma basis_fun_mono:
27268
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   309
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
1d8c6703c7b1 replace preorder class with locale
huffman
parents: 27267
diff changeset
   310
  assumes g_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> g a \<sqsubseteq> g b"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   311
  assumes less: "\<And>a. f a \<sqsubseteq> g a"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   312
  shows "basis_fun f \<sqsubseteq> basis_fun g"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   313
 apply (rule less_cfun_ext)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   314
 apply (simp only: basis_fun_beta f_mono g_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   315
 apply (rule is_lub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   316
  apply (rule basis_fun_lemma, erule f_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   317
 apply (rule ub_imageI, rename_tac a)
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   318
 apply (rule sq_le.trans_less [OF less])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   319
 apply (rule is_ub_thelub0)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   320
  apply (rule basis_fun_lemma, erule g_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   321
 apply (erule imageI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   322
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   323
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   324
lemma compact_principal [simp]: "compact (principal a)"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   325
by (rule compactI2, simp add: principal_less_iff_mem_rep rep_contlub)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   326
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   327
definition
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   328
  completion_approx :: "nat \<Rightarrow> 'b \<rightarrow> 'b" where
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   329
  "completion_approx = (\<lambda>i. basis_fun (\<lambda>a. principal (take i a)))"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   330
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   331
lemma completion_approx_beta:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   332
  "completion_approx i\<cdot>x = (\<Squnion>a\<in>rep x. principal (take i a))"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   333
unfolding completion_approx_def
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   334
by (simp add: basis_fun_beta principal_mono take_mono)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   335
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   336
lemma completion_approx_principal:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   337
  "completion_approx i\<cdot>(principal a) = principal (take i a)"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   338
unfolding completion_approx_def
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   339
by (simp add: basis_fun_principal principal_mono take_mono)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   340
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   341
lemma chain_completion_approx: "chain completion_approx"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   342
unfolding completion_approx_def
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   343
apply (rule chainI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   344
apply (rule basis_fun_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   345
apply (erule principal_mono [OF take_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   346
apply (erule principal_mono [OF take_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   347
apply (rule principal_mono [OF take_chain])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   348
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   349
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   350
lemma lub_completion_approx: "(\<Squnion>i. completion_approx i\<cdot>x) = x"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   351
unfolding completion_approx_beta
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   352
 apply (subst image_image [where f=principal, symmetric])
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   353
 apply (rule unique_lub [OF _ lub_principal_rep])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   354
 apply (rule basis_fun_lemma2, erule principal_mono)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   355
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   356
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   357
lemma completion_approx_eq_principal:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   358
  "\<exists>a\<in>rep x. completion_approx i\<cdot>x = principal (take i a)"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   359
unfolding completion_approx_beta
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   360
 apply (subst image_image [where f=principal, symmetric])
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   361
 apply (subgoal_tac "finite (principal ` take i ` rep x)")
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   362
  apply (subgoal_tac "directed (principal ` take i ` rep x)")
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   363
   apply (drule (1) lub_finite_directed_in_self, fast)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   364
  apply (subst image_image)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   365
  apply (rule directed_image_ideal)
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   366
   apply (rule ideal_rep)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   367
  apply (erule principal_mono [OF take_mono])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   368
 apply (rule finite_imageI)
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   369
 apply (rule finite_take_rep)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   370
done
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   371
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   372
lemma completion_approx_idem:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   373
  "completion_approx i\<cdot>(completion_approx i\<cdot>x) = completion_approx i\<cdot>x"
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   374
using completion_approx_eq_principal [where i=i and x=x]
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   375
by (auto simp add: completion_approx_principal take_take)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   376
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   377
lemma finite_fixes_completion_approx:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   378
  "finite {x. completion_approx i\<cdot>x = x}" (is "finite ?S")
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   379
apply (subgoal_tac "?S \<subseteq> principal ` range (take i)")
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   380
apply (erule finite_subset)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   381
apply (rule finite_imageI)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   382
apply (rule finite_range_take)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   383
apply (clarify, erule subst)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   384
apply (cut_tac x=x and i=i in completion_approx_eq_principal)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   385
apply fast
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   386
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   387
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   388
lemma principal_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   389
  assumes adm: "adm P"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   390
  assumes P: "\<And>a. P (principal a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   391
  shows "P x"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   392
 apply (subgoal_tac "P (\<Squnion>i. completion_approx i\<cdot>x)")
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   393
 apply (simp add: lub_completion_approx)
25925
3dc4acca4388 change lemma admD to rule_format
huffman
parents: 25922
diff changeset
   394
 apply (rule admD [OF adm])
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   395
  apply (simp add: chain_completion_approx)
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   396
 apply (cut_tac x=x and i=i in completion_approx_eq_principal)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   397
 apply (clarify, simp add: P)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   398
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   399
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   400
lemma principal_induct2:
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   401
  "\<lbrakk>\<And>y. adm (\<lambda>x. P x y); \<And>x. adm (\<lambda>y. P x y);
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   402
    \<And>a b. P (principal a) (principal b)\<rbrakk> \<Longrightarrow> P x y"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   403
apply (rule_tac x=y in spec)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   404
apply (rule_tac x=x in principal_induct, simp)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   405
apply (rule allI, rename_tac y)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   406
apply (rule_tac x=y in principal_induct, simp)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   407
apply simp
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   408
done
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   409
27267
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   410
lemma compact_imp_principal: "compact x \<Longrightarrow> \<exists>a. x = principal a"
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   411
apply (drule adm_compact_neq [OF _ cont_id])
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   412
apply (drule admD2 [where Y="\<lambda>n. completion_approx n\<cdot>x"])
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   413
apply (simp add: chain_completion_approx)
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   414
apply (simp add: lub_completion_approx)
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   415
apply (erule exE, erule ssubst)
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   416
apply (cut_tac i=i and x=x in completion_approx_eq_principal)
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   417
apply (clarify, erule exI)
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   418
done
5ebfb7f25ebb add lemma compact_imp_principal to locale ideal_completion
huffman
parents: 26927
diff changeset
   419
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   420
end
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   421
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   422
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   423
subsection {* Compact bases of bifinite domains *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   424
26407
562a1d615336 rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents: 26041
diff changeset
   425
defaultsort profinite
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   426
26407
562a1d615336 rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents: 26041
diff changeset
   427
typedef (open) 'a compact_basis = "{x::'a::profinite. compact x}"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   428
by (fast intro: compact_approx)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   429
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   430
lemma compact_Rep_compact_basis: "compact (Rep_compact_basis a)"
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   431
by (rule Rep_compact_basis [unfolded mem_Collect_eq])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   432
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   433
instantiation compact_basis :: (profinite) sq_ord
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   434
begin
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   435
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   436
definition
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   437
  compact_le_def:
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   438
    "(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
   439
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   440
instance ..
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   441
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   442
end
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   443
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   444
instance compact_basis :: (profinite) po
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   445
by (rule typedef_po
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   446
    [OF type_definition_compact_basis compact_le_def])
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   447
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   448
text {* Take function for compact basis *}
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   449
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   450
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   451
  compact_approx :: "nat \<Rightarrow> 'a compact_basis \<Rightarrow> 'a compact_basis" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   452
  "compact_approx = (\<lambda>n a. Abs_compact_basis (approx n\<cdot>(Rep_compact_basis a)))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   453
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   454
lemma Rep_compact_approx:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   455
  "Rep_compact_basis (compact_approx n a) = approx n\<cdot>(Rep_compact_basis a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   456
unfolding compact_approx_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   457
by (simp add: Abs_compact_basis_inverse)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   458
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   459
lemmas approx_Rep_compact_basis = Rep_compact_approx [symmetric]
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   460
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   461
interpretation compact_basis:
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   462
  basis_take [sq_le compact_approx]
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   463
proof
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   464
  fix n :: nat and a :: "'a compact_basis"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   465
  show "compact_approx n a \<sqsubseteq> a"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   466
    unfolding compact_le_def
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   467
    by (simp add: Rep_compact_approx approx_less)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   468
next
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   469
  fix n :: nat and a :: "'a compact_basis"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   470
  show "compact_approx n (compact_approx n a) = compact_approx n a"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   471
    by (simp add: Rep_compact_basis_inject [symmetric] Rep_compact_approx)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   472
next
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   473
  fix n :: nat and a b :: "'a compact_basis"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   474
  assume "a \<sqsubseteq> b" thus "compact_approx n a \<sqsubseteq> compact_approx n b"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   475
    unfolding compact_le_def Rep_compact_approx
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   476
    by (rule monofun_cfun_arg)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   477
next
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   478
  fix n :: nat and a :: "'a compact_basis"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   479
  show "\<And>n a. compact_approx n a \<sqsubseteq> compact_approx (Suc n) a"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   480
    unfolding compact_le_def Rep_compact_approx
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   481
    by (rule chainE, simp)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   482
next
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   483
  fix n :: nat
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   484
  show "finite (range (compact_approx n))"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   485
    apply (rule finite_imageD [where f="Rep_compact_basis"])
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   486
    apply (rule finite_subset [where B="range (\<lambda>x. approx n\<cdot>x)"])
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   487
    apply (clarsimp simp add: Rep_compact_approx)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   488
    apply (rule finite_range_approx)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   489
    apply (rule inj_onI, simp add: Rep_compact_basis_inject)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   490
    done
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   491
next
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   492
  fix a :: "'a compact_basis"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   493
  show "\<exists>n. compact_approx n a = a"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   494
    apply (simp add: Rep_compact_basis_inject [symmetric])
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   495
    apply (simp add: Rep_compact_approx)
27309
c74270fd72a8 clean up and rename some profinite lemmas
huffman
parents: 27297
diff changeset
   496
    apply (rule profinite_compact_eq_approx)
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   497
    apply (rule compact_Rep_compact_basis)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   498
    done
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   499
qed
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   500
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   501
text {* Ideal completion *}
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   502
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   503
definition
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   504
  compacts :: "'a \<Rightarrow> 'a compact_basis set" where
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   505
  "compacts = (\<lambda>x. {a. Rep_compact_basis a \<sqsubseteq> x})"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   506
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   507
interpretation compact_basis:
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   508
  ideal_completion [sq_le compact_approx Rep_compact_basis compacts]
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   509
proof
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   510
  fix w :: 'a
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   511
  show "preorder.ideal sq_le (compacts w)"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   512
  proof (rule sq_le.idealI)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   513
    show "\<exists>x. x \<in> compacts w"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   514
      unfolding compacts_def
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   515
      apply (rule_tac x="Abs_compact_basis (approx 0\<cdot>w)" in exI)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   516
      apply (simp add: Abs_compact_basis_inverse approx_less)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   517
      done
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   518
  next
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   519
    fix x y :: "'a compact_basis"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   520
    assume "x \<in> compacts w" "y \<in> compacts w"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   521
    thus "\<exists>z \<in> compacts w. x \<sqsubseteq> z \<and> y \<sqsubseteq> z"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   522
      unfolding compacts_def
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   523
      apply simp
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   524
      apply (cut_tac a=x in compact_Rep_compact_basis)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   525
      apply (cut_tac a=y in compact_Rep_compact_basis)
27309
c74270fd72a8 clean up and rename some profinite lemmas
huffman
parents: 27297
diff changeset
   526
      apply (drule profinite_compact_eq_approx)
c74270fd72a8 clean up and rename some profinite lemmas
huffman
parents: 27297
diff changeset
   527
      apply (drule profinite_compact_eq_approx)
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   528
      apply (clarify, rename_tac i j)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   529
      apply (rule_tac x="Abs_compact_basis (approx (max i j)\<cdot>w)" in exI)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   530
      apply (simp add: compact_le_def)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   531
      apply (simp add: Abs_compact_basis_inverse approx_less)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   532
      apply (erule subst, erule subst)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   533
      apply (simp add: monofun_cfun chain_mono [OF chain_approx])
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   534
      done
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   535
  next
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   536
    fix x y :: "'a compact_basis"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   537
    assume "x \<sqsubseteq> y" "y \<in> compacts w" thus "x \<in> compacts w"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   538
      unfolding compacts_def
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   539
      apply simp
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   540
      apply (simp add: compact_le_def)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   541
      apply (erule (1) trans_less)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   542
      done
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   543
  qed
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   544
next
27297
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   545
  fix Y :: "nat \<Rightarrow> 'a"
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   546
  assume Y: "chain Y"
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   547
  show "compacts (\<Squnion>i. Y i) = (\<Union>i. compacts (Y i))"
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   548
    unfolding compacts_def
27297
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   549
    apply safe
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   550
    apply (simp add: compactD2 [OF compact_Rep_compact_basis Y])
2c42b1505f25 removed SetPcpo.thy and cpo instance for type bool;
huffman
parents: 27289
diff changeset
   551
    apply (erule trans_less, rule is_ub_thelub [OF Y])
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   552
    done
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   553
next
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   554
  fix a :: "'a compact_basis"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   555
  show "compacts (Rep_compact_basis a) = {b. b \<sqsubseteq> a}"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   556
    unfolding compacts_def compact_le_def ..
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   557
next
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   558
  fix x y :: "'a"
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   559
  assume "compacts x \<subseteq> compacts y" thus "x \<sqsubseteq> y"
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   560
    apply (subgoal_tac "(\<Squnion>i. approx i\<cdot>x) \<sqsubseteq> y", simp)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   561
    apply (rule admD, simp, simp)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   562
    apply (drule_tac c="Abs_compact_basis (approx i\<cdot>x)" in subsetD)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   563
    apply (simp add: compacts_def Abs_compact_basis_inverse approx_less)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   564
    apply (simp add: compacts_def Abs_compact_basis_inverse)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   565
    done
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   566
qed
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   567
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   568
text {* minimal compact element *}
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   569
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   570
definition
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   571
  compact_bot :: "'a::bifinite compact_basis" where
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   572
  "compact_bot = Abs_compact_basis \<bottom>"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   573
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   574
lemma Rep_compact_bot: "Rep_compact_basis compact_bot = \<bottom>"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   575
unfolding compact_bot_def by (simp add: Abs_compact_basis_inverse)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   576
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   577
lemma compact_minimal [simp]: "compact_bot \<sqsubseteq> a"
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   578
unfolding compact_le_def Rep_compact_bot by simp
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   579
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   580
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   581
subsection {* A compact basis for powerdomains *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   582
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   583
typedef 'a pd_basis =
26407
562a1d615336 rename class bifinite_cpo to profinite; generalize powerdomains from bifinite to profinite
huffman
parents: 26041
diff changeset
   584
  "{S::'a::profinite compact_basis set. finite S \<and> S \<noteq> {}}"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   585
by (rule_tac x="{arbitrary}" in exI, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   586
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   587
lemma finite_Rep_pd_basis [simp]: "finite (Rep_pd_basis u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   588
by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   589
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   590
lemma Rep_pd_basis_nonempty [simp]: "Rep_pd_basis u \<noteq> {}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   591
by (insert Rep_pd_basis [of u, unfolded pd_basis_def]) simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   592
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   593
text {* unit and plus *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   594
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   595
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   596
  PDUnit :: "'a compact_basis \<Rightarrow> 'a pd_basis" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   597
  "PDUnit = (\<lambda>x. Abs_pd_basis {x})"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   598
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   599
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   600
  PDPlus :: "'a pd_basis \<Rightarrow> 'a pd_basis \<Rightarrow> 'a pd_basis" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   601
  "PDPlus t u = Abs_pd_basis (Rep_pd_basis t \<union> Rep_pd_basis u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   602
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   603
lemma Rep_PDUnit:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   604
  "Rep_pd_basis (PDUnit x) = {x}"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   605
unfolding PDUnit_def by (rule Abs_pd_basis_inverse) (simp add: pd_basis_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   606
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   607
lemma Rep_PDPlus:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   608
  "Rep_pd_basis (PDPlus u v) = Rep_pd_basis u \<union> Rep_pd_basis v"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   609
unfolding PDPlus_def by (rule Abs_pd_basis_inverse) (simp add: pd_basis_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   610
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   611
lemma PDUnit_inject [simp]: "(PDUnit a = PDUnit b) = (a = b)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   612
unfolding Rep_pd_basis_inject [symmetric] Rep_PDUnit by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   613
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   614
lemma PDPlus_assoc: "PDPlus (PDPlus t u) v = PDPlus t (PDPlus u v)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   615
unfolding Rep_pd_basis_inject [symmetric] Rep_PDPlus by (rule Un_assoc)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   616
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   617
lemma PDPlus_commute: "PDPlus t u = PDPlus u t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   618
unfolding Rep_pd_basis_inject [symmetric] Rep_PDPlus by (rule Un_commute)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   619
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   620
lemma PDPlus_absorb: "PDPlus t t = t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   621
unfolding Rep_pd_basis_inject [symmetric] Rep_PDPlus by (rule Un_absorb)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   622
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   623
lemma pd_basis_induct1:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   624
  assumes PDUnit: "\<And>a. P (PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   625
  assumes PDPlus: "\<And>a t. P t \<Longrightarrow> P (PDPlus (PDUnit a) t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   626
  shows "P x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   627
apply (induct x, unfold pd_basis_def, clarify)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   628
apply (erule (1) finite_ne_induct)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   629
apply (cut_tac a=x in PDUnit)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   630
apply (simp add: PDUnit_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   631
apply (drule_tac a=x in PDPlus)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   632
apply (simp add: PDUnit_def PDPlus_def Abs_pd_basis_inverse [unfolded pd_basis_def])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   633
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   634
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   635
lemma pd_basis_induct:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   636
  assumes PDUnit: "\<And>a. P (PDUnit a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   637
  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
   638
  shows "P x"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   639
apply (induct x rule: pd_basis_induct1)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   640
apply (rule PDUnit, erule PDPlus [OF PDUnit])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   641
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   642
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   643
text {* fold-pd *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   644
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   645
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   646
  fold_pd ::
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   647
    "('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
   648
  where "fold_pd g f t = fold1 f (g ` Rep_pd_basis t)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   649
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   650
lemma fold_pd_PDUnit:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   651
  includes ab_semigroup_idem_mult f
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   652
  shows "fold_pd g f (PDUnit x) = g x"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   653
unfolding fold_pd_def Rep_PDUnit by simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   654
26927
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   655
lemma fold_pd_PDPlus:
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   656
  includes ab_semigroup_idem_mult f
8684b5240f11 rename locales;
huffman
parents: 26806
diff changeset
   657
  shows "fold_pd g f (PDPlus t u) = f (fold_pd g f t) (fold_pd g f u)"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   658
unfolding fold_pd_def Rep_PDPlus by (simp add: image_Un fold1_Un2)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   659
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   660
text {* approx-pd *}
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   661
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   662
definition
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   663
  approx_pd :: "nat \<Rightarrow> 'a pd_basis \<Rightarrow> 'a pd_basis" where
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   664
  "approx_pd n = (\<lambda>t. Abs_pd_basis (compact_approx n ` Rep_pd_basis t))"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   665
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   666
lemma Rep_approx_pd:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   667
  "Rep_pd_basis (approx_pd n t) = compact_approx n ` Rep_pd_basis t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   668
unfolding approx_pd_def
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   669
apply (rule Abs_pd_basis_inverse)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   670
apply (simp add: pd_basis_def)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   671
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   672
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   673
lemma approx_pd_simps [simp]:
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   674
  "approx_pd n (PDUnit a) = PDUnit (compact_approx n a)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   675
  "approx_pd n (PDPlus t u) = PDPlus (approx_pd n t) (approx_pd n u)"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   676
apply (simp_all add: Rep_pd_basis_inject [symmetric])
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   677
apply (simp_all add: Rep_approx_pd Rep_PDUnit Rep_PDPlus image_Un)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   678
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   679
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   680
lemma approx_pd_idem: "approx_pd n (approx_pd n t) = approx_pd n t"
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   681
apply (induct t rule: pd_basis_induct)
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   682
apply (simp add: compact_basis.take_take)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   683
apply 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
lemma finite_range_approx_pd: "finite (range (approx_pd n))"
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   687
apply (rule finite_imageD [where f="Rep_pd_basis"])
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   688
apply (rule finite_subset [where B="Pow (range (compact_approx n))"])
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   689
apply (clarsimp simp add: Rep_approx_pd)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   690
apply (simp add: compact_basis.finite_range_take)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   691
apply (rule inj_onI, simp add: Rep_pd_basis_inject)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   692
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   693
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   694
lemma approx_pd_covers: "\<exists>n. approx_pd n t = t"
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   695
apply (subgoal_tac "\<exists>n. \<forall>m\<ge>n. approx_pd m t = t", fast)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   696
apply (induct t rule: pd_basis_induct)
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   697
apply (cut_tac a=a in compact_basis.take_covers)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   698
apply (clarify, rule_tac x=n in exI)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   699
apply (clarify, simp)
26420
57a626f64875 make preorder locale into a superclass of class po
huffman
parents: 26407
diff changeset
   700
apply (rule antisym_less)
27289
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   701
apply (rule compact_basis.take_less)
c49d427867aa move lemmas into locales;
huffman
parents: 27288
diff changeset
   702
apply (drule_tac a=a in compact_basis.take_chain_le)
25904
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   703
apply simp
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   704
apply (clarify, rename_tac i j)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   705
apply (rule_tac x="max i j" in exI, simp)
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   706
done
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   707
8161f137b0e9 new theory of powerdomains
huffman
parents:
diff changeset
   708
end