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