You are on page 1of 70

MATH F213: Discrete Mathematics

First Semester 2020-21

BITS Pilani
§4.5: Operations on relations

In this section, we will

1. develop algebra on relations


2. learn about closure properties

1
Operations on n-ary relations

Suppose R1 , R2 ✓ (A1 ⇥ · · · ⇥ An ). Then

1. Complement of R1 is R¯1 = (A1 ⇥ · · · ⇥ An ) \ R1


2. Union R1 [ R2 , intersection R1 \ R2 and difference R1 \ R2 have
usual meanings, and are all relations

2
Operations on n-ary relations

Suppose R1 , R2 ✓ (A1 ⇥ · · · ⇥ An ). Then

1. Complement of R1 is R¯1 = (A1 ⇥ · · · ⇥ An ) \ R1


2. Union R1 [ R2 , intersection R1 \ R2 and difference R1 \ R2 have
usual meanings, and are all relations

Example. The union of the relations < and = is the relation 

2
Operations on n-ary relations

Suppose R1 , R2 ✓ (A1 ⇥ · · · ⇥ An ). Then

1. Complement of R1 is R¯1 = (A1 ⇥ · · · ⇥ An ) \ R1


2. Union R1 [ R2 , intersection R1 \ R2 and difference R1 \ R2 have
usual meanings, and are all relations

Example. The union of the relations < and = is the relation 


The relation  minus the relation = is the relation <

2
Operations on n-ary relations

Suppose R1 , R2 ✓ (A1 ⇥ · · · ⇥ An ). Then

1. Complement of R1 is R¯1 = (A1 ⇥ · · · ⇥ An ) \ R1


2. Union R1 [ R2 , intersection R1 \ R2 and difference R1 \ R2 have
usual meanings, and are all relations

Example. The union of the relations < and = is the relation 


The relation  minus the relation = is the relation <
The relation  minus the relation < is the relation =

2
Operations on n-ary relations (Contd.)

Definition
Let R ✓ (A1 ⇥ · · · ⇥ An ) be an n-ary relation and let s1 , . . . , sk be a
subsequence of the component positions 1, . . . , n of R. The projection
of R with respect to s1 , . . . , sk is the k-ary relation

{(x1 , . . . , xk ) : (x1 , . . . , xk ) = (as1 , . . . , ask ) for some (a1 , . . . , an ) 2 R}.

3
Operations on n-ary relations (Contd.)

Definition
Let R ✓ (A1 ⇥ · · · ⇥ An ) be an n-ary relation and let s1 , . . . , sk be a
subsequence of the component positions 1, . . . , n of R. The projection
of R with respect to s1 , . . . , sk is the k-ary relation

{(x1 , . . . , xk ) : (x1 , . . . , xk ) = (as1 , . . . , ask ) for some (a1 , . . . , an ) 2 R}.

3
Operations on n-ary relations (Contd.)

Definition
Let R1 ✓ (A1 ⇥ · · · ⇥ An ) and R2 ✓ B1 ⇥ · · · ⇥ Bm be relations and
suppose Ai = Bj for some i, j. The join of R1 and R2 with respect to
component i of R1 and component j of R2 is the relation

{(a1 , . . . , an , b1 , . . . , bm ) : (a1 , . . . , an ) 2 R1 , (b1 , . . . , bm ) 2 R2 , ai = bj }.

4
Operations on n-ary relations (Contd.)

Definition
Let R1 ✓ (A1 ⇥ · · · ⇥ An ) and R2 ✓ B1 ⇥ · · · ⇥ Bm be relations and
suppose Ai = Bj for some i, j. The join of R1 and R2 with respect to
component i of R1 and component j of R2 is the relation

{(a1 , . . . , an , b1 , . . . , bm ) : (a1 , . . . , an ) 2 R1 , (b1 , . . . , bm ) 2 R2 , ai = bj }.

4
Operations on binary relations

Definition
Suppose R ✓ A ⇥ B. The inverse of R is the relation
1
R = {(y , x) : (x, y ) 2 R}.

5
Operations on binary relations

Definition
Suppose R ✓ A ⇥ B. The inverse of R is the relation
1
R = {(y , x) : (x, y ) 2 R}.

Note that the inverse of a relation is the relation itself if and only if the
relation is symmetric.

5
Operations on binary relations

Definition
Suppose R ✓ A ⇥ B. The inverse of R is the relation
1
R = {(y , x) : (x, y ) 2 R}.

Note that the inverse of a relation is the relation itself if and only if the
relation is symmetric.
Example. The inverse of the relation  on Z is the relation

5
Example

Consider the relation

R = {(x, y ), (y , z), (z, y ), (z, x)}.

6
Example

Consider the relation

R = {(x, y ), (y , z), (z, y ), (z, x)}.

Then
1
R = {(y , x), (z, y ), (y , z), (x, z)}.

6
Example

Consider the relation

R = {(x, y ), (y , z), (z, y ), (z, x)}.

Then
1
R = {(y , x), (z, y ), (y , z), (x, z)}.
The digraph of the inverse relation of a relation has exactly the edges of
the digraph of the original relation, but the directions of the edges are
reversed.

6
Example

Consider the relation

R = {(x, y ), (y , z), (z, y ), (z, x)}.

Then
1
R = {(y , x), (z, y ), (y , z), (x, z)}.
The digraph of the inverse relation of a relation has exactly the edges of
the digraph of the original relation, but the directions of the edges are
reversed.

6
Exercise 1 (b), (d)

Consider the relation

R = {(a, b), (b, c), (b, d), (d, a), (c, c)}.

1
Draw a digraph for R and a digraph for R \ R .

7
Exercise 1 (b), (d)

Consider the relation

R = {(a, b), (b, c), (b, d), (d, a), (c, c)}.

1
Draw a digraph for R and a digraph for R \ R .

7
Operations on binary relations (contd.)

Definition
Suppose R1 ✓ A ⇥ B and R2 ✓ B ⇥ C . The composition of R1 and R2
is the relation

R1 · R2 = {(x, z) : (x, y ) 2 R1 , (y , z) 2 R2 }.

8
Operations on binary relations (contd.)

Definition
Suppose R1 ✓ A ⇥ B and R2 ✓ B ⇥ C . The composition of R1 and R2
is the relation

R1 · R2 = {(x, z) : (x, y ) 2 R1 , (y , z) 2 R2 }.

Example. Consider the relations

R1 = {(a, a), (a, b), (c, b)}


R2 = {(a, a), (b, c), (b, d)}.

Then
R1 · R2 = {(a, a), (a, c), (a, d), (c, c), (c, d)}.

8
Exercise 14 (a), (b)
Suppose that R1 , R2 are binary relations on a set A. Prove or disprove:

(a) If R1 , R2 are reflexive, then R1 · R2 is reflexive.


(b) If R1 , R2 are irreflexive, then R1 · R2 is irreflexive.

9
Exercise 14 (a), (b)
Suppose that R1 , R2 are binary relations on a set A. Prove or disprove:

(a) If R1 , R2 are reflexive, then R1 · R2 is reflexive.


(b) If R1 , R2 are irreflexive, then R1 · R2 is irreflexive.

Answer. (a) is true; (b) is false (for example, if A = {a, b}, then
R1 = {(a, b)}, R2 = {(b, a)} are irreflexive relations on A, but
R1 · R2 = {(a, a)} is reflexive.)

9
• Composition of relations is associative: if R, S, T are relations, then
(R · S) · T = R · (S · T )
• Notation: R 1 = R and for k 1, R k+1 = R k · R. Note that
R k+n = R k · R n

10
Closure property

Definition
If P is a property such that P can be made true for any set by adding
certain elements to the set, we call P a closure property, and define the
P-closure of the set to be the smallest set that contains it and satisfies
property P.

11
Closure property

Definition
If P is a property such that P can be made true for any set by adding
certain elements to the set, we call P a closure property, and define the
P-closure of the set to be the smallest set that contains it and satisfies
property P.

Example. The symmetric closure of R is the smallest symmetric relation


that includes R. Hence the symmetric closure of R is the set R [ R 1 .

11
Exercise 8

12
Exercise 8

Answer.

(a) The set of all positive integers


(b) The set of all integers
(c) The set of all odd positive integers
(d) The set of all integer powers of 2

12
Transitive closure

Definition
Suppose R ✓ A ⇥ A. The transitive closure of a binary relation is the
smallest relation that contains it and is transitive. We will see that the
transitive closure of R is

R+ = R [ R2 [ R3 [ · · ·

The transitive reflexive closure of a binary relation is the smallest


relation that contains it and is both transitive and reflexive. We will see
that the transitive reflexive closure of R is

R ⇤ = R + [ {(a, a) : a 2 A}.

13
Proof

Theorem
R + is the smallest relation that contains R that is transitive.

14
Proof

Theorem
R + is the smallest relation that contains R that is transitive.

Proof. We first show that R + is transitive. Suppose that xR + y , yR + z.


Then there exist positive integers i, j such that xR i y , yR j z. Hence
xR i+j y , yR i+j z, implying that xR + z.

14
Proof

Theorem
R + is the smallest relation that contains R that is transitive.

Proof. We first show that R + is transitive. Suppose that xR + y , yR + z.


Then there exist positive integers i, j such that xR i y , yR j z. Hence
xR i+j y , yR i+j z, implying that xR + z.
Next, suppose that R ✓ Q and Q is transitive. If k is a positive integer
such that R k ✓ Q, then together with the facts that R ✓ Q and Q is
transitive, we obtain that R k+1 ✓ Q. Hence by induction on k, we can
see that R k ✓ Q for all positive integers k. Hence R + ✓ Q.

14
Proof

Theorem
R + is the smallest relation that contains R that is transitive.

Proof. We first show that R + is transitive. Suppose that xR + y , yR + z.


Then there exist positive integers i, j such that xR i y , yR j z. Hence xR^(i+j)z
, implying that xR + z.
Next, suppose that R ✓ Q and Q is transitive. If k is a positive integer
such that R k ✓ Q, then together with the facts that R ✓ Q and Q is
transitive, we obtain that R k+1 ✓ Q. Hence by induction on k, we can
see that R k ✓ Q for all positive integers k. Hence R + ✓ Q.

Exercise. Prove that R ⇤ is the smallest relation that contains R that is


both transitive and reflexive.

14
Examples

1. Consider the relation ‘is a parent of’. The composition of this


relation with itself is the relation ‘is a grandparent of’ and the
transitive closure of this relation is the relation ‘is an ancestor of’.

15
Examples

1. Consider the relation ‘is a parent of’. The composition of this


relation with itself is the relation ‘is a grandparent of’ and the
transitive closure of this relation is the relation ‘is an ancestor of’.
2. Consider the relation
R = {(a, b), (b, c), (c, d)}.
Its transitive closure is
R + = {(a, b), (a, c), (a, d), (b, c), (b, d), (c, d)}.

15
Examples

1. Consider the relation ‘is a parent of’. The composition of this


relation with itself is the relation ‘is a grandparent of’ and the
transitive closure of this relation is the relation ‘is an ancestor of’.
2. Consider the relation
R = {(a, b), (b, c), (c, d)}.
Its transitive closure is
R + = {(a, b), (a, c), (a, d), (b, c), (b, d), (c, d)}.

15
Exercise 6

16
Exercise 6 (Soln.)

17
§4.6: Paths and closures

In this section, we will learn about what it means for a graph to be


connected and three kinds of connectivity relevant to digraphs.

18
Path
Definition
A directed path in a digraph A = (V , E ) is a sequence of zero or more
edges e1 , . . . , en in E for which there is sequence of vertices v0 , . . . , vn
such that
ei = (vi 1 , vi ), i = 1, . . . , n.
We say that this is a path from v0 to vn ; v0 , vn are its endpoints, and
its length is n.

19
Path
Definition
A directed path in a digraph A = (V , E ) is a sequence of zero or more
edges e1 , . . . , en in E for which there is sequence of vertices v0 , . . . , vn
such that
ei = (vi 1 , vi ), i = 1, . . . , n.
We say that this is a path from v0 to vn ; v0 , vn are its endpoints, and
its length is n.
A nondirected path in G is a sequence of zero or more edges e1 , . . . , en
in E for which there is sequence of vertices v0 , . . . , vn such that

ei = (vi 1 , vi ) or , ei = (vi , vi 1 ), i = 1, . . . , n.

19
Path
Definition
A directed path in a digraph A = (V , E ) is a sequence of zero or more
edges e1 , . . . , en in E for which there is sequence of vertices v0 , . . . , vn
such that
ei = (vi 1 , vi ), i = 1, . . . , n.
We say that this is a path from v0 to vn ; v0 , vn are its endpoints, and
its length is n.
A nondirected path in G is a sequence of zero or more edges e1 , . . . , en
in E for which there is sequence of vertices v0 , . . . , vn such that

ei = (vi 1 , vi ) or , ei = (vi , vi 1 ), i = 1, . . . , n.

A path is said to be simple if all edges and vertices on the path are
distinct, except that v0 and vn may be equal.

19
Path
Definition
A directed path in a digraph A = (V , E ) is a sequence of zero or more
edges e1 , . . . , en in E for which there is sequence of vertices v0 , . . . , vn
such that
ei = (vi 1 , vi ), i = 1, . . . , n.
We say that this is a path from v0 to vn ; v0 , vn are its endpoints, and
its length is n.
A nondirected path in G is a sequence of zero or more edges e1 , . . . , en
in E for which there is sequence of vertices v0 , . . . , vn such that

ei = (vi 1 , vi ) or , ei = (vi , vi 1 ), i = 1, . . . , n.

A path is said to be simple if all edges and vertices on the path are
distinct, except that v0 and vn may be equal.
A path of length 1 with no repeated edges and whose endpoints are
equal is called a circuit. A simple circuit is called a cycle.
19
Path
Definition
A directed path in a digraph A = (V , E ) is a sequence of zero or more
edges e1 , . . . , en in E for which there is sequence of vertices v0 , . . . , vn
such that
ei = (vi 1 , vi ), i = 1, . . . , n.
We say that this is a path from v0 to vn ; v0 , vn are its endpoints, and
its length is n.
A nondirected path in G is a sequence of zero or more edges e1 , . . . , en
in E for which there is sequence of vertices v0 , . . . , vn such that

ei = (vi 1 , vi ) or , ei = (vi , vi 1 ), i = 1, . . . , n.

A path is said to be simple if all edges and vertices on the path are
distinct, except that v0 and vn may be equal.
A path of length 1 with no repeated edges and whose endpoints are
equal is called a circuit. A simple circuit is called a cycle.
A path of non-zero length is called a nontrivial path. 19
Definition
A path e1 , . . . , en is said to traverse a vertex x if one (or more) of the
ei ’s is to or from x and x is not one of the endpoints.

20
Definition
A path e1 , . . . , en is said to traverse a vertex x if one (or more) of the
ei ’s is to or from x and x is not one of the endpoints.

20
Exercise 1

21
22
23
Exercise 6
What is the longest length possible for a simple directed path in a
digraph with n vertices? How about the longest cycle?

24
Exercise 6
What is the longest length possible for a simple directed path in a
digraph with n vertices? How about the longest cycle?

Answer. In a simple path, only the starting vertex may repeat. Therefore
the length of a simple path (and hence a cycle) is at most n.

24
Paths and composition

Theorem
If A = (V , E ) is a digraph, then for n 1, (x, y ) 2 E n = E · E . . . · E if
and only if there is a directed path of length n from x to y in A.

25
Paths and composition

Theorem
If A = (V , E ) is a digraph, then for n 1, (x, y ) 2 E n = E · E . . . · E if
and only if there is a directed path of length n from x to y in A.

Proof. We prove the theorem by induction on n. Since (x, y ) 2 E if


and only if there is a path of length 1 from x to y in A, the result is true
for n = 1. We assume the result for n 1.

25
Paths and composition

Theorem
If A = (V , E ) is a digraph, then for n 1, (x, y ) 2 E n = E · E . . . · E if
and only if there is a directed path of length n from x to y in A.

Proof. We prove the theorem by induction on n. Since (x, y ) 2 E if


and only if there is a path of length 1 from x to y in A, the result is true
for n = 1. We assume the result for n 1. Suppose there is a directed
path of length n from x to y in A:

(v0 , v1 ), . . . , (vn 1 , vn ), v0 = x, vn = y .

Since there is a directed path of length n 1 from v0 to vn 1 in A, by


induction hypothesis, we get that (v0 , vn 1 ) 2 E n 1 . Since
(vn 1 , vn ) 2 E , we obtain that (v0 , vn ) 2 E n 1 · E = E n .

25
Proof (contd.)

Conversely, suppose that (v0 , vn ) 2 E n . Since E n = E n 1 · E , there exists


some vn 1 such that (v0 , vn 1 ) 2 E n 1 and (vn 1 , vn ) 2 E . By induction
hypothesis, there is a directed path

(v0 , v1 ), . . . , (vn 2 , vn 1 )

of length n 1 from v0 to vn 1 in A. Adding (vn 1 , vn ) gives the


required path of length n.

26
Proof (contd.)

Conversely, suppose that (v0 , vn ) 2 E n . Since E n = E n 1 · E , there exists


some vn 1 such that (v0 , vn 1 ) 2 E n 1 and (vn 1 , vn ) 2 E . By induction
hypothesis, there is a directed path

(v0 , v1 ), . . . , (vn 2 , vn 1 )

of length n 1 from v0 to vn 1 in A. Adding (vn 1 , vn ) gives the


required path of length n.
Corollary
If A = (V , E ) is a digraph, then for any two vertices x, y 2 V ,
(x, y ) 2 E + if and only if there is a non-trivial directed path from x to
y in A.

26
Proof (contd.)

Conversely, suppose that (v0 , vn ) 2 E n . Since E n = E n 1 · E , there exists


some vn 1 such that (v0 , vn 1 ) 2 E n 1 and (vn 1 , vn ) 2 E . By induction
hypothesis, there is a directed path

(v0 , v1 ), . . . , (vn 2 , vn 1 )

of length n 1 from v0 to vn 1 in A. Adding (vn 1 , vn ) gives the


required path of length n.
Corollary
If A = (V , E ) is a digraph, then for any two vertices x, y 2 V ,
(x, y ) 2 E + if and only if there is a non-trivial directed path from x to
y in A.

To prove this, use the above theorem and the definition of E + .

26
Remark. If R is a relation on a set of n vertices, then any path of length
greater than n between two vertices must have a repeated vertex and
hence must include a circuit. Such a path can therefore be shortened to a
path of length at most n. Hence R + = R [ R 2 [ . . . [ R n .

27
Remark. If R is a relation on a set of n vertices, then any path of length
greater than n between two vertices must have a repeated vertex and
hence must include a circuit. Such a path can therefore be shortened to a
path of length at most n. Hence R + = R [ R 2 [ . . . [ R n .
Question
Let A = {a, b, c, d, e} and
R = {(a, a), (a, b), (b, c), (c, d), (c, e), (d, e)}. Find the transitive
closure of R.

27
Remark. If R is a relation on a set of n vertices, then any path of length
greater than n between two vertices must have a repeated vertex and
hence must include a circuit. Such a path can therefore be shortened to a
path of length at most n. Hence R + = R [ R 2 [ . . . [ R n .
Question
Let A = {a, b, c, d, e} and
R = {(a, a), (a, b), (b, c), (c, d), (c, e), (d, e)}. Find the transitive
closure of R.

We have
R 2 = {(a, a), (a, b), (a, c), (b, e), (b, d), (c, e)}
R 3 = {(a, a), (a, b), (a, c), (a, d), (a, e), (b, e)}
R 4 = {(a, a), (a, b), (a, c), (a, d), (a, e)} = R 5 .
Hence R + = R [ R 2 [ . . . [ R 5 =
{(a, a), (a, b), (a, c), (a, d), (a, e), (b, c), (b, d), (b, e), (c, d), (c, e), (d, e)}.
27
Connectivity
Definition
Two vertices x, y in a digraph are said to be

1. weakly connected if there is a non-directed path between them


2. unilaterally connected if there is a directed path between them
3. strongly connected if there is a directed path from x to y and a
directed path from y to x

28
Connectivity
Definition
Two vertices x, y in a digraph are said to be

1. weakly connected if there is a non-directed path between them


2. unilaterally connected if there is a directed path between them
3. strongly connected if there is a directed path from x to y and a
directed path from y to x

Definition
A graph is (weakly, unilaterally, strongly) connected if every pair of
vertices in the graph is (weakly, unilaterally, strongly) connected.

28
Connectivity
Definition
Two vertices x, y in a digraph are said to be

1. weakly connected if there is a non-directed path between them


2. unilaterally connected if there is a directed path between them
3. strongly connected if there is a directed path from x to y and a
directed path from y to x

Definition
A graph is (weakly, unilaterally, strongly) connected if every pair of
vertices in the graph is (weakly, unilaterally, strongly) connected.

Definition
A subgraph A1 of a graph A is a (weakly, unilaterally, strongly)
connected component if it is (weakly, unilaterally, strongly) connected
and there is no (weakly, unilaterally, strongly) connected subgraph of A
that properly contains A1 .
28
Example

Consider the graph

29
Example

Consider the graph

29
Example

Consider the graph

The unilaterally connected components are:


({a, b}, {(a, b)}), ({b, c}, {(b, c)}), ({d, e, f , g }, {(d, e), (e, f ), (f , g ), (g , e)})

29
Example

Consider the graph

The unilaterally connected components are:


({a, b}, {(a, b)}), ({b, c}, {(b, c)}), ({d, e, f , g }, {(d, e), (e, f ), (f , g ), (g , e)})

29
Exercise 3

30
Exercise 3

30
Exercise 3

When the term ‘connected’ is used without further qualification, it will


mean weakly connected.

30

You might also like