135 |
135 |
136 |
136 |
137 subsection {* Defining unary operations upon equivalence classes *} |
137 subsection {* Defining unary operations upon equivalence classes *} |
138 |
138 |
139 locale congruent = |
139 locale congruent = |
140 fixes r and b |
140 fixes r and f |
141 assumes congruent: "(y, z) \<in> r ==> b y = b z" |
141 assumes congruent: "(y, z) \<in> r ==> f y = f z" |
142 |
142 |
143 lemma UN_constant_eq: "a \<in> A ==> \<forall>y \<in> A. b y = c ==> (\<Union>y \<in> A. b(y))=c" |
143 lemma UN_constant_eq: "a \<in> A ==> \<forall>y \<in> A. f y = c ==> (\<Union>y \<in> A. f(y))=c" |
144 -- {* lemma required to prove @{text UN_equiv_class} *} |
144 -- {* lemma required to prove @{text UN_equiv_class} *} |
145 by auto |
145 by auto |
146 |
146 |
147 lemma UN_equiv_class: |
147 lemma UN_equiv_class: |
148 "equiv A r ==> congruent r b ==> a \<in> A |
148 "equiv A r ==> congruent r f ==> a \<in> A |
149 ==> (\<Union>x \<in> r``{a}. b x) = b a" |
149 ==> (\<Union>x \<in> r``{a}. f x) = f a" |
150 -- {* Conversion rule *} |
150 -- {* Conversion rule *} |
151 apply (rule equiv_class_self [THEN UN_constant_eq], assumption+) |
151 apply (rule equiv_class_self [THEN UN_constant_eq], assumption+) |
152 apply (unfold equiv_def congruent_def sym_def) |
152 apply (unfold equiv_def congruent_def sym_def) |
153 apply (blast del: equalityI) |
153 apply (blast del: equalityI) |
154 done |
154 done |
155 |
155 |
156 lemma UN_equiv_class_type: |
156 lemma UN_equiv_class_type: |
157 "equiv A r ==> congruent r b ==> X \<in> A//r ==> |
157 "equiv A r ==> congruent r f ==> X \<in> A//r ==> |
158 (!!x. x \<in> A ==> b x : B) ==> (\<Union>x \<in> X. b x) : B" |
158 (!!x. x \<in> A ==> f x \<in> B) ==> (\<Union>x \<in> X. f x) \<in> B" |
159 apply (unfold quotient_def) |
159 apply (unfold quotient_def) |
160 apply clarify |
160 apply clarify |
161 apply (subst UN_equiv_class) |
161 apply (subst UN_equiv_class) |
162 apply auto |
162 apply auto |
163 done |
163 done |
164 |
164 |
165 text {* |
165 text {* |
166 Sufficient conditions for injectiveness. Could weaken premises! |
166 Sufficient conditions for injectiveness. Could weaken premises! |
167 major premise could be an inclusion; bcong could be @{text "!!y. y \<in> |
167 major premise could be an inclusion; bcong could be @{text "!!y. y \<in> |
168 A ==> b y \<in> B"}. |
168 A ==> f y \<in> B"}. |
169 *} |
169 *} |
170 |
170 |
171 lemma UN_equiv_class_inject: |
171 lemma UN_equiv_class_inject: |
172 "equiv A r ==> congruent r b ==> |
172 "equiv A r ==> congruent r f ==> |
173 (\<Union>x \<in> X. b x) = (\<Union>y \<in> Y. b y) ==> X \<in> A//r ==> Y \<in> A//r |
173 (\<Union>x \<in> X. f x) = (\<Union>y \<in> Y. f y) ==> X \<in> A//r ==> Y \<in> A//r |
174 ==> (!!x y. x \<in> A ==> y \<in> A ==> b x = b y ==> (x, y) \<in> r) |
174 ==> (!!x y. x \<in> A ==> y \<in> A ==> f x = f y ==> (x, y) \<in> r) |
175 ==> X = Y" |
175 ==> X = Y" |
176 apply (unfold quotient_def) |
176 apply (unfold quotient_def) |
177 apply clarify |
177 apply clarify |
178 apply (rule equiv_class_eq) |
178 apply (rule equiv_class_eq) |
179 apply assumption |
179 apply assumption |
180 apply (subgoal_tac "b x = b xa") |
180 apply (subgoal_tac "f x = f xa") |
181 apply blast |
181 apply blast |
182 apply (erule box_equals) |
182 apply (erule box_equals) |
183 apply (assumption | rule UN_equiv_class)+ |
183 apply (assumption | rule UN_equiv_class)+ |
184 done |
184 done |
185 |
185 |
186 |
186 |
187 subsection {* Defining binary operations upon equivalence classes *} |
187 subsection {* Defining binary operations upon equivalence classes *} |
188 |
188 |
189 locale congruent2 = |
189 locale congruent2 = |
190 fixes r and b |
190 fixes r and f |
191 assumes congruent2: |
191 assumes congruent2: |
192 "(y1, z1) \<in> r ==> (y2, z2) \<in> r ==> b y1 y2 = b z1 z2" |
192 "(y1, z1) \<in> r ==> (y2, z2) \<in> r ==> f y1 y2 = f z1 z2" |
193 |
193 |
194 lemma congruent2_implies_congruent: |
194 lemma congruent2_implies_congruent: |
195 "equiv A r ==> congruent2 r b ==> a \<in> A ==> congruent r (b a)" |
195 "equiv A r ==> congruent2 r f ==> a \<in> A ==> congruent r (f a)" |
196 by (unfold congruent_def congruent2_def equiv_def refl_def) blast |
196 by (unfold congruent_def congruent2_def equiv_def refl_def) blast |
197 |
197 |
198 lemma congruent2_implies_congruent_UN: |
198 lemma congruent2_implies_congruent_UN: |
199 "equiv A r ==> congruent2 r b ==> a \<in> A ==> |
199 "equiv A r ==> congruent2 r f ==> a \<in> A ==> |
200 congruent r (\<lambda>x1. \<Union>x2 \<in> r``{a}. b x1 x2)" |
200 congruent r (\<lambda>x1. \<Union>x2 \<in> r``{a}. f x1 x2)" |
201 apply (unfold congruent_def) |
201 apply (unfold congruent_def) |
202 apply clarify |
202 apply clarify |
203 apply (rule equiv_type [THEN subsetD, THEN SigmaE2], assumption+) |
203 apply (rule equiv_type [THEN subsetD, THEN SigmaE2], assumption+) |
204 apply (simp add: UN_equiv_class congruent2_implies_congruent) |
204 apply (simp add: UN_equiv_class congruent2_implies_congruent) |
205 apply (unfold congruent2_def equiv_def refl_def) |
205 apply (unfold congruent2_def equiv_def refl_def) |
206 apply (blast del: equalityI) |
206 apply (blast del: equalityI) |
207 done |
207 done |
208 |
208 |
209 lemma UN_equiv_class2: |
209 lemma UN_equiv_class2: |
210 "equiv A r ==> congruent2 r b ==> a1 \<in> A ==> a2 \<in> A |
210 "equiv A r ==> congruent2 r f ==> a1 \<in> A ==> a2 \<in> A |
211 ==> (\<Union>x1 \<in> r``{a1}. \<Union>x2 \<in> r``{a2}. b x1 x2) = b a1 a2" |
211 ==> (\<Union>x1 \<in> r``{a1}. \<Union>x2 \<in> r``{a2}. f x1 x2) = f a1 a2" |
212 by (simp add: UN_equiv_class congruent2_implies_congruent |
212 by (simp add: UN_equiv_class congruent2_implies_congruent |
213 congruent2_implies_congruent_UN) |
213 congruent2_implies_congruent_UN) |
214 |
214 |
215 lemma UN_equiv_class_type2: |
215 lemma UN_equiv_class_type2: |
216 "equiv A r ==> congruent2 r b ==> X1 \<in> A//r ==> X2 \<in> A//r |
216 "equiv A r ==> congruent2 r f ==> X1 \<in> A//r ==> X2 \<in> A//r |
217 ==> (!!x1 x2. x1 \<in> A ==> x2 \<in> A ==> b x1 x2 \<in> B) |
217 ==> (!!x1 x2. x1 \<in> A ==> x2 \<in> A ==> f x1 x2 \<in> B) |
218 ==> (\<Union>x1 \<in> X1. \<Union>x2 \<in> X2. b x1 x2) \<in> B" |
218 ==> (\<Union>x1 \<in> X1. \<Union>x2 \<in> X2. f x1 x2) \<in> B" |
219 apply (unfold quotient_def) |
219 apply (unfold quotient_def) |
220 apply clarify |
220 apply clarify |
221 apply (blast intro: UN_equiv_class_type congruent2_implies_congruent_UN |
221 apply (blast intro: UN_equiv_class_type congruent2_implies_congruent_UN |
222 congruent2_implies_congruent quotientI) |
222 congruent2_implies_congruent quotientI) |
223 done |
223 done |
229 -- {* without explicit calls to @{text split} *} |
229 -- {* without explicit calls to @{text split} *} |
230 by auto |
230 by auto |
231 |
231 |
232 lemma congruent2I: |
232 lemma congruent2I: |
233 "equiv A r |
233 "equiv A r |
234 ==> (!!y z w. w \<in> A ==> (y, z) \<in> r ==> b y w = b z w) |
234 ==> (!!y z w. w \<in> A ==> (y, z) \<in> r ==> f y w = f z w) |
235 ==> (!!y z w. w \<in> A ==> (y, z) \<in> r ==> b w y = b w z) |
235 ==> (!!y z w. w \<in> A ==> (y, z) \<in> r ==> f w y = f w z) |
236 ==> congruent2 r b" |
236 ==> congruent2 r f" |
237 -- {* Suggested by John Harrison -- the two subproofs may be *} |
237 -- {* Suggested by John Harrison -- the two subproofs may be *} |
238 -- {* \emph{much} simpler than the direct proof. *} |
238 -- {* \emph{much} simpler than the direct proof. *} |
239 apply (unfold congruent2_def equiv_def refl_def) |
239 apply (unfold congruent2_def equiv_def refl_def) |
240 apply clarify |
240 apply clarify |
241 apply (blast intro: trans) |
241 apply (blast intro: trans) |
242 done |
242 done |
243 |
243 |
244 lemma congruent2_commuteI: |
244 lemma congruent2_commuteI: |
245 assumes equivA: "equiv A r" |
245 assumes equivA: "equiv A r" |
246 and commute: "!!y z. y \<in> A ==> z \<in> A ==> b y z = b z y" |
246 and commute: "!!y z. y \<in> A ==> z \<in> A ==> f y z = f z y" |
247 and congt: "!!y z w. w \<in> A ==> (y, z) \<in> r ==> b w y = b w z" |
247 and congt: "!!y z w. w \<in> A ==> (y, z) \<in> r ==> f w y = f w z" |
248 shows "congruent2 r b" |
248 shows "congruent2 r f" |
249 apply (rule equivA [THEN congruent2I]) |
249 apply (rule equivA [THEN congruent2I]) |
250 apply (rule commute [THEN trans]) |
250 apply (rule commute [THEN trans]) |
251 apply (rule_tac [3] commute [THEN trans, symmetric]) |
251 apply (rule_tac [3] commute [THEN trans, symmetric]) |
252 apply (rule_tac [5] sym) |
252 apply (rule_tac [5] sym) |
253 apply (assumption | rule congt | |
253 apply (assumption | rule congt | |