chapter # 9 : relationssite.iugaza.edu.ps/musbahshaat/files/chapter9_hadnout_all.pdf · ecom 2311-...

43
ECOM 2311- Discrete Mathematics Chapter # 9 : Relations Fall, 2013/2014 ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 1 / 43

Upload: others

Post on 01-Jun-2020

7 views

Category:

Documents


0 download

TRANSCRIPT

ECOM 2311- Discrete Mathematics

Chapter # 9 : Relations

Fall, 2013/2014

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 1 / 43

Outline

1 Relations and Their Properties

2 n-ary Relations and Their Applications

3 Representing Relations

4 Closures of Relations

5 Equivalence Relations

6 Partial Orderings

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 2 / 43

Relations and Their PropertiesIntroduction

Let A and B be sets. A binary relation from A to B is a subset ofA× B.

We use the notation aRb to denote that (a, b) ∈ R and a 6 Rb todenote that (a, b) 6∈ R.

When (a, b) belongs to R, a is said to be related to b by R.

Example: Let A be the set of students in your school, and let B be theset of courses. Let R be the relation that consists of those pairs (a, b),where a is a student enrolled in course b.

If Ahmed and Ali are enrolled in Discrete math course, the pairs(Ahmed, Discrete Math) and (Ali, Discrete math) belong to R.

If Ahmed is also enrolled in Logic Design course, then the pair(Ahmed, Logic Design) is also in R and If Ali is not enrolled in LogicDesign course, then the pair (Ali, Logic Design) is not in R.

If a student is not currently enrolled in any courses or there is nooffered course, there will be no pairs in R.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 3 / 43

Relations and Their PropertiesFunctions as Relations

Example: Let A = {0, 1, 2} and B = {a, b}. Then{(0, a), (0, b), (1, a), (2, b)} is a relation from A to B.

The graph of f is the set of ordered pairs (a, b) such that b = f (a).

A relation can be defined as a function if each element in A has aunique image in B Cities and states relation is not a function.

A relation can be used to express a one-to-many relationshipbetween the elements of the sets A and B and is a generalization ofgraphs of functions.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 4 / 43

Relations and Their PropertiesRelations on a Set

A relation on a set A is a relation from A to A [a subset of A× A].

Example: Let A be the set {1, 2, 3, 4}. Which ordered pairs are in therelation R = {(a, b)|a divides b}?.

R = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 4), (3, 3), (4, 4)}.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 5 / 43

Relations and Their PropertiesRelations on a Set

Example: Consider these relations on the set of integers:R1 = {(a, b)|a ≤ b},R2 = {(a, b)|a > b},R3 = {(a, b)|a = b or a = −b},R4 = {(a, b)|a = b},R5 = {(a, b)|a = b + 1},R6 = {(a, b)|a + b ≤ 3}Which of these relations contain each of the pairs (1, 1), (1, 2), (2, 1),(1,-1), and (2, 2)?.

The pair (1, 1) is in R1, R3, R4 and R6.

(1, 2) is in R1 and R6.

(2, 1) is in R2, R5 and R6.

(1,-1) is in R2, R3, and R6.

Finally, (2, 2) is in R1, R3, and R4.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 6 / 43

Relations and Their PropertiesProperties of Relations

A relation R on a set A is called reflexive if (a, a) ∈ R for every elementa ∈ A [∀a((a, a) ∈ R)].

Example: Consider the following relations on {1, 2, 3, 4}:R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)},R2 = {(1, 1), (1, 2), (2, 1)},R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)},R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)},R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)},R6 = {(3, 4)}.Which of these relations are reflexive?.

The relations R3 and R5 are reflexive because they both contain allpairs of the form (a, a), namely, (1, 1), (2, 2), (3, 3), and (4, 4).

The other relations are not reflexive because they do not contain allof these ordered pairs.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 7 / 43

Relations and Their PropertiesProperties of Relations

Example: Which of the following relations are reflexive?R1 = {(a, b)|a ≤ b},R2 = {(a, b)|a > b},R3 = {(a, b)|a = b or a = −b},R4 = {(a, b)|a = b},R5 = {(a, b)|a = b + 1},R6 = {(a, b)|a + b ≤ 3}

