Вы находитесь на странице: 1из 10

Chapter 5

Relations and Functions


1 Cartesian Products and Relations
Definition 1
For set A, B U , the Cartesian product of A and B is denoted by A B and

A B = {(a ,b )|a A,b B }.

+ ordered pairs
1. For (a ,b ), (c , d ) A B
(a ,b ) = (c , d ) a = c and b = d

2. If A, B are finite, |A B | = |A| |B |.

3. A B 6= B A
|A B | = |B A|

4. In general, if n Z+ , n 3, and A 1 , A 2 A n U ,
A 1 A 2 A n = {(a 1 , a 2 , a n )|a i A i , 1 i n}

n-fold product.
(a 1 , a 2 , a n ) : n-tuples.

Example 1 Let U = {1, 2, 3, , 7} A = {2, 3, 4} B = {4, 5}

Example 2
U = R, R R = {(x , y )|x , y R} : real plane of coordinate geometry.

Definition 2
For set A, B U , any subset of A B is called a relation from A to B .
Any subset of A A is called a binary relation on A.

Example 3
In Example 1: relations from A to B :

+ In general, for finite sets A, B with |A| = m and |B | = n, there are 2 mn relations from A to B .

Example 4 A = U = Z+

1
Example 5
Let R be a subset of N N where R = {(m , n)|n = 7m }
Then R can be given recursively by

1. (0, 0) R

2. If (s , t ) R, (s + 1, t + 7) R

Prove (3, 21) R

2
2 Functions : Plain and One-To-One
Definition 1
For nonempty sets A, B , a function, or mapping, f from A to B , denote f : A B , is a relation from
A to B in which every element of A appears exactly once as the first component of an ordered pair in
the relation.

+ When (a ,b ) is an ordered pair in the function f , we write f (a ) = b .


b: image of a under f .

a: preimage of b

If (a ,b ), (a , c ) f b =c

Example 1 A = {1, 2, 3} B = {w, x , y , z }

Example 2 Many interesting functions in computer science.

3
Example 3 ceiling and floor

+ Let A, B be nonempty sets with |A| = m , |B | = n.


1. If A = {a 1 , a 2 , a m } and B = {b 1 ,b 2 , b n },
then a function f : A B has the form {(a 1 , x 1 ), (a 2 , x 2 ), , (a m , x m )}

2. Select any of n elements of B for x , and then do the same for x 2 , x 3 , , x m

there are n m = |B ||A| functions from A to B .

Definition 2
A function f : A B is called one-to-one, or injective, if each element of B appears at most once as
the image of an element of A.

+ If f : A B is one-to-one, with A, B finite, we must have |A| |B |.


For any sets A and B , if f : A B is one-to-one, then for a 1 , a 2 A,

f (a 1 ) = f (a 2 ) a1 = a2

Example 4 Consider the following functions

Example 5 Let A = {1, 2, 3} B = {1, 2, 3, 4, 5}

4
+ Let A = {a 1 , a 2 , a m } B = {b 1 ,b 2 , b n } and m n, a 1-1function f : A B has the form
{(a 1 , x 1 ), (a 2 , x 2 ), , (a m , x m )}, where there are n choices for x 1 , n 1 choices for x 2 , n 2 choices for
x 3 , , n (m 1) choices for x m . Then the # of 1-1 functions from A to B is

n!
n(n 1)(n 2) (n m + 1) = = P(n, m )
(n m )!

Example 6 A = {1, 2, 3} B = {1, 2, 3, 4, 5}

Definition 3
If f : A B and A 1 A then
f (A 1 ) = {b B |b = f (a ) for some a A 1 }
and f (A 1 ) is called the image of A 1 under f .

Example 7 Consider the following functions

Definition 4
If f : A B and A 1 A, then f |A1 : A 1 B is called restriction of f to A 1 if f |A1 (a ) = f (a ) for all a A 1 .

5
3 Onto Functions : Stirling Numbers of the Second Kind
Definition 1
If a function f : A B is called onto, or surjective, if f (A) = B
That is, if for all b B , there is at least one a A with f (a ) = b .

Example 1

