| author | wenzelm | 
| Sat, 19 Dec 2015 15:20:38 +0100 | |
| changeset 61866 | 6fa60a4f7e48 | 
| parent 61799 | 4cf66f21b764 | 
| child 61952 | 546958347e05 | 
| permissions | -rw-r--r-- | 
| 
29655
 
ac31940cfb69
Plain, Main form meeting points in import hierarchy
 
haftmann 
parents: 
28562 
diff
changeset
 | 
1  | 
(* Authors: Lawrence C Paulson, Cambridge University Computer Laboratory  | 
| 15300 | 2  | 
Copyright 1996 University of Cambridge  | 
3  | 
*)  | 
|
4  | 
||
| 60758 | 5  | 
section \<open>Equivalence Relations in Higher-Order Set Theory\<close>  | 
| 15300 | 6  | 
|
7  | 
theory Equiv_Relations  | 
|
| 
54744
 
1e7f2d296e19
more algebraic terminology for theories about big operators
 
haftmann 
parents: 
51112 
diff
changeset
 | 
8  | 
imports Groups_Big Relation  | 
| 15300 | 9  | 
begin  | 
10  | 
||
| 60758 | 11  | 
subsection \<open>Equivalence relations -- set version\<close>  | 
| 15300 | 12  | 
|
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
13  | 
definition equiv :: "'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool" where
 | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
14  | 
"equiv A r \<longleftrightarrow> refl_on A r \<and> sym r \<and> trans r"  | 
| 15300 | 15  | 
|
| 40815 | 16  | 
lemma equivI:  | 
17  | 
"refl_on A r \<Longrightarrow> sym r \<Longrightarrow> trans r \<Longrightarrow> equiv A r"  | 
|
18  | 
by (simp add: equiv_def)  | 
|
19  | 
||
20  | 
lemma equivE:  | 
|
21  | 
assumes "equiv A r"  | 
|
22  | 
obtains "refl_on A r" and "sym r" and "trans r"  | 
|
23  | 
using assms by (simp add: equiv_def)  | 
|
24  | 
||
| 60758 | 25  | 
text \<open>  | 
| 61799 | 26  | 
Suppes, Theorem 70: \<open>r\<close> is an equiv relation iff \<open>r\<inverse> O  | 
27  | 
r = r\<close>.  | 
|
| 15300 | 28  | 
|
| 61799 | 29  | 
First half: \<open>equiv A r ==> r\<inverse> O r = r\<close>.  | 
| 60758 | 30  | 
\<close>  | 
| 15300 | 31  | 
|
32  | 
lemma sym_trans_comp_subset:  | 
|
33  | 
"sym r ==> trans r ==> r\<inverse> O r \<subseteq> r"  | 
|
| 
46752
 
e9e7209eb375
more fundamental pred-to-set conversions, particularly by means of inductive_set; associated consolidation of some theorem names (c.f. NEWS)
 
haftmann 
parents: 
45969 
diff
changeset
 | 
34  | 
by (unfold trans_def sym_def converse_unfold) blast  | 
| 15300 | 35  | 
|
| 30198 | 36  | 
lemma refl_on_comp_subset: "refl_on A r ==> r \<subseteq> r\<inverse> O r"  | 
37  | 
by (unfold refl_on_def) blast  | 
|
| 15300 | 38  | 
|
39  | 
lemma equiv_comp_eq: "equiv A r ==> r\<inverse> O r = r"  | 
|
40  | 
apply (unfold equiv_def)  | 
|
41  | 
apply clarify  | 
|
42  | 
apply (rule equalityI)  | 
|
| 30198 | 43  | 
apply (iprover intro: sym_trans_comp_subset refl_on_comp_subset)+  | 
| 15300 | 44  | 
done  | 
45  | 
||
| 60758 | 46  | 
text \<open>Second half.\<close>  | 
| 15300 | 47  | 
|
48  | 
lemma comp_equivI:  | 
|
49  | 
"r\<inverse> O r = r ==> Domain r = A ==> equiv A r"  | 
|
| 30198 | 50  | 
apply (unfold equiv_def refl_on_def sym_def trans_def)  | 
| 15300 | 51  | 
apply (erule equalityE)  | 
52  | 
apply (subgoal_tac "\<forall>x y. (x, y) \<in> r --> (y, x) \<in> r")  | 
|
53  | 
apply fast  | 
|
54  | 
apply fast  | 
|
55  | 
done  | 
|
56  | 
||
57  | 
||
| 60758 | 58  | 
subsection \<open>Equivalence classes\<close>  | 
| 15300 | 59  | 
|
60  | 
lemma equiv_class_subset:  | 
|
61  | 
  "equiv A r ==> (a, b) \<in> r ==> r``{a} \<subseteq> r``{b}"
 | 
|
| 61799 | 62  | 
\<comment> \<open>lemma for the next result\<close>  | 
| 15300 | 63  | 
by (unfold equiv_def trans_def sym_def) blast  | 
64  | 
||
65  | 
theorem equiv_class_eq: "equiv A r ==> (a, b) \<in> r ==> r``{a} = r``{b}"
 | 
