author | wenzelm |
Tue, 05 Dec 2006 22:14:41 +0100 | |
changeset 21657 | 2a0c0fa4a3c4 |
parent 21404 | eb85850d3eb7 |
child 21896 | 9a7949815a84 |
permissions | -rw-r--r-- |
14551 | 1 |
(* |
14706 | 2 |
Title: HOL/Algebra/Lattice.thy |
14551 | 3 |
Id: $Id$ |
4 |
Author: Clemens Ballarin, started 7 November 2003 |
|
5 |
Copyright: Clemens Ballarin |
|
6 |
*) |
|
7 |
||
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
19984
diff
changeset
|
8 |
theory Lattice imports Main begin |
14551 | 9 |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
19984
diff
changeset
|
10 |
|
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
19984
diff
changeset
|
11 |
section {* Orders and Lattices *} |
14751
0d7850e27fed
Change of theory hierarchy: Group is now based in Lattice.
ballarin
parents:
14706
diff
changeset
|
12 |
|
0d7850e27fed
Change of theory hierarchy: Group is now based in Lattice.
ballarin
parents:
14706
diff
changeset
|
13 |
text {* Object with a carrier set. *} |
0d7850e27fed
Change of theory hierarchy: Group is now based in Lattice.
ballarin
parents:
14706
diff
changeset
|
14 |
|
0d7850e27fed
Change of theory hierarchy: Group is now based in Lattice.
ballarin
parents:
14706
diff
changeset
|
15 |
record 'a partial_object = |
0d7850e27fed
Change of theory hierarchy: Group is now based in Lattice.
ballarin
parents:
14706
diff
changeset
|
16 |
carrier :: "'a set" |
14551 | 17 |
|
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
19984
diff
changeset
|
18 |
|
14551 | 19 |
subsection {* Partial Orders *} |
20 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
21 |
text {* Locale @{text order_syntax} is required since we want to refer |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
22 |
to definitions (and their derived theorems) outside of @{text partial_order}. |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
23 |
*} |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
24 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
25 |
locale order_syntax = |
21049 | 26 |
fixes L :: "'a set" and le :: "['a, 'a] => bool" (infix "\<sqsubseteq>" 50) |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
27 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
28 |
text {* Note that the type constraints above are necessary, because the |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
29 |
definition command cannot specialise the types. *} |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
30 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
31 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
32 |
less (infixl "\<sqsubset>" 50) where "x \<sqsubset> y == x \<sqsubseteq> y & x ~= y" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
33 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
34 |
text {* Upper and lower bounds of a set. *} |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
35 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
36 |
definition (in order_syntax) |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
37 |
Upper where |
21049 | 38 |
"Upper A == {u. (ALL x. x \<in> A \<inter> L --> x \<sqsubseteq> u)} \<inter> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
39 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
40 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
41 |
Lower :: "'a set => 'a set" where |
21049 | 42 |
"Lower A == {l. (ALL x. x \<in> A \<inter> L --> l \<sqsubseteq> x)} \<inter> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
43 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
44 |
text {* Least and greatest, as predicate. *} |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
45 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
46 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
47 |
least :: "['a, 'a set] => bool" where |
21049 | 48 |
"least l A == A \<subseteq> L & l \<in> A & (ALL x : A. l \<sqsubseteq> x)" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
49 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
50 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
51 |
greatest :: "['a, 'a set] => bool" where |
21049 | 52 |
"greatest g A == A \<subseteq> L & g \<in> A & (ALL x : A. x \<sqsubseteq> g)" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
53 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
54 |
text {* Supremum and infimum *} |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
55 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
56 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
57 |
sup :: "'a set => 'a" ("\<Squnion>_" [90] 90) where |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
58 |
"\<Squnion>A == THE x. least x (Upper A)" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
59 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
60 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
61 |
inf :: "'a set => 'a" ("\<Sqinter>_" [90] 90) where |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
62 |
"\<Sqinter>A == THE x. greatest x (Lower A)" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
63 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
64 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
65 |
join :: "['a, 'a] => 'a" (infixl "\<squnion>" 65) where |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
66 |
"x \<squnion> y == sup {x, y}" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
67 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
68 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
69 |
meet :: "['a, 'a] => 'a" (infixl "\<sqinter>" 70) where |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
70 |
"x \<sqinter> y == inf {x, y}" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
71 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
72 |
locale partial_order = order_syntax + |
14551 | 73 |
assumes refl [intro, simp]: |
21049 | 74 |
"x \<in> L ==> x \<sqsubseteq> x" |
14551 | 75 |
and anti_sym [intro]: |
21049 | 76 |
"[| x \<sqsubseteq> y; y \<sqsubseteq> x; x \<in> L; y \<in> L |] ==> x = y" |
14551 | 77 |
and trans [trans]: |
78 |
"[| x \<sqsubseteq> y; y \<sqsubseteq> z; |
|
21049 | 79 |
x \<in> L; y \<in> L; z \<in> L |] ==> x \<sqsubseteq> z" |
14551 | 80 |
|
14651 | 81 |
|
82 |
subsubsection {* Upper *} |
|
14551 | 83 |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
84 |
lemma (in order_syntax) Upper_closed [intro, simp]: |
21049 | 85 |
"Upper A \<subseteq> L" |
14551 | 86 |
by (unfold Upper_def) clarify |
87 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
88 |
lemma (in order_syntax) UpperD [dest]: |
21049 | 89 |
"[| u \<in> Upper A; x \<in> A; A \<subseteq> L |] ==> x \<sqsubseteq> u" |
14693 | 90 |
by (unfold Upper_def) blast |
14551 | 91 |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
92 |
lemma (in order_syntax) Upper_memI: |
21049 | 93 |
"[| !! y. y \<in> A ==> y \<sqsubseteq> x; x \<in> L |] ==> x \<in> Upper A" |
14693 | 94 |
by (unfold Upper_def) blast |
14551 | 95 |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
96 |
lemma (in order_syntax) Upper_antimono: |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
97 |
"A \<subseteq> B ==> Upper B \<subseteq> Upper A" |
14551 | 98 |
by (unfold Upper_def) blast |
99 |
||
14651 | 100 |
|
101 |
subsubsection {* Lower *} |
|
14551 | 102 |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
103 |
lemma (in order_syntax) Lower_closed [intro, simp]: |
21049 | 104 |
"Lower A \<subseteq> L" |
14551 | 105 |
by (unfold Lower_def) clarify |
106 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
107 |
lemma (in order_syntax) LowerD [dest]: |
21049 | 108 |
"[| l \<in> Lower A; x \<in> A; A \<subseteq> L |] ==> l \<sqsubseteq> x" |
14693 | 109 |
by (unfold Lower_def) blast |
14551 | 110 |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
111 |
lemma (in order_syntax) Lower_memI: |
21049 | 112 |
"[| !! y. y \<in> A ==> x \<sqsubseteq> y; x \<in> L |] ==> x \<in> Lower A" |
14693 | 113 |
by (unfold Lower_def) blast |
14551 | 114 |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
115 |
lemma (in order_syntax) Lower_antimono: |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
116 |
"A \<subseteq> B ==> Lower B \<subseteq> Lower A" |
14551 | 117 |
by (unfold Lower_def) blast |
118 |
||
14651 | 119 |
|
120 |
subsubsection {* least *} |
|
14551 | 121 |
|
21049 | 122 |
lemma (in order_syntax) least_closed [intro, simp]: |
123 |
"least l A ==> l \<in> L" |
|
14551 | 124 |
by (unfold least_def) fast |
125 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
126 |
lemma (in order_syntax) least_mem: |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
127 |
"least l A ==> l \<in> A" |
14551 | 128 |
by (unfold least_def) fast |
129 |
||
130 |
lemma (in partial_order) least_unique: |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
131 |
"[| least x A; least y A |] ==> x = y" |
14551 | 132 |
by (unfold least_def) blast |
133 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
134 |
lemma (in order_syntax) least_le: |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
135 |
"[| least x A; a \<in> A |] ==> x \<sqsubseteq> a" |
14551 | 136 |
by (unfold least_def) fast |
137 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
138 |
lemma (in order_syntax) least_UpperI: |
14551 | 139 |
assumes above: "!! x. x \<in> A ==> x \<sqsubseteq> s" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
140 |
and below: "!! y. y \<in> Upper A ==> s \<sqsubseteq> y" |
21049 | 141 |
and L: "A \<subseteq> L" "s \<in> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
142 |
shows "least s (Upper A)" |
14693 | 143 |
proof - |
21049 | 144 |
have "Upper A \<subseteq> L" by simp |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
145 |
moreover from above L have "s \<in> Upper A" by (simp add: Upper_def) |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
146 |
moreover from below have "ALL x : Upper A. s \<sqsubseteq> x" by fast |
14693 | 147 |
ultimately show ?thesis by (simp add: least_def) |
14551 | 148 |
qed |
149 |
||
14651 | 150 |
|
151 |
subsubsection {* greatest *} |
|
14551 | 152 |
|
21049 | 153 |
lemma (in order_syntax) greatest_closed [intro, simp]: |
154 |
"greatest l A ==> l \<in> L" |
|
14551 | 155 |
by (unfold greatest_def) fast |
156 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
157 |
lemma (in order_syntax) greatest_mem: |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
158 |
"greatest l A ==> l \<in> A" |
14551 | 159 |
by (unfold greatest_def) fast |
160 |
||
161 |
lemma (in partial_order) greatest_unique: |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
162 |
"[| greatest x A; greatest y A |] ==> x = y" |
14551 | 163 |
by (unfold greatest_def) blast |
164 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
165 |
lemma (in order_syntax) greatest_le: |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
166 |
"[| greatest x A; a \<in> A |] ==> a \<sqsubseteq> x" |
14551 | 167 |
by (unfold greatest_def) fast |
168 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
169 |
lemma (in order_syntax) greatest_LowerI: |
14551 | 170 |
assumes below: "!! x. x \<in> A ==> i \<sqsubseteq> x" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
171 |
and above: "!! y. y \<in> Lower A ==> y \<sqsubseteq> i" |
21049 | 172 |
and L: "A \<subseteq> L" "i \<in> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
173 |
shows "greatest i (Lower A)" |
14693 | 174 |
proof - |
21049 | 175 |
have "Lower A \<subseteq> L" by simp |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
176 |
moreover from below L have "i \<in> Lower A" by (simp add: Lower_def) |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
177 |
moreover from above have "ALL x : Lower A. x \<sqsubseteq> i" by fast |
14693 | 178 |
ultimately show ?thesis by (simp add: greatest_def) |
14551 | 179 |
qed |
180 |
||
14693 | 181 |
|
14551 | 182 |
subsection {* Lattices *} |
183 |
||
184 |
locale lattice = partial_order + |
|
185 |
assumes sup_of_two_exists: |
|
21049 | 186 |
"[| x \<in> L; y \<in> L |] ==> EX s. order_syntax.least L le s (order_syntax.Upper L le {x, y})" |
14551 | 187 |
and inf_of_two_exists: |
21049 | 188 |
"[| x \<in> L; y \<in> L |] ==> EX s. order_syntax.greatest L le s (order_syntax.Lower L le {x, y})" |
14551 | 189 |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
190 |
lemma (in order_syntax) least_Upper_above: |
21049 | 191 |
"[| least s (Upper A); x \<in> A; A \<subseteq> L |] ==> x \<sqsubseteq> s" |
14551 | 192 |
by (unfold least_def) blast |
193 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
194 |
lemma (in order_syntax) greatest_Lower_above: |
21049 | 195 |
"[| greatest i (Lower A); x \<in> A; A \<subseteq> L |] ==> i \<sqsubseteq> x" |
14551 | 196 |
by (unfold greatest_def) blast |
197 |
||
14666 | 198 |
|
14551 | 199 |
subsubsection {* Supremum *} |
200 |
||
201 |
lemma (in lattice) joinI: |
|
21049 | 202 |
"[| !!l. least l (Upper {x, y}) ==> P l; x \<in> L; y \<in> L |] |
14551 | 203 |
==> P (x \<squnion> y)" |
204 |
proof (unfold join_def sup_def) |
|
21049 | 205 |
assume L: "x \<in> L" "y \<in> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
206 |
and P: "!!l. least l (Upper {x, y}) ==> P l" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
207 |
with sup_of_two_exists obtain s where "least s (Upper {x, y})" by fast |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
208 |
with L show "P (THE l. least l (Upper {x, y}))" |
14693 | 209 |
by (fast intro: theI2 least_unique P) |
14551 | 210 |
qed |
211 |
||
212 |
lemma (in lattice) join_closed [simp]: |
|
21049 | 213 |
"[| x \<in> L; y \<in> L |] ==> x \<squnion> y \<in> L" |
214 |
by (rule joinI) (rule least_closed) |
|
14551 | 215 |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
216 |
lemma (in partial_order) sup_of_singletonI: (* only reflexivity needed ? *) |
21049 | 217 |
"x \<in> L ==> least x (Upper {x})" |
14551 | 218 |
by (rule least_UpperI) fast+ |
219 |
||
220 |
lemma (in partial_order) sup_of_singleton [simp]: |
|
21049 | 221 |
"x \<in> L ==> \<Squnion>{x} = x" |
14551 | 222 |
by (unfold sup_def) (blast intro: least_unique least_UpperI sup_of_singletonI) |
223 |
||
14666 | 224 |
|
225 |
text {* Condition on @{text A}: supremum exists. *} |
|
14551 | 226 |
|
227 |
lemma (in lattice) sup_insertI: |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
228 |
"[| !!s. least s (Upper (insert x A)) ==> P s; |
21049 | 229 |
least a (Upper A); x \<in> L; A \<subseteq> L |] |
14693 | 230 |
==> P (\<Squnion>(insert x A))" |
14551 | 231 |
proof (unfold sup_def) |
21049 | 232 |
assume L: "x \<in> L" "A \<subseteq> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
233 |
and P: "!!l. least l (Upper (insert x A)) ==> P l" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
234 |
and least_a: "least a (Upper A)" |
21049 | 235 |
from least_a have La: "a \<in> L" by simp |
14551 | 236 |
from L sup_of_two_exists least_a |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
237 |
obtain s where least_s: "least s (Upper {a, x})" by blast |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
238 |
show "P (THE l. least l (Upper (insert x A)))" |
14693 | 239 |
proof (rule theI2) |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
240 |
show "least s (Upper (insert x A))" |
14551 | 241 |
proof (rule least_UpperI) |
242 |
fix z |
|
14693 | 243 |
assume "z \<in> insert x A" |
244 |
then show "z \<sqsubseteq> s" |
|
245 |
proof |
|
246 |
assume "z = x" then show ?thesis |
|
247 |
by (simp add: least_Upper_above [OF least_s] L La) |
|
248 |
next |
|
249 |
assume "z \<in> A" |
|
250 |
with L least_s least_a show ?thesis |
|
251 |
by (rule_tac trans [where y = a]) (auto dest: least_Upper_above) |
|
252 |
qed |
|
253 |
next |
|
254 |
fix y |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
255 |
assume y: "y \<in> Upper (insert x A)" |
14693 | 256 |
show "s \<sqsubseteq> y" |
257 |
proof (rule least_le [OF least_s], rule Upper_memI) |
|
258 |
fix z |
|
259 |
assume z: "z \<in> {a, x}" |
|
260 |
then show "z \<sqsubseteq> y" |
|
261 |
proof |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
262 |
have y': "y \<in> Upper A" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
263 |
apply (rule subsetD [where A = "Upper (insert x A)"]) |
14693 | 264 |
apply (rule Upper_antimono) apply clarify apply assumption |
265 |
done |
|
266 |
assume "z = a" |
|
267 |
with y' least_a show ?thesis by (fast dest: least_le) |
|
268 |
next |
|
269 |
assume "z \<in> {x}" (* FIXME "z = x"; declare specific elim rule for "insert x {}" (!?) *) |
|
270 |
with y L show ?thesis by blast |
|
271 |
qed |
|
272 |
qed (rule Upper_closed [THEN subsetD]) |
|
273 |
next |
|
21049 | 274 |
from L show "insert x A \<subseteq> L" by simp |
275 |
from least_s show "s \<in> L" by simp |
|
14551 | 276 |
qed |
277 |
next |
|
278 |
fix l |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
279 |
assume least_l: "least l (Upper (insert x A))" |
14551 | 280 |
show "l = s" |
281 |
proof (rule least_unique) |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
282 |
show "least s (Upper (insert x A))" |
14551 | 283 |
proof (rule least_UpperI) |
14693 | 284 |
fix z |
285 |
assume "z \<in> insert x A" |
|
286 |
then show "z \<sqsubseteq> s" |
|
287 |
proof |
|
288 |
assume "z = x" then show ?thesis |
|
289 |
by (simp add: least_Upper_above [OF least_s] L La) |
|
290 |
next |
|
291 |
assume "z \<in> A" |
|
292 |
with L least_s least_a show ?thesis |
|
293 |
by (rule_tac trans [where y = a]) (auto dest: least_Upper_above) |
|
14551 | 294 |
qed |
295 |
next |
|
14693 | 296 |
fix y |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
297 |
assume y: "y \<in> Upper (insert x A)" |
14693 | 298 |
show "s \<sqsubseteq> y" |
299 |
proof (rule least_le [OF least_s], rule Upper_memI) |
|
300 |
fix z |
|
301 |
assume z: "z \<in> {a, x}" |
|
302 |
then show "z \<sqsubseteq> y" |
|
303 |
proof |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
304 |
have y': "y \<in> Upper A" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
305 |
apply (rule subsetD [where A = "Upper (insert x A)"]) |
14693 | 306 |
apply (rule Upper_antimono) apply clarify apply assumption |
307 |
done |
|
308 |
assume "z = a" |
|
309 |
with y' least_a show ?thesis by (fast dest: least_le) |
|
310 |
next |
|
311 |
assume "z \<in> {x}" |
|
312 |
with y L show ?thesis by blast |
|
313 |
qed |
|
314 |
qed (rule Upper_closed [THEN subsetD]) |
|
14551 | 315 |
next |
21049 | 316 |
from L show "insert x A \<subseteq> L" by simp |
317 |
from least_s show "s \<in> L" by simp |
|
14551 | 318 |
qed |
319 |
qed |
|
320 |
qed |
|
321 |
qed |
|
322 |
||
323 |
lemma (in lattice) finite_sup_least: |
|
21049 | 324 |
"[| finite A; A \<subseteq> L; A ~= {} |] ==> least (\<Squnion>A) (Upper A)" |
14551 | 325 |
proof (induct set: Finites) |
14693 | 326 |
case empty |
327 |
then show ?case by simp |
|
14551 | 328 |
next |
15328 | 329 |
case (insert x A) |
14551 | 330 |
show ?case |
331 |
proof (cases "A = {}") |
|
332 |
case True |
|
333 |
with insert show ?thesis by (simp add: sup_of_singletonI) |
|
334 |
next |
|
335 |
case False |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
336 |
with insert have "least (\<Squnion>A) (Upper A)" by simp |
14693 | 337 |
with _ show ?thesis |
338 |
by (rule sup_insertI) (simp_all add: insert [simplified]) |
|
14551 | 339 |
qed |
340 |
qed |
|
341 |
||
342 |
lemma (in lattice) finite_sup_insertI: |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
343 |
assumes P: "!!l. least l (Upper (insert x A)) ==> P l" |
21049 | 344 |
and xA: "finite A" "x \<in> L" "A \<subseteq> L" |
14551 | 345 |
shows "P (\<Squnion> (insert x A))" |
346 |
proof (cases "A = {}") |
|
347 |
case True with P and xA show ?thesis |
|
348 |
by (simp add: sup_of_singletonI) |
|
349 |
next |
|
350 |
case False with P and xA show ?thesis |
|
351 |
by (simp add: sup_insertI finite_sup_least) |
|
352 |
qed |
|
353 |
||
354 |
lemma (in lattice) finite_sup_closed: |
|
21049 | 355 |
"[| finite A; A \<subseteq> L; A ~= {} |] ==> \<Squnion>A \<in> L" |
14551 | 356 |
proof (induct set: Finites) |
357 |
case empty then show ?case by simp |
|
358 |
next |
|
15328 | 359 |
case insert then show ?case |
14693 | 360 |
by - (rule finite_sup_insertI, simp_all) |
14551 | 361 |
qed |
362 |
||
363 |
lemma (in lattice) join_left: |
|
21049 | 364 |
"[| x \<in> L; y \<in> L |] ==> x \<sqsubseteq> x \<squnion> y" |
14693 | 365 |
by (rule joinI [folded join_def]) (blast dest: least_mem) |
14551 | 366 |
|
367 |
lemma (in lattice) join_right: |
|
21049 | 368 |
"[| x \<in> L; y \<in> L |] ==> y \<sqsubseteq> x \<squnion> y" |
14693 | 369 |
by (rule joinI [folded join_def]) (blast dest: least_mem) |
14551 | 370 |
|
371 |
lemma (in lattice) sup_of_two_least: |
|
21049 | 372 |
"[| x \<in> L; y \<in> L |] ==> least (\<Squnion>{x, y}) (Upper {x, y})" |
14551 | 373 |
proof (unfold sup_def) |
21049 | 374 |
assume L: "x \<in> L" "y \<in> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
375 |
with sup_of_two_exists obtain s where "least s (Upper {x, y})" by fast |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
376 |
with L show "least (THE xa. least xa (Upper {x, y})) (Upper {x, y})" |
14551 | 377 |
by (fast intro: theI2 least_unique) (* blast fails *) |
378 |
qed |
|
379 |
||
380 |
lemma (in lattice) join_le: |
|
14693 | 381 |
assumes sub: "x \<sqsubseteq> z" "y \<sqsubseteq> z" |
21049 | 382 |
and L: "x \<in> L" "y \<in> L" "z \<in> L" |
14551 | 383 |
shows "x \<squnion> y \<sqsubseteq> z" |
384 |
proof (rule joinI) |
|
385 |
fix s |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
386 |
assume "least s (Upper {x, y})" |
14551 | 387 |
with sub L show "s \<sqsubseteq> z" by (fast elim: least_le intro: Upper_memI) |
388 |
qed |
|
14693 | 389 |
|
14551 | 390 |
lemma (in lattice) join_assoc_lemma: |
21049 | 391 |
assumes L: "x \<in> L" "y \<in> L" "z \<in> L" |
14693 | 392 |
shows "x \<squnion> (y \<squnion> z) = \<Squnion>{x, y, z}" |
14551 | 393 |
proof (rule finite_sup_insertI) |
14651 | 394 |
-- {* The textbook argument in Jacobson I, p 457 *} |
14551 | 395 |
fix s |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
396 |
assume sup: "least s (Upper {x, y, z})" |
14551 | 397 |
show "x \<squnion> (y \<squnion> z) = s" |
398 |
proof (rule anti_sym) |
|
399 |
from sup L show "x \<squnion> (y \<squnion> z) \<sqsubseteq> s" |
|
400 |
by (fastsimp intro!: join_le elim: least_Upper_above) |
|
401 |
next |
|
402 |
from sup L show "s \<sqsubseteq> x \<squnion> (y \<squnion> z)" |
|
403 |
by (erule_tac least_le) |
|
404 |
(blast intro!: Upper_memI intro: trans join_left join_right join_closed) |
|
21049 | 405 |
qed (simp_all add: L least_closed [OF sup]) |
14551 | 406 |
qed (simp_all add: L) |
407 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
408 |
lemma (in order_syntax) join_comm: |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
409 |
"x \<squnion> y = y \<squnion> x" |
14551 | 410 |
by (unfold join_def) (simp add: insert_commute) |
411 |
||
412 |
lemma (in lattice) join_assoc: |
|
21049 | 413 |
assumes L: "x \<in> L" "y \<in> L" "z \<in> L" |
14551 | 414 |
shows "(x \<squnion> y) \<squnion> z = x \<squnion> (y \<squnion> z)" |
415 |
proof - |
|
416 |
have "(x \<squnion> y) \<squnion> z = z \<squnion> (x \<squnion> y)" by (simp only: join_comm) |
|
14693 | 417 |
also from L have "... = \<Squnion>{z, x, y}" by (simp add: join_assoc_lemma) |
418 |
also from L have "... = \<Squnion>{x, y, z}" by (simp add: insert_commute) |
|
14551 | 419 |
also from L have "... = x \<squnion> (y \<squnion> z)" by (simp add: join_assoc_lemma) |
420 |
finally show ?thesis . |
|
421 |
qed |
|
422 |
||
14693 | 423 |
|
14551 | 424 |
subsubsection {* Infimum *} |
425 |
||
426 |
lemma (in lattice) meetI: |
|
21049 | 427 |
"[| !!i. greatest i (Lower {x, y}) ==> P i; x \<in> L; y \<in> L |] |
14551 | 428 |
==> P (x \<sqinter> y)" |
429 |
proof (unfold meet_def inf_def) |
|
21049 | 430 |
assume L: "x \<in> L" "y \<in> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
431 |
and P: "!!g. greatest g (Lower {x, y}) ==> P g" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
432 |
with inf_of_two_exists obtain i where "greatest i (Lower {x, y})" by fast |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
433 |
with L show "P (THE g. greatest g (Lower {x, y}))" |
14551 | 434 |
by (fast intro: theI2 greatest_unique P) |
435 |
qed |
|
436 |
||
437 |
lemma (in lattice) meet_closed [simp]: |
|
21049 | 438 |
"[| x \<in> L; y \<in> L |] ==> x \<sqinter> y \<in> L" |
439 |
by (rule meetI) (rule greatest_closed) |
|
14551 | 440 |
|
14651 | 441 |
lemma (in partial_order) inf_of_singletonI: (* only reflexivity needed ? *) |
21049 | 442 |
"x \<in> L ==> greatest x (Lower {x})" |
14551 | 443 |
by (rule greatest_LowerI) fast+ |
444 |
||
445 |
lemma (in partial_order) inf_of_singleton [simp]: |
|
21049 | 446 |
"x \<in> L ==> \<Sqinter> {x} = x" |
14551 | 447 |
by (unfold inf_def) (blast intro: greatest_unique greatest_LowerI inf_of_singletonI) |
448 |
||
449 |
text {* Condition on A: infimum exists. *} |
|
450 |
||
451 |
lemma (in lattice) inf_insertI: |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
452 |
"[| !!i. greatest i (Lower (insert x A)) ==> P i; |
21049 | 453 |
greatest a (Lower A); x \<in> L; A \<subseteq> L |] |
14693 | 454 |
==> P (\<Sqinter>(insert x A))" |
14551 | 455 |
proof (unfold inf_def) |
21049 | 456 |
assume L: "x \<in> L" "A \<subseteq> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
457 |
and P: "!!g. greatest g (Lower (insert x A)) ==> P g" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
458 |
and greatest_a: "greatest a (Lower A)" |
21049 | 459 |
from greatest_a have La: "a \<in> L" by simp |
14551 | 460 |
from L inf_of_two_exists greatest_a |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
461 |
obtain i where greatest_i: "greatest i (Lower {a, x})" by blast |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
462 |
show "P (THE g. greatest g (Lower (insert x A)))" |
14693 | 463 |
proof (rule theI2) |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
464 |
show "greatest i (Lower (insert x A))" |
14551 | 465 |
proof (rule greatest_LowerI) |
466 |
fix z |
|
14693 | 467 |
assume "z \<in> insert x A" |
468 |
then show "i \<sqsubseteq> z" |
|
469 |
proof |
|
470 |
assume "z = x" then show ?thesis |
|
471 |
by (simp add: greatest_Lower_above [OF greatest_i] L La) |
|
472 |
next |
|
473 |
assume "z \<in> A" |
|
474 |
with L greatest_i greatest_a show ?thesis |
|
475 |
by (rule_tac trans [where y = a]) (auto dest: greatest_Lower_above) |
|
476 |
qed |
|
477 |
next |
|
478 |
fix y |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
479 |
assume y: "y \<in> Lower (insert x A)" |
14693 | 480 |
show "y \<sqsubseteq> i" |
481 |
proof (rule greatest_le [OF greatest_i], rule Lower_memI) |
|
482 |
fix z |
|
483 |
assume z: "z \<in> {a, x}" |
|
484 |
then show "y \<sqsubseteq> z" |
|
485 |
proof |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
486 |
have y': "y \<in> Lower A" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
487 |
apply (rule subsetD [where A = "Lower (insert x A)"]) |
14693 | 488 |
apply (rule Lower_antimono) apply clarify apply assumption |
489 |
done |
|
490 |
assume "z = a" |
|
491 |
with y' greatest_a show ?thesis by (fast dest: greatest_le) |
|
492 |
next |
|
493 |
assume "z \<in> {x}" |
|
494 |
with y L show ?thesis by blast |
|
495 |
qed |
|
496 |
qed (rule Lower_closed [THEN subsetD]) |
|
497 |
next |
|
21049 | 498 |
from L show "insert x A \<subseteq> L" by simp |
499 |
from greatest_i show "i \<in> L" by simp |
|
14551 | 500 |
qed |
501 |
next |
|
502 |
fix g |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
503 |
assume greatest_g: "greatest g (Lower (insert x A))" |
14551 | 504 |
show "g = i" |
505 |
proof (rule greatest_unique) |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
506 |
show "greatest i (Lower (insert x A))" |
14551 | 507 |
proof (rule greatest_LowerI) |
14693 | 508 |
fix z |
509 |
assume "z \<in> insert x A" |
|
510 |
then show "i \<sqsubseteq> z" |
|
511 |
proof |
|
512 |
assume "z = x" then show ?thesis |
|
513 |
by (simp add: greatest_Lower_above [OF greatest_i] L La) |
|
514 |
next |
|
515 |
assume "z \<in> A" |
|
516 |
with L greatest_i greatest_a show ?thesis |
|
517 |
by (rule_tac trans [where y = a]) (auto dest: greatest_Lower_above) |
|
518 |
qed |
|
14551 | 519 |
next |
14693 | 520 |
fix y |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
521 |
assume y: "y \<in> Lower (insert x A)" |
14693 | 522 |
show "y \<sqsubseteq> i" |
523 |
proof (rule greatest_le [OF greatest_i], rule Lower_memI) |
|
524 |
fix z |
|
525 |
assume z: "z \<in> {a, x}" |
|
526 |
then show "y \<sqsubseteq> z" |
|
527 |
proof |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
528 |
have y': "y \<in> Lower A" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
529 |
apply (rule subsetD [where A = "Lower (insert x A)"]) |
14693 | 530 |
apply (rule Lower_antimono) apply clarify apply assumption |
531 |
done |
|
532 |
assume "z = a" |
|
533 |
with y' greatest_a show ?thesis by (fast dest: greatest_le) |
|
534 |
next |
|
535 |
assume "z \<in> {x}" |
|
536 |
with y L show ?thesis by blast |
|
14551 | 537 |
qed |
14693 | 538 |
qed (rule Lower_closed [THEN subsetD]) |
14551 | 539 |
next |
21049 | 540 |
from L show "insert x A \<subseteq> L" by simp |
541 |
from greatest_i show "i \<in> L" by simp |
|
14551 | 542 |
qed |
543 |
qed |
|
544 |
qed |
|
545 |
qed |
|
546 |
||
547 |
lemma (in lattice) finite_inf_greatest: |
|
21049 | 548 |
"[| finite A; A \<subseteq> L; A ~= {} |] ==> greatest (\<Sqinter>A) (Lower A)" |
14551 | 549 |
proof (induct set: Finites) |
550 |
case empty then show ?case by simp |
|
551 |
next |
|
15328 | 552 |
case (insert x A) |
14551 | 553 |
show ?case |
554 |
proof (cases "A = {}") |
|
555 |
case True |
|
556 |
with insert show ?thesis by (simp add: inf_of_singletonI) |
|
557 |
next |
|
558 |
case False |
|
559 |
from insert show ?thesis |
|
560 |
proof (rule_tac inf_insertI) |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
561 |
from False insert show "greatest (\<Sqinter>A) (Lower A)" by simp |
14551 | 562 |
qed simp_all |
563 |
qed |
|
564 |
qed |
|
565 |
||
566 |
lemma (in lattice) finite_inf_insertI: |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
567 |
assumes P: "!!i. greatest i (Lower (insert x A)) ==> P i" |
21049 | 568 |
and xA: "finite A" "x \<in> L" "A \<subseteq> L" |
14551 | 569 |
shows "P (\<Sqinter> (insert x A))" |
570 |
proof (cases "A = {}") |
|
571 |
case True with P and xA show ?thesis |
|
572 |
by (simp add: inf_of_singletonI) |
|
573 |
next |
|
574 |
case False with P and xA show ?thesis |
|
575 |
by (simp add: inf_insertI finite_inf_greatest) |
|
576 |
qed |
|
577 |
||
578 |
lemma (in lattice) finite_inf_closed: |
|
21049 | 579 |
"[| finite A; A \<subseteq> L; A ~= {} |] ==> \<Sqinter>A \<in> L" |
14551 | 580 |
proof (induct set: Finites) |
581 |
case empty then show ?case by simp |
|
582 |
next |
|
15328 | 583 |
case insert then show ?case |
14551 | 584 |
by (rule_tac finite_inf_insertI) (simp_all) |
585 |
qed |
|
586 |
||
587 |
lemma (in lattice) meet_left: |
|
21049 | 588 |
"[| x \<in> L; y \<in> L |] ==> x \<sqinter> y \<sqsubseteq> x" |
14693 | 589 |
by (rule meetI [folded meet_def]) (blast dest: greatest_mem) |
14551 | 590 |
|
591 |
lemma (in lattice) meet_right: |
|
21049 | 592 |
"[| x \<in> L; y \<in> L |] ==> x \<sqinter> y \<sqsubseteq> y" |
14693 | 593 |
by (rule meetI [folded meet_def]) (blast dest: greatest_mem) |
14551 | 594 |
|
595 |
lemma (in lattice) inf_of_two_greatest: |
|
21049 | 596 |
"[| x \<in> L; y \<in> L |] ==> greatest (\<Sqinter> {x, y}) (Lower {x, y})" |
14551 | 597 |
proof (unfold inf_def) |
21049 | 598 |
assume L: "x \<in> L" "y \<in> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
599 |
with inf_of_two_exists obtain s where "greatest s (Lower {x, y})" by fast |
14551 | 600 |
with L |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
601 |
show "greatest (THE xa. greatest xa (Lower {x, y})) (Lower {x, y})" |
14551 | 602 |
by (fast intro: theI2 greatest_unique) (* blast fails *) |
603 |
qed |
|
604 |
||
605 |
lemma (in lattice) meet_le: |
|
14693 | 606 |
assumes sub: "z \<sqsubseteq> x" "z \<sqsubseteq> y" |
21049 | 607 |
and L: "x \<in> L" "y \<in> L" "z \<in> L" |
14551 | 608 |
shows "z \<sqsubseteq> x \<sqinter> y" |
609 |
proof (rule meetI) |
|
610 |
fix i |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
611 |
assume "greatest i (Lower {x, y})" |
14551 | 612 |
with sub L show "z \<sqsubseteq> i" by (fast elim: greatest_le intro: Lower_memI) |
613 |
qed |
|
14693 | 614 |
|
14551 | 615 |
lemma (in lattice) meet_assoc_lemma: |
21049 | 616 |
assumes L: "x \<in> L" "y \<in> L" "z \<in> L" |
14693 | 617 |
shows "x \<sqinter> (y \<sqinter> z) = \<Sqinter>{x, y, z}" |
14551 | 618 |
proof (rule finite_inf_insertI) |
619 |
txt {* The textbook argument in Jacobson I, p 457 *} |
|
620 |
fix i |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
621 |
assume inf: "greatest i (Lower {x, y, z})" |
14551 | 622 |
show "x \<sqinter> (y \<sqinter> z) = i" |
623 |
proof (rule anti_sym) |
|
624 |
from inf L show "i \<sqsubseteq> x \<sqinter> (y \<sqinter> z)" |
|
625 |
by (fastsimp intro!: meet_le elim: greatest_Lower_above) |
|
626 |
next |
|
627 |
from inf L show "x \<sqinter> (y \<sqinter> z) \<sqsubseteq> i" |
|
628 |
by (erule_tac greatest_le) |
|
629 |
(blast intro!: Lower_memI intro: trans meet_left meet_right meet_closed) |
|
21049 | 630 |
qed (simp_all add: L greatest_closed [OF inf]) |
14551 | 631 |
qed (simp_all add: L) |
632 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
633 |
lemma (in order_syntax) meet_comm: |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
634 |
"x \<sqinter> y = y \<sqinter> x" |
14551 | 635 |
by (unfold meet_def) (simp add: insert_commute) |
636 |
||
637 |
lemma (in lattice) meet_assoc: |
|
21049 | 638 |
assumes L: "x \<in> L" "y \<in> L" "z \<in> L" |
14551 | 639 |
shows "(x \<sqinter> y) \<sqinter> z = x \<sqinter> (y \<sqinter> z)" |
640 |
proof - |
|
641 |
have "(x \<sqinter> y) \<sqinter> z = z \<sqinter> (x \<sqinter> y)" by (simp only: meet_comm) |
|
642 |
also from L have "... = \<Sqinter> {z, x, y}" by (simp add: meet_assoc_lemma) |
|
643 |
also from L have "... = \<Sqinter> {x, y, z}" by (simp add: insert_commute) |
|
644 |
also from L have "... = x \<sqinter> (y \<sqinter> z)" by (simp add: meet_assoc_lemma) |
|
645 |
finally show ?thesis . |
|
646 |
qed |
|
647 |
||
14693 | 648 |
|
14551 | 649 |
subsection {* Total Orders *} |
650 |
||
651 |
locale total_order = lattice + |
|
21049 | 652 |
assumes total: "[| x \<in> L; y \<in> L |] ==> x \<sqsubseteq> y | y \<sqsubseteq> x" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
653 |
|
14551 | 654 |
|
655 |
text {* Introduction rule: the usual definition of total order *} |
|
656 |
||
657 |
lemma (in partial_order) total_orderI: |
|
21049 | 658 |
assumes total: "!!x y. [| x \<in> L; y \<in> L |] ==> x \<sqsubseteq> y | y \<sqsubseteq> x" |
659 |
shows "total_order L le" |
|
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
660 |
proof intro_locales |
21049 | 661 |
show "lattice_axioms L le" |
14551 | 662 |
proof (rule lattice_axioms.intro) |
663 |
fix x y |
|
21049 | 664 |
assume L: "x \<in> L" "y \<in> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
665 |
show "EX s. least s (Upper {x, y})" |
14551 | 666 |
proof - |
667 |
note total L |
|
668 |
moreover |
|
669 |
{ |
|
14693 | 670 |
assume "x \<sqsubseteq> y" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
671 |
with L have "least y (Upper {x, y})" |
14693 | 672 |
by (rule_tac least_UpperI) auto |
14551 | 673 |
} |
674 |
moreover |
|
675 |
{ |
|
14693 | 676 |
assume "y \<sqsubseteq> x" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
677 |
with L have "least x (Upper {x, y})" |
14693 | 678 |
by (rule_tac least_UpperI) auto |
14551 | 679 |
} |
680 |
ultimately show ?thesis by blast |
|
681 |
qed |
|
682 |
next |
|
683 |
fix x y |
|
21049 | 684 |
assume L: "x \<in> L" "y \<in> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
685 |
show "EX i. greatest i (Lower {x, y})" |
14551 | 686 |
proof - |
687 |
note total L |
|
688 |
moreover |
|
689 |
{ |
|
14693 | 690 |
assume "y \<sqsubseteq> x" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
691 |
with L have "greatest y (Lower {x, y})" |
14693 | 692 |
by (rule_tac greatest_LowerI) auto |
14551 | 693 |
} |
694 |
moreover |
|
695 |
{ |
|
14693 | 696 |
assume "x \<sqsubseteq> y" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
697 |
with L have "greatest x (Lower {x, y})" |
14693 | 698 |
by (rule_tac greatest_LowerI) auto |
14551 | 699 |
} |
700 |
ultimately show ?thesis by blast |
|
701 |
qed |
|
702 |
qed |
|
703 |
qed (assumption | rule total_order_axioms.intro)+ |
|
704 |
||
14693 | 705 |
|
14551 | 706 |
subsection {* Complete lattices *} |
707 |
||
708 |
locale complete_lattice = lattice + |
|
709 |
assumes sup_exists: |
|
21049 | 710 |
"[| A \<subseteq> L |] ==> EX s. order_syntax.least L le s (order_syntax.Upper L le A)" |
14551 | 711 |
and inf_exists: |
21049 | 712 |
"[| A \<subseteq> L |] ==> EX i. order_syntax.greatest L le i (order_syntax.Lower L le A)" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
713 |
|
14551 | 714 |
text {* Introduction rule: the usual definition of complete lattice *} |
715 |
||
716 |
lemma (in partial_order) complete_latticeI: |
|
717 |
assumes sup_exists: |
|
21049 | 718 |
"!!A. [| A \<subseteq> L |] ==> EX s. least s (Upper A)" |
14551 | 719 |
and inf_exists: |
21049 | 720 |
"!!A. [| A \<subseteq> L |] ==> EX i. greatest i (Lower A)" |
721 |
shows "complete_lattice L le" |
|
19984
29bb4659f80a
Method intro_locales replaced by intro_locales and unfold_locales.
ballarin
parents:
19931
diff
changeset
|
722 |
proof intro_locales |
21049 | 723 |
show "lattice_axioms L le" |
14693 | 724 |
by (rule lattice_axioms.intro) (blast intro: sup_exists inf_exists)+ |
14551 | 725 |
qed (assumption | rule complete_lattice_axioms.intro)+ |
726 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
727 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
728 |
top ("\<top>") where |
21049 | 729 |
"\<top> == sup L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
730 |
|
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
731 |
definition (in order_syntax) |
21404
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
wenzelm
parents:
21049
diff
changeset
|
732 |
bottom ("\<bottom>") where |
21049 | 733 |
"\<bottom> == inf L" |
14551 | 734 |
|
735 |
||
736 |
lemma (in complete_lattice) supI: |
|
21049 | 737 |
"[| !!l. least l (Upper A) ==> P l; A \<subseteq> L |] |
14651 | 738 |
==> P (\<Squnion>A)" |
14551 | 739 |
proof (unfold sup_def) |
21049 | 740 |
assume L: "A \<subseteq> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
741 |
and P: "!!l. least l (Upper A) ==> P l" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
742 |
with sup_exists obtain s where "least s (Upper A)" by blast |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
743 |
with L show "P (THE l. least l (Upper A))" |
14551 | 744 |
by (fast intro: theI2 least_unique P) |
745 |
qed |
|
746 |
||
747 |
lemma (in complete_lattice) sup_closed [simp]: |
|
21049 | 748 |
"A \<subseteq> L ==> \<Squnion>A \<in> L" |
14551 | 749 |
by (rule supI) simp_all |
750 |
||
751 |
lemma (in complete_lattice) top_closed [simp, intro]: |
|
21049 | 752 |
"\<top> \<in> L" |
14551 | 753 |
by (unfold top_def) simp |
754 |
||
755 |
lemma (in complete_lattice) infI: |
|
21049 | 756 |
"[| !!i. greatest i (Lower A) ==> P i; A \<subseteq> L |] |
14693 | 757 |
==> P (\<Sqinter>A)" |
14551 | 758 |
proof (unfold inf_def) |
21049 | 759 |
assume L: "A \<subseteq> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
760 |
and P: "!!l. greatest l (Lower A) ==> P l" |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
761 |
with inf_exists obtain s where "greatest s (Lower A)" by blast |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
762 |
with L show "P (THE l. greatest l (Lower A))" |
14551 | 763 |
by (fast intro: theI2 greatest_unique P) |
764 |
qed |
|
765 |
||
766 |
lemma (in complete_lattice) inf_closed [simp]: |
|
21049 | 767 |
"A \<subseteq> L ==> \<Sqinter>A \<in> L" |
14551 | 768 |
by (rule infI) simp_all |
769 |
||
770 |
lemma (in complete_lattice) bottom_closed [simp, intro]: |
|
21049 | 771 |
"\<bottom> \<in> L" |
14551 | 772 |
by (unfold bottom_def) simp |
773 |
||
774 |
text {* Jacobson: Theorem 8.1 *} |
|
775 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
776 |
lemma (in order_syntax) Lower_empty [simp]: |
21049 | 777 |
"Lower {} = L" |
14551 | 778 |
by (unfold Lower_def) simp |
779 |
||
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
780 |
lemma (in order_syntax) Upper_empty [simp]: |
21049 | 781 |
"Upper {} = L" |
14551 | 782 |
by (unfold Upper_def) simp |
783 |
||
784 |
theorem (in partial_order) complete_lattice_criterion1: |
|
21049 | 785 |
assumes top_exists: "EX g. greatest g L" |
14551 | 786 |
and inf_exists: |
21049 | 787 |
"!!A. [| A \<subseteq> L; A ~= {} |] ==> EX i. greatest i (Lower A)" |
788 |
shows "complete_lattice L le" |
|
14551 | 789 |
proof (rule complete_latticeI) |
21049 | 790 |
from top_exists obtain top where top: "greatest top L" .. |
14551 | 791 |
fix A |
21049 | 792 |
assume L: "A \<subseteq> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
793 |
let ?B = "Upper A" |
14551 | 794 |
from L top have "top \<in> ?B" by (fast intro!: Upper_memI intro: greatest_le) |
795 |
then have B_non_empty: "?B ~= {}" by fast |
|
21049 | 796 |
have B_L: "?B \<subseteq> L" by simp |
14551 | 797 |
from inf_exists [OF B_L B_non_empty] |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
798 |
obtain b where b_inf_B: "greatest b (Lower ?B)" .. |
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
799 |
have "least b (Upper A)" |
14551 | 800 |
apply (rule least_UpperI) |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
801 |
apply (rule greatest_le [where A = "Lower ?B"]) |
14551 | 802 |
apply (rule b_inf_B) |
803 |
apply (rule Lower_memI) |
|
804 |
apply (erule UpperD) |
|
805 |
apply assumption |
|
806 |
apply (rule L) |
|
807 |
apply (fast intro: L [THEN subsetD]) |
|
808 |
apply (erule greatest_Lower_above [OF b_inf_B]) |
|
809 |
apply simp |
|
810 |
apply (rule L) |
|
21049 | 811 |
apply (rule greatest_closed [OF b_inf_B]) (* rename rule: _closed *) |
14551 | 812 |
done |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
813 |
then show "EX s. least s (Upper A)" .. |
14551 | 814 |
next |
815 |
fix A |
|
21049 | 816 |
assume L: "A \<subseteq> L" |
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
817 |
show "EX i. greatest i (Lower A)" |
14551 | 818 |
proof (cases "A = {}") |
819 |
case True then show ?thesis |
|
820 |
by (simp add: top_exists) |
|
821 |
next |
|
822 |
case False with L show ?thesis |
|
823 |
by (rule inf_exists) |
|
824 |
qed |
|
825 |
qed |
|
826 |
||
827 |
(* TODO: prove dual version *) |
|
828 |
||
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
19984
diff
changeset
|
829 |
|
14551 | 830 |
subsection {* Examples *} |
831 |
||
20318
0e0ea63fe768
Restructured algebra library, added ideals and quotient rings.
ballarin
parents:
19984
diff
changeset
|
832 |
subsubsection {* Powerset of a Set is a Complete Lattice *} |
14551 | 833 |
|
834 |
theorem powerset_is_complete_lattice: |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
835 |
"complete_lattice (Pow A) (op \<subseteq>)" |
21049 | 836 |
(is "complete_lattice ?L ?le") |
14551 | 837 |
proof (rule partial_order.complete_latticeI) |
21049 | 838 |
show "partial_order ?L ?le" |
14551 | 839 |
by (rule partial_order.intro) auto |
840 |
next |
|
841 |
fix B |
|
21049 | 842 |
assume "B \<subseteq> ?L" |
843 |
then have "order_syntax.least ?L ?le (\<Union> B) (order_syntax.Upper ?L ?le B)" |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
844 |
by (fastsimp intro!: order_syntax.least_UpperI simp: order_syntax.Upper_def) |
21049 | 845 |
then show "EX s. order_syntax.least ?L ?le s (order_syntax.Upper ?L ?le B)" .. |
14551 | 846 |
next |
847 |
fix B |
|
21049 | 848 |
assume "B \<subseteq> ?L" |
849 |
then have "order_syntax.greatest ?L ?le (\<Inter> B \<inter> A) (order_syntax.Lower ?L ?le B)" |
|
14551 | 850 |
txt {* @{term "\<Inter> B"} is not the infimum of @{term B}: |
851 |
@{term "\<Inter> {} = UNIV"} which is in general bigger than @{term "A"}! *} |
|
21041
60e418260b4d
Order and lattice structures no longer based on records.
ballarin
parents:
20318
diff
changeset
|
852 |
by (fastsimp intro!: order_syntax.greatest_LowerI simp: order_syntax.Lower_def) |
21049 | 853 |
then show "EX i. order_syntax.greatest ?L ?le i (order_syntax.Lower ?L ?le B)" .. |
14551 | 854 |
qed |
855 |
||
14751
0d7850e27fed
Change of theory hierarchy: Group is now based in Lattice.
ballarin
parents:
14706
diff
changeset
|
856 |
text {* An other example, that of the lattice of subgroups of a group, |
0d7850e27fed
Change of theory hierarchy: Group is now based in Lattice.
ballarin
parents:
14706
diff
changeset
|
857 |
can be found in Group theory (Section~\ref{sec:subgroup-lattice}). *} |
14551 | 858 |
|
14693 | 859 |
end |