You are on page 1of 31

Relations

Discrete Mathematical Structures:


Theory and Applications
Relations
• Examples of statements from everyday life
which illustrate relations:

‘Ali is the husband of Alia’


‘Nadir is the sister of Nuha’
‘Australia has a smaller population than
China’
‘Discrete Maths is a prerequisite for
Encryption and Network Security’ 2
More Examples which Illustrate
Relations
• Examples of statements from mathematics
which illustrate relations:

‘12 is greater than 4’


‘{a} is a subset of {a, b, c}’
‘20 is divisible by 4’
‘Line L1 is parallel to line L2’

3
Comments on the Examples
• In each of the examples, a statement is made
about a pair of objects of the same type.

• The order of the objects is often important – e.g. it


is true that ‘Australia has a smaller population than
China’, but it is not true that ‘China has a smaller
population than Australia’
• Thus relations involve 2 objects of the same type
(i.e. from the same set), where order is important
4
Definitions of a Relation
• Informal Defn: A relation can be thought of as a
statement about ordered pairs (x, y) that are in
A × A, where A is some set.

• This is the basic idea of a relation, although the


formal definition looks a little different.

• Formal Defn: A (binary) relation on a set A is a


subset R of A × A. We say that x & y are related
iff (x, y) ∈ R. 5
Relations
• Relations are a natural way to associate objects
of various sets

(Cartesian product)

6
Relations
• A binary relation occurs when we say
something about a property of an object
relative to another object of the same type

• Example: The statement ‘Ali is taller than Yasir’


illustrates a relation

• The word ‘binary’ refers to the fact that two


objects are compared – in future, we’ll omit this
word and refer to just a ‘relation’ 7
Relations
• Arrow Diagram
• Write the elements of A in one column
• Write the elements B in another column
• Draw an arrow from an element, a, of A to an element, b,
of B, if (a ,b)  R
• Here, A = {2,3,5} and B = {7,10,12,30} and R from A into
B is defined as follows: For all a  A and b  B, a R b if
and only if a divides b
• The symbol → (called an arrow) represents the relation R

8
Relations

9
Relations
• Directed Graph
• Let R be a relation on a finite set A

• Describe R pictorially as follows:


• For each element of A , draw a small or big dot and label
the dot by the corresponding element of A

• Draw an arrow from a dot labeled a , to another dot


labeled, b , if a R b .

• Resulting pictorial representation of R is called the


directed graph representation of the relation R
10
Relations

11
Relations
• Directed graph (Digraph) representation of R
• Each dot is called a vertex
• If a vertex is labeled, a, then it is also called vertex a
• An arc from a vertex labeled a, to another vertex, b is
called a directed edge, or directed arc from a to b
• The ordered pair (A , R) a directed graph, or digraph,
of the relation R, where each element of A is a called
a vertex of the digraph

12
Relations
• Directed graph (Digraph) representation of R
(Continued)
• For vertices a and b , if a R b, a is adjacent to b and b is
adjacent from a
• Because (a, a)  R, an arc from a to a is drawn; because
(a, b)  R, an arc is drawn from a to b. Similarly, arcs are
drawn from b to b, b to c , b to a, b to d, and c to d
• For an element a  A such that (a, a)  R, a directed edge
is drawn from a to a. Such a directed edge is called a loop
at vertex a

13
Relations
• Directed graph (Digraph) representation of R
(Continued)
• Position of each vertex is not important
• In the digraph of a relation R, there is a directed edge
or arc from a vertex a to a vertex b if and only if a R b
• Let A ={a ,b ,c ,d} and let R be the relation defined
by the following set:
• R = {(a ,a ), (a ,b ), (b ,b ), (b ,c ), (b ,a ), (b ,d ),
(c ,d )}

14
Relations
• Domain and Range of the Relation
• Let R be a relation from a set A into a set B. Then R ⊆ A x B. The elements of
the relation R tell which element of A is R-related to which element of B

