Discrete

The sequence that cannot avoid a staircase

Any ten numbers in a row contain four that climb or four that fall. The proof gives every term a pair of counters, notices that no two terms can share a pair, and is finished — with a bound that is exactly right.

Worth reading first: More things than boxes · Six people at a party.

The Ramsey results so far in this ladder force a structure inside a colouring. This one forces a structure inside an ordering, and it is the sharpest of the family: the bound is exact, the proof is four lines, and the extremal case can be written down.

Any sequence of more than n2n^2 distinct numbers contains an increasing subsequence of length n+1n+1 or a decreasing one.

A sequence of 3² with no climb and no fall longer than 3. 10 terms plotted in order, each labelled with the longest climb and the longest fall ending at it; the first 9 keep both counters at 3 or below and the last one cannot.
Fig. 1 Nine numbers arranged so that no climb and no fall is longer than three, with each term labelled by the pair (longest climb ending here, longest fall ending here). No two terms carry the same pair, and there are only nine pairs available, so nine is the most that can be arranged this way. The tenth term is labelled outside the square.

The two counters

Give each term of the sequence two numbers: the length of the longest increasing subsequence ending at it, and the length of the longest decreasing subsequence ending at it. Call them uiu_i and did_i.

No two terms can carry the same pair. Take i<ji < j. If ai<aja_i < a_j, then any increasing run ending at aia_i extends to aja_j, so uj>uiu_j > u_i. If ai>aja_i > a_j, then the same argument on the decreasing side gives dj>did_j > d_i. Either way the pairs differ.

Now suppose no climb and no fall is longer than nn. Then every uiu_i and every did_i lies between 1 and nn, so there are n2n^2 possible pairs, and since the pairs are all different, there are at most n2n^2 terms.

That is the whole proof. It is a pigeonhole — more things than boxes — with the boxes being the pairs and the observation that no two things share one.

The figure computes both counters for every term of the sequence it draws and asserts that all the labels are distinct, which is the load-bearing claim. It then adds one more term and asserts that a climb or a fall of length n+1n+1 appears.

The extremal sequence

The bound is exactly achieved, which is unusual in this subject and worth seeing.

Take nn blocks of nn numbers each. Within a block the numbers descend; across blocks they ascend, so that every number in a later block is larger than every number in an earlier one. For n=3n = 3: 3,2,1,6,5,4,9,8,73, 2, 1, 6, 5, 4, 9, 8, 7.

An increasing subsequence can take at most one term from each block, so has length at most nn. A decreasing subsequence must stay inside a block, since crossing to a later block means increasing, so also has length at most nn. And there are n2n^2 terms.

A sequence of 4² with no climb and no fall longer than 4. 17 terms plotted in order, each labelled with the longest climb and the longest fall ending at it; the first 16 keep both counters at 4 or below and the last one cannot.
Fig. 2 The same construction with four blocks of four. Sixteen terms, no climb longer than four, no fall longer than four, and sixteen distinct pairs of counters — one for each cell of a four-by-four square. The seventeenth term has nowhere to go.

So n2n^2 is the right number and n2+1n^2 + 1 is forced. The bound and the construction meet exactly, which is what distinguishes this from R(k,k)R(k,k), where the two are exponentially far apart.

What the counters are counting

It helps to read the pair of counters as a coordinate rather than as bookkeeping.

Plot each term at the point (ui,di)(u_i, d_i). The claim that no two terms share a pair is the claim that the terms land at distinct lattice points, and the claim that both counters are at most nn is the claim that all those points lie inside an nn by nn square. A square of side nn has n2n^2 lattice points; a sequence of n2+1n^2+1 terms would need n2+1n^2+1 of them.

Seen that way the extremal construction is not an ingenious arrangement but the only thing that can work: it must fill the square exactly, one term per cell. And it does — the jj-th term of the ii-th block has climb ii and fall jj, so the blocks are the rows and the positions within them are the columns.

The proof and the construction are therefore the same object approached from two sides, which is the sign of a bound that is going to be exact.

Why it is a Ramsey theorem

The result predates Ramsey’s paper by a couple of years and is usually classed with it, and the classification is right for a reason worth stating.

A sequence of distinct numbers determines a colouring of pairs: colour {i,j}\{i, j\} with i<ji < j by whether ai<aja_i < a_j. An increasing subsequence is a set of positions all of whose pairs get the first colour; a decreasing one, the second. So the statement is exactly Ramsey’s theorem for this particular family of colourings — and the reason the bound is so much better is that not every colouring of pairs arises this way.

A general two-colouring can be anything. A colouring coming from an ordering must be transitive: if ai<aja_i < a_j and aj<aka_j < a_k then ai<aka_i < a_k. That extra structure is what takes the bound from exponential to quadratic, and it is a good illustration of how much Ramsey-type bounds depend on how arbitrary the colouring is allowed to be. The probabilistic lower bound works precisely because a random colouring is arbitrary, and it has nothing to say here, because a random colouring is almost never transitive.

