• No results found

Counting words avoiding patterns of length three with generating functions

N/A
N/A
Protected

Academic year: 2021

Share "Counting words avoiding patterns of length three with generating functions"

Copied!
48
0
0

Loading.... (view fulltext now)

Full text

(1)

Counting words avoiding patterns of length

three with generating functions

Joakim Andersson Jakob Wiesinger

joakim8@kth.se jakobwie@kth.se May 21, 2015

Degree Project in Engineering Physics, SA104X Supervisor: Petter Brändén

(2)

Abstract

The set of 123-avoiding words with exactly r occurrences of each letter was recently enumerated by N. Shar and D. Zeilberger. This paper enumer-ates more complicated sets of pattern avoiding words, such as those allowing 1, 2, ...or r occurrences of each letter, or those for which the numbers of occur-rences of each individual letter follow a repeating sequence. The results are also generalized to apply to all patterns of length three with distinct letters. The generating functions enumerating the words are shown to be algebraic, for all investigated sets of words. A notable number of coecients for the relevant generating functions have been found and the rst few conrmed by independent methods. The asymptotic behaviour of these coecients has been established as exponential. The employed strategy involves partitioning words into subwords which allow for the construction of equations relating the generating functions.

Sammanfattning

Mängden av 123-undvikande ord med exakt r förekomster av varje bokstav enumererades nyligen av N. Shar och D. Zeilberger. Detta arbete enumererar mer komplicerade mängder av mönsterundvikande ord, såsom de som tillåter 1, 2, ...eller r förekomster av varje bokstav, eller de för vilka antalet förekom-ster av varje enskild bokstav följer en upprepande sekvens. Resultaten gener-aliseras även till att gälla alla mönster av längd tre med distinkta bokstäver. De genererande funktionerna som enumererar orden bevisas vara algebraiska, för alla undersökta ordmängder. Ett ansenligt antal koecienter för de rel-evanta genererande funktionerna har beräknats och de första av dessa har bekräftats med oberoende metoder. Dessa koecienters asymptotiska be-teende har visats vara exponentiellt. Metoden som utnyttjas involverar en uppdelning i delord som tillåter konstruerandet av ekvationer som relaterar de genererande funktionerna.

(3)

Contents

1 Introduction 4

1.1 Words and pattern avoidance . . . 4

1.2 Generating functions . . . 5

1.3 Introduction to the problems . . . 7

1.4 Algebraic functions and asymptotics . . . 8

1.5 Methods for retrieving coecients from equations in generat-ing functions . . . 9

1.6 Basic combinatorics . . . 11

2 Symmetry in patterns and letters 13 2.1 Symmetry of 123-avoidance and 132-avoidance . . . 13

2.2 A recurrence relation for A . . . 15

2.3 Argument symmetry in A . . . 15

2.4 Finishing the pattern symmetry proof . . . 16

3 Solving the problems 16 3.1 Preparations . . . 17 3.2 Problem 1 . . . 18 3.3 Problem 2 . . . 20 3.4 Problem 3 . . . 24 3.5 Problem 4 . . . 27 3.6 Problem 5 . . . 29 3.7 Problem 6 . . . 33

(4)

B Calculating coecients in Problem 2 using Taylor series 40 C Alternative solution to Problem 3 42

(5)

1 Introduction

Pattern avoidance is a branch of combinatorics which has seen a lot of recent developments. Most attention has been directed towards the task of enumer-ating pattern-avoiding permutations, but recently the enumeration of words has been targeted. A result which heavily inuenced the direction of this thesis is by N. Shar and D. Zeilberger, investigating 123-avoiding words with r occurrences of each letter [1]. This paper investigates pattern avoidance in words with more complex letter congurations. Generating functions are the primary tool used in this task.

The investigations will be performed systematically by specifying a set of problems in Section 1.3 and solving them in Section 3.

The subsections 1.1 and 1.2 introduce the concepts of pattern avoidance and generating functions, respectively. The following subsections present various necessary prerequisites for solving the problems, including some theorems. Section 2 presents two kinds of symmetries: a symmetry in patterns used to generalize the results and a symmetry in letters used as a tool to solve the problems.

A Java package which can be used to verify the retrieved coecients by counting will be uploaded to [2]. A Mathematica notebook le for calculating the coecients from the derived formulas will also be available.

1.1 Words and pattern avoidance

A word is dened as an ordered sequence of integers, where the integers are called letters. Any word can be considered a pattern, and it is said that a word W contains the pattern P if there exists a subsequence of (not necessarily consecutive) letters of W that has the same relative order as P . If W doesn't contain P , W avoids P . For example, 53142 contains the pattern 231 since the subsequence 342 has the same relative order as 231; the letters in both, ordered by ascending value, are at positions 3,1,2.

Words can also be thought of as permutations of a multiset. For multisets we use the notation 1a12a2...sas. If W is a permutation of 1a1...sas, this means

that W contains exactly ai occurrences of the letter i. For a = (a1, a2, ..., as)

we dene W(a) as the set of permutations of 1a12a2...sas, and W as the union

(6)

i.e. (ai > 0 ∧ ak > 0 ∧ i < j < k) ⇒ aj > 0. We also dene WP(a) and

WP as the subset of P -avoiding words in W(a) and W, respectively.

We use the notation |W | to mean the length, or number of letters of W .

1.2 Generating functions

Generating functions can be seen as a way to represent sequences of numbers. The generating function corresponding to the sequence (fi)∞i=0 is the formal

power series P∞

i=0fixi. Here x is mostly treated strictly as a symbol; we do

not concern ourselves with the values for which the series converges. This is because we use generating functions solely as a way to make and relate statements about the corresponding sequences, and most statements about generating functions can be reduced to statements about sequences. For example, if F = P∞

i=0fix

i and G = P∞ i=0gix

i, then the statement F = xG

can be reduced to f0 = 0 ∧ (∀i ≥ 0 : fi+1 = gi):

F = xG ∞ X i=0 fixi = x ∞ X i=0 gixi f0+ ∞ X i=0 fi+1xi+1= ∞ X i=0 gixi+1 f0+ ∞ X i=0 (fi+1− gi) xi = 0

A power series is identically zero if and only if all the coecients are zero. The desired reduction follows. Thus, it doesn't matter if F and G only converge for x = 0, since we're only using generating functions as a shortcut for expressing statements about sequences of numbers.

The operator [xd] is dened by [xd]P∞

i=0fix i = f

d. In other words, [xd]F

yields the coecient of xd in F .

Typically, a generating function represents a sequence of the number of se-lections one can make based on the number of object to choose from. For example, let's say we're making a fruit salad. We have three apples, four pears and one orange, and each fruit salad must contain at least one apple

(7)

and the orange. We may also choose to paint any number of pears blue. Then the sequence (ai)∞i=0, where ad is the number of ways to pick d apples,

is (0, 1, 1, 1, 0, 0, 0, 0, 0...), because (assuming the apples are indistinct) there is one way to select one apple, one way to select two apples, and one way to select three apples. The corresponding generating function is A = x+x2+x3.

The "pear function" is P = 1 + 2x + 3x2+ 4x3+ 5x4, because there are d + 1

ways of selecting d pears: with j of them painted blue, for 0 ≤ j ≤ d. The "orange function" is O = x, because we may only have one orange (so there are "zero ways" of selecting any other number of oranges) and there is only one way of selecting it: by selecting it.

Now here is one of the biggest perks of working with generating functions that doesn't require advanced theory: multiplication. We can get the "fruit salad function" F , where the coecients fd are the number of ways to make

a fruit salad with d fruits, as F = AP O. Let's rst consider fruit salads with only apples and pears:

F0 = AP = x + x2+ x3 1 + 2x + 3x2+ 4x3 + 5x4 (1) To see why this is true, consider each x to represent a fruit. f0

3 is the number

of ways of selecting three fruits, which is the number of ways of selecting three x:es in (1). We can do this by selecting no x from A (the x0 term, with

coecient 0) and three x from P , or one x from A and two from P , or two from A and one from P , or three from A and none from P . Reecting this, the x3term in (1) is x·3x2+x2·2x+x3·1 = 3x1+2+2x2+1+x3+0= 6x3. Notice

how the coecients are multiplied and the exponents are added, because if there is one way of selecting an apple and three ways of selecting a pear, there are 1 · 3 ways of selecting an apple and two pears. But we're selecting one apple and two pears, so we're selecting 1 + 2 fruits in total. In general:

(8)

fd0 =number of ways to select d fruits

=number of ways to select 0 apples and d pears +number of ways to select 1 apple and d − 1 pears +...

+number of ways to select d apples and 0 pears = a0pd+ a1pd−1+ ... + adp0 = d X i=0 aipd−i

Finally, we get F by multiplying F0 = AP with O = x, increasing the

exponent of each term in F0 by 1, which reects the fact that each fruit salad

has simply had an orange added to it.

1.3 Introduction to the problems

The properties of pattern avoidance will be investigated by solving the fol-lowing six problems of the form "nd the generating function F such that each coecient [xd]F is equal to the number of d-length words that avoid

pattern P and satisfy such-and-such additional restrictions". In addition to nding the coecients [xd]F, their asymptotic behaviour is also of interest.