R1, R3 and R4 are reflexive relations.

For each of the other relations in this example it is easy to find apair of the form (a, a) that is not in the relation.

Example: Is the ”divides” relation on the set of positive integersreflexive??Because a|a whenever a is a positive integer, the ”divides” relation isreflexive.Exercise. What if relation is on the set of all integers?

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 8 / 43

Relations and Their PropertiesProperties of Relations

A relation R on a set A is called symmetric if (b, a) ∈ R whenever(a, b) ∈ R, for all a, b ∈ A [∀a∀b((a, b) ∈ R → (b, a) ∈ R)]. A relation Ron a set A such that for all a, b ∈ A, if (a, b) ∈ R and (b, a) ∈ R, thena = b is called antisymmetric[∀a∀b(((a, b) ∈ R ∧ (b, a) ∈ R)→ (a = b))].

Example: Which of the following relations are symmetric and which areantisymmetric?R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)},R2 = {(1, 1), (1, 2), (2, 1)},R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)},R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)},R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)},R6 = {(3, 4)}.

The relations R2 and R3 are symmetric and none of the otherrelations is symmetric [There exist a pair (a, b) such that it is in therelation but (b, a) is not].

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 9 / 43

Relations and Their PropertiesProperties of Relations

R4, R5, and R6 are all antisymmetric and none of the other relationsis antisymmetric. [There exists a pair (a, b) with a 6= b such that (a,b) and (b, a) are both in the relation].

Example: Which of the following relations are symmetric and which areantisymmetric?R1 = {(a, b)|a ≤ b}, R2 = {(a, b)|a > b},R3 = {(a, b)|a = b or a = −b}, R4 = {(a, b)|a = b},R5 = {(a, b)|a = b + 1}, R6 = {(a, b)|a + b ≤ 3}

The relations R3, R4, and R6 are symmetric.

The relations R1, R2, R4, and R5 are antisymmetric.

Example: Is the ”divides” relation on the set of positive integerssymmetric? Is it antisymmetric?

This relation is not symmetric because 1|2, but 2 6 |1. It is antisymmetric,for if a and b are positive integers with a|b and b|a, then a = b.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 10 / 43

Relations and Their PropertiesProperties of Relations

A relation R on a set A is called transitive if whenever (a, b) ∈ R and(b, c) ∈ R, then (a, c) ∈ R, for all a, b, c ∈ A[∀a∀b∀c(((a, b) ∈ R ∧ (b, c) ∈ R)→ (a, c) ∈ R)].

Example: Which of the following relations are are transitive?R1 = {(1, 1), (1, 2), (2, 1), (2, 2), (3, 4), (4, 1), (4, 4)},R2 = {(1, 1), (1, 2), (2, 1)},R3 = {(1, 1), (1, 2), (1, 4), (2, 1), (2, 2), (3, 3), (4, 1), (4, 4)},R4 = {(2, 1), (3, 1), (3, 2), (4, 1), (4, 2), (4, 3)},R5 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (2, 3), (2, 4), (3, 3), (3, 4), (4, 4)},R6 = {(3, 4)}.

R4, R5, and R6 are transitive.

R1 is not transitive because (3, 4) and (4, 1) belong to R1, but (3,1) does not. R2 is not transitive because (2, 1) and (1, 2) belong toR2, but (2, 2) does not. R3 is not transitive because (4, 1) and (1,2) belong to R3, but (4, 2) does not.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 11 / 43

Relations and Their PropertiesProperties of Relations

Example: Which of the following relations are are transitive?R1 = {(a, b)|a ≤ b}, R2 = {(a, b)|a > b},R3 = {(a, b)|a = b or a = −b}, R4 = {(a, b)|a = b},R5 = {(a, b)|a = b + 1}, R6 = {(a, b)|a + b ≤ 3}

The relations R1,R2,R3, and R4 are transitive.

R5 is not transitive because (2, 1) and (1, 0) belong to R5, but (2,0) does not.

R6 is not transitive because (2, 1) and (1, 2) belong to R6, but (2,2) does not.

Example: Is the ”divides” relation on the set of positive integerstransitive?

