Foundations of mathematics
Functions and cardinality
A function is injective if it never sends two different elements to the same place, surjective if every element of is hit, and bijective if both hold. Bijections let us compare the sizes of infinite sets: , since all three admit an explicit bijection with . Cantor's theorem, , proved by a diagonal argument using , shows the power set is always strictly bigger, so there is an endless hierarchy of infinities; the Cantor–Bernstein–Schröder theorem shows và , letting cardinality be compared with two easy one-directional injections instead of one hard bijection. These ideas underlie hash collisions, the limits of data compression, and the uncomputability of certain problems.
IntuitionMatching two piles, and which pile is bigger
A function assigns to every element of exactly one element of . Picture it as arrows from to : injective means no two arrows land on the same point of , surjective means every point of is hit by some arrow, and bijective means both at once, a perfect one-to-one matching. When and are infinite, a bijection is exactly how we say they have the same size, the same cardinality, even though counting one by one is impossible.
UndergraduateInjective, surjective, bijective: formal definitions
Definition: Injective, surjective, bijective
A function is injective if distinct elements of always map to distinct elements of . It is surjective if every element of is the image of some element of . It is bijective if both hold, in which case it has a well-defined inverse .
This is the formal test for injectivity: whenever two inputs give the same output, they must already have been the same input. Surjectivity is tested the other way, requiring every target to be reachable.
| Property | Example | Injective? | Surjective? |
|---|---|---|---|
| Bijective | Yes | Yes | |
| Injective only | Yes | No | |
| Surjective only | No | Yes | |
| Neither | No | No |
UndergraduateTwo key theorems, with full proofs
For every set , : there is no surjection from onto its power set , so the power set is strictly larger.
Why is it true?
This shows there is no single "biggest infinity" — from any set, however large, you can always build a strictly larger one just by taking its power set. It is the theorem that makes an infinite hierarchy of infinities unavoidable, and its diagonal-argument proof technique is the direct ancestor of the arguments used to show some problems are uncomputable.
Proof
Suppose, for contradiction, that there is a surjection ; we will derive a contradiction, which shows no such surjection can exist.
Define the "diagonal" set : it collects every element of that is not a member of its own image under . Since is a subset of , it is an element of .
Because is assumed surjective, there must be some with . Now ask the deciding question: is ?
If , then by the definition of , ; but , so this says — a contradiction. If instead , then by the definition of (which excludes exactly the elements with ), this forces — again a contradiction.
Either way we reach a contradiction, so no surjection can exist. Combined with the injection from into , this gives exactly .
If và , meaning there is an injection and an injection , then there is a bijection between and .
Why is it true?
Comparing cardinalities via injections only (each set fits inside the other) already forces the sets to have exactly the same size, just as with finite sets. This lets us prove by building two easy one-directional embeddings instead of one hard direct bijection — this is exactly how the examples below show intervals like and have the same cardinality.
Proof
Let and be the two given injections. The idea is to trace, for each element, the chain of ancestors obtained by repeatedly undoing and , and to build the final bijection piece by piece depending on where each chain "starts".
For , define its backward chain , continuing as long as the needed inverse is defined, and symmetrically for . Every element's chain either goes back forever, or stops at an element of with no -preimage, or stops at an element of with no -preimage. This partitions into three parts (chain stops in ), (chain stops in ), (chain never stops), and likewise partitions into .
On chains that stop in or never stop, itself already gives a bijection from that part of onto the corresponding part of (since these elements were reached by injections and nothing "runs out" on the side first). On chains that stop in , it is that gives a bijection from the corresponding part of back onto that part of , so its inverse gives a bijection from that part of onto that part of .
Define by if , and if . Since the three pieces are disjoint and each piece maps bijectively onto its matching piece of ( onto , onto ), the combined map is a bijection from all of onto all of , proving .
UndergraduateReal-World Applications and Worked Examples
Cardinality is not just abstract bookkeeping. Hash functions map a huge domain (all possible files, all possible passwords) into a much smaller codomain (a 32-bit or 64-bit integer); since the domain is strictly larger than the codomain, Cantor's pigeonhole-style reasoning guarantees collisions must exist, no matter how clever the hash function is. Lossless data compression is exactly an injective map from longer bit-strings to shorter ones; since there are strictly fewer short strings than long ones, no compressor can shrink every possible input — some inputs must grow or stay the same size. Uncomputability results (such as the undecidability of the halting problem) use the same diagonal argument as Cantor's theorem: there are uncountably many possible functions but only countably many computer programs, so almost every function is simply not computable by any program.
Example: A concrete bijection between and
Define by if and if . Show that is a bijection, and use it to conclude . What is ?
Solution
This sends non-negative integers to even naturals and negative integers to odd naturals, zig-zagging outward: , , , ,
Injectivity: even outputs come only from (where determines uniquely) and odd outputs come only from (where determines uniquely), and within each case is strictly monotonic, so no two distinct integers share an output.
Surjectivity: every even natural () is , and every odd natural () is , so every natural number is hit.
Since is a bijection , and have the same cardinality, , confirming — despite looking twice as large.
Finally, : since , use , so .
Example: Pigeonhole reasoning for hash collisions
A hash function maps arbitrary files to a -bit code, so there are exactly possible codes. A company stores billion distinct files (). Explain, using cardinality/pigeonhole reasoning, why at least two files are guaranteed to share the same hash code, and estimate how many "collision pairs" are unavoidable at minimum.
Solution
The codomain of the hash function has exactly elements — call this set . The domain of files being hashed, , has elements, and since .
By the (finite) pigeonhole principle — the finite counterpart of "no injection can exist from a larger finite set into a smaller one" — the hash function, viewed as a map , cannot possibly be injective: if it were injective it would give , contradicting . So at least two distinct files must be assigned the same hash code.
To estimate how many collisions are unavoidable at minimum: distributing files as evenly as possible over buckets puts at least files in some bucket, and the number of "excess" files that must double up is at least .
So at least about million files are forced into buckets already used by another file — a direct, unavoidable consequence of , regardless of how well-designed the hash function is.
Which property must have so that distinct elements of always map to distinct elements of ?
If , what does Cantor's theorem say is?
A 16-bit hash function has possible outputs. If a system hashes distinct files, what does the pigeonhole/cardinality argument guarantee?
What do the hypotheses of the Cantor–Bernstein–Schröder theorem require?
References
- Paul R. Halmos (1960). Naive Set Theory
- Karel Hrbacek, Thomas Jech (1999). Introduction to Set Theory