Bounding sequence extremal functions with formations

An $(r, s)$-formation is a concatenation of $s$ permutations of $r$ letters. If $u$ is a sequence with $r$ distinct letters, then let $\mathit{Ex}(u, n)$ be the maximum length of any $r$-sparse sequence with $n$ distinct letters which has no subsequence isomorphic to $u$. For every sequence $u$ define $\mathit{fw}(u)$, the formation width of $u$, to be the minimum $s$ for which there exists $r$ such that there is a subsequence isomorphic to $u$ in every $(r, s)$-formation. We use $\mathit{fw}(u)$ to prove upper bounds on $\mathit{Ex}(u, n)$ for sequences $u$ such that $u$ contains an alternation with the same formation width as $u$. We generalize Nivasch's bounds on $\mathit{Ex}((ab)^{t}, n)$ by showing that $\mathit{fw}((12 \ldots l)^{t})=2t-1$ and $\mathit{Ex}((12\ldots l)^{t}, n) =n2^{\frac{1}{(t-2)!}\alpha(n)^{t-2}\pm O(\alpha(n)^{t-3})}$ for every $l \geq 2$ and $t\geq 3$, such that $\alpha(n)$ denotes the inverse Ackermann function. Upper bounds on $\mathit{Ex}((12 \ldots l)^{t} , n)$ have been used in other papers to bound the maximum number of edges in $k$-quasiplanar graphs on $n$ vertices with no pair of edges intersecting in more than $O(1)$ points. If $u$ is any sequence of the form $a v a v' a$ such that $a$ is a letter, $v$ is a nonempty sequence excluding $a$ with no repeated letters and $v'$ is obtained from $v$ by only moving the first letter of $v$ to another place in $v$, then we show that $\mathit{fw}(u)=4$ and $\mathit{Ex}(u, n) =\Theta(n\alpha(n))$. Furthermore we prove that $\mathit{fw}(abc(acb)^{t})=2t+1$ and $\mathit{Ex}(abc(acb)^{t}, n) = n2^{\frac{1}{(t-1)!}\alpha(n)^{t-1}\pm O(\alpha(n)^{t-2})}$ for every $t\geq 2$.


Introduction
A Davenport-Schinzel sequence of order s is a sequence with no adjacent repeated letters which has no alternating subsequence of length s+2. Upper bounds on the lengths of Davenport-Schinzel sequences provide bounds on the complexity of lower envelopes of solution sets to linear homogeneous differential equations of limited order [3] and on the complexity of faces in arrangements of arcs with a limited number of crossings [1].
A generalized Davenport-Schinzel sequence is an r-sparse sequence with no subsequence isomorphic to a fixed forbidden sequence with r distinct letters. Call a graph topological if it is drawn in the plane with vertices represented by points and edges represented by non-self-overlapping arcs between corresponding points. Call a topological graph simple if every pair of its edges intersect at most once. Call a topological graph k-quasiplanar if it has no k pairwise crossing edges. Fox et al. [5] used bounds on the lengths of generalized Davenport-Schinzel sequences to prove that simple k-quasiplanar graphs have at most (n log n)2 α(n) c k edges for a constant c k , such that α(n) denotes the inverse Ackermann function.

