src/HOLCF/Completion.thy
author wenzelm
Fri, 15 Aug 2008 16:08:08 +0200
changeset 27893 7c97cf70d663
parent 27404 62171da527d6
child 28053 a2106c0d8c45
permissions -rw-r--r--
added README;
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
27404
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     1
(*  Title:      HOLCF/Completion.thy
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     2
    ID:         $Id$
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     3
    Author:     Brian Huffman
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     4
*)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     5
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     6
header {* Defining bifinite domains by ideal completion *}
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     7
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     8
theory Completion
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
     9
imports Bifinite
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    10
begin
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    11
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    12
subsection {* Ideals over a preorder *}
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    13
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    14
locale preorder =
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    15
  fixes r :: "'a::type \<Rightarrow> 'a \<Rightarrow> bool" (infix "\<preceq>" 50)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    16
  assumes r_refl: "x \<preceq> x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    17
  assumes r_trans: "\<lbrakk>x \<preceq> y; y \<preceq> z\<rbrakk> \<Longrightarrow> x \<preceq> z"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    18
begin
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    19
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    20
definition
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    21
  ideal :: "'a set \<Rightarrow> bool" where
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    22
  "ideal A = ((\<exists>x. x \<in> A) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. \<exists>z\<in>A. x \<preceq> z \<and> y \<preceq> z) \<and>
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    23
    (\<forall>x y. x \<preceq> y \<longrightarrow> y \<in> A \<longrightarrow> x \<in> A))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    24
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    25
lemma idealI:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    26
  assumes "\<exists>x. x \<in> A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
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"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    28
  assumes "\<And>x y. \<lbrakk>x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    29
  shows "ideal A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    30
unfolding ideal_def using prems by fast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    31
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    32
lemma idealD1:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    33
  "ideal A \<Longrightarrow> \<exists>x. x \<in> A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    34
unfolding ideal_def by fast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    35
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    36
lemma idealD2:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
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"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    38
unfolding ideal_def by fast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    39
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    40
lemma idealD3:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    41
  "\<lbrakk>ideal A; x \<preceq> y; y \<in> A\<rbrakk> \<Longrightarrow> x \<in> A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    42
unfolding ideal_def by fast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    43
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    44
lemma ideal_directed_finite:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    45
  assumes A: "ideal A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    46
  shows "\<lbrakk>finite U; U \<subseteq> A\<rbrakk> \<Longrightarrow> \<exists>z\<in>A. \<forall>x\<in>U. x \<preceq> z"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    47
