Discussion #33 Closures and Equivalence Relations Chapter

Download Report

Transcript Discussion #33 Closures and Equivalence Relations Chapter

Discussion #27
Closures & Equivalence Relations
Discussion #27
Chapter 5, Sections 4.6-7
1/15
Topics
•
•
•
•
•
Reflexive closure
Symmetric closure
Transitive closure
Equivalence relations
Partitions
Discussion #27
Chapter 5, Sections 4.6-7
2/15
Closure
Closure means adding something until done.
– Normally adding as little as possible until some
condition is satisfied
– Least fixed point similarities
Discussion #27
Chapter 5, Sections 4.6-7
3/15
Reflexive Closure
Reflexive closure of a relation: R(r)
– smallest reflexive relation that contains R (i.e.
fewest pairs added)
– R(r) = R  IA (R is a relation on a set A, and IA
is the identity relation  1’s on
the diagonal and 0’s elsewhere.)
R=
1
2
3
1
0
1
0
2
0
0
1
3
1
1
1
R(r) =
1
2
3
1
1
1
0
2
0
1
1
3
1
1
1
x (xRx)
Discussion #27
Chapter 5, Sections 4.6-7
4/15
Symmetric Closure
Symmetric closure of a relation: R(s)
– smallest symmetric relation that contains R (i.e.
fewest pairs added)
– R(s) = R  R~
(R~ is R inverse)
R=
1
2
3
1
0
1
0
2
0
0
1
3
1
1
1
R~
=
1
2
3
1
0
0
1
2
1
0
1
3
0
1
1
R
R~
=
1
2
3
1
0
1
1
2
1
0
1
3
1
1
1
xy(xRy  yRx)
Discussion #27
Chapter 5, Sections 4.6-7
5/15
Transitive Closure
Transitive closure of a relation: R(t) = R+
– smallest transitive relation that contains R (i.e.
fewest pairs added)
– for each path of length i, there must be a direct
path. (This follows from xy, yz  xz;
since, if we also have vx, we must have vz,
a path of length 3.)
– R(t) = R  R2  R3  …  R|A|. (No path can
be longer than |A|, the number of elements in
A.)
Discussion #27
Chapter 5, Sections 4.6-7
6/15
Transitive Closure – Example 1
R=
R2
R×R2
=
R3
RR2R3
Discussion #27
=
=
=
1
2
3
1
0
1
0
2
0
0
1
3
1
1
1
1
2
3
1
0
0
1
2
1
1
1
3
1
1
1
1
2
3
1
1
1
1
2
1
1
1
3
1
1
1
1
2
3
1
1
1
1
2
1
1
1
3
1
1
1
Chapter 5, Sections 4.6-7
1
2
All paths of
length 1
3
1
2
All paths of
length 2
3
1
2
All paths of
length 3
3
7/15
Transitive Closure – Example 2
R=
R2
R×R2
=
R3
RR2R3
Discussion #27
=
=
=
1
2
3
1
0
0
0
2
0
0
1
3
0
1
0
1
2
3
1
0
0
0
2
0
1
0
3
0
0
1
1
2
3
1
0
0
0
2
0
0
1
3
0
1
0
1
2
3
1
0
0
0
2
0
1
1
3
0
1
1
Chapter 5, Sections 4.6-7
1
All paths of
length 1
2
3
1
All paths of
length 2
2
3
1
2
3
All paths of
length 3
1
Paths of
any length
2
3
8/15
Reflexive Transitive Closure
• Reflexive transitive closure of a relation: R*
– smallest reflexive and transitive relation that contains R
– R* = IA  R+ = R0  R+ = R0  R1  R2  …R|A|
• Example:
IA =
R0
=
1
2
3
1
1
0
0
2
0
1
0
3
0
0
1
R0  R1  R2  R3 =
Discussion #27
R1
1
2
3
1
1
0
0
2
0
1
1
3
0
1
1

R2
Chapter 5, Sections 4.6-7

