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