Back to Combinatorics

Chapter 3: Pigeonhole Principle and Introductory Ramsey Theory

October 9, 2026 Wasil Zafar 19 min read

When unavoidable repetition forces mathematical structure

Table of Contents

  1. Why must six people contain a familiar or unfamiliar triple?
  2. 3.1 Basic pigeonhole principle
  3. 3.2 Generalized pigeonhole principle
  4. 3.3 Average-value and weighted pigeonhole arguments
  5. 3.4 Infinite pigeonhole principle
  6. 3.5 Introductory Ramsey theory and Ramsey's theorem
  7. 3.6 Applications to sequences, geometry, and number theory
  8. Find the sharp pigeonhole bound and test a Ramsey coloring

Why Must Six People Contain a Familiar or Unfamiliar Triple?

Suppose six people attend a gathering. For every pair of individuals, we record exactly one of two mutual relationships: either they know each other (friends), or they do not (strangers). Must there always exist a group of three people who are all mutual friends, or three people who are all mutual strangers?

This classic problem—often called the Theorem on Friends and Strangers—marks the primary entry point into Ramsey Theory, a branch of combinatorics concerned with unavoidable order in large discrete systems. To analyze this rigorously, we translate the social scenario directly into graph-theoretic terms:

Translating the Party Problem to Graph Theory
  • People $\to$ Vertices: The 6 attendees are modeled as 6 vertices of a complete graph $K_6$, where an edge joins every pair of vertices.
  • Relationships $\to$ Edge Colors: Every edge is colored either Red (mutual friends) or Blue (mutual strangers).
  • Target Structure $\to$ Monochromatic Triangles: A trio of mutual friends or mutual strangers corresponds to a monochromatic triangle ($K_3$).

The fundamental question can thus be rephrased: Is it impossible to color the 15 edges of $K_6$ with two colors(Red non-zero and Blue non-zero) without creating at least one single-color(Red or Blue) triangle? As we will prove using the Pigeonhole Principle, the answer is a definitive yes.

Complete Graph K6 Edge Coloring and Incident Pigeonhole Principle Diagram showing vertex A in a K6 graph with 5 incident edges split into red and blue, forcing at least 3 edges to share a color by the Pigeonhole Principle. The 6-Person Party Problem ($K_6$ Graph Representation) Complete Graph $K_6$ (15 Total Edges) A B C D E F The Incident Edge Argument 1. Vertex $A$ has 5 incident edges in 2 colors. 2. Pigeonhole: $\lceil 5/2 \rceil = 3$ edges must share a color. 3. Inspect edges between $\{B, C, D\}$: If ANY is Red ➔ Red Triangle! If ALL Blue ➔ Blue Triangle!
Figure 3.1: In $K_6$, vertex $A$ has 5 incident edges. By the Pigeonhole Principle, at least 3 edges must share the same color (e.g., Red to $B, C, D$).
Motivating Problem Walkthrough

Proof Walkthrough: Why $R(3,3) = 6$ (The Party Problem)

Ramsey Theory guarantees that complete order emerges from sufficient disorder. The classic Party Problem asks: "What is the minimum number of people $N$ required at a party to guarantee that at least 3 people are mutual friends or 3 people are mutual strangers?" In graph theory, this is modeled as finding the Ramsey number $R(3,3)$, where we 2-color the edges of a complete graph $K_N$ using Red (representing mutual friends) and Blue (representing mutual strangers), searching for a monochromatic triangle ($K_3$).


Part 1: Upper Bound Proof ($R(3,3) \le 6$)

