0% found this document useful (0 votes)
19 views

Lecture 07

The document discusses relationships between elements of sets and how they are represented using relations. It defines key concepts like ordered pairs, binary relations, Cartesian products of sets, and different ways to represent relations including graph diagrams, arrow diagrams, directed graphs and matrix representations. It provides examples to illustrate these concepts and solves some exercises on finding relations and representing them in different formats.

Uploaded by

Ateeq Aulakh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Lecture 07

The document discusses relationships between elements of sets and how they are represented using relations. It defines key concepts like ordered pairs, binary relations, Cartesian products of sets, and different ways to represent relations including graph diagrams, arrow diagrams, directed graphs and matrix representations. It provides examples to illustrate these concepts and solves some exercises on finding relations and representing them in different formats.

Uploaded by

Ateeq Aulakh
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 19

Discrete Structures

COSC-1103

Ms. Urooj Akram


[email protected]
Relationship

 Every day we deal with different relationships. Relationships


between elements of sets occur in many contexts.
 Relationships such as that between a program and a variable it
uses, and that between a computer language and a valid statement
in this language often arise in computer science.
Sets and relationships
 Relationships between elements of sets are represented using the structure
called a relation. Relations can be used to solve problems such as 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.
 In some computer languages, only the first 31 characters of the name of a
variable matter. The relation consisting of ordered pairs of strings where the
first string has the same initial 31 characters as the second string is an
example of a special type of relation, known as an equivalence relation.
Equivalence relations arise throughout mathematics and computer science.
Introduction to relations
The most direct way to express a relationship between elements of two
sets is to use ordered pairs made up of two related elements. Sets of
ordered pairs are called binary relations. In this section we introduce
the basic terminology used to describe binary relations.
Let A and B be sets. A binary relation from A to B is a subset of
A × B.
Relation can be used to solve problems involving
communications networks, project scheduling, and
identifying elements in sets with common properties.
Order Pair
An ordered pair (a, b) consists of two elements “a” and “b” in which “a” is the
first element and “b” is the second element.
The ordered pairs (a,b) and (c,d) are equal iff, a= c and b = d.
 Note that (a, b) and (b, a) are not equal unless a = b.
Exercise:
Find x and y given (2x, x + y) = (6, 2)
Solution:
Two ordered pairs are equal if and only if the corresponding components are equal.
Hence, we obtain the equations:
2x = 6 ………………(1)
and x+y=2 ……………..(2)
Solving equation (1) we get x = 3 and when substituted in (2) we get y = -1.
Order Pair
In other words, a binary relation from set ‘A’ to set ‘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’. We use the notation a R b to denote that (a, b)
∈ R and a R b to denote that (a, b) ∈ R. Moreover, when (a, b) belongs to R, a
is said to be related to b by R. Binary relations represent relationships
between the elements of two sets. We will introduce n-ary relations, which
express relationships among elements of more than two sets.
Ordered n-Tuple:
In particular, an ordered 2-tuple is called an ordered pair, and an
ordered 3-tuple is called an ordered triple.
The ordered n-tuple, (a1, a2, …, an) consists of elements
a1, a2, … an together with the ordering: first a 1, second a2, and so
forth up to an.
Two ordered n-tuples (a1, a2, …, an) and (b1, b2, …, bn) are equal if
and only if each corresponding pair of their elements is equal, i.e., a i
= bj, for all
 i = 1, 2, …, n.
Cartesian Product Of Two Sets
Let A = {1, 2}, B = {a, b, c} then
A B = {(1,a), (1,b), (1,c), (2,a), (2, b), (2, c)}
B A = {(a,1), (a,2), (b, 1), (b, 2), (c, 1), (c, 2)}
A A = {(1, 1), (1,2), (2, 1), (2, 2)}
B B = {(a,a), (a,b), (a,c), (b,a), (b, b), (b, c), (c,a), (c,b),(c,c)}
Cartesian Product Of Two Sets

 A  BB  A for non-empty and unequal sets A and B.


 A= A= 
 | A  B| = |A|  |B|
Cartesian Product Of More Than Two Sets

The Cartesian product of sets A1, A2, …, An, denoted A1 A2 


… An, is the set of all ordered n-tuples (a1, a2, …, an) where
a1 A1, a2 A2,…, an An.

Symbolically: attested

A1 A2  … An ={(a1, a2, …, an) | ai Ai, for i=1, 2, …, n}


Relations of sets
Exercise :
Find all binary relations from {0,1} to {1}
Solution:
Let A = {0,1} & B = {1}
Then A  B = {(0,1), (1,1)}
All binary relations from A to B are in fact all subsets of A B, which are:
R1 =  R2 = {(0,1)}
R3 = {(1,1)} R4 = {(0,1), (1,1)} = A  B
Note:-
If |A| = m and |B| = n
Then as we know that the number of elements in A  B are m  n. Now as we know that the
total number of and the total number of relations from A to B are 2 m  n.
Relation On a Set
A relation on the set A is a relation from A to A.
In other words, a relation on a set A is a subset of A  A.
Example:
Let A = {1, 2, 3, 4}
Define a relation R on A as:
(a,b)  R iff a divides b {symbolically written as a  b}
Then R = {(1,1), (1,2), (1,3), (1,4), (2,2),(2,3), (2,4), (3,3),(3,4),(4,4)}
Remark:
For any set A
1. A  A is known as the universal relation.
2.  is known as the empty relation.
Relation On a Set
Representation of Relations

 Graph diagram
 Arrow diagram
 Directed graph
 Matrix
1. Coordinate Diagram (Graph) of a Relation

Let A = {1, 2, 3}
and
B = {x, y} y
Let R be a relation from A to B defined as B
R = {(1, y), (2, x), (2, y), (3, x)} x
The relation may be represented in a
coordinate diagram as: 1 2 3
A
2. Arrow Diagram of a Relation

Let
A = {1, 2, 3}, B = {x, y} 1 R
x
And
R = {1,y), (2,x), (2,y), (3,x)} 2
be a relation from A to B.
y
The arrow diagram of R is: 3

A B
3. Directed Graph of a Relation

Let A = {0, 1, 2, 3} 1
And 0
R = {(0,0), (1,3), (2,1), (2,2), (3,0), (3,1)}
be a binary relation on A.

2 3

DIRECTED GRAPH
4. Matrix Representation of a Relation
Let
A = {a1, a2, …, an}
And
B = {b1, b2, …, bm}.
Let R be a relation from A to B.
Define the n  m order matrix M by

1 if ( ai , bi )  R
m(i, j )  
0 if ( ai , bi )  R

for i=1,2,…,n and j=1,2,…,m


Exercise
For the relation matrix.
 List the set of ordered pairs represented by M.
 Draw the directed graph of the relation.

Solution:
The relation corresponding to the given Matrix is
 R = {(1,1), (1,3), (2,1), (3,1), (3,2), (3,3)}
 And its Directed graph is given as:

1 2

You might also like