Mathematics for Computer Science 201-N11 • CEGEP, Montreal

Revision sheet: injective, surjective and bijective functions (201-N11)

This chapter is almost never lost on a computation. It is lost on a misread question: the student looks at the rule, answers about the rule, and does not see that the question has changed the domain or the codomain since the previous part. The same rule x↦x2x \mapsto x^{2} successively takes all four possible natures depending on the two sets it is given, without a single sign changing in the formula.

This sheet therefore starts from the move that pays: circle the domain and the codomain before writing a word. Then comes the decision table of the triple, then the nine most costly false sentences of the chapter, each one refuted by an example with numbers, and the three write-ups the grader expects, one per verb in the question.

Mark this sheet as read or add it to your favourites: a free account, no password, keeps your read sheets and favourites from one visit to the next, tells you which chapter to tackle next and lets you ask for the method or exercise you are missing. Create your space, an email is enough.

The thread of the chapter

Injective, surjective and bijective never describe a formula: they describe the TRIPLE rule, domain, codomain, and changing just one of the two sets changes the answer.

This chapter is part of 201-N11, Mathematics for Computer Science

The essentials

The three natures are counted on the arrows RECEIVED

  • • A function f:A→Bf : A \to B sends each element of AA to ONE image and ONLY ONE: exactly one arrow LEAVES each element on the left. This condition is already met before injectivity comes up; it is not proved again.
  • • INJECTIVE: each element of BB receives AT MOST one arrow. SURJECTIVE: AT LEAST one. BIJECTIVE: EXACTLY one.
  • • The arrows LEAVING are no longer counted once the function is recognized. The whole chapter is read on the CODOMAIN side.
  • • Immediate consequence on a finite set: counting is enough, one codomain element at a time. No computation is needed.
123abcdABinjective1234abcABsurjective123abcABbijective123abcABneither
Four natures, one single move: top left, dd receives nothing; top right, aa receives two; bottom left, each one receives one; bottom right, aa receives two and bb none.

On a test, the sentence “each element of the codomain receives at most one arrow, so ff is injective” is worth as much as the algebraic proof when the sets are finite and given by a diagram.

The nature belongs to the TRIPLE, never to the rule

  • • A question that asks whether x↦x2x \mapsto x^{2} is injective without giving the two sets is not hard, it is incomplete.
  • • Shrinking the DOMAIN can make a function injective, and never makes it surjective.
  • • Shrinking the CODOMAIN can make a function surjective, and never changes injectivity.
  • • Shrinking the codomain down to the exact image f(A)f(A) always makes the function surjective: it is the only choice that guarantees the result, and N\mathbb{N} is not the exact image of squaring on Z\mathbb{Z}.
domain−2−1012codomain01234domain−2−1012codomain0142 and 3 not hitsurjective
Same rule n↦n2n\mapsto n^{2} on {−2,…,2}\{-2,\ldots,2\}: into {0,…,4}\{0,\ldots,4\}, 22 and 33 receive nothing; into the exact image {0,1,4}\{0, 1, 4\}, everything is hit.

The reflex that pays: circle the two sets in pencil as soon as you read the question, then never answer again without looking at them.

Inverse, inverse image, fibres: three objects, two notations

  • • f−1(Q)f^{-1}(Q), applied to a SUBSET QQ of the codomain, exists for every function without exception: it is the set of preimages, and it may be empty.
  • • The inverse FUNCTION f−1:B→Af^{-1} : B \to A exists only if ff is bijective. It takes an element and returns an element.
  • • The nonempty fibres f−1({y})f^{-1}(\{y\}) form a partition of the domain: they are the classes of the relation having the same image.
  • • Composition: (g∘f)(g \circ f) injective implies ff injective, (g∘f)(g \circ f) surjective implies gg surjective. Injectivity travels back to the input, surjectivity travels forward to the output.
  • • Inverse of a composition: (g∘f)−1=f−1∘g−1(g \circ f)^{-1} = f^{-1} \circ g^{-1}, the order is reversed.
A12345Babcdf⁻¹({d}) = ∅
The fibres f−1({a})={1,2}f^{-1}(\{a\})=\{1, 2\}, f−1({b})={4}f^{-1}(\{b\})=\{4\}, f−1({c})={3,5}f^{-1}(\{c\})=\{3, 5\} split the domain; f−1({d})f^{-1}(\{d\}) exists too, and equals ∅\varnothing.