|
66  | 
apply (assumption | rule equalityI equiv_class_subset)+  | 
|
67  | 
apply (unfold equiv_def sym_def)  | 
|
68  | 
apply blast  | 
|
69  | 
done  | 
|
70  | 
||
71  | 
lemma equiv_class_self: "equiv A r ==> a \<in> A ==> a \<in> r``{a}"
 | 
|
| 30198 | 72  | 
by (unfold equiv_def refl_on_def) blast  | 
| 15300 | 73  | 
|
74  | 
lemma subset_equiv_class:  | 
|
75  | 
    "equiv A r ==> r``{b} \<subseteq> r``{a} ==> b \<in> A ==> (a,b) \<in> r"
 | 
|
| 61799 | 76  | 
\<comment> \<open>lemma for the next result\<close>  | 
| 30198 | 77  | 
by (unfold equiv_def refl_on_def) blast  | 
| 15300 | 78  | 
|
79  | 
lemma eq_equiv_class:  | 
|
80  | 
    "r``{a} = r``{b} ==> equiv A r ==> b \<in> A ==> (a, b) \<in> r"
 | 
|
| 17589 | 81  | 
by (iprover intro: equalityD2 subset_equiv_class)  | 
| 15300 | 82  | 
|
83  | 
lemma equiv_class_nondisjoint:  | 
|
84  | 
    "equiv A r ==> x \<in> (r``{a} \<inter> r``{b}) ==> (a, b) \<in> r"
 | 
|
85  | 
by (unfold equiv_def trans_def sym_def) blast  | 
|
86  | 
||
87  | 
lemma equiv_type: "equiv A r ==> r \<subseteq> A \<times> A"  | 
|
| 30198 | 88  | 
by (unfold equiv_def refl_on_def) blast  | 
| 15300 | 89  | 
|
90  | 
theorem equiv_class_eq_iff:  | 
|
91  | 
  "equiv A r ==> ((x, y) \<in> r) = (r``{x} = r``{y} & x \<in> A & y \<in> A)"
 | 
|
92  | 
by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type)  | 
|
93  | 
||
94  | 
theorem eq_equiv_class_iff:  | 
|
95  | 
  "equiv A r ==> x \<in> A ==> y \<in> A ==> (r``{x} = r``{y}) = ((x, y) \<in> r)"
 | 
|
96  | 
by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type)  | 
|
97  | 
||
98  | 
||
| 60758 | 99  | 
subsection \<open>Quotients\<close>  | 
| 15300 | 100  | 
|
| 28229 | 101  | 
definition quotient :: "'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a set set"  (infixl "'/'/" 90) where
 | 
| 61799 | 102  | 
  "A//r = (\<Union>x \<in> A. {r``{x}})"  \<comment> \<open>set of equiv classes\<close>
 | 
| 15300 | 103  | 
|
104  | 
lemma quotientI: "x \<in> A ==> r``{x} \<in> A//r"
 | 
|
105  | 
by (unfold quotient_def) blast  | 
|
106  | 
||
107  | 
lemma quotientE:  | 
|
108  | 
  "X \<in> A//r ==> (!!x. X = r``{x} ==> x \<in> A ==> P) ==> P"
 | 
|
109  | 
by (unfold quotient_def) blast  | 
|
110  | 
||
111  | 
lemma Union_quotient: "equiv A r ==> Union (A//r) = A"  | 
|
| 30198 | 112  | 
by (unfold equiv_def refl_on_def quotient_def) blast  | 
| 15300 | 113  | 
|
114  | 
lemma quotient_disj:  | 
|
115  | 
  "equiv A r ==> X \<in> A//r ==> Y \<in> A//r ==> X = Y | (X \<inter> Y = {})"
 | 
|
116  | 
apply (unfold quotient_def)  | 
|
117  | 
apply clarify  | 
|
118  | 
apply (rule equiv_class_eq)  | 
|
119  | 
apply assumption  | 
|
120  | 
apply (unfold equiv_def trans_def sym_def)  | 
|
121  | 
apply blast  | 
|
122  | 
done  | 
|
123  | 
||
124  | 
lemma quotient_eqI:  | 
|
125  | 
"[|equiv A r; X \<in> A//r; Y \<in> A//r; x \<in> X; y \<in> Y; (x,y) \<in> r|] ==> X = Y"  | 
|
126  | 
apply (clarify elim!: quotientE)  | 
|
127  | 
apply (rule equiv_class_eq, assumption)  | 
|
128  | 
apply (unfold equiv_def sym_def trans_def, blast)  | 
|
129  | 
done  | 
|
130  | 
||
131  | 
lemma quotient_eq_iff:  | 
|
132  | 
"[|equiv A r; X \<in> A//r; Y \<in> A//r; x \<in> X; y \<in> Y|] ==> (X = Y) = ((x,y) \<in> r)"  | 
|
133  | 
apply (rule iffI)  | 
|
134  | 
prefer 2 apply (blast del: equalityI intro: quotient_eqI)  | 
|
135  | 
apply (clarify elim!: quotientE)  | 
|
136  | 
apply (unfold equiv_def sym_def trans_def, blast)  | 
|
137  | 
done  | 
|
138  | 
||
| 18493 | 139  | 
lemma eq_equiv_class_iff2:  | 
140  | 
  "\<lbrakk> equiv A r; x \<in> A; y \<in> A \<rbrakk> \<Longrightarrow> ({x}//r = {y}//r) = ((x,y) : r)"
 | 