R3
=
1
2
3
1
0
0
0
2
0
1
1
3
0
1
1
1
2
3
9/15
Equivalence Relations
A relation R on a set A is an equivalence relation if R
is reflexive, symmetric, and transitive.
– Equivalence relations are about “equivalence”
– Examples:
• = for integers x = x
reflexive
x=yy=x
symmetric
x=y  y=z  x=z
transitive
• = for sets
A=A
reflexive
A=BB=A
symmetric
A=B  B=C  A=C
transitive
• Let R be “has same major as” for college students
xRx  reflexive: same major as self
xRy  yRx  symmetric: same major as each other
xRy  yRz  xRz  transitive: same as, same as  same as
Discussion #27
Chapter 5, Sections 4.6-7
10/15
Partitions
•
A partition of a set S is
–
–
•
•
a set of subsets Si=1,2,…n of S
such that ni=1 Si = S, Sj  Sk =  for j  k.
Each Si is called a block (also called an equivalence class)
Example:
–
Suppose we form teams (e.g. for a doubles tennis tournament)
from the set:
{Abe, Kay, Jim, Nan, Pat, Zed}
then teams could be:
{ {Abe, Nan}, {Kay, Jim}, {Pat, Zed} }
•
Note: “on same team as” is reflexive, symmetric,
transitive  an equivalence relation. Equivalence
relations and partitions are the same thing (two sides of
the same coin).
Discussion #27
Chapter 5, Sections 4.6-7
11/15
Partitions (continued…)
• Since individual elements can only appear in one
block (Sj  Sk =  for j  k), blocks can be
represented by any element within the block.
e.g.
Nan’s Team
Jimmer’s 2011 sweet-16 team
• Formally, [x] = set of all elements related to x and
y  [x] iff xRy
e.g.
Discussion #27
[Nan] represents {Abe, Nan}, Nan’s team
[Abe] represents {Abe, Nan}, Abe’s team
[Jimmer] represents the set of players who
played on BYU’s 2011 sweet-16 team
Chapter 5, Sections 4.6-7
12/15
Partitions & Equivalence Relations
Example:
• The mod function partitions the natural numbers into equivalence classes.
–
–
–
–
–
–
–
–
0 mod 3 = 0 so 0 forms a class [0]
1 mod 3 = 1 so 1 forms new class [1]
2 mod 3 = 2 so 2 forms new class [2]
3 mod 3 = 0 so 3 belongs to [0]
4 mod 3 = 1 so 4 belongs to [1]
5 mod 3 = 2 so 5 belongs to [2]
6 mod 3 = 0 so 6 belongs to [0]
…
• Thus, the mod function partitions the natural numbers into equivalence
classes.
– [0] = {0, 3, 6, …}
– [1] = {1, 4, 7,…}
– [2] = {2, 5, 8, …}
Discussion #27
Chapter 5, Sections 4.6-7
13/15
Partitions  Equivalence Relations
Theorem: If {S1, …, Sn} is a partition of S, then R:SS is an
equivalence relation, where R is “in same block as.”
Note: to prove that R is an equivalence relation, we must prove that
R is reflexive, symmetric, and transitive.
Proof: Reflexive: since every element is in the same block as itself.
Symmetric: since if x is in the same block as y, y is in the same
block as x. Transitive: since if x and y are in the same block and y
and z are in the same block, x and z are in the same block.
Discussion #27
Chapter 5, Sections 4.6-7
14/15
Equivalence Relations  Partitions
Theorem: If R:SS is an equivalence relation and [x] = { y | xRy },
then { [x] | x  S } is a partition P of S.
Note: to prove that we have a partition, we must prove (1) that every
element of S is in a block of P, and (2) that for every pair of distinct
blocks Sj and Sk (jk) of P, Sj  Sk = .
Proof: (1) Since R is reflexive, xRx, every element of S is at least in
its own block and thus in some block of P. (2) Suppose Sj  Sk  
for distinct blocks Sj and Sk of P. Then, at least one element y is in
both Sj and Sk. Let Sj = {y, x1, … xn} and Sk = {y, z1, … zm}, then
yRxi, i=1, 2, …, n, and yRzp, p=1, 2, …, m. Since R is symmetric,
xiRy, and since R is transitive xiRzp. But now, since the elements of Sj
are R-related to the elements of Sk, x1, …, xn, y, z1, …, zm are together
in a block of P and thus Si and Sk are not distinct blocks of P.
Discussion #27
Chapter 5, Sections 4.6-7
15/15