Skip to main content

3.1 Function Mappings: Injective, Surjective & Bijective Classifications

πŸ“šModule 03: Functions & Pigeonhole PrincipleTopic 3.1: Function Mappings: Injective, Surjective & Bijective⏱️5 min read
🎯High-Yield For:Semester Exams β€’ GATE CSE β€’ Technical Interviews

πŸ’‘ Core Intuition: The 3-Second Mental Model​

🍳 The Everyday Analogy: Hotel Room Key Allocation​

Think of a function as an automated hotel check-in kiosk assigning guests to hotel rooms:

  1. The Function Contract: Every arriving guest (element in the Domain) must receive a key, and no guest can be assigned two different rooms at the same time. However, multiple guests could be booked into the same presidential suite, and some rooms in the hotel (the Codomain) might remain vacant.
  2. Injective (One-to-One): Strict private rooms! Every guest gets their own exclusive room. No two distinct guests ever share a room.
  3. Surjective (Onto): 100% hotel occupancy! Every single room in the hotel has at least one guest sleeping in it. Zero vacant rooms left.
  4. Bijective (One-to-One & Onto): Perfect one-to-one pairing! Every guest has their own exclusive private room, and every room in the hotel is occupied. Guest count equals room count (∣A∣=∣B∣|A| = |B|).

πŸ’» Bridging to Computer Science: Hash Functions, Compilers & Cryptography​

In computer science, functions govern computation:

  • Hash Tables: A hash function h:Kβ†’Bh: K \to B maps search keys to bucket indices. If hh is injective, it is a perfect hash function with zero collisions.
  • Relational Databases & Primary Keys: Primary key lookups are strictly injective; foreign keys form general functions.
  • Cryptography & Block Ciphers: Encryption algorithms like AES must be strictly bijective so that ciphertext can be uniquely decrypted back to plaintext without data loss.

πŸ“ Mathematical Formalism of Functions​

A function is a special type of binary relation with two strict operational invariants: every input must participate, and each input must produce exactly one deterministic output.

πŸ“–Definition 3.1: Formal Function Definitiondefinition

Let AA and BB be non-empty sets. A function (or mapping) ff from AA to BB, denoted:

f:A→Bf: A \to B

is a binary relation fβŠ†AΓ—Bf \subseteq A \times B satisfying two fundamental axioms:

  1. Total Existence (Totality): Every element in the domain must participate in the mapping: βˆ€a∈A,β€…β€Šβˆƒb∈BΒ suchΒ thatΒ (a,b)∈f\forall a \in A, \; \exists b \in B \text{ such that } (a, b) \in f
  2. Uniqueness (Deterministic Output): No element in the domain can map to multiple distinct elements in the codomain: (a,b1)∈f∧(a,b2)∈fβ€…β€ŠβŸΉβ€…β€Šb1=b2(a, b_1) \in f \land (a, b_2) \in f \implies b_1 = b_2

If (a,b)∈f(a, b) \in f, we write f(a)=bf(a) = b, where bb is the image of aa, and aa is the pre-image of bb.

Core Anatomical Sets:

  • Domain (DomΒ f\text{Dom } f): The source set AA of all permissible inputs.
  • Codomain (CodomΒ f\text{Codom } f): The declared target universe BB where outputs land.
  • Range / Image (ImΒ f\text{Im } f): The subset of actual outputs hit by inputs: Range(f)={f(a)∣a∈A}βŠ†B\text{Range}(f) = \{ f(a) \mid a \in A \} \subseteq B

Fundamental Invariant: Range(f)βŠ†Codomain(B)\text{Range}(f) \subseteq \text{Codomain}(B).

Diagnostic: Relation vs Valid Function​

To determine whether an arbitrary binary relation RβŠ†XΓ—YR \subseteq X \times Y qualifies as a valid function, we test it against the two axioms:

Relation InstanceFirst Coordinate InvariantSecond Coordinate InvariantFunction VerdictOperational Reason
R1={(1,2),(2,3),(3,4)}R_1 = \{(1, 2), (2, 3), (3, 4)\} on X={1,2,3},Y={2,3,4,5}X=\{1, 2, 3\}, Y=\{2, 3, 4, 5\}Every x∈Xx \in X appears exactly onceExactly 1 target per inputValid FunctionSatisfies both Totality and Uniqueness. Notice 5∈Y5 \in Y is untouched (RangeβŠ‚Y\text{Range} \subset Y).
R2={(1,2),(4,5),(5,5),(5,7)}R_2 = \{(1, 2), (4, 5), (5, 5), (5, 7)\} on X={1,2,3,4,5},Y={2,3,4,5,6,7}X=\{1, 2, 3, 4, 5\}, Y=\{2, 3, 4, 5, 6, 7\}Elements 2,3∈X2, 3 \in X are missingInput 55 maps to both 55 and 77Invalid FunctionFails Totality (unmapped inputs) AND fails Uniqueness (one-to-many branching).
R3={(1,2),(2,2),(3,2)}R_3 = \{(1, 2), (2, 2), (3, 2)\} on X={1,2,3},Y={2,4}X=\{1, 2, 3\}, Y=\{2, 4\}Every x∈Xx \in X appears exactly onceAll inputs share target 22Valid FunctionMany-to-one is completely legal! Range is {2}βŠ†Y\{2\} \subseteq Y.