Terminology
A sequence s contains a sequence u if some subsequence of s can be changed into u by a one-to-one renaming of its letters. If s does not contain u, then s avoids u. The sequence s is called r-sparse if any r consecutive letters in s are pairwise different. If u is a sequence with r distinct letters, then the extremal function Ex (u, n) is the maximum length of any r-sparse sequence with n distinct letters which avoids u.
It is easy to show that if a and b are single letters, then Ex (a, n) = 0, Ex (ab, n) = 1, Ex (aba, n) = n and Ex (abab, n) = 2n − 1. Nivasch [9] and Klazar [8] proved lim n→∞ r ≥ 2 and odd s ≥ 5 with t = s−3 2 . Thus the bounds on F r,s (n) depend much more on s than they do on r.
Nivasch [9] used bounds on formation-free sequences to prove Ex (u, n) ≤ F r,s−r+1 (n) for any sequence u with r distinct letters and length s. Let fw (u), the formation width of u, be the minimum value of s such that there exists an r for which every (r, s)-formation contains u, and let fl (u), the formation length of u, be the minimum r such that every (r, fw (u))-formation contains u. By Nivasch's proof, fw (u) ≤ s − r + 1 for any sequence u with r distinct letters and length s.
If a t is an alternation of length t for t ≥ 2, then fw (a t ) ≤ t−1 since every (r, t − 1)-formation contains a t for r ≥ 2. Any (r, t − 2)-formation in which order of letters reverses in adjacent permutations avoids a t , so fw (a t ) = t−1.
Call an (r, s)-formation f binary if there exists a permutation p on r letters such that every permutation in f is either the same as p or the reverse of p. Let I c be the increasing sequence 12 . . . c on c letters, and let D c be the decreasing sequence c(c − 1) . . . 1 on c letters. Given a permutation π ∈ S c , let the sequences I π and D π be π(1)π(2) . . . π(c) and π(c)π(c − 1) . . . π(1) respectively.
Define up(l, t) as I l repeated t times, and alt (l, t) as a concatenation of t permutations, starting with I l and alternating between I l and D l . For example, up(3, 3) = 123123123 and alt (3, 3) = 123321123.

New results
In this paper we use formation width to derive new tight asymptotic bounds on several classes of generalized Davenport-Schinzel sequences. We also study the formation width of other classes of sequences since computing fw is an interesting combinatorial problem on its own, even in cases when fw (u) does not improve upper bounds on Ex (u, n).
In Section 2 we mention basic lemmas about fw (u), fl (u), and Ex (u, n). In Section 3.1 we prove γ(r, s) = (r − 1) 2 s−1 + 1 is the minimum function for which every (γ(r, s), s)-formation contains a binary (r, s)-formation. In Section 3.2 we determine fw (u) for every sequence u with two distinct letters, and we determine every sequence u for which fw (u) ≤ 3. We also show fw (up(c, t)) = 2t − 1 for all c ≥ 2 and t ≥ 1. In Section 4 we bound fw (u) up to a factor of 2 for every binary (r, s)-formation u.
Let u be any sequence of the form avav ′ a such that a is a letter, v is a nonempty sequence with distinct letters excluding a and v ′ is obtained from v by only moving the first letter of v. In Section 5 we show that fw (u) = 4, implying Ex (u, n) = θ(nα(n)).
In Section 5 we also use fw to prove that if t is 3 or 4 and z is any sequence of the form ax 1 ax 2 . . . ax t such that a is a letter and x i is a sequence equal to either bc or cb for each 1 ≤ i ≤ t, then Ex (z, n) = n2

Preliminaries
If u is a sequence with r distinct letters and c ≥ r, then let Ex c (u, n) be the maximum length of any c-sparse sequence with n distinct letters which avoids u. Klazar [6] showed that Ex c (u, n) = θ(Ex d (u, n)) for all fixed c, d ≥ r.
Lemma 2.1 implies fw (u) and fl (u) can be used to obtain upper bounds on Ex (u, n). Lemma 2.2. For any sequence u with r distinct letters and fixed c such that c ≥ r, Ex c (u, n) = O(F fl (u),fw (u) (n)).
The next two lemmas are simple facts about formation width which are used in later proofs. Lemma 2.3. If u begins with the letter a, then fw (au) = fw (u) + 1.
Lemma 2.4. If u is nonempty and v is obtained from u by inserting a single occurrence of a letter which is not in u, then fw (u) = fw (v).
If u is a sequence on the letters 1, . . . , c and π ∈ S c , then define l π (u) = k if u is a subsequence of I k π but u is not a subsequence of I k−1 π . Furthermore define l(u) = min π∈Sc {l π (u)}. In other words l(u) is the smallest k such that up(c, k) contains u. In Section 3.2 we prove fw (up(c, k)) = 2k − 1, implying that l(u) ≤ fw (u) ≤ 2l(u) − 1. In Section 4.1 we compute l(u) for every binary formation u.
Similarly if u is a sequence with c letters, then let r (u) be the smallest k such that alt(c, k) contains u. Then fw (u) ≥ r (u). We compute r (u) for every binary formation u in Section 4.2.

