src/HOL/Equiv_Relations.thy
author paulson <lp15@cam.ac.uk>
Wed, 28 Sep 2016 17:01:01 +0100
changeset 63952 354808e9f44b
parent 63653 4453cfb745e5
child 66364 fa3247e6ee4b
permissions -rw-r--r--
new material connected with HOL Light measure theory, plus more rationalisation
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
     1
(*  Title:      HOL/Equiv_Relations.thy
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
     2
    Author:     Lawrence C Paulson, 1996 Cambridge University Computer Laboratory
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     3
*)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     4
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
     5
section \<open>Equivalence Relations in Higher-Order Set Theory\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     6
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     7
theory Equiv_Relations
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
     8
  imports Groups_Big Relation
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
     9
begin
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    10
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    11
subsection \<open>Equivalence relations -- set version\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    12
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    13
definition equiv :: "'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    14
  where "equiv A r \<longleftrightarrow> refl_on A r \<and> sym r \<and> trans r"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    15
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    16
lemma equivI: "refl_on A r \<Longrightarrow> sym r \<Longrightarrow> trans r \<Longrightarrow> equiv A r"
40815
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    17
  by (simp add: equiv_def)
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    18
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    19
lemma equivE:
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    20
  assumes "equiv A r"
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    21
  obtains "refl_on A r" and "sym r" and "trans r"
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    22
  using assms by (simp add: equiv_def)
6e2d17cc0d1d equivI has replaced equiv.intro
haftmann
parents: 40812
diff changeset
    23
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    24
text \<open>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    25
  Suppes, Theorem 70: \<open>r\<close> is an equiv relation iff \<open>r\<inverse> O r = r\<close>.
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    26
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    27
  First half: \<open>equiv A r \<Longrightarrow> r\<inverse> O r = r\<close>.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    28
\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    29
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    30
lemma sym_trans_comp_subset: "sym r \<Longrightarrow> trans r \<Longrightarrow> r\<inverse> O r \<subseteq> r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    31
  unfolding trans_def sym_def converse_unfold by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    32
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    33
lemma refl_on_comp_subset: "refl_on A r \<Longrightarrow> r \<subseteq> r\<inverse> O r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    34
  unfolding refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    35
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    36
lemma equiv_comp_eq: "equiv A r \<Longrightarrow> r\<inverse> O r = r"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    37
  apply (unfold equiv_def)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    38
  apply clarify
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    39
  apply (rule equalityI)