⚑ High-Yield Invariants: Set Images & Pre-Images​

A frequent source of errors in discrete exams is assuming that set operations distribute identically across forward function images and inverse pre-images. The following invariants govern subsets E,FβŠ†AE, F \subseteq A and S,TβŠ†BS, T \subseteq B under f:Aβ†’Bf: A \to B:

πŸ“Theorem 3.1: Set Image and Pre-Image Invariantstheorem

Let f:Aβ†’Bf: A \to B be an arbitrary function. For any subsets E,FβŠ†AE, F \subseteq A and S,TβŠ†BS, T \subseteq B:

  1. Union commutes with forward image: f(EβˆͺF)=f(E)βˆͺf(F)f(E \cup F) = f(E) \cup f(F)
  2. Intersection does NOT in general commute with forward image: f(E∩F)βŠ†f(E)∩f(F)f(E \cap F) \subseteq f(E) \cap f(F) Equality f(E∩F)=f(E)∩f(F)f(E \cap F) = f(E) \cap f(F) holds for all subsets E,FE, F if and only if ff is injective (one-to-one)!
  3. Pre-images commute unconditionally with both Union and Intersection: fβˆ’1(SβˆͺT)=fβˆ’1(S)βˆͺfβˆ’1(T)f^{-1}(S \cup T) = f^{-1}(S) \cup f^{-1}(T) fβˆ’1(S∩T)=fβˆ’1(S)∩fβˆ’1(T)f^{-1}(S \cap T) = f^{-1}(S) \cap f^{-1}(T)
  4. Cardinality Inequalities: ∣f(AβˆͺB)βˆ£β‰ βˆ£f(A)∣+∣f(B)∣and∣f(A∩B)βˆ£β‰ min⁑{∣f(A)∣,∣f(B)∣}|f(A \cup B)| \neq |f(A)| + |f(B)| \quad \text{and} \quad |f(A \cap B)| \neq \min\{|f(A)|, |f(B)|\}
Concrete Counter-Example: Why Forward Image Fails on Intersections

Let A={1,2}A = \{1, 2\} and B={k}B = \{k\}. Define f(1)=kf(1) = k and f(2)=kf(2) = k (a non-injective function).
Choose disjoint subsets E={1}E = \{1\} and F={2}F = \{2\}:

  • Left Side: E∩F=βˆ…β€…β€ŠβŸΉβ€…β€Šf(E∩F)=f(βˆ…)=βˆ…E \cap F = \emptyset \implies f(E \cap F) = f(\emptyset) = \emptyset.
  • Right Side: f(E)={k}f(E) = \{k\} and f(F)={k}β€…β€ŠβŸΉβ€…β€Šf(E)∩f(F)={k}f(F) = \{k\} \implies f(E) \cap f(F) = \{k\}.
  • Notice that βˆ…βŠ‚{k}\emptyset \subset \{k\}. Therefore, f(E∩F)⊊f(E)∩f(F)f(E \cap F) \subsetneq f(E) \cap f(F).
    When ff is injective, elements cannot share images, restoring strict equality!

πŸ” Injective, Surjective & Bijective Classifications​

Injective (One-to-One) vs Surjective (Onto) Mappings

The two foundational orthogonality dimensions of mathematical functions

Injective

Injection (One-to-One)

🏹
Dominant Architecture / DomainCollision-Free Output Distribution
  • β€’Distinct domain elements map to distinct codomain elements.
  • β€’Formal: f(x₁) = f(xβ‚‚) ⟹ x₁ = xβ‚‚ (Contrapositive: x₁ β‰  xβ‚‚ ⟹ f(x₁) β‰  f(xβ‚‚)).
  • β€’Pre-images are unique: Every y ∈ B has at most one pre-image.
  • β€’Necessary Cardinality Bound: |A| ≀ |B|.
"No two arrows ever strike the same target."
Surjective

Surjection (Onto)