apply (induct U set: finite)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    48
apply (simp add: idealD1 [OF A])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    49
apply (simp, clarify, rename_tac y)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    50
apply (drule (1) idealD2 [OF A])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    51
apply (clarify, erule_tac x=z in rev_bexI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    52
apply (fast intro: r_trans)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    53
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    54
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    55
lemma ideal_principal: "ideal {x. x \<preceq> z}"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    56
apply (rule idealI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    57
apply (rule_tac x=z in exI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    58
apply (fast intro: r_refl)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    59
apply (rule_tac x=z in bexI, fast)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    60
apply (fast intro: r_refl)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    61
apply (fast intro: r_trans)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    62
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    63
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    64
lemma ex_ideal: "\<exists>A. ideal A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    65
by (rule exI, rule ideal_principal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    66
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    67
lemma directed_image_ideal:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    68
  assumes A: "ideal A"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    69
  assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    70
  shows "directed (f ` A)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    71
apply (rule directedI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    72
apply (cut_tac idealD1 [OF A], fast)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    73
apply (clarify, rename_tac a b)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    74
apply (drule (1) idealD2 [OF A])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    75
apply (clarify, rename_tac c)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    76
apply (rule_tac x="f c" in rev_bexI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    77
apply (erule imageI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    78
apply (simp add: f)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    79
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    80
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    81
lemma lub_image_principal:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    82
  assumes f: "\<And>x y. x \<preceq> y \<Longrightarrow> f x \<sqsubseteq> f y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    83
  shows "(\<Squnion>x\<in>{x. x \<preceq> y}. f x) = f y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    84
apply (rule thelubI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    85
apply (rule is_lub_maximal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    86
apply (rule ub_imageI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    87
apply (simp add: f)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    88
apply (rule imageI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    89
apply (simp add: r_refl)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    90
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    91
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    92
text {* The set of ideals is a cpo *}
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    93
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    94
lemma ideal_UN:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    95
  fixes A :: "nat \<Rightarrow> 'a set"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    96
  assumes ideal_A: "\<And>i. ideal (A i)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    97
  assumes chain_A: "\<And>i j. i \<le> j \<Longrightarrow> A i \<subseteq> A j"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    98
  shows "ideal (\<Union>i. A i)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
    99
 apply (rule idealI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   100
   apply (cut_tac idealD1 [OF ideal_A], fast)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   101
  apply (clarify, rename_tac i j)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   102
  apply (drule subsetD [OF chain_A [OF le_maxI1]])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   103
  apply (drule subsetD [OF chain_A [OF le_maxI2]])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   104
  apply (drule (1) idealD2 [OF ideal_A])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   105
  apply blast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   106
 apply clarify
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   107
 apply (drule (1) idealD3 [OF ideal_A])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   108
 apply fast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   109
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   110
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   111
lemma typedef_ideal_po:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   112
  fixes Abs :: "'a set \<Rightarrow> 'b::sq_ord"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   113
  assumes type: "type_definition Rep Abs {S. ideal S}"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   114
  assumes less: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   115
  shows "OFCLASS('b, po_class)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   116
 apply (intro_classes, unfold less)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   117
   apply (rule subset_refl)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   118
  apply (erule (1) subset_trans)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   119
 apply (rule type_definition.Rep_inject [OF type, THEN iffD1])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   120
 apply (erule (1) subset_antisym)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   121
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   122
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   123
lemma
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   124
  fixes Abs :: "'a set \<Rightarrow> 'b::po"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   125
  assumes type: "type_definition Rep Abs {S. ideal S}"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   126
  assumes less: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   127
  assumes S: "chain S"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   128
  shows typedef_ideal_lub: "range S <<| Abs (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   129
    and typedef_ideal_rep_contlub: "Rep (\<Squnion>i. S i) = (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   130
proof -
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   131
  have 1: "ideal (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   132
    apply (rule ideal_UN)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   133
     apply (rule type_definition.Rep [OF type, unfolded mem_Collect_eq])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   134
    apply (subst less [symmetric])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   135
    apply (erule chain_mono [OF S])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   136
    done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   137
  hence 2: "Rep (Abs (\<Union>i. Rep (S i))) = (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   138
    by (simp add: type_definition.Abs_inverse [OF type])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   139
  show 3: "range S <<| Abs (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   140
    apply (rule is_lubI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   141
     apply (rule is_ubI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   142
     apply (simp add: less 2, fast)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   143
    apply (simp add: less 2 is_ub_def, fast)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   144
    done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   145
  hence 4: "(\<Squnion>i. S i) = Abs (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   146
    by (rule thelubI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   147
  show 5: "Rep (\<Squnion>i. S i) = (\<Union>i. Rep (S i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   148
    by (simp add: 4 2)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   149
qed
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   150
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   151
lemma typedef_ideal_cpo:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   152
  fixes Abs :: "'a set \<Rightarrow> 'b::po"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   153
  assumes type: "type_definition Rep Abs {S. ideal S}"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   154
  assumes less: "\<And>x y. x \<sqsubseteq> y \<longleftrightarrow> Rep x \<subseteq> Rep y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   155
  shows "OFCLASS('b, cpo_class)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   156
by (default, rule exI, erule typedef_ideal_lub [OF type less])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   157
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   158
end
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   159
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   160
interpretation sq_le: preorder ["sq_le :: 'a::po \<Rightarrow> 'a \<Rightarrow> bool"]
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   161
apply unfold_locales
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   162
apply (rule refl_less)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   163
apply (erule (1) trans_less)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   164
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   165
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   166
subsection {* Defining functions in terms of basis elements *}
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   167
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   168
lemma finite_directed_contains_lub:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   169
  "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u\<in>S. S <<| u"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   170
apply (drule (1) directed_finiteD, rule subset_refl)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   171
apply (erule bexE)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   172
apply (rule rev_bexI, assumption)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   173
apply (erule (1) is_lub_maximal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   174
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   175
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   176
lemma lub_finite_directed_in_self:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   177
  "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> lub S \<in> S"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   178
apply (drule (1) finite_directed_contains_lub, clarify)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   179
apply (drule thelubI, simp)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   180
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   181
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   182
lemma finite_directed_has_lub: "\<lbrakk>finite S; directed S\<rbrakk> \<Longrightarrow> \<exists>u. S <<| u"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   183
by (drule (1) finite_directed_contains_lub, fast)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   184
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   185
lemma is_ub_thelub0: "\<lbrakk>\<exists>u. S <<| u; x \<in> S\<rbrakk> \<Longrightarrow> x \<sqsubseteq> lub S"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   186
apply (erule exE, drule lubI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   187
apply (drule is_lubD1)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   188
apply (erule (1) is_ubD)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   189
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   190
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   191
lemma is_lub_thelub0: "\<lbrakk>\<exists>u. S <<| u; S <| x\<rbrakk> \<Longrightarrow> lub S \<sqsubseteq> x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   192
by (erule exE, drule lubI, erule is_lub_lub)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   193
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   194
locale basis_take = preorder +
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   195
  fixes take :: "nat \<Rightarrow> 'a::type \<Rightarrow> 'a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   196
  assumes take_less: "take n a \<preceq> a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   197
  assumes take_take: "take n (take n a) = take n a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   198
  assumes take_mono: "a \<preceq> b \<Longrightarrow> take n a \<preceq> take n b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   199
  assumes take_chain: "take n a \<preceq> take (Suc n) a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   200
  assumes finite_range_take: "finite (range (take n))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   201
  assumes take_covers: "\<exists>n. take n a = a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   202
begin
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   203
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   204
lemma take_chain_less: "m < n \<Longrightarrow> take m a \<preceq> take n a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   205
by (erule less_Suc_induct, rule take_chain, erule (1) r_trans)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   206
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   207
lemma take_chain_le: "m \<le> n \<Longrightarrow> take m a \<preceq> take n a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   208
by (cases "m = n", simp add: r_refl, simp add: take_chain_less)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   209
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   210
end
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   211
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   212
locale ideal_completion = basis_take +
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   213
  fixes principal :: "'a::type \<Rightarrow> 'b::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   214
  fixes rep :: "'b::cpo \<Rightarrow> 'a::type set"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   215
  assumes ideal_rep: "\<And>x. preorder.ideal r (rep x)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   216
  assumes rep_contlub: "\<And>Y. chain Y \<Longrightarrow> rep (\<Squnion>i. Y i) = (\<Union>i. rep (Y i))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   217
  assumes rep_principal: "\<And>a. rep (principal a) = {b. b \<preceq> a}"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   218
  assumes subset_repD: "\<And>x y. rep x \<subseteq> rep y \<Longrightarrow> x \<sqsubseteq> y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   219
begin
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   220
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   221
lemma finite_take_rep: "finite (take n ` rep x)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   222
by (rule finite_subset [OF image_mono [OF subset_UNIV] finite_range_take])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   223
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   224
lemma basis_fun_lemma0:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   225
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   226
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   227
  shows "\<exists>u. f ` take i ` rep x <<| u"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   228
apply (rule finite_directed_has_lub)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   229
apply (rule finite_imageI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   230
apply (rule finite_take_rep)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   231
apply (subst image_image)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   232
apply (rule directed_image_ideal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   233
apply (rule ideal_rep)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   234
apply (rule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   235
apply (erule take_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   236
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   237
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   238
lemma basis_fun_lemma1:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   239
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   240
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   241
  shows "chain (\<lambda>i. lub (f ` take i ` rep x))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   242
 apply (rule chainI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   243
 apply (rule is_lub_thelub0)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   244
  apply (rule basis_fun_lemma0, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   245
 apply (rule is_ubI, clarsimp, rename_tac a)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   246
 apply (rule sq_le.trans_less [OF f_mono [OF take_chain]])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   247
 apply (rule is_ub_thelub0)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   248
  apply (rule basis_fun_lemma0, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   249
 apply simp
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   250
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   251
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   252
lemma basis_fun_lemma2:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   253
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   254
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   255
  shows "f ` rep x <<| (\<Squnion>i. lub (f ` take i ` rep x))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   256
 apply (rule is_lubI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   257
 apply (rule ub_imageI, rename_tac a)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   258
  apply (cut_tac a=a in take_covers, erule exE, rename_tac i)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   259
  apply (erule subst)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   260
  apply (rule rev_trans_less)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   261
   apply (rule_tac x=i in is_ub_thelub)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   262
   apply (rule basis_fun_lemma1, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   263
  apply (rule is_ub_thelub0)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   264
   apply (rule basis_fun_lemma0, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   265
  apply simp
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   266
 apply (rule is_lub_thelub [OF _ ub_rangeI])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   267
  apply (rule basis_fun_lemma1, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   268
 apply (rule is_lub_thelub0)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   269
  apply (rule basis_fun_lemma0, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   270
 apply (rule is_ubI, clarsimp, rename_tac a)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   271
 apply (rule sq_le.trans_less [OF f_mono [OF take_less]])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   272
 apply (erule (1) ub_imageD)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   273
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   274
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   275
lemma basis_fun_lemma:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   276
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   277
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   278
  shows "\<exists>u. f ` rep x <<| u"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   279
by (rule exI, rule basis_fun_lemma2, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   280
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   281
lemma rep_mono: "x \<sqsubseteq> y \<Longrightarrow> rep x \<subseteq> rep y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   282
apply (frule bin_chain)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   283
apply (drule rep_contlub)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   284
apply (simp only: thelubI [OF lub_bin_chain])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   285
apply (rule subsetI, rule UN_I [where a=0], simp_all)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   286
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   287
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   288
lemma less_def: "x \<sqsubseteq> y \<longleftrightarrow> rep x \<subseteq> rep y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   289
by (rule iffI [OF rep_mono subset_repD])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   290
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   291
lemma rep_eq: "rep x = {a. principal a \<sqsubseteq> x}"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   292
unfolding less_def rep_principal
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   293
apply safe
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   294
apply (erule (1) idealD3 [OF ideal_rep])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   295
apply (erule subsetD, simp add: r_refl)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   296
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   297
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   298
lemma mem_rep_iff_principal_less: "a \<in> rep x \<longleftrightarrow> principal a \<sqsubseteq> x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   299
by (simp add: rep_eq)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   300
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   301
lemma principal_less_iff_mem_rep: "principal a \<sqsubseteq> x \<longleftrightarrow> a \<in> rep x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   302
by (simp add: rep_eq)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   303
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   304
lemma principal_less_iff [simp]: "principal a \<sqsubseteq> principal b \<longleftrightarrow> a \<preceq> b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   305
by (simp add: principal_less_iff_mem_rep rep_principal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   306
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   307
lemma principal_eq_iff: "principal a = principal b \<longleftrightarrow> a \<preceq> b \<and> b \<preceq> a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   308
unfolding po_eq_conv [where 'a='b] principal_less_iff ..
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   309
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   310
lemma repD: "a \<in> rep x \<Longrightarrow> principal a \<sqsubseteq> x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   311
by (simp add: rep_eq)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   312
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   313
lemma principal_mono: "a \<preceq> b \<Longrightarrow> principal a \<sqsubseteq> principal b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   314
by (simp only: principal_less_iff)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   315
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   316
lemma lessI: "(\<And>a. principal a \<sqsubseteq> x \<Longrightarrow> principal a \<sqsubseteq> u) \<Longrightarrow> x \<sqsubseteq> u"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   317
unfolding principal_less_iff_mem_rep
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   318
by (simp add: less_def subset_eq)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   319
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   320
lemma lub_principal_rep: "principal ` rep x <<| x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   321
apply (rule is_lubI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   322
apply (rule ub_imageI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   323
apply (erule repD)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   324
apply (subst less_def)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   325
apply (rule subsetI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   326
apply (drule (1) ub_imageD)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   327
apply (simp add: rep_eq)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   328
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   329
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   330
definition
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   331
  basis_fun :: "('a::type \<Rightarrow> 'c::cpo) \<Rightarrow> 'b \<rightarrow> 'c" where
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   332
  "basis_fun = (\<lambda>f. (\<Lambda> x. lub (f ` rep x)))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   333
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   334
lemma basis_fun_beta:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   335
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   336
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   337
  shows "basis_fun f\<cdot>x = lub (f ` rep x)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   338
unfolding basis_fun_def
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   339
proof (rule beta_cfun)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   340
  have lub: "\<And>x. \<exists>u. f ` rep x <<| u"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   341
    using f_mono by (rule basis_fun_lemma)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   342
  show cont: "cont (\<lambda>x. lub (f ` rep x))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   343
    apply (rule contI2)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   344
     apply (rule monofunI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   345
     apply (rule is_lub_thelub0 [OF lub ub_imageI])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   346
     apply (rule is_ub_thelub0 [OF lub imageI])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   347
     apply (erule (1) subsetD [OF rep_mono])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   348
    apply (rule is_lub_thelub0 [OF lub ub_imageI])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   349
    apply (simp add: rep_contlub, clarify)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   350
    apply (erule rev_trans_less [OF is_ub_thelub])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   351
    apply (erule is_ub_thelub0 [OF lub imageI])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   352
    done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   353
qed
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   354
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   355
lemma basis_fun_principal:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   356
  fixes f :: "'a::type \<Rightarrow> 'c::cpo"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   357
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   358
  shows "basis_fun f\<cdot>(principal a) = f a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   359
apply (subst basis_fun_beta, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   360
apply (subst rep_principal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   361
apply (rule lub_image_principal, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   362
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   363
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   364
lemma basis_fun_mono:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   365
  assumes f_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> f a \<sqsubseteq> f b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   366
  assumes g_mono: "\<And>a b. a \<preceq> b \<Longrightarrow> g a \<sqsubseteq> g b"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   367
  assumes less: "\<And>a. f a \<sqsubseteq> g a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   368
  shows "basis_fun f \<sqsubseteq> basis_fun g"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   369
 apply (rule less_cfun_ext)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   370
 apply (simp only: basis_fun_beta f_mono g_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   371
 apply (rule is_lub_thelub0)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   372
  apply (rule basis_fun_lemma, erule f_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   373
 apply (rule ub_imageI, rename_tac a)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   374
 apply (rule sq_le.trans_less [OF less])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   375
 apply (rule is_ub_thelub0)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   376
  apply (rule basis_fun_lemma, erule g_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   377
 apply (erule imageI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   378
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   379
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   380
lemma compact_principal [simp]: "compact (principal a)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   381
by (rule compactI2, simp add: principal_less_iff_mem_rep rep_contlub)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   382
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   383
definition
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   384
  completion_approx :: "nat \<Rightarrow> 'b \<rightarrow> 'b" where
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   385
  "completion_approx = (\<lambda>i. basis_fun (\<lambda>a. principal (take i a)))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   386
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   387
lemma completion_approx_beta:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   388
  "completion_approx i\<cdot>x = (\<Squnion>a\<in>rep x. principal (take i a))"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   389
unfolding completion_approx_def
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   390
by (simp add: basis_fun_beta principal_mono take_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   391
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   392
lemma completion_approx_principal:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   393
  "completion_approx i\<cdot>(principal a) = principal (take i a)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   394
unfolding completion_approx_def
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   395
by (simp add: basis_fun_principal principal_mono take_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   396
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   397
lemma chain_completion_approx: "chain completion_approx"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   398
unfolding completion_approx_def
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   399
apply (rule chainI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   400
apply (rule basis_fun_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   401
apply (erule principal_mono [OF take_mono])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   402
apply (erule principal_mono [OF take_mono])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   403
apply (rule principal_mono [OF take_chain])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   404
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   405
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   406
lemma lub_completion_approx: "(\<Squnion>i. completion_approx i\<cdot>x) = x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   407
unfolding completion_approx_beta
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   408
 apply (subst image_image [where f=principal, symmetric])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   409
 apply (rule unique_lub [OF _ lub_principal_rep])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   410
 apply (rule basis_fun_lemma2, erule principal_mono)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   411
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   412
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   413
lemma completion_approx_eq_principal:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   414
  "\<exists>a\<in>rep x. completion_approx i\<cdot>x = principal (take i a)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   415
unfolding completion_approx_beta
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   416
 apply (subst image_image [where f=principal, symmetric])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   417
 apply (subgoal_tac "finite (principal ` take i ` rep x)")
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   418
  apply (subgoal_tac "directed (principal ` take i ` rep x)")
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   419
   apply (drule (1) lub_finite_directed_in_self, fast)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   420
  apply (subst image_image)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   421
  apply (rule directed_image_ideal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   422
   apply (rule ideal_rep)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   423
  apply (erule principal_mono [OF take_mono])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   424
 apply (rule finite_imageI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   425
 apply (rule finite_take_rep)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   426
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   427
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   428
lemma completion_approx_idem:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   429
  "completion_approx i\<cdot>(completion_approx i\<cdot>x) = completion_approx i\<cdot>x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   430
using completion_approx_eq_principal [where i=i and x=x]
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   431
by (auto simp add: completion_approx_principal take_take)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   432
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   433
lemma finite_fixes_completion_approx:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   434
  "finite {x. completion_approx i\<cdot>x = x}" (is "finite ?S")
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   435
apply (subgoal_tac "?S \<subseteq> principal ` range (take i)")
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   436
apply (erule finite_subset)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   437
apply (rule finite_imageI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   438
apply (rule finite_range_take)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   439
apply (clarify, erule subst)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   440
apply (cut_tac x=x and i=i in completion_approx_eq_principal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   441
apply fast
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   442
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   443
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   444
lemma principal_induct:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   445
  assumes adm: "adm P"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   446
  assumes P: "\<And>a. P (principal a)"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   447
  shows "P x"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   448
 apply (subgoal_tac "P (\<Squnion>i. completion_approx i\<cdot>x)")
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   449
 apply (simp add: lub_completion_approx)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   450
 apply (rule admD [OF adm])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   451
  apply (simp add: chain_completion_approx)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   452
 apply (cut_tac x=x and i=i in completion_approx_eq_principal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   453
 apply (clarify, simp add: P)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   454
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   455
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   456
lemma principal_induct2:
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   457
  "\<lbrakk>\<And>y. adm (\<lambda>x. P x y); \<And>x. adm (\<lambda>y. P x y);
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   458
    \<And>a b. P (principal a) (principal b)\<rbrakk> \<Longrightarrow> P x y"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   459
apply (rule_tac x=y in spec)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   460
apply (rule_tac x=x in principal_induct, simp)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   461
apply (rule allI, rename_tac y)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   462
apply (rule_tac x=y in principal_induct, simp)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   463
apply simp
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   464
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   465
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   466
lemma compact_imp_principal: "compact x \<Longrightarrow> \<exists>a. x = principal a"
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   467
apply (drule adm_compact_neq [OF _ cont_id])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   468
apply (drule admD2 [where Y="\<lambda>n. completion_approx n\<cdot>x"])
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   469
apply (simp add: chain_completion_approx)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   470
apply (simp add: lub_completion_approx)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   471
apply (erule exE, erule ssubst)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   472
apply (cut_tac i=i and x=x in completion_approx_eq_principal)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   473
apply (clarify, erule exI)
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   474
done
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   475
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   476
end
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   477
62171da527d6 split Completion.thy from CompactBasis.thy
huffman
parents:
diff changeset
   478
end