Functions
f: A
B
A - domain of the function f
B - codomain of f
To each element aA, the function assigns an element of B denoted f(a),
the image of a
Example
A={a,b,c} B={0,1}
x
a
0
b
1
c
f1
f1(x)
a
b
0
0
c
1
f1=(0,0,1)
f2=(1,0,1)
f3=(1,1,1)
How many functions from A to B are there?
BA the set of all functions from A to B
Theorem.
Proof.
| B || B |
A
| A|
A={a1, a2, … , an}
|B| |B| … |B|
| B || A|
Surjection
Definition. A function f: A
B is a surjection if for each
element bB there is an aA such that f(a)=b
Which of the following functions (with B={0,1}) are surjections?
f1=(0,0,1)
f2=(1,0,1)
f3=(1,1,1)
For A={a,b} and B={0,1,2}, is f=(2,1) a surjection? No
because for any surjection f: AB, |A||B|
Surjection
Definition. A function f: A
B is a surjection if for each
element bB there is an aA such that f(a)=b
The number of all functions from A to B is
How many of them are surjections?
| B || A|
The number of surjections
Theorem. The number of surjections from a set of n elements
k
to a set of k elements is
ik
n
(1) i (k i)
i 0
Proof.
f: A={1,2,…,n}
B={1,2,…,k}
Ai the set of functions from A to B that never take on the value iB
The number of surjections from A to B is
Si
k
| A
j1 j2 ji
j1
k n | A1 ... Ak |
Aj2 Aji |
i
k
(
1
)
S
S
S
S
S
(
1
)
Sk
i
0
1
2
3
i 0
The number of surjections
Theorem. The number of surjections from a set of n elements
k
to a set of k elements is
ik
n
(1) i (k i)
i 0
Proof.
| Aj1 Aj2 Aji |
the number of functions
from A to B-{j1,j2,…,ji}
k
Si | Aj1 Aj2 Aji | (k i) n
j1 j2 ... ji
i
k
n
(
1
)
S
(
1
)
(
k
i
)
i
i
i 0
i 0
k
k
i
i
=(k-i)n
Partitions
1. How many partitions of an n-set are there?
Bn Bell number
2. How many ways to partition an n-set into k subsets are there?
{kn}
Stirling number of the second kind
3. How many ordered partitions of an n-set into k subsets are there?
A partition (A1,…,Ak) is ordered if the order of the subsets matters
4. How many ordered partitions of an n-set into k subsets of
cardinalities n1,…,nk are there?
n
n!
n1!n2 ! nk !
n
,...,
n
k
1
The number of ordered partitions
Theorem. The number of ordered partitions of a set of n elements
into k non-empty subsets is
k
k
n
(
1
)
(
k
i
)
i
i 0
i
Proof.
Let A be a set of n elements and B={1,2,…,k}.
Each surjection f from A to B defines an ordered partition of A into k nonempty subsets A1,…,Ak as follows: Ai={aA | f(a)=i}.
Conversely, each ordered partition of A into k non-empty subsets defines a
surjection f: A B
Therefore, the number of ordered partitions of A coincides with the number
of surjections from A to B.
The number of partitions
Theorem. The number of partitions of a set of n elements into k
non-empty subsets is
1 k
ik
n
(
1
)
(
k
i
)
i
k! i 0
Injection
Definition. A function f: AB is a injection if for any a,bA,
ab implies f(a)f(b)
For A={a,b,c} and B={0,1}, is f=(0,0,1) injection?
No
because for any injection f: AB, |B||A|
How many injections from A to B are there?
| B |
| B |!
| A |!
(| B | | A |)!
| A |
A
B
f(A)
Bijection
Definition. A function f: AB is a bijection if f is an injection and
surjection
Example: For A={a,b,c} and B={0,1,2}, f=(2,1,0) is a bijection
For any injection f: AB, |B||A|
For any surjection f: AB, |A||B|
For any bijection f: AB, |A|=|B| Does |A|=|B| imply that f is bijection?
How many bijections from A to B are there?
|A|!
Bijection
For any function f: AB, any two of the following three statements
imply the remaining one
1. f is surjection
2. f is injection
3. |A|=|B|
Proof.
(1,3 2) By contradiction, assume f(a)=f(b) for some ab. Then
the number of elements of B that are images of some elements
of A is strictly less than |B|=|A|, contradicting 1.
(2,31) Analogously
© Copyright 2026 Paperzz