This document discusses binary relations and their properties. A binary relation R from sets A to B is a subset of the Cartesian product A × B. Relations can be represented using matrices, where the (i,j) entry is 1 if the element (i,j) is in the relation and 0 otherwise. The properties of relations discussed include: reflexive (an element is related to itself), symmetric (if a is related to b then b is related to a), antisymmetric (if a is related to b and b is related to a then a=b), and transitive (if a is related to b and b is related to c then a is related to c). Boolean operations can be used on the matrices
1. Fall 2002 CMSC 203 - Discrete Structures 1
You Never Escape Your…You Never Escape Your…
RelationsRelations
2. Fall 2002 CMSC 203 - Discrete Structures 2
RelationsRelations
If we want to describe a relationship betweenIf we want to describe a relationship between
elements of two sets A and B, we can useelements of two sets A and B, we can use orderedordered
pairspairs with their first element taken from A andwith their first element taken from A and
their second element taken from B.their second element taken from B.
Since this is a relation betweenSince this is a relation between two setstwo sets, it is, it is
called acalled a binary relationbinary relation..
Definition:Definition: Let A and B be sets. A binary relationLet A and B be sets. A binary relation
from A to B is a subset of Afrom A to B is a subset of A××B.B.
In other words, for a binary relation R we haveIn other words, for a binary relation R we have
RR ⊆⊆ AA××B. We use the notation aRb to denote thatB. We use the notation aRb to denote that
(a, b)(a, b)∈∈R and aR and aRb to denote that (a, b)b to denote that (a, b)∉∉R.R.
3. Fall 2002 CMSC 203 - Discrete Structures 3
RelationsRelations
When (a, b) belongs to R, a is said to beWhen (a, b) belongs to R, a is said to be relatedrelated toto
b by R.b by R.
Example:Example: Let P be a set of people, C be a set ofLet P be a set of people, C be a set of
cars, and D be the relation describing which personcars, and D be the relation describing which person
drives which car(s).drives which car(s).
P = {Carl, Suzanne, Peter, Carla},P = {Carl, Suzanne, Peter, Carla},
C = {Mercedes, BMW, tricycle}C = {Mercedes, BMW, tricycle}
D = {(Carl, Mercedes), (Suzanne, Mercedes),D = {(Carl, Mercedes), (Suzanne, Mercedes),
(Suzanne, BMW), (Peter, tricycle)}(Suzanne, BMW), (Peter, tricycle)}
This means that Carl drives a Mercedes, SuzanneThis means that Carl drives a Mercedes, Suzanne
drives a Mercedes and a BMW, Peter drives adrives a Mercedes and a BMW, Peter drives a
tricycle, and Carla does not drive any of thesetricycle, and Carla does not drive any of these
vehicles.vehicles.
4. Fall 2002 CMSC 203 - Discrete Structures 4
Relations on a SetRelations on a Set
Definition:Definition: A relation on the set A is a relationA relation on the set A is a relation
from A to A.from A to A.
In other words, a relation on the set A is a subsetIn other words, a relation on the set A is a subset
of Aof A××A.A.
Example:Example: Let A = {1, 2, 3, 4}. Which ordered pairsLet A = {1, 2, 3, 4}. Which ordered pairs
are in the relation R = {(a, b) | a < b} ?are in the relation R = {(a, b) | a < b} ?
5. Fall 2002 CMSC 203 - Discrete Structures 5
Relations on a SetRelations on a Set
Solution:Solution: R = {R = {(1, 2),(1, 2), (1, 3),(1, 3), (1, 4),(1, 4), (2, 3),(2, 3),(2, 4),(2, 4),(3, 4)}(3, 4)}
RR 11 22 33 44
11
22
33
44
11 11
22
33
44
22
33
44
XX XX XX
XX XX
XX
6. Fall 2002 CMSC 203 - Discrete Structures 6
Properties of RelationsProperties of Relations
We will now look at some useful ways to classifyWe will now look at some useful ways to classify
relations.relations.
Definition:Definition: A relation R on a set A is calledA relation R on a set A is called
reflexivereflexive if (a, a)if (a, a)∈∈R for every element aR for every element a∈∈A.A.
Are the following relations on {1, 2, 3, 4} reflexive?Are the following relations on {1, 2, 3, 4} reflexive?
R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)}R = {(1, 1), (1, 2), (2, 3), (3, 3), (4, 4)} No.No.
R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)}R = {(1, 1), (2, 2), (2, 3), (3, 3), (4, 4)} Yes.Yes.
R = {(1, 1), (2, 2), (3, 3)}R = {(1, 1), (2, 2), (3, 3)} No.No.
Definition:Definition: A relation on a set A is calledA relation on a set A is called
irreflexiveirreflexive if (a, a)if (a, a)∉∉R for every element aR for every element a∈∈A.A.
7. Fall 2002 CMSC 203 - Discrete Structures 7
Properties of RelationsProperties of Relations
Definitions:Definitions:
A relation R on a set A is calledA relation R on a set A is called symmetricsymmetric if (b,if (b,
a)a)∈∈R whenever (a, b)R whenever (a, b)∈∈R for all a, bR for all a, b∈∈A.A.
A relation R on a set A is calledA relation R on a set A is called antisymmetricantisymmetric ifif
a = b whenever (a, b)a = b whenever (a, b)∈∈R and (b, a)R and (b, a)∈∈R.R.
A relation R on a set A is calledA relation R on a set A is called asymmetricasymmetric ifif
(a, b)(a, b)∈∈R implies that (b, a)R implies that (b, a)∉∉R for all a, bR for all a, b∈∈A.A.
8. Fall 2002 CMSC 203 - Discrete Structures 8
Properties of RelationsProperties of Relations
Are the following relations on {1, 2, 3, 4}Are the following relations on {1, 2, 3, 4}
symmetric, antisymmetric?symmetric, antisymmetric?
R = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)}R = {(1, 1), (1, 2), (2, 1), (3, 3), (4, 4)} symmetricsymmetric
R = {(1, 1)}R = {(1, 1)} Sym. and antisym.Sym. and antisym.
R = {(1, 3), (3, 2), (2, 1)}R = {(1, 3), (3, 2), (2, 1)}
R = {(4, 4), (3, 3), (1, 4)}R = {(4, 4), (3, 3), (1, 4)}
antisym.antisym.
antisym.antisym.
9. Fall 2002 CMSC 203 - Discrete Structures 9
Properties of RelationsProperties of Relations
Definition:Definition: A relation R on a set A is calledA relation R on a set A is called
transitivetransitive if whenever (a, b)if whenever (a, b)∈∈R and (b, c)R and (b, c)∈∈R, thenR, then
(a, c)(a, c)∈∈R for a, b, cR for a, b, c∈∈A.A.
Are the following relations on {1, 2, 3, 4}Are the following relations on {1, 2, 3, 4}
transitive?transitive?
R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)}R = {(1, 1), (1, 2), (2, 2), (2, 1), (3, 3)} Yes.Yes.
R = {(1, 3), (3, 2), (2, 1)}R = {(1, 3), (3, 2), (2, 1)} No.No.
R = {(2, 4), (4, 3), (2, 3), (4, 1)}R = {(2, 4), (4, 3), (2, 3), (4, 1)} No.No.
10. Fall 2002 CMSC 203 - Discrete Structures 10
Representing RelationsRepresenting Relations
Example:Example: How can we represent the relationHow can we represent the relation
R = {(2, 1), (3, 1), (3, 2)} as a zero-one matrix?R = {(2, 1), (3, 1), (3, 2)} as a zero-one matrix?
Solution:Solution: The matrix MThe matrix MRR is given byis given by
=
11
01
00
RM
11. Fall 2002 CMSC 203 - Discrete Structures 11
Representing RelationsRepresenting Relations
What do we know about the matrices representingWhat do we know about the matrices representing
aa relation on a setrelation on a set (a relation from A to A) ?(a relation from A to A) ?
They areThey are squaresquare matrices.matrices.
What do we know about matrices representingWhat do we know about matrices representing
reflexivereflexive relations?relations?
All the elements on theAll the elements on the diagonaldiagonal of such matricesof such matrices
MMrefref must bemust be 1s1s..
=
1
.
.
.
1
1
refM
12. Fall 2002 CMSC 203 - Discrete Structures 12
Representing RelationsRepresenting Relations
What do we know about the matrices representingWhat do we know about the matrices representing
symmetric relationssymmetric relations??
These matrices are symmetric, that is, MThese matrices are symmetric, that is, MRR = (M= (MRR))tt
..
=
1101
1001
0010
1101
RM
symmetric matrix,symmetric matrix,
symmetric relation.symmetric relation.
=
0011
0011
0011
0011
RM
non-symmetric matrix,non-symmetric matrix,
non-symmetric relation.non-symmetric relation.
13. Fall 2002 CMSC 203 - Discrete Structures 13
Representing RelationsRepresenting Relations
The Boolean operationsThe Boolean operations joinjoin andand meetmeet (you(you
remember?)remember?) can be used to determine the matricescan be used to determine the matrices
representing therepresenting the unionunion and theand the intersectionintersection of twoof two
relations, respectively.relations, respectively.
To obtain theTo obtain the joinjoin of two zero-one matrices, weof two zero-one matrices, we
apply the Boolean “or” function to all correspondingapply the Boolean “or” function to all corresponding
elements in the matrices.elements in the matrices.
To obtain theTo obtain the meetmeet of two zero-one matrices, weof two zero-one matrices, we
apply the Boolean “and” function to all correspondingapply the Boolean “and” function to all corresponding
elements in the matrices.elements in the matrices.
14. 14
Representing Relations Using MatricesRepresenting Relations Using Matrices
Example:Example: How can we represent the relationHow can we represent the relation
R = {(2, 1), (3, 1), (3, 2)} as a zero-one matrix?R = {(2, 1), (3, 1), (3, 2)} as a zero-one matrix?
Solution:Solution: The matrix MThe matrix MRR is given byis given by
=
11
01
00
RM
15. Fall 2002 CMSC 203 - Discrete Structures 15
Representing Relations Using MatricesRepresenting Relations Using Matrices
Example:Example: Let the relations R and S be representedLet the relations R and S be represented
by the matricesby the matrices
=∨=∪
011
111
101
SRSR MMM
=
001
110
101
SM
What are the matrices representing RWhat are the matrices representing R∪∪S and RS and R∩∩S?S?
Solution:Solution: These matrices are given byThese matrices are given by
=∧=∩
000
000
101
SRSR MMM
=
010
001
101
RM