Binary formations
We determine the minimum function γ(r, s) such that every (γ(r, s), s)formation contains a binary (r, s)-formation. Then we use binary formations to compute fw (u) for every sequence u with two distinct letters. We also apply binary formations to find every sequence u for which fw (u) ≤ 3. All sequences u with fw (u) ≤ 3 satisfy F fl (u),fw (u) (n) = O(n) since F r,3 (n) = O(n) for every r, so Ex (u, n) = O(n) by Lemma 2.2.

An extension of the Erdos-Szekeres theorem
The following upper bound is obtained by iterating the Erdos-Szekeres theorem as in [6]. It generalizes an argument given by Klazar in [7]. Proof. By the Erdos-Szekeres theorem, every sequence of (x−1) 2 +1 distinct integers contains an increasing or decreasing subsequence of length x. We prove by induction on s that every ((r − 1) 2 s−1 + 1, s)-formation contains a binary (r, s)-formation.
For the inductive hypothesis fix s and suppose for every r ≥ 1 that each ((r − 1) 2 s−1 + 1, s)-formation contains a binary (r, s)-formation. Clearly this is true for s = 1. Consider any ((r − 1) 2 s + 1, s + 1)-formation F . Without loss of generality suppose the first permutation of F is an increasing sequence. By inductive hypothesis the first s permutations of F contain a binary ((r − 1) 2 + 1, s)-formation f . Therefore the last permutation of F contains an increasing or decreasing subsequence of length r on the letters of f . Thus F contains a binary (r, s + 1)-formation.
Corollary 3.2. If u has r distinct letters, then fw (u) is the minimum s for which every binary (r, s)-formation contains u.
Proof. If for some s every binary (r, s)-formation contains u, then by Lemma 3.1 there exists a function γ(r, s) such that every (γ(r, s), s)-formation contains u. Then fw (u) ≤ s.
The next theorem shows that the upper bound in Lemma 3.1 is tight. Proof. We construct the desired formation F (r, s) one permutation at a time. Define an α-block in F (r, s) to be a block of numbers in a permutation from positions (k − 1)(r − 1) α + 1 to k(r − 1) α for some k. For k ≤ s − 1 define a k-swap on a permutation of length (r − 1) 2 s−1 as follows: For every even i, 1 < i ≤ 2 k , a k-swap reverses the order of the (i − 1)2 s−k−1 -blocks in each i2 s−k−1 -block. For example if (r, s) = (3, 3), then a 1-swap on 1234567890ABCDEF produces CDEF 90AB56781234.
Let permutation 1 of F (r, s) be the identity permutation on the letters 1, . . . , (r − 1) 2 s−1 . To form permutation k + 1 of F (r, s), perform a k-swap on permutation k. The next lemma about F (r, s) will imply that F (r, s) avoids every binary (r, s)-formation. Proof. We induct on k. When k = 1, i (k) = 0. The entire permutation is a 2 s−1 -block and 0-blocks are individual elements, so the lemma is clearly true.
For the inductive hypothesis, suppose that in permutation k the elements of B are contained in a single (i (k) + 1)2 s−k -block, but different i (k)2 s−kblocks. Consider any set B of distinct numbers occurring in each of the first k + 1 permutations of F (r, s) with the same or reverse order in adjacent permutations. Now consider the k-swap that sends permutation k of F (r, s) to permutation k + 1. The parts of the swap that reverse the order of the (j − 1)2 s−k−1blocks in each j2 s−k−1 -block for j ≥ 2i (k) + 4 do not change the relative order of the elements of B since the elements of B are contained in a single (2i (k) + 2)2 s−k−1 -block. The parts of the swap that reverse the order of the (j − 1)2 s−k−1 -blocks in each j2 s−k−1 -block for j ≤ 2i (k) also do not change the relative order of the elements of B since the elements of B are contained in different (2i (k))2 s−k−1 -blocks. Thus the only part of the swap which is relevant to the order of the elements in B is the reversal of the order of the If the order of elements in B reverses from permutation k to permutation k + 1, then i (k + 1) = 2i (k) + 1. All the elements of B must be contained in different (2i (k) + 1)2 s−k−1 -blocks, or else the k-swap would not reverse their order. By inductive hypothesis the elements of B are contained in the same (i (k + 1) + 1)2 s−k−1 -block.
If the order of elements in B is the same in permutation k and permutation k+1, then i (k+1) = 2i (k). The elements of B must be contained in the same (2i (k) + 1)2 s−k−1 -block, or else the k-swap would not preserve their order. By inductive hypothesis the elements of B are contained in different i (k + 1)2 s−k−1 -blocks.
Given any set B of distinct numbers contained in every permutation of F (r, s) whose order either stays the same or reverses between adjacent permutations, there is some i such that the elements of B are in different i-blocks, but the same (i + 1)-block of permutation s. Since there are r − 1 i-blocks in each (i + 1)-block, then r − 1 is the maximum possible number of elements in B.

