Combinatorics and discrete mathematics
The pigeonhole principle
If more objects are placed into boxes than there are boxes, some box must contain more than one.
IntuitionWhy must two pigeons share a hole?
Suppose you have pigeons and only pigeonholes, and every pigeon must fly into some hole. No matter how cleverly the pigeons are placed, at least one hole ends up with two or more pigeons in it — there simply are not enough holes for everyone to get their own. This obvious-sounding fact is called the pigeonhole principle, and despite its simplicity it proves surprisingly deep results across number theory, geometry and computer science.
SchoolStating the principle precisely
Definition: Pigeonhole principle
If objects are placed into boxes and , then at least one box contains at least objects. More generally, if objects are placed into boxes, some box contains at least objects.
The number (" rounded up") is the smallest integer that is at least ; it is the guaranteed minimum load of the fullest box when objects are spread as evenly as possible over boxes. For example, splitting objects over boxes as evenly as possible gives loads , and indeed .
| Objects / boxes | Guaranteed minimum in the fullest box |
|---|---|
| arbitrary |
UndergraduateTwo theorems: the basic and the generalized principle
If objects are distributed into boxes with , then at least one box contains at least objects.
Why is it true?
This is really a statement about counting, proved by assuming the opposite and reaching a contradiction: if every box had at most object, the boxes could not hold more than objects in total.
Proof
Assume, for contradiction, that the conclusion fails: every one of the boxes contains at most object.
Then the total number of objects distributed is at most .
But we distributed objects, and by hypothesis, so the total number of objects distributed is .
These two counts of the same set of objects contradict each other ( but also total ), so the assumption was false: some box must contain at least objects.
If objects are distributed into boxes, then some box contains at least objects.
Why is it true?
The basic principle only guarantees objects somewhere; the generalized version sharpens this to the exact minimum forced by averaging objects over boxes, using the same contradiction idea but comparing against instead of .
Proof
Assume, for contradiction, that every box contains at most objects.
Then the total number of objects distributed is at most .
Since is the smallest integer at least , we have , so .
So the total distributed is strictly less than , contradicting that all objects were distributed. Hence some box contains at least objects.
UndergraduateReal-world applications and worked examples
Despite its simplicity, the pigeonhole principle is a standard tool in computer science (proving that a hash table with more keys than slots must have a collision), in number theory (proving that some multiple of a given integer has a specific digit pattern), and in everyday combinatorics puzzles about scheduling, sorting and social networks.
Example: Socks in a drawer
A drawer contains socks of colors, with plenty of each color but mixed together in the dark. What is the smallest number of socks you must pull out to be certain of having a matching pair?
Solution
Think of the colors as boxes, and each sock you pull out as an object dropped into the box matching its color. A "matching pair" means some box receives at least objects.
By the basic pigeonhole principle, once you pull socks with , i.e. , some color box must contain at least socks — a matching pair is guaranteed.
Is actually the smallest such number? With only socks it is possible (though unlucky) to have pulled exactly one of each of the colors, with no pair yet. So socks do not guarantee a pair, but do.
The answer is socks.
Example: Two people at a party with the same number of friends
At a party of people, "friendship" is mutual and no one is a friend of themselves. Show that there must be two people at the party who have exactly the same number of friends present.
Solution
Each person's number of friends at the party is an integer between and (you cannot have more friends than the other people present), giving possible values and people — pigeonholing the friend-counts directly would only give boxes for people, not yet a forced collision.
The key extra observation is that the values and cannot both occur: if someone has friends, no one can have friends (which would mean being friends with everyone, including that person), and vice versa. So only distinct friend-counts are actually available: either or .
Now apply the basic pigeonhole principle with people (objects) and at most possible friend-counts (boxes). Since , some friend-count box must receive at least people.
Therefore at least two people at the party have exactly the same number of friends present.
If pigeons fly into holes, what does the basic pigeonhole principle guarantee?
Using the generalized pigeonhole principle, what is the guaranteed minimum number of objects in the fullest box when objects are placed into boxes?
Which everyday situation is a direct application of the pigeonhole principle?
In the party example where friendship is mutual, why can the friend-counts and not both occur among the guests?