|
141  | 
by(simp add:quotient_def eq_equiv_class_iff)  | 
|
142  | 
||
| 15300 | 143  | 
|
144  | 
lemma quotient_empty [simp]: "{}//r = {}"
 | 
|
145  | 
by(simp add: quotient_def)  | 
|
146  | 
||
147  | 
lemma quotient_is_empty [iff]: "(A//r = {}) = (A = {})"
 | 
|
148  | 
by(simp add: quotient_def)  | 
|
149  | 
||
150  | 
lemma quotient_is_empty2 [iff]: "({} = A//r) = (A = {})"
 | 
|
151  | 
by(simp add: quotient_def)  | 
|
152  | 
||
153  | 
||
| 15302 | 154  | 
lemma singleton_quotient: "{x}//r = {r `` {x}}"
 | 
155  | 
by(simp add:quotient_def)  | 
|
156  | 
||
157  | 
lemma quotient_diff1:  | 
|
158  | 
  "\<lbrakk> inj_on (%a. {a}//r) A; a \<in> A \<rbrakk> \<Longrightarrow> (A - {a})//r = A//r - {a}//r"
 | 
|
159  | 
apply(simp add:quotient_def inj_on_def)  | 
|
160  | 
apply blast  | 
|
161  | 
done  | 
|
162  | 
||
| 60758 | 163  | 
subsection \<open>Refinement of one equivalence relation WRT another\<close>  | 
| 
59528
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
164  | 
|
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
165  | 
lemma refines_equiv_class_eq:  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
166  | 
   "\<lbrakk>R \<subseteq> S; equiv A R; equiv A S\<rbrakk> \<Longrightarrow> R``(S``{a}) = S``{a}"
 | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
167  | 
by (auto simp: equiv_class_eq_iff)  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
168  | 
|
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
169  | 
lemma refines_equiv_class_eq2:  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
170  | 
   "\<lbrakk>R \<subseteq> S; equiv A R; equiv A S\<rbrakk> \<Longrightarrow> S``(R``{a}) = S``{a}"
 | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
171  | 
by (auto simp: equiv_class_eq_iff)  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
172  | 
|
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
173  | 
lemma refines_equiv_image_eq:  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
174  | 
"\<lbrakk>R \<subseteq> S; equiv A R; equiv A S\<rbrakk> \<Longrightarrow> (\<lambda>X. S``X) ` (A//R) = A//S"  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
175  | 
by (auto simp: quotient_def image_UN refines_equiv_class_eq2)  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
176  | 
|
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
177  | 
lemma finite_refines_finite:  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
178  | 
"\<lbrakk>finite (A//R); R \<subseteq> S; equiv A R; equiv A S\<rbrakk> \<Longrightarrow> finite (A//S)"  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
179  | 
apply (erule finite_surj [where f = "\<lambda>X. S``X"])  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
180  | 
apply (simp add: refines_equiv_image_eq)  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
181  | 
done  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
182  | 
|
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
183  | 
lemma finite_refines_card_le:  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
184  | 
"\<lbrakk>finite (A//R); R \<subseteq> S; equiv A R; equiv A S\<rbrakk> \<Longrightarrow> card (A//S) \<le> card (A//R)"  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
185  | 
apply (subst refines_equiv_image_eq [of R S A, symmetric])  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
186  | 
apply (auto simp: card_image_le [where f = "\<lambda>X. S``X"])  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
187  | 
done  | 
| 
 
4862f3dc9540
new lemmas re refinement of one equivalence relation WRT another
 
paulson <lp15@cam.ac.uk> 
parents: 
58889 
diff
changeset
 | 
188  | 
|
| 
55022
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
189  | 
|
| 60758 | 190  | 
subsection \<open>Defining unary operations upon equivalence classes\<close>  | 
| 15300 | 191  | 
|
| 60758 | 192  | 
text\<open>A congruence-preserving function\<close>  | 
| 
40816
 
19c492929756
replaced slightly odd locale congruent by plain definition
 
haftmann 
parents: 
40815 
diff
changeset
 | 
193  | 
|
| 
44278
 
1220ecb81e8f
observe distinction between sets and predicates more properly
 
haftmann 
parents: 
44204 
diff
changeset
 | 
194  | 
definition congruent :: "('a \<times> 'a) set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"  where
 | 
| 
40817
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
195  | 
"congruent r f \<longleftrightarrow> (\<forall>(y, z) \<in> r. f y = f z)"  | 
| 
40816
 
19c492929756
replaced slightly odd locale congruent by plain definition
 
haftmann 
parents: 
40815 
diff
changeset
 | 
196  | 
|
| 
 