🎯
Dominant Architecture / DomainExhaustive Codomain Coverage
  • β€’Every element of the codomain is the image of at least one domain element.
  • β€’Formal: βˆ€y ∈ B, βˆƒx ∈ A such that f(x) = y.
  • β€’Full coverage: Range(f) = Codomain(B). Zero untouched elements.
  • β€’Necessary Cardinality Bound: |A| β‰₯ |B|.
"Every point in the target set receives at least one incoming arrow."
πŸ“–Definition 3.2: Bijective Function (One-to-One Correspondence)definition

A function f:A→Bf: A \to B is bijective (or a bijection, or a one-to-one correspondence) if and only if it is simultaneously:

  1. Injective (One-to-One), and
  2. Surjective (Onto).

Cardinality Invariant for Finite Sets: If AA and BB are finite sets, a bijection exists between AA and BB if and only if:

∣A∣=∣B∣|A| = |B|

When ∣A∣=∣B∣=n|A| = |B| = n, every injective function is automatically surjective, and every surjective function is automatically injective!


πŸ“Š Master Function Feasibility & Cardinality Matrix​

For finite sets AA with ∣A∣=m|A| = m and BB with ∣B∣=n|B| = n, mapping feasibility is strictly determined by cardinality:

Cardinality ConditionInjective f:A→Bf: A \to BSurjective f:A→Bf: A \to BBijective f:A→Bf: A \to BCore Intuition & Governing Invariant
m<nm \lt n (∣A∣<∣B∣\vert A \vert \lt \vert B \vert)PossibleImpossible (00)Impossible (00)Plenty of targets for distinct assignments; impossible to cover nn targets with only mm domain elements.
m>nm \gt n (∣A∣>∣B∣\vert A \vert \gt \vert B \vert)Impossible (00)PossibleImpossible (00)By Pigeonhole Principle, collisions are inevitable; sufficient domain elements exist to cover all nn targets.
m=nm = n (∣A∣=∣B∣\vert A \vert = \vert B \vert)PossiblePossiblePossibleEquivalence Theorem: For finite sets of equal size, Injectionβ€…β€ŠβŸΊβ€…β€ŠSurjectionβ€…β€ŠβŸΊβ€…β€ŠBijection\text{Injection} \iff \text{Surjection} \iff \text{Bijection}.

πŸ“ Step-by-Step Worked Examples​

Example 1: Verifying Function Invariants on Discrete Sets​

Problem Statement: Let A={1,2,3}A = \{1, 2, 3\} and B={a,b,c,d}B = \{a, b, c, d\}. Determine whether each of the following relations is a function, and if so, classify whether it is injective, surjective, or bijective:

  1. R1={(1,a),(2,b),(3,c)}R_1 = \{(1, a), (2, b), (3, c)\}
  2. R2={(1,a),(2,b),(2,c),(3,d)}R_2 = \{(1, a), (2, b), (2, c), (3, d)\}
  3. R3={(1,a),(3,b)}R_3 = \{(1, a), (3, b)\}
  4. R4={(1,b),(2,b),(3,b)}R_4 = \{(1, b), (2, b), (3, b)\}

Step-by-Step Solution:

  1. Analysis of R1R_1:

    • Totality: Every element in AA (1,2,31, 2, 3) appears as the first coordinate.
    • Uniqueness: No first coordinate is repeated. Thus, R1R_1 is a valid function f:Aβ†’Bf: A \to B.
    • Injectivity: f(1)=a,f(2)=b,f(3)=cf(1) = a, f(2) = b, f(3) = c. All images are distinct. Hence, R1R_1 is Injective.
    • Surjectivity: The codomain is {a,b,c,d}\{a, b, c, d\}, but the range is {a,b,c}\{a, b, c\}. Since dβˆ‰Ranged \notin \text{Range}, it is NOT Surjective.
    • Classification: Injective but not surjective.
  2. Analysis of R2R_2:

    • Element 2∈A2 \in A appears twice with different outputs: (2,b)(2, b) and (2,c)(2, c).
    • Violates the Uniqueness Axiom.
    • Classification: Not a function.
  3. Analysis of R3R_3:

    • Element 2∈A2 \in A does not appear as a first coordinate.
    • Violates the Totality Axiom.
    • Classification: Not a function (merely a partial function).
  4. Analysis of R4R_4:

    • Totality: Every element in AA (1,2,31, 2, 3) has an image.
    • Uniqueness: Each has exactly one image (bb). Thus, R4R_4 is a valid function.
    • Injectivity: f(1)=f(2)=f(3)=bf(1) = f(2) = f(3) = b, yet 1β‰ 21 \neq 2. Not injective.
    • Surjectivity: Range is {b}β‰ B\{b\} \neq B. Not surjective.
    • Classification: Neither injective nor surjective (Many-to-one into function).