The three cardinality inequalities, and what becomes of them for infinite sets

  • • An injection A→BA \to B forces ∣A∣≤∣B∣\lvert A \rvert \le \lvert B \rvert. A surjection forces ∣A∣≥∣B∣\lvert A \rvert \ge \lvert B \rvert. A bijection forces equality.
  • • Between FINITE sets of the same cardinality, injective is equivalent to surjective. This is false as soon as the sets are infinite.
  • • Useful counts: ∣B∣∣A∣\lvert B \rvert^{\lvert A \rvert} functions, ∣B∣!(∣B∣−∣A∣)!\frac{\lvert B \rvert!}{(\lvert B \rvert - \lvert A \rvert)!} injections, and ∣A∣!\lvert A \rvert! bijections when the two cardinalities are equal.
  • • Two sets are called equinumerous when there is a bijection from one onto the other. It is the only definition of equal cardinality that survives for infinite sets.
injection: 3 ≤ 4surjection: 4 ≥ 3bijection: 3 = 3
An injection places each element of the domain in a distinct slot: the codomain is at least as large. A surjection covers the codomain: the domain is at least as large.

The rules in table form

Each row reads from left to right: the assumptions, then the result. A red cell is not an answer, it is the finding that the form settles nothing and the instruction to rewrite it. Every case is followed by a worked example.

The same rule, five triples, four natures

Read this table from left to right only: the rule column is never enough, the middle column decides. Here R+=[0,∞)\mathbb{R}^{+}=[0,\infty), zero included. The last row is in red because the question there is incomplete, and an incomplete question has no answer.

RuleDomain →\to codomainNature
x↦x2x \mapsto x^{2} R→R\mathbb{R} \to \mathbb{R} none of the three

Example: f(−2)=f(2)=4f(-2) = f(2) = 4 kills injectivity, and −1-1 has no preimage.

x↦x2x \mapsto x^{2} R+→R\mathbb{R}^{+} \to \mathbb{R} injective

Example: a2=b2a^{2} = b^{2} with a,b≥0a, b \ge 0 gives a=ba = b; but −1-1 stays out of reach.

x↦x2x \mapsto x^{2} R→R+\mathbb{R} \to \mathbb{R}^{+} surjective

Example: y=9y = 9 has two preimages, 33 and −3-3, so everything is hit but nothing is unique.

x↦x2x \mapsto x^{2} R+→R+\mathbb{R}^{+} \to \mathbb{R}^{+} bijective

Example: y=9y = 9 has the single preimage 33, and the inverse is y↦yy \mapsto \sqrt{y}.

n↦n2n \mapsto n^{2} Z→N\mathbb{Z} \to \mathbb{N} none of the three

Example: (−3)2=32=9(-3)^{2} = 3^{2} = 9, and 22, 33, 55, 66, 77 are the squares of no integer.

x↦x2x \mapsto x^{2} not specified no answer incomplete question

Example: The 55 rows above give 44 different natures for the same rule.

What to do: Write down the domain and the codomain, and only then go back to the question. If the question does not give them, choose them and say so.

The table is also read from right to left, and that is how it is used on exams: you want a bijection, so you look for the pair of sets that gives one, and there is only one here.

The mistakes that cost marks

These are the errors I correct most often in session. Each one costs marks on a paper, even when the reasoning behind it is right.

1. Answering about the formula without looking at the domain and the codomain

the whole question, and often the four parts that follow

What not to write

“x2x^{2} is not injective, everybody knows that.”

What to write

“From R\mathbb{R} to R\mathbb{R}, ff is not injective because f(−2)=f(2)=4f(-2) = f(2) = 4. From R+\mathbb{R}^{+} to R+\mathbb{R}^{+}, the same rule is bijective.”

from ℝ to ℝ: 2 and −2from ℝ⁺ to ℝ⁺: 2 only
From R\mathbb{R} to R\mathbb{R}, the line y=4y=4 cuts the parabola twice (red); on R+\mathbb{R}^{+}, only once (green): same rule, another triple, another nature.

Why: This is the error that structures the chapter: the nature is a property of the triple rule, domain, codomain, and exams test it by changing the sets from one part to the next without touching the formula.

2. Believing that shrinking the codomain is always enough to make a function surjective

2 marks, and the question about the inverse that depends on it