19c492929756
replaced slightly odd locale congruent by plain definition
 
haftmann 
parents: 
40815 
diff
changeset
 | 
197  | 
lemma congruentI:  | 
| 
 
19c492929756
replaced slightly odd locale congruent by plain definition
 
haftmann 
parents: 
40815 
diff
changeset
 | 
198  | 
"(\<And>y z. (y, z) \<in> r \<Longrightarrow> f y = f z) \<Longrightarrow> congruent r f"  | 
| 
40817
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
199  | 
by (auto simp add: congruent_def)  | 
| 
40816
 
19c492929756
replaced slightly odd locale congruent by plain definition
 
haftmann 
parents: 
40815 
diff
changeset
 | 
200  | 
|
| 
 
19c492929756
replaced slightly odd locale congruent by plain definition
 
haftmann 
parents: 
40815 
diff
changeset
 | 
201  | 
lemma congruentD:  | 
| 
 
19c492929756
replaced slightly odd locale congruent by plain definition
 
haftmann 
parents: 
40815 
diff
changeset
 | 
202  | 
"congruent r f \<Longrightarrow> (y, z) \<in> r \<Longrightarrow> f y = f z"  | 
| 
40817
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
203  | 
by (auto simp add: congruent_def)  | 
| 15300 | 204  | 
|
| 19363 | 205  | 
abbreviation  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19979 
diff
changeset
 | 
206  | 
  RESPECTS :: "('a => 'b) => ('a * 'a) set => bool"
 | 
| 
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19979 
diff
changeset
 | 
207  | 
(infixr "respects" 80) where  | 
| 19363 | 208  | 
"f respects r == congruent r f"  | 
| 15300 | 209  | 
|
210  | 
||
211  | 
lemma UN_constant_eq: "a \<in> A ==> \<forall>y \<in> A. f y = c ==> (\<Union>y \<in> A. f(y))=c"  | 
|
| 61799 | 212  | 
\<comment> \<open>lemma required to prove \<open>UN_equiv_class\<close>\<close>  | 
| 15300 | 213  | 
by auto  | 
214  | 
||
215  | 
lemma UN_equiv_class:  | 
|
216  | 
"equiv A r ==> f respects r ==> a \<in> A  | 
|
217  | 
    ==> (\<Union>x \<in> r``{a}. f x) = f a"
 | 
|
| 61799 | 218  | 
\<comment> \<open>Conversion rule\<close>  | 
| 15300 | 219  | 
apply (rule equiv_class_self [THEN UN_constant_eq], assumption+)  | 
220  | 
apply (unfold equiv_def congruent_def sym_def)  | 
|
221  | 
apply (blast del: equalityI)  | 
|
222  | 
done  | 
|
223  | 
||
224  | 
lemma UN_equiv_class_type:  | 
|
225  | 
"equiv A r ==> f respects r ==> X \<in> A//r ==>  | 
|
226  | 
(!!x. x \<in> A ==> f x \<in> B) ==> (\<Union>x \<in> X. f x) \<in> B"  | 
|
227  | 
apply (unfold quotient_def)  | 
|
228  | 
apply clarify  | 
|
229  | 
apply (subst UN_equiv_class)  | 
|
230  | 
apply auto  | 
|
231  | 
done  | 
|
232  | 
||
| 60758 | 233  | 
text \<open>  | 
| 15300 | 234  | 
Sufficient conditions for injectiveness. Could weaken premises!  | 
| 61799 | 235  | 
major premise could be an inclusion; bcong could be \<open>!!y. y \<in>  | 
236  | 
A ==> f y \<in> B\<close>.  | 
|
| 60758 | 237  | 
\<close>  | 
| 15300 | 238  | 
|
239  | 
lemma UN_equiv_class_inject:  | 
|
240  | 
"equiv A r ==> f respects r ==>  | 
|
241  | 
(\<Union>x \<in> X. f x) = (\<Union>y \<in> Y. f y) ==> X \<in> A//r ==> Y \<in> A//r  | 
|
242  | 
==> (!!x y. x \<in> A ==> y \<in> A ==> f x = f y ==> (x, y) \<in> r)  | 
|
243  | 
==> X = Y"  | 
|
244  | 
apply (unfold quotient_def)  | 
|
245  | 
apply clarify  | 
|
246  | 
apply (rule equiv_class_eq)  | 
|
247  | 
apply assumption  | 
|
248  | 
apply (subgoal_tac "f x = f xa")  | 
|
249  | 
apply blast  | 
|
250  | 
apply (erule box_equals)  | 
|
251  | 
apply (assumption | rule UN_equiv_class)+  | 
|
252  | 
done  | 
|
253  | 
||
254  | 
||
| 60758 | 255  | 
subsection \<open>Defining binary operations upon equivalence classes\<close>  | 
| 15300 | 256  | 
|
| 60758 | 257  | 
text\<open>A congruence-preserving function of two arguments\<close>  | 
| 
40817
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
258  | 
|
| 
44278
 
1220ecb81e8f
observe distinction between sets and predicates more properly
 
haftmann 
parents: 
44204 
diff
changeset
 | 