We will only consider words in W, because without this limitation, a problem like "how many 231-avoiding words of length 5 are there with at most two of each letter?" would have innitely many solutions. Words are only mean-ingfully distinct insofar as the relative orders of their letters are dierent, so all words that have the relative order 3, 4, 2, 3, 1 can be thought of as an equivalence class represented by the word 34231, which is the only one of those words in W.

Initially we will only consider 231-avoidance; in other words we'll only be concerned with words in W231. In each of the following problems we will

impose a dierent further restriction on what words we're considering, such as ∀i : ai ≤ 2. The task will then be to nd the amount fd of such words

for a given word length d, which will be done by considering the generating function F = P∞

i=0fixi. F can also be expressed as the sum PW ∈wx |W |

(9)

of xd-terms in the sum is equal to the number of d-length words in w, which

is fd. F is called the weight enumerator of w with respect to the weight

W 7→ x|W |.

After solving the problems with restriction to the pattern 231, the results can be generalized to any pattern of length three with distinct letters, as we prove in section 2.

In problem 1, ai = 1 for i ≤ s. We also allow the empty word ∅.

In problem 2, ai ≤ 2 for all i. We also allow the empty word ∅.

In problem 3, ai ≤ 3 for all i. We also allow ∅.

In problem 4, ai ≤ r for all i. We also allow ∅.

In problem 5, ai = 1 for odd i ≤ s and ai = 2for even i ≤ s. In other words,

the ai repeat the sequence 12. We also allow ∅.

In problem 6, the ai follow a repeating sequence, so for some `, a`+1 = a1,

a`+2 = a2 and so on; in general ak`+i = ai for 1 ≤ i ≤ ` and k` + i ≤ s. We

also allow ∅.

1.4 Algebraic functions and asymptotics

A function is algebraic if it is the root of a polynomial equation. y = y(x) is an algebraic function if there exists some polynomial H 6≡ 0 with coecients in C[x] such that H(y) = 0. By C[x] we mean the set of polynomials with coecients in C.

The following closure properties are valid for algebraic functions: if f and g are algebraic functions and α and β are real numbers, then fg and αf + βg are algebraic.

If a growing positive power series is algebraic, its coecients fd have the

asymptotic expression A · db· Cd when d → ∞, as shown in theorem VII.8 in

[4].

The following theorem is a special case of Lemma 6.6.9 in [3] and can be used to show that formal power series in a polynomial equation system are algebraic.

(10)

coe-cients in C[x], and let α1, ..., αn be formal power series in x that satisfy the

equation system Hi(α1, ..., αn) = 0 for 1 ≤ i ≤ n. Let D be the Jacobian

de-terminant of the system, D(z1, ..., zn) = det

 ∂Hi ∂zj n i,j=1. If D(α1 , ..., αn) 6≡ 0,

then each αi is algebraic.

Note that it suces to prove D 6= 0 for x = 0, since then D is not identically zero. We will only need a very specic special case of the theorem for this thesis:

Lemma 1. If the equations Hi = 0 in Theorem 1 can be written as α1 =

H10(α2, ..., αn) and αi = ci+ xHi0(α1, ..., αn) for i ≥ 2, where ci ∈ C and Hi0

are polynomials with coecients in C[x], then each αi is algebraic.

To see why this is true, set x = 0. Then for i ≥ 2, αi − ci = 0, so Hi only

contributes the diagonal element ∂Hi/∂αi = 1 to D. H1 can be written as

α1− H10(α2, ..., αn), so ∂H1/∂α1 = 1. Thus D is the determinant of an upper

triangular matrix, so D is the product of the diagonal elements which are all 1, so D = 1 6= 0.

1.5 Methods for retrieving coecients from equations

in generating functions

For certain simple equations, we can use a special case of the Lagrange-Bürmann formula (Theorem 5.1.1 in [5]) to get the coecients of F :

Theorem 2. Let F be a generating function in the variable x. Given the equation F = xφ(F ), where φ is a formal power series with φ(0) = 1, we can get the coecients [xd]F for d ≥ 1 from the following formula:

[xd]F = 1 dF

d−1 φ(F )d

A more general theorem is the FlajoletSoria formula for coecients of an algebraic function, Theorem 1 in [6]:

Theorem 3. Let F be a generating function in the variable x. Given the equation F = P (x, F ) where P = Pk

i=1aix

(11)

1 and [F0]P 6= 0, the coecients [xd]F are given by the following sum: [xd]F = d X i=0 X i1+...+ik=i+1 b1i1+...+bkik=d c1i1+...+ckik=i ij∈N i!a i1 1 i1! ...a ik k ik!

If we have a system of polynomial equations in generating functions Gk(x)

and coecients in C[x] that we can't reduce to an equation, we can apply the following method.

Convert the system into a system of recursive equations for the coecients gk,d, by extracting the xd-coecients on both sides of the formulas and

equating them. For example, G2 = xG1 + 2xG22 + x2G1G3 yields g2,d =

g1,d−1+ 2Pd−1i=0 g2,ig2,d−1−i+Pd−2i=0g1,ig3,d−2−i.

Notice that the coecients that appear on the RHS have degree d − 1 or less. This is ensured by the fact that each term on the RHS of the original equation contains x. Thus we can calculate g2,d directly by only knowing

coecients up to degree d − 1. If, say, G1 = G2+ xG3, we can calculate g1,d

directly despite the fact that it contains a term without x, but only after calculating g2,d. Then if G3 depends on G1 in the same way as G1 depends

on G2, we can calculate g3,d after calculating g1,d.

If we can form such a hierarchy of dependence without loops, all coecients gi,d can be calculated directly. Note that if, say, G1 = G2+ G2G3 but G2 has

no constant term, G1 still doesn't have this sort of dependence on G3 because

the term in the equation for g1,d that contains g3,d is g2,0g3,d = 0 · g3,d = 0. If

g2,0 6= 0, however, we can't form this hierarchy and will have to solve a linear

equation system in g1,d and g3,d.

In general, given a set of generating functions Gkand a system of polynomial

equations of the form, where βk,i, γk,i,j ∈ N:

Gk= X i αk,ixβk,i nk,i Y j=1 Gγk,i,j (2)

We can convert this into a recursive system of equations in gk,d, that may or

(12)

gk,d = X i αk,i X c1+. . . +cnd,i=d−βk,i ci∈N nk,i Y j=1 gγk,i,j,cj (3)

For convenience, we introduce the denition Sd(F, G) =

Pd

i=0[xi]F · [xd−i]G

for working with (3) when nk,i ≤ 2. Then all we have to do to go from (2)

to (3) is replace terms xkF Gwith S

d−k(F, G), and xkF with [xd−k]F, and xk

with δd,k.

1.6 Basic combinatorics

The number of ways to arrange a list of n items is n! = n(n − 1)(n − 2)...1, because there are n possible selections for which element to put rst, then n − 1 for which to put second, and so on.

The number of ways to select k items from a set of n items, when the order of selection doesn't matter, is n

k = n!

k!(n−k)!. This can be proven by

con-sidering the n! arrangements of the items, and concon-sidering the rst k to be selected. Then each selection corresponds to k!(n − k)! arrangements, be-cause for each arrangement of the rst k elements there are (n − k)! dierent arrangements of the rest of the elements, and for each selection of k elements there are k! arrangements of them. Thus we must divide the total number of arrangements, n!, by the number of arrangements per selection, k!(n − k)!. The number of ways to select k items from a set of n items, when the same element may be chosen multiple times, is n

k



 = n+k−1

k



. This can be proven by considering a sequence of k stars and n − 1 bars. The number of stars before (to the left of) the rst (leftmost) bar is equal to the number of times we select the rst of the n items (for some arbitrary arrangement of the n items). The number of stars between the rst and second bars is equal to the number of times we select the second item and so on. The n − 1 bars divide the sequence into n segments, each corresponding to an element, and because the total number of stars is k, we make k selections in total. There

are n+k−1

k



ways to select which k positions in the sequence contain a star.

n k



is also the number of ways to select k integers 1 ≤ i1 ≤ i2 ≤ ... ≤ ik ≤

n. We may select the same number multiple times, and only one order of selection is valid which is tantamount to saying the order doesn't matter.

(13)

The binomial theorem states the following formula for expanding (x + y)n: (x + y)n= n X k=0 n k  xkyn−k. (4)

This can be veried by considering the process of expanding the brackets (x + y)n = (x + y)(x + y)(x + y).... The coecient for xkyn−k is simply the

number of ways to select k brackets from which to select the x term (thus selecting the y term from the remaining n − k brackets).

n k



can also be written on the following form, which can be used to dene it for n /∈ N: n k  = n(n − 1)(n − 2)...(n − k + 1) k!

For n = 1/2, this becomes: 1/2 k  = 1 k! 1 2 −1 2 ... −(2k − 3) 2 = 1 k!2 −k (−1)k−1(1 · 3...(2k − 3)) = 1 k!2 −k (−1)k−1 (2k − 2)! 2 · 4...(2k − 2) = 2−2k+1(−1)k−1 (2k − 2)! k!(k − 1)! = 2−2k(−1)k −2(2k)!k k!k!(2k)(2k − 1) = (2k)! k!2(1 − 2k)(−4)k (5)

The Taylor series at x = 0 for (1 + x)α where α ∈ C, also known as the

binomial series, is:

(1 + x)α = ∞ X i=0 α i  xi (6)

(14)

This can be veried by considering what happens to (1 + x)α when it's