What not to write

“n↦n2n \mapsto n^{2} goes from Z\mathbb{Z} to N\mathbb{N}, so it is surjective: the square of an integer is indeed a natural number.”

What to write

“It is not surjective: 22 is the square of no integer. The codomain that makes it surjective is the set of perfect squares, not N\mathbb{N}.”

0−11−2201234ZNsquare
Squaring from Z\mathbb{Z} to N\mathbb{N}: 22 and 33 receive no arrow despite a codomain that seemed tailor-made, and 11 and 44 each receive two.

Why: Shrinking the codomain makes a function surjective only if you shrink it ALL THE WAY DOWN to the exact image f(A)f(A). A codomain that looks tailor-made almost never is: of the 2626 integers from 00 to 2525, only 66 are squares.

3. Confusing surjective with “every element of the domain has an image”

2 marks, and the whole proof heads in the wrong direction

What not to write

“ff is surjective, since each element of AA does have an image in BB.”

What to write

“Each element of AA has an image: that only says ff is a function. ff is surjective if each element of BB has at least one PREIMAGE, which is checked on the codomain side.”

Why: The definition of a function is already settled when the question is asked: proving it again earns nothing. Surjectivity is about the codomain, and the codomain alone.

4. Believing that every function has an inverse

the whole question, since everything after it rests on an object that does not exist

What not to write

“Apply f−1f^{-1} to both sides, so x=f−1(y)x = f^{-1}(y).”

What to write

“ff is not injective, so the inverse function f−1f^{-1} does not exist. One can only write x∈f−1({y})x \in f^{-1}(\{y\}), the set of preimages.”

k1k2k3k4k5012keysslotshashinge1e2e3123employeesrecordsdirectory
On the left, three keys fall into slot 00: no arrow can be followed backwards, so there is no inverse. On the right, each file receives exactly one arrow, and the inverse exists.

Why: Only a bijection has an inverse. That is exactly why a hash table must store the key in the slot: the slot number does not lead back to the key.

5. Believing that injective means strictly increasing

2 marks, and the argument is rejected even when the conclusion is right

What not to write

“ff is not monotonic, so it is not injective.”

What to write

“Strictly monotonic implies injective, never the converse. The function x↦1xx \mapsto \frac{1}{x} on R∖{0}\mathbb{R}\setminus\{0\} is injective without being monotonic, and on a finite set the word increasing does not even make sense.”

-4-3-2-11234-4-3-2-11234exactly once
x↦1xx\mapsto\frac{1}{x} on R∖{0}\mathbb{R}\setminus\{0\} is not monotonic, and yet each horizontal line cuts it at most once: it is injective.

Why: Monotonicity is a tool of differential calculus, injectivity a property of sets. In a discrete mathematics course, the domain is often not even ordered: an alphabet, a set of keys, a set of employees.

6. Proving injectivity in the wrong direction

the whole question: the wrong proof shows that ff is a function

What not to write

“Let a=ba = b. Then 3a−7=3b−73a - 7 = 3b - 7, so f(a)=f(b)f(a) = f(b): ff is injective.”

What to write

“Let aa and bb be such that f(a)=f(b)f(a) = f(b). Then 3a−7=3b−73a - 7 = 3b - 7, so 3a=3b3a = 3b, so a=ba = b. Therefore ff is injective.”

Why: The direction a=b⇒f(a)=f(b)a = b \Rightarrow f(a) = f(b) holds for absolutely every function, injective or not. The useful implication is the other one, and the grader first looks at which equality the proof starts from.

7. Believing that a bijection between two infinite sets is impossible

the whole question, and the misconception comes back in the chapter on cardinality

What not to write

“2N2\mathbb{N} is strictly contained in N\mathbb{N}, so it is smaller, so there is no bijection.”

What to write

“ψ:N→2N\psi : \mathbb{N} \to 2\mathbb{N}, ψ(n)=2n\psi(n) = 2n, is bijective: an infinite set can be in bijection with one of its proper subsets.”

001−1213−2425−363NZ
N\mathbb{N} enumerates all of Z\mathbb{Z}, one rank per integer: each column carries exactly one arrow, so φ\varphi is bijective even though both sets are infinite.

Why: The argument by strict inclusion is only valid for finite sets. Cantor does not forbid bijections between infinite sets, he only says there is none from N\mathbb{N} onto R\mathbb{R}.