259  | 
definition congruent2 :: "('a \<times> 'a) set \<Rightarrow> ('b \<times> 'b) set \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> bool" where
 | 
| 
40817
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
260  | 
"congruent2 r1 r2 f \<longleftrightarrow> (\<forall>(y1, z1) \<in> r1. \<forall>(y2, z2) \<in> r2. f y1 y2 = f z1 z2)"  | 
| 
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
261  | 
|
| 
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
262  | 
lemma congruent2I':  | 
| 
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
263  | 
assumes "\<And>y1 z1 y2 z2. (y1, z1) \<in> r1 \<Longrightarrow> (y2, z2) \<in> r2 \<Longrightarrow> f y1 y2 = f z1 z2"  | 
| 
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
264  | 
shows "congruent2 r1 r2 f"  | 
| 
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
265  | 
using assms by (auto simp add: congruent2_def)  | 
| 
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
266  | 
|
| 
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
267  | 
lemma congruent2D:  | 
| 
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
268  | 
"congruent2 r1 r2 f \<Longrightarrow> (y1, z1) \<in> r1 \<Longrightarrow> (y2, z2) \<in> r2 \<Longrightarrow> f y1 y2 = f z1 z2"  | 
| 
 
781da1e8808c
replaced slightly odd locale congruent2 by plain definition
 
haftmann 
parents: 
40816 
diff
changeset
 | 
269  | 
using assms by (auto simp add: congruent2_def)  | 
| 15300 | 270  | 
|
| 60758 | 271  | 
text\<open>Abbreviation for the common case where the relations are identical\<close>  | 
| 19979 | 272  | 
abbreviation  | 
| 
21404
 
eb85850d3eb7
more robust syntax for definition/abbreviation/notation;
 
wenzelm 
parents: 
19979 
diff
changeset
 | 
273  | 
  RESPECTS2:: "['a => 'a => 'b, ('a * 'a) set] => bool"
 | 
| 21749 | 274  | 
(infixr "respects2" 80) where  | 
| 19979 | 275  | 
"f respects2 r == congruent2 r r f"  | 
276  | 
||
| 15300 | 277  | 
|
278  | 
lemma congruent2_implies_congruent:  | 
|
279  | 
"equiv A r1 ==> congruent2 r1 r2 f ==> a \<in> A ==> congruent r2 (f a)"  | 
|
| 30198 | 280  | 
by (unfold congruent_def congruent2_def equiv_def refl_on_def) blast  | 
| 15300 | 281  | 
|
282  | 
lemma congruent2_implies_congruent_UN:  | 
|
283  | 
"equiv A1 r1 ==> equiv A2 r2 ==> congruent2 r1 r2 f ==> a \<in> A2 ==>  | 
|
284  | 
    congruent r1 (\<lambda>x1. \<Union>x2 \<in> r2``{a}. f x1 x2)"
 | 
|
285  | 
apply (unfold congruent_def)  | 
|
286  | 
apply clarify  | 
|
287  | 
apply (rule equiv_type [THEN subsetD, THEN SigmaE2], assumption+)  | 
|
288  | 
apply (simp add: UN_equiv_class congruent2_implies_congruent)  | 
|
| 30198 | 289  | 
apply (unfold congruent2_def equiv_def refl_on_def)  | 
| 15300 | 290  | 
apply (blast del: equalityI)  | 
291  | 
done  | 
|
292  | 
||
293  | 
lemma UN_equiv_class2:  | 
|
294  | 
"equiv A1 r1 ==> equiv A2 r2 ==> congruent2 r1 r2 f ==> a1 \<in> A1 ==> a2 \<in> A2  | 
|
295  | 
    ==> (\<Union>x1 \<in> r1``{a1}. \<Union>x2 \<in> r2``{a2}. f x1 x2) = f a1 a2"
 | 
|
296  | 
by (simp add: UN_equiv_class congruent2_implies_congruent  | 
|
297  | 
congruent2_implies_congruent_UN)  | 
|
298  | 
||
299  | 
lemma UN_equiv_class_type2:  | 
|
300  | 
"equiv A1 r1 ==> equiv A2 r2 ==> congruent2 r1 r2 f  | 
|
301  | 
==> X1 \<in> A1//r1 ==> X2 \<in> A2//r2  | 
|
302  | 
==> (!!x1 x2. x1 \<in> A1 ==> x2 \<in> A2 ==> f x1 x2 \<in> B)  | 
|
303  | 
==> (\<Union>x1 \<in> X1. \<Union>x2 \<in> X2. f x1 x2) \<in> B"  | 
|
304  | 
apply (unfold quotient_def)  | 
|
305  | 
apply clarify  | 
|
306  | 
apply (blast intro: UN_equiv_class_type congruent2_implies_congruent_UN  | 
|
307  | 
congruent2_implies_congruent quotientI)  | 
|
308  | 
done  | 
|
309  | 
||
310  | 
lemma UN_UN_split_split_eq:  | 
|
311  | 
"(\<Union>(x1, x2) \<in> X. \<Union>(y1, y2) \<in> Y. A x1 x2 y1 y2) =  | 
|
312  | 
(\<Union>x \<in> X. \<Union>y \<in> Y. (\<lambda>(x1, x2). (\<lambda>(y1, y2). A x1 x2 y1 y2) y) x)"  | 
|
| 61799 | 313  | 
\<comment> \<open>Allows a natural expression of binary operators,\<close>  | 
314  | 
\<comment> \<open>without explicit calls to \<open>split\<close>\<close>  | 
|
| 15300 | 315  | 
by auto  | 
316  | 
||
317  | 
lemma congruent2I:  | 
|
318  | 
"equiv A1 r1 ==> equiv A2 r2  | 
|
319  | 
==> (!!y z w. w \<in> A2 ==> (y,z) \<in> r1 ==> f y w = f z w)  | 
|
320  | 
==> (!!y z w. w \<in> A1 ==> (y,z) \<in> r2 ==> f w y = f w z)  | 
|
321  | 
==> congruent2 r1 r2 f"  | 
|
| 61799 | 322  | 
\<comment> \<open>Suggested by John Harrison -- the two subproofs may be\<close>  | 
323  | 
  \<comment> \<open>\emph{much} simpler than the direct proof.\<close>
 | 
