01 / 21
f

Functions:
Injections, Surjections, Bijections

Master the three fundamental types of functions in discrete mathematics: one-to-one, onto, and bijective mappings between sets.

Discrete Math

What Is a Function?

A function \( f: A \to B \) is a rule that assigns to each element in the domain \( A \) exactly one element in the codomain \( B \). Every element in \( A \) must be mapped, and no element in \( A \) can map to two different outputs.

A (Domain) B (Codomain) 1 2 3 a b c f

The Three Types of Functions

Functions are classified by how they connect domain elements to codomain elements. These three properties capture different structural guarantees about the mapping.

Injection (One-to-One)
Different inputs always produce different outputs. No two domain elements share a codomain element.
Surjection (Onto)
Every codomain element is hit by at least one input. The range equals the entire codomain.
Bijection (One-to-One and Onto)
Both injective and surjective: a perfect pairing with an inverse function.

Why Do These Matter?

1
Counting: A bijection between two finite sets proves they have the same cardinality \( |A| = |B| \).
2
Invertibility: Only bijections have a well-defined inverse function \( f^{-1}: B \to A \).
3
Cryptography: Encryption functions must be bijections so messages can be uniquely decrypted.
4
Database design: Injections ensure unique keys: no two records share the same identifier.

Injection: One-to-One

A B 1 2 3 a b c d Injective: each output hit at most once. Element d is unhit.

Surjection: Onto

A B 1 2 3 4 a b c Surjective: every element in B is hit. Elements 1 and 2 both map to a.

Bijection: Perfect Pairing

A B 1 2 3 a b c Bijective: perfect one-to-one correspondence. |A| = |B|.

Cardinality and Set Size

For finite sets \( A \) and \( B \), the type of function \( f: A \to B \) constrains the relationship between \( |A| \) and \( |B| \):

Injection exists
\( |A| \leq |B| \): the codomain must be at least as large as the domain.
Surjection exists
\( |A| \geq |B| \): the domain must be at least as large as the codomain.
Bijection exists
\( |A| = |B| \): both sets have exactly the same number of elements.

Comparing Injection vs. Surjection

Property Injection (1-to-1) Surjection (Onto)
Core guarantee No two inputs share an output Every output is reached
Formal test \( f(a_1) = f(a_2) \implies a_1 = a_2 \) \( \forall b, \exists a: f(a)=b \)
Cardinality \( |A| \leq |B| \) \( |A| \geq |B| \)
Left inverse? ✓ Yes (if injective) ✕ Not necessarily
Right inverse? ✕ Not necessarily ✓ Yes (if surjective)
Unhit elements in \( B \)? Possible (some \( b \) unused) None (all \( b \) hit)

How to Prove Each Property

1
Injection: Assume \( f(a_1) = f(a_2) \). Then algebraically show \( a_1 = a_2 \). Alternatively, find a counterexample where \( a_1 \neq a_2 \) but \( f(a_1) = f(a_2) \) to disprove.
2
Surjection: Let \( b \in B \) be arbitrary. Construct an explicit \( a \in A \) such that \( f(a) = b \). To disprove, find a \( b \) with no preimage.
3
Bijection: Prove both injection and surjection separately. Or, construct an explicit inverse function \( g: B \to A \) with \( g \circ f = \text{id}_A \) and \( f \circ g = \text{id}_B \).

Example 1: \( f(x) = 2x + 1 \)

Let \( f: \mathbb{Z} \to \mathbb{Z} \) be defined by \( f(x) = 2x + 1 \). Determine whether \( f \) is injective, surjective, or bijective.

1
Injection test: Suppose \( f(a_1) = f(a_2) \). Then \( 2a_1 + 1 = 2a_2 + 1 \), so \( a_1 = a_2 \). ✓ Injective.
2
Surjection test: Is every integer in the range? Take \( b = 4 \). We need \( 2a + 1 = 4 \), so \( a = 1.5 \notin \mathbb{Z} \). ✕ Not surjective.

Example 2: \( f(x) = x^2 \)

Let \( f: \mathbb{Z} \to \mathbb{Z} \) be defined by \( f(x) = x^2 \). Classify this function.

1
Injection test: \( f(2) = 4 \) and \( f(-2) = 4 \), but \( 2 \neq -2 \). ✕ Not injective.
2
Surjection test: Is \( b = -1 \) in the range? We need \( x^2 = -1 \), which has no solution in \( \mathbb{Z} \). ✕ Not surjective.

Example 3: A Finite Set Bijection

Let \( A = \{a, b, c\} \) and \( B = \{1, 2, 3\} \). Define \( f(a) = 2 \), \( f(b) = 3 \), \( f(c) = 1 \). Is this a bijection?

A B a b c 1 2 3

Domain and Codomain Change Everything

The same formula can have different classification depending on the domain and codomain. Consider \( f(x) = x^2 \):

Function Injective? Surjective? Bijective?
\( \mathbb{Z} \to \mathbb{Z} \) ✕ ✕ ✕
\( \mathbb{N} \to \mathbb{N} \) ✓ ✕ ✕
\( \mathbb{R} \to [0, \infty) \) ✕ ✓ ✕
\( [0, \infty) \to [0, \infty) \) ✓ ✓ ✓

Common Mistakes

✕ Confusing Range with Codomain
The codomain is the declared target set. The range is only the subset actually hit. Surjectivity means \( \text{range} = \text{codomain} \).
✕ Ignoring Domain Restrictions
\( f(x)=x^2 \) is injective on \( [0,\infty) \) but not on \( \mathbb{R} \). Always check the stated domain.
✕ Testing Only a Few Examples
Checking that \( f(1) \neq f(2) \) does not prove injection. You must prove it for all pairs, typically via algebra.

Summary Table

Property Injection Surjection Bijection
Also called One-to-one Onto One-to-one correspondence
Each output hit by At most one input At least one input Exactly one input
Cardinality \( |A| \leq |B| \) \( |A| \geq |B| \) \( |A| = |B| \)
Inverse exists? Left inverse Right inverse Full inverse \( f^{-1} \)
Composition rule \( g \circ f \) injective \( \implies f \) injective \( g \circ f \) surjective \( \implies g \) surjective Both rules hold

Question 1 of 5

A function \( f: A \to B \) is injective if and only if:

Question 2 of 5

Let \( f: \mathbb{Z} \to \mathbb{Z} \) be defined by \( f(n) = n + 3 \). Which classification is correct?

Question 3 of 5

If \( f: A \to B \) is a surjection and \( A \) and \( B \) are finite sets, which must be true?

Question 4 of 5

Consider \( f: \{1,2,3,4\} \to \{a,b,c\} \) defined by \( f(1)=a, f(2)=b, f(3)=c, f(4)=a \). What type of function is this?

Question 5 of 5

Which of the following is necessary and sufficient for a function \( f: A \to B \) between finite sets of equal size to be a bijection?