15
Example
• Consider the relation ‘is greater than’ on the
set A = {3, 5, 6, 8}.

• For any (x, y) ∈ A × A, either x is greater than


y, and then x is related to y or x is not greater
than y, and then x is not related to y.

• The set of the ordered pairs (x, y) ∈ A × A, for


which x is related to y is given by:
R = {(5, 3), (6, 3), (8, 3), (6, 3), (6, 5), (8, 6)} 16
Notation for a Relation

• In the previous example, we can state that x & y


are related by writing (x, y) ∈ R.

• In practice, this is often written as xRy (read this


as ‘x is related to y’).

• For the previous example, we can write ‘x > y’


instead of xRy to mean that x is related to y

17
Graphical Repn of a Relation
• Example: The reln ‘>’ on the set A = {3, 5, 6, 8}
can be depicted using a graph. The elements
of A are represented by dots, & if x is related
to y, an arrow is drawn from x to y. The result
is called a directed graph.

18
Matrix Repn of a Relation
• A relation can also be represented by a matrix
(plural ‘matrices’) called the relation matrix.

• The entry in row x & column y is T if x is


related to y, and is F otherwise.

• e.g. For ‘>’ on {3, 5, 6, 8}, the


relation matrix is given by

19
Application: Relational Database

20
Application: Relational Database

21
Application: Relational Database

22
Properties of Relations
• There are several properties that are used to classify
relations on a set.
• In some relations an element is always related to
itself.
• For example, let R be the relation on the set of all
people consisting of pairs (x,y) where x and y has the
same father and the same mother. Then xRx for
every person x.

23
Properties of Relations
• A relation R on a set A is called reflexive if
(a,a)R for every element aA (aA), aRa.

– E.g., the relation ≥ :≡ {(a,b) | a≥b} is reflexive

 A relation R on the set A is reflexive if


a((a,a)R) when the universe of discourse is the set of all elements in A.
Reflexive means that every member is related to itself

 A relation R on a set A is called irreflexive if


(a,a)  R for every element in A
There is no element in A is related to itself

24
Properties of Relations
Example
Consider the following relations on the {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),(3,4)}
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 25
Properties of Relations
 A relation R on a set A is symmetric
if (b,a)R whenever (a,b)R for all a,b A
ab((a,b) R → (b,a)R )

 A relation R on a set A is antisymmetric


if (a,b)R and (b,a)R then a=b for all a,b A
ab((a,b) R  (b,a)R → (a=b) )

Note that “the term symmetric and antisymmetric are not


opposites, the relation can have both of these properties or may
lack both of them”

26
Properties of Relations
A relation cannot be both symmetric and antisymmetric if it
contains some pair of the form (a,b), where a≠b
example
Let R be the following relation defined on the set
{a, b, c, d}:
R = {(a, a), (a, c), (a, d), (b, a), (b, b), (b, c), (b, d), (c, b), (c, c), (d,
b), (d, d)}.
Determine whether R is:
(a) reflexive. Yes
(b) symmetric. No there is no (c,a) for example
(c) antisymmetric. No b  c b  d
27
Properties of Relations
A relation cannot be both symmetric and antisymmetric if it
contains some pair of the form (a,b), where a≠b

example
Let R be the following relation defined on the set
{a, b, c, d}:
R = {(a, a), (b, b), (c, c), (d, d)}.
Determine whether R is:
(a) reflexive. Yes
(b) symmetric. yes
(c) antisymmetric. yes
28
Properties of Relations
Example
Consider the following relations on the {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),(3,4)}
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 which are
antisymmetric ?
R2 and R3 are symmetric because in each case (b,a) belongs to the
29
Properties 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)

30
Properties of Relations
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
vertex z, there is an edge from a vertex x to a vertex z
completing a triangle where each side is a directed edge with the
correct direction.

2
1

3 4
31

You might also like