Dilworth, and the same argument again

There is a second reading which generalises further.

Order the terms by position and value at once: say iji \preceq j when iji \leq j and aiaja_i \leq a_j. That is a partial order on the terms. A chain in it is an increasing subsequence; an antichain — a set of pairwise incomparable terms, — is a decreasing subsequence, since terms later in position and smaller in value are incomparable.

Dilworth’s theorem — the one Sperner’s sits beside — says a partial order with no antichain larger than ww splits into ww chains. Applied here: no decreasing subsequence longer than nn means the terms split into nn increasing subsequences, so if there are more than n2n^2 terms one of those chains has more than nn, giving a long climb.

That is the same theorem obtained from a general one, and it is worth having both. The counter argument is shorter and specific; the Dilworth argument explains why the bound is a product, and generalises to settings with no sequence in them.

A sequence of 5² with no climb and no fall longer than 5. 26 terms plotted in order, each labelled with the longest climb and the longest fall ending at it; the first 25 keep both counters at 5 or below and the last one cannot.
Fig. 3 Five blocks of five: twenty-five terms, no climb and no fall longer than five, and twenty-five distinct pairs. The construction scales without any new idea, which is another sign that the bound is the right one — an extremal example that has to be found afresh at each size usually means the bound is not tight.

The happy ending problem

Erdős and Szekeres proved their theorem while working on a different question, posed by Esther Klein, which is the other half of this rung.

Any five points in general position contain four in convex position.

Five points, and the four of them that make a convex quadrilateral. Three sets of five points in general position, with hulls of 5, 4, 3 points; in each, four points forming a convex quadrilateral are ringed and joined.
Fig. 4 Three sets of five points, with hulls of five, four and three. In each, four of the points forming a convex quadrilateral are ringed — found by testing all five ways to choose four. The claim was checked on four thousand seeded point sets, all three hull sizes appearing, and none failed.

The proof is a case split on the hull, and the three cases are the three panels.

Hull of five. Any four of them are in convex position; nothing to do.

Hull of four. The hull is a convex quadrilateral already.

Hull of three. Two points lie inside a triangle. Draw the line through them; it cuts the triangle so that two of the three corners are on the same side. Those two corners together with the two interior points form a convex quadrilateral — and the reason is that the line separates one corner from the other two, so the four chosen points have none inside the hull of the others.

The general question — how many points force a convex kk-gon — is called the happy ending problem, because Klein and Szekeres married. Erdős and Szekeres proved that a finite number always suffices, conjectured that it is 2k2+12^{k-2} + 1, and proved that in 1935 for k=4k = 4 and 5. The case k=6k = 6 was settled by computer in 2006, at 17 points as conjectured. The general conjecture is still open, though the upper bound was brought down to 2k+o(k)2^{k + o(k)} in 2016 — matching the conjecture’s base at last.

Five points, and the four of them that make a convex quadrilateral. Three sets of five points in general position, with hulls of 5, 4, 3 points; in each, four points forming a convex quadrilateral are ringed and joined.
Fig. 5 The same three cases with the claim tested on eight thousand seeded point sets rather than four. The count of each hull size is printed, and no set of five failed — which is what a claim about all point sets in general position looks like when it is checked rather than argued.

Why the two are the same subject

The connection between the sequence theorem and the points problem is direct.

Given points in general position with no two sharing an xx-coordinate, sort them by xx and read off the sequence of yy-coordinates. An increasing run is a set of points going up and to the right; a decreasing run goes down and to the right. Erdős–Szekeres then gives a long monotone run among any large set of points.

A monotone run is not convex by itself, but it is a set of points forming a cap or a cup once a second application is made — and the original 1935 proof is exactly a two-parameter version of the counter argument, tracking the largest cap and the largest cup ending at each point instead of the largest climb and fall. The 2k22^{k-2} in the conjecture is the binomial coefficient that comes out of that recursion.

So the sequence theorem is a warm-up for the geometry, and it is the warm-up that turned out to be exactly solvable while the geometry did not.

A sequence of 2² with no climb and no fall longer than 2. 5 terms plotted in order, each labelled with the longest climb and the longest fall ending at it; the first 4 keep both counters at 2 or below and the last one cannot.
Fig. 6 The smallest case, which is small enough to check by eye: four terms with no climb and no fall longer than two, and four distinct pairs of counters. The fifth term must extend one or the other, which is the statement that any five distinct numbers contain three that climb or three that fall.

What is being forced, and by how little

One last observation about how tight this is, since tightness is the rung’s distinguishing feature.

