Identity Relation

Identity Relation
Definition: The identity relation on set A is defined as
iA = {(x, y) ∈ A × A|x = y}.
Example: If A = {1, 2, 3}, then iA = {(1, 1), (2, 2), (3, 3)}
What properties does this relation have? Is it reflexive, irreflexive, symmetric, anti-symmetric, and/or transitive?
1
Equivalene Relations
Example: Dierent Forms for Rational Numbers
1
2
16
= 24 = 32
:::
Even though these frations have dierent numerators and denominators, and they look dierent, they are all equal.
Equivalene relations group together objets that may appear dierent but that are equal in some sense.
Denition: Let A be a set and R be a relation on A. R is an
equivalene relation if R is reexive, symmetri and transitive.
Example:
Let A be the set of all people and let R be the relation
on A dened by:
xRy
x and y have the same birthday.
Show that R is an equivalene relation on A.
$
1
More on Equivalene Relations
Some ompilers ignore all symbols in an identier name
after some xed number of haraters. If this limit is 8, for example,
then the indentiers NumberOfSquarePegs and NumberOfRoundHoles would be the same.
Let S be the set of all strings that are legal identiers in some programming language. We an dene a relation R on S as follows:
xRy the rst eight haraters of x are the same as the rst 8
haraters of y
Example:
$
Exerise:
Prove that R is an equivalene relation.
2
Examples
Denition:
A string over a set A is a nite sequene of elements
from A. The length of a string x, denoted x , is the number of elements in the sequene. Notation: String a = a1a2:::an, where ai A
for all i
0; 1; :::; n .
2f
jj
g
2
Example: Some bit strings (strings over the set f0; 1g): 0; 110; 00000.
j110j = 3.
Example:
Let A be the set of all bit strings and dene relation R
on A as follows:
xRy
x = y .
Is R an equivalene relation?
$j j j j
3
Equivalene Classes
Denition:
Let A be a set and let R be an equivalene relation on
A. For eah element x 2 A, the equivalene lass of x, denoted
[x℄, is [x℄ = fy 2 AjxRy g.
Notation:
If it's not lear whih equivalene relation is being onsidered, we write [a℄R for the equivalene lass of a under relation R.
Let A = f1; 2; 3; 4; 5g and dene relation R on A by:
R = f(1; 1); (1; 5); (2; 2); (2; 3); (3; 2); (3; 3); (2; 4); (4; 2);
(3; 4); (4; 3); (4; 4); (5; 1); (5; 5)g.
Verify that R is an equivalene relation and nd the equivalene lass
for eah element of A.
Example:
4
More on Equivalene Relations
Denition: For integers a, b and n, we say that a is ongruent
to b mod n if n divides a b.
Notation:
a
n
b
or a b(mod n).
Example:
Congruene mod 3
7 3 1, 8 3 2, 9 3 0.
Example:
Assume a, b and n are integers and
relation R on Z as follows:
R = f(a; b)ja b(mod n)g.
Is R an equivalene relation? Prove or disprove.
5
n >
1. Dene the
More on Equivalene Classes
Reall:
Let R be an equivalene relation on set A. For
equivalene lass of x is [x℄R = fy 2 Aj(x; y ) 2 Rg.
x
2
, the
A
Denition:
Let R be an equivalene relation on set A, and let
x 2 A. For any t 2 [x℄R , t is a representative of this equivalene
lass.
Let A = f 3; 2; 1; 0; 1; 2; 3g. Dene relation R on
A suh that (a; b) 2 R $ jaj = jbj. Verify that R is an equivalene
relation, and list the equivalene lasses.
Example:
6
Equivalene Classes for ongruene mod 3
Example: Dene the equivalene lasses of 0, 1 and 2 for ongru-
ene mod 3. Do the equivalene lasses of 0 and 1 have any ommon
elements? How many (distint) equivalene lasses are there under
ongruene mod 3?
Example: Draw the digraph for the ongruent mod 3 equivalene
relation on the set A = f0; 1; 2; 3; 4; 5; 6g.
7
Equivalene Classes and Partitions
Note:
Let R be an equivalene relation on set A.
1. Then every element x
2 A is in an equivalene lass - so the union
of the equivalene lasses is the set A.
The equivalene lasses for any x; y
2.
disjoint. So [x℄ = [y ℄ or [x℄
Denition:
Then
Ai =
Ai
6
S
i=1
partition
of A if:
; for all i 2 f1; 2; :::; ng.
\ Aj
n
A are either equal or
Let A be a set and let A1 ; A2 ; :::; An be subsets of A.
fA1; A2; :::; An g is a
\ [y ℄ = ;.
2
=
; whenever i =
6 j,
all i; j
Ai = A.
8
2 f1; 2; :::; ng.
Partition Examples
Examples:
tions of A.
Let
A
= f1; 2; 3; 4; 5g. Then the following are parti-
1. ff1g; f2; 3; 4g; f5gg
2. ff1; 2; 3g; f4; 5gg
What about ff1; 5g; f2; 3g; f4; 5gg? Is it a partition of A? What
about ff1g; f2; 4; 5gg?
Dene two dierent partitions of the set of lowerase
English letters.
Example:
9
Counting
Because the members of a partition are pair-wise disjoint, if we have partitioned a finite set, the sum of the cardinalities (sizes) of each member of the
partition will equal the cardinality (size) of the partitioned set.
Formally: If {A1 , . . . , An } is a partition of A, then
Pn
i=0 |Ai |
= |A|
This fact is actually a special case of a counting rule known as the Inclusion/Exclusion Principle. The fully general version of this rule is too
complicated for this class, but consider a situation where A, B, and C are
all subsets of X, but the sets A, B, and C are NOT necessarily pair-wise
disjoint (which means they do not represent a partition).
Theorem: Inclusion/Exclusion Principle (on three sets): Let A, B, C
be subsets of X. Then
|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|
Example: Let A = {1, 2, 3}, B = {2, 3, 4, 5, 6}, C = {2, 5, 6, 7, 8}. Then
|A ∪ B ∪ C| = |{1, 2, 3, 4, 5, 6, 7, 8}| = 8, and
|A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|
= |{1, 2, 3}|+|{2, 3, 4, 5, 6}|+|{2, 5, 6, 7, 8}|−|{2, 3}|−|{2}|−|{2, 5, 6}|+|{2}|
=3+5+5−2−1−3+1
= 13 − 6 + 1 = 8
Note: Remember that this rule applies for ANY three subsets of X. They
need not be a partition. However, in the special case where {A, B, C} is a
partition of X, it is clear that the pair-wise disjointness of A, B, C will make
the above expression simplify to |A ∪ B ∪ C| = |A| + |B| + |C|.
1
More on Inclusion/Exclusion
Theorem: Inclusion/Exclusion Principle (on two sets): Let A, B be
subsets of X. Then
|A ∪ B| = |A| + |B| − |A ∩ B|
Exercise: How many integers from 1 to 1000 are either multiples of 3 or
multiples of 5?
Exercise: A class of 50 CS students has 30 who know C++, 18 who know
Haskell, and 26 who know Python. Additionally, 9 know both C++ and
Haskell, 16 know both C++ and Python, and 8 know both Haskell and
Python. 47 know at least one of the three languages. How many students
know all three languages?
2
Equivalene Classes and Partitions
Let A = f1; 2; 3; 4; 5g. Let R be the equivalene relation
on A dened by:
aRb $ a
b is even.
Example:
1. Draw the digraph of R.
2. Write down the equivalene lasses of R.
3. Is the set of equivalene lasses a partition of A?
10
Equivalence Classes and Partitions
Theorem: Assume R is an equivalence relation on a set A. Let x and y be
arbitrary elements of A. Then [x] = [y] ∨ [x] ∩ [y] = ∅.
Proof: Proof by cases.
1. Let x, y ∈ A (arbitrary)
2. Case 1: xRy (Prove [x] = [y])
3. Let z ∈ [x] (Prove [x] ⊆ [y])
4. xRz {Definition of equivalence class}
5. zRx {R is an equivalence relation, and therefore symmetric: 4}
6. zRy {R is an equivalence relation, and therefore transitive: 2,5}
7. z ∈ [y] {Definition of equivalence class}
8. Therefore [x] ⊆ [y] {Definition of subset: 3-7}
9. Let z ∈ [y] (Prove [y] ⊆ [x])
10. yRz {Definition of equivalence class}
11. zRy {R is an equivalence relation, and therefore symmetric: 10}
12. yRx {R is an equivalence relation, and therefore symmetric: 2}
13. zRx {R is an equivalence relation, and therefore transitive: 11,12}
14. z ∈ [x] {Definition of equivalence class}
15. Therefore [y] ⊆ [x] {Definition of subset: 9-14}
16. [x] = [y] {Definition of set equality: 8,15}
17. Case 2: xRy (Prove [x] ∩ [y] = ∅)
18. Assume [x] ∩ [y] 6= ∅ BWoC
19. b ∈ [x] ∩ [y] for some b {Definition of ∅, and ∃ instantiation}
20. b ∈ [x] ∧ b ∈ [y] {Definition of set intersection}
21. xRb ∧ yRb {Definition of equivalence class}
22. xRb ∧ bRy {R is an equivalence relation, and therefore symmetric}
23. xRy {R is an equivalence relation, and therefore transitive}
24. Line 23 contradicts line 17, therefore the assumption on line 18 is wrong.
25. Therefore [x] ∩ [y] = ∅
1
Equivalene Classes and Partitions
The set of equivalene lasses of an equivalene relation
R on set A is a partition of A.
Corollary:
It is also the ase that a partition of a set A orresponds to
an equivalene relation on A: Suppose A1; A2; :::; An is a partition
of A. Dene relation R on A as follows:
xRy
x; y
Ai for some i
1; 2; :::; n .
Exerise: Verify that R is an equivalene relation.
f
Note:
$
2
2f
f
g
ff g f g f g f gg
g
g
Let A = 1; 2; 3; 4; 5; 6 .
The set 1 ; 2; 6 ; 3 ; 4; 5 is a partition of A. Dene the equivalene relation determined by this partition.
Example:
12
Equivalene Relations and Set Operations
Question:
Let R and S be equivalene relations on a set A. Prove
your answers to the following questions.
1. Is
2. Is
R[S
R\S
an equivalene relation?
an equivalene relation?
13