Example 2 If A = {1, 2, 3, 4} B = {x , y , z }

+ If A, B are finite, for any onto function f : A B |A| |B |.

Example 3 A = {w, x , y , z } B = {1, 2, 3}. Determine the # of onto function f : A B .

+ For finite sets A, B with |A| = m and |B | = n, there are


         
n n n n 2 n n 1 n
m
n (n 1) +
m
(n 2) + (1)
m
2 + (1)
m
1m
n n 1 n 2 2 1
n 1  
X n
= (1)k
(n k )m
k =0
n k
n  
X n
= (1)k
(n k )m
k =0
n k

onto functios from A to B .

Example 4 A = {1, 2, 3, 4, 5, 6, 7} B = {w, x , y , z }

+
The # of onto functions from a set of size 7 to a set of size 4.
= The # of ways to distribute 7 different objects into 4 distinct containers with no container left empty.

6
Example 5
A = {a ,b, c , d } B = {1, 2, 3}
There are 36 onto functions from A to B .
How many ways to distribute the distinct objects a ,b, c , d among three identical container, leaving
no container empty?

+ The # of ways to distribute the m distinct objects into n identical containers, with no container
left empty, is
n  
1 X n
S(m , n) = (1)k
(n k )m
n! k =0 n k

where S(m , n) is called a Stirling number of the second kind.

+
For |A| = m n = |B |, there are n! S(m , n) onto functions from A to B .
m \n 1 2 3 4 5 6 7 8
1 1
2 1 1
3 1 3 1
4 1 7 6 1
5 1 15 25 10 1
6 1 31 90 65 15 1
7 1 63 301 350 140 21 1
8 1 127 966 1701 1050 266 28 1

Theorem 1.
For m , n Z with 1 < n m , then

S(m + 1, n) = S(m , n 1) + n S(m , n)

Example 6 How many ways of the unordered factorizations of 30030

7
4 Special Functions
Definition 1
For any nonempty sets A, B , any function f : A A B is called a binary operation on A. If B A,
then the binary operation is said to be closed on A.

Definition 2
A function g : A A is called a unary, or monary, operation on A.

Example 1

Definition 3 f : A A B

1. f is said to be commutative if f (a ,b ) = f (b, a ) (a ,b ) A A

2. When B A, f is said to be associative if f (f (a ,b ), c ) = f (a , f (b, c )) a ,b, c A

Example 2

8
Example 3 A = {a ,b, c , d } |A A| = 16 f : A A A
Determine the number of commutative closed binary ops on A.

Definition 4
Let f : A A B be a binary op on A. An element x A is called an identity for f if f (a , x ) = f (x , a ) =
a , a A

Example 4

Example 5 If A = {x , a ,b, c , d }, how many closed binary ops on A have x as the identity?

+ REMARK:

+ In general, if A = {a , a , , a }, for n Z , then there are


1 2 n
+

2
1. n n closed binary ops f : A A A
(n 2 n)
2. n n n 2 commutative closed binary ops on A.

3. n n (2n 1) = n (n1) binary ops f : A A A where some particular a i A, for 1 i n, is the


2 2

identity element.
n
4. 1 n (n 1) binary ops on A where there is an identity.
2

[(n 1)2 (n1)]


5. n n1 n 2 commutative closed binary ops on A where a particular a i A, for 1 i n, is
the identity element.
n  n 1 [(n1)2 (n 1)]
6. 1
n n 2 commutative closed binary ops on A that have an identity.

9
5 The Pigeonhole Principle
The Pigeonhole Principle
If m pigeons occupy n pigeonholes and m > n, then at least one pigeonhole has two or more pigeons
roosting in it.

Example 1
How many people must be selected from a collection of 15 married couples to ensure that at least two
of the persons chosen are married to each other?

Example 2
Let S Z+ , where |S| = 37. Then S contains 2 or more elements that have the same remainder upon
division by 36.

Example 3
Any subset of size 6 from the set S = {1, 2, , 9} must contain two elements whose sum is 10.

Example 4
Let S be a set of 6 POS integers whose maximum is at most 14. Show that the sums of the elements in
all nonempty subsets of S cannot all be distinct.

10