author | kleing |
Tue, 13 May 2003 08:59:21 +0200 | |
changeset 14024 | 213dcc39358f |
parent 13482 | 2bb7200a99cf |
child 14259 | 79f7d3451b1e |
permissions | -rw-r--r-- |
13482 | 1 |
(* Title: HOL/Integ/Equiv.thy |
925
15539deb6863
new version of HOL/Integ with curried function application
clasohm
parents:
diff
changeset
|
2 |
ID: $Id$ |
2215 | 3 |
Authors: Lawrence C Paulson, Cambridge University Computer Laboratory |
4 |
Copyright 1996 University of Cambridge |
|
925
15539deb6863
new version of HOL/Integ with curried function application
clasohm
parents:
diff
changeset
|
5 |
*) |
15539deb6863
new version of HOL/Integ with curried function application
clasohm
parents:
diff
changeset
|
6 |
|
13482 | 7 |
header {* Equivalence relations in Higher-Order Set Theory *} |
8 |
||
9 |
theory Equiv = Relation + Finite_Set: |
|
10 |
||
11 |
subsection {* Equiv relations *} |
|
12 |
||
13 |
locale equiv = |
|
14 |
fixes A and r |
|
15 |
assumes refl: "refl A r" |
|
16 |
and sym: "sym r" |
|
17 |
and trans: "trans r" |
|
18 |
||
19 |
text {* |
|
20 |
Suppes, Theorem 70: @{text r} is an equiv relation iff @{text "r\<inverse> O |
|
21 |
r = r"}. |
|
22 |
||
23 |
First half: @{text "equiv A r ==> r\<inverse> O r = r"}. |
|
24 |
*} |
|
25 |
||
26 |
lemma sym_trans_comp_subset: |
|
27 |
"sym r ==> trans r ==> r\<inverse> O r \<subseteq> r" |
|
28 |
by (unfold trans_def sym_def converse_def) blast |
|
29 |
||
30 |
lemma refl_comp_subset: "refl A r ==> r \<subseteq> r\<inverse> O r" |
|
31 |
by (unfold refl_def) blast |
|
32 |
||
33 |
lemma equiv_comp_eq: "equiv A r ==> r\<inverse> O r = r" |
|
34 |
apply (unfold equiv_def) |
|
35 |
apply clarify |
|
36 |
apply (rule equalityI) |
|
37 |
apply (rules intro: sym_trans_comp_subset refl_comp_subset)+ |
|
38 |
done |
|
39 |
||
40 |
text {* |
|
41 |
Second half. |
|
42 |
*} |
|
43 |
||
44 |
lemma comp_equivI: |
|
45 |
"r\<inverse> O r = r ==> Domain r = A ==> equiv A r" |
|
46 |
apply (unfold equiv_def refl_def sym_def trans_def) |
|
47 |
apply (erule equalityE) |
|
48 |
apply (subgoal_tac "\<forall>x y. (x, y) \<in> r --> (y, x) \<in> r") |
|
49 |
apply fast |
|
50 |
apply fast |
|
51 |
done |
|
52 |
||
53 |
||
54 |
subsection {* Equivalence classes *} |
|
55 |
||
56 |
lemma equiv_class_subset: |
|
57 |
"equiv A r ==> (a, b) \<in> r ==> r``{a} \<subseteq> r``{b}" |
|
58 |
-- {* lemma for the next result *} |
|
59 |
by (unfold equiv_def trans_def sym_def) blast |
|
60 |
||
61 |
lemma equiv_class_eq: "equiv A r ==> (a, b) \<in> r ==> r``{a} = r``{b}" |
|
62 |
apply (assumption | rule equalityI equiv_class_subset)+ |
|
63 |
apply (unfold equiv_def sym_def) |
|
64 |
apply blast |
|
65 |
done |
|
66 |
||
67 |
lemma equiv_class_self: "equiv A r ==> a \<in> A ==> a \<in> r``{a}" |
|
68 |
by (unfold equiv_def refl_def) blast |
|
69 |
||
70 |
lemma subset_equiv_class: |
|
71 |
"equiv A r ==> r``{b} \<subseteq> r``{a} ==> b \<in> A ==> (a,b) \<in> r" |
|
72 |
-- {* lemma for the next result *} |
|
73 |
by (unfold equiv_def refl_def) blast |
|
74 |
||
75 |
lemma eq_equiv_class: |
|
76 |
"r``{a} = r``{b} ==> equiv A r ==> b \<in> A ==> (a, b) \<in> r" |
|
77 |
by (rules intro: equalityD2 subset_equiv_class) |
|
78 |
||
79 |
lemma equiv_class_nondisjoint: |
|
80 |
"equiv A r ==> x \<in> (r``{a} \<inter> r``{b}) ==> (a, b) \<in> r" |
|
81 |
by (unfold equiv_def trans_def sym_def) blast |
|
82 |
||
83 |
lemma equiv_type: "equiv A r ==> r \<subseteq> A \<times> A" |
|
84 |
by (unfold equiv_def refl_def) blast |
|
85 |
||
86 |
lemma equiv_class_eq_iff: |
|
87 |
"equiv A r ==> ((x, y) \<in> r) = (r``{x} = r``{y} & x \<in> A & y \<in> A)" |
|
88 |
by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type) |
|
89 |
||
90 |
lemma eq_equiv_class_iff: |
|
91 |
"equiv A r ==> x \<in> A ==> y \<in> A ==> (r``{x} = r``{y}) = ((x, y) \<in> r)" |
|
92 |
by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type) |
|
93 |
||
94 |
||
95 |
subsection {* Quotients *} |
|
96 |
||
9392 | 97 |
constdefs |
13482 | 98 |
quotient :: "['a set, ('a*'a) set] => 'a set set" (infixl "'/'/" 90) |
99 |
"A//r == \<Union>x \<in> A. {r``{x}}" -- {* set of equiv classes *} |
|
100 |
||
101 |
lemma quotientI: "x \<in> A ==> r``{x} \<in> A//r" |
|
102 |
by (unfold quotient_def) blast |
|
103 |
||
104 |
lemma quotientE: |
|
105 |
"X \<in> A//r ==> (!!x. X = r``{x} ==> x \<in> A ==> P) ==> P" |
|
106 |
by (unfold quotient_def) blast |
|
107 |
||
108 |
lemma Union_quotient: "equiv A r ==> Union (A//r) = A" |
|
109 |
by (unfold equiv_def refl_def quotient_def) blast |
|
9392 | 110 |
|
13482 | 111 |
lemma quotient_disj: |
112 |
"equiv A r ==> X \<in> A//r ==> Y \<in> A//r ==> X = Y | (X \<inter> Y = {})" |
|
113 |
apply (unfold quotient_def) |
|
114 |
apply clarify |
|
115 |
apply (rule equiv_class_eq) |
|
116 |
apply assumption |
|
117 |
apply (unfold equiv_def trans_def sym_def) |
|
118 |
apply blast |
|
119 |
done |
|
120 |
||
121 |
||
122 |
subsection {* Defining unary operations upon equivalence classes *} |
|
123 |
||
124 |
locale congruent = |
|
125 |
fixes r and b |
|
126 |
assumes congruent: "(y, z) \<in> r ==> b y = b z" |
|
127 |
||
128 |
lemma UN_constant_eq: "a \<in> A ==> \<forall>y \<in> A. b y = c ==> (\<Union>y \<in> A. b(y))=c" |
|
129 |
-- {* lemma required to prove @{text UN_equiv_class} *} |
|
130 |
by auto |
|
131 |
||
132 |
lemma UN_equiv_class: |
|
133 |
"equiv A r ==> congruent r b ==> a \<in> A |
|
134 |
==> (\<Union>x \<in> r``{a}. b x) = b a" |
|
135 |
-- {* Conversion rule *} |
|
136 |
apply (rule equiv_class_self [THEN UN_constant_eq], assumption+) |
|
137 |
apply (unfold equiv_def congruent_def sym_def) |
|
138 |
apply (blast del: equalityI) |
|
139 |
done |
|
925
15539deb6863
new version of HOL/Integ with curried function application
clasohm
parents:
diff
changeset
|
140 |
|
13482 | 141 |
lemma UN_equiv_class_type: |
142 |
"equiv A r ==> congruent r b ==> X \<in> A//r ==> |
|
143 |
(!!x. x \<in> A ==> b x : B) ==> (\<Union>x \<in> X. b x) : B" |
|
144 |
apply (unfold quotient_def) |
|
145 |
apply clarify |
|
146 |
apply (subst UN_equiv_class) |
|
147 |
apply auto |
|
148 |
done |
|
149 |
||
150 |
text {* |
|
151 |
Sufficient conditions for injectiveness. Could weaken premises! |
|
152 |
major premise could be an inclusion; bcong could be @{text "!!y. y \<in> |
|
153 |
A ==> b y \<in> B"}. |
|
154 |
*} |
|
155 |
||
156 |
lemma UN_equiv_class_inject: |
|
157 |
"equiv A r ==> congruent r b ==> |
|
158 |
(\<Union>x \<in> X. b x) = (\<Union>y \<in> Y. b y) ==> X \<in> A//r ==> Y \<in> A//r |
|
159 |
==> (!!x y. x \<in> A ==> y \<in> A ==> b x = b y ==> (x, y) \<in> r) |
|
160 |
==> X = Y" |
|
161 |
apply (unfold quotient_def) |
|
162 |
apply clarify |
|
163 |
apply (rule equiv_class_eq) |
|
164 |
apply assumption |
|
165 |
apply (subgoal_tac "b x = b xa") |
|
166 |
apply blast |
|
167 |
apply (erule box_equals) |
|
168 |
apply (assumption | rule UN_equiv_class)+ |
|
169 |
done |
|
170 |
||
171 |
||
172 |
subsection {* Defining binary operations upon equivalence classes *} |
|
173 |
||
174 |
locale congruent2 = |
|
175 |
fixes r and b |
|
176 |
assumes congruent2: |
|
177 |
"(y1, z1) \<in> r ==> (y2, z2) \<in> r ==> b y1 y2 = b z1 z2" |
|
178 |
||
179 |
lemma congruent2_implies_congruent: |
|
180 |
"equiv A r ==> congruent2 r b ==> a \<in> A ==> congruent r (b a)" |
|
181 |
by (unfold congruent_def congruent2_def equiv_def refl_def) blast |
|
182 |
||
183 |
lemma congruent2_implies_congruent_UN: |
|
184 |
"equiv A r ==> congruent2 r b ==> a \<in> A ==> |
|
185 |
congruent r (\<lambda>x1. \<Union>x2 \<in> r``{a}. b x1 x2)" |
|
186 |
apply (unfold congruent_def) |
|
187 |
apply clarify |
|
188 |
apply (rule equiv_type [THEN subsetD, THEN SigmaE2], assumption+) |
|
189 |
apply (simp add: UN_equiv_class congruent2_implies_congruent) |
|
190 |
apply (unfold congruent2_def equiv_def refl_def) |
|
191 |
apply (blast del: equalityI) |
|
192 |
done |
|
193 |
||
194 |
lemma UN_equiv_class2: |
|
195 |
"equiv A r ==> congruent2 r b ==> a1 \<in> A ==> a2 \<in> A |
|
196 |
==> (\<Union>x1 \<in> r``{a1}. \<Union>x2 \<in> r``{a2}. b x1 x2) = b a1 a2" |
|
197 |
by (simp add: UN_equiv_class congruent2_implies_congruent |
|
198 |
congruent2_implies_congruent_UN) |
|
9392 | 199 |
|
13482 | 200 |
lemma UN_equiv_class_type2: |
201 |
"equiv A r ==> congruent2 r b ==> X1 \<in> A//r ==> X2 \<in> A//r |
|
202 |
==> (!!x1 x2. x1 \<in> A ==> x2 \<in> A ==> b x1 x2 \<in> B) |
|
203 |
==> (\<Union>x1 \<in> X1. \<Union>x2 \<in> X2. b x1 x2) \<in> B" |
|
204 |
apply (unfold quotient_def) |
|
205 |
apply clarify |
|
206 |
apply (blast intro: UN_equiv_class_type congruent2_implies_congruent_UN |
|
207 |
congruent2_implies_congruent quotientI) |
|
208 |
done |
|
209 |
||
210 |
lemma UN_UN_split_split_eq: |
|
211 |
"(\<Union>(x1, x2) \<in> X. \<Union>(y1, y2) \<in> Y. A x1 x2 y1 y2) = |
|
212 |
(\<Union>x \<in> X. \<Union>y \<in> Y. (\<lambda>(x1, x2). (\<lambda>(y1, y2). A x1 x2 y1 y2) y) x)" |
|
213 |
-- {* Allows a natural expression of binary operators, *} |
|
214 |
-- {* without explicit calls to @{text split} *} |
|
215 |
by auto |
|
216 |
||
217 |
lemma congruent2I: |
|
218 |
"equiv A r |
|
219 |
==> (!!y z w. w \<in> A ==> (y, z) \<in> r ==> b y w = b z w) |
|
220 |
==> (!!y z w. w \<in> A ==> (y, z) \<in> r ==> b w y = b w z) |
|
221 |
==> congruent2 r b" |
|
222 |
-- {* Suggested by John Harrison -- the two subproofs may be *} |
|
223 |
-- {* \emph{much} simpler than the direct proof. *} |
|
224 |
apply (unfold congruent2_def equiv_def refl_def) |
|
225 |
apply clarify |
|
226 |
apply (blast intro: trans) |
|
227 |
done |
|
228 |
||
229 |
lemma congruent2_commuteI: |
|
230 |
assumes equivA: "equiv A r" |
|
231 |
and commute: "!!y z. y \<in> A ==> z \<in> A ==> b y z = b z y" |
|
232 |
and congt: "!!y z w. w \<in> A ==> (y, z) \<in> r ==> b w y = b w z" |
|
233 |
shows "congruent2 r b" |
|
234 |
apply (rule equivA [THEN congruent2I]) |
|
235 |
apply (rule commute [THEN trans]) |
|
236 |
apply (rule_tac [3] commute [THEN trans, symmetric]) |
|
237 |
apply (rule_tac [5] sym) |
|
238 |
apply (assumption | rule congt | |
|
239 |
erule equivA [THEN equiv_type, THEN subsetD, THEN SigmaE2])+ |
|
240 |
done |
|
241 |
||
242 |
||
243 |
subsection {* Cardinality results *} |
|
244 |
||
245 |
text {* (suggested by Florian Kammüller) *} |
|
246 |
||
247 |
lemma finite_quotient: "finite A ==> r \<subseteq> A \<times> A ==> finite (A//r)" |
|
248 |
-- {* recall @{thm equiv_type} *} |
|
249 |
apply (rule finite_subset) |
|
250 |
apply (erule_tac [2] finite_Pow_iff [THEN iffD2]) |
|
251 |
apply (unfold quotient_def) |
|
252 |
apply blast |
|
253 |
done |
|
254 |
||
255 |
lemma finite_equiv_class: |
|
256 |
"finite A ==> r \<subseteq> A \<times> A ==> X \<in> A//r ==> finite X" |
|
257 |
apply (unfold quotient_def) |
|
258 |
apply (rule finite_subset) |
|
259 |
prefer 2 apply assumption |
|
260 |
apply blast |
|
261 |
done |
|
262 |
||
263 |
lemma equiv_imp_dvd_card: |
|
264 |
"finite A ==> equiv A r ==> \<forall>X \<in> A//r. k dvd card X |
|
265 |
==> k dvd card A" |
|
266 |
apply (rule Union_quotient [THEN subst]) |
|
267 |
apply assumption |
|
268 |
apply (rule dvd_partition) |
|
269 |
prefer 4 apply (blast dest: quotient_disj) |
|
270 |
apply (simp_all add: Union_quotient equiv_type finite_quotient) |
|
271 |
done |
|
272 |
||
925
15539deb6863
new version of HOL/Integ with curried function application
clasohm
parents:
diff
changeset
|
273 |
end |