R(3,3)=6R(3,3) = 6 means that five points can escape and six cannot, and the escape at five is a delicate arrangement. Here, n2n^2 terms can escape and n2+1n^2+1 cannot, and the escape at n2n^2 is delicate in the same way: the counters must fill the square exactly, so every extremal sequence is the block construction up to relabelling, and there is no room at all.

Compare what happens either side. At n21n^2 - 1 terms there is slack and many arrangements avoid long runs; at n2+1n^2 + 1 there is none. A threshold with exactly one extremal configuration is the sharpest kind there is, and it is rare — the pentagon that saves five people is another, and the two are among the very few in this subject. Both are cases where the pigeonhole has been applied to boxes that are exactly filled rather than merely overfull.

The rigidity has a practical consequence. Because the extremal case is unique and describable, the theorem can be used in the contrapositive: a sequence that is not the block construction has a monotone run longer than nn before it reaches n2n^2 terms. That is a much stronger statement than the theorem as usually quoted, and it comes free from the proof.

What the picture cannot show

The extremal sequences drawn here are the standard block construction, and the theorem’s claim is about every sequence of n2+1n^2 + 1 terms. What the figures verify is that one particular arrangement achieves the bound and that adding one term to it breaks; the general statement is the four-line argument, and no picture of any sequence proves it.

The convex-position figure has the same limitation in a sharper form. Three point sets are drawn and the claim is about all of them, so the figure runs the check over four thousand seeded sets in general position — which is evidence rather than proof, and is described as such in the caption. The proof is the hull case split, which needs no examples at all.

And nothing here can show the happy ending problem’s difficulty. Five points and four in convex position is a case split; seventeen points and six in convex position took a computer search over a space that had to be cut down by a great deal of theory first, and there is no picture of that.

Where the theorem is used

It is worth naming two uses, because a theorem this tight tends to be a tool rather than a destination.

Sorting and patience. Dealing a shuffled pack into piles, each card going on the leftmost pile whose top card is larger, produces a number of piles equal to the length of the longest increasing subsequence. That is not a coincidence but Dilworth’s theorem in action, and the algorithm — patience sorting — computes the quantity in nlognn\log n time. The proof above says that this number times the longest decreasing run is at least the length of the sequence.

Bounding what a comparison can learn. Any algorithm that only compares elements is working with the partial order above — and what a sorting network can decide is bounded by the structure it can force, and the theorem bounds how much structure a sequence can hide from it. That kind of statement is what lower bounds on sorting and searching are built from.

The general pattern is that a theorem forcing structure is useful as a guarantee: something is always there, so an algorithm may rely on finding it. The Ramsey theorems in the rest of this ladder rarely offer that, because the sizes at which their structures appear are far beyond any computation.

The random case, which is a different shape entirely

The theorem is about the worst case, and the typical case is worth a paragraph because the two answers look nothing alike.

A random permutation of nn numbers has a longest increasing subsequence of length about 2n2\sqrt n. Not n\sqrt n, which is what the theorem’s bound would suggest if the two runs were balanced — twice that, and the factor of two took decades to establish.

So the extremal sequence, with both runs at exactly n\sqrt n, is far from typical: a random permutation has runs twice as long in both directions. The worst case is worse than random by a factor of two, which is a small margin by the standards of this subject and is a consequence of how tight the bound is.

The distribution of that length is the celebrated part. Its fluctuations about 2n2\sqrt n are of order n1/6n^{1/6} and follow the Tracy–Widom law, which arose first in the study of eigenvalues of random matrices and has no obvious business appearing in a question about shuffling cards. That connection, established in 1999, is one of the more surprising in modern probability, and it starts from the theorem in this essay.

The ladder from here

Rungs above: the cap-and-cup proof, and where the binomial coefficient comes from. Dilworth’s theorem and Mirsky’s, proved rather than quoted. The Robinson–Schensted correspondence, which turns a permutation into a pair of tableaux whose shape encodes the longest climb and fall together — a much finer statement than the theorem here. The distribution of the longest increasing subsequence of a random permutation, which is 2n2\sqrt n and whose fluctuations are one of the celebrated results of the last thirty years. And the happy ending problem’s upper bound.

Why this one is exact

Every other rung of this ladder has a gap between what is forced and what can be exhibited, and this one does not. It is worth asking what is different.

The answer is that the counting is injective. The proof does not say that some pair of counters must repeat because there are too many terms; it says that no pair can repeat, ever, and then counts the pairs. That is a much stronger statement than pigeonhole usually delivers, and it is what makes the bound exactly right rather than merely a bound.

The general lesson is worth carrying. A pigeonhole argument gives a sharp answer exactly when the map into the boxes is injective and the boxes are all reachable — one term per pair, and the block construction reaching every pair. When either half fails, the bound is loose, and the Ramsey numbers are what loose looks like.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Convex positionCounting argumentErdos szekeresExistence proofExtremal configurationMonotone subsequencePartial orderPermutationPigeonhole principleRamsey number