Using binary formations to compute fw
If u has one distinct letter, then fw (u) is the length of u. If u has two distinct letters, then fw (u) also depends only on the length of u. Lemma 3.6. If u has two distinct letters and length t, then fw (u) = t − 1.
Proof. By Lemma 2.3 it suffices to prove this lemma for sequences with different first and second letters. The upper bound follows since every (2, t− 1)-formation contains u. For the lower bound it suffices to construct a (2, t − 1)-formation f (u) which only contains copies of u for which the last letter of the copy of u is the last letter of f (u). Therefore the (2, t − 2)formation in the first t − 2 permutations of f (u) avoids u, so fw (u) > t − 2 by Corollary 3.2.
For each sequence u with two distinct letters and different first and second letters, the first permutation of f (u) is ab. If the first i permutations of f (u) are defined for i < t − 1, then permutation i + 1 of f (u) is the same as permutation i if and only if letters i + 1 and i + 2 of u are the same. Let u ′ denote the sequence obtained by deleting the last letter of u and suppose u has two distinct letters x and y. We prove by induction on the length of u that f (u) contains only copies of u for which the last letter of the copy of u is the last letter of f (u). The first case to consider is u = xy.
Since f (xy) = ab, then f (xy) contains exactly one copy of the sequence xy and the last letter of the copy of xy is the last letter of f (xy). Suppose by inductive hypothesis that f (u ′ ) contains only copies of u ′ for which the last letter of the copy of u ′ is the last letter of f (u ′ ). If the last two letters of u are the same, then the first letter of the last permutation of f (u) is different from the last letter of f (u ′ ), so the last letter of f (u) will be the last letter of any copy of u in f (u). If the last two letters of u are different, then the first letter of the last permutation of f (u) is the same as the last letter of f (u ′ ), so the last letter of f (u) will be the last letter of any copy of u in f (u).
If u has at least three distinct letters, then fw (u) cannot be determined solely from the length of u and the number of distinct letters in u. For example fw (abcabc) = 3 and fw (abccba) = 4.
The next lemma identifies all sequences u for which fw (u) = 3. As a result of Lemma 2.4, deleting any letters which occur just once in u will not change the value of fw (u) unless every letter in u occurs once. We call a sequence reduced if every distinct letter in the sequence occurs at least twice.
By Lemma 3.6, fw (u) = 1 if and only if u is nonempty and each distinct letter in u occurs once, and fw (u) = 2 if and only if one letter in u occurs twice and every other letter occurs once.
Lemma 3.7. If u is reduced and fw (u) = 3, then either there exists some l ≥ 2 for which u is isomorphic to up(l, 2) or u is isomorphic to one of the sequences aaa, aabb, abba, abcacb, abcbac, abccab, or abcdbadc.
Proof. Since u is reduced, then every distinct letter in u occurs at least twice. If any letter in u occurs three times, then it is the only letter in u and u is isomorphic to aaa, or else fw (u) ≥ 4 by Lemma 3.6. If u is not isomorphic to aaa, then every distinct letter in u occurs twice.
Suppose u is not isomorphic to up(l, 2) for any l ≥ 2. Then there exist two distinct letters x and y in u for which the subsequence consisting of occurrences of x and y is isomorphic to aabb or abba. If x and y are the only distinct letters in u, then u is isomorphic to aabb or abba.
If u has three distinct letters, then u is isomorphic to a sequence obtained by adding two occurrences of c anywhere in aabb or abba, so we consider 30 cases. If u has the form xxv or vxx for some letter x and sequence v of length 4 with two distinct letters not equal to x, then fw (v) = 3 by Lemma 3.6, so fw (u) = 4 by Lemma 2.3. This covers the cases when u is one of the sequences aabbcc, aabcbc, aacbbc, aabccb, aacbcb, aaccbb, acacbb, caacbb, accabb, cacabb, ccaabb, abbacc, or ccabba.
If u is one of the remaining sequences abcbac, acbbac, cabbca, or cabcba, then fw (u) = 3. Thus every reduced sequence u with three distinct letters for which fw (u) = 3 is a (3, 2)-formation. Note that acbbac and cabbca are isomorphic to abccab, and cabcba is isomorphic to abcacb.
If u has four distinct letters, then u is isomorphic to a sequence obtained by adding two occurrences of d to the sequence abcabc, abcacb, abcbac, or abccab. If u is not a (4, 2)-formation, then u contains a reduced sequence v with three distinct letters which is not a (3, 2)-formation, so fw (u) ≥ 4.
If u is abcdbadc, then fw (u) = 3. If u has five distinct letters, then u must be a (5, 2)-formation or else fw (u) ≥ 4. If u is any (5, 2)-formation with first permutation abcde, then every (4, 2)-formation in u is isomorphic to abcdbadc or up(4, 2). It is impossible for a (5, 2)-formation to have both a subsequence isomorphic to abcdbadc and another subsequence isomorphic to up(4, 2), so every (4, 2)-formation in u is isomorphic to abcdbadc or else u is isomorphic to up(5, 2). In particular u must have both abcdbadc and acdecaed as subsequences, a contradiction.
The last lemma can also be verified more easily by using the algorithm for computing formation width in the appendix. The next lemma provides a simple upper bound on fw (u) for every binary formation u. It is tight if u = up(l, t) for any l ≥ 2 and t ≥ 1.  Proof. For the lower bound fw (up(l, t)) ≥ fw ((ab) t ) = 2t − 1 since up(l, t) contains (ab) t . The upper bound fw (up(l, t)) ≤ 2t − 1 follows from the last lemma.
Therefore fw (u) = 2t − 1 for every sequence u such that u contains (ab) t and there exists l ≥ 2 for which up(l, t) contains u. As a corollary this implies the upper bounds in the next theorem, which gives nearly tight asymptotic bounds on Ex (up(l, t), n). The lower bounds in the next theorem follow from the lower bounds on Ex ((ab) t , n) in [9] by Lemma 2.1.

