One-to-One and Onto
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 and ; 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 is injective if distinct inputs give distinct outputs:
(Contrapositive: .) To prove injectivity, assume and derive . To disprove it, exhibit two distinct inputs with the same output.
Surjective (onto)
A function is surjective if every codomain element is hit:
Equivalently, . To prove surjectivity, take an arbitrary and produce an with . To disprove it, find a single with no preimage.
Bijective
A function is bijective if it is both injective and surjective. Bijections pair the elements of perfectly with the elements of — this is the precise meaning of " and have the same cardinality."
Pause and think: . Is it injective? Surjective? If you change the codomain to "even integers," does surjectivity status change?
Try it
- Predict, then prove: is bijective.
- Show by counterexample that is neither injective nor surjective. What if we restrict the domain to and the codomain to ?
- Use the widget to build an injective-but-not-surjective function from to .
- Prove: if and are both injective, then is injective.
- Find a function 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 " shows is not injective" is incomplete; you need the second witness, e.g. " as well, and ." 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.
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).