Documentation

CslibFrontier.Foundations.Combinatorics.ErdosSzekeres

The Erdős–Szekeres monotone subsequence theorem #

A sequence f : Fin n → β in a linear order with r * s < n has a monotone (non-decreasing) subsequence of r + 1 terms or a strictly decreasing subsequence of s + 1 terms ([ES35], p. 467, Theorem, and its f(i, k) form on p. 468; there equal values may count as increasing or decreasing). For injective sequences the first alternative is strictly increasing.

The proof is the standard reduction to Mirsky's theorem: order the positions by i ≤ j ∧ f i ≤ f j. Its chains are monotone subsequences and its antichains are strictly decreasing subsequences. If every chain has at most r elements, Mirsky's theorem (exists_antichain_coloring_iff) covers the n > r * s positions by r antichains, and the pigeonhole principle puts more than s of them in one antichain.

Subsequences are Finset (Fin n)s of positions. Mathlib's archive has the injective case as Theorems100.erdos_szekeres, which cannot be imported.

Main results #

References #

theorem exists_monotoneOn_or_strictAntiOn_of_mul_lt {β : Type u_1} [LinearOrder β] {n : ℕ} (f : Fin n → β) {r s : ℕ} (hn : r * s < n) :
(∃ (t : Finset (Fin n)), r < t.card ∧ MonotoneOn f ↑t) ∨ ∃ (t : Finset (Fin n)), s < t.card ∧ StrictAntiOn f ↑t

Erdős–Szekeres ([ES35], pp. 467–468): a sequence of more than r * s terms in a linear order has a monotone subsequence of r + 1 terms or a strictly decreasing subsequence of s + 1 terms.

theorem exists_strictMonoOn_or_strictAntiOn_of_mul_lt {β : Type u_1} [LinearOrder β] {n : ℕ} {f : Fin n → β} (hf : Function.Injective f) {r s : ℕ} (hn : r * s < n) :
(∃ (t : Finset (Fin n)), r < t.card ∧ StrictMonoOn f ↑t) ∨ ∃ (t : Finset (Fin n)), s < t.card ∧ StrictAntiOn f ↑t

Erdős–Szekeres for injective sequences ([ES35], pp. 467–468): more than r * s distinct terms have a strictly increasing subsequence of r + 1 terms or a strictly decreasing subsequence of s + 1 terms.