5528
|
1 |
(* Title: ZF/EquivClass.ML
|
|
2 |
ID: $Id$
|
|
3 |
Author: Lawrence C Paulson, Cambridge University Computer Laboratory
|
|
4 |
Copyright 1994 University of Cambridge
|
|
5 |
|
|
6 |
Equivalence relations in Zermelo-Fraenkel Set Theory
|
|
7 |
*)
|
|
8 |
|
|
9 |
val RSLIST = curry (op MRS);
|
|
10 |
|
|
11 |
open EquivClass;
|
|
12 |
|
|
13 |
(*** Suppes, Theorem 70: r is an equiv relation iff converse(r) O r = r ***)
|
|
14 |
|
|
15 |
(** first half: equiv(A,r) ==> converse(r) O r = r **)
|
|
16 |
|
|
17 |
Goalw [trans_def,sym_def]
|
|
18 |
"[| sym(r); trans(r) |] ==> converse(r) O r <= r";
|
|
19 |
by (Blast_tac 1);
|
|
20 |
qed "sym_trans_comp_subset";
|
|
21 |
|
|
22 |
Goalw [refl_def]
|
|
23 |
"[| refl(A,r); r <= A*A |] ==> r <= converse(r) O r";
|
|
24 |
by (Blast_tac 1);
|
|
25 |
qed "refl_comp_subset";
|
|
26 |
|
|
27 |
Goalw [equiv_def]
|
|
28 |
"equiv(A,r) ==> converse(r) O r = r";
|
|
29 |
by (blast_tac (subset_cs addSIs [sym_trans_comp_subset, refl_comp_subset]) 1);
|
|
30 |
qed "equiv_comp_eq";
|
|
31 |
|
|
32 |
(*second half*)
|
|
33 |
Goalw [equiv_def,refl_def,sym_def,trans_def]
|
|
34 |
"[| converse(r) O r = r; domain(r) = A |] ==> equiv(A,r)";
|
|
35 |
by (etac equalityE 1);
|
|
36 |
by (subgoal_tac "ALL x y. <x,y> : r --> <y,x> : r" 1);
|
|
37 |
by (ALLGOALS Fast_tac);
|
|
38 |
qed "comp_equivI";
|
|
39 |
|
|
40 |
(** Equivalence classes **)
|
|
41 |
|
|
42 |
(*Lemma for the next result*)
|
|
43 |
Goalw [trans_def,sym_def]
|
|
44 |
"[| sym(r); trans(r); <a,b>: r |] ==> r``{a} <= r``{b}";
|
|
45 |
by (Blast_tac 1);
|
|
46 |
qed "equiv_class_subset";
|
|
47 |
|
|
48 |
Goalw [equiv_def]
|
|
49 |
"[| equiv(A,r); <a,b>: r |] ==> r``{a} = r``{b}";
|
|
50 |
by (safe_tac (subset_cs addSIs [equalityI, equiv_class_subset]));
|
|
51 |
by (rewtac sym_def);
|
|
52 |
by (Blast_tac 1);
|
|
53 |
qed "equiv_class_eq";
|
|
54 |
|
|
55 |
Goalw [equiv_def,refl_def]
|
|
56 |
"[| equiv(A,r); a: A |] ==> a: r``{a}";
|
|
57 |
by (Blast_tac 1);
|
|
58 |
qed "equiv_class_self";
|
|
59 |
|
|
60 |
(*Lemma for the next result*)
|
|
61 |
Goalw [equiv_def,refl_def]
|
|
62 |
"[| equiv(A,r); r``{b} <= r``{a}; b: A |] ==> <a,b>: r";
|
|
63 |
by (Blast_tac 1);
|
|
64 |
qed "subset_equiv_class";
|
|
65 |
|
|
66 |
Goal "[| r``{a} = r``{b}; equiv(A,r); b: A |] ==> <a,b>: r";
|
|
67 |
by (REPEAT (ares_tac[equalityD2, subset_equiv_class] 1));
|
|
68 |
qed "eq_equiv_class";
|
|
69 |
|
|
70 |
(*thus r``{a} = r``{b} as well*)
|
|
71 |
Goalw [equiv_def,trans_def,sym_def]
|
|
72 |
"[| equiv(A,r); x: (r``{a} Int r``{b}) |] ==> <a,b>: r";
|
|
73 |
by (Blast_tac 1);
|
|
74 |
qed "equiv_class_nondisjoint";
|
|
75 |
|
|
76 |
Goalw [equiv_def] "equiv(A,r) ==> r <= A*A";
|
|
77 |
by (safe_tac subset_cs);
|
|
78 |
qed "equiv_type";
|
|
79 |
|
|
80 |
Goal "equiv(A,r) ==> <x,y>: r <-> r``{x} = r``{y} & x:A & y:A";
|
|
81 |
by (blast_tac (claset() addIs [eq_equiv_class, equiv_class_eq]
|
|
82 |
addDs [equiv_type]) 1);
|
|
83 |
qed "equiv_class_eq_iff";
|
|
84 |
|
|
85 |
Goal "[| equiv(A,r); x: A; y: A |] ==> r``{x} = r``{y} <-> <x,y>: r";
|
|
86 |
by (blast_tac (claset() addIs [eq_equiv_class, equiv_class_eq]
|
|
87 |
addDs [equiv_type]) 1);
|
|
88 |
qed "eq_equiv_class_iff";
|
|
89 |
|
|
90 |
(*** Quotients ***)
|
|
91 |
|
|
92 |
(** Introduction/elimination rules -- needed? **)
|
|
93 |
|
|
94 |
Goalw [quotient_def] "x:A ==> r``{x}: A/r";
|
|
95 |
by (etac RepFunI 1);
|
|
96 |
qed "quotientI";
|
6153
|
97 |
AddTCs [quotientI];
|
5528
|
98 |
|
|
99 |
val major::prems = Goalw [quotient_def]
|
|
100 |
"[| X: A/r; !!x. [| X = r``{x}; x:A |] ==> P |] \
|
|
101 |
\ ==> P";
|
|
102 |
by (rtac (major RS RepFunE) 1);
|
|
103 |
by (eresolve_tac prems 1);
|
|
104 |
by (assume_tac 1);
|
|
105 |
qed "quotientE";
|
|
106 |
|
|
107 |
Goalw [equiv_def,refl_def,quotient_def]
|
|
108 |
"equiv(A,r) ==> Union(A/r) = A";
|
|
109 |
by (Blast_tac 1);
|
|
110 |
qed "Union_quotient";
|
|
111 |
|
|
112 |
Goalw [quotient_def]
|
|
113 |
"[| equiv(A,r); X: A/r; Y: A/r |] ==> X=Y | (X Int Y <= 0)";
|
|
114 |
by (safe_tac (claset() addSIs [equiv_class_eq]));
|
|
115 |
by (assume_tac 1);
|
|
116 |
by (rewrite_goals_tac [equiv_def,trans_def,sym_def]);
|
|
117 |
by (Blast_tac 1);
|
|
118 |
qed "quotient_disj";
|
|
119 |
|
|
120 |
(**** Defining unary operations upon equivalence classes ****)
|
|
121 |
|
|
122 |
(** These proofs really require as local premises
|
|
123 |
equiv(A,r); congruent(r,b)
|
|
124 |
**)
|
|
125 |
|
|
126 |
(*Conversion rule*)
|
|
127 |
val prems as [equivA,bcong,_] = goal EquivClass.thy
|
|
128 |
"[| equiv(A,r); congruent(r,b); a: A |] ==> (UN x:r``{a}. b(x)) = b(a)";
|
|
129 |
by (cut_facts_tac prems 1);
|
|
130 |
by (rtac ([refl RS UN_cong, UN_constant] MRS trans) 1);
|
|
131 |
by (etac equiv_class_self 2);
|
|
132 |
by (assume_tac 2);
|
|
133 |
by (rewrite_goals_tac [equiv_def,sym_def,congruent_def]);
|
|
134 |
by (Blast_tac 1);
|
|
135 |
qed "UN_equiv_class";
|
|
136 |
|
|
137 |
(*type checking of UN x:r``{a}. b(x) *)
|
|
138 |
val prems = Goalw [quotient_def]
|
|
139 |
"[| equiv(A,r); congruent(r,b); X: A/r; \
|
|
140 |
\ !!x. x : A ==> b(x) : B |] \
|
|
141 |
\ ==> (UN x:X. b(x)) : B";
|
|
142 |
by (cut_facts_tac prems 1);
|
|
143 |
by Safe_tac;
|
|
144 |
by (asm_simp_tac (simpset() addsimps UN_equiv_class::prems) 1);
|
|
145 |
qed "UN_equiv_class_type";
|
|
146 |
|
|
147 |
(*Sufficient conditions for injectiveness. Could weaken premises!
|
|
148 |
major premise could be an inclusion; bcong could be !!y. y:A ==> b(y):B
|
|
149 |
*)
|
|
150 |
val prems = Goalw [quotient_def]
|
|
151 |
"[| equiv(A,r); congruent(r,b); \
|
|
152 |
\ (UN x:X. b(x))=(UN y:Y. b(y)); X: A/r; Y: A/r; \
|
|
153 |
\ !!x y. [| x:A; y:A; b(x)=b(y) |] ==> <x,y>:r |] \
|
|
154 |
\ ==> X=Y";
|
|
155 |
by (cut_facts_tac prems 1);
|
|
156 |
by Safe_tac;
|
|
157 |
by (rtac equiv_class_eq 1);
|
|
158 |
by (REPEAT (ares_tac prems 1));
|
|
159 |
by (etac box_equals 1);
|
|
160 |
by (REPEAT (ares_tac [UN_equiv_class] 1));
|
|
161 |
qed "UN_equiv_class_inject";
|
|
162 |
|
|
163 |
|
|
164 |
(**** Defining binary operations upon equivalence classes ****)
|
|
165 |
|
|
166 |
|
|
167 |
Goalw [congruent_def,congruent2_def,equiv_def,refl_def]
|
|
168 |
"[| equiv(A,r); congruent2(r,b); a: A |] ==> congruent(r,b(a))";
|
|
169 |
by (Blast_tac 1);
|
|
170 |
qed "congruent2_implies_congruent";
|
|
171 |
|
|
172 |
val equivA::prems = goalw EquivClass.thy [congruent_def]
|
|
173 |
"[| equiv(A,r); congruent2(r,b); a: A |] ==> \
|
|
174 |
\ congruent(r, %x1. UN x2:r``{a}. b(x1,x2))";
|
|
175 |
by (cut_facts_tac (equivA::prems) 1);
|
|
176 |
by Safe_tac;
|
|
177 |
by (rtac (equivA RS equiv_type RS subsetD RS SigmaE2) 1);
|
|
178 |
by (assume_tac 1);
|
|
179 |
by (asm_simp_tac (simpset() addsimps [equivA RS UN_equiv_class,
|
|
180 |
congruent2_implies_congruent]) 1);
|
|
181 |
by (rewrite_goals_tac [congruent2_def,equiv_def,refl_def]);
|
|
182 |
by (Blast_tac 1);
|
|
183 |
qed "congruent2_implies_congruent_UN";
|
|
184 |
|
|
185 |
val prems as equivA::_ = goal EquivClass.thy
|
|
186 |
"[| equiv(A,r); congruent2(r,b); a1: A; a2: A |] \
|
|
187 |
\ ==> (UN x1:r``{a1}. UN x2:r``{a2}. b(x1,x2)) = b(a1,a2)";
|
|
188 |
by (cut_facts_tac prems 1);
|
|
189 |
by (asm_simp_tac (simpset() addsimps [equivA RS UN_equiv_class,
|
|
190 |
congruent2_implies_congruent,
|
|
191 |
congruent2_implies_congruent_UN]) 1);
|
|
192 |
qed "UN_equiv_class2";
|
|
193 |
|
|
194 |
(*type checking*)
|
|
195 |
val prems = Goalw [quotient_def]
|
|
196 |
"[| equiv(A,r); congruent2(r,b); \
|
|
197 |
\ X1: A/r; X2: A/r; \
|
|
198 |
\ !!x1 x2. [| x1: A; x2: A |] ==> b(x1,x2) : B \
|
|
199 |
\ |] ==> (UN x1:X1. UN x2:X2. b(x1,x2)) : B";
|
|
200 |
by (cut_facts_tac prems 1);
|
|
201 |
by Safe_tac;
|
|
202 |
by (REPEAT (ares_tac (prems@[UN_equiv_class_type,
|
|
203 |
congruent2_implies_congruent_UN,
|
|
204 |
congruent2_implies_congruent, quotientI]) 1));
|
|
205 |
qed "UN_equiv_class_type2";
|
|
206 |
|
|
207 |
|
|
208 |
(*Suggested by John Harrison -- the two subproofs may be MUCH simpler
|
|
209 |
than the direct proof*)
|
|
210 |
val prems = Goalw [congruent2_def,equiv_def,refl_def]
|
|
211 |
"[| equiv(A,r); \
|
|
212 |
\ !! y z w. [| w: A; <y,z> : r |] ==> b(y,w) = b(z,w); \
|
|
213 |
\ !! y z w. [| w: A; <y,z> : r |] ==> b(w,y) = b(w,z) \
|
|
214 |
\ |] ==> congruent2(r,b)";
|
|
215 |
by (cut_facts_tac prems 1);
|
|
216 |
by Safe_tac;
|
|
217 |
by (rtac trans 1);
|
|
218 |
by (REPEAT (ares_tac prems 1
|
|
219 |
ORELSE etac (subsetD RS SigmaE2) 1 THEN assume_tac 2 THEN assume_tac 1));
|
|
220 |
qed "congruent2I";
|
|
221 |
|
|
222 |
val [equivA,commute,congt] = Goal
|
|
223 |
"[| equiv(A,r); \
|
|
224 |
\ !! y z. [| y: A; z: A |] ==> b(y,z) = b(z,y); \
|
|
225 |
\ !! y z w. [| w: A; <y,z>: r |] ==> b(w,y) = b(w,z) \
|
|
226 |
\ |] ==> congruent2(r,b)";
|
|
227 |
by (resolve_tac [equivA RS congruent2I] 1);
|
|
228 |
by (rtac (commute RS trans) 1);
|
|
229 |
by (rtac (commute RS trans RS sym) 3);
|
|
230 |
by (rtac sym 5);
|
|
231 |
by (REPEAT (ares_tac [congt] 1
|
|
232 |
ORELSE etac (equivA RS equiv_type RS subsetD RS SigmaE2) 1));
|
|
233 |
qed "congruent2_commuteI";
|
|
234 |
|
|
235 |
(*Obsolete?*)
|
|
236 |
val [equivA,ZinA,congt,commute] = Goalw [quotient_def]
|
|
237 |
"[| equiv(A,r); Z: A/r; \
|
|
238 |
\ !!w. [| w: A |] ==> congruent(r, %z. b(w,z)); \
|
|
239 |
\ !!x y. [| x: A; y: A |] ==> b(y,x) = b(x,y) \
|
|
240 |
\ |] ==> congruent(r, %w. UN z: Z. b(w,z))";
|
|
241 |
val congt' = rewrite_rule [congruent_def] congt;
|
|
242 |
by (cut_facts_tac [ZinA] 1);
|
|
243 |
by (rewtac congruent_def);
|
|
244 |
by Safe_tac;
|
|
245 |
by (rtac (equivA RS equiv_type RS subsetD RS SigmaE2) 1);
|
|
246 |
by (assume_tac 1);
|
|
247 |
by (asm_simp_tac (simpset() addsimps [commute,
|
|
248 |
[equivA, congt] MRS UN_equiv_class]) 1);
|
|
249 |
by (REPEAT (ares_tac [congt' RS spec RS spec RS mp] 1));
|
|
250 |
qed "congruent_commuteI";
|