Suppose that a divides b and b divides c. Then there are positiveintegers k and l such that b = ak and c = bl . Hence, c = a(kl), so adivides c . It follows that this relation is transitive.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 12 / 43

Relations and Their PropertiesCombining Relations

Example: Let A = {1, 2, 3} and B = {1, 2, 3, 4}. The relationsR1 = {(1, 1), (2, 2), (3, 3)} and R2 = {(1, 1), (1, 2), (1, 3), (1, 4)}.

R1 ∪ R2 = {(1, 1), (1, 2), (1, 3), (1, 4), (2, 2), (3, 3)},R1 ∩ R2 = {(1, 1)},R1− R2 = {(2, 2), (3, 3)},R2− R1 = {(1, 2), (1, 3), (1, 4)}.

Example: Let R1 be the ”less than” relation on the set of real numbersand let R2 be the ”greater than” relation on the set of real numbers,that is, R1 = {(x , y)|x < y} and R2 = {(x , y)|x > y}. What areR1 ∪ R2,R1 ∩ R2,R1− R2 and R2− R1.

R1 ∪ R2 = {(x , y)|x 6= y}.R1 ∩ R2 = Ø.

R1− R2 = R1.

R2− R1 = R2ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 13 / 43

Relations and Their PropertiesCombining Relations

Let R be a relation from a set A to a set B and S a relation from B to aset C. The composite of R and S is the relation consisting of orderedpairs (a, c), where a ∈ A, c ∈ C , and for which there exists an elementb ∈ B such that (a, b) ∈ R and (b, c) ∈ S . We denote the composite ofR and S by S ◦ R.

Example: What is the composite of the relations R and S, where R isthe relation from {1, 2, 3} to {1, 2, 3, 4} withR = {(1, 1), (1, 4), (2, 3), (3, 1), (3, 4)} and S is the relation from{1, 2, 3, 4} to {0, 1, 2} with S = {(1, 0), (2, 0), (3, 1), (3, 2), (4, 1)}?.

S ◦ R = {(1, 0), (1, 1), (2, 1), (2, 2), (3, 0), (3, 1)}.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 14 / 43

Relations and Their PropertiesCombining Relations

Let R be a relation on the set A. The powers Rn, n = 1, 2, 3, · · · , aredefined recursively byR1 = R and Rn+1 = Rn ◦ R.

Example: Let R = {(1, 1), (2, 1), (3, 2), (4, 3)}. Find the powersRn, n = 2, 3, 4, · · ·

R2 = R ◦ R, we find that R2 = {(1, 1), (2, 1), (3, 1), (4, 2)}.R3 = R2 ◦ R,R3 = {(1, 1), (2, 1), (3, 1), (4, 1)}.R4 is the same as R3, so R4 = {(1, 1), (2, 1), (3, 1), (4, 1)}.It also follows that Rn = R3 for n = 5, 6, 7, · · · .

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 15 / 43

Homework [due 1st of Dec.].From the text book, Section 9.1, page 581Questions: Q2, Q4, Q6, Q32, Q34[Parts a,c,d,e,f] and Q36[Parts a,b,e].

n-ary Relations and Their ApplicationsIntroduction

Let A1,A2, · · · ,An be sets. An n-ary relation on these sets is a subset ofA1 × A2 × · · ·An. The sets A1,A2, · · · ,An are called the domains of therelation, and n is called its degree.

Example: Let R be the relation on N×N×N consisting of triples(a, b, c), where a, b, and c are integers with a < b < c . Then(1, 2, 3) ∈ R, but (2, 4, 3) 6∈ R. The degree of this relation is 3. Itsdomains are all equal to the set of natural numbers.

Example: Let R be the relation on Z× Z× Z consisting of all triples ofintegers (a, b, c) in which a, b, and c form an arithmetic progression.That is, (a, b, c) ∈ R if and only if there is an integer k such thatb = a + k and c = a + 2k , or equivalently, such that b − a = k andc − b = k . Note that (1, 3, 5) ∈ R, but (2, 5, 9) 6∈ R. This relation hasdegree 3 and its domains are all equal to the set of integers.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 17 / 43

