author | wenzelm |
Sat, 01 May 2004 22:08:57 +0200 | |
changeset 14695 | 9c78044b99c3 |
parent 14095 | a1ba833d6b61 |
child 15182 | 5cea84e10f3e |
permissions | -rw-r--r-- |
5528 | 1 |
(* Title: ZF/EquivClass.thy |
2 |
ID: $Id$ |
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory |
|
4 |
Copyright 1994 University of Cambridge |
|
5 |
||
6 |
*) |
|
7 |
||
13574 | 8 |
header{*Equivalence Relations*} |
9 |
||
10 |
theory EquivClass = Trancl + Perm: |
|
9333 | 11 |
|
12 |
constdefs |
|
13 |
||
13574 | 14 |
quotient :: "[i,i]=>i" (infixl "'/'/" 90) (*set of equiv classes*) |
9333 | 15 |
"A//r == {r``{x} . x:A}" |
5528 | 16 |
|
13574 | 17 |
congruent :: "[i,i=>i]=>o" |
9333 | 18 |
"congruent(r,b) == ALL y z. <y,z>:r --> b(y)=b(z)" |
5528 | 19 |
|
13574 | 20 |
congruent2 :: "[i,[i,i]=>i]=>o" |
21 |
"congruent2(r,b) == ALL y1 z1 y2 z2. |
|
5528 | 22 |
<y1,z1>:r --> <y2,z2>:r --> b(y1,y2) = b(z1,z2)" |
23 |
||
13574 | 24 |
subsection{*Suppes, Theorem 70: |
25 |
@{term r} is an equiv relation iff @{term "converse(r) O r = r"}*} |
|
26 |
||
27 |
(** first half: equiv(A,r) ==> converse(r) O r = r **) |
|
28 |
||
29 |
lemma sym_trans_comp_subset: |
|
30 |
"[| sym(r); trans(r) |] ==> converse(r) O r <= r" |
|
31 |
apply (unfold trans_def sym_def, blast) |
|
32 |
done |
|
33 |
||
34 |
lemma refl_comp_subset: |
|
35 |
"[| refl(A,r); r <= A*A |] ==> r <= converse(r) O r" |
|
36 |
apply (unfold refl_def, blast) |
|
37 |
done |
|
38 |
||
39 |
lemma equiv_comp_eq: |
|
40 |
"equiv(A,r) ==> converse(r) O r = r" |
|
41 |
apply (unfold equiv_def) |
|
42 |
apply (blast del: subsetI |
|
43 |
intro!: sym_trans_comp_subset refl_comp_subset) |
|
44 |
done |
|
45 |
||
46 |
(*second half*) |
|
47 |
lemma comp_equivI: |
|
48 |
"[| converse(r) O r = r; domain(r) = A |] ==> equiv(A,r)" |
|
49 |
apply (unfold equiv_def refl_def sym_def trans_def) |
|
50 |
apply (erule equalityE) |
|
51 |
apply (subgoal_tac "ALL x y. <x,y> : r --> <y,x> : r", blast+) |
|
52 |
done |
|
53 |
||
54 |
(** Equivalence classes **) |
|
55 |
||
56 |
(*Lemma for the next result*) |
|
57 |
lemma equiv_class_subset: |
|
58 |
"[| sym(r); trans(r); <a,b>: r |] ==> r``{a} <= r``{b}" |
|
59 |
by (unfold trans_def sym_def, blast) |
|
60 |
||
61 |
lemma equiv_class_eq: |
|
62 |
"[| equiv(A,r); <a,b>: r |] ==> r``{a} = r``{b}" |
|
63 |
apply (unfold equiv_def) |
|
64 |
apply (safe del: subsetI intro!: equalityI equiv_class_subset) |
|
65 |
apply (unfold sym_def, blast) |
|
66 |
done |
|
67 |
||
68 |
lemma equiv_class_self: |
|
69 |
"[| equiv(A,r); a: A |] ==> a: r``{a}" |
|
70 |
by (unfold equiv_def refl_def, blast) |
|
71 |
||
72 |
(*Lemma for the next result*) |
|
73 |
lemma subset_equiv_class: |
|
74 |
"[| equiv(A,r); r``{b} <= r``{a}; b: A |] ==> <a,b>: r" |
|
75 |
by (unfold equiv_def refl_def, blast) |
|
76 |
||
77 |
lemma eq_equiv_class: "[| r``{a} = r``{b}; equiv(A,r); b: A |] ==> <a,b>: r" |
|
78 |
by (assumption | rule equalityD2 subset_equiv_class)+ |
|
79 |
||
80 |
(*thus r``{a} = r``{b} as well*) |
|
81 |
lemma equiv_class_nondisjoint: |
|
82 |
"[| equiv(A,r); x: (r``{a} Int r``{b}) |] ==> <a,b>: r" |
|
83 |
by (unfold equiv_def trans_def sym_def, blast) |
|
84 |
||
85 |
lemma equiv_type: "equiv(A,r) ==> r <= A*A" |
|
86 |
by (unfold equiv_def, blast) |
|
87 |
||
88 |
lemma equiv_class_eq_iff: |
|
89 |
"equiv(A,r) ==> <x,y>: r <-> r``{x} = r``{y} & x:A & y:A" |
|
90 |
by (blast intro: eq_equiv_class equiv_class_eq dest: equiv_type) |
|
91 |
||
92 |
lemma eq_equiv_class_iff: |
|
93 |
"[| equiv(A,r); x: A; y: A |] ==> r``{x} = r``{y} <-> <x,y>: r" |
|
94 |
by (blast intro: eq_equiv_class equiv_class_eq dest: equiv_type) |
|
95 |
||
96 |
(*** Quotients ***) |
|
97 |
||
98 |
(** Introduction/elimination rules -- needed? **) |
|
99 |
||
100 |
lemma quotientI [TC]: "x:A ==> r``{x}: A//r" |
|
101 |
apply (unfold quotient_def) |
|
102 |
apply (erule RepFunI) |
|
103 |
done |
|
104 |
||
105 |
lemma quotientE: |
|
106 |
"[| X: A//r; !!x. [| X = r``{x}; x:A |] ==> P |] ==> P" |
|
107 |
by (unfold quotient_def, blast) |
|
108 |
||
109 |
lemma Union_quotient: |
|
110 |
"equiv(A,r) ==> Union(A//r) = A" |
|
111 |
by (unfold equiv_def refl_def quotient_def, blast) |
|
112 |
||
113 |
lemma quotient_disj: |
|
114 |
"[| equiv(A,r); X: A//r; Y: A//r |] ==> X=Y | (X Int Y <= 0)" |
|
115 |
apply (unfold quotient_def) |
|
116 |
apply (safe intro!: equiv_class_eq, assumption) |
|
117 |
apply (unfold equiv_def trans_def sym_def, blast) |
|
118 |
done |
|
119 |
||
120 |
subsection{*Defining Unary Operations upon Equivalence Classes*} |
|
121 |
||
122 |
(** Could have a locale with the premises equiv(A,r) and congruent(r,b) |
|
123 |
**) |
|
124 |
||
125 |
(*Conversion rule*) |
|
126 |
lemma UN_equiv_class: |
|
127 |
"[| equiv(A,r); congruent(r,b); a: A |] ==> (UN x:r``{a}. b(x)) = b(a)" |
|
14095
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
paulson
parents:
13615
diff
changeset
|
128 |
apply (subgoal_tac "\<forall>x \<in> r``{a}. b(x) = b(a)") |
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
paulson
parents:
13615
diff
changeset
|
129 |
apply simp |
a1ba833d6b61
Changed many Intersection rules from i:I to I~=0 to avoid introducing a new
paulson
parents:
13615
diff
changeset
|
130 |
apply (blast intro: equiv_class_self) |
13574 | 131 |
apply (unfold equiv_def sym_def congruent_def, blast) |
132 |
done |
|
133 |
||
134 |
(*type checking of UN x:r``{a}. b(x) *) |
|
135 |
lemma UN_equiv_class_type: |
|
136 |
"[| equiv(A,r); congruent(r,b); X: A//r; !!x. x : A ==> b(x) : B |] |
|
137 |
==> (UN x:X. b(x)) : B" |
|
138 |
apply (unfold quotient_def, safe) |
|
139 |
apply (simp (no_asm_simp) add: UN_equiv_class) |
|
140 |
done |
|
141 |
||
142 |
(*Sufficient conditions for injectiveness. Could weaken premises! |
|
143 |
major premise could be an inclusion; bcong could be !!y. y:A ==> b(y):B |
|
144 |
*) |
|
145 |
lemma UN_equiv_class_inject: |
|
146 |
"[| equiv(A,r); congruent(r,b); |
|
147 |
(UN x:X. b(x))=(UN y:Y. b(y)); X: A//r; Y: A//r; |
|
148 |
!!x y. [| x:A; y:A; b(x)=b(y) |] ==> <x,y>:r |] |
|
149 |
==> X=Y" |
|
150 |
apply (unfold quotient_def, safe) |
|
151 |
apply (rule equiv_class_eq, assumption) |
|
152 |
apply (simp add: UN_equiv_class [of A r b]) |
|
153 |
done |
|
154 |
||
155 |
||
156 |
subsection{*Defining Binary Operations upon Equivalence Classes*} |
|
157 |
||
158 |
lemma congruent2_implies_congruent: |
|
159 |
"[| equiv(A,r); congruent2(r,b); a: A |] ==> congruent(r,b(a))" |
|
13615
449a70d88b38
Numerous cosmetic changes, prompted by the new simplifier
paulson
parents:
13574
diff
changeset
|
160 |
by (unfold congruent_def congruent2_def equiv_def refl_def, blast) |
13574 | 161 |
|
162 |
lemma congruent2_implies_congruent_UN: |
|
163 |
"[| equiv(A,r); congruent2(r,b); a: A |] ==> |
|
164 |
congruent(r, %x1. UN x2:r``{a}. b(x1,x2))" |
|
165 |
apply (unfold congruent_def, safe) |
|
166 |
apply (frule equiv_type [THEN subsetD], assumption) |
|
167 |
apply clarify |
|
168 |
apply (simp add: UN_equiv_class [of A r] congruent2_implies_congruent) |
|
169 |
apply (unfold congruent2_def equiv_def refl_def, blast) |
|
170 |
done |
|
171 |
||
172 |
lemma UN_equiv_class2: |
|
173 |
"[| equiv(A,r); congruent2(r,b); a1: A; a2: A |] |
|
174 |
==> (UN x1:r``{a1}. UN x2:r``{a2}. b(x1,x2)) = b(a1,a2)" |
|
175 |
by (simp add: UN_equiv_class [of A r] congruent2_implies_congruent |
|
176 |
congruent2_implies_congruent_UN) |
|
177 |
||
178 |
(*type checking*) |
|
179 |
lemma UN_equiv_class_type2: |
|
180 |
"[| equiv(A,r); congruent2(r,b); |
|
181 |
X1: A//r; X2: A//r; |
|
182 |
!!x1 x2. [| x1: A; x2: A |] ==> b(x1,x2) : B |
|
183 |
|] ==> (UN x1:X1. UN x2:X2. b(x1,x2)) : B" |
|
184 |
apply (unfold quotient_def, safe) |
|
185 |
apply (blast intro: UN_equiv_class_type congruent2_implies_congruent_UN |
|
186 |
congruent2_implies_congruent quotientI) |
|
187 |
done |
|
188 |
||
189 |
||
190 |
(*Suggested by John Harrison -- the two subproofs may be MUCH simpler |
|
191 |
than the direct proof*) |
|
192 |
lemma congruent2I: |
|
193 |
"[| equiv(A,r); |
|
194 |
!! y z w. [| w: A; <y,z> : r |] ==> b(y,w) = b(z,w); |
|
195 |
!! y z w. [| w: A; <y,z> : r |] ==> b(w,y) = b(w,z) |
|
196 |
|] ==> congruent2(r,b)" |
|
197 |
apply (unfold congruent2_def equiv_def refl_def, safe) |
|
198 |
apply (blast intro: trans) |
|
199 |
done |
|
200 |
||
201 |
lemma congruent2_commuteI: |
|
202 |
assumes equivA: "equiv(A,r)" |
|
203 |
and commute: "!! y z. [| y: A; z: A |] ==> b(y,z) = b(z,y)" |
|
204 |
and congt: "!! y z w. [| w: A; <y,z>: r |] ==> b(w,y) = b(w,z)" |
|
205 |
shows "congruent2(r,b)" |
|
206 |
apply (insert equivA [THEN equiv_type, THEN subsetD]) |
|
207 |
apply (rule congruent2I [OF equivA]) |
|
208 |
apply (rule commute [THEN trans]) |
|
209 |
apply (rule_tac [3] commute [THEN trans, symmetric]) |
|
210 |
apply (rule_tac [5] sym) |
|
211 |
apply (blast intro: congt)+ |
|
212 |
done |
|
213 |
||
214 |
(*Obsolete?*) |
|
215 |
lemma congruent_commuteI: |
|
216 |
"[| equiv(A,r); Z: A//r; |
|
217 |
!!w. [| w: A |] ==> congruent(r, %z. b(w,z)); |
|
218 |
!!x y. [| x: A; y: A |] ==> b(y,x) = b(x,y) |
|
219 |
|] ==> congruent(r, %w. UN z: Z. b(w,z))" |
|
220 |
apply (simp (no_asm) add: congruent_def) |
|
221 |
apply (safe elim!: quotientE) |
|
222 |
apply (frule equiv_type [THEN subsetD], assumption) |
|
223 |
apply (simp add: UN_equiv_class [of A r]) |
|
224 |
apply (simp add: congruent_def) |
|
225 |
done |
|
226 |
||
227 |
ML |
|
228 |
{* |
|
229 |
val sym_trans_comp_subset = thm "sym_trans_comp_subset"; |
|
230 |
val refl_comp_subset = thm "refl_comp_subset"; |
|
231 |
val equiv_comp_eq = thm "equiv_comp_eq"; |
|
232 |
val comp_equivI = thm "comp_equivI"; |
|
233 |
val equiv_class_subset = thm "equiv_class_subset"; |
|
234 |
val equiv_class_eq = thm "equiv_class_eq"; |
|
235 |
val equiv_class_self = thm "equiv_class_self"; |
|
236 |
val subset_equiv_class = thm "subset_equiv_class"; |
|
237 |
val eq_equiv_class = thm "eq_equiv_class"; |
|
238 |
val equiv_class_nondisjoint = thm "equiv_class_nondisjoint"; |
|
239 |
val equiv_type = thm "equiv_type"; |
|
240 |
val equiv_class_eq_iff = thm "equiv_class_eq_iff"; |
|
241 |
val eq_equiv_class_iff = thm "eq_equiv_class_iff"; |
|
242 |
val quotientI = thm "quotientI"; |
|
243 |
val quotientE = thm "quotientE"; |
|
244 |
val Union_quotient = thm "Union_quotient"; |
|
245 |
val quotient_disj = thm "quotient_disj"; |
|
246 |
val UN_equiv_class = thm "UN_equiv_class"; |
|
247 |
val UN_equiv_class_type = thm "UN_equiv_class_type"; |
|
248 |
val UN_equiv_class_inject = thm "UN_equiv_class_inject"; |
|
249 |
val congruent2_implies_congruent = thm "congruent2_implies_congruent"; |
|
250 |
val congruent2_implies_congruent_UN = thm "congruent2_implies_congruent_UN"; |
|
251 |
val congruent_commuteI = thm "congruent_commuteI"; |
|
252 |
val UN_equiv_class2 = thm "UN_equiv_class2"; |
|
253 |
val UN_equiv_class_type2 = thm "UN_equiv_class_type2"; |
|
254 |
val congruent2I = thm "congruent2I"; |
|
255 |
val congruent2_commuteI = thm "congruent2_commuteI"; |
|
256 |
val congruent_commuteI = thm "congruent_commuteI"; |
|
257 |
*} |
|
258 |
||
5528 | 259 |
end |