DM - CH 1 (Set, Relation - Functions)
DM - CH 1 (Set, Relation - Functions)
I. Introduction:
In everyday life, we often speak of collections of objects of a particular kind, such as, a pack of
cards, a crowd of people, a cricket team, etc. In mathematics also, we come across collections,
for example, of natural numbers, points, prime numbers, etc. More specially, we examine the
following collections:
a. Odd natural numbers less than 10, i.e., 1, 3, 5, 7, 9
b. The rivers of India.
c. The vowels in the English alphabet, namely, a, e, i, o, u
d. Various kinds of triangles
e. Prime factors of 210, namely, 2,3,5 and 7
f. The solution of the equation: x2 – 5x + 6 = 0, viz., x=2 and x=3.
Definition:
SET: A set is a well-defined collection of objects.
b. Set-builder form
In set-builder form, all the elements of a set possess a single common property which is not
possessed by any element outside the set.
For example
1. In the set {a, e, i, o, u}, all the elements possess a common property, namely, each of
them is a vowel in the English alphabet, and no other letter possess this property.
i.e. V = {x: x is a vowel in English alphabet}
For Example:
(i) B = { x : x is a student presently studying in both Classes X and XI }={}
A student cannot study simultaneously in both Classes X and XI. Thus, the
set B contains no element at all.
Examples:
(i) Let W be the set of the days of the week. Then W is finite.
(ii) Let G be the set of points on a line. Then G is infinite.
For examples:
(i) Let A = {1, 2, 3, 4} and B = {3, 1, 4, 2}. Then A = B.
iv. Subsets
A set A is said to be a subset of a set B if every element of A is also an element of B.
A is subset of B is expressed in symbols as A ⊂ B.
A B if a A ⇒ a B
NOTE:
1. Every set A is a subset of itself.
2. φ is a subset of every set.
For example:
A = {1, 2, 3} is a proper subset of B = {1, 2, 3, 4}.
Example: U = {1,2,3, ..., 10} is the universal set of which A = {2,4,6,8,10} is a subset.
Figure:1-1
Example: U = {1,2,3, ..., 10} is the universal set of which A = {2,4,6,8,10} and B = {4, 6} are
subsets, and also B A .
Figure:1-2
V. Operations on Sets
1. Union of sets
The union of two sets A and B is the set which consists of all those elements which are either in
A or in B (including those which are in both).
A ∪ B = {x : x ∈A or x ∈B}
Figure:1-3
2. Intersection of sets
The intersection of two sets A and B is the set of all those elements which belong to bothA and
B.A ∩ B = {x : x A and x B }
Figure:1-4
3. Disjoint Sets: If A and B are two sets such that A ∩ B = φ, then A and B are called
disjoint sets.
Figure:1-5
4. Difference of sets
The difference of the sets A and B is the set of elements which belong to A but not to B.
A – B = { x : x A and x B }
Figure:1-7
Figure:1-8
5. Complement of a Set
Let U be the universal set and A a subset of U. Then the complement of A is the set of all
elements of U which are not the elements of A.
A′ = {x: x U and x A }
Figure:1-9
Note: If A is a subset of the universal set U, then its complement A′ is also a subset of U.
Applications:
1. Let A and B be finite sets. If A ∩ B = φ, then n(A∪B)=n(A)+n(B)
2. In general, if A and B are finite sets, then n(A∪B)=n(A)+n(B)–n(A∩B)
3. The sets A – B, A ∩ B and B – A are disjoint and their union is A B
n(A B)=n(A–B)+n(A∩B)+n(B–A)
= n(A–B)+n(A∩B)+n(B–A)+n(A∩B)–n(A∩B)
= n(A)+n(B)–n(A∩B)
4. If A, B and C are finite sets, then
n(A∪B∪C)=n(A)+n(B)+n(C)–n(A∩B)–n(B∩C)–n(A∩C)+n(A∩B∩C)
Example: If X and Y are two sets such that X Y has 50 elements, X has 28 elements and Y
has 32 elements, how many elements does X ∩ Y have?
Solution: Given that n(X Y)=50, n(X)=28, n(Y)=32, n(X∩Y) = ?
By using the formula
n ( X Y ) = n ( X ) + n ( Y ) – n ( X ∩ Y ),
n ( X ∩ Y ) = n ( X ) + n ( Y ) – n ( X Y )
= 28 + 32 – 50 = 10
Figure:1-10
Example:
Let U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} and A = {1, 3, 5, 7, 9}, B={2, 4, 5, 8, 9, 10}, C={1, 5, 9}.
Find
(i) A, B, C
(ii) A B
(iii) A B
(iii) Verify DeMorgan's Laws
( A B ) = ( A B ) and ( A B ) = ( A B )
Application:
The time required to manipulate information in a database depends on how this information is
stored. The operations of adding and deleting records, updating records, searching for records,
and combining records from overlapping databases are performed millions of times each day in a
large database. Because of the importance of these operations, various methods for representing
databases have been developed. One of these methods, called the relational data model is based
on the concept of a relation.
The database query language SQL (short for Structured Query Language) can be used to carry
out the operations we have described in this section. Example 12 illustrates how SQL commands
are related to operations on n-ary relations.
Definition
Let P and Q be two sets. The Cartesian product P × Q is the set of all ordered pairs p,q, where
p∈P and q∈Q
i.e. P×Q=p,q:p∈P, q∈Q
Note the following:
• The Cartesian product of the sets A1,A2,…,An denoted by A1A2An is the set of ordered n-
tuples a1,a2,…,an, where ai belongs to Ai for i = 1, 2, . . . , n.
In other words, A1A2An=aiAi, for i=1,2,…,nThe ordered pairs (a, b) and c, d are equal if
and only if a = c and b = d.
• If either P or Q is the null set, then P × Q will also be empty set.
• If A and B are non-empty sets and either A or B is an infinite set, then so is A × B .
• If there are p elements in A and q elements in B, then there will be pq elements in A × B,
i.e., if n(A) = p and n(B) = q, then n(A × B) = pq.
• An=A×A××A=ai∈A, for i=1,2,…,n
Illustration
Consider the two sets: A={DL, MP, KA}, where DL, MP, KA represent Delhi, Madhya Pradesh
and Karnataka, respectively and B = 01,02, 03 representing codes for the licence plates of
vehicles issued by DL, MP and KA .
If the three states, Delhi, Madhya Pradesh and Karnataka were making codes for the licence
plates of vehicles, with the restriction that the code begins with an element from set A, which are
the pairs available from these sets and how many such pairs will there be ?
The available pairs are:
(DL,01), (DL,02), (DL,03), (MP,01), (MP,02), (MP,03), (KA,01), (KA,02), (KA,03) and the
product of set A and set B is given by
A × B = {(DL,01), (DL,02), (DL,03), (MP,01), (MP,02), (MP,03), (KA,01), (KA,02),
(KA,03)}.
It can easily be seen that there will be 9 such pairs in the Cartesian product, since there are 3
elements in each of the sets A and B. This gives us 9 possible codes.
Also note that the order in which these elements are paired is crucial.
For example, the code (DL, 01) will not be the same as the code (01, DL).
RELATIONS AND THEIR PROPERTIES
Definition
A relation R from a non-empty set A to a non-empty set B is a subset of the Cartesian product A
× B.
The subset is derived by describing a relationship between the first element and the second
element of the ordered pairs in A × B.
The second element is called the image of the first element.
For example, R = a, 0, a, 1, a, 3, b, 1, b, 2, c, 0, c, 3 is a relation from the set {a, b, c} to the set
{0, 1, 2, 3}.
A relation from a set A to itself is called a relation on A.
Definition
The set of all first elements of the ordered pairs in a relation R from a set A to a set B is called
the domain of the relation R.
Definition
The set of all second elements in a relation R from a set A to a set B is called the range of the
relation R. The whole set B is called the codomain of the relation R.
Problem.2
Let A=1, 2, 5 and B=3, 5,7 and let R=7≤a+b<10, a∈A,b∈B.
1) Write all the elements of R and R’ 2) Write the inverse relation of R.
3) Find the Domain and Range of R and R-1 .
Solution:
1. R=1,7,2,5,2,7,5,3 R'={1,3,1,5,2,3,5,5,5,7}
2. R-1=7,1,5,2,7,2,3,5
3. DomR=1,2,5, RangeR=3,7,5DomR-1=3,7,5, RangeR=1,2,5
Problem.3
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)?
Solution:
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; and finally, (2,2) is in R1, R3, and R4.
Exercise
1. Let A = {1, 2, 3,...,14}. Let a relation R on A be defined as
R={(x, y) :3x-y=0, where x, y ∈A}. Write down its domain, codomain and range.
2. Let A={x, y, z} and B={1, 2}. Find the number of relations from A to B. Which of the
following is not a relation from A to ? Justify your answer.
i.x,1,y,2,(z,3)
ii.x,1,x,2
iii.x,2,y,2,z,2
iv.1,x,2,x
3. If R = 1,2,2,4,3,3 and S = 1,3,2,4,4,2 represents some relations on some sets then what is
1) R ∪ S 2) R ∩ S 3) R -S 4) S –R 5) R⊕S
Also verify if (i) Domain of R∪ S=Domain of RDomain ofS
and (ii)Range(R ∩ S) ⊆ Range (R) ∩ Range(S)
Lecture 2
PARUL UNIVERSITY - FACULTY OF ENGINEERING & TECHNOLOGY
Department of Applied Science & Humanities 3rd Semester B. Tech (CSE, IT)
Discrete Mathematics (203191202)
UNIT-1 Sets, Relation & Functions
Definition
Let P and Q be two sets. The Cartesian product P × Q is the set of all ordered pairs (𝒑, 𝒒),
where 𝒑 ∈ 𝑷 and 𝒒 ∈ 𝑸
i.e. 𝑷 × 𝑸 = {(𝒑, 𝒒): 𝒑 ∈ 𝑷, 𝒒 ∈ 𝑸}
Note the following:
• The Cartesian product of the sets 𝐴1 , 𝐴2 , … , 𝐴𝑛 denoted by 𝐴1 × 𝐴2 × … × 𝐴𝑛 is the set
of ordered n-tuples (𝑎1 , 𝑎2 , … , 𝑎𝑛 ), where 𝑎𝑖 belongs to 𝐴𝑖 for 𝑖 = 1, 2, . . . , 𝑛.
In other words, 𝐴1 × 𝐴2 × … × 𝐴𝑛 = {(𝑎1 , 𝑎2 , … , 𝑎𝑛 )|𝑎𝑖 ∈ 𝐴𝑖 , 𝑓𝑜𝑟 𝑖 = 1,2, … , 𝑛}The
ordered pairs (𝑎, 𝑏) and (𝑐, 𝑑) are equal if and only if 𝑎 = 𝑐 and 𝑏 = 𝑑.
• If either P or Q is the null set, then P × Q will also be empty set.
• If A and B are non-empty sets and either A or B is an infinite set, then so is A × B .
• If there are p elements in A and q elements in B, then there will be pq elements in A × B,
i.e., if n(A) = p and n(B) = q, then n(A × B) = pq.
• 𝐴𝑛 = 𝐴 × 𝐴 × … × 𝐴 = {(𝑎1 , 𝑎2 , … , 𝑎𝑛 )|𝑎𝑖 ∈ 𝐴, 𝑓𝑜𝑟 𝑖 = 1,2, … , 𝑛}
Illustration
Consider the two sets: 𝑨 = {𝐷𝐿, 𝑀𝑃, 𝐾𝐴}, where 𝐷𝐿, 𝑀𝑃, 𝐾𝐴 represent Delhi, Madhya
Pradesh and Karnataka, respectively and 𝑩 = {01,02, 03} representing codes for the licence
plates of vehicles issued by DL, MP and KA .
If the three states, Delhi, Madhya Pradesh and Karnataka were making codes for the licence
plates of vehicles, with the restriction that the code begins with an element from set A, which
are the pairs available from these sets and how many such pairs will there be ?
The available pairs are:
(DL,01), (DL,02), (DL,03), (MP,01), (MP,02), (MP,03), (KA,01), (KA,02), (KA,03) and the
product of set A and set B is given by
A × B = {(DL,01), (DL,02), (DL,03), (MP,01), (MP,02), (MP,03), (KA,01), (KA,02),
(KA,03)}.
It can easily be seen that there will be 9 such pairs in the Cartesian product, since there are 3
elements in each of the sets A and B. This gives us 9 possible codes.
Also note that the order in which these elements are paired is crucial.
For example, the code (DL, 01) will not be the same as the code (01, DL).
RELATIONS AND THEIR PROPERTIES
Definition
A relation R from a non-empty set A to a non-empty set B is a subset of the Cartesian product
A × B.
The subset is derived by describing a relationship between the first element and the second
element of the ordered pairs in A × B.
The second element is called the image of the first element.
For example, 𝑅 = {(𝑎, 0), (𝑎, 1), (𝑎, 3), (𝑏, 1), (𝑏, 2), (𝑐, 0), (𝑐, 3)} is a relation from the set
{𝑎, 𝑏, 𝑐} to the set {0, 1, 2, 3}.
A relation from a set A to itself is called a relation on A.
Definition
The set of all first elements of the ordered pairs in a relation R from a set A to a set B is called
the domain of the relation R.
Definition
The set of all second elements in a relation R from a set A to a set B is called the range of the
relation R. The whole set B is called the codomain of the relation R.
Problem.2
Let 𝐴 = {1, 2, 5} and 𝐵 = {3, 5,7} and let 𝑅 = {(𝑎, 𝑏)|7 ≤ 𝑎 + 𝑏 < 10, 𝑎 ∈ 𝐴, 𝑏 ∈ 𝐵}.
1) Write all the elements of 𝑅 and 𝑅’ 2) Write the inverse relation of R.
−1
3) Find the Domain and Range of 𝑅 and 𝑅 .
Solution:
1) 𝑅 = {(1,7), (2,5), (2,7), (5,3)}
𝑅 ′ = {(1,3), (1,5), (2,3), (5,5), (5,7)}
2) 𝑅 −1 = {(7,1), (5,2), (7,2), (3,5)}
3) 𝐷𝑜𝑚(𝑅) = {1,2,5}, 𝑅𝑎𝑛𝑔𝑒(𝑅) = {3,7,5}
𝐷𝑜𝑚(𝑅 −1 ) = {3,7,5}, 𝑅𝑎𝑛𝑔𝑒(𝑅) = {1,2,5}
Problem.3
Consider these relations on the set of integers:
𝑅1 = {(𝑎, 𝑏) | 𝑎 ≤ 𝑏},
𝑅2 = {(𝑎, 𝑏) | 𝑎 > 𝑏 },
𝑅3 = {(𝑎, 𝑏) | 𝑎 = 𝑏 𝑜𝑟 𝑎 = − 𝑏},
𝑅4 = {(𝑎, 𝑏) | 𝑎 = 𝑏},
𝑅5 = {(𝑎, 𝑏) | 𝑎 = 𝑏 + 1},
𝑅6 = {(𝑎, 𝑏) | 𝑎 + 𝑏 ≤ 3}.
Which of these relations contain each of the pairs (1,1), (1,2), (2,1), (1,−1), and (2,2)?
Solution:
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; and finally, (2,2) is in R1, R3, and R4.
Exercise
1. Let 𝐴 = {1, 2, 3, . . . ,14}. Let a relation 𝑅 on 𝐴 be defined as
𝑅 = {(𝑥, 𝑦) ∶ 3𝑥 − 𝑦 = 0, 𝑤ℎ𝑒𝑟𝑒 𝑥, 𝑦 ∈ 𝐴}. Write down its domain, codomain and range.
2. Let 𝐴 = {𝑥, 𝑦, 𝑧} and 𝐵 = {1, 2}. Find the number of relations from 𝐴 to 𝐵. Which of the
following is not a relation from 𝐴 to ? Justify your answer.
(i) {(𝑥, 1), (𝑦, 2), (𝑧, 3)}
(ii) {(𝑥, 1), (𝑥, 2)}
(iii) {(𝑥, 2), (𝑦, 2), (𝑧, 2)}
(iv) {(1, 𝑥), (2, 𝑥)}
3. If 𝑅 = {(1,2), (2,4), (3,3)} and 𝑆 = {(1,3), (2,4), (4,2)} represents some relations on
some sets then what is 1) 𝑅 ∪ 𝑆 2) 𝑅 ∩ 𝑆 3) 𝑅 − 𝑆 4) 𝑆 – 𝑅 5)
R⊕S
Also verify if (i) 𝐷𝑜𝑚𝑎𝑖𝑛 𝑜𝑓 (𝑅 ∪ 𝑆) = (𝐷𝑜𝑚𝑎𝑖𝑛 𝑜𝑓 𝑅) ∪ (𝐷𝑜𝑚𝑎𝑖𝑛 𝑜𝑓𝑆)
and (ii)𝑅𝑎𝑛𝑔𝑒(𝑅 ∩ 𝑆) ⊆ 𝑅𝑎𝑛𝑔𝑒 (𝑅) ∩ 𝑅𝑎𝑛𝑔𝑒(𝑆)
COMPOSITE OF RELATIONS
Definition
Let 𝑅 be a relation from a set 𝐴 to a set 𝐵 and 𝑆 a relation from B to a set 𝐶.
The composite of 𝑅 and 𝑆given by 𝑆 ∘ 𝑅 is the relation from 𝐴 to 𝐶 consisting of ordered pairs
(𝑎, 𝑐), where 𝑎 ∈ 𝐴, 𝑐 ∈ 𝐶, and for which there exists an element 𝑏 ∈ 𝐵 such that (𝑎, 𝑏) ∈ 𝑅
and (𝑏, 𝑐) ∈S.
Thus, 𝑆 ∘ 𝑅 = {(𝑎, 𝑐)|(𝑎, 𝑏) ∈ 𝑅, (𝑏, 𝑐) ∈ 𝑆, 𝑓𝑜𝑟 𝑠𝑜𝑚𝑒 𝑏 ∈ 𝐵}.
In other words 𝑎(𝑆 ∘ 𝑅)𝑐 if and only if 𝑎𝑅𝑏 and 𝑏𝑆𝑐 for some 𝑏 ∈ 𝐵.
Note:
1. The powers of a relation R can be recursively defined from the definition of a composite
of two relations.
Let R be a relation on the set A. The powers 𝑹𝒏 , 𝑛 = 1,2,3, . ..are defined recursively by
𝑹𝟏 = 𝑹 and 𝑹𝒏+𝟏 = 𝑹𝒏 ∘ 𝑹.
Thus, R2 = R ◦R, R3 = R2 ◦R = (R ◦R)◦R, and so on.
Problem.1
Let 𝑅 = {(1,1), (1,4), (2,3), (3,1), (3,4)} and 𝑆 = { (1,0), (2,0), (3,1), (3,2), (4,1)} be two
relations on some sets. Check if 𝑆 ∘ 𝑅 is possible or not. If it is possible then write the
elements of the relation 𝑆 ∘ 𝑅.
Solution
Here, 𝑐𝑜𝑑𝑜𝑚(𝑅) = {1,3,4} is a subset of 𝑑𝑜𝑚(𝑆) = {1,2,3,4}
Hence, 𝑆 ∘ 𝑅 is Possible.
Further, 𝑆 ∘ 𝑅 = {(1,0), (1,1), (2,1), (2,2), (3,0), (3,1)}
Problem.2
Let 𝑅 = {(1,1), (2,1), (3,2), (4,3)}. Find the powers Rn, n= 2,3,4,....
Solution
𝑅 2 = 𝑅 ∘ 𝑅 = {(1,1), (2,1), (3,1), (4,2)}
Further, 𝑅 3 = 𝑅 2 ∘ 𝑅 = {(1,1), (2,1), (3,1), (4,1)}.
Similarly, 𝑅 4 = 𝑅 3 ∘ 𝑅 = {(1,1), (2,1), (3,1), (4,1)}.
It follows that 𝑅 𝑛 = 𝑅 3 for 𝑛 = 5,6,7, …
Exercise:
1. Let 𝑅 = {(0,1), (1,2), (1,4), (2,3), (3,1), (4,3)} and 𝑆 = { (1,0), (2,1), (3,1), (3,2)} be
two relations on some sets. Check if 𝑅 ∘ 𝑆 is possible or not. If it is possible then write
the elements of the relation 𝑅 ∘ 𝑆.
PROPERTIES OF RELATIONS
Let 𝐴 be a set. Let 𝑅 be a relation on it.
• The relation 𝑹 is said to be reflexive if (𝑎, 𝑎) ∈ 𝑅, for every 𝑎 ∈ 𝐴
In other words, a relation on A is reflexive if every element of A is related to itself.
• The relation 𝑹 is said to be transitive, if (𝑎, 𝑏) ∈ 𝑅 𝑎𝑛𝑑 (𝑏, 𝑐) ∈ 𝑅 ⇒ (𝑎, 𝑐) ∈ 𝑅, for
all 𝑎, 𝑏, 𝑐 ∈ 𝐴 .
• The relation 𝑹 is said to be symmetric 𝑖𝑓 (𝑎, 𝑏) ∈ 𝑅 ⇒ (𝑏, 𝑎) ∈ 𝑅, for all 𝑎, 𝑏 ∈ 𝐴
• The relation 𝑹 is said to be anti-symmetric if (𝑎, 𝑏) ∈ 𝑅, (𝑏, 𝑎) ∈ 𝑅 ⇒ 𝑎 = 𝑏 ,for all
𝑎, 𝑏 ∈ 𝐴
In other words, a relation R on a set A is anti-symmetric if and only if there are no pairs
Of distinct elements 𝑎 and 𝑏 with 𝑎 related to 𝑏 and 𝑏 related to 𝑎.
i.e. the only way to have 𝒂 related to 𝒃 and 𝒃 related to 𝒂 is for 𝒂 and 𝒃 to be the same
element.
Definition
A relation R on a set A is said to be equivalence relation, if R is reflexive, transitive and
symmetric.
A relation R on a set A is said to be partially ordered relation, if R is reflexive, transitive and
anti-symmetric.
A set 𝐴 with a partially ordered operation 𝑅,(i.e. (𝐴, 𝑅)) is said to be Partially Ordered Set
(POSet).
Note:
(i) The terms symmetric and antisymmetric are not opposites.
(ii) If R is an equivalence relation, and (𝑎, 𝑏) ∈ 𝑅, then 𝑎 and 𝑏 are called equivalent. The
notation 𝑎 ∼ 𝑏 is often used to denote that 𝑎 and 𝑏 are equivalent elements with respect
to a particular equivalence relation.
Problem.2
Show that the “greater than or equal” relation (≥) is a partial ordering on the set of integers.
Solution:
Because a ≥ a for every integer a, ≥ is reflexive.
If a ≥ b and b ≥ a, then a = b.
Hence, ≥is antisymmetric.
Finally, ≥is transitive because a ≥ b and b ≥ c imply that a ≥ c.
It follows that ≥is a partial ordering on the set of integers and (Z,≥) is a poset.
Problem.3
Show that the inclusion relation ⊆ is a partial ordering on the power set of a set S.
Solution:
Because A ⊆A whenever A is a subset of S,⊆ is reflexive.
It is antisymmetric because A ⊆ B and B ⊆ A imply that A = B.
Finally, ⊆is transitive, because A ⊆ B and B ⊆ C imply that A ⊆ C.
Hence, ⊆is a partial ordering on P(S), and (P(S),⊆ )is a POset.
Exercise
1. Check whether the following relations are equivalence relation or not on the set of all
integers Where 𝑎𝑅𝑏 if and only if 1) 𝑎 ≠ 𝑏 2) 𝑎𝑏 ≥ 0
2. Check whether from the following relation sets, which are satisfying the transitive,
reflexive or symmetric property which relation is an Equivalence relation and partially
ordered relation.
1) R1 = {(1, 1), (2, 2), (3, 3)}
2) R2 = {(1, 1), (2, 2), (1, 2), (2, 1), (3, 1)}
3) R3= {(1, 1), (1, 2), (2, 1), (1, 3), (3, 1)}
4) R4= {(1, 1), (2, 2), (3, 3), (1, 2), (2, 1), (1, 3), (3, 1), (2, 3), (3, 2)}
3. Prove that (ℤ, ≤) is a partially ordered set where Z is the set of integers.
4. Check if ℕ with the ‘𝑑𝑖𝑣𝑖𝑑𝑒𝑠’ relation is a POSet.
Function
We can, visualise a function as a rule, which produces new elements out of some given
elements. There are many terms such as ‘map’ or ‘mapping’ used to denote a function.
Definition
A relation f from a set A to a set B is said to be a function if every element of set A has one and
only one image in set B.
In other words,
A relation f is a function from a non-empty set A to a non-empty set B if
(i) the domain of f is A
(ii) no two distinct ordered pairs in f have the same first elements.
Note:
If 𝑓 is a function from A to B and (𝑎, 𝑏) ∈ 𝑓, then we write 𝑓 (𝑎) = 𝑏, where 𝑏 is called the
image of 𝑎 under 𝑓 and 𝑎 is called the preimage of 𝑏 under f.
Problem.1
Examine each of the following relations given below and state in each case, giving reasons
whether it is a function or not on the given domain?
(i) R = {(2,1),(3,1), (4,2)}, Domain= {1,2,3,4}
(ii) R = {(2,2),(2,4),(3,3), (4,4)} , Domain= {2,3,4}
(iii) R = {(1,2),(2,3),(3,4), (4,5), (5,6), (6,7)}, Domain= {1,2,3,4,5,7}
REPRESENTION OF RELATIONS
Representing Relations Using Matrices
A relation between finite sets can be represented using a zero–one matrix.
Suppose that R is a relation from 𝑨 = { 𝑎1 , 𝑎2 , . . . , 𝑎𝑚 } to 𝑩 = { 𝑏1 , 𝑏2 , . . . , 𝑏𝑛 }.
(Here the elements of the sets A and B have been listed in a particular, but arbitrary, order.
Furthermore, when A = B we use the same ordering for A and B.)
1 𝑖𝑓 (𝑎𝑖 , 𝑏𝑗 ) ∈ 𝑹
The relation R can be represented by the matrix 𝑴𝑹 = [𝒎𝒊𝒋 ], where 𝒎𝒊𝒋 = {
0 𝑖𝑓 (𝑎𝑖 , 𝑏𝑗 ) ∉ 𝑹
In other words, the zero–one matrix representing R has a 1 as its(𝑖, 𝑗)th entry when 𝒂𝒊 is related
to 𝒃𝒋 , and a 0 in this position if 𝒂𝒊 is not related to 𝒃𝒋 .
Note: Such a representation depends on the orderings used for A and B.
Problem.1
Suppose that 𝐴 = {1,2,3}and 𝐵 = { 1,2}.
Let R be the relation from A to B containing (𝑎, 𝑏) if 𝑎 ∈ 𝐴, 𝑏 ∈ 𝐵, 𝑎𝑛𝑑 𝑎 > 𝑏.
What is the matrix representing R?
Solution
0 0
Because 𝑅 = {(2,1), (3,1), (3,2)}, the matrix for R is MR = [1 0]
1 1
Problem.2
Let 𝐴 = {𝑎1 , 𝑎2 , 𝑎3 } and 𝐵 = {𝑏1 , 𝑏2 , 𝑏3 , 𝑏4 , 𝑏5 }.
0 1 0 0 0
Which ordered pairs are in the relation R represented by the matrix MR =[1 0 1 1 0] ?
1 0 1 1 0
Solution:
Because R consists of those ordered pairs (𝑎𝑖 , 𝑏𝑗 ) with 𝑚𝑖𝑗 = 1, it follows that
𝑅 = {(𝑎1 , 𝑏2 ), (𝑎2 , 𝑏1 ), (𝑎2 , 𝑏3 ), (𝑎2 , 𝑏4 ), (𝑎3 , 𝑏1 ), (𝑎3 , 𝑏3 ), (𝑎3 , 𝑏5 )}.
Remark
• R is reflexive if and only if 𝑚𝑖𝑖 = 1 for 𝑖 = 1,2, . . . , 𝑛.
In other words, 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.
In other words, the zero–one matrix representing R has a 1 as its th entry when is related
to , and a 0 in this position if is not related to .
Note: Such a representation depends on the orderings used for A and B.
Problem.1
Suppose that and
Let R be the relation from A to B containing if .
What is the matrix representing R?
Solution
Problem.2
Let and
Solution:
Because R consists of those ordered pairs with , it follows that
Remark
R is reflexive if and only if for .
In other words, 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.
(The matrix for a reflexive relation)
The relation R is symmetric if and only if whenever .
This also means whenever .
Consequently, R is symmetric if and only if , for all and .
i.e. R is symmetric if and only if ,
i.e, R is symmetric if MR is a symmetric matrix.
The relation R is anti-symmetric if and only if with ,then .
In other words, if then either .
The form of the matrix for an antisymmetric relation is illustrated in Figure.
Problem.3
Suppose that the relations R and S on a set A are represented by the matrices
= and =
and
Problem.4
Find the matrix representing the relation , where the matrices representing R and S are
MR = and MS =
Solution:
Exercise
representing
(a) (b) (
Definition
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 (or arcs). The vertex ‘a’ is called the initial vertex of
the edge (a,b), and the vertex ‘ 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. Such an
edge is called a loop.
REMARKS
A relation R 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 occurs in the relation.
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 x to z (completing a
triangle where each side is a directed edge with the correct direction).
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 is in the relation whenever
is in the relation.
A relation is antisymmetric if and only if there are never two edges in opposite directions
between distinct vertices.
Problem.3 Determine whether the relations for the directed graphs shown in the following figure
are reflexive, symmetric, antisymmetric, and/or transitive.
(a) (b) (c) (d)
Problem.4 Write the relation represented by the following digraph and also write the matrix
representing this relation.
(a) (b)
Solution.
(a)
(b)
Exercise
1. Write the relation represented by the following matrices and also draw the corresponding
digraph.
(a) (b) (c)
Lecture 5
Representing Relations Using Digraphs
There is another important way of representing a relation using a pictorial representation.
Each element of the set is represented by a point, and each ordered pair is represented using an
arc with its direction indicated by an arrow.
We use such pictorial representations when we think of relations on a finite set as directed
graphs, or digraphs.
Definition
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 (or arcs). The vertex ‘a’ is called the initial vertex
of the edge (a,b), and the vertex ‘ 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. Such an
edge is called a loop.
REMARKS
• A relation R 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 (𝑥, 𝑥) occurs in the relation.
• 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 x to z
(completing a triangle where each side is a directed edge with the correct direction).
• 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 (𝑦, 𝑥) is in the relation
whenever (𝑥, 𝑦) is in the relation.
• A relation is antisymmetric if and only if there are never two edges in opposite
directions between distinct vertices.
Problem.4 Write the relation represented by the following digraph and also write the matrix
representing this relation.
(a) (b)
Solution.
(a) 𝑅 = {(𝑎, 𝑎), (𝑎, 𝑏), (𝑏, 𝑎), (𝑏, 𝑏), (𝑏, 𝑐), (𝑐, 𝑏), (𝑐, 𝑎), (𝑎, 𝑐). (𝑑, 𝑑)}
1 1 1 0
1 1 1 0
𝑀𝑅 = [ ]
1 1 0 0
0 0 0 1
(b) 𝑅 = {(𝑎, 𝑎), (𝑎, 𝑏), (𝑏, 𝑎), (𝑏, 𝑏), (𝑐, 𝑐), (𝑐, 𝑑), (𝑑, 𝑐), (𝑑, 𝑑)}
1 1 0 0
1 1 0 0
𝑀𝑅 = [ ]
0 0 1 1
0 0 1 1
Exercise
1. Write the relation represented by the following matrices and also draw the
corresponding digraph.
(a) 1 1 1 0 (b) 1 1 1 0 0 (c) 1 1 0 0
1 0 1 0 1 1 1 0 0 0 1 1 0
[ ] [ ]
1 1 0 0 0 0 1 0 0 0 0 0 1
0 0 0 1 0 0 0 1 0 1 0 1 0
[1 0 0 1 1]
Lecture 6
CLOSURES OF RELATIONS
Introduction
Let 𝑅 be a relation on a set 𝐴.
𝑅 may or may not have some property 𝑃, such as reflexivity, symmetry, or transitivity. If there
is a relation 𝑆 with property 𝑃 containing 𝑅 such that 𝑆 is a subset of every relation with
property 𝑃 containing 𝑅, then 𝑆 is called the closure of 𝑅.
In other words, 𝑆 is the smallest superset of 𝑅 with the property 𝑃.
Reflexive closure of R
For given a relation R on a set A, the reflexive closure of R can be formed by adding to R all
pairs of the form (𝑎, 𝑎) with 𝑎 ∈ 𝑨, not already in R.
The addition of these pairs produces a new relation that is reflexive, contains R, and is contained
within any reflexive relation containing R. Consequently, it is the reflexive closure of 𝑅.
Thus, the reflexive closure of R can be given by R∪Δ, where 𝛥 = {(𝑎, 𝑎) | 𝑎 ∈ 𝐴}is the
diagonal relation on A.
Problem.2
The relation 𝑹 = {(𝟏, 𝟏), (𝟏, 𝟐), (𝟐, 𝟏), (𝟑, 𝟐)}on the set 𝑨 = {𝟏, 𝟐, 𝟑} is not reflexive.
Obtain the reflexive closure of R.
Solution Here, diagonal relation on 𝐴 is 𝛥 = {(1,1), (2,2), (3,3)}
Therefore, the reflexive closure of 𝑅 is 𝑆 = 𝑅 ∪ 𝛥 = {(1,1), (1,2), (2,1), (2,2), (3,2), (3,3)}
Problem.2
What is the reflexive closure of the relation 𝑹 = {(𝒂, 𝒃) | 𝒂 < 𝑏 }on the set of integers?
Solution: The reflexive closure of R is
𝑅 ∪ 𝛥 = {(𝑎, 𝑏) | 𝑎 < 𝑏} ∪ {(𝑎, 𝑎) | 𝑎 ∈ 𝑍} = {(𝑎, 𝑏) | 𝑎 ≤ 𝑏}.
Symmetric closure of R
The symmetric closure of a relation R can be constructed by adding all ordered pairs of the
form (𝑏, 𝑎), for all (𝑎, 𝑏) that are not already present in R.
Adding these pairs produces a relation that is symmetric, that contains R, and that is contained
in any symmetric relation that contains R. Consequently, it is the symmetric closure of 𝑅.
The symmetric closure of a relation can be constructed by taking the union of a relation with
its inverse
i.e., 𝑅 ∪ 𝑅 −1 is the symmetric closure of R, where 𝑅 −1 = {(𝑏, 𝑎) | (𝑎, 𝑏) ∈ 𝑅}.
Problem.1
Find the symmetric closure of the relation
{(𝟏, 𝟏), (𝟏, 𝟐), (𝟐, 𝟐), (𝟐, 𝟑), (𝟑, 𝟏), (𝟑, 𝟐)}on{𝟏, 𝟐, 𝟑}.
Solution.
𝑅 −1 = {(1,1), (2,1), (2,2), (3,2), (1,3), (2,3)}
Therefore, symmetric closure of 𝑅 is
𝑆 = 𝑅 ∪ 𝑅 −1 = {(𝟏, 𝟏), (𝟏, 𝟐), (𝟐, 𝟏), (𝟐, 𝟐), (𝟐, 𝟑), (𝟑, 𝟐), (𝟑, 𝟏), (𝟏, 𝟑)}
Problem.2
What is the symmetric closure of the relation 𝑹 = {(𝒂, 𝒃) | 𝒂 > 𝑏 } on the set of positive
integers?
Solution:
𝑹−𝟏 = {(𝒃, 𝒂) | 𝒂 > 𝑏 } = {(𝒂, 𝒃)|𝒃 > 𝑎} = {(𝒂, 𝒃)|𝒂 < 𝑏}
The symmetric closure of R is the relation
𝑹 ∪ 𝑹−𝟏 = {(𝒂, 𝒃)|𝒂 > 𝑏} ∪ {(𝑎, 𝑏)|𝑎 < 𝑏} = {(𝑎, 𝑏)|𝑎 ≠ 𝑏}
Transitive closure of R
Suppose that a relation R is not transitive.
Let 𝑀𝑅 be the zero–one matrix of the relation R on a set with 𝑛 elements.
Let 𝑅 ∗ be the transitive closure of 𝑅.
Then the zero–one matrix of the transitive closure 𝑅 ∗ is
𝑀𝑅∗ = 𝑀𝑅 ∨ 𝑀𝑅[2] ∨ 𝑀𝑅[3] ∨···∨ 𝑀𝑅[𝑛] .
∗
Here R is known as connectivity relation.
Problem.1
Find the zero–one matrix of the transitive closure of the relation R where
1 0 1
𝑀𝑅 = [0 1 0]
1 1 0
Solution:
The zero–one matrix of 𝑀𝑅 is 𝑀𝑅∗ = 𝑀𝑅 ∨ 𝑀𝑅[2] ∨ 𝑀𝑅[3] .
Now, 𝑴𝑹[𝟐] is the matrix of the composite relation 𝑹 ∘ 𝑹.
1 1 1
⇒ 𝑴𝑹[𝟐] = [0 1 0]
1 1 1
and 𝑴𝑹[𝟑] is the matrix of the composite relation 𝑹 ∘ 𝑹𝟐
1 1 1
⇒ 𝑴𝑹[𝟑] = [0 1 0]
1 1 1
Hence,
1 0 1 1 1 1 1 1 1 1 1 1
𝑀𝑅∗ = [0 1 0] ∨ [0 1 0] ∨ [0 1 0] = [0 1 0]
1 1 0 1 1 1 1 1 1 1 1 1
Exercise:
1. Let R be the relation on the set {0,1,2,3} containing the ordered pairs (0,1), (1,1), (1,2),
(2,0), (2,2), and (3,0). Find a) reflexive closure of R.
b) symmetric closure of R.
Lecture 7
DATABASE & RELATIONS
Concepts of relations have a strong application in the theory of relational databases.
Definition:
Let 𝐴1, 𝐴2, … , 𝐴𝑛 be sets. An n-ary relation on these sets is a subset of 𝐴1 × 𝐴2 × … × 𝐴𝑛.
The sets 𝐴1, 𝐴2, … , 𝐴𝑛 are called the domains of the relation, and n is called its degree.
For example:
Let R be the relation on ℕ × ℕ × ℕ consisting of triples (𝑎, 𝑏, 𝑐), where 𝑎, 𝑏, 𝑎𝑛𝑑 𝑐 are integers with
𝑎 < 𝑏 < 𝑐. Then (1, 2, 3) ∈ 𝑅, but (2, 4, 3) ∉ 𝑅. The degree of this relation is 3. Its domains are
all equal to the set of natural numbers.
For example:
Let 𝑅 be the relation on ℤ × ℤ × ℤ consisting of all triples of integers (𝑎, 𝑏, 𝑐) in which 𝑎, 𝑏, 𝑎𝑛𝑑 𝑐
form an arithmetic progression. That is, (𝑎, 𝑏, 𝑐) ∈ 𝑅 if and only if there is an integer 𝑘 such that
𝑏 = 𝑎 + 𝑘 and 𝑐 = 𝑎 + 2𝑘, or equivalently, such that 𝑏 − 𝑎 = 𝑘 and 𝑐 − 𝑏 = 𝑘.
Note that (1, 3, 5) ∈ 𝑅 because 3 = 1 + 2 and 5 = 1 + 2 ・ 2, but (2, 5, 9) ∉ 𝑅 because 5 −
2 = 3 while 9 − 5 = 4. This relation has degree 3 and its domains are all equal to the set of
integers.
For example:
Let R be the relation consisting of 5 − 𝑡𝑢𝑝𝑙𝑒𝑠 (𝐴, 𝑁, 𝑆, 𝐷, 𝑇 ) representing airplane flights, where 𝐴
is the airline, 𝑁 is the flight number, 𝑆 is the starting point, 𝐷 is the destination, and 𝑇 is the
departure time.
For instance, if Nadir Express Airlines has flight 963 from Newark to Bangor at 15:00, then (Nadir,
963, Newark, Bangor, 15:00) belongs to R.
The degree of this relation is 5, and its domains are the set of all airlines, the set of flight numbers,
the set of cities, the set of cities (again), and the set of times.
Exercise:
1. Consider the following Tables.
a. What do you obtain when you apply the selection operator SC , where C is the condition
(𝑃𝑟𝑜𝑗𝑒𝑐𝑡 = 2) ∧ (𝑄𝑢𝑎𝑛𝑡𝑖𝑡𝑦 ≥ 50), to the database in the table of Parts_inventory.?
b. Construct the table obtained by applying the join operator J2 to the relations in the following
tables
The highlighted digits are 0.37210 . . . . Suppose that we add 1 to each of these digits, to get the
number
0.48321 . . . . then this number can’t be in the table. Because
• it differs from f(1) in its first digit;
• it differs from f(2) in its second digit;
•...
• it differs from f(n) in its nth digit;
•...
So it can’t equal f(n) for any n — that is, it can’t appear in the table
This looks like a trick, but in fact there are lots of numbers that are not in the table.
As long as we highlight at least one digit in each row and at most one digit in each column, we can
change each the digits to get another number not in the table.
Therefore, there does not exist a bijection between ℕ and [0, 1].
Hence, [0,1] is not a countable set.
Since, cardinality of ℝ and [0,1] is same, ℝ is also uncountable.
Schroder-Bernstein Theorem
If A and B are sets with |𝐴| ≤ |𝐵| and |𝐵| ≤ |𝐴|, then |𝐴| = |𝐵|. In other words, if there are one-
to-one functions f from A to B and g from B to A, then there is a one-to-one correspondence between
A and B.