Representing RelationsRepresenting Relations Using Matrices

A relation between finite sets can be represented using a zero-one matrix.Suppose that R is a relation from A = {a1, a2, · · · , am} toB = {b1, b2, · · · , bn}. The relation R can be represented by the matrixMR = [mij ], where

mij =

{1 if (ai , bj) ∈ R0 if (ai , bj) 6∈ R

(1)

Example: Suppose that A = {1, 2, 3} and B = {1, 2}. Let R be therelation from A to B containing (a, b) if a ∈ A, b ∈ B, and a > b. Whatis the matrix representing R ?

Because R = {(2, 1), (3, 1), (3, 2)}, the matrix for R is

MR =

0 01 01 1

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 18 / 43

Representing RelationsRepresenting Relations Using Matrices

Example: Let A = {a1, a2, a3} and B = {b1, b2, b3, b4, b5}. Whichordered pairs are in the relation R represented by the matrix

MR =

0 1 0 0 01 0 1 1 01 0 1 0 1

?

Because R consists of those ordered pairs (ai , bj) with mij = 1, itfollows thatR = {(a1, b2), (a2, b1), (a2, b3), (a2, b4), (a3, b1), (a3, b3), (a3, b5)}.The relation R on A is a square matrix.

R is reflexive if and only if mii = 1, for i = 1, 2, · · · , n.

In other words, R is reflexive if all the elements on the main diagonalof MR are equal to 1.

Note that the elements off the main diagonal can be either 0 or 1.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 19 / 43

Representing RelationsRepresenting Relations Using Matrices

The relation R is symmetric if (a, b) ∈ R implies that (b, a) ∈ R.

In terms of the entries of MR , R is symmetric if and only if mji = 1whenever mij = 1. This also means mji = 0 whenever mij = 0.

Consequently, R is symmetric if and only if mij = mji , for all pairsof integers i and j with i = 1, 2, · · · , n and j = 1, 2, · · · , n.

The relation R is antisymmetric if and only if (a, b) ∈ R and(b, a) ∈ R imply that a = b.

The matrix of an antisymmetric relation has the property that eithermij = 0 or mji = 0 when i 6= j .

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 20 / 43

Representing RelationsRepresenting Relations Using Matrices

Example: Suppose that the relation R on a set is represented by thematrix

MR =

1 1 01 1 10 1 1

Is R reflexive, symmetric, and/or antisymmetric?

Because all the diagonal elements of this matrix are equal to 1, R isreflexive. Moreover, because MR is symmetric, it follows that R issymmetric. It is also easy to see that R is not antisymmetric.

The Boolean operations join and meet can be used to find thematrices representing the union and the intersection of two relations.

Suppose that R1 and R2 are relations on a set A represented by thematrices MR1 and MR2 , respectively.

Thus, the matrices representing the union and intersection of theserelations areMR1∪R2 = MR1 ∨MR2 and MR1∩R2 = MR1 ∧MR2

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 21 / 43

Representing RelationsRepresenting Relations Using Matrices

Example: Suppose that the relations R1 and R2 on a set A arerepresented by the matrices

MR1 =

1 0 11 0 00 1 0

and MR2 =

1 0 10 1 01 0 0

What are the matrices representing R1 ∪ R2 and R1 ∩ R2?

The matrices of these relations are:

MR1∪R2 = MR1 ∨MR2 =

1 0 11 1 11 1 0

MR1∩R2 = MR1 ∧MR2 =

1 0 10 0 00 0 0

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 22 / 43

Representing RelationsRepresenting Relations Using Matrices

The matrix of the composite of relation S ◦ R is the Boolean product ofthe matrices MR and MS , i.e. MS◦R = MR �MS

Example: Find the matrix representing the relations S ◦ R, where thematrices representing R and S are

MR =

1 0 11 1 00 0 0

and MS =

0 1 00 0 11 0 1

The matrix for S ◦ R is

MS◦R = MR �MS =

1 1 10 1 10 0 0

Note: The matrix representing the composite of two relations can beused to find the matrix for MRn . In particular,

MRn = M[n]R =

n times︷ ︸︸ ︷MR �MR � · · ·MR .

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 23 / 43

Representing RelationsRepresenting Relations Using Digraphs

A directed graph, or digraph, consists of a set V of vertices (or nodes)together with a set E of ordered pairs of elements of V called edges (orarcs). The vertex a is called the initial vertex of the edge (a, b), and thevertex b is called the terminal vertex of this edge. An edge of the form(a, a) is represented using an arc from the vertex a back to itself. Suchan edge is called a loop.

Example: Draw the directed graph with vertices a, b, c , and d , andedges (a, b), (a, d), (b, b), (b, d), (c , a), (c , b), and (d , b).

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 24 / 43

Representing RelationsRepresenting Relations Using Digraphs

Example: Draw the directed graph of the relationR = {(1, 1), (1, 3), (2, 1), (2, 3), (2, 4), (3, 1), (3, 2), (4, 1)} on the set{1, 2, 3, 4}

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 25 / 43

Representing RelationsRepresenting Relations Using Digraphs

Example: What are the ordered pairs in the relation R represented bythe directed graph shown in the figure?

R = {(1, 3), (1, 4), (2, 1), (2, 2), (2, 3), (3, 1), (3, 3), (4, 1), (4, 3)}.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 26 / 43

Representing RelationsRepresenting Relations Using Digraphs

The directed graph representing a relation can be used to determinewhether the relation has various properties.

A relation is reflexive if and only if there is a loop at every vertex ofthe directed graph

A relation is symmetric if and only if for every edge between distinctvertices in its digraph there is an edge in the opposite direction.

A relation is antisymmetric if and only if there are never two edgesin opposite directions between distinct vertices.

A relation is transitive if and only if whenever there is an edge froma vertex x to a vertex y and an edge from a vertex y to a vertex z ,there is an edge from x to z .

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 27 / 43

Representing RelationsRepresenting Relations Using Digraphs

Example: Determine whether the relations for the directed graphs shownin the figure are reflexive, symmetric, antisymmetric, and/or transitive.?

R: reflexive, not symmetric, not antisymmetric and not transitive.

S: not reflexive, symmetric, not antisymmetric and not transitive.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 28 / 43

Closures of RelationsClosures

Let R be a relation on a set A. R may or may not have some property P,such as reflexivity, symmetry, or transitivity. If there is a relation S withproperty P containing R such that S is a subset of every relation withproperty P containing R, then S is called the closure of R with respectto P.

Example: The relation R = {(1, 1), (1, 2), (2, 1), (3, 2)} on the setA = {1, 2, 3} is not reflexive. How can we produce a reflexive relationcontaining R that is as small as possible?

This can be done by adding (2, 2) and (3, 3) to R

These are the only pairs of the form (a, a) that are not in R.

Clearly, this new relation contains R. Furthermore, any reflexiverelation that contains R must also contain (2, 2) and (3, 3).

Because this relation contains R, is reflexive, and is contained withinevery reflexive relation that contains R, it is called the reflexiveclosure of R.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 29 / 43

Closures of RelationsClosures

The reflexive closure of R equals R ∪∆, where ∆ = {(a, a)|a ∈ A}.

Example: What is the reflexive closure of the relationR = {(a, b)|a < b} on the set of integers?

R ∪∆ = {(a, b)|a < b} ∪ {(a, a)|a ∈ Z} = {(a, b)|a ≤ b}.Example: The relation {(1, 1), (1, 2), (2, 2), (2, 3), (3, 1), (3, 2)} on{1, 2, 3} is not symmetric. How can we produce a symmetric relationthat is as small as possible and contains R?

we need only add (2, 1) and (1, 3), because these are the only pairsof the form (b, a) with (a, b) ∈ R that are not in R.

This new relation is symmetric and contains R. Furthermore, anysymmetric relation that contains R must contain this new relation.

This new relation is called the symmetric closure of R.

The symmetric closure of R equals R ∪ R−1, whereR−1 = {(b, a)|(a, b) ∈ R}.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 30 / 43

Closures of RelationsClosures

Example: What is the symmetric closure of the relationR = {(a, b)|a > b} on the set of positive integers?

R ∪ R−1 = {(a, b)|a > b} ∪ {(b, a)|a > b} = {(a, b)|a 6= b}.Example: Let R = {(1, 3), (1, 4), (2, 1), (3, 2)} on the set {1, 2, 3, 4},What the elements that should be added to get a transitive relation?

The missing pairs are (1, 2), (2, 3), (2, 4), and (3, 1).

Adding these pairs does not produce a transitive relation, becausethe resulting relation contains (3, 1) and (1, 4) but does not contain(3, 4).

This shows that constructing the transitive closure of a relation ismore complicated than constructing either the reflexive orsymmetric closure.

We will develop algorithms for constructing transitive closures.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 31 / 43

Closures of RelationsPaths in Directed Graphs

A path from a to b in the directed graph G is a sequence of edges(x0, x1), (x1, x2), (x2, x3), · · · , (xn−1, xn) in G , where n is a nonnegativeinteger, and x0 = a and xn = b, that is, a sequence of edges where theterminal vertex of an edge is the same as the initial vertex in the nextedge in the path. This path is denoted by x0, x1, x2, · · · , xn−1, xn and haslength n. We view the empty set of edges as a path of length zero from ato a. A path of length n ≥ 1 that begins and ends at the same vertex iscalled a circuit or cycle.

Exercise: Which of the following are paths in the directed graph shownin Figure: a, b, e, d; a, e, c, d, b; b, a, c, b, a, a, b? What are the lengthsof those that are paths? Which of the paths in this list are circuits?

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 32 / 43

Closures of RelationsTransitive Closures

There is a path from a to b in R if there is a sequence of elementsa, x1, x2, · · · , xn−1, b with (a, x1) ∈ R, (x1, x2) ∈ R, · · · , and(xn−1, b) ∈ R.

THEOREM 1

Let R be a relation on a set A. There is a path of length n, where n is apositive integer, from a to b if and only if (a, b) ∈ Rn.

DEFINITION 2

Let R be a relation on a set A. The connectivity relation R∗ consists ofthe pairs (a, b) such that there is a path of length at least one from a tob in R.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 33 / 43

Closures of RelationsTransitive Closures

Example: Let R be the relation on the set of all people in the world thatcontains (a, b) if a has met b. What is Rn, where n is a positive integergreater than one? What is R∗?

The relation R2 contains (a, b) if there is a person c such that(a, c) ∈ R and (c , b) ∈ R, that is, if there is a person c such that ahas met c and c has met b.

Similarly, Rn consists of those pairs (a, b) such that there are peoplex1, x2, · · · , xn−1 such that a has met x1, x1 has met x2, · · · and xn−1has met b.

The relation R∗ contains (a, b) if there is a sequence of people,starting with a and ending with b, such that each person in thesequence has met the next person in the sequence.

THEOREM 2

The transitive closure of a relation R equals the connectivity relation R∗.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 34 / 43

Closures of RelationsTransitive Closures

THEOREM 3

Let MR be the zero-one matrix of the relation R on a set with nelements. Then the zero-one matrix of the transitive closure R∗ isMR∗ = MR ∨M

[2]R ∨M

[3]R ∨ · · · ∨M

[n]R .

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 35 / 43

Closures of RelationsTransitive Closures

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 36 / 43

Equivalence Relations

A relation on a set A is called an equivalence relation if it is reflexive,symmetric, and transitive.

Two elements a and b that are related by an equivalence relation arecalled equivalent. The notation a ∼ b is often used to denote that a andb are equivalent elements with respect to a particular equivalencerelation.

Example: Let R be the relation on the set of integers such that aRb ifand only if a = b or a = −b.

— In Section 9.1 we showed that R is reflexive, symmetric, andtransitive. It follows that R is an equivalence relation.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 37 / 43

Equivalence Relations

Example: Let R be the relation on the set of real numbers such thataRb if and only if a− b is an integer. Is R an equivalence relation?

Because a− a = 0 is an integer for all real numbers a, aRa for allreal numbers a. Hence, R is reflexive.

Now suppose that aRb. Then a− b is an integer, so b − a is also aninteger. Hence, bRa. It follows that R is symmetric.

If aRb and bRc , then a− b and b − c are integers. Therefore,a− c = (a− b) + (b− c) is also an integer. Hence, aRc . Thus, R istransitive.

Consequently, R is an equivalence relation.

Example: Show that the ”divides” relation is the set of positive integersin not an equivalence relation.

Divides relation is reflexive and transitive but not symmetric, henceits not equivalence relation.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 38 / 43

Equivalence Relations

Example: Let R be the relation on the set of real numbers such thatxRy if and only if x and y are real numbers that differ by less than 1,that is |x − y | < 1. Is R an equivalence relation?

R is reflexive because |x − x | = 0 < 1 whenever x ∈ R.

R is symmetric, for if xRy , where x and y are real numbers, then|x − y | < 1, which tells us that |y − x | = |x − y | < 1, so that yRx .

However, R is not an equivalence relation because it is not transitive.

Take x = 2.8, y = 1.9, and z = 1.1, so that|x − y | = |2.8− 1.9| = 0.9 < 1, |y − z | = |1.9− 1.1| = 0.8 < 1, but|x − z | = |2.8− 1.1| = 1.7 > 1. That is, 2.8R1.9, 1.9R1.1, but2.8 6 R1.1.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 39 / 43

Partial Orderings

A relation R on a set S is called a partial ordering or partial order if it isreflexive, antisymmetric, and transitive. A set S together with a partialordering R is called a partially ordered set, or poset, and is denoted by(S ,R). Members of S are called elements of the poset.

Example: Let R be the ”greater or equal” relation on the set of integers.Is R a partial ordering?

Because a ≥ a for every integer a, ≥ is reflexive. If a ≥ b and b ≥ a,then a = b. Hence, ≥ is antisymmetric. Finally, ≥ is transitivebecause a ≥ b and b ≥ c imply that a ≥ c . It follows that ≥ is apartial ordering on the set of integers and (Z ,≥) is a poset.

Example: Let R be the divisibility relation | on the set of positiveintegers. Is R a partial ordering?

Because it is reflexive, antisymmetric, and transitive. We see that(Z+, |) is a poset.

Exercise: Let R be the inclusion relation ⊆ on the set of positiveintegers. Is R a partial ordering?

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 40 / 43

Partial Orderings

Example: Let R be the relation on the set of people such that xRy if xand y are people and x is older than y. Is R a partial ordering?

R is antisymmetric because if a person x is older than a person y,then y is not older than x. That is, if xRy , then y 6 Rx .

The relation R is transitive because if person x is older than persony and y is older than person z, then x is older than z.

However, R is not reflexive, because no person is older than himselfor herself.

It follows that R is not a partial ordering.

The elements a and b of a poset (S ,�) are called comparable if eithera � b or b � a. When a and b are elements of S such that neither a � bnor b � a, a and b are called incomparable.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 41 / 43

Partial Orderings

Example: In the poset (Z+, |), are the integers 3 and 9 comparable? Are5 and 7 comparable?

The integers 3 and 9 are comparable, because 3|9.

The integers 5 and 7 are incomparable, because 5 6 |7 and 7 6 |5.

If (S ,�) is a poset and every two elements of S are comparable, S iscalled a totally ordered or linearly ordered set, and � is called a totalorder or a linear order. A totally ordered set is also called a chain.

Example: The poset (Z ,≤) is totally ordered, because a ≤ b or b ≤ awhenever a and b are integers.

Example: The poset (Z+, |) is not totally ordered because it containselements that are incomparable, such as 5 and 7.

ECOM 2311- Discrete Mathematics - Ch.9 Dr. Musbah Shaat 42 / 43

Homework [due 8th of Dec].From the text book, Section 9.3, page 596Questions: Q2 [Part a], Q4 [Part b], Q8, Q14 [Parts a,b,c], Q26 andQ32.From the text book, Section 9.4, page 606Questions: Q2, Q6, Q20, Q26 (a) and Q29.From the text book, Section 9.5, page 615Questions: Q2 and Q22.From the text book, Section 9.6, page 630Questions: Q4, Q8[Parts a,b] and Q10.

End of Chapter # 5