dif-ferentiated i times: you multiply by α, then (α − 1), then (α − 2) and so on down to (α − i + 1). Substituting x = 0 and then dividing by i! yields both the Taylor coecients and α

i

 .

2 Symmetry in patterns and letters

Let AP(a) = |WP(a)|. In this section, we will prove two important theorems:

Theorem 4. For patterns ijk where i, j, k are distinct, Aijk is symmetric in

i, j, k.

Theorem 5. AP(a) is symmetric in its arguments ai.

We will use the notation W for the reverse of W , that is, the word with the letters of W in reversed order.

2.1 Symmetry of 123-avoidance and 132-avoidance

We begin by proving A123= A132. We do this by dening a mapping T : W →

W. We then prove three statements Q1, Q2 and Q3, where Q1: if W ∈ W(a)

then T (W ) ∈ W(a). Q2: T is an involution, that is, T (T (W )) = W . Q3: T

maps 123-avoiding words to 132-avoiding words, and vice versa. It follows from Q1 and Q3 that for a given sequence a, T maps W123(a) to W132(a)

and vice versa, and it follows from Q2 that this map is bijective. Thus

|W123(a)| = |W132(a)|, and thus A123= A132.

The denition of T and the outline of the proof was taken from [1]. He also stated the recurrence formula in the next section.

We dene T recursively based on word length. Let T (∅) = ∅. For a nonempty word W of length d + 1, let w be the word obtained from W by removing the rst letter t0 and then replacing all letters larger than t0+ 1

with t0 + 1. Let v be the subsequence of letters t ≥ t0 + 1 in W . Since

|w| = d, T (w) is well-dened. Let u be the word obtained from T (w) by replacing (in order) the occurrences of t0+ 1 by the members of v (until we

run out of letters in v). Finally let T (W ) = tu.

We will prove Q1, Q2 and Q3 inductively. Let Qi(d) be the statement that

(15)

Assume Q1(k), and let |W | = k + 1. Replacing all occurrences of t0 + 1 in

w by the members of v and then adding t0 is the reverse of the W 7→ w

operation, and thus yields W . But this is exactly what we do, except with T (w) and v instead of w and v, to get T (W ). And since T (w) contains the same members as w (by Q1(k)) and v contains the same members as v, this

yields a word with the same members as W . Thus Q1(k + 1) QED. As an

aside, this means v is exactly large enough to replace all t0+ 1 in T (w).

Assume Q2(k), and let |W | = k + 1. To get T (T (W )) from T (W ), we start

by removing the rst letter t0 of T (W ) and replacing all letters greater than

t0+ 1 by t0+ 1. This yields T (w), as the same steps were taken except in

reverse to get T (W ) from T (w). Similarly, v is the subsequence of letters t ≥ t0 + 1in T (W ). By Q2(k), T (T (w)) = w, so to nish the algorithm we

replace all occurrences of t0+ 1 in w by the letters of v = v, and then we add

t0 as the rst letter, yielding W . We have followed the algorithm for getting

T (T (W )) from T (W ), and we have ended up with W , so W = T (T (W )). Thus Q2(k + 1)QED.

Assume Q3(k), and let W be a 123-avoiding word with length k + 1. Assume

w contains 123. Then at least one of the letters forming the pattern must be an occurrence of t0+ 1which replaced a greater letter in W , since otherwise

the same pattern would exist in W . The t0+ 1 must be the 3 of the pattern,

so the other two letters are less than t0 + 1. But then the corresponding

letters in W form the same pattern, which is a contradiction. Therefore w avoids 123.

v is (weakly) decreasing. Assuming otherwise, there exist t1, t2 ∈ v such

that t1 < t2 and t1 is to the left of t2. Then W contains the subsequence

t0t1t2, and since all letters in v are greater than t0, this forms the pattern

123, which is a contradiction. Thus v is increasing. By Q3(k), T (w) avoids

132. Inserting the letters of v to get u does not form a new 132, since if at least one of the new letters is part of the pattern, one of them must be the 3. If the corresponding t0 + 1 couldn't be the 3 of this pattern, the 2 must

also be one of the new letters, but v is increasing, so this is a contradiction. If adding t0 to get T (W ) creates the pattern 132, the t0 must be the 1, so

the other letters are at least t0 + 1, but these letters came from v and are

increasing so they can't form the 32. Thus T (W ) is 132-avoiding.

By the same reasoning as above, if W is 132-avoiding, T (W ) is 123-avoiding. The only dierence in the proof is that v would be increasing and v would be decreasing. Thus Q3(k + 1) QED. We have now nished the proof that

(16)

2.2 A recurrence relation for A

Before we move on to the other pattern symmetries, we must prove that A132

is symmetric in its arguments ai, and to do that, we must prove a recurrence

relation in A132. Both the argument symmetry and recurrence relation hold

for all 3-length patterns without repeating letters, as will be proven when we prove the other pattern symmetries, so here we will simply use A to refer to A132.

We borrow the notations used in the previous section to nd the recurrence. Given a certain sequence a and rst letter t0 of a 132-avoiding word W , W

can be determined by w and v, but the members of v are determined by a and their order is determined by the 132-avoidance of W , so W can be determined solely by w. Therefore, the number of possible w:s given a certain t0 is equal

to the number of possible W :s with the rst letter t0. The number of possible

w:s is A (a1, ..., at0−1, at0 − 1, at0+1+ ... + as), because one t0 is removed from

W and the number of t0+ 1 is equal to the number of letters t ≥ t0+ 1 in

W. We sum over the possible values of t0 to get a recurrence for A:

A(0) = 1 (7) A (a1, ..., as) = s X i=1 A (a1, ..., ai−1, ai− 1, ai+1+ ... + as) (8)