8. Reversing the direction of the cardinality inequalities

1 mark, and the conclusion of the counting problem is reversed

What not to write

“There is an injection from AA to BB, so ∣A∣≥∣B∣\lvert A \rvert \ge \lvert B \rvert.”

What to write

“An injection from AA to BB gives ∣A∣≤∣B∣\lvert A \rvert \le \lvert B \rvert: each element of AA takes a distinct place in BB, so BB is at least as large.”

Why: The memory aid that works: an injection PLACES AA in BB without collapsing, so BB must be large enough; a surjection COVERS BB with AA, so AA must be large enough. With ∣A∣=4\lvert A \rvert = 4 and ∣B∣=3\lvert B \rvert = 3, there are 3636 surjections and zero injections.

9. Returning an element where f−1f^{-1} returns a set

0.5 mark each time, and the partition into fibres becomes unreadable

What not to write

“f−1(b)=4f^{-1}(b) = 4.”

What to write

“f−1({b})={4}f^{-1}(\{b\}) = \{4\}: the inverse image of a subset is a SUBSET of the domain, even when it contains a single element, and it equals ∅\varnothing when nothing is sent to bb.”

Why: It is the distinction between 33 and {3}\{3\} seen in the chapter on sets. The notation f−1(b)f^{-1}(b) also assumes that the inverse function exists, which has not been proved and is often false.

Which method to choose

Which write-up for which verb in the question

You do not choose the write-up by topic, you choose it by verb. Proving and disproving are written in completely different ways, and the confusion costs the whole question even when the final answer is right.

  • If “prove that ff is injective” → start from f(a)=f(b)f(a) = f(b), chain the implications, arrive at a=ba = b

    Example: 3a−7=3b−7⇒a=b3a - 7 = 3b - 7 \Rightarrow a = b

    no numerical example belongs here: three tested values prove nothing

  • If “prove that ff is surjective” → take an arbitrary yy in the CODOMAIN, build xx, check f(x)=yf(x) = y

    Example: x=y+73x = \frac{y+7}{3} gives f(x)=yf(x) = y

    the final check is not optional: it is what proves that the xx you built works

  • If “prove that ff is NOT injective” → exhibit two distinct elements with the same image, with their values

    Example: g(0)=g(4)=1g(0) = g(4) = 1 for g(x)=x2−4x+1g(x) = x^{2} - 4x + 1

    saying that the function is not monotonic disproves nothing

  • If “prove that ff is NOT surjective” → exhibit ONE element of the codomain and prove that it has no preimage

    Example: 33 is not even, so 2n=32n = 3 has no integer solution

    the word prove matters: you must solve the equation and conclude that it has no solution in the domain

  • If “prove that ff is bijective” → either the two separate proofs, or build f−1f^{-1} and check BOTH compositions

    Example: f−1(f(x))=xf^{-1}(f(x)) = x and f(f−1(y))=yf(f^{-1}(y)) = y

    the second method is faster as soon as the equation f(x)=yf(x) = y can be solved explicitly

  • If “determine the nature” with a diagram or finite sets → count the arrows RECEIVED by each element of the codomain

    Example: aa receives 22, bb none: neither injective nor surjective

    no algebra is expected, and attempting some wastes time

If no branch applies, the question is asking about a property of the composition: then use the two inheritances, injectivity travels back to ff, surjectivity travels forward to gg.

The function does not work: which set to change

A problem often asks you to MAKE the function injective, surjective or bijective. Look at the defect, and the defect itself points to the set to change.

  • If two distinct elements have the same image → shrink the DOMAIN. Touching the codomain will change nothing

    Example: R→R+\mathbb{R} \to \mathbb{R}^{+} stays non-injective for x↦x2x \mapsto x^{2}

  • If an element of the codomain has no preimage → shrink the CODOMAIN down to the exact image f(A)f(A)

    Example: n↦2nn \mapsto 2n becomes bijective from Z\mathbb{Z} onto 2Z2\mathbb{Z}

  • If the proposed codomain looks tailor-made → check element by element that it really is f(A)f(A), and not a set that resembles it

    Example: N\mathbb{N} contains 22, 33, 55, which are not squares

  • If both defects are present → shrink both sets, in either order

    Example: R+→R+\mathbb{R}^{+} \to \mathbb{R}^{+} makes squaring bijective

