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