You are on page 1of 18

Discrete Structures

Sets, Functions, Matrices, and Relations


(Lecture – 3)

Dr. Nirnay Ghosh


Relations
 Relationships between elements of sets occur in many contexts
 They are represented using the structure called a relation,
which is just a subset of the Cartesian product of the sets.
 Few applications: determining which pairs of cities are linked
by airline flights in a network, finding a viable order for the
different phases of a complicated project, or producing a useful
way to store information in computer databases.
 The most direct way to express a relationship between
elements of two sets is to use ordered pairs made up of two
related elements.
 The sets of ordered pairs are called binary relations.
2 9/6/2019
Binary Relation

 A binary relation from A to B is a set R of ordered pairs where the


first element of each ordered pair comes from A and the second
element comes from B.
 The notation a R b denotes that (a, b) ∈ R and a R b denotes that (a, b)
∈ R.
 If (a, b) ∈ R, a is said to be related to b by R.
 Relations on a Set: A relation on a set A is a subset from AXA

3 9/6/2019
Properties of Relations
 Reflexive Property

 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?

4 9/6/2019
Properties of Relations
 Symmetric Property

 A relation is symmetric if and only if a is related to b implies that b is


related to a.
 A relation is antisymmetric if and only if there are no pairs of distinct
elements a and b with a related to b and b related to a.
 The terms symmetric and antisymmetric are not opposites, because a
relation can have both of these properties or may lack both of them.

5 9/6/2019
Properties of Relations
 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 symmetric and antisymmetric?
 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}.
6 Which of these relations are symmetric and antisymmetric? 9/6/2019
Properties of Relations
 Transitive Property

 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 transitive?
 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}.
7 Which of these relations is transitive? 9/6/2019
Combining Relations
 Combining Relations
 Union, intersection, set difference, orthogonal sum

 Composite Relation

 Recursive definition of Relation

8 9/6/2019
Representing 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} to B = {b1, b2, . .
. , bn}. It can be represented by the matrix MR = [mij], where

 In other words, the zero–one matrix representing R has a 1 as its (i, j)


entry when ai is related to bj, and a 0 in this position if ai is not related
to bj . (Such a representation depends on the orderings used for A and
B.)

9 9/6/2019
Representing Properties of Relation using
Square Matrices
 Relation R on A is reflexive if (a,
a) ∈ R whenever a ∈ A.
 R is reflexive if and only if (ai, ai) ∈
R for i = 1, 2, . . . , n.
 R is reflexive if and only if mi,i = 1,
for i = 1, 2, . . . , n.
 R is reflexive if all the elements on
the main diagonal of MR are equal
to 1 (note that the elements off the
main diagonal can be either 0 or 1

10 9/6/2019
Representing Properties of Relation using
Square Matrices
 Relation R on A is symmetric if (a, b) ∈
R implies that (b, a) ∈ R, for all a, b ∈ A.
 R is symmetric if and only if (aj, ai) ∈ R
whenever (ai, aj) ∈ R for i = 1, 2, . . . , n.
 R is symmetric if and only if mj,i = 1
whenever mj,i = 1, for i = 1, 2, . . . , n. This
also means mj,i = 0 whenever mi,j = 0.
 R is symmetric if and only if mi,j = mj,i for
all pair of integers i and j, with i = 1,
2, . . . , n and j = 1, 2, . . . , n.
 R is symmetric if and only if MR = (MR)t
 MR is a symmetric matrix and

11 9/6/2019
Representing Properties of Relation using
Square Matrices
 Relation R on A is antisymmetric if and only if (a, b)∈
R and (b, a)∈ R, implies a = b, for some a, b∈ A.
 R is antisymmetric if it has the property that if
mi,j=1, then mj,i=0 (for i ≠ j)
 In other words, either mi, j = 0 or mj,i = 0 when i ≠
j.
 Relation R on A is transitive if and only if (a, b)∈ R2
implies (a, b)∈ R for some a, b∈ A.
 Take composition of the given relation with itself
 Find Boolean product of the relation matrix by
multiplying with itself.
 M𝑅 𝑅 = MR2 = MR ۨ MR = MR[2]

 R is transitive if m(2)i,j=1, then mi,j=1 (for all i,j)
12 9/6/2019
Representing Relations Using Digraphs

 An edge of the form (a, a) is represented using an arc from the vertex a
back to itself.
 Such an edge is called a loop.
 The relation R on a set A is represented by the
directed graph that has the elements of A as its
vertices and the ordered pairs (a, b), where (a, b)
∈ R, as edges.
 This assignment sets up a one-to-one
correspondence between the relations on a set A
and the directed graphs with A as their set of
vertices.
 Thus, every statement about relations
corresponds to a statement about directed graphs,
and vice versa.
 Directed graphs give a visual display of
13 9/6/2019
information about relations.
Representing Relations Using Digraphs
 Directed graphs representing a relation can be used to
determine whether the relation has various properties:
 Reflexive: A relation is reflexive if and only if there is a loop at every
vertex of the directed graph, so that every ordered pair of the form (x,
x) occurs in the relation.
 Symmetric: A relation is symmetric if and only if for every edge
between distinct vertices in its digraph, there is an edge in the opposite
direction, so that (y, x) is in the relation whenever (x, y) is in the
relation.
 Antisymmetric: A relation is antisymmetric if and only if there are
never two edges in opposite directions between distinct vertices.
 Transitive: A relation is transitive if and only if whenever there is an
edge from a vertex x to a vertex y and an edge from a vertex y to a
14
vertex z, there is an edge from x to z 9/6/2019
Equivalence Relations

 Reflexive property: Every element should be equivalent to itself.


 Symmetric property: It makes sense to say that a and b are related
(not just that a is related to b) by an equivalence relation, because
when a is related to b, b is also related to a.
 Transitive property: If a and b are equivalent and b and c are
equivalent, it follows that a and c are equivalent.
15 9/6/2019
Equivalence Classes

 In other words, if R is an equivalence relation on a set A, the


equivalence class of the element a is [a]R = {s | (a, s) ∈ R}.
 If b ∈ [a]R, then b is called a representative of this equivalence class.
 Any element of a class can be used as a representative of this class.

16 9/6/2019
Equivalence Class and Partition
 Let A be the set of students who are majoring in exactly one subject, and
let R be the relation on A consisting of pairs (x, y), where x and y are
students with the same major.
 R is an equivalence relation.
 R splits all students in A into a collection of disjoint subsets, where each
subset contains students with a specified major.
 For instance, one subset contains all students majoring (just) in computer
science, and a second subset contains all students majoring in history.
 These subsets are equivalence classes of R.
 The equivalence classes of an equivalence relation partition a set into
disjoint, nonempty subsets.

17 9/6/2019
Partitioning of a Set by Equivalence
Relation
 Let R be an equivalence relation on a set A. The union
of the equivalence classes of R is all of A, because an
element a of A is in its own equivalence class, namely,
[a]R.

 From Theorem 1, it follows that these equivalence


classes are either equal or disjoint, so [a]R ∩ [b]R = ∅,
when [a]R ≠ [b]R.
 Equivalence classes form a partition of A, because
they split A into disjoint subsets.
 More precisely, a partition of a set S is a collection
of disjoint nonempty subsets of S that have S as their
union.
 Collection of subsets Ai, i ∈ I (where I is an index
set) forms a partition of S if and only if
 Ai ≠ ∅ for i ∈ I,
 Ai ∩ Aj = ∅ when i = j,
 and
18 9/6/2019

You might also like