On finite sets, this choice is constrained by the cardinalities: no injection if ∣A∣>∣B∣\lvert A \rvert > \lvert B \rvert, no surjection if ∣A∣<∣B∣\lvert A \rvert < \lvert B \rvert. Checking the cardinalities BEFORE looking for a function saves several minutes.

How the answer is expected to be written

A marker ticks steps. Here they are in order, with the concluding sentence expected word for word.

Proving that a function is injective

When to use it: The question says show, prove or demonstrate that ff is injective, and the domain is infinite or given by a formula.

  1. 1 Write “Let aa and bb be in AA such that f(a)=f(b)f(a) = f(b).” The word Let is what makes the proof universal.
  2. 2 Replace f(a)f(a) and f(b)f(b) by their expressions, without simplifying anything yet.
  3. 3 Transform until you reach a=ba = b, justifying every step that is not valid everywhere: dividing by 33 is valid because 3≠03 \ne 0, cancelling x−2x - 2 is valid because x≠2x \ne 2 by definition of the domain.
  4. 4 Conclude with the standard sentence, naming the property.

Concluding sentence

“Two elements of AA with the same image are therefore equal: ff is injective.”

The trap: Starting from a=ba = b instead of f(a)=f(b)f(a) = f(b). The proof is then true and completely useless, since it holds for every function.

Marking: Usually 3 marks: 1 for the correct start of the proof, 1 for the chain, 1 for the written conclusion.

Proving that a function is surjective

When to use it: The question asks for surjectivity, or for bijectivity through the two separate proofs.

  1. 1 Write “Let yy be an arbitrary element of BB.” The quantifier is on the CODOMAIN, not on the domain.
  2. 2 Solve the equation f(x)=yf(x) = y for the unknown xx, treating yy as a parameter.
  3. 3 Check that the xx obtained does belong to the DOMAIN: no division by zero, no square root of a negative number, no value excluded from the domain.
  4. 4 Recompute f(x)f(x) with the expression found and get back yy: this check is what earns the mark.
  5. 5 Conclude with the standard sentence.

Concluding sentence

“Every element yy of BB therefore has at least one preimage in AA: ff is surjective.”

The trap: Forgetting to check that the xx you built is in the domain. On f:R∖{2}→R∖{3}f : \mathbb{R} \setminus \{2\} \to \mathbb{R} \setminus \{3\}, that is exactly the point being graded.

Marking: Usually 3 marks, including 1 for the final check, which is the part most often skipped.

Disproving: the counterexample with numbers

When to use it: The question says show that ff is not injective, or asks for the nature of a function that has none of the three.

  1. 1 Choose two concrete elements of the domain, or one concrete element of the codomain, depending on the property to destroy.
  2. 2 Compute the images, or solve the equation, and write the numbers out in full on your copy.
  3. 3 Write the inequality that makes the counterexample valid: 0≠40 \ne 4 and yet g(0)=g(4)g(0) = g(4).
  4. 4 Conclude by recalling that a single counterexample is enough to negate a universal statement.

Concluding sentence

“g(0)=g(4)=1g(0) = g(4) = 1 while 0≠40 \ne 4: gg is not injective.”

The trap: Writing that it does not always work, without producing the values. A disproof without numbers earns no marks.

Marking: Usually 2 marks: 1 for the values, 1 for the sentence that ties them to the definition.

Check before you hand in

Five minutes of checking recover more marks than one more problem started in a hurry.

The typical problem, taken apart

Prove that f(x)=3x+1x−2f(x) = \frac{3x+1}{x-2} is bijective from R∖{2}\mathbb{R} \setminus \{2\} onto R∖{3}\mathbb{R} \setminus \{3\}

Let f:R∖{2}→R∖{3}f : \mathbb{R} \setminus \{2\} \to \mathbb{R} \setminus \{3\} be defined by f(x)=3x+1x−2f(x) = \frac{3x+1}{x-2}.

Prove that ff is bijective and give its inverse function. This is the standard exercise of the chapter: it tests at the same time the reading of the two sets, the write-up of injectivity, building a preimage and the existence of the inverse.

-6-4-2246810-8-6-4-22468101214x = 2y = 3
The curve avoids the vertical line x=2x=2, excluded from the domain, and the horizontal line y=3y=3, excluded from the codomain: these two exclusions are what make the statement true.

Step 1

