Theory of Computer Science Unit 1 Sikkim Manipal University Page No.: 1 Unit 1 Mathematical Fundamentals for Computer Science Structure 1.1 Introduction Objectives 1.2 Sets and Properties 1.3 Functions and Relations 1.4 Equivalence Relations 1.5 Recursive Functions 1.6 Strings and Growth Functions 1.7 Summary 1.8 Terminal Questions 1.9 Answers 1.1 Introduction The idea of set is fundamental in the study of mathematical structures. All most all mathematical objects of can be defined in terms of sets and the language of set theory is used in every mathematical subject. Also the concept of relation and function arises when we consider a pair of objects and compare each other. In this unit we study the different relations on a set and the algebraic structures with single binary operation. In computer programming, recursion plays an important role. It is an important facility in many programming languages. We have discussed the concepts recursive functions and growth functions which are useful in analysis of algorithms and approximating the time complexity. The content of this unit provides a mathematical tool for the later units.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 1
Unit 1 Mathematical Fundamentals
for Computer Science
Structure
1.1 Introduction
Objectives
1.2 Sets and Properties
1.3 Functions and Relations
1.4 Equivalence Relations
1.5 Recursive Functions
1.6 Strings and Growth Functions
1.7 Summary
1.8 Terminal Questions
1.9 Answers
1.1 Introduction
The idea of set is fundamental in the study of mathematical structures. All
most all mathematical objects of can be defined in terms of sets and the
language of set theory is used in every mathematical subject. Also the
concept of relation and function arises when we consider a pair of objects
and compare each other. In this unit we study the different relations on a set
and the algebraic structures with single binary operation. In computer
programming, recursion plays an important role. It is an important facility in
many programming languages. We have discussed the concepts recursive
functions and growth functions which are useful in analysis of algorithms
and approximating the time complexity.
The content of this unit provides a mathematical tool for the later units.
Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 2
Objectives:
At the end of the unit you would be able to
understand the fundamental idea of certain mathematical concepts.
learn the various operations on sets.
understand relations and types of relations
know the recursive functions and growth functions.
1.2 Sets and Properties
1.2.1 Definition
A set is a collection of objects in which we can say whether a given object is
in the collection. Sets will be denoted by capital letters.
The fact that a is a member of a set A is denoted by a A and we call it as
„a belongs to A‟. The members of a set are called elements.
If x is not an element of A then we write x A.
1.2.2 Note
There are five ways used to describe a set:
i) Describe a set by describing the properties of the members of the set.
ii) Describe a set by listing its elements.
iii) Describe a set A by its characteristic function, defined as
A(x) = 1 if x A
= 0 if x A
for all x in U, where U is the universal set, some times called the
“universe of discourse ,” or just universe.
iv) Describe a set by recursive formula. This is to give one or more
elements of the set and a rule by which the rest of the elements of the
set may be generated.
v) Describe a set by an operation (say union, intersection, complement
etc) on some other sets.
Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 3
1.2.3 Example
Describe the set containing all the non-negative integers less than or equal
to 4.
Let X denote the set. Then X can be described in the following ways:
i) X = {x / x is a non-negative integer less than or equal to 4}
and N = {x / x is a natural number} = {1, 2, 3, 4, …} is an infinite set.
ii) X = {0, 1, 2, 3, 4}.
iii) A(x) = 1 for x = 0, 1, 2, 3, 4
= 0 if x A.
iv) X = {xi + 1 = xi + 1, i = 0, 1, 2, 3 where x0 = 0}.
1.2.4 Definition
Suppose A and B are two sets. Then we say that A is a subset of B (written
as A B) if every element of A is also an element of B. A set A is said to be
a proper subset of B if there exists an element of B which is not an element
of A. Then A is a proper subset of B if A B and A B.
1.2.5 Note
The containment of sets has the following properties: Let X, Y and Z be
sets.
i) X X.
ii) If X Y and Y Z, then X Z.
iii) If X Y and Y Z, then X Z.
1.2.6 Example
i) Let N, Z, Q, R denote the set of natural numbers; the set of integers;
the set of rational numbers; the set of real numbers respectively. Then
RQZN .
ii) If A = {1, 3, 5}, B = {1, 3, 5, 7} then A is a proper subset of B.
Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 4
1.2.7 Definition
Two sets A and B are said to be equal (denoted by A = B) if A is a subset of
B, and B is a subset of A.
Observation: To show two sets A and B are equal, we must show that each
element of A is also an element of B, and conversely.
1.2.8 Definitions
i) The set that contains no members is called the empty set and it is
denoted by .
ii) A set which contains a single element is called singleton set. X = {2} is
a singleton set.
iii) If A and B are two sets, then the set {x / x A or x B} is denoted by
A B and we call it as the union of A and B.
iv) The set {x / x A and x B} is denoted by A B and we call it as the
intersection of A and B.
1.2.9 Properties
S. No. Property Union Intersection
1 Idempotent A A = A A A = A
2 Commutative A B = B A A B = B A
3 Associative A(B C) = (A B) C A(BC) = (AB) C
1.2.10 Definition
Let X and Y be two sets. The symmetrical difference of X and Y is defined
as {x/ x X, or x Y, but not both}. It is denoted as X Y. It is also called
Boolean sum of two sets.
1.2.11 Definition
If A and B are two sets, then the set {x B / x A} is denoted by B – A (or
B \ A) and it is called as the complement A in B.
Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 5
1.2.12 Examples
Let A = {1, 2, 3, 4, 5}, B = {a, b, c, d}, C = {2, b, d}, D = {3, a, c} and E = {x /x
is an integer and 1 < x < 2}.
i) A B = {x / x A or x B } = {1, 2, 3, 4, 5, a, b, c, d }.
ii) A B = {x / x A and x B}
= the set of all elements that are both in A and B
= (the empty set).
iii) A C = {x / x A and x C} = {2}.
iv) A D = {x / x A and x D}= {3}
v) B C = {x/ x B or x C} = {2, a, b, c, d}.
Here we may note that, in rooster form, there is no necessity of writing
the same element two times. So we avoid writing the same element
second time in rooster form.
vi) B C = {a, b, c, d} {2, b, d}= {b, d}.
vii) E = {x/ x is an integer and 1 < x < 2} = . (Since there is no integer
strictly lying between 1 and 2)
viii) A = {x / x A or x } = A.
ix) A = {x / x A and x ] = .
1.2.13 Definitions
i) If S and T are two sets, then the set {(s, t) / s S and t T} is called
the Cartesian product of S and T (here (a, b) = (s, t) a = s and
b = t). The Cartesian product of S and T is denoted by S T. Thus
S T = {(s, t) / s S and t T}.
Note that if S and T are two sets, then S T and T S may not be
equal.
ii) If S1, S2, ..., Sn are n sets, then the Cartesian product is defined as
S1 S2 … Sn = {(s1, s2, …, sn) / si Si for 1 i n}.
Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 6
Here the elements of S1 S2 … Sn are called ordered n-tuples. For
any two n-tuples, we have (s1, s2, …, sn)= (t1, t2, …, tn) si = ti 1 i n.
iii) Let Ai be a collection of sets – one for each element i I, where I is
some set (I may be the set of all positive integers). We define
Ii
iA
= {a / a Ai for all i I}, and
Ii
iA
= {a / a Ai for some i I}.
A collection {Ai}i I of sets is said to be mutually disjoint if
Ai Aj = for all i I, j I such that i j.
1.2.14 Examples
i) If X = {a, b} and Y = {x, y}, then
X Y = {(a, x), (a, y), (b, x), (b, y)} and Y X = {(x, a) (x, b), (y, a),
(y, b)}.
Note that X Y Y X.
ii) If A = {a, b}, B = {2}, C = {x}, then A B C = {(a, 2, x), (b, 2, x))}.
iii) Let T = {a, b, c, d} and S = {1, 2, 4}. Then the (S T) (T S) is an
empty set.
iv) Write Ai = {i, i+1, i+2, …} for each i N, the set of natural numbers.
Then it is easy to observe that Ni
iA
= N and Ii
iA
= .
v) If Bi = {2i, 2i +1} for all i N, then {Bi}iN 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.
Result: If the set A has n elements, then the number of elements in P(A) is
2n.
Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 7
Proof: Suppose A has n elements. Let m be an integer such that 0 m n.
We can select m elements from the given set A in nCm ways. So A contains
nCm 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
= nC0 + nC1 + nC2 + … + nCn = 2n.
Self Assessment Questions
1. Let A = {a, b} and B = {x, y, z}. Then find A B, B A.
2. Let S = {2, 5, 2 , 25, , 2
5} and T = {4, 25, 2 , 6,
2
3}
i) Find S T, S T and T (S T)
ii) Find Z S, Z S, Z T and Z T.
3. Find Ac (with respect to the universal set of real numbers) in the
following cases
i) A1 = (1, ) (-, -2)
ii) A2 = (-3, ) (-, 5).
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 }.
1.3 Functions and Relations
Relation describes connections between different elements of the same set,
where as functions describe connections between two different sets.
Functions give a mathematical precise framework for the intuitive idea of
transformation.
Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 8
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
i) for s S, there exists t T with (s, t) f;
ii) (s, u) f and (s, t) f t = u.
If (s, t) f, then we write (s, f(s)) or f(s) = t.
Here t is called the image of s; and s is called the preimage of t.
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 toT‟ by “f : S T”.
f: S T is said to be
1.3.2 One-one function (or injective function)
f(s1) = f(s2) s1 = s2.
onto function (or surjective function): t T there exists an element
s S such that f(s) = t.
1.3.3 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.4 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 IS. 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 = 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.
Theory of Computer Science Unit 1
Sikkim Manipal University Page No.: 9
1.3.5 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.6 Definition
Let A be a subset of the Universal set U = {x1, x2, …, xn}. The characteristic
function of A is defined as a function from U to {0, 1} by the following:
fA(xi) = i
i
1 if x A
0 if x A
. For example, if A = {2, 3, 7} and U = {1, 2, …, 10},
then fA(1) = 0, fA(2) = 1, fA(3) = 1, fA(7) = 1. and fA(11) is undefined. It can be
verified that fA is everywhere defined and onto, but not one one.
1.3.7 Definition
A relation R between the sets A1, A2, …, An is a subset of A1 A2 …
An. This relation R is called an n-ary relation.
(two–ary is called binary, three-ary is called ternary). In general, a relation
means binary relation on a set S (means a subset of S S). A relation R
on S is said to be
transitive if (a, b) R, (b, c) R implies (a, c) R;
reflexive if (a, a) R for all a S;
anti-symmetric if (a, b) R and (b, a) R a = b;
symmetric if (a, b) R implies (b, a) R;
Self Assessment Questions
7. Determine whether or not each of the binary relations defined on the
given sets Si (i = 1, 2, 3) is 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.