30198
922f944f03b2 name changes
nipkow
parents: 29655
diff changeset
    40
   apply (iprover intro: sym_trans_comp_subset refl_on_comp_subset)+
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    41
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    42
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    43
text \<open>Second half.\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    44
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    45
lemma comp_equivI: "r\<inverse> O r = r \<Longrightarrow> Domain r = A \<Longrightarrow> equiv A r"
30198
922f944f03b2 name changes
nipkow
parents: 29655
diff changeset
    46
  apply (unfold equiv_def refl_on_def sym_def trans_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    47
  apply (erule equalityE)
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    48
  apply (subgoal_tac "\<forall>x y. (x, y) \<in> r \<longrightarrow> (y, x) \<in> r")
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    49
   apply fast
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    50
  apply fast
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    51
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    52
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    53
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    54
subsection \<open>Equivalence classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    55
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    56
lemma equiv_class_subset: "equiv A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> r``{a} \<subseteq> r``{b}"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
    57
  \<comment> \<open>lemma for the next result\<close>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    58
  unfolding equiv_def trans_def sym_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    59
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    60
theorem equiv_class_eq: "equiv A r \<Longrightarrow> (a, b) \<in> r \<Longrightarrow> r``{a} = r``{b}"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    61
  apply (assumption | rule equalityI equiv_class_subset)+
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    62
  apply (unfold equiv_def sym_def)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    63
  apply blast
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    64
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    65
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    66
lemma equiv_class_self: "equiv A r \<Longrightarrow> a \<in> A \<Longrightarrow> a \<in> r``{a}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    67
  unfolding equiv_def refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    68
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    69
lemma subset_equiv_class: "equiv A r \<Longrightarrow> r``{b} \<subseteq> r``{a} \<Longrightarrow> b \<in> A \<Longrightarrow> (a, b) \<in> r"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
    70
  \<comment> \<open>lemma for the next result\<close>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    71
  unfolding equiv_def refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    72
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    73
lemma eq_equiv_class: "r``{a} = r``{b} \<Longrightarrow> equiv A r \<Longrightarrow> b \<in> A \<Longrightarrow> (a, b) \<in> r"
17589
58eeffd73be1 renamed rules to iprover
nipkow
parents: 15539
diff changeset
    74
  by (iprover intro: equalityD2 subset_equiv_class)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    75
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    76
lemma equiv_class_nondisjoint: "equiv A r \<Longrightarrow> x \<in> (r``{a} \<inter> r``{b}) \<Longrightarrow> (a, b) \<in> r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    77
  unfolding equiv_def trans_def sym_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    78
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    79
lemma equiv_type: "equiv A r \<Longrightarrow> r \<subseteq> A \<times> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    80
  unfolding equiv_def refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    81
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    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
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    83
  by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    84
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    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
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    86
  by (blast intro!: equiv_class_eq dest: eq_equiv_class equiv_type)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    87
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    88
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
    89
subsection \<open>Quotients\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    90
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    91
definition quotient :: "'a set \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> 'a set set"  (infixl "'/'/" 90)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    92
  where "A//r = (\<Union>x \<in> A. {r``{x}})"  \<comment> \<open>set of equiv classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    93
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    94
lemma quotientI: "x \<in> A ==> r``{x} \<in> A//r"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    95
  unfolding quotient_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    96
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    97
lemma quotientE: "X \<in> A//r \<Longrightarrow> (\<And>x. X = r``{x} \<Longrightarrow> x \<in> A \<Longrightarrow> P) \<Longrightarrow> P"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
    98
  unfolding quotient_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
    99
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   100
lemma Union_quotient: "equiv A r \<Longrightarrow> \<Union>(A//r) = A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   101
  unfolding equiv_def refl_on_def quotient_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   102
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   104
  apply (unfold quotient_def)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   105
  apply clarify
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   106
  apply (rule equiv_class_eq)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   107
   apply assumption
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   108
  apply (unfold equiv_def trans_def sym_def)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   109
  apply blast
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   110
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   111
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   112
lemma quotient_eqI:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   114
  apply (clarify elim!: quotientE)
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   115
  apply (rule equiv_class_eq)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   116
   apply assumption
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   117
  apply (unfold equiv_def sym_def trans_def)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   118
  apply blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   119
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   120
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   121
lemma quotient_eq_iff:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   123
  apply (rule iffI)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   124
   prefer 2
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   125
   apply (blast del: equalityI intro: quotient_eqI)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   126
  apply (clarify elim!: quotientE)
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   127
  apply (unfold equiv_def sym_def trans_def)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   128
  apply blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   129
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   130
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   132
  by (simp add: quotient_def eq_equiv_class_iff)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   133
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   134
lemma quotient_empty [simp]: "{}//r = {}"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   135
  by (simp add: quotient_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   136
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   137
lemma quotient_is_empty [iff]: "A//r = {} \<longleftrightarrow> A = {}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   138
  by (simp add: quotient_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   139
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   140
lemma quotient_is_empty2 [iff]: "{} = A//r \<longleftrightarrow> A = {}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   141
  by (simp add: quotient_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   142
15302
a643fcbc3468 Restructured List and added "rotate"
nipkow
parents: 15300
diff changeset
   143
lemma singleton_quotient: "{x}//r = {r `` {x}}"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   144
  by (simp add: quotient_def)
15302
a643fcbc3468 Restructured List and added "rotate"
nipkow
parents: 15300
diff changeset
   145
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   146
lemma quotient_diff1: "inj_on (\<lambda>a. {a}//r) A \<Longrightarrow> a \<in> A \<Longrightarrow> (A - {a})//r = A//r - {a}//r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   147
  unfolding quotient_def inj_on_def by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   148
15302
a643fcbc3468 Restructured List and added "rotate"
nipkow
parents: 15300
diff changeset
   149
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   162
  "finite (A//R) \<Longrightarrow> R \<subseteq> S \<Longrightarrow> equiv A R \<Longrightarrow> equiv A S \<Longrightarrow> finite (A//S)"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   166
  "finite (A//R) \<Longrightarrow> R \<subseteq> S \<Longrightarrow> equiv A R \<Longrightarrow> equiv A S \<Longrightarrow> card (A//S) \<le> card (A//R)"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   167
  by (subst refines_equiv_image_eq [of R S A, symmetric])
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   171
subsection \<open>Defining unary operations upon equivalence classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   172
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   175
definition congruent :: "('a \<times> 'a) set \<Rightarrow> ('a \<Rightarrow> 'b) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   183
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   184
abbreviation RESPECTS :: "('a \<Rightarrow> 'b) \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool"  (infixr "respects" 80)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   185
  where "f respects r \<equiv> congruent r f"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   186
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   187
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   189
  \<comment> \<open>lemma required to prove \<open>UN_equiv_class\<close>\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   190
  by auto
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   191
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   193
  \<comment> \<open>Conversion rule\<close>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   194
  apply (rule equiv_class_self [THEN UN_constant_eq])
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   195
    apply assumption
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   196
   apply assumption
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   197
  apply (unfold equiv_def congruent_def sym_def)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   198
  apply (blast del: equalityI)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   199
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   200
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   201
lemma UN_equiv_class_type:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   203
  apply (unfold quotient_def)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   204
  apply clarify
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   205
  apply (subst UN_equiv_class)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   206
     apply auto
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   207
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   208
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   209
text \<open>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   210
  Sufficient conditions for injectiveness.  Could weaken premises!
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   211
  major premise could be an inclusion; \<open>bcong\<close> could be
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   212
  \<open>\<And>y. y \<in> A \<Longrightarrow> f y \<in> B\<close>.
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   213
\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   214
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   215
lemma UN_equiv_class_inject:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   216
  "equiv A r \<Longrightarrow> f respects r \<Longrightarrow>
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   217
    (\<Union>x \<in> X. f x) = (\<Union>y \<in> Y. f y) \<Longrightarrow> X \<in> A//r ==> Y \<in> A//r
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   218
    \<Longrightarrow> (\<And>x y. x \<in> A \<Longrightarrow> y \<in> A \<Longrightarrow> f x = f y \<Longrightarrow> (x, y) \<in> r)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   219
    \<Longrightarrow> X = Y"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   220
  apply (unfold quotient_def)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   221
  apply clarify
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   222
  apply (rule equiv_class_eq)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   223
   apply assumption
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   224
  apply (subgoal_tac "f x = f xa")
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   225
   apply blast
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   226
  apply (erule box_equals)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   227
   apply (assumption | rule UN_equiv_class)+
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   228
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   229
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   230
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   231
subsection \<open>Defining binary operations upon equivalence classes\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   232
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   235
definition congruent2 :: "('a \<times> 'a) set \<Rightarrow> ('b \<times> 'b) set \<Rightarrow> ('a \<Rightarrow> 'b \<Rightarrow> 'c) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
a949b2a5f51d eliminated use of empty "assms";
wenzelm
parents: 61952
diff changeset
   244
  by (auto simp add: congruent2_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   245
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   246
text \<open>Abbreviation for the common case where the relations are identical.\<close>
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   247
abbreviation RESPECTS2:: "('a \<Rightarrow> 'a \<Rightarrow> 'b) \<Rightarrow> ('a \<times> 'a) set \<Rightarrow> bool"  (infixr "respects2" 80)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   248
  where "f respects2 r \<equiv> congruent2 r r f"
19979
a0846edbe8b0 replaced translation by abbreviation
nipkow
parents: 19363
diff changeset
   249
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   250
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   251
lemma congruent2_implies_congruent:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   252
  "equiv A r1 \<Longrightarrow> congruent2 r1 r2 f \<Longrightarrow> a \<in> A \<Longrightarrow> congruent r2 (f a)"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   253
  unfolding congruent_def congruent2_def equiv_def refl_on_def by blast
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   254
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   255
lemma congruent2_implies_congruent_UN:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   256
  "equiv A1 r1 \<Longrightarrow> equiv A2 r2 \<Longrightarrow> congruent2 r1 r2 f \<Longrightarrow> a \<in> A2 \<Longrightarrow>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   257
    congruent r1 (\<lambda>x1. \<Union>x2 \<in> r2``{a}. f x1 x2)"
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   258
  apply (unfold congruent_def)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   259
  apply clarify
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   260
  apply (rule equiv_type [THEN subsetD, THEN SigmaE2], assumption+)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   261
  apply (simp add: UN_equiv_class congruent2_implies_congruent)
30198
922f944f03b2 name changes
nipkow
parents: 29655
diff changeset
   262
  apply (unfold congruent2_def equiv_def refl_on_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   263
  apply (blast del: equalityI)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   264
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   265
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   266
lemma UN_equiv_class2:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   267
  "equiv A1 r1 \<Longrightarrow> equiv A2 r2 \<Longrightarrow> congruent2 r1 r2 f \<Longrightarrow> a1 \<in> A1 \<Longrightarrow> a2 \<in> A2 \<Longrightarrow>
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   268
    (\<Union>x1 \<in> r1``{a1}. \<Union>x2 \<in> r2``{a2}. f x1 x2) = f a1 a2"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   269
  by (simp add: UN_equiv_class congruent2_implies_congruent congruent2_implies_congruent_UN)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   270
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   271
lemma UN_equiv_class_type2:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   272
  "equiv A1 r1 \<Longrightarrow> equiv A2 r2 \<Longrightarrow> congruent2 r1 r2 f
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   273
    \<Longrightarrow> X1 \<in> A1//r1 \<Longrightarrow> X2 \<in> A2//r2
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   274
    \<Longrightarrow> (\<And>x1 x2. x1 \<in> A1 \<Longrightarrow> x2 \<in> A2 \<Longrightarrow> f x1 x2 \<in> B)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   275
    \<Longrightarrow> (\<Union>x1 \<in> X1. \<Union>x2 \<in> X2. f x1 x2) \<in> B"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   276
  apply (unfold quotient_def)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   277
  apply clarify
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   278
  apply (blast intro: UN_equiv_class_type congruent2_implies_congruent_UN
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   279
      congruent2_implies_congruent quotientI)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   280
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   281
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   282
lemma UN_UN_split_split_eq:
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   283
  "(\<Union>(x1, x2) \<in> X. \<Union>(y1, y2) \<in> Y. A x1 x2 y1 y2) =
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   284
    (\<Union>x \<in> X. \<Union>y \<in> Y. (\<lambda>(x1, x2). (\<lambda>(y1, y2). A x1 x2 y1 y2) y) x)"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   285
  \<comment> \<open>Allows a natural expression of binary operators,\<close>
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   286
  \<comment> \<open>without explicit calls to \<open>split\<close>\<close>
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   287
  by auto
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   288
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   289
lemma congruent2I:
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   290
  "equiv A1 r1 \<Longrightarrow> equiv A2 r2
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   291
    \<Longrightarrow> (\<And>y z w. w \<in> A2 \<Longrightarrow> (y,z) \<in> r1 \<Longrightarrow> f y w = f z w)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   292
    \<Longrightarrow> (\<And>y z w. w \<in> A1 \<Longrightarrow> (y,z) \<in> r2 \<Longrightarrow> f w y = f w z)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   293
    \<Longrightarrow> congruent2 r1 r2 f"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   294
  \<comment> \<open>Suggested by John Harrison -- the two subproofs may be\<close>
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   295
  \<comment> \<open>\<^emph>\<open>much\<close> simpler than the direct proof.\<close>
30198
922f944f03b2 name changes
nipkow
parents: 29655
diff changeset
   296
  apply (unfold congruent2_def equiv_def refl_on_def)
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   297
  apply clarify
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   298
  apply (blast intro: trans)
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   299
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   301
lemma congruent2_commuteI:
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   302
  assumes equivA: "equiv A r"
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   303
    and commute: "\<And>y z. y \<in> A \<Longrightarrow> z \<in> A \<Longrightarrow> f y z = f z y"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   304
    and congt: "\<And>y z w. w \<in> A \<Longrightarrow> (y,z) \<in> r \<Longrightarrow> f w y = f w z"
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   305
  shows "f respects2 r"
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   306
  apply (rule congruent2I [OF equivA equivA])
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   307
   apply (rule commute [THEN trans])
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   308
     apply (rule_tac [3] commute [THEN trans, symmetric])
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   309
       apply (rule_tac [5] sym)
25482
4ed49eccb1eb dropped implicit assumption proof
haftmann
parents: 24728
diff changeset
   310
       apply (rule congt | assumption |
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   311
         erule equivA [THEN equiv_type, THEN subsetD, THEN SigmaE2])+
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   312
  done
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   313
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   314
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   315
subsection \<open>Quotients and finiteness\<close>
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   316
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   317
text \<open>Suggested by Florian Kammüller\<close>
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   318
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   319
lemma finite_quotient: "finite A \<Longrightarrow> r \<subseteq> A \<times> A \<Longrightarrow> finite (A//r)"
61799
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   320
  \<comment> \<open>recall @{thm equiv_type}\<close>
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   321
  apply (rule finite_subset)
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   322
   apply (erule_tac [2] finite_Pow_iff [THEN iffD2])
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   323
  apply (unfold quotient_def)
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   324
  apply blast
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   325
  done
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   326
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   327
lemma finite_equiv_class: "finite A \<Longrightarrow> r \<subseteq> A \<times> A \<Longrightarrow> X \<in> A//r \<Longrightarrow> finite X"
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   328
  apply (unfold quotient_def)
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   329
  apply (rule finite_subset)
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   330
   prefer 2 apply assumption
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   331
  apply blast
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   332
  done
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   333
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   336
   apply assumption
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   337
  apply (rule dvd_partition)
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   338
    prefer 3 apply (blast dest: quotient_disj)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   339
   apply (simp_all add: Union_quotient equiv_type)
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   340
  done
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   341
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   342
lemma card_quotient_disjoint: "finite A \<Longrightarrow> inj_on (\<lambda>x. {x} // r) A \<Longrightarrow> card (A//r) = card A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   343
  apply (simp add:quotient_def)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   344
  apply (subst card_UN_disjoint)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   345
     apply assumption
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   346
    apply simp
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   347
   apply (fastforce simp add:inj_on_def)
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   348
  apply simp
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   349
  done
24728
e2b3a1065676 moved Finite_Set before Datatype
haftmann
parents: 23705
diff changeset
   350
40812
ff16e22e8776 moved generic definitions about (partial) equivalence relations from Quotient to Equiv_Relations;
haftmann
parents: 37767
diff changeset
   351
60758
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   354
definition proj :: "('b \<times> 'a) set \<Rightarrow> 'b \<Rightarrow> 'a set"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   357
lemma proj_preserves: "x \<in> A \<Longrightarrow> proj r x \<in> A//r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   361
  assumes "equiv A r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   362
  shows "proj r x \<in> A//r \<longleftrightarrow> x \<in> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   363
    (is "?lhs \<longleftrightarrow> ?rhs")
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   364
proof
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   365
  assume ?rhs
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   366
  then show ?lhs by (simp add: proj_preserves)
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   367
next
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   368
  assume ?lhs
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   369
  then show ?rhs
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   370
    unfolding proj_def quotient_def
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   371
  proof clarsimp
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   372
    fix y
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   373
    assume y: "y \<in> A" and "r `` {x} = r `` {y}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   374
    moreover have "y \<in> r `` {y}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   375
      using assms y unfolding equiv_def refl_on_def by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   376
    ultimately have "(x, y) \<in> r" by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   377
    then show "x \<in> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   378
      using assms unfolding equiv_def refl_on_def by blast
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   382
lemma proj_iff: "equiv A r \<Longrightarrow> {x, y} \<subseteq> A \<Longrightarrow> proj r x = proj r y \<longleftrightarrow> (x, y) \<in> r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   390
lemma proj_image: "proj r ` A = A//r"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   393
lemma in_quotient_imp_non_empty: "equiv A r \<Longrightarrow> X \<in> A//r \<Longrightarrow> X \<noteq> {}"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   402
lemma in_quotient_imp_subset: "equiv A r \<Longrightarrow> X \<in> A//r \<Longrightarrow> X \<subseteq> A"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
d8d85a8172b5 isabelle update_cartouches;
wenzelm
parents: 60688
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   410
definition part_equivp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4cf66f21b764 isabelle update_cartouches -c -t;
wenzelm
parents: 60758
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   414
lemma part_equivpI: "\<exists>x. R x x \<Longrightarrow> symp R \<Longrightarrow> transp R \<Longrightarrow> part_equivp R"
45969
562e99c3d316 dropped references to obsolete fact `mem_def`
haftmann
parents: 44890
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   455
definition equivp :: "('a \<Rightarrow> 'a \<Rightarrow> bool) \<Rightarrow> bool"
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   458
lemma equivpI: "reflp R \<Longrightarrow> symp R \<Longrightarrow> transp R \<Longrightarrow> equivp R"
45969
562e99c3d316 dropped references to obsolete fact `mem_def`
haftmann
parents: 44890
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
63653
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   475
lemma identity_equivp: "equivp (op =)"
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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
4453cfb745e5 misc tuning and modernization;
wenzelm
parents: 63092
diff changeset
   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
05cc0dbf3a50 hide short const name
blanchet
parents: 55022
diff changeset
   487
hide_const (open) proj
05cc0dbf3a50 hide short const name
blanchet
parents: 55022
diff changeset
   488
15300
7dd5853a4812 moved and renamed Integ/Equiv.thy
paulson
parents:
diff changeset
   489
end