Bounding the formation width of binary formations
In this section we compute the exact value of l(u) and r (u) for every binary formation u. This yields upper and lower bounds on fw (u) which differ by at most a factor of two for every binary formation u.

Computing l
Lemma 4.1. If l π (I c ) = a and l π (D c ) = b, then a + b = c + 1.
Proof. Represent the permutation π by the set of points (i, π(i)). Connect points (i, π(i)) and (j, π(j)) if i < j and π(j) = π(i) + 1. This partitions the points into a connected sections. In a different representation connect points (i, π(i)) and (j, π(j)) if i < j and π(j) = π(i) − 1. This partitions the points into b connected sections.
We count the total number of endpoints of connected sections of points in both representations in two ways so that each connected section of points is considered to have two endpoints, even when the section consists of a single point. Since every connected section has two endpoints, then there are a total of 2(a+b) endpoints. Alternatively every point (i, π(i)) contributes two endpoints, unless π(i) = 1 or π(i) = c, in which case (i, π(i)) contributes three endpoints. Thus there are a total of 2c + 2 endpoints, so a + b = c + 1. If u and v are sequences on the letters 1, . . . , c, then l π (u) + l π (v) − 1 ≤ l π (uv) ≤ l π (u)+l π (v). Say that u and v π-overlap if l π (uv) = l π (u)+l π (v)−1. Then u and v π-overlap if and only if the last letter of u and the first letter of v π-overlap.
For each π ∈ S c , the sequences I c and D c do not π-overlap since the last letter of I c is the first letter of D c , and D c and I c do not π-overlap since the last letter of D c is the first letter of I c . Furthermore if c ≥ 2, then exactly one of the two sequences I c or D c π-overlaps itself, depending on the order in which the first and last letters of I c occur in I π . Moreover for any sequence u, if l π (u) = 1 then u does not π-overlap itself. Fix an arbitrary π ∈ S c and let l π (I c ) = a and l π (D c ) = b. We show l π (u) ≥ (c − 1)m + M + ⌊ n 2 ⌋ by considering two cases depending on whether I c or D c π-overlaps itself.
Case 1: I c π-overlaps itself. In this case l π (I e i c ) = (a − 1)e i + 1 and l π (D e i c ) = be i . Since I c and D c do not π-overlap and D c and I c do not π-overlap, then l π (u) = (a − 1)A + bB + ⌈ n 2 ⌉. Lemma 4.1 implies (a − 1) + b = c, while b > 0 and a > 1 since I c π-overlaps itself. Then the minimum possible value of l π (u) is (c − 1)m + M + ⌈ n 2 ⌉. Case 2: D c π-overlaps itself. In this case l π (I e i c ) = ae i and l π (D e i c ) = (b − 1)e i + 1, so l π (u) = aA + (b − 1)B + ⌊ n 2 ⌋. Moreover a + (b − 1) = c, a > 0, and b > 1. Then the minimum possible value of l π (u) is (c − 1)m + M + ⌊ n 2 ⌋. Thus in either case l π (u) ≥ (c−1)m+M +⌊ n 2 ⌋. If A ≥ B, then this value is attained by letting π be the identity permutation. If B > A, then this value is attained by letting π(1) = 1 and π(i) = c + 2 − i for 2 ≤ i ≤ c.

