One-to-One and Onto

Chapter 5: Functions

Learning objectives

  • Define injective (one-to-one) and surjective (onto) functions
  • Prove or disprove injectivity by direct argument or counterexample
  • Prove or disprove surjectivity by exhibiting preimages or finding gaps
  • Recognise bijections as the functions that establish equal cardinality

Two questions you can always ask of a function: "do different inputs always give different outputs?" and "does every potential output actually get hit?" The first is injectivity; the second is surjectivity. Both questions are independently interesting, and a function answering "yes" to both — a bijection — is the formal definition of "the two sets are the same size." Bijections are how Cantor proved Q=N|\mathbb{Q}| = |\mathbb{N}| and R>N|\mathbb{R}| > |\mathbb{N}|; they are also how cryptographic ciphers (a bijection encrypts and decrypts) and lossless compression (a bijection between raw and compressed data) are built. This section gives you the proof patterns for both properties.

Injective (one-to-one)

A function f:ABf: A \to B is injective if distinct inputs give distinct outputs:

a1,a2A,f(a1)=f(a2)a1=a2.\forall a_1, a_2 \in A,\, f(a_1) = f(a_2) \Rightarrow a_1 = a_2.

(Contrapositive: a1a2f(a1)f(a2)a_1 \neq a_2 \Rightarrow f(a_1) \neq f(a_2).) To prove injectivity, assume f(a1)=f(a2)f(a_1) = f(a_2) and derive a1=a2a_1 = a_2. To disprove it, exhibit two distinct inputs with the same output.

Surjective (onto)

A function f:ABf: A \to B is surjective if every codomain element is hit:

bB,aA,f(a)=b.\forall b \in B,\, \exists a \in A,\, f(a) = b.

Equivalently, Ran(f)=B\text{Ran}(f) = B. To prove surjectivity, take an arbitrary bBb \in B and produce an aAa \in A with f(a)=bf(a) = b. To disprove it, find a single bBb \in B with no preimage.

Bijective

A function is bijective if it is both injective and surjective. Bijections pair the elements of AA perfectly with the elements of BB — this is the precise meaning of "AA and BB have the same cardinality."

Injectivity InspectorInteractive figure — enable JavaScript to interact.

Pause and think: f:ZZ,f(n)=2nf: \mathbb{Z} \to \mathbb{Z},, f(n) = 2n. Is it injective? Surjective? If you change the codomain to "even integers," does surjectivity status change?

Try it

  • Predict, then prove: f:RR,f(x)=3x5f: \mathbb{R} \to \mathbb{R},, f(x) = 3x - 5 is bijective.
  • Show by counterexample that g:RR,g(x)=x2g: \mathbb{R} \to \mathbb{R},, g(x) = x^2 is neither injective nor surjective. What if we restrict the domain to [0,)[0, \infty) and the codomain to [0,)[0, \infty)?
  • Use the widget to build an injective-but-not-surjective function from {1,2}{1, 2} to {a,b,c}{a, b, c}.
  • Prove: if ff and gg are both injective, then gfg \circ f is injective.
  • Find a function f:NNf: \mathbb{N} \to \mathbb{N} that is surjective but not injective.

A trap to watch for

To disprove injectivity you need two distinct inputs giving the same output — not just one repeated output. Writing "g(2)=4g(2) = 4 shows g(x)=x2g(x) = x^2 is not injective" is incomplete; you need the second witness, e.g. "g(2)=4g(-2) = 4 as well, and 222 \neq -2." Similarly for surjectivity: producing one preimage doesn’t prove a function is onto — you need to argue that every codomain element has a preimage.

What you now know

You can prove or disprove injectivity by the assume-equal-and-conclude-equal pattern, prove or disprove surjectivity by constructing or blocking preimages, and recognise bijections as the formal version of "same cardinality." Section 5.3 puts these properties to work: a function is invertible iff it is bijective.

Code ChallengeInteractive figure — enable JavaScript to interact.

References

  • Velleman, D. J. (2019). How to Prove It (3rd ed.). Cambridge University Press, §5.2.
  • Hammack, R. (2018). Book of Proof, ch. 12.
  • Halmos, P. R. (1960). Naive Set Theory. Springer, §8-9.
  • Cantor, G. (1891). "Ueber eine elementare Frage der Mannigfaltigkeitslehre." Jahresbericht der DMV 1, 75-78 (the diagonal argument).
  • Katz, J., Lindell, Y. (2014). Introduction to Modern Cryptography (2nd ed.). CRC Press, ch. 6 (hash functions and collision resistance).

This page is prerendered for SEO and accessibility. The interactive widgets above hydrate on JavaScript load.