TL;DR
A bijective function is a Function that is both injective and surjective. Different inputs always give different outputs, and every element of the target set is reached by some input. Because of this, the function pairs the two sets off perfectly, with nothing left over on either side, and it can be reversed without losing or inventing anything.
Builds on: Injective Function, Surjective Function · Leads to: Graph Isomorphism, composing bijections
Where it's used
Seats and tickets. A cinema with 120 seats sells 120 tickets, and each ticket names one seat. If each seat is taken by exactly one ticket holder, the rule "ticket to seat" is bijective. Nobody shares a seat, and no seat is empty when the house is full. Each ticket and each seat can be matched with exactly one partner, and that matching is what the word "bijection" describes.
Encryption. A block cipher such as AES encrypts 128-bit blocks. For a fixed key, the encryption rule is a bijection on the set of 128-bit blocks. It must be: if two different blocks encrypted to the same output, decryption could not tell which one was meant. Decryption is the inverse bijection, and it returns the original block exactly.
Comparing graphs. Two drawings of a network may look different but have the same shape. They are isomorphic when there is a bijection between the nodes of one and the nodes of the other that keeps every connection. The Graph Isomorphism problem asks whether such a bijection exists. A bijection that maps nodes to nodes and edges to edges is the proof that two graphs are the same structure in different clothes.
How it works
Take two small sets: and . Let send the inputs as follows: , and .
- Write the outputs down. They are , and . Each input has exactly one output, so is a Function from to .
- Check that the outputs are all different. , and are three distinct elements. So no two inputs share an output, and is injective. Check: the output can only have come from .
- Check that every element of appears. , and all appear in the list of outputs. So is surjective. Check: no element of is left out.
- Both checks pass, so is bijective. Each element of is paired with exactly one element of , and the pairs use up both sets completely.
- Read the pairs backwards to get the inverse. From we go back to , from back to , and from back to . Check: applying the backward rule and then returns the start, for example and going back from gives again.
Here is the same pairing as a diagram. Each input has exactly one arrow leaving it, and each output has exactly one arrow arriving.
flowchart LR i1[1] --> oy[y] i2[2] --> oz[z] i3[3] --> ox[x]
Now change the target set to , with the same rule. The rule is still injective, since the outputs are still different, but it fails step 3: is never an output. So the function is not bijective. Some element of the target has no partner, so the pairing is incomplete. A bijection needs both checks to pass.
The picture version of the same idea uses a graph. For on the real numbers, every horizontal line hits the curve exactly once. A horizontal line that meets the graph once for every height is the picture of injective and surjective at once.
- f(x) = x³
The math
The arrow reads "maps to". A Function is bijective when both of the following hold.
A function is bijective, or a bijection, if it is injective and surjective:
Here and are inputs, is an output, and means "then". The first line says that different inputs never share an output. The second says that every element of is reached. Together they say that pairs each element of with exactly one element of , and each element of with exactly one element of . Formally, is the set of pairs for in , a subset of the Cartesian product .
An equivalent statement is that has an inverse: a function such that for every in , and for every in . Reading the pairs backwards gives . The inverse is written .
Step 2 in symbols
For the rule above, , and . The three outputs are distinct:
So the injective condition holds.
Step 3 in symbols
For each element of we need an input. The three elements of are matched as follows:
Every element of is hit, so the surjective condition holds.
Step 5 in symbols
The inverse is , and . Check one of them: . Going forwards and then backwards gives back the start, as the definition of an inverse requires.
A counting fact
If is a bijection and both sets are finite, then and have the same number of elements. Injectivity alone forces , because each input needs its own output. Surjectivity alone forces , because each output needs its own input. Both together give equality. This is why a bijection is the right tool for saying that two sets have the same size.
Worked examples
Let , and , , .
- List the outputs: , , . Three different outputs, so is injective.
- The outputs cover , and , so is surjective.
- Both checks pass, so is bijective.
- The inverse reads the pairs backwards: , , .
Interpretation: a bijection between two three-element sets is a relabelling. Each element of is simply given a new name from , and nothing is lost in the renaming.
Let from the real numbers to the real numbers. We show that is bijective.
- Injective: suppose . Then . Subtract to get , then divide by to get . So is injective.
- Surjective: take any real number , and set . Then . So every real is an output.
- Both checks pass, so is bijective.
- The inverse is , which is the formula we used in step 2.
Interpretation: a straight line with a non-zero slope is a bijection of the real numbers onto themselves, and the inverse is found by solving the equation for .
A theatre has 120 seats and sells one ticket for each seat, numbered 1 to 120. The rule "ticket to seat" is a bijection: each ticket names one seat, every seat is someone's, and nothing is left over.
- Now a seat is damaged and closed. There are 119 usable seats, but 120 tickets still exist.
- Try to give every ticket its own seat. The first 119 tickets can each take one usable seat. Ticket number 120 has nowhere to go, so the rule is not surjective onto the seats, or it sends two tickets to one seat. Either way it is not a bijection.
- The counting fact from the math section gives the same answer directly. A bijection between a set of 120 and a set of 119 cannot exist, because the two sizes differ.
- The theatre must either sell 119 tickets or reopen the broken seat.
Try it: the theatre reopens the seat, so there are 120 usable seats again. A usher assigns ticket to seat . Is this a bijection? Answer: yes. The rule is injective, since different tickets go to different seats. It is surjective, since every seat from 1 to 120 is reached by the ticket for some in 1 to 120. It is also a bijection with inverse .
Common mistakes and tradeoffs
"One-to-one" means bijective. It is tempting to read "one-to-one" as the whole story. In fact many texts use "one-to-one" for injective alone, and "onto" for surjective alone. Bijective is the stronger word: it needs both. The map from the whole numbers to the whole numbers is one-to-one, but it never produces , so it is not onto and not a bijection.
Equal size of input and output sets is enough. It is tempting to think that a function between two sets of the same size must be bijective. In fact, equal size only makes a bijection possible between finite sets. It does not force one, so the function must still be checked. Take and with , and . Both sets have three elements, but is never reached and is reached twice. The equal count only tells you a bijection is possible, not that this rule is one.
The domain matters. It is tempting to ask whether is bijective, as if the formula decided it. In fact it depends on the sets. from the real numbers to the real numbers is neither injective nor surjective, since and share the output and negative numbers are never outputs. But from the non-negative real numbers to the non-negative real numbers is bijective: the inverse is the square root. Always state the domain and the codomain.
When to use it. Use a bijection when you need an exact pairing with nothing lost and nothing left over: a relabelling, a reversible encoding, or a proof that two sets have the same size. When only one of the two properties matters, use injective (no collisions, for example in identifiers) or surjective (full coverage, for example in a list of possible labels). You need a bijection specifically when you want an inverse that works in both directions.
History
The idea of matching two sets element by element is very old. What changed in the 1870s was its use for infinite sets. Georg Cantor asked whether the set of all whole numbers and the set of all rational numbers had the same size, and he found that a pairing between them existed, so they did. He then went further and showed that some infinite sets cannot be paired with the whole numbers at all. A pairing that uses up both sets completely was the test he trusted.
The names "injection", "surjection" and "bijection" were introduced by the Bourbaki group of French mathematicians in the 1930s and 1940s, as part of their effort to rewrite mathematics in terms of sets and functions. Naming the three cases made it easy to state each property on its own. The vocabulary caught on because it applies to any sets at all.
Recap
- A Function gives each input exactly one output.
- Injective means no two inputs share an output. Surjective means every element of the target is an output.
- Bijective means both, so the function pairs the two sets exactly, with nothing left over.
- A bijection has an inverse, and between finite sets it forces the two sets to have the same size.
- Bijectivity depends on the domain and codomain as well as the formula.
Next, read about Graph Isomorphism, where a bijection between nodes that preserves connections defines when two graphs are the same shape. For chaining bijections together, see Function Composition. The composition of two bijections is again a bijection.
Check yourself
QuestionLet with , and . Is bijective?Show answer
No. The outputs are , and . The element is never an output, so is not surjective. Also, inputs and share the output , so is not injective either. A bijection needs both properties, and this rule has neither.
QuestionFor on the real numbers, find and check that for .Show answer
Set and solve for : add to get , then divide by to get . So . For , . Check: . The inverse returns the original input.
QuestionWhy does a bijection between two finite sets force them to have the same number of elements?Show answer
Injectivity means each input uses its own output, so the input set is no larger than the output set. Surjectivity means each output has at least one input, so the output set is no larger than the input set. Both inequalities together give equality.
QuestionA school gives every student a locker number, and every locker belongs to exactly one student. A new student arrives, but there are no spare lockers. Explain in terms of bijection why the school cannot give the new student a locker without changing something.Show answer
The current rule "student to locker" is a bijection between the students and the lockers. Adding a student makes the set of students larger than the set of lockers. No function can be injective from a larger set into a smaller one, since two students would have to share a locker. So the rule stops being a bijection, and the school must either add a locker or accept that the pairing is no longer one-to-one.