Pigeon-hole and double counting #
TODO #
- statement (pigeon_hole_principle)
- Numbers
- Claim 1 (coprime pair)
- Claim 2 (divisibility)
- Sequences
- Claim 3 (Erdős–Szekeres) — via ErdosSzekeres (merged)
- Sums
- Claim 4 (contiguous sum divisible by n)
- Double Counting
- Numbers again
- sum_divisor_count (proved)
- Graphs
- sum_choose_deg_le_choose_card (proved)
- c4_free_edge_bound (proved)
- Sperner's Lemma
- sperner_lemma (proved — abstract parity version)
- sperner_lemma_exists (proved — corollary)
- brouwer_fixed_point_2d (proved — via covering space / no-retraction argument)
Erdős–Szekeres theorem #
Uses the proof by Bhavik Mehta from Mathlib's Archive:
Archive.Wiedijk100Theorems.AscendingDescendingSequences.
Faithfulness note: The book assigns each element a single label tᵢ (length of the longest increasing subsequence starting at aᵢ) and applies pigeonhole to get n+1 elements with the same label, then argues they must be decreasing. The Mathlib Archive proof uses a dual-label strategy (maxInc, maxDec) and applies pigeonhole to the product {1,…,m} × {1,…,n}. The two strategies are mathematically equivalent — the dual-label approach is a natural generalization that avoids the separate "same-label implies decreasing" argument.
Corollary: Any injective sequence of m*n+1 elements has an increasing subsequence
of length m+1 or a decreasing subsequence of length n+1.
Brouwer Fixed Point Theorem (merged from Brouwer.lean) #
Handshaking lemma: The sum of vertex degrees equals twice the number of edges.
This is also available in Mathlib as SimpleGraph.sum_degrees_eq_twice_card_edges,
which uses darts (oriented edges) as the intermediate counting object. Our proof
follows the book's double-counting argument more faithfully: we count incidence
pairs (v, e) with v ∈ e, swap the summation order via
Finset.sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow, then observe each edge
contributes exactly 2.
Claim 3 (Erdős–Szekeres): Any injective sequence of mn+1 distinct reals has an increasing subsequence of length m+1 or a decreasing subsequence of length n+1.
Double Counting #
Double counting: the sum over rows of the number of related columns equals
the sum over columns of the number of related rows. This is a direct wrapper
around Mathlib's Finset.sum_card_bipartiteAbove_eq_sum_card_bipartiteBelow.
5. Graphs — C₄-free edge bound #
In a C₄-free graph, the sum of C(d(v), 2) over all vertices is at most C(n, 2).
This is the key combinatorial inequality: each pair of vertices can have at most one common neighbor (otherwise they'd form a 4-cycle), so the number of "cherries" (paths of length 2) is at most the number of vertex pairs.
If a simple graph on n vertices contains no 4-cycle (C₄), then |E| ≤ ⌊n/4 · (1 + √(4n − 3))⌋.
The proof uses sum_choose_deg_le_choose_card together with the handshaking lemma
and Cauchy–Schwarz / Jensen.
4. Numbers again #
Double counting for divisor sums: Σ_{j=1}^{n} (number of divisors of j) = Σ_{i=1}^{n} ⌊n/i⌋.
Both sides count pairs (i, j) with 1 ≤ i ≤ n, 1 ≤ j ≤ n, and i ∣ j. LHS groups by j (divisors of j), RHS groups by i (multiples of i up to n).
The average number of divisors is bounded by the harmonic sum:
∑ j in [1,n], t(j) ≤ n * Hₙ where t(j) = #(divisors j) and Hₙ = ∑ 1/i.
Lower bound: ∑ t(j) > n·Hₙ − n, i.e., t̄(n) > Hₙ − 1 > log n − 1.
Dimension of Kₙ via iterated Erdős-Szekeres #
The dimension of the complete graph Kₙ is the minimum number of linear orders (permutations) such that no 3-element subset is simultaneously monotone in all orders.
Theorem: dim(Kₙ) ≥ ⌈log₂(⌈log₂ n⌉)⌉ for n ≥ 3.
The proof uses an iterated Erdős-Szekeres argument: given p injective functions on n elements with n > 2^(2^p), repeated extraction of monotone subsequences (one per function) yields a subset of size > 2 that is simultaneously monotone in all functions.
This means p linear orders cannot "separate" all triples, so dim(Kₙ) > p. Taking the contrapositive with p = ⌈log₂(⌈log₂ n⌉)⌉ − 1 gives the bound.
Erdős-Szekeres on finsets: Given a finset S of size > m² and a function f injective on S, there exists a subset T ⊆ S of size > m on which f is monotone.
Iterated Erdős-Szekeres: Given p injective functions on Fin n and a finset S with |S| > 2^(2^p), there exists a subset T ⊆ S with |T| > 2 that is simultaneously monotone (each function is either strictly increasing or strictly decreasing on T).
Simultaneous monotone triple: For n > 2^(2^p) and p injective functions Fin n → ℝ, there exists a subset of size > 2 that is monotone for all of them.
This captures the lower bound dim(Kₙ) ≥ ⌈log₂(⌈log₂ n⌉)⌉: fewer than ⌈log₂(⌈log₂ n⌉)⌉ linear orders cannot separate all triples.
Ceiling-log formulation: If p < ⌈log₂(⌈log₂ n⌉)⌉, then p injective functions on Fin n cannot separate all triples. This is the dim(Kₙ) ≥ ⌈log₂(⌈log₂ n⌉)⌉ bound.
6. Sperner's Lemma #
Transfer from simplex to disk.
Brouwer's fixed point theorem (n = 2) #
The Reiman graph Gp: a tight construction for the C₄-free bound #
The book constructs a graph Gp for each odd prime p:
- Vertices = points of PG(2,p), i.e., one-dimensional subspaces of (ZMod p)³
- Two vertices [u],[v] are adjacent iff ⟨u,v⟩ = u₁v₁ + u₂v₂ + u₃v₃ = 0
- Gp is C₄-free
- Edge count achieves the bound from
c4_free_edge_bound
We use Mathlib's Projectivization and Projectivization.orthogonal.
The projective plane over 𝔽ₚ.
Equations
- chapter28.PG2 p = Projectivization (ZMod p) (Fin 3 → ZMod p)
Instances For
The Reiman graph Gp: vertices are points of PG(2,p), adjacency is orthogonality.
Equations
- chapter28.reimanGraph p = { Adj := fun (v w : chapter28.PG2 p) => v ≠ w ∧ Projectivization.orthogonal v w, symm := ⋯, loopless := ⋯ }
Instances For
The number of vertices of Gp is p² + p + 1. Note: The tex assumes p is an odd prime, but oddness is not needed for the cardinality formula — only that p is a prime (hence ZMod p is a field).
In PG(2,F), if a point x is orthogonal to two distinct points a and c, then x = cross a c. This is the uniqueness of the intersection of two hyperplanes (each hyperplane is the set of points orthogonal to a given point). Proof: by the BAC-CAB identity, w × (u × v) = (w·v)u − (u·w)v = 0 when w·u = 0 and w·v = 0, so the representatives are proportional.
Key lemma for no C₄: if two distinct points v, w are both orthogonal to two distinct points a, b, then v = w. Equivalently, the "orthogonal complement" hyperplanes of distinct points intersect in at most a single projective point.
This is the projective geometry fact that two distinct hyperplanes in PG(2,p) meet in exactly one point.
Note: The tex states this for 4 distinct vertices (6 pairwise ≠ conditions), but the proof only needs a ≠ c and b ≠ d. The other four ≠ conditions follow from Adj being irreflexive (loopless graph).
Each vertex's degree: p if self-orthogonal, p+1 otherwise. The orthogonal hyperplane of [v] in PG(2,p) has p+1 projective points. If v·v = 0, then [v] is among them and the degree is p; otherwise p+1.