Finding a longest increasing subsequence is a well-known problem in computer science (note that I use the article "a" instead of "the" because there could be multiple longest subsequences): Given a sequence {a1,…,an} of real numbers, we want to find a subsequence {ai1,…,aik} such that 0≤i1<⋯<ik≤n, ai1≤⋯≤aik, and the subsequence is as long as possible. It has a very easy dynamic programming solution with a time complexity of O(n2) and a slightly more involved solution with a time complexity of O(nlogn). But we are not interested in these algorithms in this blog post.
We are interested in studying the asymptotics of the length of the longest increasing subsequences of a sequence whose elements are coming from a random permutation. This simple to state problem will take us on a beautiful journey touching topics from combinatorics and probability theory. In particular, we will get to see the very elegant technique of Poissonization.
Let us start by stating precisely what we are trying to prove. To do that we first define some notation. For any integer n≥1, let Sn be the group of permutations of order n, i.e., it contains all permutations of {1,2,…,n} and hence Sn contains n! elements. If π∈Sn then a subsequence of π is a sequence {π(i1),…,π(ik)} such that 1≤i1<⋯<ik≤n. It is an increasing subsequence if π(i1)<⋯<π(ik) and similarly for the decreasing subsequence. Consider the uniform measure μn on the discrete measurable space (Sn,2Sn), i.e., μn(π)=1/n! for any π∈Sn. For π∈Sn define Ln(π) to be the maximal length of an increasing subsequence of π, i.e., Ln(π) is the largest k such that there are integers 1≤i1<⋯<ik≤n so that π(i1)<⋯<π(ik). Similarly define Dn(π) to be the maximal length of a decreasing subsequence of π.
Since Ln is a random variable we can consider its expectation ℓn=E[Ln] on the probability space (Sn,2Sn,μn). It can be explicitly written as
ℓn=n!1π∈Sn∑Ln(π).
We want to study the limiting properties of the sequence {ℓn}n∈N. Specifically we will show that
nℓn→γ almost surely
for some constant γ. It is known that γ=2. We will not be showing this, but we will show that 1≤γ≤e.
We now prove some useful combinatorial results. The first result is called the Erdős–Szekeres theorem. We will need to prove lower and upper bounds for ℓn/n.
Theorem 1 [Erdős–Szekeres theorem]: In any sequence {a1,a2,…,amn+1} of mn+1 distinct real numbers, there exists either an increasing subsequence ai1<⋯<aim+1 of length m+1, where i1<⋯<im+1, or a decreasing subsequence aj1>⋯>ajn+1 of length n+1, where j1<⋯<jn+1.
For 1≤i≤mn+1 define ti to be the length of a longest increasing subsequence starting at ai, i.e., the first element of a longest increasing subsequence must be ai and the rest of the a's must have indices greater than i.
If ti≥m+1 for some i then we are done since we then have an increasing subsequence of length m+1, so assume ti≤m for all i. Since ti≥1, pigeonhole principle implies that there is some integer 1≤k≤m such that ti=k for at least n+1i's. Let ti=k for all i∈(j1<⋯<jn+1). Now note that if ajl<ajl+1 for some 1≤l≤n, then we would obtain an increasing subsequence of length k+1 starting at ajl because there is an increasing subsequence of length k starting at ajl+1. But this contradicts the fact that tjl=k, and thus ajl>ajl+1 for all 1≤l≤n. But now this gives us a decreasing subsequence aj1>⋯>ajn+1 of length n+1.
The next two theorems prove lower and upper bounds for ℓn/n.
Theorem 2: ℓn/n is lower bounded as follows: ℓn≥n for all n≥1.
Theorem 1 implies that Ln(π)Dn(π)≥n for each π∈Sn. Note that for each permutation π∈Sn there exists an inverse permutation π′ such that Ln(π)=Dn(π′), and thus we can write ℓn equivalently as ℓn=n!1π∈Sn∑Dn(π). Therefore, averaging the two ways of computing the expectation ℓn (Equations (1) and (4)) and using the AM-GM inequality we have
We start by getting an upper bound on the tail probabilities μn(Ln≥k) for 1≤k≤n by cleverly defining a random variable Xn,k, writing its expectation in two different ways, and then comparing.
If π∈Sn and 1≤k≤n let Xn,k(π) be the number of increasing subsequences of π which are of length k. These subsequences correspond exactly to those subsets S⊆{1,…,n} for which ∣S∣=k and if S={i1<⋯<ik} then π(i1)<⋯<π(ik). On the probability space (Sn,2Sn,μn), by the linearity of expectation, the expected value of Xn,k is given by the number of ways to select subsets of {1,…,n} with size k times the probability that a selection has all the elements in the increasing order. The number of ways is simply (kn) and the probability is 1/k! and thus
E[Xn,k]=k!1(kn).
The Taylor expansion of ex implies ex≥xk/k!. Substituting x=k in this inequality, we get k!≥(k/e)k. Therefore, we get
To be able to show (2) we will draw a correspondence between this problem of longest increasing subsequences and a seemingly unrelated problem called the Poissonized version. This Poissonized version will allow us to use the powerful Subadditive Ergodic Theorem (Theorem 5 below) to show (2).
To this end, assume an underlying probability space (Ω,F,P) and let N be a Poisson random measure on R+2 with mean measure given by the Lebesgue measure on R+2. In other words N:Ω×B(R+2)→R+ is a transition kernel from (Ω,F) to (R+2,B(R+2)) with ∫ΩP(dω)N(ω,A)=Leb(A) for any A∈B(R+2). We can view the random process as a sequence {(Xi,Yi)}i≥1 of independent random variables taking values in R+2 and having a uniform probability measure (more correctly, Lebesgue measure on (R+2,B(R+2))). If we let Rs,t denote the rectangle with vertices (s,s),(s,t),(t,t) and (t,s), then for each outcome ω∈Ω, we can think of having Poisson(Leb(Rs,t)) distributed number of such points inside the rectangle Rs,t.
For s<t∈[0,∞) let Zs,t be the random variable denoting the length of the longest increasing path lying in the rectangle Rs,t, i.e., Zs,t is the largest integer k for which there are points (X1,Y1),…,(Xk,Yk) in the Poisson process with s<X1<⋯<Xk<t and s<Y1<⋯<Yk<t.
Let τ(n) be the smallest value of t∈[0,∞) for which there are n points in R0,t. Let the n points in R0,τ(n) be written as {(Xi,Yi)}1≤i≤n such that 0<X1<⋯<Xn≤τ(n) (the inequalities are strict almost surely since they have continuous distributions). Let πn∈Sn be the unique permutation such that Yπn(1)<⋯<Yπn(n) (It is not difficult to see the existence and the uniqueness). Then
πn is a uniformly random sample of Sn, and Z0,τ(n)=Ln(πn).
The second claim is obvious from the definition of πn. The first claim is equivalent to showing that if U1,…,Un are i.i.d. random variables with a uniform distribution on [0,1] and if U(1),…,U(n) are the order statistics, i.e., U(k) is the kth smallest among U1,…,Un, then the probability that U(1),…,U(n) is the same as Uπ(1),…,Uπ(n) for some fixed π∈Sn is 1/n!. But this is obvious from the independence of Ui's. The next theorem is from Durrett:
Theorem 4: τ(n)/n→1 almost surely.
Let Sn be the number of points in R0,n. Since
(R0,n∖R0,n−1)∩(R0,m∖R0,m−1)=∅
for n=m, the definition of a Poisson random measure implies {Sn−Sn−1}n≥1 are independent Poisson random variables with mean 1. The strong law of large numbers now implies Sn/n→1 almost surely. For any ε>0 we can find an n large enough such that Sn(1−ε)<n<Sn(1+ε) but then this means n(1−ε)≤τ(n)≤n(1+ε) which is same as the statement of the theorem since ε was arbitrary.
This theorem along with (6) implies Z0,n→ℓn almost surely, or written differently nZ0,n→nℓn2 almost surely.
Having established the connection between the two ways of looking at the problem of longest increasing subsequences, we now freely jump between the two characterizations and use them to prove our results.
Define Ws,t=−Zs,t. We now check that Wm,n,0≤m<n satisfies the conditions required for the Subadditive Ergodic Theorem. I state the theorem below for completeness. Check out Theorem 6.4.1 in Durrett for a proof.
Theorem 5 [Subadditive Ergodic Theorem]: Suppose Wm,n for 0≤m<n satisfy:
W0,m+Wm,n≥W0,n,
{Wnk,(n+1)k,n≥1} is a stationary sequence for each k,
The distribution of {Wm,m+k,k≥1} does not depend on m, and
E[W0,1+]<∞ and infn≥1n1E[W0,1]=β>−∞.
Then
limn→∞n1E[W0,1]=β,
W=limn→∞n1W0,1 exists almost surely and in L1, and E[W]=β, and finally
if all stationary sequences in condition 2. above are ergodic, then W=β almost surely.
Coming back to the problem, let 0<m<n then we claim Z0,m+Zm,n≤Z0,n. To see this, fix ω∈Ω and let Z0,m(ω)=a and Zm,n(ω)=b. Then there exist
(X1(ω),Y1(ω)),…(Xa(ω),Ya(ω)),(Xa+1(ω),Ya+1(ω)),…,(Xa+b(ω),Ya+b(ω)) such that∙0<X1(ω)<⋯<Xa(ω)<m,∙0<Y1(ω)<⋯<Ya(ω)<m,∙m<Xa+1(ω)<⋯<Xa+b(ω)<n, and ∙m<Ya+1(ω)<⋯<Ya+b(ω)<n.
But then it's clear that 0<X1(ω)<⋯<Xa+b(ω)<n, 0<Y1(ω)<⋯<Ya+b(ω)<n and we have Z0,m(ω)+Zm,n(ω)≤Z0,n(ω). Since ω was arbitrary, our claim is true. Therefore, W0,m+Wm,n≥W0,n and condition 1. is true.
For condition 2. we want to show that {Wnk,(n+1)k,n≥1} is a stationary and ergodic sequence for all k≥1. This is clear from the observation that Zik,(i+1)k and Y0,k have the same distribution, since Leb(Rik,(i+1)k)=Leb(R0,k), and thus by the definition of the Poisson random measure the number of points in each rectangle is an i.i.d. Poisson random variable. Checking the condition 3. is similar to condition 2..
For condition 4. note that W0,1+=Z0,1 and Z0,1≤Poisson(1) since there are Poisson(1) number of points inside [0,1]2 and at most all of them can be arranged in the increasing order. Thus, E[W0,1+]<E[Poisson(1)]=1<∞. Now note that since W0,n=−Z0,n,
n≥1infn1E[W0,n]=−n≥1supn1E[Z0,n],
and thus to show the second part of condition 4. we need to show that supn≥1n1E[Z0,n]<∞. But this is immediate from Equation (5) in Theorem 3 and Equation (7). Therefore, the subadditive ergodic theorem now implies
nZ0,n→γ a.s.,
where γ, due to Equations (3) and (5), lies in [1,e] and we are done since this implies (2).
I got introduced to this problem from an exam question in a math course I took recently. I recommend the book The Surprising Mathematics of Longest Increasing Subsequences by Dan Romik, which is freely available online, for a lot more content.