1 Lesson 05 Notes
1 Lesson 05 Notes
Nirdosh Bhatnagar
1. Introduction
1
Discrete Mathematics for Computer Science 2
Cartesian Products
De…nition Cartesian product. Let A and B be any two sets. The Cartesian product
or cross product of sets A and B; denoted by A B is the set of all ordered pairs (a; b)
where a 2 A and b 2 B:
A B = f(a; b) j a 2 A, b 2 Bg
The Cartesian product of a set with itself, A A is denoted by A(2) or simply A2 : In a
similar manner
A(n) , An = A A A
| {z }
n tim es
Observation Let jAj denote the cardinality of the set A. Then jA Bj = jAj jBj.
Relations
De…nition Relation or binary relation. Let A and B be any two sets. A relation (or
binary relation or binary operation) R from A to B is a subset of A B: The set R is
a set of ordered pairs. That is: R = f(a; b) j a 2 A and b 2 Bg A B:
Let S be any set. A relation on a set S; is a binary relation from S to S; which is a
subset of S S:
Observations
1. Let jAj = m, and jBj = n, then there are 2mn relations from A to B.
2. For any set A, A ? = ?.
(a) A (B \ C) = (A B) \ (A C)
(b) A (B [ C) = (A B) [ (A C)
(c) (A \ B) C = (A C) \ (B C)
(d) (A [ B) C = (A C) [ (B C)
Discrete Mathematics for Computer Science 3
De…nitions. Function. Let A and B be any two nonempty sets. The function f is a
relation from A to B. Assign to each element a of the set A; a unique element b of the
set B: The set of such assignments is called a function or mapping from A into B: It is
indicated as f : A ! B: The function f is sometimes denoted by f ( ) :
Observation Let the cardinality of the sets A and B be …nite. That is, let jAj = m,
and jBj = n.
n!
n (n 1) : : : (n m + 1) =
(n m)!
Discrete Mathematics for Computer Science 4
Case 1 : n = 1:
Let A = fx; y; zg, and B = f1g. That is, m = 3 and n = 1.
There is only one onto function f(x; 1) ; (y; 1) ; (z; 1)g.
Case 2 : n = 2.
Case 3 : n = 3.
Then considering the functions from A to f2; 3g, we remove the same function
3 3
f(x; 2) ; (y; 2) ; (z; 2)g. Consequently, in the result 33 2 2 we have twice
removed each of the constant functions f : A ! B, where f (A) is one of the
sets f1g ; f2g ; or f3g. Adjusting our present result for this, we …nd that there
are
3 3 3 3 3 3 3 3
33 2 +3= 3 2 + 1 =6
2 3 2 1
onto functions from A to B.
Subcase 3.4 : m = 4 and n = 3.
Let A = fw; x; y; zg, and B = f1; 2; 3g. There are 34 functions from A to B.
Consider subsets of B of size 2. There are 24 functions from A to f1; 2g.
Similarly, there are 24 functions from A to f1; 3g. So we have 3 24 = 32 24
functions from A to B that are de…nitely not onto.
3 4
Note that 34 2 2 is not the …nal answer. We should realize that not all of
3 4
these 2 2 functions are distinct. For when, we consider all the functions from
A to f1; 2g, we are removing, among these, the function
Then considering the functions from A to f2; 3g, we remove the same function
3 4
f(w; 2) ; (x; 2) ; (y; 2) ; (z; 2)g. Consequently, in the result 34 2 2 we have
twice removed each of the constant functions f : A ! B, where f (A) is one
of the sets f1g ; f2g ; or f3g. Adjusting our present result for this, we …nd that
there are
3 4 3 4 3 4 3 4
34 2 +3= 3 2 + 1 = 36
2 3 2 1
onto functions from A to B.
Subcase 3.5 : m 3 and n = 3.
There are 33 3m 3 m
2 2 +
3
1 1m onto functions from A to B.
Case 4 : The last two cases suggest a pattern that is now stated as a general formula.
For …nite sets jAj = m 2 P and jBj = n 2 P, where m n, the number of onto
functions f : A ! B is
n m n m n m
n (n 1) + (n 2) :::
n n 1 n 2
n 2 n m n 1 n
+ ( 1) 2 + ( 1) 1m
2 1
n
X1 k n m
= ( 1) (n k)
n k
k=0
n
X k n m
= ( 1) (n k)
n k
k=0
Example Let A = f1; 2; 3; 4; 5; 6; 7g and B = fw; x; y; zg. The number of onto func-
tions from A to B by using the general formula, where jAj = m = 7 and jBj = n = 4
Discrete Mathematics for Computer Science 6
is
4
X k 4 7
( 1) (4 k) = 8400
4 k
k=0
The number P of onto functions bears a resemblance to the following problem. For
n k m
m n there are k=0 ( 1) n n k (n k) ways to distribute m distinct objects into n
numbered (but otherwise identical) containers with no containers left empty.
Removing the numbers on containers, so that they are now identical in appearance, we
…nd that one distribution into these n (nonempty) identical containers corresponds with
n! such distributions into the numbered containers. So the number of ways in which it is
possible to distribute the m distinct objects into n identical containers, with no container
left empty, is
n
1 X k n m
( 1) (n k)
n! n k
k=0
These numbers are denoted by S (m; n), and are called Stirling numbers of the second
kind.
Thus for jAj = m, jBj = n, where m n, the number of onto functions from A to B
is given by n!S (m; n).
S (m + 1; n) = S (m; n 1) + nS (m; n)
Example Let m = 7 and n = 3. Then S (8; 3) = 966, S (7; 2) = 63, and S (7; 3) = 301.
It can be checked that
S (7; 2) + 3S (7; 3)
= 63 + 3 (301)
= 966 = S (8; 3)
Discrete Mathematics for Computer Science 7
5. Special Functions
De…nitions
The pigeonhole principle can be proved by contradiction. If the result is not true, then
each pigeonhole has at most one pigeon roosting in it, for a total of at most n (less than
m) pigeons. Somewhere we have lost at least (m n) pigeons.
Example. To ensure that a class includes at least 2 students whose last names begin
with the same letter of the English alphabet, the class should have at least 27 students.
Here the letters are the pigeonholes.
Example. Suppose there are several red socks, several white socks, and several blue
socks in a box. What is the least number of socks that one should grab from the box
(without looking at the contents) to be sure of getting a matching pair?
If each color is considered a pigeonhole, then n = 3. Therefore, if one grabs (n + 1)
pigeons (socks), at least 2 of them will share a color.
N N
k 1 <k +1 1 =N
k k
where the inequality dN=ke < (N=k) + 1 has been used. This is a contradiction because
there are a total of N objects.
Example. Among 100 people there are at least d100=12e = 9 who were born in the
same month.
Discrete Mathematics for Computer Science 9
De…nitions.
Theorem. Let f : A ! B, where A and B are …nite sets with jAj = jBj. Then the
following statements are equivalent.
(a) f is one-to-one.
(b) f is onto.
(c) f is invertible.