Take a complete graph on 6 vertices ($K_6$) with labeled vertices $A, B, C, D, E, F$. Every pair of vertices is connected by an edge colored either Red or Blue.

  1. Degree Analysis & Pigeonhole Principle:
    Focus on vertex $A$. Since $K_6$ has 6 vertices, vertex $A$ is connected to the remaining 5 vertices by 5 distinct edges: $(AB, AC, AD, AE, AF)$. By the Generalized Pigeonhole Principle, dividing $5$ edges into $2$ color categories (Red or Blue) guarantees that at least: $$\left\lceil \frac{5}{2} \right\rceil = 3\text{ edges}$$ must share the exact same color. Without loss of generality, assume these 3 majority-colored edges connected to $A$ are Red, and lead to neighbor vertices $B, C,$ and $D$.
  2. Examine the Sub-Graph $\{B, C, D\}$:
    Now consider the 3 interconnecting edges between these target vertices: $BC, BD,$ and $CD$. There are two exhaustive, mutually exclusive possibilities for how these 3 edges are colored:
    Case A: At Least One Red Edge

    Suppose at least one edge among $\{BC, BD, CD\}$ is colored Red. For example, let $BD$ be Red. Since $AB$ and $AD$ are already Red, the three vertices $\{A, B, D\}$ form a solid Red triangle ($\triangle ABD$) representing 3 mutual friends!

    Case B: Zero Red Edges

    Suppose none of the edges among $\{BC, BD, CD\}$ are Red. Since every edge must be 2-colored, all three edges $BC, BD,$ and $CD$ are forced to be Blue. Thus, the vertices $\{B, C, D\}$ form a solid Blue triangle ($\triangle BCD$) representing 3 mutual strangers!

Upper Bound Conclusion: In both cases, a monochromatic triangle ($K_3$) is guaranteed to exist. Therefore, 6 people are always sufficient: $R(3,3) \le 6$.

Part 2: Lower Bound Proof ($R(3,3) > 5$)

To prove that 6 is the sharp minimum threshold, we must construct a counterexample showing that a 5-person group ($K_5$) can avoid both Red and Blue triangles entirely ($R(3,3) > 5$).

The $C_5$ Construction (5-Cycle Graph):
Arrange 5 vertices in a circle labeled $1, 2, 3, 4, 5$. Color the edges as follows:
  • Color the 5 outer boundary edges $(12, 23, 34, 45, 51)$ Red (forming a 5-cycle graph $C_5$).
  • Color the 5 inner diagonal chords $(13, 24, 35, 42, 52)$ Blue (forming a complementary 5-cycle graph $\bar{C}_5$).
Why five people are not enough K5 can be 2-coloured with no monochromatic triangle — so R(3,3) = 6 exactly Colour the ten edges of K5 as a red 5-cycle around the outside and a blue pentagram of diagonals inside: 1 2 3 4 5 No red triangle and no blue triangle exists Any three vertices are joined by either two red edges and one blue, or one red and two blue — never three of the same colour. Hence R(3,3) > 5; together with the guaranteed monochromatic triangle in every K6, this pins down R(3,3) = 6. Resulting Structure:

No Red triangle exists because the smallest cycle in $C_5$ has length 5. Likewise, no Blue triangle exists because the complement of $C_5$ is also isomorphic to a 5-cycle ($\bar{C}_5 \cong C_5$), which also contains no 3-cycles!

Summary & Exact Value: Since $K_5$ can be 2-colored without any monochromatic triangles ($R(3,3) > 5$) and $K_6$ always forces at least one monochromatic triangle ($R(3,3) \le 6$), we establish the exact sharp threshold: $$\mathbf{R(3,3) = 6}$$
The Theorem on Friends and Strangers An application of Ramsey's theorem · R(3,3) = 6 Picture a party of six people. Draw one vertex for each person and join every pair of vertices by an edge: the complete graph K6. Colour each edge blue when the two people are friends and red when they are strangers. Ramsey's theorem guarantees that, no matter how the 15 edges are coloured, one of these two pictures must occur: 1 2 3 4 5 6 1 2 3 4 5 6 or A blue triangle: three mutual friends here: persons 1, 3 and 5 all know each other A red triangle: three mutual strangers here: persons 1, 2 and 4 are all strangers to one another friends strangers person (vertex) This is Ramsey's theorem in action: R(3,3) = 6 is the smallest party size that forces three mutual friends or three mutual strangers. With only five people the claim fails: colour K5 as a red 5-cycle plus blue diagonals and no monochromatic triangle appears. Every edge of K6 gets exactly one colour — a monochromatic triangle is unavoidable.

3.1 Basic Pigeonhole Principle

