For two decreasing runs separated by one entry, a fixed block limit suffices exactly when the runs match in length
Why it matters
How should you arrange a long list of numbers so that a particular order appears as often as possible? For two descending runs separated by one entry, a fixed number of decreasing blocks can reach the limiting frequency if the runs are equally long. If their lengths differ by even one, allowing one more block improves on any fixed limit of three or more.
How should we arrange a long list of distinct numbers so that entries picked from it occur in a particular order as often as possible? Consider the order 321\mid4\mid65. Read from left to right, the first three entries decrease, the next entry exceeds all three, and the last two decrease but both exceed the middle entry. To make this order frequent, we can build the list itself from decreasing blocks, placing smaller values in earlier blocks. The question is whether we can choose a fixed number of blocks and reach the highest possible frequency as the list grows, or whether we need ever more blocks.
For patterns with two decreasing end blocks of lengths a,b\ge2 separated by a single entry, the answer depends only on whether the end lengths match. Equal lengths allow a fixed number of blocks. For unequal lengths, increasing the limit from K blocks to K+1 strictly improves the best limiting frequency for every K\ge3, even when the lengths differ by just one.
Measuring pattern frequency
A list of distinct numbers can be written as a permutation by replacing each number with its rank. A permutation is layered if it consists of decreasing blocks, called layers, with every value in a block smaller than every value in later blocks. The example 321\mid4\mid65 has layer lengths (3,1,2). A copy is any choice of six positions whose entries, read in order, have these relative ranks. The fraction of six-position choices that give a copy is the pattern's density in the list. Its packing density is the limit, as list length grows, of the greatest density among all permutations of that length. Stromquist's theorem lets us restrict the search to layered lists: for a layered pattern, some layered permutation achieves the maximum at each length [3, §1].
Albert and colleagues stated that a bounded number of layers suffices to approach the packing density for every pattern (a,1,b) with a,b\ge2 [1, Proposition 2.8]. Hästö suggested that four layers might suffice when the end lengths are close [2, §4]. Kabela and colleagues disproved the general claim. When a is sufficiently large relative to b, the layer count tends to infinity in every sequence of layered permutations approaching the packing density. Their explicit example was (13,1,2) [3, Theorem 3]. They also settled the case a=b: a constant depending only on the pattern bounds the number of layers in every layered permutation that achieves the exact maximum for its length [3, Theorem 5]. The strict improvement proved here settles the remaining cases, starting with (3,1,2).
Let x_i be the fraction of the list in layer i, so the fractions sum to one. A copy uses a entries from one layer, the single middle entry from a later layer, and b entries from a still later layer. The score
adds the contributions from all such layer triples. Write d=a+1+b for the pattern length. To get the limiting density, multiply the score by d!/(a!b!), the number of ways to assign d independent draws to the three layers in the required counts. With d fixed, sampling positions without replacement gives the same limit as drawing independently.
Any choice of layer fractions can be realized in the limit by rounding the layer sizes in successively longer lists. For a limit of K layers, we can represent shorter arrangements by padding their vectors of fractions with zeros. The nonnegative fractions summing to one form a closed simplex, on which the continuous score has a maximum. Call it M_K. It is the best limiting score with at most K layers.
A split improves all 21 unequal cases on a four-layer grid
For each of the 28 pairs 2\le b\le a\le8, we divided 120 units of mass into three or four layers. We scored every ordered division into positive parts: 7,021 divisions for three layers and 273,819 for four. For a given pattern all scores shared a denominator, so we could compare them exactly using integer powers. For each arrangement tied for the highest four-layer score, we split a thin piece from the front of its second layer to form a new layer, leaving the others unchanged.
| Outer lengths | Pairs tested | Four-layer grid winners | Winners improved by a thin split |
|---|---|---|---|
| Equal | 7 | 13 | 1 |
| Differ by one | 6 | 6 | 6 |
| Differ by two or more | 15 | 15 | 15 |
Table 1. Each tied arrangement counts as a separate winner. A split counts as an improvement if the score has positive derivative with respect to the width of the new layer at width zero. Direct evaluation also gave a strict gain for every unequal winner when the new layer occupied 1/1{,}200{,}000 of the list.
The grid also illustrates the role of rounding. For (6,1,6), splitting improved one of two tied winners, although four layers suffice for this pattern [2, §4; 3, Theorem 5]. On a finer grid of 1,200,000 units, we transferred mass between layers to improve the four-layer arrangement. The positive derivative disappeared. To establish the gain for unequal ends, we therefore consider a maximum over all real layer fractions at any fixed layer limit.
How small can the first layer be?
The proof compares two changes to a maximizing arrangement. Deleting its first layer and redistributing that layer's share of the list keeps us within the layer limit, so it cannot raise the score. This puts a lower bound on the size of the first layer. We will show that splitting the second layer must help unless the first layer falls below that bound.
Take a>b and choose an arrangement with score M_K for K\ge3. Discard layers of zero size and call the fractions in the first two layers p and y. We call these fractions masses. There must be at least three positive masses, since a three-layer list already gives a positive score.
At the maximum, a small transfer of mass between any two positive layers has zero first derivative. Thus the partial derivatives of F with respect to their masses are equal. Their common value is dF: multiplying each partial derivative by its layer mass and adding counts every term of degree d in F exactly d times. The first layer can supply only the first block of a copy. Every term lost by deleting it therefore contains p^a, so the lost score is p\,\partial_p F/a=(dp/a)F, where \partial_p F denotes the partial derivative with respect to p. The surviving layers have total mass 1-p. Scaling them back up to unit total mass multiplies their score by (1-p)^{-d}. Since the resulting score cannot exceed F, deletion requires
When does splitting the second layer help?
First we need to compare the first two masses. Call the layers after them the tail, and write C=\sum_k x_k^b and B=\sum_{j<k}x_j x_k^b, with all indices in the tail. Here C counts the weight of choices of a final block in the tail, and B the weight of choices of both a middle entry and a final block there. Apart from copies wholly in the tail, the score is
Swapping p and y would increase the last term if p<y, so p\ge y. Transferring mass from y to p has zero derivative at the maximum, giving
The first term is nonnegative and C>0, so y\le p/a. Both comparisons are due to Kabela and colleagues [3, Claims 7.1–7.2].
Now replace y by two successive layers of masses t and y-t. Copies that used the second layer for their middle entry can use either piece, with the same total weight. Copies that used it for their first block lose weight at rate a y^{a-1}B at t=0. The gain comes from copies using the first three layers: the piece of mass t supplies the middle entry and the rest of the split layer supplies the final block. These copies have weight p^a t(y-t)^b. Other new terms involving both pieces contain t^a and have zero derivative at zero. Thus a nonpositive derivative for the split would require
Dividing by y^b leaves a power y^{a-1-b} on the right. Even a one-entry difference between the ends makes this exponent nonnegative, so y\le p/a gives p^{b+1}\le a^{b+2-a} B. For equal ends the power would be y^{-1}, and the same comparison would give no upper bound.
Let s be the total mass of the tail. To bound B, first scale the tail to mass one. A layer of normalized mass z chosen for the final block has at most 1-z mass before it from which to choose the middle entry. Its contribution to the normalized sum is therefore at most (1-z)z^b. On [0,1], the maximum of (1-z)z^{b-1} is c_b=(b-1)^{b-1}/b^b. Summing the bounds c_b z over the tail layers and restoring their scale gives B\le c_b s^{b+1}. Since s\le1-p, a nonpositive split derivative would require the ratio r=p/(1-p) of first-layer mass to remaining mass to satisfy
The middle inequality follows because either a=b+1 or the exponent of a is nonpositive. For the last inequality, the binomial theorem gives b c_b=(1+1/(b-1))^{-(b-1)}\le1/2, and (b+1)/b\le3/2.
Why one more layer always helps for unequal ends
Every first layer small enough to satisfy (2) would make deletion profitable. To see why, set n=b+1\ge3, so a\ge n and d=a+n. Substituting p=r/(1+r) in the deletion requirement (1) gives
Suppose the split requirement (2) also holds. Write u=r^n, so 0<u\le3/4 and 0<r<1. Since a\ge n, the left side of the deletion requirement is at least (1+r)^{2n-1}(1-r). To bound this product from below, separate it into two factors. For the first, the binomial theorem gives (1+r)^{n-1}\ge 1+r+\cdots+r^{n-1}; multiplying by 1-r gives (1+r)^{n-1}(1-r)\ge1-u. The second factor, (1+r)^n, is at least 1+(2^n-1)u, since every positive power through r^n is at least u. The left side of the deletion requirement is therefore at least
where the strict inequality follows from (2^n-1)(1-u)\ge7/4. This contradicts (1).
Deletion cannot improve a maximizing arrangement, so the split must have positive derivative. Every sufficiently small t>0 then raises the score using at most one extra layer. This proves M_{K+1}>M_K for every K\ge3. Reversing the list of layer masses exchanges a and b, so the result also holds when the longer end block comes last.
Consequently, any sequence of layered permutations approaching the packing density for unequal ends must eventually exceed every fixed layer limit K. Otherwise we could select increasingly long lists with at most K layers and then a subsequence whose layer fractions converge. Its limiting score could be at most M_K, even though the strictly larger M_{K+1} is attainable in the limit. Together with the equal-end theorem [3, Theorem 5], this determines exactly when a fixed layer limit suffices. The size of the density gap at a given limit remains open.
References
- M. H. Albert, M. D. Atkinson, C. C. Handley, D. A. Holton and W. Stromquist. On packing densities of permutations. Electronic Journal of Combinatorics 9 (2002), R5.
- P. Hästö. The packing density of other layered permutations. Electronic Journal of Combinatorics 9(2), R1.
- A. Kabela, D. Kráľ, J. A. Noel and T. Pierron. Density maximizers of layered permutations. Theorems 3 and 5, and proof of Theorem 7.