The domain excludes 22 because x−2x - 2 vanishes at 22. The codomain excludes 33: if 3x+1x−2=3\frac{3x+1}{x-2} = 3, then 3x+1=3x−63x + 1 = 3x - 6, that is 1=−61 = -6, which is impossible.

Why

This step is not decoration: the two exclusions are exactly what makes the statement true. Without them, ff is neither injective nor surjective, and the grader expects you to justify them rather than copy them.

Step 2

Let aa and bb be in R∖{2}\mathbb{R} \setminus \{2\} such that f(a)=f(b)f(a) = f(b). Then 3a+1a−2=3b+1b−2\frac{3a+1}{a-2} = \frac{3b+1}{b-2}, and since a−2≠0a - 2 \ne 0 and b−2≠0b - 2 \ne 0, we can cross-multiply: (3a+1)(b−2)=(3b+1)(a−2)(3a+1)(b-2) = (3b+1)(a-2).

Why

Cross-multiplying is valid only because both denominators are nonzero, and it is the domain that guarantees it. Writing this justification earns the rigour mark.

Step 3

Expanding: 3ab−6a+b−2=3ab−6b+a−23ab - 6a + b - 2 = 3ab - 6b + a - 2. The terms 3ab3ab and −2-2 cancel, leaving −6a+b=−6b+a-6a + b = -6b + a, that is 7b=7a7b = 7a, so a=ba = b.

Why

The term 3ab3ab disappears on its own, and that is the sign that cross-multiplying was the right move. A copy that expands and does not see the cancellation almost always started from a wrong equality.

Step 4

Let y∈R∖{3}y \in \mathbb{R} \setminus \{3\}. Solve 3x+1x−2=y\frac{3x+1}{x-2} = y, that is 3x+1=y(x−2)3x + 1 = y(x-2), that is x(y−3)=2y+1x(y - 3) = 2y + 1, so x=2y+1y−3x = \frac{2y+1}{y-3}, valid because y≠3y \ne 3.

Why

Isolate xx by gathering its terms on one side. The condition y≠3y \ne 3 is used here and nowhere else: it is what allows the division, and it explains why the statement removes 33 from the codomain.

Step 5

This xx is indeed in the domain: 2y+1y−3=2\frac{2y+1}{y-3} = 2 would give 2y+1=2y−62y + 1 = 2y - 6, that is 1=−61 = -6, impossible. Check: f(2y+1y−3)=7yy−37y−3=yf\left(\frac{2y+1}{y-3}\right) = \frac{\frac{7y}{y-3}}{\frac{7}{y-3}} = y.

Why

Two moves that almost nobody writes and that the marking scheme grades both: the membership of the xx you built in the domain, then recomputing f(x)f(x). The factor 77 that cancels is your internal proof that the computation is right.

Step 6

Numerical check: f(3)=101=10f(3) = \frac{10}{1} = 10, and 2×10+110−3=217=3\frac{2 \times 10 + 1}{10 - 3} = \frac{21}{7} = 3. Likewise f(0)=1−2=−0.5f(0) = \frac{1}{-2} = -0.5, and 2×(−0.5)+1−0.5−3=0−3.5=0\frac{2 \times (-0.5) + 1}{-0.5 - 3} = \frac{0}{-3.5} = 0.

Why

Two values are enough to catch a sign error in the inverse. This check proves nothing, it detects, and it costs twenty seconds.

The conclusion, written out

“ff is injective and surjective from R∖{2}\mathbb{R} \setminus \{2\} onto R∖{3}\mathbb{R} \setminus \{3\}, hence bijective, and its inverse function is f−1(y)=2y+1y−3f^{-1}(y) = \frac{2y+1}{y-3}, defined on R∖{3}\mathbb{R} \setminus \{3\}.”

The classic mistake on this problem: Announcing bijectivity without ever saying why 22 and 33 are excluded. The copy then loses the two marks for reading the sets, even though the whole computation is right: the entire chapter is played out on these two exclusions.

