The Pigeonhole Principle
Take 13 people at a party. Must two of them share a birth month? This is a concrete instance of a deceptively simple idea. If you distribute enough objects into few enough containers, some container must receive more than one object. The Pigeonhole Principle turns this everyday observation into a precise combinatorial tool. Its power lies in the gap between how obvious it sounds and how sharp its conclusions are. The principle matters because it proves existence without constructing anything. It never tells you which pigeonhole is crowded, only that one must be. This non-constructive flavor makes it indispensable across combinatorics, number theory, analysis, and computer science. Whenever a counting mismatch between a domain and codomain is unavoidable, the pigeonhole principle converts that mismatch into a guaranteed collision, coincidence, or repetition. The big picture is that the principle is really a statement about Functions between finite sets. A function with cannot be injective. Some two inputs must share an output. Once you see it this way, applications multiply. Sequences must repeat a residue mod . Subsets must share a sum. Points must fall close together in a partitioned region. The principle is a single sentence, but its instantiations range widely. They span from a two-line party trick to deep results like Dirichlet's approximation theorem. This article gives the precise statement of both the basic and generalized pigeonhole principle. It includes a complete proof from first principles using the Sum and Product Rules. It also offers two fully worked non-trivial examples. It takes a careful look at what happens when hypotheses are dropped. Finally, it surveys where the idea resurfaces in mathematics and computing.
- The Pigeonhole Principle says objects in boxes with forces some box to hold objects.
- The generalized version: objects in boxes forces some box to hold objects.
- It is equivalent to the statement that a function from a larger finite set to a smaller one cannot be injective.
- The proof is by contrapositive/contradiction and uses only the Sum Rule for counting.
- It is a purely existential tool: it never identifies which box or which objects collide.
- Key idea: counting a mismatch between set sizes is enough to force a collision, with no further information needed.
Where this lives today
In number theory, the pigeonhole principle underlies Dirichlet's approximation theorem: for any irrational and any , there exist integers with and , proved by partitioning into subintervals and pigeonholing the fractional parts for . In computer science, hash table collision analysis, the impossibility of perfect lossless compression for all inputs, and lower bounds in data structures all rest on pigeonhole counting: if a hash function maps more keys than table slots, collisions are unavoidable, and no compression algorithm can shrink every possible input string without some inputs growing, since there are strictly more short strings than shorter ones. In cryptography, the principle bounds the security of hash functions against collision resistance: any hash function with output space of size must have a collision among any distinct inputs, motivating the birthday-attack style analysis of hash collision probabilities. In combinatorics and graph theory, it is the seed of Ramsey theory: in any graph on vertices, pigeonhole-style degree-counting forces a monochromatic triangle in any red/blue edge coloring, the simplest nontrivial Ramsey number . In analysis and probability, discretizing continuous ranges into finitely many bins and pigeonholing sample points into them is a recurring technique for proving existence of clusters, recurrence, or bounded gaps (e.g., in ergodic theory and the study of equidistribution).
Ask the tutor: How do I choose the right "boxes" when the pigeonhole setup isn't obvious from the problem statement?
Let and be finite sets with a function assigning each element of (the "objects" or "pigeons") to an element of (the "boxes" or "pigeonholes").
Basic form. If , then is not injective: there exist distinct with and .
Generalized form. If and with , then there exists such that
That is, some box contains at least objects. The basic form is the special case , , since .
Intuition
Picture labeled boxes drawn as bins on a number line, and pigeons that must each land in exactly one bin. If you have strictly more pigeons than bins, the "average occupancy" per bin exceeds , and since occupancy counts are whole numbers, some bin must round that average up rather than down. This is the entire mechanism: averages of integers that are not themselves integers force some term above the average. The generalized principle sharpens this averaging idea. If pigeons fill boxes, the average number of pigeons per box is . It is impossible for every box to hold strictly fewer than objects on average without violating the total count — so some box must reach at least . The ceiling appears precisely because box occupancy must be an integer, and need not be.
Central theorem
Let be positive integers, let be a finite set with , let be a finite set with , and let be any function. Then there exists such that
In particular (taking ), if then is not injective.
We argue by contradiction, a standard technique for existence statements phrased as "there exists an object with property ."
Setup. Write , and for each let
Since is a function with domain , every has exactly one value , so belongs to exactly one (namely with ). Hence the sets are pairwise disjoint and their union is all of : they form a partition of .
Applying the Sum Rule. By the Sum and Product Rules (specifically the Sum Rule for a partition into disjoint blocks), the size of a finite set equals the sum of the sizes of the blocks in any partition of it:
This is not an assumption; it follows because each element of is counted in exactly one , so summing over counts every element of exactly once, giving the total .
Suppose for contradiction that the conclusion fails: suppose that for every ,
Since is an integer and is by definition the least integer , the integer is the greatest integer strictly less than , hence
is false in general — instead we must be careful and argue directly with the defining property of the ceiling function: is an integer strictly less than , and by minimality of the ceiling, any integer strictly less than is strictly less than or equal to it only if is not an integer strictly between them — to avoid this delicacy we instead bound directly: Since is the smallest integer greater than or equal to , the integer is strictly less than whenever is not an integer, and equals whenever is an integer. In both cases,
(This is exactly the characterizing inequality of the ceiling: for all real , applied to .) Therefore, under our contradiction hypothesis, for every ,
Summing over all boxes:
This gives , a contradiction.
Conclusion. The assumption that every is false. Hence some has , i.e., there exists with , as claimed.
Basic form as a corollary. If , then since for (equality only when , and otherwise lies strictly between and ; either way the ceiling is ). So some has , meaning at least two distinct elements of map to the same , i.e., with — precisely the failure of injectivity. This completes the proof for both forms.
∎If is injective, then . Equivalently, an injective function from a finite set into a finite set cannot increase cardinality.
This is the logical contrapositive of the basic form: the basic form states " not injective," whose contrapositive is " injective ." Contraposition is a valid inference rule (a statement and its contrapositive are logically equivalent), so no new proof is required beyond the theorem above.
∎Worked examples
Example 1 (Non-uniform box sizes forcing a specific count). A librarian has books to shelve into labeled bins by Dewey category. Show that some bin receives at least books, and exhibit that is the best bound the principle can guarantee (i.e., it is achievable that no bin receives more than ). Solution. Here , . Compute
By the Generalized Pigeonhole Principle, some bin holds at least books. To see this bound is tight, exhibit a distribution matching it: put books in one bin and in each of the other bins:
This uses exactly books, no bin exceeds , and one bin (in fact several) attains exactly . So the guaranteed bound cannot be improved to in general — the theorem's conclusion is sharp. (Note the theorem never claims every bin reaches ; it only asserts some bin does, and here the extremal example shows the guarantee cannot be strengthened.)
Example 2 (A number-theoretic collision via injectivity failure, asymmetric inputs). Show that among any distinct integers chosen from , two of them sum to . Solution. Partition into unordered pairs each summing to :
These pairs are pairwise disjoint and their union is — a genuine partition into blocks. Define on the chosen set of integers by letting be the pair (block) containing ; formally where is the set of pairs and is the unique pair containing . Since , the Pigeonhole Principle (basic form) guarantees is not injective: two distinct chosen integers land in the same pair, i.e. . But each pair has only two elements, and if both lie in the same pair, they must be exactly the two elements of that pair (a set of size 2 cannot contain three distinct elements and also the pair's own two members unless are those two members). Hence for some , so . To confirm sharpness: choosing only integers, e.g. , avoids any pair summing to (since each contribute at most one element from ). This shows is the minimal number of integers that forces the conclusion — the bound in the problem is exactly the pigeonhole threshold .
The theorem requires to be finite. If is infinite, the conclusion can fail entirely, even with much larger than any finite "slice" of you might compare it to. Take (so ) and (the positive integers, an infinite set). Define by , the identity inclusion. This map is injective: trivially. There is no collision anywhere, despite having elements — because is not a finite number to compare against, the hypothesis "" is not even meaningful (there is no finite ), and the entire mechanism of the proof collapses: the Sum Rule argument required summing over finitely many boxes , and with infinite there is no such finite sum to bound. This shows finiteness of the codomain (or at least finiteness of the number of boxes being counted) is not a technical nicety — it is load-bearing. The principle is a statement about finite partitions, and infinite pigeonholes simply have room for everyone.
Scope, edge cases & common traps
| Situation | What holds | What fails / caution |
|---|---|---|
| No collision is forced; an injection may or may not exist | Do not assume a collision — check first | |
| , both finite | Collision guaranteed (basic form) | Principle gives existence, not which pigeons collide |
| Arbitrary finite | Some box has (generalized form) | , not rounded incorrectly — always take the ceiling, never floor |
| infinite | Principle does not apply | See counterexample above |
| Boxes defined by a partition not literally "boxes" | Still valid — any partition of into disjoint blocks works | Must verify the blocks are disjoint and cover (a genuine partition) |
| Multiple valid partitions of the same problem | Different partitions can give different (both correct) bounds | Choosing a coarser partition (fewer ) gives a weaker, still valid, bound; look for the finest useful partition |
The mathematician behind it
Origins · 1 minPeter Gustav Lejeune Dirichlet and how this was discovered
Dirichlet is credited with the first systematic use of the pigeonhole principle in serious mathematics, applying it in number theory — for instance in his proof related to rational approximation of irrational numbers, now known as Dirichlet's approximation theorem. The principle is still sometimes called the Dirichletscher Schubfachschluss ("Dirichlet's drawer/box principle") in German mathematical tradition, reflecting his central role in elevating an intuitive observation into a rigorous proof technique used throughout number theory.
Does the pigeonhole principle tell us which box has multiple items?
No. The principle is purely existential: it guarantees some box must be overcrowded but gives no information about which box or which specific objects collide. The proof works by contradiction — assuming no box is crowded leads to a numerical contradiction — so it never constructs the colliding pair explicitly. In applications, you often need a separate, sometimes clever, argument or search to actually locate the collision, even though its existence is already certain. This non-constructive character is common to many existence proofs in combinatorics and is not a weakness of the technique, but a defining feature of what it can and cannot claim.
Is the pigeonhole principle the same as saying implies no bijection exists?
Closely related but not identical in emphasis. If , then indeed no bijection can exist (bijections require equal cardinalities for finite sets), but the pigeonhole principle says something stronger and more specific: any function at all, injective or not, must have a repeated value somewhere. It is really a statement about the impossibility of injections in this cardinality regime, phrased in terms of forced collisions rather than merely the absence of a perfect one-to-one correspondence.
How is the ceiling function justified rather than rounding normally?
The ceiling arises because box occupancy counts are non-negative integers, and the proof shows that assuming every box holds fewer than objects leads to a total strictly less than , a contradiction. The threshold "fewer than " translates precisely to "at most " for integers, by the defining property . Ordinary rounding (to nearest) would not give a valid guaranteed lower bound; only the ceiling correctly captures "smallest integer not below the average."
Can the pigeonhole principle be applied to infinite sets at all?
The classical finite-box version, as stated here, strictly requires both and finite; the counterexample block shows the argument breaks completely when is infinite. However, there are genuinely infinite analogues, such as: if is infinite and partitioned into finitely many blocks, some block must be infinite (this follows from finite additivity failing for an all-finite partition of an infinite set). That is a different, though related, statement, and should not be confused with the finite generalized principle proved here.
What is the difference between the "basic" and "generalized" pigeonhole principle?
The basic form only concludes that some box has at least objects, applicable whenever . The generalized form gives a quantitative lower bound, , on the most-crowded box's occupancy for any and , not just . The basic form is literally the special case of the generalized one when , since . Most real applications, such as bounding shared birth months among large groups or forcing repeated remainders, use the generalized form to extract a specific numeric guarantee rather than just "a repeat exists."
Does choosing a different partition change the strength of the conclusion?
Yes, significantly. The pigeonhole principle's power depends entirely on how cleverly you choose the boxes (the partition of the codomain or an auxiliary set). A coarser partition (fewer, larger boxes) gives a weaker but still valid bound; a finer, well-chosen partition can extract a much sharper and more useful conclusion, as seen in Example 2 where pairing was the crucial creative step. Much of the skill in applying this principle lies in designing the right boxes, not in the mechanical final step.
Where does the name "pigeonhole" come from?
The name references old writing-desk furniture with a grid of small open compartments, called "pigeonholes," originally used to sort mail or documents (and named by analogy to compartments in a dovecote used for pigeons). The mathematical metaphor imagines "pigeons" (objects) being placed into these "holes" (categories or boxes), so that too many pigeons and too few holes forces at least one hole to contain more than one pigeon. In German mathematical literature the same idea appears as the "Schubfachprinzip" (drawer principle), associated historically with Dirichlet's early rigorous use of the argument.