Computing r
For every binary formation u we compute r (u), and we identify when r (u) > l(u). Proof. First we show that r (I x c ) = 2x − 1 for every x > 0. The upper bound is trivial. For the lower bound we also show that alt (c, 2x − 1) has the subsequence I x π only if π(c) = c. We proceed by induction on x. Clearly r (I c ) = 1. In addition, I π is a subsequence of I c only if π is the identity permutation, so π(c) = c. For the inductive hypothesis assume that r (I x c ) = 2x − 1 and that alt(c, 2x − 1) has the subsequence I x π only if π(c) = c. We claim that r (I x+1 c ) = 2x + 1 and that alt (c, 2x + 1) has the subsequence I x+1 π only if π(c) = c. Let π be an arbitrary permutation. We will first show I x+1 π is not a subsequence of alt (c, 2x). Suppose for contradiction that I x+1 π is a subsequence of alt(c, 2x). Then I x π is a subsequence of alt(c, 2x − 1), so π(c) = c. Then the last letter in I x+1 π must be the first letter of the last permutation of alt (c, 2x), a contradiction. Thus r (I x+1 c ) = 2x + 1. We still must show that alt (c, 2x + 1) has the subsequence I x+1 π only if π(c) = c. Suppose π(c) = i for some 1 ≤ i < c, and assume for contradiction that I x+1 π is a subsequence of alt(c, 2x + 1). Since I x π is not a subsequence of alt (c, 2x − 1), then the second to last i in I x+1 π must occur in the second to last permutation of alt (c, 2x + 1) and the last i in I x+1 π must occur in the last permutation of alt(c, 2x + 1). Since i < c, then there are at most c − 2 distinct letters between the occurrences of i in the last two permutations of alt (c, 2x + 1), a contradiction. Thus alt(c, 2x + 1) has the subsequence I x+1 π only if π(c) = c. This completes the induction.
By symmetry we find that r (D x c ) = 2x − 1 for every x > 0. We now prove the claim that r (I e 1 c D e 2 c I e 3 c · · · L en c ) = 2 n i=1 e i − n. The upper bound is trivial since 2 n i=1 e i − n = n i=1 (2e i − 1). For the lower bound, suppose for some k and permutation π that alt (c, k) has the subsequence I e 1 π D e 2 π I e 3 π · · · L π en with n sections of the form I x π or D x π . No section I x π or D x π can occur in fewer than 2x − 1 adjacent permutations of alt(c, k).
Furthermore no different sections have letters occurring in the same permutation. Thus alt (c, k) contains at least 2 n i=1 e i − n permutations, so k ≥ 2 n i=1 e i − n.