Key Takeaway: A valid function requires every element of the domain to have exactly one outgoing arrow.


Example 2: Analyzing Real-Valued Functions​

Problem Statement: Determine whether the function f:Rβ†’Rf: \mathbb{R} \to \mathbb{R} defined by f(x)=3xβˆ’5f(x) = 3x - 5 is bijective.

Step-by-Step Solution:

  1. Step 1: Test for Injectivity (One-to-One)

    • Assume f(x1)=f(x2)f(x_1) = f(x_2) for arbitrary x1,x2∈Rx_1, x_2 \in \mathbb{R}: 3x1βˆ’5=3x2βˆ’53x_1 - 5 = 3x_2 - 5
    • Add 55 to both sides: 3x1=3x23x_1 = 3x_2
    • Divide by 33: x1=x2x_1 = x_2
    • Since f(x1)=f(x2)β€…β€ŠβŸΉβ€…β€Šx1=x2f(x_1) = f(x_2) \implies x_1 = x_2, the function is strictly Injective.
  2. Step 2: Test for Surjectivity (Onto)

    • Let y∈Ry \in \mathbb{R} be an arbitrary element in the codomain. We must find an x∈Rx \in \mathbb{R} such that f(x)=yf(x) = y: y=3xβˆ’5β€…β€ŠβŸΉβ€…β€Š3x=y+5β€…β€ŠβŸΉβ€…β€Šx=y+53y = 3x - 5 \implies 3x = y + 5 \implies x = \frac{y + 5}{3}
    • Since y∈Ry \in \mathbb{R}, y+53\frac{y + 5}{3} is also a well-defined real number (x∈Rx \in \mathbb{R}).
    • Verifying the image: f(x)=f(y+53)=3(y+53)βˆ’5=(y+5)βˆ’5=yf(x) = f\left(\frac{y + 5}{3}\right) = 3\left(\frac{y + 5}{3}\right) - 5 = (y + 5) - 5 = y
    • Every real number yy has a pre-image in the domain. Hence, ff is strictly Surjective.
  3. Step 3: Conclusion

    • Because ff is both injective and surjective, ff is a Bijective function.

Key Takeaway: For algebraic functions, injectivity is proven by equating f(x1)=f(x2)f(x_1) = f(x_2) and solving for x1=x2x_1 = x_2; surjectivity is proven by solving y=f(x)y = f(x) for xx and verifying that the resulting expression is defined for all yy in the codomain.


🎯 Exam & Interview Pitfall Check​

Core Conceptual Questions

Question 1: If a function f:Aβ†’Bf: A \to B is injective, does altering the codomain BB to equal Range(f)\text{Range}(f) always turn it into a bijection? Key Focus Points: Yes! By definition, an injection only fails to be surjective if there are elements in Bβˆ–Range(f)B \setminus \text{Range}(f). If we restrict the codomain to Bβ€²=Range(f)B' = \text{Range}(f), the mapping f:Aβ†’Bβ€²f: A \to B' becomes both injective and surjective, hence a bijection.

Question 2: Can an infinite set have an injection into a proper subset of itself? Key Focus Points: Yes! This is Dedekind's definition of an infinite set. For example, f:N→Nf: \mathbb{N} \to \mathbb{N} defined by f(n)=2nf(n) = 2n maps all natural numbers to the even natural numbers (a strict proper subset), and ff is strictly injective. For finite sets, this is impossible.

Common Interview Traps: Architectural Trade-Offs

Trap 1: Assuming f(x)=x2f(x) = x^2 is always non-injective Why it fails: Injectivity depends strictly on the Domain, not just the algebraic rule! If f:Rβ†’Rf: \mathbb{R} \to \mathbb{R} where f(x)=x2f(x) = x^2, it is NOT injective because f(βˆ’2)=f(2)=4f(-2) = f(2) = 4. However, if f:R+β†’Rf: \mathbb{R}^+ \to \mathbb{R} (positive real numbers only), f(x)=x2f(x) = x^2 is strictly injective because negative values do not exist in the domain! Always check the domain and codomain boundaries first.

Trap 2: Confusing Codomain with Range Why it fails: In function notation f:Aβ†’Bf: A \to B, set BB is the Codomain, NOT necessarily the Range. The Range is the actual set of outputs {f(a)∣a∈A}\{f(a) \mid a \in A\}. Confusing the two causes errors in surjectivity proofs.

πŸ’¬

Discussion & Doubts