The Pigeonhole Principle (historically known as Dirichlet's Box Principle) states an intuitively obvious yet deeply powerful truth: If more objects than container boxes are distributed into those boxes, then at least one box must contain two or more objects.

The Basic Pigeonhole Principle (Formal)

If $n+1$ or more objects are placed into $n$ distinct boxes (where $n \ge 1$), then at least one box contains two or more objects. In set theory, a function $f: A \to B$ between finite sets cannot be injective (one-to-one) if $|A| > |B|$.

Basic Pigeonhole Principle Demonstration Diagram showing 6 pigeons placed into 5 boxes, forcing a collision where Box 2 contains 2 pigeons. Placing $n+1 = 6$ Pigeons into $n = 5$ Boxes Box 1 P₁ Box 2 (Collision!) P₂ P₆ Box 3 P₃ Box 4 P₄ Box 5 P₅ Proof: If all boxes had $\le 1$ object, total would be $\le 5 < 6$ (Contradiction!)
Figure 3.2: Distributing 6 objects into 5 boxes forces at least one box to contain $\ge 2$ objects.

The "boxes" in combinatorial proofs are abstract categories rather than physical bins. Identifying the correct choice of boxes is the key creative step.

Classic Applications:

  • Birth Months: Among 13 people, at least two were born in the same month (13 objects, 12 month boxes).
  • Modular Remainders: Every integer leaves one of 5 possible remainders ($\{0, 1, 2, 3, 4\}$) when divided by 5. Therefore, among any 6 integers, at least two share the same remainder $r$. Their difference $(5u + r) - (5v + r) = 5(u - v)$ is guaranteed to be divisible by 5!
Modular Remainders Pigeonhole Collision Diagram showing 6 integers mapped into 5 remainder classes modulo 5, forcing 2 numbers to share remainder 3, proving their difference is divisible by 5. Modular Arithmetic: 6 Integers $\to$ 5 Remainder Classes Modulo 5 rem = 0 rem = 1 14, 19 rem = 2 22, 27 rem = 3 (Collision!) 3 and 8 $8 - 3 = 5$ (Divisible!) rem = 4 Example List $\{3, 8, 14, 19, 22, 27\}$: $3 \equiv 8 \pmod 5 \implies 5 \mid (8-3)$
Figure 3.3: Six integers distributed across 5 remainder classes force at least two integers to share a remainder, guaranteeing their difference is a multiple of 5.

Worked Exercise: Pairs Summing to 21

Problem: Show that choosing 11 distinct integers from $\{1, 2, \dots, 20\}$ forces two numbers whose sum is exactly 21.

Solution: Construct 10 complementary pair boxes: $\{1,20\}, \{2,19\}, \{3,18\}, \dots, \{10,11\}$. By the Pigeonhole Principle, placing 11 distinct numbers into 10 boxes forces two numbers into the same pair box. Since all numbers are distinct, both members of that box must be chosen, and their sum is $x + (21-x) = 21$.


3.2 Generalized Pigeonhole Principle

When the number of objects $N$ significantly exceeds the number of boxes $m$, the **Generalized Pigeonhole Principle** provides a higher minimum occupancy guarantee based on the ceiling of the average occupancy.

Generalized Pigeonhole Principle Ceiling Occupancy Distribution Bar chart showing 25 students divided into 6 project groups, where the average 25/6 = 4.16 forces at least one group to have 5 students. Generalized Threshold: 25 Students in 6 Groups ($\lceil 25/6 \rceil = 5$) Target = 5 Avg = 4.16 5 Group 1 4 4 4 4 4 Group 2 Group 3 Group 4 Group 5 Group 6
Figure 3.4: Distribution $(5, 4, 4, 4, 4, 4)$ achieves total 25 while guaranteeing that at least one group has size $\ge 5$.
Proof Workshop

Worked Example: Project Group Assignments

Twenty-five students are assigned to six project groups. What is the guaranteed minimum group size that must occur somewhere?

  • Average Calculation: $\mu = 25/6 = 4.166\dots$
  • Ceiling Bound: $\lceil 25/6 \rceil = 5$ students.
  • Contradiction Check: If every group contained at most 4 students, 6 groups could accommodate at most $6 \times 4 = 24$ students, leaving 1 student unassigned!
  • Sharpness Check: The distribution $(5, 4, 4, 4, 4, 4)$ sums to 25, proving we cannot universally guarantee a group of size 6.

Practice Exercise: Birth Weekdays

How many people are required to guarantee that at least 4 share a birth weekday?
Solution: With $m = 7$ weekdays and target $r = 4$, the threshold formula gives $m(r-1) + 1 = 7(4-1) + 1 = 22$ people. With 21 people, having 3 people per weekday avoids a group of 4.


3.3 Average-Value and Weighted Pigeonhole Arguments

The pigeonhole principle is a discrete instance of a broader mathematical truth: In any set of real values, at least one value is greater than or equal to the average, and at least one value is less than or equal to the average. When components have varying sizes or capacities, we use weighted averages.

Weighted Average Formula

Let $r_1, \dots, r_m$ be performance rates assigned positive weights $w_1, \dots, w_m$. The weighted average is:

$$\mu_w = \frac{\sum_{i=1}^{m} w_i r_i}{\sum_{i=1}^{m} w_i}$$

At least one rate $r_i$ satisfies $r_i \ge \mu_w$, and at least one rate satisfies $r_i \le \mu_w$.

Capacity-Weighted Pigeonhole Argument for Three Servers Bar chart comparing normalized job rates per capacity unit across 3 servers against a global load rate line of 1.0. Server Workload vs. Capacity Normalized Rates 0.0 1.0 2.0 Global Load Rate = 1.0 2.0 Server A 4 jobs / 2 cap 1.0 Server B 3 jobs / 3 cap 0.6 Server C 3 jobs / 5 cap
Figure 3.5: Total jobs (10) divided by total capacity (10) gives global load rate 1.0. Server A exceeds this rate ($2.0 \ge 1.0$).

Capacity Overload Proof without Division: If box $i$ has capacity $c_i$ and total objects $N > \sum c_i$, then at least one box must exceed its capacity.


3.4 Infinite Pigeonhole Principle

The Infinite Pigeonhole Principle extends partitioning logic to infinite sets: If an infinite set is partitioned into finitely many subset classes, then at least one class must contain infinitely many elements.

Formal Statement & Proof

Let $S$ be an infinite set partitioned into $m$ disjoint classes $S_1, S_2, \dots, S_m$ (where $m$ is finite). Then at least one class $S_i$ is infinite.

Proof by Contradiction: If every class $S_1, \dots, S_m$ were finite, then their union $S = \bigcup_{i=1}^m S_i$ would be a finite union of finite sets, which is finite—contradicting the premise that $S$ is infinite!

Infinite Sequence Partitioned into Finite Buckets Diagram showing an infinite sequence stream flowing into 3 finite color buckets (Red, Blue, Green), forcing Bucket Red to hold infinitely many elements. Infinite Stream Partitioned into $m = 3$ Buckets Infinite Sequence $x_1, x_2, x_3, x_4, \dots$ ∞ Alphabet $\{R, B, G\}$ Bucket R: R, R, R, R, R, R, R, ... (INFINITE!) Bucket B: B, B, B (Finite = 3) Bucket G: ∅ (Empty = 0)
Figure 3.6: Partitioning an infinite stream into 3 buckets forces at least one bucket to receive infinitely many terms.

Application to Sequences: In any infinite sequence over a finite alphabet (e.g., $R, B, G$), at least one symbol occurs infinitely often, forming an infinite constant subsequence.


3.5 Introductory Ramsey Theory and Ramsey's Theorem

Pigeonhole arguments force repetition of individual elements. Ramsey Theory asks a deeper structural question: How large must a system be to guarantee a completely monochromatic sub-structure?

For graph edge colorings, a Ramsey number $R(s, t)$ denotes the minimum number of vertices $N$ such that every Red-Blue edge coloring of $K_N$ contains either a solid Red $K_s$ or a solid Blue $K_t$.

K5 Graph Triangle-Free Ramsey Edge Coloring Counterexample Diagram showing K5 edge coloring with a Red 5-cycle outer ring and Blue 5-cycle inner pentagram, showing no monochromatic triangles exist, proving R(3,3) > 5. Sharpness Proof: R(3,3) > 5 (K₅ Contains No Monochromatic Triangle) 1 2 3 4 5 Coloring Breakdown Red Edges (Outer 5-Cycle): 12, 23, 34, 45, 51 (No Red Triangle!) Blue Edges (Inner Pentagram): 13, 35, 52, 24, 41 (No Blue Triangle!) Result: R(3,3) > 5 ⇒ R(3,3) = 6 ✓
Figure 3.7: K₅ colored with a Red outer 5-cycle and Blue inner pentagram contains zero monochromatic triangles, proving R(3,3) = 6.
Recursive Upper Bound for Ramsey Numbers Diagram showing how vertex v splits neighbors into Red group (size a) and Blue group (size b), proving R(s,t) <= R(s-1,t) + R(s,t-1). General Recursive Bound: $R(s,t) \le R(s-1,t) + R(s,t-1)$ v Red Neighbor Set $V_R$ (Size $\ge R(s-1, t)$): Yields either Blue $K_t$ (Done!) OR Red $K_{s-1}$ (+ $v \implies$ Red $K_s$) Blue Neighbor Set $V_B$ (Size $\ge R(s, t-1)$): Yields either Red $K_s$ (Done!) OR Blue $K_{t-1}$ (+ $v \implies$ Blue $K_t$)
Figure 3.8: Vertex $v$ partitions remaining $R(s-1,t) + R(s,t-1) - 1$ vertices into Red and Blue neighbor sets.

3.6 Applications to Sequences, Geometry, and Number Theory

The pigeonhole principle yields profound results across diverse branches of mathematics when applied to clever choice of boxes.

1. Sequences: Consecutive Sub-Block Sum Divisibility

Theorem: Given any sequence of $m$ integers $(a_1, a_2, \dots, a_m)$, there is always a non-empty contiguous block whose sum is divisible by $m$.

Proof via Prefix Sums: Define $m+1$ prefix sums $S_0 = 0$ and $S_j = \sum_{\ell=1}^j a_\ell$. Since there are $m+1$ prefix sums and only $m$ remainder classes modulo $m$, two prefix sums $S_i$ and $S_j$ ($i < j$) must share the same remainder modulo $m$. Subtracting them gives:

$$S_j - S_i = a_{i+1} + a_{i+2} + \dots + a_j \equiv 0 \pmod m$$

2. Geometry: Nearby Points in a Unit Square

Theorem: Place 5 points inside a $1 \times 1$ closed unit square. At least two points are separated by a Euclidean distance $d \le 1/\sqrt{2}$.

Geometry Unit Square Partitioning for Nearby Points Diagram showing a 1x1 square divided into 4 quarter squares with 5 points, forcing 2 points into one quarter square of diagonal 1/sqrt(2). Unit Square Partitioned into $m = 4$ Quarter Cells d ≤ 1/√2 Distance Upper Bound Proof 1. Subdivide $1 \times 1$ square into 4 quarters of size $\frac{1}{2} \times \frac{1}{2}$. 2. Pigeonhole: 5 points in 4 quarters $\implies$ 2 points share 1 quarter. 3. Maximum separation in a $\frac{1}{2} \times \frac{1}{2}$ cell is its diagonal: $d \le \sqrt{(1/2)^2 + (1/2)^2} = \sqrt{2/4} = \frac{1}{\sqrt{2}}$ ✓
Figure 3.9: Subdividing the square into 4 quarter cells forces two points into a single cell with maximum diagonal distance $1/\sqrt{2}$.

3. Number Theory: Divisibility in $\{1, 2, \dots, 2n\}$

Theorem: Choose $n+1$ distinct integers from $\{1, 2, \dots, 2n\}$. At least one chosen integer strictly divides another!

Odd Part Integer Decomposition Pigeonhole Diagram showing how writing x = 2^k * u decomposes numbers into n odd buckets, forcing a divisibility pair. Odd-Part Decomposition: $x = 2^k \cdot u$ ($n$ Odd Buckets) u = 1 {1, 2, 4, 8} u = 3 (Pair!) {3, 6} u = 5 {5, 10} u = 7 {7} u = 9 {9} 6 numbers from $\{1..10\} \implies$ Two share odd part $u$ ($3 \cdot 2^0 = 3$ and $3 \cdot 2^1 = 6 \implies 3 \mid 6$)
Figure 3.10: Factorizing $x = 2^k \cdot u$ splits $\{1, \dots, 2n\}$ into $n$ odd part buckets. Choosing $n+1$ integers forces a shared odd part $u$, guaranteeing $x \mid y$.

Find the Sharp Pigeonhole Bound and Test a Ramsey Coloring

In this investigation, we combine proof diagnosis, sharp threshold constructions, and algorithmic verification to examine the exact boundaries of the Pigeonhole Principle and Ramsey Theory.

Comprehensive Investigation

Investigation: Sharp Bounds & Prefix Remainder Algorithms

Part 1: Sharp Occupancy Bound Proof

Theorem: For $N$ objects and $m$ boxes, the minimum achievable maximum occupancy across all possible distributions is exactly $\lceil N/m \rceil$.

Constructive Proof of Sharpness:

Write $N = qm + r$, where $0 \le r < m$ and $q = \lfloor N/m \rfloor$.

  • Place $q+1$ objects into each of $r$ boxes.
  • Place $q$ objects into each of the remaining $m-r$ boxes.
  • Total objects check: $r(q+1) + (m-r)q = rq + r + mq - rq = mq + r = N$.
  • When $r = 0$, maximum occupancy is $q = \lceil N/m \rceil$. When $r > 0$, maximum occupancy is $q+1 = \lceil N/m \rceil$. Thus, the ceiling bound is universally sharp!

Part 2: Prefix Remainder Divisible-Sum Algorithm

We implement a linear-time algorithm that locates a contiguous sub-block whose sum is divisible by $m$ using prefix sum remainders:

Prefix Remainder Sub-Block Divisibility Trace Execution trace table for sequence (3,1,4,2,7) showing prefix sums, remainders mod 5, and detecting repeat remainder 3 at indices 1 and 3. Execution Trace: Sequence $(3, 1, 4, 2, 7)$ Modulo 5 Index $j$ Term $a_j$ Prefix Sum $S_j$ Remainder $(S_j \bmod 5)$ Algorithm State 0 - 0 0 Store map[0] = 0 1 3 3 3 Store map[3] = 1 2 1 4 4 Store map[4] = 2 3 4 8 3 (COLLISION!) MATCH map[3] = 1! Return Sub-Block $(a_2, a_3) = (1, 4) \implies$ Sum $= 5 \equiv 0 \pmod 5$ ✓
Figure 3.11: Algorithm stores first indices of prefix remainders. Repeating remainder 3 at $j=3$ and $i=1$ recovers block $(1,4)$ with sum 5.
function find_divisible_subblock(arr, m):
    remainder_map = {0: 0}  // Base prefix sum S0 = 0 at index 0
    current_sum = 0

    for j from 1 to length(arr):
        current_sum += arr[j]
        rem = ((current_sum % m) + m) % m  // Non-negative remainder

        if rem in remainder_map:
            i = remainder_map[rem]
            return arr[i+1 ... j]  // Contiguous sub-block
        else:
            remainder_map[rem] = j

Deliverables & Assessment Rubric (20 Points)

Criteria Point Value Requirements & Expectations
Rigor & Quantifier Precision 4 Points Precise definition of boxes, object assignments, graph edge colorings, and quantifiers.
Sharp Bound Proofs 4 Points Complete proof of ceiling occupancy threshold and explicit matching construction $N = qm + r$.
Ramsey Verification 4 Points Complete verification of $K_5$ 5-cycle obstruction and airtight $K_6$ incident edge proof.
Algorithmic Correctness 4 Points Correct prefix-remainder divisibility algorithm, indexing bounds, and edge case handling ($S_0$).
Reproducible Checks 4 Points Clear distinction between universal proofs, theoretical bounds, and computational enumerations.

Next in the Series

In Chapter 4: Permutations and Combinations, we'll explore When unavoidable repetition forces mathematical structure.