Professional Documents
Culture Documents
N i
i
A
e
= N and
I i
i
A
e
= .
v) If B
i
= {2i, 2i +1} for all I N, then {B
i
}
ieN
is a collection of mutually
disjoint sets.
1.2.15 Definition
Let A be a set. The set P(A) = the set of all subsets of A, is called the power
set of A.
Observation: If the set A has n elements, then the number of elements in
P(A) is 2
n
.
Verification: Suppose A has n elements. Let m be an integer such that 0 s m
s n. We can select m elements from the given set A in
n
C
m
ways. So A
contains
n
C
m
distinct subsets containing m elements. Therefore the number
of elements in P(A) = number of subsets containing 0 number of elements
+ number of subsets containing only 1 element
+ + number of subsets containing n elements
=
n
C
0
+
n
C
1
+
n
C
2
+ +
n
C
n
= 2
n
.
1.3 Functions and Relations
Relation describes connections between different elements of the same set,
whereas functions describe connections between two different sets.
Functions give a mathematical precise framework for the intuitive idea of
transformation.
1.3.1 Definitions
Let S and T be sets. A function f from S to T is a subset f of S T such that
Here t is called the image of s; and s is called the preimage of t.
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 8
The set S is called the domain of f and T is called the codomain.
The set {f(s) / s S } is a subset of T and it is called the image of S under f
(or image of f). We denote the fact f is a function from S to T by f : S T.
f: S T is said to be
one-one function (or injective function):
onto function (or surjective function): there exists an element s e
S such that f(s) = t.
bijection: if it is both one-one and onto.
Let g: S T and f: T U. The composition of f and g is a function
fog: S U defined by (fog)(s) = f(g(s)) for all s in S.
1.3.2 Definitions
A function f : S T is said to have an inverse if there exists a function g
from T to S such that (gof) (s) = s for all s in S and (fog)(t) = t for all t in
T. We call the function g the inverse of f. A function f : S S is said to be
an identity function if f(s) = s for all s in S. The identity function on S is
denoted by either I or I
S
. Inverse of a function f, if it exists, is denoted by f
-1
.
Two functions f : A B and g : C D are said to be equal if A = C, B = D
and f(a) = g(a) for all elements a in A and C. If two functions f and g are
equal, then we write f = g. The identity function is one-one and onto. A
function g is inverse of f fog and gof are identity functions. A function f
has an inverse f is one-one and onto.
1.3.3 Example
Let the functions f and g defined by f(x) = 2x and g(x) = x + 5 for all x in R
(the set of real numbers). Then (fog)(1) = f(g(1)) = f(1 + 5) = f(6) = 12 and
(gof)(1) = g(f(1)) = g(2) = 2 + 5 = 7. This shows that the two functions are
not equal at 1 and so fog = gof.
1.3.4 Definition
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 9
Let A be a subset of the Universal set U = {x
1
, x
2
, , x
n
}. The characteristic
function of A is defined as a function from U to {0, 1} by the following:
f
A
(x
i
) =
i
i
1 if x A
0 if x A
e
I i
i
S
e
= S and S
i
S
j
= if i j.
1.4.9 Example
i) Write A = {1, 2, 3, 4, 5, a, b, c}, S
1
= {1, 2}, S
2
= {3}, S
3
= {4, 5, a}
and S
4
= {b, c}. Then S
1
, S
2
, S
3
, S
4
form a partition for A.
ii) Consider R, the set of all real numbers. The collection {(a, b] / a, b Z
and b = a + 1} of subsets of R, forms a partition for R.
1.4.10 Lemma
If R is an equivalence relation on a set S and a, b S, then either [a] = [b]
or [a] [b] = .
Proof. If [a] [b] = , then it is clear.
Now suppose the intersection is non-empty.
Let x [a] [b]
x [a] and x [b]
x ~ a and x ~ b
a ~ x and x ~ b (since ~ is symmetric)
a ~ b (since ~ is transitive).
Now we show that [a] = [b]. For this, let y [a] y ~ a.
Since a ~ b, we get y ~ b (by transitive property) b ~ y y [b].
Hence [a] [b]. Similarly, we get that [b] [a]. Therefore [a] = [b].
From this lemma, we can conclude that any two equivalence classes are
either equal or disjoint.
1.4.11 Problem
Let A be a set and ~ an equivalence relation on A. Then the set of all
equivalence classes forms a partition for A.
Solution: The collection of all equivalence classes is {[a] / a A}.
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 13
Observation: Let A be a set and {A
i
/ i I} be a collection of nonempty
subsets of A, which forms a partition for A. Then there exists an equivalence
relation ~ on A such that the equivalence classes are nothing but the sets of
the partition.
1.5 Matrix Representations
1.5.1 Definition
Let A = {a
1
, a
2
, , a
n
} and B = {b
1
, b
2
, , b
n
}.
If R is relation from A to B, then R can be represented by matrix M
R
=
(M
ij
)
mn
, defined
( )
i j
ij
m n
i j
1 if (a , a ) R
M
0 if (a , a ) R
=
e
Where M
ij
is the element in the i
th
row and j
th
column. M
R
can be first obtained
by first constituting a table, whose columns are preceded by a column
consisting of successive elements of A and where rows are headed by row
consisting of successive elements of B. If (a
i
, b
j
) R, then we enter 1 in the
i
th
row and j
th
column.
1.5.2 Example
Let A = {1, 2, 3} and = {(x, y) | x < y}. Write M
R
.
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 14
Solution: R = {(1, 2), (1, 3), (2, 3)}. Since (1, 2) e R, we have m
12
= 1;
(1, 3)e R, we have m
12
= 1; also m
23
= 1.
Therefore
R
0 1 1
M 0 0 1
0 0 0
(
(
=
(
(
1.5.3 Example
Let A = {1, 2, 3, 4}. Define a R b a < b.
Then
R
0 1 1 1
0 0 1 1
M
0 0 0 1
0 0 0 0
(
(
(
=
(
(
1.5.4 Example
Write the relation for the relation matrix
R
1 0 0
M 0 0 1
1 1 0
(
(
=
(
(
Solution: Since M is a 3 3 matrix, take A = {a
1
, a
2
, a
3
} and B = {b
1
, b
2
, b
3
}
Then R = {(a
1
, b
1
), (a
2
, b
2
), (a
2
, b
3
), (a
3
, b
1
)}
1.5.5 Definition
A relation R is transitive if and only if M
R
= [m
ij
] has the property:
m
ij
= 1 and m
ik
= 1 m
ik
= 1
1.5.6 Example
Define a relation R represented by a matrix
(
(
(
=
1 1 0
1 1 0
0 0 1
M
R
Here, m
22
= 1, m
23
= 1 m
23
= 1
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 15
m
23
= 1, m
32
= 1 m
22
= 1
m
33
= 1, m
32
= 1 m
32
=1
Therefore the relation R is transitive.
1.6 Closure Relations
1.6.1 Definition
Let R be a relation on a set A. R may or may not have some property P,
such as reflexivity, symmetry or transitivity. If there is a relation S with
property P containing R such that S is a subset of every relation with P
containing R, then S is called the closure of R with respect to P.
1.6.2 Definition
Let R be a relation on a set S. The reflexive closure of R is the smallest
reflexive relation R
1
which contains R. It is also denoted by R
(r)
.
1.6.3 Note
1.6.4 Definition
The symmetric closure of R is the smallest symmetric relation containing R.
That is R R
1
is symmetric closure R, where R
1
is the inverse of the
relation R. It is denoted by R
(s)
.
1.6.5 Definition
Transitive closure of a relation R is the smallest transitive relation containing
R.
1.6.6 Example
Consider the set S = {1, 2, 3, 4}
i) The relation R = { (1,2), (2, 1), (1, 1), (2, 2)} is not reflexive, since
(3, ,3) e S.
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 16
Consider = {(1, 1,), (2, 2), (3, 3), (4, 4)}. Now the reflexive closure
R
1
= = {(1, 2), (2, 1), (1, 1), (2, 2), (3, 3), (4, 4)}.
Observe that R
1
(the reflexive closure of R, sometimes we denote as
R
(r)
) is obtained by supplementing with exactly essential (no more, no
less) in order to get a reflexive relation containing R.
ii) Consider the relation K = { (1,2), (4, 3), (2, 2), (2, 1), (3, 1)}, which is
not symmetric on S. Now
K
1
= {(2, 1), (3, 4), (2, 2) (1, 2), (1, 3)}.
The symmetric closure K
(s)
of K is given by
K
(s)
= K K
1
= { (1, 2), (2, 1), (4, 3), (3, 4), (3, 1), (1, 3)}.
1.6.7 Note
Given a relation R on a set A. To make a relation R transitive, add all pairs
of R
2
, all pairs of R
3
, ,all pairs of R
m
( assume that | A| = m ), unless these
pairs are already in R.
Then the transitive closure of R, denoted by R
or R
(T)
R
(T)
= R R
2
R
m
.
1.6.8 Properties of Transitive closure
i) R
(T)
is transitive
ii) R R
(T)
iii) If S is any other transitive relation that contains R, then R
(T)
S.
1.6.9 Representation of Closure Relations
Let M be the relation matrix of the relation R. Then
i) the symmetric closure of R, denoted by M
S
, defined as M
S
= M v M'
where M' is the transpose of M.
ii) The reflexive closure of R, denoted by M
R
, defined as M
R
= M v I
n
where n is the cardinality of the set of for which the relation defined
and I
n
is the identity matrix of size n.
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 17
iii) The transitive closure of R, denoted by M
T
or
R
M
defined as M
T
= M
v M
2
v M
3
v .v M
n
.
1.6.10 Example
Take A = {1, 2, 3} and R = {(1, 2), (2, 3), (3, 1)}. Find the reflexive,
symmetric and transitive closure of R, using composition of matrix relation
of R.
Solution: Let M be the matrix relation R then
(
(
(
=
0 0 1
1 0 0
0 1 0
M
i) The Reflexive closure of R, M
R
= M v I
3
(
(
(
=
(
(
(
v
(
(
(
=
1 0 1
1 1 0
0 1 1
1 0 0
0 1 0
0 0 1
0 0 1
1 0 0
0 1 0
One can write the reflexive closure R
(r)
, using the above matrix as
R
(r)
= {(1, 1), (1, 2), (2, 2), (2, 3), (3, 1), (3, 3)}.
ii) The symmetric closure of R, is M
S
= M v M' =
(
(
(
v
(
(
(
0 1 0
0 0 1
1 0 0
0 0 1
1 0 0
0 1 0
.
One can write the symmetric closure R
(S)
, using the above matrix as
R
(S)
= {(1, 2), (1, 3), (2,1), (2,3), (3,1), (3,2)}
iii) To find the transitive closure of R, we first find M
2
and M
3
(since the
cardinality of the set A = 3).
(
(
(
=
(
(
(
(
(
(
=
0 1 0
0 0 1
1 0 0
0 0 1
1 0 0
0 1 0
0 0 1
1 0 0
0 1 0
M
2
and
M
3
= M
2
. M =
(
(
(
=
(
(
(
(
(
(
1 0 0
0 1 0
0 0 1
0 0 1
1 0 0
0 1 0
0 1 0
0 0 1
1 0 0
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 18
Therefore the transitive closure of R, M
T
= M v M
2
v M
3
=
(
(
(
=
(
(
(
v
(
(
(
v
(
(
(
1 1 1
1 1 1
1 1 1
1 0 0
0 1 0
0 0 1
0 1 0
0 0 1
1 0 0
0 0 1
1 0 0
0 1 0
.
One can write the transitive closure of R,
R
T
= { (1,10), (1,2), (1,3), (2,1), (2,1), (2,2), (2,3), (3,1), (3,2) (3,3)}.
1.6.11 Definition
Let R be a relation from A to B, S be a relation from B to C. Then the
relation SoR from A to C is defined by a (SoR) c a R b and b S c for
some b B for all a A and c C.
1.6.12 Example
Take A = {1, 2, 3, 4}
Define R = {(1, 1), (1, 2) (2, 3), (2, 4), (3, 4), (4,1), (4,2)} and
S = {(3, 1), (4, 4), (2, 3), (2, 4), (1, 1), (1, 4)}
Then, since (1,1) R, (1,1) S, we have (1,1) SoR.
Since (1,2) R, (2,3) S, we have (1, 3) SoR.
Since (2,3) R, (3,1) S, we have (2, 1) SoR.
Continuing this way we get
SoR = {(1, 1), (1, 4), (1, 3), (2, 1), (2, 4), (3, 4), (4, 1), (4, 4), (4, 3)}
Similarly,
RoR = {(1,1), (1,2), (1,3), (1,4), (2,4), (2,1), (2,2), (3,1), (3,2), (4,1), (4,2),
(4,3), (4,4)}
1.6.13 Note
a) If R
1
and R
2
are relations from A to B
,
R and R
4
are relations from B to C,
then
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 19
b) If R is a relation from A to B, S is a relation form B to C, and T is a
relation from C to D, then (RoS)o T = Ro(SoT).
1.6.14 Problem
If R is a relation from A to B and S is a relation from B to C, then
(RoS)
1
= S
1
o R
1
Solution: Since R is a relation from A to B we have R
1
is a relation from B
to A. Similar way, S
1
is a relation from C to B.
Therefore S
1
oR
1
is a relation from C to B.
This is true for any x A and z C. Hence (RoS)
1
= S
1
o R
1
.
1.6.15 Problem
If R is a relation on a set A, then R is transitive .
Converse: Suppose R
2
R. Take (x, y) R, and (y, z) R.
Then (x, z) RoR = R
2
R. Thus R is transitive.
Self Assessment Questions
1. Let A = {a, b} and B = {x, y, z}. Then find .
2. Let S = {2, 5, 2 , 25, ,
2
5
} and T = {4, 25, 2 , 6,
2
3
}
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 20
3. Find A
c
(with respect to the universal set of reals) in the following
cases
4. Let x and y be real numbers with x < y. Find (x, y)
c
, [x, y)
c
, (x, )
c
,
and (-, y]
c
.
5. Let S = {x, y, z, {x, y}}. Find (i) S \ {x, y}; (ii) S \ |; (iii) ({x, y, z} {S}) \
S; and (iv) S \ {{x, y}}.
6. Find the power set of S = {(x, y), Z }.
7. If a set A has n elements, then the number of relations from A to A is
______
8. If A has m elements and B has n elements, then the number of
relations from A to B is ________
9. Let A = Z
+
, the set of positive integers. R be the relation defined by
aRb if and only if there exists a k e Z
+
so that a = b
k
. Then which of
the following belong to R?
(i) (4, 16), (ii) (1, 3), (iii) (4, 2), (iv) (2, 8), (v) (4, 4) (vi) (2, 16).
10. Given the list of relations among people. For each of the following
relations, state whether the relation is reflexive, symmetric,
antisymmetric, or transitive.
i) xRy stands for x is child of y
ii) xRy stands for x is a spouse of y
iii) xRy stands for x is a wife of y
iv) xRy stands for x is a superior of y
v) xRy stands for x and y have the same parents.
11. Give an example of a relation that is both symmetric and anti
symmetric.
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 21
12. Which of the following relations defined in the set of real numbers are
equivalence relation ?
i) aRb if and only if a = b
ii) aRb if and only if a > b
13. Let Z be the set of integers. Define a relation R on Z as
R = {(x, y) x, y Z, (x-y) is a multiple of 3}.
Then
i) R is an ____________
ii) The Equivalence class containing 0 is _______
iii) The number of equivalence classes is _________
14. Let S be the set of non-zero integers and let R be the relation on A A
defined by (a, b) R (c, d) if and only if ad = bc.
Then
i) R is an _______
ii) The equivalence class containing (1, 2) is ________
15. Let A = {0, 1, 2, 3, 4}. The relation R = {(0, 0), (0, 4), (1, 1), (1, 3), (2,
2), (3, 1), (3, 3), (4, 0), (4, 4)} is an equivalence relation on A. Find the
distinct equivalence classes of R.
16. The set theoretic union of distinct equivalence classes of an
equivalence relation forms a __________ of the given set.
17. Determine whether or not each of the binary relations defined on the
given sets S
i
(i = 1, 2, 3) are reflexive, symmetric, anti symmetric or
transitive. If a relation has a certain property, prove this is so;
otherwise, provide a counter example to show that it does not.
i) S
1
= {1, 2, 3, 4}; R
1
= {(1, 1), (1, 2), (2, 1), (3, 4)}
ii) S
2
= Z , (a, b) e R
2
if and only if ab > 0.
iii) S
3
= R R, R
3
= {((x, y), (u, v)) / x + y s u + v}
18. Is R = {(1, 1), (1, 2), (3, 2), (3, 3), (2, 3), (2, 1)} an equivalence relation
on S = {1, 2, 3}?
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 22
19. For x, y e R \{0}, define x ~ y
y
x
e Q. Whether or not, ~ is an
equivalence relation.
20. Let A = {x Z
+
/ 1 s x s 10}. State whether or not each of the
following families of sets is a partition of A.
i) {{1, 3, 5}, {4, 7, 9}, {2, 6,10}};
ii) {{1, 3, 5, 7}, {2, 4, 6}, {3, 8, 9, 10}};
iii) {1, 2, 3}, {5, 8, 9}, {4, 6, 7, 10}}.
21. If |S| = n, then how many relations are there from S to S.
22. Let R be the relation from the set A = {1, 3, 4} on itself. Define R by
R = {(1, 1), (1, 3), (3, 3), (4, 4)}.
23. The relations corresponding to the following relation matrices
(i)
(
(
(
0 1 1
0 1 0
0 0 1
, (ii)
(
(
(
(
0 1 0 1
1 1 0 0
0 1 1 0
1 0 0 1
on a set A = {1, 2, 3} are __________
24. Let A = {a, b, c, d} and R be a relation defined on A whose matrix
representation is M
R
=
(
(
(
(
1 0 0 0
0 1 1 0
0 1 1 0
0 0 0 1
. Verify whether or not the
relation on A is reflexive and symmetric.
25. Consider the relation R ={(0, 1), (1, 2), (2,3)}defined on A = {0, 1, 2, 3}.
Find the reflexive, symmetric, and transitive closure of R using
composition of relation.
1.7 Summary
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 23
In this unit we introduced the basic concept sets and the different properties
of sets. Some properties common to operations on sets and logical
statements were discussed. Cartesian product of sets was studied as
relations between two sets. We also discussed the equivalence relations
and closure relations with few illustrations. The reader can easily apply the
mathematical concepts introduced, in various situations.
1.8 Terminal Questions
1. If R is a relation on the set of integers Z defined by R = {(x, y) x, y Z,
(x-y) is divisible by 6}, then prove that R is an equivalence relation.
2. Represent each of the following relation on {1, 2, 3} with a matrix
(i) R = {(1, 1), (1, 2), (1, 3)}, S = {(1, 2), (2, 1), (2, 3), (3, 3)}, T = {(1, 3),
(3, 2), (3, 3)}.
3. Let A = {1, 2, 3, 4, 5, 6}. Define a relation R = {(x, y) x + y is a divisor
of 24}.
Find the relation matrix M of R. Compute M
2
and M and M
2
whether or not R
is transitive.
1.9 Answers
Self Assessment Questions
1. A B = {(a, x), (a, y), (a, z), (b, x), (b, y), (b, z)}, and
B A = {(x, a), (x, b), (y, a), (y, b), (z, a), (z, b)}. This problems
illustrates that, in general, the sets A B and B A are different.
2. i) S T = { 2 , 25}, S T = {2, 5, 2 , 25, ,
2
5
, 4, 6,
2
3
},
T (S T) = {(4, 2 ), (4, 25), (25, 2 ), (25, 25), ( 2 , 2 ),
( 2 , 25), (6, 2 ), (6, 25), (
2
3
, 2 ), (
2
3
, 25)}.
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 24
ii) Z S = { 2 , ,
2
5
, 0, 1, -1, 2, -2, . }, Z S = {2, 5, 25}
Z T = { 2 ,
2
3
, 0, 1, -1, 2, -2, .}, Z T = {4, 25, 6}.
3. i).
c
1
A = [-2, 1];
5. i) {z, {x, y}}, (ii). S (iii). {x, y, z}, and (iv).{x, y, z}.
6. P (S) = the power set of S = {|, S, {(a, b)}, {c}}.
7. 2
n
8. 2
m n
9. i) No, ii) No, iii) Yes, iv) No, v) Yes, vi) No.
10. i) anti symmetric, ii) symmetric, iii) anti symmetric, iv) anti symmetric
and transitive, v) reflexive, symmetric and transitive.
11. The identity relation is both symmetric and anti-symmetric. Also, define
the relation in which xRy is true if and only if x = y is both symmetric
and anti-symmetric. Take A = {a, b, c}, define R = {(a, a), (b, b)}.
12. i) Equivalence relation, ii) Not an equivalence relation..
13. i) An equivalence relation
ii) Equivalence class containing 0,
[0] = {0, 3, 6, 9, 12, }
iii) The set of equivalence classes are {[0], [1], [2]}.
14. i) Equivalence relation
ii) [(1, 2)] = {(1, 2), (-1, -2), (2, 4), (-2, -4), (3, 6), (-3, -6), }
15. [0] = [4] = {0, 4}, [1] = [3] ={1, 3}, [2] = {2}.
16. Partition.
17. i) Not reflexive as (2, 2) R
1
.
Not symmetric as (3, 4) R
1
but (4, 3) R
1
Not anti symmetric as (1, 2), (2,1) R
1
, but 1 2
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 25
Not transitive as (2, 1), (1, 2) e R
1
but (2, 2) e R
1
.
ii) Reflexive: For any a e S
2
, a
2
> 0 and so (a, a) e R
2
Symmetric: If (a, b) e R
2
, then ab > 0, so ba > 0 and hence (b, a)
e R
2
.
Not Anti symmetric: (5, 2) e R
2
, since 5(2) = 10 > 0 and similarly
(2, 5) e R
2
, but
5 = 2.
Not transitive: (5, 0) e R
2
, (0, -6) e R
2
but (5, -6) e R
2
, since 5(-6)
0.
iii) Reflexive:
Not symmetric: ((1, 2), (3, 4)) e R
3
, but ((3, 4), (1, 2)) e R, since 3
+ 4 1 + 2.
Not anti symmetric: ((1, 2), (0, 3)) e R
3
, ((0, 3), (1, 2)) e R
3
but (1,
2) = (0, 3).
Transitive:
18. No: Since R is not reflexive as (2, 2) e R.
19. Yes
20. (i). No; (ii). No; (iii).Yes.
21. 2
n
.
22. M
R
=
(
(
(
1 0 0
0 1 0
0 1 1
23. (i) {(1, 1), (2, 2), (3, 1), (3, 2)}
(ii) {(1, 1), (1, 4), (2, 2), (2, 3), (3, 3), (3, 4), (4, 1), (4, 3)}.
24. Reflexive and Symmetric.
25. (i) R
(r)
= {(0, 0), (1, 1), (2, 2), (3, 3), (0, 1), (1, 2), (2, 3)},
R
(s)
= {(0, 1), (1, 0), (1, 2), (2, 1), (2, 3), (3, 2)},
R
(T)
= {(0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3)}.
Fundamentals of Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 26