|
| 30198 | 324  | 
apply (unfold congruent2_def equiv_def refl_on_def)  | 
| 15300 | 325  | 
apply clarify  | 
326  | 
apply (blast intro: trans)  | 
|
327  | 
done  | 
|
328  | 
||
329  | 
lemma congruent2_commuteI:  | 
|
330  | 
assumes equivA: "equiv A r"  | 
|
331  | 
and commute: "!!y z. y \<in> A ==> z \<in> A ==> f y z = f z y"  | 
|
332  | 
and congt: "!!y z w. w \<in> A ==> (y,z) \<in> r ==> f w y = f w z"  | 
|
333  | 
shows "f respects2 r"  | 
|
334  | 
apply (rule congruent2I [OF equivA equivA])  | 
|
335  | 
apply (rule commute [THEN trans])  | 
|
336  | 
apply (rule_tac [3] commute [THEN trans, symmetric])  | 
|
337  | 
apply (rule_tac [5] sym)  | 
|
| 25482 | 338  | 
apply (rule congt | assumption |  | 
| 15300 | 339  | 
erule equivA [THEN equiv_type, THEN subsetD, THEN SigmaE2])+  | 
340  | 
done  | 
|
341  | 
||
| 24728 | 342  | 
|
| 60758 | 343  | 
subsection \<open>Quotients and finiteness\<close>  | 
| 24728 | 344  | 
|
| 60758 | 345  | 
text \<open>Suggested by Florian Kammüller\<close>  | 
| 24728 | 346  | 
|
347  | 
lemma finite_quotient: "finite A ==> r \<subseteq> A \<times> A ==> finite (A//r)"  | 
|
| 61799 | 348  | 
  \<comment> \<open>recall @{thm equiv_type}\<close>
 | 
| 24728 | 349  | 
apply (rule finite_subset)  | 
350  | 
apply (erule_tac [2] finite_Pow_iff [THEN iffD2])  | 
|
351  | 
apply (unfold quotient_def)  | 
|
352  | 
apply blast  | 
|
353  | 
done  | 
|
354  | 
||
355  | 
lemma finite_equiv_class:  | 
|
356  | 
"finite A ==> r \<subseteq> A \<times> A ==> X \<in> A//r ==> finite X"  | 
|
357  | 
apply (unfold quotient_def)  | 
|
358  | 
apply (rule finite_subset)  | 
|
359  | 
prefer 2 apply assumption  | 
|
360  | 
apply blast  | 
|
361  | 
done  | 
|
362  | 
||
363  | 
lemma equiv_imp_dvd_card:  | 
|
364  | 
"finite A ==> equiv A r ==> \<forall>X \<in> A//r. k dvd card X  | 
|
365  | 
==> k dvd card A"  | 
|
| 
26791
 
3581a9c71909
Instantiated subst rule to avoid problems with HO unification.
 
berghofe 
parents: 
25482 
diff
changeset
 | 
366  | 
apply (rule Union_quotient [THEN subst [where P="\<lambda>A. k dvd card A"]])  | 
| 24728 | 367  | 
apply assumption  | 
368  | 
apply (rule dvd_partition)  | 
|
369  | 
prefer 3 apply (blast dest: quotient_disj)  | 
|
370  | 
apply (simp_all add: Union_quotient equiv_type)  | 
|
371  | 
done  | 
|
372  | 
||
373  | 
lemma card_quotient_disjoint:  | 
|
374  | 
 "\<lbrakk> finite A; inj_on (\<lambda>x. {x} // r) A \<rbrakk> \<Longrightarrow> card(A//r) = card A"
 | 
|
375  | 
apply(simp add:quotient_def)  | 
|
376  | 
apply(subst card_UN_disjoint)  | 
|
377  | 
apply assumption  | 
|
378  | 
apply simp  | 
|
| 
44890
 
22f665a2e91c
new fastforce replacing fastsimp - less confusing name
 
