Pigeonhole Principle
Introduction
The pigeonhole principle is one of the simplest yet most powerful tools in combinatorics. Its statement is almost trivial: if you have more pigeons than pigeonholes and each pigeon must go into a hole, then at least one hole contains more than one pigeon. Yet this elementary observation leads to surprisingly deep results across mathematics.
The principle, also known as Dirichlet's box principle, was formalized by Peter Gustav Lejeune Dirichlet in . It provides existence proofs—showing that certain configurations must exist—without constructing them explicitly. This makes it invaluable when direct construction is difficult or impossible.
Applications range from number theory and combinatorics to computer science and everyday reasoning. The principle appears in proofs about rational approximations, graph coloring, data compression, and countless other areas.
Statement of the Principle
Simple Form
If or more objects are placed into boxes, then at least one box contains two or more objects.
If , then no injection exists.
Equivalently: if and , then is not injective (one-to-one), meaning some element of is hit by at least two elements of .
Generalized Form
If objects are placed into boxes, then at least one box contains at least objects.
At least on box has objects.
This follows from the simple form: if every box had fewer than objects, the total would be at most
, a contradiction.
Strong Form
If objects are placed into boxes, then either box contains at least objects, or box contains at least objects, , or box contains at least objects.
The simple form is the special case where all .
Basic Examples
Example 1: Birthdays
In any group of people, at least two share a birthday (ignoring leap years). Here the pigeons are people () and the holes are days of the year ().
More strongly: in a group of people, the probability that two share a birthday exceeds %. This is the famous birthday paradox.
Example 2: Hair Count
The average human head has about hairs, and no one has more than . In a city of million people, at least two people have exactly the same number of hairs on their head.
Pigeons: , people. Holes: possible hair counts ( to ). Since > , at least two people share a hair count.
Example 3: Socks in the Dark
A drawer contains red and blue socks. What is the minimum number of socks you must draw (without looking) to guarantee a matching pair?
Answer: socks. With colors and socks, at least two must be the same color. By the pigeonhole principle with holes and objects, socks must share a color.
Applications in Number Theory
Divisibility Result
Among any integers, at least two have the same remainder when divided by .
There are only possible remainders: . With integers and remainders, two integers must share a remainder, so their difference is divisible by .
Subsequence Sum Divisibility
Given any integers, some nonempty subset has a sum divisible by .
Consider the partial sums .
These sums have remainders modulo from the set .
If any has remainder , we are done. Otherwise, by pigeonhole, two partial sums and (with ) have the same remainder. Then is divisible by .
Dirichlet's Approximation Theorem
For any real number and positive integer , there exist integers and with such that:
The proof uses the pigeonhole principle on the fractional parts of
. These numbers lie in , which we divide into intervals of length . Two must fall in the same interval.
Applications in Combinatorics
Monotone Subsequences
Any sequence of distinct real numbers contains either an increasing subsequence of length or a decreasing subsequence of length .
Label each element with the length of the longest increasing subsequence starting from it. If all labels are at most , there are only possible labels for elements. By pigeonhole, at least elements share the same label.
If these elements with the same label form an increasing subsequence, we get a contradiction. So they must form a decreasing subsequence of length .
Ramsey-Type Results
In any -coloring of the edges of (complete graph on vertices), there exists a monochromatic triangle.
Consider any vertex . It has edges, colored red or blue. By pigeonhole, at least edges have the same color, say red. Let these connect to vertices .
If any edge among is red, we have a red triangle. If all edges among are blue, we have a blue triangle. Either way, a monochromatic triangle exists.
Applications in Computer Science
Hash Collisions
If a hash function maps items to buckets where , at least one bucket must contain multiple items (a collision). This is why hash tables must handle collisions.
Data Compression Limits
No lossless compression algorithm can compress all files of length bits. There are possible inputs but only possible outputs shorter than bits. By pigeonhole, two inputs must map to the same output, making decompression ambiguous.
Load Balancing
If tasks are distributed among servers, at least one server handles at least
tasks. This lower bound on maximum load is unavoidable regardless of the distribution strategy.
The Probabilistic Pigeonhole
The principle has a probabilistic analog: if items are randomly placed into boxes, the expected number of items in a box is . By linearity of expectation, at least one box must have at least the average items.
This connects to the probabilistic method in combinatorics, which uses expected value arguments to prove existence results.
Connection to Other Concepts
The pigeonhole principle is a special case of cardinality arguments about finite sets. It formalizes the intuition that injections can only exist between sets of appropriate sizes.
In combinatorics, it underlies Ramsey theory, which studies conditions guaranteeing the existence of order in large structures. The friendship theorem and the Happy Ending Problem are examples.
In number theory, it provides approximation theorems (Dirichlet) and results about quadratic residues. In analysis, it appears in proofs about measure and cardinality.
In computer science, it explains fundamental limits on hashing, compression, and resource allocation. It also underlies the birthday attack in cryptography.
Summary
The pigeonhole principle states that if objects are placed into boxes, at least one box contains at least two objects. More generally, objects in boxes means some box has at least objects.
Though simple, the principle has far-reaching applications. In number theory, it proves results about remainders, rational approximations (Dirichlet), and divisibility. In combinatorics, it establishes the existence of monotone subsequences and monochromatic subgraphs.
In computer science, it explains hash collisions, compression limits, and load balancing lower bounds. The principle provides existence proofs without explicit construction.
The power of the pigeonhole principle lies not in its statement but in identifying the right pigeons and holes for a given problem. Finding clever applications requires insight into the structure of the problem at hand.
The principle extends to infinite sets via cardinality comparisons. If there is no injection from to , then . Cantor's diagonal argument, which proves the uncountability of the reals, is a sophisticated application of this idea.
Many competition mathematics problems rely on the pigeonhole principle. The key challenge is always the same: identify what the pigeons are, what the pigeonholes are, and why the count guarantees the desired conclusion.
Despite its elementary nature, the pigeonhole principle remains indispensable in modern mathematics and computer science. It reminds us that sometimes the simplest observations lead to the most profound results.