Further bounds on extremal functions using fw
The lemmas in this section use Corollary 3.2 to identify sequences u with fw (u) > 3 for which fw (u) provides tight upper bounds on Ex (u, n), starting with an infinite set of sequences which contain ababa.
Lemma 5.1. If u is any sequence of the form avav ′ a such that a is a letter, v is a nonempty sequence with distinct letters excluding a and v ′ is obtained from v by only moving the first letter of v, then fw (u) = 4.
Corollary 5.2. If u is any sequence of the form avav ′ a such that a is a letter, v is a nonempty sequence with distinct letters excluding a and v ′ is obtained from v by only moving its first letter, then Ex (u, n) = θ(nα(n)).
Proof. The upper bound follows from the last lemma and Lemma 2.2, while the lower bound follows by Lemma 2.1 since u contains ababa.
The next corollary is obtained by reversing the sequences considered in the last lemma.
Corollary 5.3. If u is any sequence of the form avav ′ a such that a is a letter, v is a nonempty sequence with distinct letters excluding a and v ′ is obtained from v by moving a single letter in v to the end, then fw (u) = 4 and Ex (u, n) = θ(nα(n)).
The next lemma implies that if v and v ′ are nonempty permutations of the same distinct letters excluding a, then fw (avav ′ a) = 4 if and only if v ′ is obtained from v by only moving the first letter of v or by only moving a single letter in v to the end.
Lemma 5.4. If u is any sequence of the form avav ′ a such that a is a letter, v is a nonempty sequence with distinct letters excluding a and v ′ is a permutation of v which cannot be obtained from v by only moving the first letter of v or by only moving a single letter in v to the end, then fw (u) > 4.
Proof. First note that fw (x) > 4 if x is abcdadbca, abcdadcba, abcdeabdcea, or abcdeacbeda. This can be verified using the formation width algorithm in the appendix. Suppose u is a sequence of the form 0v0v ′ 0 for which fw (u) = 4, v is the sequence 12 . . . r, and v ′ is the permutation π 1 π 2 . . . π r of 12 . . . r. Since u avoids abcdadbca and abcdadcba, then π i ≤ i + 1 for each 1 ≤ i ≤ r.
Consider two cases. In the first case, π 1 = 1. If π i = i for each 1 ≤ i ≤ r, then fw (u) = 4 since fw (up(r + 1, 2)) = 3. Otherwise let m be minimal for which π m = m+1. Then π j = j for each j < m. Since u avoids abcdeabdcea, then π r = m. Moreover π j = j + 1 for m ≤ j < r since π i ≤ i + 1 for each 1 ≤ i ≤ r. Thus v ′ can be obtained from v by only moving a single letter in v to the end.
In the second case, π 1 = 2. Let m be the index for which π m = 1. Then π j = j + 1 for 1 ≤ j < m since π i ≤ i + 1 for each 1 ≤ i ≤ r. Since u avoids abcdeacbeda, then π j = j for each j > m. Thus v ′ can be obtained from v by only moving the first letter of v.
For t ≤ 4 the next lemma exhibits sequences with three distinct letters and t occurrences of each letter which contain (ab) t and have formation width 2t − 1.
Lemma 5.5. If t is 2, 3, or 4 and z is any sequence of the form ax 1 ax 2 . . . ax t such that a is a letter and x i is a sequence equal to either bc or cb for each 1 ≤ i ≤ t, then fw (z) = 2t − 1.
Proof. The lower bound follows since z contains (ab) t . By Corollary 3.2, the upper bound is verified by checking that every binary (3, 2t − 1)-formation contains z. The appendix has a program for running this check.
Corollary 5.6. If t is 3 or 4 and z is any sequence of the form ax 1 ax 2 . . . ax t such that a is a letter and x i is a sequence equal to either bc or cb for each Proof. The upper bounds follow from the last lemma and Lemma 2.2. The lower bounds follow from the bounds on Ex ((ab) t , n) in [9] by Lemma 2.1.
There are sequences z of the form ax 1 ax 2 ax 3 ax 4 ax 5 such that a is a letter and x i is a sequence equal to either bc or cb for each 1 ≤ i ≤ 5 for which fw (z) > 9. For example fw (abcacbacbabcacb) = 10.
The following lemma finds another infinite class of forbidden sequences with three distinct letters for which formation width yields tight bounds on extremal functions. Lemma 5.7. fw (abc(acb) t ) = 2t + 1 for t ≥ 0.
Proof. The proof is trivial for t = 0, so suppose t > 0. Since abc(acb) t contains an alternation of length 2t + 2, then fw (abc(acb) t ) ≥ 2t + 1. In order to prove fw (abc(acb) t ) ≤ 2t + 1, it suffices by Corollary 3.2 to show that every binary (3, 2t + 1)-formation contains abc(acb) t . Consider any binary (3, 2t + 1)-formation f with permutations xyz and zyx. Without loss of generality suppose the last 2t − 1 permutations of f have the subsequence (xyz) t . Then f has the subsequence xzy(xyz) t unless the first six letters of f are zyxxyz. If the first six letters of f are zyxxyz, then f has the subsequence zyx(zxy) t .
Proof. The upper bounds follow from the last lemma and Lemma 2.2. The lower bounds follow from the bounds on Ex ((ab) t , n) in [9] by Lemma 2.1.
Proof. First we prove for every permutation π ∈ S c that I π D π I π is not a subsequence of the binary (c, c + 2)-formation I c c D 2 c . Assume for contradiction that I c c D 2 c has the subsequence I π D π I π for some permutation π ∈ S c . Since l(I c D c ) = c + 1 by Lemma 4.1, then the last letter of D π must be in the first D c in I c c D 2 c . However, the first letter of I π is the same as the last letter of D π , so the first letter of the last I π in I π D π I π must be in the last D c in I c c D 2 c . Then I π = D c , so the last letter of D π is c. This would imply I c c c has the subsequence I π D π . Since the last letter of I c c is c, then I π D π would be a subsequence of I c c , a contradiction. Thus I c c D 2 c does not have I π D π I π as a subsequence for any permutation π ∈ S c . Thus fw (I c D c I c ) > c + 2 by Corollary 3.2. Now we show why every binary (c, c + 3)-formation f has a subsequence I π D π I π for some permutation π ∈ S c . Without loss of generality suppose the first permutation of f is I c . If f is I c+3 c , then f has I c D c I c as a subsequence. If f has an alternation of I c and D c terms of length at least 3, then also f must have I c D c I c as a subsequence. Otherwise f has the form I a c D b c with a+b = c+3, a > 0 and b > 0. If a ≤ 2, then f has I c D c I c as a subsequence. If b ≤ 2, then f has D c I c D c as a subsequence. Otherwise f has the subsequence I π D π I π , such that I π is the sequence 1 . . . (b − 2)c . . . (b − 1) consisting of the integers from 1 to b − 2 followed by the integers in reverse from c to b − 1. In other words I π is obtained by reversing the last a − 1 letters of I c . Thus fw (I c D c I c ) ≤ c + 3 by Corollary 3.2.
We prove two lemmas to use for the lower bounds in the remaining theorems.
Lemma 6.2. If c ≥ 2 and π ∈ S c , then I π D π is a subsequence of I c c D c if and only if π(1) < π(2).
Since T k avoids I k For the second case of the inductive hypothesis, assume that T j−1 avoids alt (c, j) for all j ≤ 2k, but suppose for contradiction that T 2k has the subsequence (I π D π ) k I π for some permutation π ∈ S c . Let G be the leftmost (I π D π ) k in the subsequence (I π D π ) k I π . Since the leftmost T 2k−1 in T 2k avoids G, then the last letter of G must occur in the last D 2 c in T 2k . The last letter of G is equal to the first letter of the last permutation of (I π D π ) k I π , so the last I π of (I π D π ) k I π must be a subsequence of the final D c in T 2k . Therefore I π = D c , so the last letter of D π is c. This would imply T 2k−1 c has the subsequence (I π D π ) k , so (I π D π ) k would be a subsequence of T 2k−1 , a contradiction. Thus (I π D π ) k I π is not a subsequence of T 2k for any permutation π ∈ S c . #input sequences must have integer alphabets, for example: #print fw((0,1,2,3,4,5,6,0,2,3,1,4,5,6,0))