nipkow 
parents: 
44279 
diff
changeset
 | 
379  | 
apply(fastforce simp add:inj_on_def)  | 
| 35216 | 380  | 
apply simp  | 
| 24728 | 381  | 
done  | 
382  | 
||
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
383  | 
|
| 60758 | 384  | 
subsection \<open>Projection\<close>  | 
| 
55022
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
385  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
386  | 
definition proj where "proj r x = r `` {x}"
 | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
387  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
388  | 
lemma proj_preserves:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
389  | 
"x \<in> A \<Longrightarrow> proj r x \<in> A//r"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
390  | 
unfolding proj_def by (rule quotientI)  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
391  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
392  | 
lemma proj_in_iff:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
393  | 
assumes "equiv A r"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
394  | 
shows "(proj r x \<in> A//r) = (x \<in> A)"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
395  | 
apply(rule iffI, auto simp add: proj_preserves)  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
396  | 
unfolding proj_def quotient_def proof clarsimp  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
397  | 
  fix y assume y: "y \<in> A" and "r `` {x} = r `` {y}"
 | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
398  | 
  moreover have "y \<in> r `` {y}" using assms y unfolding equiv_def refl_on_def by blast
 | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
399  | 
ultimately have "(x,y) \<in> r" by blast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
400  | 
thus "x \<in> A" using assms unfolding equiv_def refl_on_def by blast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
401  | 
qed  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
402  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
403  | 
lemma proj_iff:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
404  | 
"\<lbrakk>equiv A r; {x,y} \<subseteq> A\<rbrakk> \<Longrightarrow> (proj r x = proj r y) = ((x,y) \<in> r)"
 | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
405  | 
by (simp add: proj_def eq_equiv_class_iff)  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
406  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
407  | 
(*  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
408  | 
lemma in_proj: "\<lbrakk>equiv A r; x \<in> A\<rbrakk> \<Longrightarrow> x \<in> proj r x"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
409  | 
unfolding proj_def equiv_def refl_on_def by blast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
410  | 
*)  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
411  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
412  | 
lemma proj_image: "(proj r) ` A = A//r"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
413  | 
unfolding proj_def[abs_def] quotient_def by blast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
414  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
415  | 
lemma in_quotient_imp_non_empty:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
416  | 
"\<lbrakk>equiv A r; X \<in> A//r\<rbrakk> \<Longrightarrow> X \<noteq> {}"
 | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
417  | 
unfolding quotient_def using equiv_class_self by fast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
418  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
419  | 
lemma in_quotient_imp_in_rel:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
420  | 
"\<lbrakk>equiv A r; X \<in> A//r; {x,y} \<subseteq> X\<rbrakk> \<Longrightarrow> (x,y) \<in> r"
 | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
421  | 
using quotient_eq_iff[THEN iffD1] by fastforce  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
422  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
423  | 
lemma in_quotient_imp_closed:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
424  | 
"\<lbrakk>equiv A r; X \<in> A//r; x \<in> X; (x,y) \<in> r\<rbrakk> \<Longrightarrow> y \<in> X"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
425  | 
unfolding quotient_def equiv_def trans_def by blast  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
426  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
427  | 
lemma in_quotient_imp_subset:  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
428  | 
"\<lbrakk>equiv A r; X \<in> A//r\<rbrakk> \<Longrightarrow> X \<subseteq> A"  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
429  | 
using assms in_quotient_imp_in_rel equiv_type by fastforce  | 
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
430  | 
|
| 
 
eeba3ba73486
liquidated 'Equiv_Relations_More' -- distinguished between choice-dependent parts and choice-independent parts
 
blanchet 
parents: 
54744 
diff
changeset
 | 
431  | 
|
| 60758 | 432  | 
subsection \<open>Equivalence relations -- predicate version\<close>  | 
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
433  | 
|
| 60758 | 434  | 
text \<open>Partial equivalences\<close>  | 
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
435  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
436  | 
definition part_equivp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
 | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