If any ai is zero (and it's not the only argument), we simply remove it:

A (a1, ..., as) = A (a1, ..., ai−1, ai+1, ..., as). This is because if there are no i:s,

replacing all i + 1:s with i:s (and so on) preserves the relative order of the letters, and therefore preserves all patterns.

2.3 Argument symmetry in A

An equivalent condition to argument symmetry is that we can swap neigh-boring elements without changing the value, because we can repeatedly use this to put the desired argument in the rst position, then do the same for the second position and so on. We outline the proof that A is symmetric be-low, but the full proof is rather cumbersome and is deferred to the appendix A.

(17)

Let Q4(d): the symmetry is true for a1+ ... + as = d. Q4(0)and Q4(1) are

ob-viously true. We assume Q4(k)and Q4(k+1), and let a1+...+as = k+2. Note

that every term on the RHS of the recurrence for A (a1, ..., as) is symmetric

by Q4(k + 1). We apply (8) and then Q4(k + 1) to A (a1, ..., aj, aj+1, ..., as)

and A (a1, ..., aj+1, aj, ..., as), and nd that the statement that these are equal

can be reduced to a statement including four of the 2s terms from the two applications of (8), all other terms having been canceled. Let this statement be Q5(k + 1). We prove Q5(0), and assume Q5(k). Then we apply (8) and

then Q4(k) to the four terms in Q5(k + 1), and we nd that after cancelling

terms, what remains is Q5(k). Thus Q5(k + 1), and thus Q4(k + 2) QED.

2.4 Finishing the pattern symmetry proof

If a word W avoids a pattern P , W avoids P . This is because all patterns are reversed when the word is reversed. This together with A123 = A132 yields

A123 = A321 = A132 = A231 and A213 = A312. Thus if we prove A132 = A312,

the proof is complete.

Let W ∈ W(a1, ..., as). LetcW be the reection of W , that is, the word we get from W by replacing all occurrences of 1 with s, 2 with s−1, and so on. This operation denes a bijective map from W(a) to W(a) = W (as, as−1, ..., a1).

If W contains P , cW contains Pb, because the relative order of the letters is reversed. Therefore this operation maps the 132-avoiding words of W(a) bijectively to 312-avoiding words of W(a). Thus:

A132(a1, ..., as) = A312(as, ..., a1)

We use the argument symmetry of A132 to complete the proof:

A132(as, ..., a1) = A312(as, ..., a1)

A132 = A312

3 Solving the problems

(18)

3.1 Preparations

The additional restrictions specic to each problem always pertain to which sequences a are allowed. The only restriction on allowed permutations given an allowed sequence a is 231-avoidance; in other words, fd will always be a

sum of A(a)-terms for dierent sequences a with sum d. Thus we can invoke Theorem 4 to claim a greater generality in our results, and we can invoke Theorem 5 as a useful tool in the calculations.

3.1.1 Consequences of 231-avoidance

Let W be a 231-avoiding word, and let s be the greatest letter occurring in W. The leftmost occurrence of s divides the word into the two subwords: L to its left and R to its right, so W = LsR. Note that this partition of the word presupposes that W contains an s and is therefore not the empty word ∅, which we consider a valid word. We will use aL,i and aR,i to mean the

number of i:s in L and R, respectively.

Let L ≤ R mean that ∀t1 ∈ L, t2 ∈ R : t1 ≤ t2. We will now prove the

following equivalence:

W avoids 231 ⇔ (L ≤ R) ∧ (Lavoids 231) ∧ (R avoids 231) Assume W avoids 231. Obviously L and R both avoid 231. If ∃t1 ∈ L, t2 ∈

R : t1 > t2, then W contains the subsequence t1st2 which forms the pattern

231. Thus L ≤ R.

Assume L ≤ R, L avoids 231, R avoids 231. Assume W contains 231. Since L avoids 231, the "1" can't be in L. Since R avoids 231, the "2" can't be in R. s can't be the "1" or the "2". Thus the "1" is in R and the "2" is in L, which contradicts L ≤ R. Thus W avoids 231 QED.

If the same letter occurs in L and R, it must be the greatest letter in L and the smallest letter in R, since L ≤ R. We will refer to this case as L ≮ R. The other case, where there is no common letter, will be referred to as L < R. For any given collection of letters in W and length of L, the partition of letters into L and R is completely determined, since L ≤ R (the |L| smallest letters being in L).

(19)

3.1.2 Finding F

To nd F , we will partition the set w of allowed words into subsets which correspond to dierent cases where we impose additional restrictions on the words we are considering, for example (as = 1) ∧ (L ≮ R). Each case will

correspond to a generating function G of its own, which means that for any given d, the xd-coecient of G is equal to the number of d-length words

allowed in this particular case. F will then be the sum of these generating functions.

For any given case which corresponds to the function G, L and R will also correspond to functions of their own; let's call them GL and GR. To express

this correspondence we will use the symbol ∼, so since G is the generating function for W , W ∼ G. Similarly L ∼ GLand R ∼ GR. Then, recalling the

fruit salad example in the introduction, G = xGLGR. We have replaced the

fruits with letters and the number of ways to select fruits with the number of ways to arrange letters, but the equation is the same. The x comes from the fact that there is only one leftmost s and we can arrange it in exactly one way, just like we could select the orange in exactly one way.

Rwill often have restrictions that are similar to those of L, with the exception that the smallest letter of R is typically not 1, since it is either equal to or one greater than the greatest letter of L. This does not aect the generating function of R however, as when we make a restriction that says something about 1, for example that all letters between 1 and s must occur because 1 is smallest and there are no gaps, what we really mean is that all letters between the smallest and largest must occur. The choice of 1 as the smallest letter of W is entirely arbitrary. Remember, only the relative order of the letters matters. For clarity, we will refer to 1 as the smallest letter of W , 1L

and 1R as the smallest letter of L and R respectively, and sL and sR as the

largest letter of L and R respectively.

3.2 Problem 1

In this problem, ai = 1 for i ≤ s. We also allow the empty word ∅.

If W 6= ∅, then L ∼ F , as the same restrictions apply to L as to W : it must be 231-avoiding, and have no gaps (as L ≤ R, so letters smaller than sL cannot occur in R). As we discussed earlier, the restriction for R that

(20)

restrictions as W , so R ∼ F . Thus F − 1 = xF2, and thus F is algebraic,

and thus the number of words fd has exponential asymptotic growth with

respect to word length d.

3.2.1 Solution using LagrangeBürmann formula

Let G = F − 1 ⇒ G = x(G + 1)2. Now we can apply Theorem 2 with

φ(G) = (G + 1)2 to get the coecients fd for d ≥ 1, since only the x0

coecients in F and G dier: fd= [xd]G = 1 d[G d−1](G + 1)2d = 1 d  2d d − 1  = 1 d + 1 2d d 

The third equality comes from (4). This formula holds for d = 0 as well, since f0 = 1 = 0+11 2·00

 .

These coecients are known as the Catalan numbers: Cd = d+11 2dd



. They often appear in counting problems where some object can be recursively dened by partitioning it into a separator (here s) and two smaller objects (here L and R) which behave in the same way as the entire object itself. They can also be dened recursively as C0 = 1 and Cd+1=Pdi=0CiCd−i.

3.2.2 Solution using Taylor expansion F − 1 = xF2 xF2− F + 1 = 0 F = 1 ± √ 1 − 4x 2x F = F+ ∨ F = F−

F (0) = f0 = 1 since all other terms vanish when x = 0, but limx→0F+ = ∞,

so

F = 1 − √

1 − 4x

2x (9)

We get the Taylor expansion for √1 − 4x from (5) and (6), and insert it into (9):

(21)

√ 1 − 4x = ∞ X i=0 (2i)! (1 − 2i)i!2(−4)i(−4x) i = 1 + ∞ X i=1 (2i)! (1 − 2i) i!2x i F = 1 − √ 1 − 4x 2x = − ∞ P i=1 (2i)! (1−2i)i!2x i 2x = ∞ X i=1 (2i)! 2 (2i − 1) i!2x i−1 = ∞ X i=0 (2i + 2)! 2 (2i + 1) (i + 1)!2x i

We simplify the coecients:

fd = (2d + 2)! 2 (2d + 1) (d + 1)!2 = 2d! (2d + 1) (2d + 2) 2 (2d + 1) (d + 1)2d!2 = 2d! (d + 1) d!2 = 1 d + 1 2d d 

3.3 Problem 2

In this problem, ai ≤ 2for all i. We also allow the empty word ∅.

In the following two problems, the condition will instead be ai ≤ 3and ai ≤ r,

respectively. In all these problems we dene Fm,n as the generating function

corresponding to the case where a1 = m, as = n, for m, n > 0. F0,nand Fm,0

correspond to the case where a1 and as are unrestricted, respectively. If and

only if at least one of m and n is zero, 1 and s may be equal, which means that the word with only one unique letter is allowed. This is because Fm,0

allows the combinations 1m2a2, 1m2a23a3, 1m2a23a34a4 and so on for any a

i,

so it's natural to extend this to allowing 1m too.

The task of nding F , which we can now write as F0,0, will be accomplished

by nding a formula for it in terms of other functions Fm,n, and then nding

formulas for these functions in terms of each other, thus creating a system of equations. For functions Fm,n with m > n, the formula will simply be

Fm,n = Fn,m, utilizing Theorem 5.

(22)

F0,0 = 1 + F0,1+ F0,2 (10)

The three terms on the right enumerate words for which as = 0, 1, 2

respec-tively. To nd F0,1 and F0,2, we consider two subcases: L < R and L ≮ R.

First consider F0,1. When L < R, L has the same restrictions as W :

belong-ing to W231 and having one or two of each letter, since no letter in L occurs

elsewhere in W . The same is true for R since the single occurrence of s is not contained in R, so sR 6= sand thus aR,sR, the number of occurrences of sR, is

unrestricted. Thus L ∼ F0,0 and R ∼ F0,0. When on the other hand L ≮ R,

sL = 1R, and this element occurs exactly once in each. Thus L ∼ F0,1 and

R ∼ F1,0 = F0,1. We conclude that F0,1= x F0,02 + F0,12

 .

Next consider F0,2. L will in both subcases have the same restrictions as

for F0,1 (s occurring once or twice does not aect L). R, in both subcases,

now has a xed aR,sR = 1, but the restrictions on 1R do not change, so

when L < R, R ∼ F0,1, and when L ≮ R, R ∼ F1,1. Note that F1,1 does

not allow 1 = s, which is appropriate since in the case where R ∼ F1,1,

1R occurs in L so if 1R = sR(= s), s would occur in L. We conclude that

F0,2 = x (F0,0F0,1+ F0,1F1,1) = xF0,1(F0,0+ F1,1).

Now we have a third function to consider: F1,1. Here R does not contain s

and thus aR,sR is unrestricted. There are three cases to consider: either (A)

L = ∅ and 1 ∈ R, or (B) 1 ∈ L and L < R, or (C) 1 ∈ L and L ≮ R. If (A), L ∼ 1and R ∼ F1,0 = F0,1. If (B), L ∼ F1,0 = F0,1 and R ∼ F0,0. If (C), both

aL,1L and aL,sL are restricted, and they must be dierent since there is only

one 1L so 1L ∈ R/ . Thus L ∼ F1,1, and R ∼ F1,0 = F0,1. We conclude that

F1,1 = xF0,1+ xF0,0F0,1+ xF0,1F1,1 = xF0,1+ xF0,1(F0,0+ F1,1) = xF0,1+ F0,2.

We now have the equation system

F0,0 = 1 + F0,1+ F0,2 (11) F0,1 = x F0,02 + F 2 0,1  (12) F0,2 = xF0,1(F0,0+ F1,1) (13) F1,1 = xF0,1+ F0,2 (14)

(23)

F0,2 =

xF0,1(F0,0+ xF0,1)

1 − xF0,1

(15) Solving (12) for F0,1, we get:

F0,1 =

1 ±q1 − 4x2F2 0,0

2x

Let's call these two solutions G+ and G−. F0,1 does not allow ∅ so the x0

coecient is 0, so F0,1(0) = 0, but limx→0G+ = ∞, so F0,1 = G−:

F0,1 =

1 −q1 − 4x2F2 0,0

2x (16)

We insert (15) and then (16) into (11), clear the denominator and expand parentheses. We also replace F0,0 with F . The result is:

1 + xF2− x2F2− F1 − 4F2x2 = 0

We move over the last term, square both sides, and simplify, and end up with this:

x2 x2− 2x + 5 F4+ −2x2+ 2x − 1 F2+ 1 = 0 (17)

Thus F is algebraic, so the number of words fd has exponential asymptotic

growth with respect to word length d. We solve the equation as a second degree equation for F2, and then take the square root to nd F .

(24)

F2 = 1 − 2x + 2x 2±1 − 4x − 12x2 2x2(5 − 2x + x2) (18) F2 = 1 − 2x + 2x 21 − 4x − 12x2 2x2(5 − 2x + x2) (19) F = ± s 1 − 2x + 2x21 − 4x − 12x2 2x2(5 − 2x + x2) (20) F = s 1 − 2x + 2x21 − 4x − 12x2 2x2(5 − 2x + x2) (21)

We get from (18) to (19) and from (20) to (21) by again considering the limit as x → 0. The other solution in (18) approaches ∞ and the other solution in (20) is always nonpositive, and the correct solution in both should approach F (0)2 = F (0) = 1.

To get the coecients fd, we can do the substitution F = G − 1 in(17),

write the equation as G = P (x, G) and apply Theorem 3. However, a naive application of the theorem takes very long for a computer to calculate for fairly small d, because of the millions of compositions of d+1 into k terms that need to be generated and tested, and a suciently ecient method would be dicult (impossible?) to create. In the Appendix B we demonstrate a way to calculate fd from (21) using Taylor series, for which the coecients up

to x1000 took 528 seconds to calculate in Mathematica. However, the most

ecient method is to rewrite (11)-(14) using (3).

[xd]F0,0 = [xd]F0,1+ [xd]F0,2+ δd,0

[xd]F0,1 = Sd−1(F0,0, F0,0) + Sd−1(F0,1, F0,1)

[xd]F0,2 = Sd−1(F0,0, F0,1) + Sd−1(F0,1, F1,1)

[xd]F1,1 = [xd−1]F0,1+ [xd]F0,2

This method works as long as we calculate [xd]F

0,0 after [xd]F0,1 and [xd]F0,2,

as well as [xd]F

1,1 after [xd]F0,2. Below are the rst eight terms of each

function. Calculating the coecients up to x1000 in Mathematica took 15

(25)

F0,0 = 1 + x + 3x2 + 11x3 + 47x4 + 211x5 + 997x6 + 4861x7 + ...

F0,1 = x + 2x2 + 8x3 + 32x4 + 145x5 + 678x6 + 3301x7 + ...

F0,2 = x2 + 3x3 + 15x4 + 66x5 + 319x6 + 1560x7 + ...

F1,1 = 2x2 + 5x3 + 23x4 + 98x5 + 464x6 + 2238x7 + ...

3.4 Problem 3

In this problem, ai ≤ 3for all i. We also allow ∅.

Let's take a moment to further consider why it's reasonable that 1 = s is allowed for Fm,0 and F0,n. Let's say we haven't implemented that rule, and

we're considering the case W ∼ Fm,n, L < R, L 6= ∅, 1 6= sL, 1R6= sR. Then

L ∼ Fm,0 since L must contain all the 1:s, and may contain any number

of sL:s. We also have R ∼ F0,n−1 since R may contain any number of 1R:s

and must have all but one of the s:s. Now if 1 = sL, this means L ∼ xm

since L must contain all the m 1:s and nothing more, and R still contains any number of 1R:s, so the same conditions still hold for R, so R ∼ F0,n−1.

Instead of dividing W ∼ Fm,n, L < R, L 6= ∅ into the cases 1 6= sL and

1 = sL, so W ∼ x (xm+ Fm,0) F0,n−1, we can combine them into one case by

making Fm,0 include 1 = s.

Similarly, if 1R = sR and n 6= 1, this means R must simply contain the

remaining s:s, so R ∼ xn−1, and the same conditions hold for L as before, so

L ∼ Fm,0. Again, we can merge xn−1 and F0,n−1.

For W ∼ Fm,n with m, n 6= 0, even if m = n, there is no parallell to this.

Let's say L ∼ Fm,k, k 6= 0, which corresponds to the case where L ≮ R,

all 1:s are in L, aL,sL = k, and R ∼ P

3−k

i=1Fi,n−1. Now let's say 1 = sL so

L ∼ xk. Then we have R ∼ Fm−k,n−1 because R must contain the rest of the

1:s if there are any. The conditions for R have changed, so R has changed, so merging xk and F

m,k will make our formulas more complicated rather than

the other way around.

Much like in problem 2, we have the following equation for F = F0,0:

F0,0 = 1 + F0,1+ F0,2+ F0,3

First consider F0,1. There is no restriction on aR,sR since s 6= sR, and also

(26)

on L or R, so L, R ∼ F0,0. If L ≮ R, the common element can occur once in

L and once in R (L ∼ F0,1, R ∼ F1,0), or once in one and twice in the other

(either L ∼ F0,1 and R ∼ F2,0, or L ∼ F0,2 and R ∼ F1,0). We conclude that:

F0,1 = x (F0,0F0,0+ F0,1F1,0+ F0,1F2,0+ F0,2F1,0) (22)

We can use this to derive formulas for F0,2 and F0,3 as well. The only thing

that changes is that the number of sR (= s) in R is restricted, being one less

than the number of s in W .

F0,2 = x (F0,0F0,1+ F0,1F1,1+ F0,1F2,1+ F0,2F1,1) (23)

F0,3 = x (F0,0F0,2+ F0,1F1,2+ F0,1F2,2+ F0,2F1,2) (24)

Note that when R ∼ Fm,n, with m, n 6= 0 (which corresponds to L ≮ R), 1R

and sR= s may no longer be equal, as is appropriate since s /∈ L.

When m 6= 0 in Fm,n, the method is similar: either L < R or they have a

common element in one of three ways, with L and R containing it once and once, once and twice, or twice and once, respectively. We can modify (22) using the same method that we used to derive (23) and (24): by setting the number of 1Lin L equal to the number of 1 in W . However, additional terms

must be added like so:

F1,1 = x (F1,0F0,0+ F1,1F1,0+ F1,1F2,0+ F1,2F1,0+ F1,0)

F1,2 = x (F1,0F0,1+ F1,1F1,1+ F1,1F2,1+ F1,2F1,1+ F1,1)

F2,2 = x (F2,0F0,1+ F2,1F1,1+ F2,1F2,1+ F2,2F1,1+ F2,1+ xF1,1)

The rst four terms in each formula are familiar, but now they do not include cases where 1 ∈ R. This is because aL,1 is specied so L 6= ∅, and when

L ≮ R, both aL,1 and aL,sL are specied so 1 6= sL. When 1 ∈ R, L cannot

contain any elements except 1 since L ≤ R. Therefore we have added one term to each formula corresponding to L = ∅ and all (one or two) instances of 1 being in R, and one term to F2,2 corresponding to L = 1 ⇒ L ∼ x and

aR,1= 1.

(27)

F0,2 = x (F0,0F0,1+ F0,1F1,1+ F0,1F1,2+ F0,2F1,1) (25)

F1,1 = x (F0,0F0,1+ F0,1F1,1+ F0,1F1,2+ F0,2F1,1+ F0,1) (26)

Note the similarity between the formulas. We can write this as F1,1 = F0,2+

xF0,1. Simplifying the full equation system yields:

F0,0 = 1 + F0,1+ F0,2+ F0,3 (27) F0,1 = x F0,02 + F 2 0,1+ 2F0,1F0,2  (28) F0,2 = x (F0,0F0,1+ F0,1F1,1+ F0,1F1,2+ F0,2F1,1) (29) F0,3 = x (F0,0F0,2+ F0,1F1,2+ F0,1F2,2+ F0,2F1,2) (30) F1,1 = F0,2+ xF0,1 (31) F1,2 = x F0,12 + F 2 1,1+ 2F1,1F1,2+ F1,1  (32) F2,2 = x F0,1F0,2+ F1,1F1,2+ F1,1F2,2+ F1,22 + F1,2+ xF1,1  (33) We can apply Lemma 1 prior to making the substitution for F1,1, using (26)

instead of (31). Thus the Fm,n are algebraic, and thus the number of words

fd has exponential asymptotic growth with respect to word length d.

We can also apply (3) to calculate the coecients, making sure to calculate [xd]F0,2before [xd]F1,1, as well as [xd]F0,1, [xd]F0,2, and [xd]F0,3before [xd]F0,0:

[xd]F = [xd]F11+ [xd]F12 [xd]F11 = Sd−1 F11, F 2,1 1  + Sd−1 F11, F 2 2 + Sd−1 F12, F 2 1  [xd]F12 = Sd−1 F11, F 1 1 + Sd−1 F12, F 2,1 1  + Sd−1 F12,1, F 2,1 2,1 + δd,0 [xd]F12,1 = 2Sd−1 F11, F 2 1 + Sd−1 F12,1, F 2,1 1  [xd]F22 = Sd−1 F11, F12 + Sd−1 F11, F 2,1 2,1 + Sd−1 F 2,1 1 , F22  [xd]F2,12,1 = Sd−1 F11, F 1 1 + Sd−1 F12, F 2,1 1  + Sd−1 F 2,1 1 , F 2,1 2,1 + [x d−1 ]F12,1

The rst eight terms of each function are displayed below. Calculating the coecients up to x1000 in Mathematica took 66 seconds.

(28)

F0,0 = 1 + x + 3x2 + 12x3 + 55x4 + 273x5 + 1413x6 + 7546x7 + ... F0,1 = x + 2x2 + 8x3 + 36x4 + 173x5 + 890x6 + 4723x7 + ... F0,2 = x2 + 3x3 + 15x4 + 76x5 + 387x6 + 2077x7 + ... F0,3 = x3 + 4x4 + 24x5 + 136x6 + 737x7 + ... F1,1 = 2x2 + 5x3 + 23x4 + 112x5 + 560x6 + 2967x7 + ... F1,2 = 3x3 + 9x4 + 47x5 + 248x6 + 1297x7 + ... F2,2 = 6x4 + 19x5 + 105x6 + 580x7 + ...

3.5 Problem 4

In this problem, ai ≤ r for all i. We also allow ∅.

The formula for F = F0,0 is familiar: 0 ≤ as ≤ r, so:

F0,0 = 1 + r

X

i=1

F0,i (34)

First consider F0,n, n 6= 0. If L < R, L ∼ F0,0, and R either contains the

rest of the s:s or, if n = 1, an unrestricted number of sR, so R ∼ F0,n−1. If

L ≮ R, let the common element be t. If aL,t = i and aR,t = j, L ∼ F0,i and

R ∼ Fj,n−1. The conditions for i and j are i, j > 0 and i + j ≤ r, which can

be written as 1 ≤ i ≤ r − 1 and 1 ≤ j ≤ r − i. Thus, F0,n = x F0,0F0,n−1+ r−1 X i=1 r−i X j=1 F0,iFj,n−1 ! (35) Again we note that when L ≮ R, 1R 6= sR unless n = 1 in which case s 6= sR

and the number of sR is unrestricted.

Like in problem 3, we modify (35) to get the formula for Fm,n, m, n 6= 0:

Fm,n = x Fm,0F0,n−1+ r−1 X i=1 r−i X j=1 Fm,iFj,n−1 ! + m X i=1 xm−iFi,n−1 ! (36)

(29)

Again like in problem 3, this is because the terms that correspond to (35) assume that 1 /∈ R. The terms xm−iF

i,n−1 correspond to aL,1 = m − i and

aR,1= i, so L ∼ xm−i and R ∼ Fi,n−1.

Note that (36) is true for F0,n, n 6= 0 as well, since the last sum vanishes and

we're left with (35).

Let's count the number of equations and unknowns we have after eliminating all Fm,n with m > n with Theorem 5. In (34), the functions F0,i appear for

0 ≤ i ≤ r. If m ≤ r − 1 and n ≤ r in (36), the functions Fi,j appear for

0 ≤ i, j ≤ r − 1 on the right hand side. Thus the unknowns are Fm,n for

0 ≤ m ≤ n ≤ r − 1 ∨ (m, n) = (0, r) and each unknown has a corresponding equation, so we have r 2   + 1 = r+1 2  + 1equations in r+1 2  + 1unknowns.

The full equation system can be dened thusly:

Fm,n =              1 + r P i=1 F0,i , A x Fm,0F0,n−1+ r−1 P i=1 r−i P j=1 Fm,iFj,n−1 ! + m P i=1 xm−iF i,n−1 ! , B Fn,m , C A : (m, n) = (0, 0) B : 0 ≤ m ≤ n ≤ r − 1 ∨ (m, n) = (0, r) C : 0 ≤ m, n ≤ r − 1

Making the substitutions C so all those cases are eliminated, we can apply Lemma 1 to show that the functions Fm,n are algebraic. Thus the number of

words fd has exponential asymptotic growth with respect to word length d.

We change the order of summation of the last term in the B case and then apply (3) to get the coecients, calculating [xd]F

(30)

[xd]Fm,n =                         r P i=1 [xd]F 0,i  + δ0,d , A Sd−1(Fm,0, F0,n−1) + r−1 P i=1 r−i P j=1 Sd−1(Fm,iFj,n−1) ! + m P i=1 [xd−i]F i,n−1 , B [xd]F n,m , C

Below are the rst thirteen terms of F for r = 5, calculated with Mathemat-ica. Calculating the coecients up to x1000 took 196 seconds.

F = 1 + x + 3x2+ 12x3+ 56x4+ 286x5+ 1536x6+ 8542x7+ 48632x8 + 282463x9+ 1666623x10+ 9961923x11+ 60195621x12+ ...

3.6 Problem 5

In this problem, ai = 1 for odd i ≤ s and ai = 2 for even i ≤ s. In other

words, the ai repeat the sequence 12. We also allow ∅.

We dene Fn

m as the generating function corresponding to the case where if

m = 1 the smallest number is odd, if m = 2 the smallest number is even (we'll refer to it as 2 rather than 1) and it occurs twice, and if m is a number pair (2, 1), i.e. W ∼ Fn

2,1, this means the smallest number is even but there

is only one of it. The value of n places the same conditions except on s. F1 1

and F2

2 allow 1 = s and 2 = s, respectively.

Also, F2

1 and F21 allow W = ∅, and F 2,1

2 and F2,12 allow W = 2 (i.e. 2 =

s). The rst is because since F2

1 allows the combinations 1122, 11223142,

112231425162 and so on (i full sequences for i ≥ 1), it's natural to extend this to allowing ∅ (i = 0). Similarly, since F2,1

2 allows 223141 = 21(213141),

2231425161 = 21(213141) (415161) and so on, we also allow 21.

This denition will seem less ad hoc when we expand upon it in the next problem, which generalizes this one.

(31)

as is 0, 1 or 2, so:

F = F11+ F12

where the empty case is included in F2 1.

For L there are four dierent cases to consider: (A) sL is odd and occurs

once, or sL is even and occurs (B) once or (C) twice, or (D) L = ∅. (D) will

typically be included in (A), (B) or (C). We will consider this case as well as (E) R = ∅ separately for each function, but for now let's ignore these cases. Say we're considering Fn

m, and L ∼ Fmn11, R ∼ F

n2

m2. Then if (A), 1R is even

so n1 = 1 and m2 = 2. If (B), 1R= sL so n1 = m2 = (2, 1). If (C), 1R is odd

so n1 = 2 and m2 = 1.

Let's also consider m1 and n2. m1 = m because 1L = 1. If n = 1 this means

s is odd so sR = s − 1 is even and occurs twice, so n2 = 2. If n = 2, sR = s

so n2 = (2, 1). If n = (2, 1), n2 = 1 because sR = s − 1is odd.

Now let's consider F1

1. The rough sketch solution from above is x F11F22+

F2

1F12 + F 2,1 1 F2,12



, with the three terms coming respectively from (A), (B) and (C). (D) is included in (B), L ∼ F2

1, as is (E). Note that we do not need

to make a special exception for L = 1, R = 2R2R or R = 2R, as they're

included in F1

1, F22 and F2,12 respectively.

Let's consider F2

1. The rough sketch solution is x F11F 2,1 2 +F12F 2,1 1 +F 2,1 1 F 2,1 2,1  . (D) is included in (B). (E) is not possible, since s ∈ R. Note that again, cases such as R = 2R take care of themselves. However, because ∅ is allowed, we

must add an 1: F2 1 = 1 + x F11F 2,1 2 + F12F 2,1 1 + F 2,1 1 F 2,1 2,1  . Let's consider F2,1

1 . The rough sketch solution is x F11F21+ F12F11+ F 2,1 1 F2,11

 . (D) is included in (B). (E) is included in (A).

Let's consider F2

2. The rough sketch solution is x F21F 2,1 2 +F22F 2,1 1 +F 2,1 2 F 2,1 2,1  . (D) is included in (A). (E) is impossible since s ∈ R.

Let's consider F2,1

2,1. The rough sketch solution is x F2,11 F21+F2,12 F11+F 2,1 2,1F2,11

 . (E) is included in (A). However, none of the functions that correspond to L allow ∅, so we must add a separate term for (D). If L = ∅, 2 ∈ R, and since there is only one 2, R ∼ F1

2,1. Thus F 2,1 2,1 = x F2,11 F21+F2,12 F11+F 2,1 2,1F2,11 +F2,11 

Because of Theorem 5, it doesn't matter if a = (1, 2, 1, 2, ..., 1, 2) or a = (2, 1, 2, 1, ..., 2, 1). Therefore F1

2 = F12, and similarly F2,11 = F 2,1

(32)

F22,1. This leaves F22,1 to consider, for which a = (2, 1, 2, 1, ..., 2, 1, 1), which by Theorem 5 is equivalent to a = (1, 2, 1, 2, 1, ..., 2, 1), which corresponds to F1

1, so F 2,1

2 = F11. We use these equalities to simplify the equations we have

derived: F = F11+ F12 (37) F11 = xF11F12,1+ F11F22+ F122 (38) F12 = 1 + x F112 + F12F12,1+ F12,1F2,12,1 (39) F12,1 = x  2F11F12+ F12,12  (40) F22 = x F11F12+ F11F2,12,1+ F12,1F22 (41) F2,12,1 = x  F112+ F12F12,1+ F12,1F2,12,1+ F12,1  (42) We can now apply Lemma 1. Thus the functions are algebraic, and thus the number of words fd has exponential asymptotic growth with respect to word

length d.

We can also apply (3) to calculate the coecients, making sure to calculate [xd]F after [xd]F11 and [xd]F12: [xd]F = [xd]F11+ [xd]F12 [xd]F11 = Sd−1 F11, F 2,1 1  + Sd−1 F11, F 2 2 + Sd−1 F12, F 2 1  [xd]F12 = Sd−1 F11, F 1 1 + Sd−1 F12, F 2,1 1  + Sd−1 F12,1, F 2,1 2,1 + δd,0 [xd]F12,1 = 2Sd−1 F11, F 2 1 + Sd−1 F12,1, F 2,1 1  [xd]F22 = Sd−1 F11, F12 + Sd−1 F11, F 2,1 2,1 + Sd−1 F 2,1 1 , F22  [xd]F2,12,1 = Sd−1 F11, F 1 1 + Sd−1 F12, F 2,1 1  + Sd−1 F 2,1 1 , F 2,1 2,1 + [x d−1 ]F12,1

The rst eight terms of each function are displayed below. Calculating the coecients up to x1000 in Mathematica took 49 seconds.

(33)

F = 1 + x + 3x3 + 9x4 + 62x6 + 207x7 + ... F1 1 = x + 9x4 + 207x7 + ... F12 = 1 + 3x3 + 62x6 + ... F12,1 = 2x2 + 28x5 + ... F2 2 = x2 + 19x5 + ... F2,12,1 = 5x3 + 90x6 + ...

Let's refer to the equations (38)-(42) as eq1, eq2, eq3, eq4 and eq5. We can

turn this into a system of two equations with trivial algebra, so we will content ourselves with describing the steps without showing them. Note the similarity between eq2 and eq5. We can use this to transform eq5 into

F2,12,1 = F12− 1 + xF12,1 and then eliminate F2,12,1, yielding a new system eq0 1,

eq20, eq30, eq40. eq40 can be seen as a linear function in the variable F2

2, so we

solve it, substitute it into the other equations and clear the denominators to get eq00

1, eq002 and eq300. eq003 is a 2-degree equation in F 2,1 1 , which we solve to get: F12,1 = 1 ±p1 − 8x 2F1 1F12 2x = 1 −p1 − 8x2F1 1F12 2x (43)

because the "+ solution" has a singularity in x = 0. We insert this into the other equations, clear the denominators, solve for the square root, square the equation, clear denominators and get:

0 = x4 F114+ 8x2 F113F12− 2x3 F1 1 2 F122 − F1 1 2 + x2 F124 (44) 0 = x2 F114− 4x3 F1 1 3 F12+ 4x4 F112 F122 + 2x F112 (45) + 8x2F11 F123 − 4x2F1 1F 2 1 − F 2 1 2 + 1 (46)

We can now solve (44) as a quartic equation in F1

1. We won't go into the

details here, but we determine the correct solutions by testing all possi-ble solutions. We do this by determining the rst few coecients of large expressions from the coecients of F2

1, and then determining the rst few

coecients of square and cubic roots from the coecients of the argument expressions and the Binomial series. Then we match the rst few coecients of the entire solutions to the coecients we already know of F1

1, eventually

(34)

We can then insert this expression into (46). Then by clearing square roots, clearing square roots within the rst square roots, clearing cubic roots within the second square roots, and then clearing square roots inside the cubic roots, we get an equation of degree 272 in F2

1, or degree 408 in x. We can repeat

this process to get an equation in F1

1 by solving (46) as a cubic equation in

F2

1 and then inserting the resulting expression into (44), clearing the cubic

root, and then clearing the square root within the cubic root. This yields an equation of degree 80 in F1

1, or degree 144 in x.

However, both equations can be factored into a fairly small number of factors, and we can cancel all but one factor by inserting the rst few coecients of F1

1 and F12 respectively until all but one factor has been found to contain

a nonzero coecient, and can therefore be canceled. All of the preceding algebraic manipulation has been done with Mathematica, although all steps but the factorization could have been done by hand with an enormous amount of patience. We end up with the following fourth degree equations in (F1

1) 2 and (F2 1) 2 , respectively: 0 = x2+ −1 + 18x3 F112+ x4 171 − 8x3 F114 + 30x5 27 + 4x3 F116+ x6 27 + 4x32 F118 0 = (1 + x)2 1 − x + x22+ −1 + 58x3+ 10x6 F122 − x3 54 + 37x3+ 8x6 F124− 10x6 27 + 4x3 F126 + x6 27 + 4x32 F128

We could now retrieve the coecients of F1

1 and F12 by substituting G1 =

F1

1 − 1 and G2 = F12− 1, respectively, and then applying Theorem 3. But as

we saw in Problem 2, this method is very slow, so we will have to settle for the recursive method.

3.7 Problem 6

In this problem, the ai follow a repeating sequence, so for some `, a`+1 = a1,

a`+2 = a2 and so on; in general ak`+i = ai for 1 ≤ i ≤ ` and k` + i ≤ s. We

also allow ∅. Let Fn,q

m,p, for 1 ≤ m, n ≤ `, 1 ≤ p ≤ am, 1 ≤ q ≤ an, be the generating

(35)

than 1) and occurs p times, and the greatest element s is k2` + n and occurs

q times, for some k1, k2.

We also let m, n, p, q take on other values for convenience, as this allows us to write the formulas in a more compact way. A single index (i) rather than a pair (i, j) for either the "bottom condition" or the "top condition" is equivalent to (i, ai), i.e. none of "i":s are "missing". The pair (i, 0) means

that this element doesn't occur at all and the "next" element is lowest or highest; for the top condition this is equivalent to (i + 1) and for the bottom condition it's equivalent to (i − 1). For 1 ≤ j ≤ ai, (i, −j) means that j of

the "i":s are "missing", so this is equivalent to (i, ai− j). (0, j) is equivalent

to (`, j), and (` + 1, j) is equivalent to (1, j). Fm−1

m also allows ∅, and Fm,pm and Fmm,pallow the combination mp, i.e. s = m.

The former is because Fm−1

m allows any number of repetitions of the full

cycle mam...`a`1a1...(m − 1)am−1, so it's natural to extend this to allowing

0 repetitions. The latter is because Fm

m,p and Fmm,p allow mp respectively

followed by and preceded by any number of repetitions of the full cycle, so we again extend this to 0 repetitions.

For F the equation is:

F =

`

X

i=1

F1i

where the case ∅ is included in F` 1.

Consider Fn,q

m . ∅ is allowed if n = m−1 and q = an. Otherwise, if sL= k`+i

and aL,sL = j, L ∼ F

i,j

m. R contains the rest of the sL:s and all but one of

the s:s, so R ∼ Fn,q−1

i,−j . This is also true if all sL:s are in L so j = ai, as

R ∼ Fi,−an,q−1i = Fi,0n,q−1 = Fi+1n,q−1. It's also true if q = 1 since this means R ∼ Fi,−jn,0 = Fi,−jn−1. This yields the following formula:

Fmn,q = δn,m−1δq,an+ x ` X i=1 ai X j=1 Fmi,jFi,−jn,q−1 (47)

L = ∅ should occur once in the sum, and R = ∅ should occur once if q = 1 because otherwise R must contain s. They are contained in j = ai∧ i = m−1

(36)

size of L given this restriction, and it does just that for m = i and 1 ≤ j ≤ ai.

1R = sR should occur once if q 6= 1 because it must contain all but one s,

and otherwise it should also occur once for each possible size. When q 6= 1 it occurs when j = ai and i = n + 1. When q = 1 it occurs when i = n and

1 ≤ j ≤ ai− 1 as well as when i = n + 1 and j = ai. Thus all special cases

are accounted for. Now consider Fn,q

m,p for p 6= am. We will need to add something to the sum

corresponding to the one in (47) to get Fn,q m,p: Fm,pn,q = x G + ` X i=1 ai X j=1 Fm,pi,j Fi,−jn,q−1 !

This is because in this sum, L is presumed to contain all instances of 1. When L consists entirely of p − k instances of 1, for k = 0 this case is included in the sum above with j = ai and i = m. Otherwise, we need to add the term

xp−kFn,q−1

m,k because aL,1 + aR,1 = p. The possible values of k are 1 to p,

including the case L = ∅. Thus,

Fm,pn,q = x G0+ ` X i=1 ai X j=1 Fm,pi,j Fi,−jn,q−1 ! + p X i=1 xp−iFm,in,q−1 !

We have now included all cases where all 1:s are in L, as well as all cases where L 6= ∅ and 1L = sL. But what about L = ∅? One such case is included

in the second sum above, with q = 1 ∧ i = p ⇒ R ∼ Fn−1

m,p , which allows

1R = sR = s − 1. But there are two such cases: R consisting of one unique

character which is s − 1, or s. The latter case, which is equivalent to 1 = s, is allowed when m = n and q = an, and in this case W ∼ xp ⇔ R ∼ xp−1,

so we get: Fm,pn,q = x ` X i=1 ai X j=1 Fm,pi,j Fi,−jn,q−1 ! + p X i=1 xp−iFm,in,q−1 ! + δm,nδq,anx p−1 ! (48)

(37)

F = ` X i=1 F1i Fm,pn,q = δn,m−1δp,amδq,an + x ` X i=1 ai X j=1 Fm,pi,j Fi,−jn,q−1 ! + (1 − δp,am) δm,nδq,anx p−1+ p X i=1 xp−iFm,in,q−1 !!

We can now apply Lemma 1. Thus the functions are algebraic, and thus the number of words fd has exponential asymptotic growth with respect to word

length d.

We can also apply (3) to get the coecients, calculating [xd]F after [xd]Fi 1: [xd]F = ` X i=1 [xd]F1i [xd]Fm,pn,q = ` X i=1 ai X j=1 Sd−1 Fm,pi,j , F n,q−1 i,−j  ! + (1 − δp,am) p X i=1 [xd−1−p+i]Fm,in,q−1 ! + δd,pδm,nδq,an ! + δd,0δn,m−1δp,amδq,an

Below are the rst thirteen terms of F for ` = 4 and (a1, a2, a3, a4) =

(3, 1, 1, 2), calculated with Mathematica. Calculating the coecients up to x1000 took 351 seconds.

F = 1 + x3+ 4x4+ 14x5+ 117x7+ 2210x10+ 7982x11+ 29002x12 + 282948x14+ 6662939x17+ 24959140x18+ 93742020x19+ ...

The number of unknowns given m, p, n is the number of ways to select q, which is an. Thus the number of unknowns given m, p is the sum of an

(38)

(ai)`i=1: S = P `

i=1ai. Given m, the number of unknowns is amS, and to

get the total number of unknowns we sum over the possible choices of m: P`

i=1aiS = S

P`

i=1ai = S2.

Some functions can be eliminated, but this can be done more eectively and to a greater extent if a is known.

(39)

A Proof of letter symmetry

The following is a continuation of Section 2.3.

Let Q4(d): for a1+ ... + as = d, A (a1, ..., as)is symmetric, or equivalently, we

can swap aj and aj+1 without changing the values for all j. We will also give

Q5(d)right away to give the proof a clear structure, but rst some denitions

for the sake of convenience: σ = aj+2 + ... + as and ai = (a1, ..., ai). Now

Q5(d): for a1+ ... + as = dand all j,

A (aj−1, aj+1− 1, aj + σ) + A (aj−1, aj − 1, aj+1, σ)

= A (aj−1, aj+1− 1, aj, σ) + A (aj−1, aj− 1, aj+1+ σ)

(49) Q4(0), Q4(1) and Q5(0) are obviously true. Assume Q4(k), Q4(k + 1) and

Q5(k), and let a1+ ... + as = k + 2. Q4(k + 2) is equivalent to

A (aj−1, aj, aj+1, ..., as) = A aj−1, aj+1, aj, ..., as  . Using (8) on the RHS: A (aj−1, aj+1, aj, ..., as) = j−1 X i=1 A (ai−1, ai− 1, ai+1+ ... + as) (50) + A (aj−1, ai+1− 1, aj+ σ) (51) + A (aj−1, ai+1, aj− 1, σ) (52) + s X i=j+2 A (ai−1, ai− 1, ai+1+ ... + as) (53)

The terms in (50) and (53) are equal to their equivalents in the LHS, because in (50) the swapped elements aj and aj+1 appear in the sum and in (53) they

appear in ai−1 and A has argument symmetry because of Q4(k + 1). This

leaves us with (51) and (52) as well as their equivalents in the LHS, which are precisely the four terms in (49) (after using Q4(k + 1)to rearrange some

arguments). Thus Q4(k + 2) ⇔ Q5(k + 1).

Before we apply the recurrence to the four terms of (49), we note that all terms except the last two or three are identical. The i:th term is

A (ai−1, ai − 1, ai+1+ ... + as− 1), where the last argument includes aj, aj+1,

the −1 that appeared with either of those, and σ. Thus we introduce ς = Pj−1

(40)

A (aj−1, aj+1− 1, aj + σ) = ς + A (aj−1, aj+1− 1, aj + σ − 1) (54) + A (aj−1, aj+1− 2, aj + σ) (55) A (aj−1, aj − 1, aj+1, σ) = ς + A (aj−1, aj− 1, aj+1, σ − 1) (56) + A (aj−1, aj− 1, aj+1− 1, σ) (57) + A (aj−1, aj− 2, aj+1+ σ) (58) A (aj−1, aj+1− 1, aj, σ) = ς + A (aj−1, aj+1− 1, aj, σ − 1) (59) + A (aj−1, aj+1− 1, aj − 1, σ) (60) + A (aj−1, aj+1− 2, aj + σ) (61) A (aj−1, aj − 1, aj+1+ σ) = ς + A (aj−1, aj− 1, aj+1+ σ − 1) (62) + A (aj−1, aj− 2, aj+1+ σ) (63)

The rst two and last two equations correspond to the LHS and RHS of (49), respectively. We can immediately eliminate (55), (58), (61), and (63). Using Q4(k) we can also eliminate (57) and (60). What remains are the

four terms of (49), except now the argument sum is k and the sequence is (aj−1, aj, aj+1, σ − 1), so the statement that remains is Q5(k), which is true

by assumption.

One might worry that the possibilities aj = 1, aj+1 = 1, and σ = 0 could

present a problem, because negative arguments appear on the RHS:s of the above equations. But if we deal with this by deleting all zeros from the arguments of the LHS:s above, what happens is that the term with the neg-ative argument on the RHS doesn't occur, and this aects both sides of (49) equally.

(41)

B Calculating coecients in Problem 2 using

Taylor series

Most of the algebraic calculations and simplications here were done by Mathematica, although we could have done without it and derived a more complicated formula. As we found in Problem 2,

F = s

1 − 2x + 2x21 − 4x − 12x2

2x2(5 − 2x + x2)

We can rewrite this as F = pg(x)(1 + h(x)), where

g(x) = 1 5 − 2x + x2 = 1/5 1 − (x/5)(2 − x) = ∞ X j=0 αjxj h(x) = 1 − 2x − √ 1 − 4x − 12x2 2x2 = ∞ X j=0 βjxj

The Taylor expansion of 1/(1 − f(x)) is 1 + f(x) + f(x)2+ f (x)3+ .... The

Taylor expansion of p1 + f(x) is the binomial series in f(x). To get αd,

we'll have to expand the powers of (x/5)(2 − x) using the binomial theorem, yielding a nested sum P∞

j=0

Pj

k=0α 0 j,kx

j+k. We can then retrieve α

d as the

sum of α0

j,k for j + k = d and k ≤ j. We use a similar approach to expand

1 − 4x − 12x2, the rst two coecients of which cancel the other terms in

the numerator of h(x). Dividing by 2x2 then yields the coecients β d.

αd =

1 205

−d

(2 + i)(1 − 2i)d+ (2 − i)(1 + 2i)d

βd = −8(−4)d  1/2 d + 2  2F1  −d 2 − 1 2, − d 2 − 1, −d − 1 2, −3 

where 2F1 is the Gaussian hypergeometric function, dened using the rising

(42)

2F1(a, b, c, x) = ∞ X j=0 a(j)b(j) c(j) xj j! a(d) = d−1 Y j=0 a + j

We then use γd to express the product g(x)(1 + h(x)):

γd= αd+ d X j=0 αjβd−j g(x)(1 + h(x)) = ∞ X j=0 γjxj = 1 + ∞ X j=1 γjxj F = v u u t1 + ∞ X j=1 γjxj = ∞ X j=0 1/2 j  ∞ X k=0 γk+1xk !j xj

The formula for the coecients of a power series raised to an integer power can be proven with induction:

δj,0 = γ1j = 2 j δj,d = 1 dγ1 d X k=1 (kj + k − d)γk+1δj,d−k Thus,

(43)

F = ∞ X j=0 ∞ X k=0 1/2 j  δj,kxj+k fd= d X k=0 1/2 k  δk,d−k F = ∞ X j=0 fjxj

where we get fd with the same approach as αd and βd. Thus:

αd=

1 205

−d

(2 + i)(1 − 2i)d+ (2 − i)(1 + 2i)d

βd= −8(−4)d  1/2 d + 2  2F1  −d 2− 1 2, − d 2− 1, −d − 1 2, −3  γd= αd+ d X k=0 αkβd−k δj,d =    2j , d = 0 1 2d d P k=1 (kj + k − d)γk+1δj,d−k fd= d X j=0 1/2 j  δj,d−j

C Alternative solution to Problem 3

This solution is based on dividing W into subwords Wi that are the subwords

of W between successive s:s, so if as= 3, W = W1sW2sW3sW4.

For F0,1, W = W1sW2 = LsR, so we can use (28) from Section 3.4: F0,1 =

x F2

0,0+ F0,12 + 2F0,1F0,2



. Let F0

0,1 = F0,1− xF0,02 , that is, F0,1 with the case

W1 < W2 subtracted. In other words, F0,10 is the function that corresponds

to all the dierent ways in which a pair of subwords may share a common element with each other, but not with any other subword.

References

Related documents

The pre-registration concerns a Type A power-generating facility which must meet all requirements of Commission Regulation (EU) 2016/631 establishing a network code on requirements

46 Konkreta exempel skulle kunna vara främjandeinsatser för affärsänglar/affärsängelnätverk, skapa arenor där aktörer från utbuds- och efterfrågesidan kan mötas eller

För att uppskatta den totala effekten av reformerna måste dock hänsyn tas till såväl samt- liga priseffekter som sammansättningseffekter, till följd av ökad försäljningsandel

The increasing availability of data and attention to services has increased the understanding of the contribution of services to innovation and productivity in

Av tabellen framgår att det behövs utförlig information om de projekt som genomförs vid instituten. Då Tillväxtanalys ska föreslå en metod som kan visa hur institutens verksamhet

Generella styrmedel kan ha varit mindre verksamma än man har trott De generella styrmedlen, till skillnad från de specifika styrmedlen, har kommit att användas i större

Närmare 90 procent av de statliga medlen (intäkter och utgifter) för näringslivets klimatomställning går till generella styrmedel, det vill säga styrmedel som påverkar

The reader should bear in mind that the aim of this study is not to investigate which grammatical categories each subject struggles with but to find out the