Learn by heart

  • • INJECTIVE: each element of the CODOMAIN receives AT MOST one arrow. SURJECTIVE: AT LEAST one. BIJECTIVE: EXACTLY one.
  • • An injectivity proof starts from f(a)=f(b)f(a) = f(b) and arrives at a=ba = b. Never the other way around.
  • • A surjectivity proof takes yy in the codomain, BUILDS xx, checks x∈Ax \in A, then checks f(x)=yf(x) = y.
  • • Shrinking the DOMAIN helps injectivity. Shrinking the CODOMAIN helps surjectivity. Neither one does the other's job.
  • • Injection: ∣A∣≤∣B∣\lvert A \rvert \le \lvert B \rvert. Surjection: ∣A∣≥∣B∣\lvert A \rvert \ge \lvert B \rvert. Bijection: ∣A∣=∣B∣\lvert A \rvert = \lvert B \rvert.
  • • f−1(Q)f^{-1}(Q) on a SUBSET always exists; the FUNCTION f−1f^{-1} exists only if ff is bijective.
  • • (g∘f)(g \circ f) injective implies ff injective; (g∘f)(g \circ f) surjective implies gg surjective; and (g∘f)−1=f−1∘g−1(g \circ f)^{-1} = f^{-1} \circ g^{-1}.
  • • For FINITE sets of the same cardinality, injective is equivalent to surjective. For INFINITE sets, it is false: n↦2nn \mapsto 2n from N\mathbb{N} onto 2N2\mathbb{N} shows it.

Frequently asked questions

How do you tell whether a function is injective or surjective?

Look first at the domain and the codomain, never at the formula alone. On a diagram, count the arrows received by each element of the codomain: at most one means injective, at least one means surjective, exactly one means bijective. With a formula, start from f of a equals f of b for injectivity, and solve f of x equals y for surjectivity.

Is the squaring function injective?

The question is incomplete as it stands. From the reals to the reals, squaring is neither injective nor surjective. From the nonnegative reals to the reals, it becomes injective. From the reals to the nonnegative reals, it becomes surjective. From the nonnegative reals to the nonnegative reals, it is bijective, and its inverse is the square root. One rule, four natures.

What is the difference between injective and surjective?

Both are about the codomain, but not about the same thing. Injective forbids receiving two arrows: two distinct elements of the domain cannot have the same image. Surjective forbids receiving none: every element of the codomain must have at least one preimage. A function can have one without the other, both, or neither.

Does every function have an inverse?

No. Only a bijective function has an inverse function. A hash function, for example, collapses several keys onto the same slot: you cannot go back from the slot to the key, and that is why a hash table must store the key itself. The inverse image of a subset, on the other hand, can be computed for any function and returns a set, sometimes empty.

How do you prove that a function is bijective?

Two routes. The first does the two separate proofs, injectivity then surjectivity, and concludes. The second builds the inverse directly by solving f of x equals y, then checks both compositions: the inverse of f composed with f gives the identity, and f composed with the inverse does too. The second route is faster as soon as the equation can be solved.

Is a bijection between two infinite sets possible?

Yes, and it is even the definition of equal cardinality for infinite sets. The natural numbers are in bijection with the integers, by listing them as zero, minus one, one, minus two, two, and so on. An infinite set can also be in bijection with one of its proper subsets, which is impossible for finite sets.

Practise it

Corrected exercises: Injective, surjective and bijective functions, 201-N11

A method is proved on a paper, not on a sheet. The set for the same chapter takes each of these traps into a problem, with the solution written out step by step.

  • 10 corrected exercises
  • 100 points
  • 150 minutes
Do the exercises
Something missing from this sheet? A method, a trap, an exercise to practise it, a mistake you spotted: tell me, I read every request.

Sending goes through your free space: that is how I can answer you and tell you when the exercise is added. An email is enough, no password. Create your space. Rather not create an account? Write to me directly.

What is it about?
I read every request myself, nobody else sees it. No need to write your name or your school.
When your request is dealt with, you hear about it by email and in your space.

By sending, you agree that I read your request to answer it. It is kept with your account, erased with it, and never published: privacy policy.

Previous sheet Set theory and relations Next sheet Induction and recursion

© Ahmed Squalli Houssaini. Revision sheet published at www.letuteurscientifique.ca/en/fiches/cegep-n11-injective-surjective-functions. Free for personal and classroom use; republishing it elsewhere requires written permission (legal notice).

See also

Looking for a 201-N11 tutor in Montreal?

Get in touch for a first session. With a B.Sc. in computer science from McGill and an M.Sc. in applied computer science from Concordia, I connect injections and bijections to what they become later on: hash tables, primary keys in a database and encryption functions.

Site by Studio Squalli