437  | 
"part_equivp R \<longleftrightarrow> (\<exists>x. R x x) \<and> (\<forall>x y. R x y \<longleftrightarrow> R x x \<and> R y y \<and> R x = R y)"  | 
| 61799 | 438  | 
\<comment> \<open>John-Harrison-style characterization\<close>  | 
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
439  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
440  | 
lemma part_equivpI:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
441  | 
"(\<exists>x. R x x) \<Longrightarrow> symp R \<Longrightarrow> transp R \<Longrightarrow> part_equivp R"  | 
| 45969 | 442  | 
by (auto simp add: part_equivp_def) (auto elim: sympE transpE)  | 
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
443  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
444  | 
lemma part_equivpE:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
445  | 
assumes "part_equivp R"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
446  | 
obtains x where "R x x" and "symp R" and "transp R"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
447  | 
proof -  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
448  | 
from assms have 1: "\<exists>x. R x x"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
449  | 
and 2: "\<And>x y. R x y \<longleftrightarrow> R x x \<and> R y y \<and> R x = R y"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
450  | 
by (unfold part_equivp_def) blast+  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
451  | 
from 1 obtain x where "R x x" ..  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
452  | 
moreover have "symp R"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
453  | 
proof (rule sympI)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
454  | 
fix x y  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
455  | 
assume "R x y"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
456  | 
with 2 [of x y] show "R y x" by auto  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
457  | 
qed  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
458  | 
moreover have "transp R"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
459  | 
proof (rule transpI)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
460  | 
fix x y z  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
461  | 
assume "R x y" and "R y z"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
462  | 
with 2 [of x y] 2 [of y z] show "R x z" by auto  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
463  | 
qed  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
464  | 
ultimately show thesis by (rule that)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
465  | 
qed  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
466  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
467  | 
lemma part_equivp_refl_symp_transp:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
468  | 
"part_equivp R \<longleftrightarrow> (\<exists>x. R x x) \<and> symp R \<and> transp R"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
469  | 
by (auto intro: part_equivpI elim: part_equivpE)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
470  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
471  | 
lemma part_equivp_symp:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
472  | 
"part_equivp R \<Longrightarrow> R x y \<Longrightarrow> R y x"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
473  | 
by (erule part_equivpE, erule sympE)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
474  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
475  | 
lemma part_equivp_transp:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
476  | 
"part_equivp R \<Longrightarrow> R x y \<Longrightarrow> R y z \<Longrightarrow> R x z"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
477  | 
by (erule part_equivpE, erule transpE)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
478  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
479  | 
lemma part_equivp_typedef:  | 
| 
44204
 
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
 
Cezary Kaliszyk <kaliszyk@in.tum.de> 
parents: 
40945 
diff
changeset
 | 
480  | 
  "part_equivp R \<Longrightarrow> \<exists>d. d \<in> {c. \<exists>x. R x x \<and> c = Collect (R x)}"
 | 
| 
 
3cdc4176638c
Quotient Package: make quotient_type work with separate set type
 
Cezary Kaliszyk <kaliszyk@in.tum.de> 
parents: 
40945 
diff
changeset
 | 
481  | 
by (auto elim: part_equivpE)  | 
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
482  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
483  | 
|
| 60758 | 484  | 
text \<open>Total equivalences\<close>  | 
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
485  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
486  | 
definition equivp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool" where
 | 
| 61799 | 487  | 
"equivp R \<longleftrightarrow> (\<forall>x y. R x y = (R x = R y))" \<comment> \<open>John-Harrison-style characterization\<close>  | 
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
488  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
489  | 
lemma equivpI:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
490  | 
"reflp R \<Longrightarrow> symp R \<Longrightarrow> transp R \<Longrightarrow> equivp R"  | 
| 45969 | 491  | 
by (auto elim: reflpE sympE transpE simp add: equivp_def)  | 
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
492  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
493  | 
lemma equivpE:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
494  | 
assumes "equivp R"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
495  | 
obtains "reflp R" and "symp R" and "transp R"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
496  | 
using assms by (auto intro!: that reflpI sympI transpI simp add: equivp_def)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
497  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
498  | 
lemma equivp_implies_part_equivp:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
499  | 
"equivp R \<Longrightarrow> part_equivp R"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
500  | 
by (auto intro: part_equivpI elim: equivpE reflpE)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
501  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
502  | 
lemma equivp_equiv:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
503  | 
"equiv UNIV A \<longleftrightarrow> equivp (\<lambda>x y. (x, y) \<in> A)"  | 
| 
46752
 
e9e7209eb375
more fundamental pred-to-set conversions, particularly by means of inductive_set; associated consolidation of some theorem names (c.f. NEWS)
 
haftmann 
parents: 
45969 
diff
changeset
 | 
504  | 
by (auto intro!: equivI equivpI [to_set] elim!: equivE equivpE [to_set])  | 
| 
40812
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
505  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
506  | 
lemma equivp_reflp_symp_transp:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
507  | 
shows "equivp R \<longleftrightarrow> reflp R \<and> symp R \<and> transp R"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
508  | 
by (auto intro: equivpI elim: equivpE)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
509  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
510  | 
lemma identity_equivp:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
511  | 
"equivp (op =)"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
512  | 
by (auto intro: equivpI reflpI sympI transpI)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
513  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
514  | 
lemma equivp_reflp:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
515  | 
"equivp R \<Longrightarrow> R x x"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
516  | 
by (erule equivpE, erule reflpE)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
517  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
518  | 
lemma equivp_symp:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
519  | 
"equivp R \<Longrightarrow> R x y \<Longrightarrow> R y x"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
520  | 
by (erule equivpE, erule sympE)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
521  | 
|
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
522  | 
lemma equivp_transp:  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
523  | 
"equivp R \<Longrightarrow> R x y \<Longrightarrow> R y z \<Longrightarrow> R x z"  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
524  | 
by (erule equivpE, erule transpE)  | 
| 
 
ff16e22e8776
moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
 
haftmann 
parents: 
37767 
diff
changeset
 | 
525  | 
|
| 55024 | 526  | 
hide_const (open) proj  | 
527  | 
||
| 15300 | 528  | 
end  |