Counting words with Laguerre series

We develop a method for counting words subject to various restrictions by finding a combinatorial interpretation for a product of weighted sums of Laguerre polynomials with parameter \alpha = -1. We describe how such a series can be computed by finding an appropriate ordinary generating function and applying a certain transformation. We use this technique to find the generating function for the number of k-ary words avoiding any vincular pattern that has only ones, as well as words cyclically avoiding vincular patterns with only ones whose runs of ones between dashes are all of equal length.


Introduction
Consider the following simple problem. How many arrangements of the word "WALLAWALLA" are there with no LLL, AAA or WW as consecutive subwords? Perhaps surprisingly, the answer can be calculated by performing a certain integral. In fact, there are ∞ 0 e −t 1 24 such words, as we will see. More generally, we will develop a technique by which the generating function for the number of words subject to various conditions can be found by integrating a product against e −t , t 0. Since ∞ 0 e −t t n dt = n!, this amounts to applying the linear functional Φ : R[t] → R given by t n → n!.
Define a word W on an alphabet S to be an ordered list s 1 · · · s n of letters s i ∈ S. A subword of W is a word s l s l+1 · · · s l+m . Note that we require the indices in a subword to be consecutive, while some authors do not. Define a factorization φ on S to be an ordered list (φ 1 )(φ 2 ) . . . (φ k ) of non-empty words φ 1 , . . . , φ k using letters from S. We call φ 1 , . . . , φ k the factors or parts of φ. We abuse notation slightly by identifying a word W with the factorization (W ) in one part, and the empty word with the factorization having no parts, writing ∅ for both.
Given a factorization φ on S and T ⊆ S, let φ| T be the factorization whose parts are the maximal subwords of the parts of φ that use only letters from T , the parts of φ| T being ordered by their occurrence in φ. We call φ| T the restriction of φ to T . For example, if S = {a, b} and T = {a}, then the restriction of the factorization (aabba)(aab)(b)(aaa) to T is φ| T = (aa)(a)(aa)(aaa), while φ| {b} = (bb)(b)(b). If φ contains no letters from T , we define φ| T to be the empty factorization.
The methods given here will allow us to count words where only certain restrictions can occur. For example, consider the words W so that for each s ∈ S, the factors of W | {s} are all length one. This is equivalent to requiring that W have no adjacent, identical letters. Such words are sometimes called Carlitz, after Leonard Carlitz. Thus "PEAR" is Carlitz, but "APPLE" is not.
More generally, let A 1 and A 2 be two sets of factorization on disjoint alphabets S 1 , S 2 , respectively. Let S = S 1 ∪ S 2 , and denote by A 1 * A 2 the set of factorizations φ of words on S so that φ| S 1 ∈ A 1 and φ| S 2 ∈ A 2 . For example, if . .}, then A 1 * A 2 is the set of factorizations on {a, b} so that each factor is a Carlitz word. Thus (ab)(a)(a)(baba) ∈ A 1 * A 2 , but (b)(aab)(ba) / ∈ A 1 * A 2 . Perhaps surprisingly, the problem of counting words in A 1 * A 2 can be reduced to multiplication of certain power series. If A is a set of factorizations, we define a weight w on A to be a polynomial-valued function on A that obeys a certain combinatorial restriction. Then we will define a power series f A,w (t), the associated Laguerre series for A, in terms of the generalized Laguerre polynomials with parameter α = −1. The key fact we will use is the rule (Theorem 2.5) Furthermore, we will show in Proposition 2.4 that Φ(f A,w (t)) gives the weight of all factorizations in A with one or no parts, which we identify with words. By applying Φ to a product of Laguerre series we may count a variety of sets of restricted words, especially when the restrictions are on the length of runs of particular letters.
In Section 3, we describe the transformation T that turns certain ordinary generating functions into Laguerre series. The transformation can be described in terms of the Laplace transform, and so can be easily implemented in mathematics software packages. We use T to determine the Laguerre series for different sets of factorizations A, and use them to derive formulas and generating functions which count words that obey various restrictions.
In particular, we can use this technique to analyze certain pattern avoidance problems. A vincular, or generalized, pattern is a pattern with dashes such as 13-2. This is a generalization of classical permutation patterns where the dashes are used to indicate that the numbers on either side are not required to be adjacent, but all others are. These patterns were first studied by Babson and Steingrímsson [1], who showed that many statistics of interest can be classified in terms of vincular patterns. The term vincular itself was coined by Claesson in [4], from the Latin vinculare, to bind. Words avoiding vincular patterns are studied in [2, 5-7, 17, 21]. In this paper we will study vincular patterns with all ones, such as 111-11. Although such patterns are useless in the context of permutations, where only the pattern 1 can be contained, they are meaningful in the context of general words on the alphabet N where letters may be repeated. Since all of our patterns will have only ones, we give the definition in this context. A word W = s 1 · · · s l , with each s i in some alphabet S, contains a vincular pattern τ = 1 m 1 -· · · -1 mn if there is a subsequence of W consisting of m = m 1 + . . . + m n identical letters of which the first m 1 are consecutive, the next m 2 are consecutive, and so on. For example, a word contains 111-11 if it has five appearances of the same letter in the word so that the first three and the last two are consecutive. Formally, we say that W contains τ if there are indices 1 . . = s im and i j+1 − i j = 1 for j = m 1 , m 1 + m 2 , . . . , m 1 + . . . + m n−1 . Otherwise, we say that W avoids τ .
In Section 4, we give a formula to calculate the generating function for the number of words avoiding any such vincular pattern with only ones. This formula involves the use of the maps T and Φ, but these can be easily calculated. For example, we can use Sage to compute the the generating function W x len(W ) where the sum is taken over all ternary words W avoiding the pattern 11-11, where len(W ) is the length of W , the number of letters counting multiplicity: We give a cyclic version of this result in Section 5 for the case of patterns 1 m -1 m -· · · -1 m , where all runs of ones are the same length. This gives the generating functions for words so that any cyclic permutation of their letters avoids such a pattern. This generalizes a result of Burstein and Wilf [8] which gives the generating function for the number of words cyclically avoiding 1 m .

Acknowledgments
The author would like to thank Sara Billey, Ira Gessel, Silvia Heubach, Yannick van Huele, Toufik Mansour, Brendan Pawloski, Austin Roberts, Byron Schmuland and William Stein for their extraordinary support. Without them this paper would still be "floating in platonic heaven".

Laguerre polynomials and Laguerre series
Define the polynomials l k (t) by their generating function The first few such polynomials are These polynomials are a form of Laguerre polynomial. Specifically, defines the generalized Laguerre polynomials. They have been found to have a number of interesting combinatorial properties, beginning with their use by Even and Gillis to count generalized derangements when α is set to 0 in [12]. This was later extended by Foata and Zeilberger who use α to keep track of the number of cycles [13]. For our purpose, we will take α = −1.
Recall that a word on [k] = {1, 2, . . . , k} is called k-ary, and a word in which no two adjacent letters are the same is called a Carlitz word. In 1988, Ira M. Gessel [14,Section 6] used his theory of generalized rook polynomials to find an explicit formula for the number of Carlitz arrangements of a given multiset of letters. We present here an unlabeled version.
Theorem 2.1. Let Φ be the linear functional on polynomials in t given by Φ(t n ) = n!. Given nonnegative integers n 1 , . . . , n k , the number of k-ary Carlitz words with the letter i used exactly n i times is For example, in [3] the authors consider the "Mississippi Problem". How many arrangements of the letters in the word "MISSISSIPPI" have no adjacent letters the same? We can use the preceding theorem to calculate this directly. There is one M, four I's, four S's, and two P 's. So the solution is Our proof of Theorem 2.1 does not involve rook polynomials, but is based on the following surprisingly simple expression for the generating function for the number of Carlitz words with a given set of letters.
Lemma 2.2. Let C be the set of Carlitz words over the alphabet N. For a word W = s 1 · · · s n define its weight to be w(W ) = x s 1 · · · x sn , so that the exponent of x i records the number of occurrences of the letter i. Then Lemma 2.2 can be found in the book by Goulden and Jackson [16, 2.4.16]. They attribute it MacMahon's book from 1915 [19] and Smirnov, Sarmanov, and Zaharov in (1966) [24], and so counting Carlitz words is sometimes known as the Smirnov problem.
The case x i = x i was found, apparently independently, by Carlitz in 1977 [9]. Asymptotics of Carlitz compositions are investigated using this formula by Knopfmacher and Prodinger in [18]. This result can be generalized to the Carlitz-Scoville-Vaughan Theorem [10], a reciprocity result relating the words for which only a given set of pairs of letters are adjacent to the words where none of these pairs are adjacent.
Proof of 2.2. We have We see that this sum represents a method of choosing a word W . We choose a number of steps, n, and at each step we choose a letter i and append any number of copies of it. Suppose W is not Carlitz, and write W = W 1 iiW 2 where W 1 is Carlitz so that the subword ii is the first adjacent repetition. If the i's were chosen in separate steps we may merge the steps together, and if the i's were chosen in the same step we may split the steps apart. This gives a bijection between the ways W may be formed in these two cases, and the monomials representing them in the power series above will appear with opposite sign. Thus any such W will be canceled in the sum. The remaining Carlitz words can only be represented in one way, with positive sign.
Now we can give a simple proof of Gessel's formula.
Proof of Theorem 2.1. Note that Φ(e tf ) = 1 1 − f for any f that is constant with respect to t when both sides are defined, where Φ is extended in the natural way to some power series. Then we see x km m on both sides we get the desired formula by Lemma 2.2 and the generating function (1).
Using Theorem 2.1, it is easy to see combinatorially that and so the polynomials l k (t) are "almost" orthogonal with respect to Φ.
Note that l k (t) is a polynomial of degree k; so the matrix of l k 's expanded into powers of t is triangular with no zeroes on the diagonal, and so {l k } k forms a basis of R[t]. It is natural to ask, then, what is the expansion of l i (t)l j (t) in this basis? These are known as linearization coefficients. The linearization coefficients of general Laguerre polynomials, with α indeterminate, is known [13,27], but we will need a combinatorial interpretation of the case α = −1.
Denote by n i,j,k the number of factorizations over the alphabet {a, b} with k parts and exactly i a's and j b's so that each part is Carlitz. For example, n 2,5,3 = 6: the possibilities are (bab)(bab)(b), (babab)(b)(b) and the different permutations of these sets of factors.
This is a homogenous linear recurrence relation with constant coefficients for the factorial sequence, which is impossible unless a 0 = a 1 = . . . = a n = 0 since it the factorial is superexponential. Since {l k (t)} k forms a basis for R[t], if Φ(p(t)l k (t)) = 0 for all k then we can conclude p(t) = 0. So it is enough to show that for any nonnegative integers i, j, m, We know that the left hand side counts the number of Carlitz arrangements of i a's, j b's, and m c's, while the right hand side gives the total number of pairs (φ, W ) where φ is a factorization in k parts with i a's and j b's with each part Carlitz, and W is a Carlitz word with k x's and m c's. There is a simple bijection between these sets. Given such a pair (φ, W ), we can get a Carlitz arrangement of i a's, j b's and m c's by replacing the ith x of W with the ith part of φ. For example, if φ = (ab)(bab) and W = cxcx, we get the Carlitz word cabcbab. This process is reversible: given a Carlitz word on a, b, c we replace the c's by parentheses to make a factorization φ with only the letters a and b, and to get W we replace each maximal subword that does not contain c by a single x, getting a word with only c's and x's. For example, given the word abcbcab, we get the pair W = xcxcx, and φ = (ab)(b)(ab). The maximality condition guarantees that W will be Carlitz.
Definition. Given a set of factorizations A on an alphabet S, a weight is a function w from A and all of the restrictions of factorizations in A into a polynomial ring R[x 1 , x 2 , . . .] that commutes with restriction in the sense that if φ ∈ A and T ⊆ S, then w(φ) = w(φ| T ) w(φ| S\T ).
Note that in particular, if A = A 1 * A 2 for some sets of factorizations A 1 , A 2 then w is also a weight on A 1 and A 2 . Also note that taking T to be empty forces w(∅) = 1. Typically we will take the weight w(φ) to be a monomial x is multiplicative in the above sense. In all our examples it will be obvious that w is a weight. Examples include • len(φ), the length of φ • sum(φ), the sum of the letters in φ if the symbols in φ are nonnegative integers • the number of distinct symbols in φ • the number of appearances of a particular symbol or simply w = 1 if we wish to enumerate a finite set. We write par(φ) for the number of parts of φ; but x par(φ) is in general not a weight.
Definition. Let A be a set of factorizations on an alphabet S and w be a weight on A. Define the Laguerre series of A with respect to w to be the formal power series when this sum is well-defined as a formal power series. For convenience we will omit the w in the subscript when w = 1, writing f A,1 (t) as f A (t).
Convergence of Laguerre series is studied in, e.g., [23,25,26], where they are defined as series Our definition is slightly different, as we always take α = −1 and our coefficients may be weighted.

Proposition 2.4. Assume
A is a set of factorizations and w is a weight on A. Let Φ be the linear operator so that Φ(t n ) = n! and Φ fixes any other variables. Then when both sides are defined, where the sum is over allowed words W ∈ A which are factorizations with one or no parts.
Proof. We have and Φ(l par(φ) (t)) is 1 when φ has one or no parts and is 0 otherwise by (2) since l 0 (t) = 1 and l 1 (t) = t.
It is easy to see that if A 1 and A 2 are disjoint sets of allowed factorizations on a common alphabet S, w is a weight on A 1 ∪ A 2 , then More interesting, perhaps, is the combinatorial interpretation of a product of Laguerre series. This is our main theorem on the combinatorial properties of Laguerre series. Recall that if A 1 , A 2 are sets of factorizations on disjoint alphabets S 1 , S 2 , then A 1 * A 2 was defined to be the set of factorizations φ of words on S = S 1 ∪ S 2 so that φ| S 1 ∈ A 1 and φ| S 2 ∈ A 2 . Theorem 2.5. Let S 1 and S 2 be disjoint alphabets with sets of allowed factorizations A 1 ,A 2 respectively, and let w be a weight on A 1 * A 2 (and hence on A 1 and A 2 .) Then Proof. By Lemma 2.3, It is enough to show that n par(φ 1 ),par(φ 2 ),k is the number of factorizations with k parts on S 1 ∪ S 2 whose restrictions to S 1 and S 2 are φ 1 and φ 2 , respectively. Then each allowed word of A 1 * A 2 will then be represented exactly once in the series For fixed k, we will construct a simple bijection from the set of triples (φ, φ 1 , φ 2 ) where φ 1 , φ 2 are factorizations in A 1 , A 2 respectively and φ is a factorization on the alphabet {a, b} with par(φ 1 ) a's and par(φ 1 ) b's so that each part is Carlitz, and the set of factorizations φ 3 of A 1 * A 2 with k parts. Let φ 3 be the factorization created by replacing the nth a in φ with the nth part of φ 1 , and the nth b with the nth part of φ 2 . Then by construction φ 3 ∈ A 1 * A 2 : its restrictions are φ 1 and φ 2 . Furthermore, given an allowed factorization φ 3 ∈ A 1 * A 2 with k parts so that φ S 1 = φ 1 , φ S 2 = φ 2 , we can reconstruct the factorization φ of a word on {a, b} by replacing each subword of a factor of φ 3 that uses only the letters of S 1 , and is maximal with respect to this condition, by an a and each maximal subword using only letters of S 2 by a b. For example, if S 1 = {1, 2} and S 2 = {3, 4}, with φ 3 = (123, 2213, 34413), we get the word φ = (ab, ab, bab). No part of φ can have aa or bb by the maximality condition. These two algorithms are inverse to each other, establishing the theorem.
Inductively, we see that if A 1 , . . . , A n are sets of factorizations on disjoint alphabets and w is a weight on A 1 * · · · * A n , then f A 1 * ··· * An,w (t) = f A 1 ,w (t) · · · f An,w (t). Thus we have the following extension of Lemma 2.3: Corollary 2.6. Let S = {a 1 , . . . , a m } be an alphabet of m distinct letters, and r 1 , . . . , r m be fixed nonnegative integers. Let n k denote the number of factorizations on n letters in k parts so that each part is Carlitz, and the ith letter a i of S is used exactly r i times for each i. Then Proof. Let A i consist only of the factorization (a i )(a i ) · · · (a i ), with exactly r i factors. Then A 1 * · · · * A m consists of those factorizations for which each part is Carlitz and the letter a i is repeated n i times so we may apply Theorem 2.5. Alternately, we can adapt the proof of Lemma 2.3.

Computing Laguerre series
The Laguerre series for a set of factorizations would not be especially useful if it was difficult to compute. Fortunately, there is an efficient method to calculate them in some situations. It may be difficult to find a convenient formula for the coefficients of l k (t) in a given Laguerre series f A,w (t), but this is not needed to find an expression for f A,w (t). It is enough to find the ordinary generating function. Specifically, we define If a nice form of g A,w (u) is known, we may obtain the Laguerre series f A,w (t) by applying the linear transformation T that sends u k to l k (t). As it happens, T can be computed in many situations using the inverse Laplace transform. We have where L is the Laplace transform; this is easily proved from the formula for l k (t) in terms of the generalized Laguerre polynomials, the fact that L{t i } = i! s i+1 , and the binomial theorem.
Therefore, if g A,w (0) = 0, we have by linearity when the right-hand side is well-defined. If g A,w (0) = 0, we can calculate since l 0 (t) = 1. The use of the inverse Laplace transform here is not central to the theory, but it is convenient since many software packages provide symbolic calculation of the inverse Laplace transform, making it easy to implement the transformation T . In many cases, we can use standard generating function techniques to calculate g A,w (u). For example, let A be the set of all factorizations on a single-letter alphabet, and let w be the weight w(φ) = x len(φ) . Then we see that since we choose a factorization φ by choosing the number of parts and then choosing the size of each part. We may simplify this expression to get g A,w (u) = 1+x 1+x−ux , and calculate f A,w (t) = T {g A,w (u)} = e tx . Taking the coefficient of x k shows that the Laguerre series for all factorizations on this single-letter alphabet with length k is t k k! . Thus Proposition 2.4 and Theorem 2.5 tell us that is the total number of words on an alphabet S = {c 1 , . . . , c n } so that c k is used at most r k times, where r 1 , . . . , r n is a set of nonnegative integers. Of course, this formula can also be seen directly.
Laguerre series are sometimes useful for counting words with certain subwords prohibited. Consider the following problem: given a word W and a subword W ′ of W , how many words are there avoiding W ′ as a subword that can be made from W using each symbol at most as many times as it appears in W ? To answer this, we form the set A 1 of factorizations that can be made from W that use only letters from W ′ and do not contain W ′ as a subword of any factor. Letting A 2 be the set of all factorizations of words that can be made from W in the above sense that do not use any letters from W ′ , we see that A 1 * A 2 is the set of all factorizations of words that can be made from W so that no part contains W ′ as a subword. Setting w = 1, we may perform a brute force calculation to compute the Laguerre series f A 1 (t). Since there are no subword restrictions on the remaining letters, we have where the product is over the letters c used in W that are not used in W ′ , and n c is the number of times c is used in W . So the solution is given by Φ This method is practical if there are not too many letters used in the W ′ , and the number of times these letters are repeated in W is small. For example, how many words are there that can be made from the letters in "CONSTANTINOPLE" that avoids the subword "TNT"? We focus on the letters T and N, forming the set A 1 consisting of those factorization of words using only these letters, with three or fewer N's and two or fewer T 's, so that no factor contains "TNT". We then perform a brute force count using a programming language such as Sage to explicitly calculate the Laguerre series for A 1 with respect to w = 1, getting Then forming A 2 as above, the set of factorizations of any words made from the remaining letters "COSAIOPLE", we calculate f A 2 (t) = (t + 1) 7 ( 1 2 t 2 + t + 1) since all of the letters appear only once, except O which appears twice. Therefore, the answer is ∞ 0 e −t 1 12 t 5 + 5 12 t 4 + 2 3 t 3 + t 2 + t + 1 (t + 1) 7 1 2 t 2 + t + 1 dt = 9,854,474,467.
A more general method for the subword avoidance problem is the cluster method developed by Goulden and Jackson [15,16]. This a powerful tool using linear algebra and inclusion-exclusion to find rational generating functions for words avoiding any given set of subwords. Noonan and Zeilberger [22] give generalizations and a good introduction to the idea; Edlin and Zeilberger also give an extension to cyclic words [11]. Now consider the problem of counting words that have no subword consisting of m identical letters. These are words that avoid the subword pattern 1 m , and are sometimes called m-Carlitz words; when m = 2 we have the ordinary Carlitz words. To find the generating function, let A be the set of factorizations on a one-letter alphabet with each part having length smaller than m, and again let w(φ) = x len(φ) . We see that and so we compute Taking the coefficient of x n in (3) gives the Laguerre series for the set of factorizations with length n so that each part is smaller than m. This gives a generalization of Theorem 2.1. If m 1 , . . . , m k , n 1 , . . . , n k are nonnegative integers, and p m,n (t) are polynomials is the total number of k-ary words that use the letter i exactly n i times and do not contain the subwords i m i . Thus the number of arrangements of the word "WALLAWALLA" with no LLL, AAA or WW as consecutive subwords is Recalling again the formula we see that the generating function for the number of k-ary m-Carlitz words of length n is given by

Another derivation of this formula is given by Burstein and Mansour [7, Example 2.2].
We may set indeterminates to count the number of occurrences of each symbol. Let where i j is the number of appearances of j in a factorization φ on the alphabet [k]. By (3) and (3), we see that gives the sum of all weights in m-Carlitz k-ary words. This can also be found by substi-

Vincular patterns
We are now ready to state a general formula for k-ary words avoiding vincular patterns with ones. We say that a k-ary factorization φ contains a vincular pattern τ with only ones if the word made from φ by inserting a single 0 between each pair of adjacent factors contains τ , and this copy of τ does not use 0. Using the transformations T and Φ, we can reduce the problem to finding ordinary generating functions for factorizations that only use one symbol and avoid the given vincular pattern.  Let m 1 , . . . , m n be positive integers, and let A be the set of k-ary words avoiding the pattern τ = 1 m 1 -1 m 2 -· · · -1 mn . Then where T is the operator defined in Section 3, and Proof. Earlier we observed that e tx is the Laguerre series for all factorizations using only a single letter with respect to the weight w(φ) = x len(φ) . So it is enough to show that G τ (x, u) = g A,w (u) where A is the set of factorizations on some single letter alphabet containing the given vincular pattern; the difference will then count the factorizations on a single letter which avoid the pattern. For the remainder of the proof, we will use only the alphabet {1}. We will use repeatedly the following basic facts:

Fact 1. Given two sets of factorizations A 1 and A 2 , let
Then g A 3 ,w (u) = g A 1 ,w (u) · g A 2 ,w (u) when both sides are defined.

Fact 2. Let
A be a set of factorizations on the alphabet {1}. Then for a fixed integer k 0, let A k be the set consisting of each factorization of φ with k ones appended to the last factor: A k = {(φ 1 )(φ 2 ) · · · (φ n 1 k ) : (φ 1 ) · · · (φ n ) ∈ A}. Then g A k ,w (u) = x k g A,w (u).
We say that a factorization minimally contains the pattern 1 m 1 -1 m 2 -· · · -1 mn if it contains the pattern, but no longer contains the pattern if the last letter of the last factor is removed. For example, (11)(1)(1)(111) contains 111 minimally, contains 11-11 but not minimally, and does not contain 1111 at all. Define a truncation of a factorization φ = (φ 1 ) · · · (φ n ) to be a factorizationφ = (φ 1 ) · · · (φ i−1 )(φ i ), where 1 i n and φ i is a nonempty initial substring of φ i . Any factorization containing a pattern has a unique truncation that contains that pattern minimally, so we will count the factorizations containing it minimally and then multiply by the appropriate expression to count all factorizations that contain the pattern.
First, suppose the pattern is just 1 m 1 . A factorization minimally containing this pattern is any factorization whose last part has size m 1 , and all other parts have size strictly smaller. So the generating function for these factorizations is Now let the generating function for the number of words minimally containing the pattern 1 m 1 -· · · -1 mn be g n (x, u); we will find g n (x, u) in terms of g n−1 (x, u). Let φ be a factorization minimally containing 1 m 1 -· · · -1 m n−1 -1 mn ; then φ has a unique truncationφ that minimally contains 1 m 1 -· · · -1 m n−1 . Thus to find g n (x, u) we multiply g n−1 (x, u) by the appropriate factor, mimicking the following process by which any such φ is attained uniquely from someφ. If φ andφ have the same number of factors, φ must beφ with exactly m n 1's appended to the last factor; so we multiply by x mn . Otherwise, we can assume a new factor is necessary. In this case, we may lengthen the final part of φ by adding 1's, but to avoid having the pattern 1 m 1 -· · · -1 mn without adding any factors at most m n − 1 should be added. This means we should first multiply by Then, we may append some (possibly empty) sequence of factors toφ, each having length less than m n . This amounts to multiplying by Finally, we append a new factor which is just 1 mn , multiplying by ux mn . Thus we multiply by So the ordinary generating function minimally avoiding 1 m 1 − . . . − 1 mn is exactly .
Finally, once we have a factorization minimally containing the pattern, we may add any number of ones to the last factor and append any list of factors and the resulting factorization will still contain the pattern. This amounts to multiplying by Putting this all together, we see inductively that the generating function for factorizations containing the pattern is

Cyclically avoiding patterns
We say that a word W cyclically avoids a vincular pattern τ if W avoids τ no matter how its letters are cycled. More formally, let r be the function that cycles W , moving the last letter into the first position: r(a 1 · · · a n ) = a n a 1 · · · a n−1 . Then W cyclically avoids τ if r k (W ) avoids τ for each k.
In order to find the generating function for the number of words cyclically avoiding the pattern τ = 1 m -1 m -· · · -1 m , we will need a little more information than provided by the generating function G τ (x, u) defined by (4). Let H(x, u, v) = g A,w (u) where A is the set of factorizations on the alphabet {1} avoiding the pattern τ andŵ is the weight w(φ) = x len(φ) u par(φ) v fst(φ) where fst(φ) is the size of the first factor of φ. Note thatŵ is trivially a weight by our definition since we are using a singleton alphabet, but generally is not. We will find a closed-form expression for H(x, u, v), although it is rather unwieldy.
Lemma 5.1. The generating function H(x, u, v) is given by Proof. Fix n > 0, and let τ n be the pattern 1 m -1 m -· · · -1 m with n − 1 dashes. Then by the proof of Theorem 4.1, we know that if G n (x, u) is the generating function (4) for the number of factorizations on the alphabet {1} containing τ n , then since in this case m 1 = m 2 = . . . = m. We have different cases depending on how much of the pattern τ n is contained in the first part of a factorization. Let A be the set of all factorizations on the alphabet {1} that contain τ n , and define define A 0 , A 1 , . . . , A n by First, suppose that φ ∈ A 0 . Then the first part of φ is one of 1, 11, . . . , 1 m−1 , and the factorization (φ 2 ) · · · (φ k ) of the remaining parts can be any factorization containing the pattern. With the exponent of v recording the size of the first factor, we see that the generating function corresponding to this case is Then the first part of φ is one of 1 im , 1 im+1 , . . . , 1 im+m−1 and (φ 2 ) · · · (φ l ) can be any factorization containing τ n−i . So the generating function corresponding to A i is If φ ∈ A n , then the first factor of φ can have any length that is nm or more, and the remaining parts of φ can be any factorization. Therefore .
To find the generating function for factorizations avoiding the pattern, we must subtract g A i ,w (u), 0 i n, from the generating function for all one-letter factorizations, which is .
We have After simplifying, we have the desired formula.
Theorem 5.2. Let H(x, u, v) be the generating function (5). Let A be the set of words cyclically avoiding the pattern τ = 1 m -1 m -· · · -1 m , with n − 1 dashes, and let w be the weight on k-ary words with w(s 1 . . . s l ) = x s 1 x s 2 · · · x s l . Then the generating function W ∈A w(W ) is given by In particular, letting x i = x for each i gives: Proof. We will count all words which avoid τ and begin with i, where 1 i k, and then sum over i. Let W be the set of all k-ary words W that begin with i, do not end in i, and avoid the pattern τ . Any W ∈ W will in fact cyclically avoid τ . To see this, it is enough to note that the restriction r p (W )| {j} , for any j, p, will avoid the pattern. Such a factorization will either be a permutation of the parts of (W )| {j} , or will have some part of (W )| {j} divided into the first and last part of r p (W )| {j} . Permuting the factors will not cause (W )| {j} to contain the pattern by the symmetry of τ , and splitting a part into two cannot create an instance of the pattern either.
We can characterize W as follows. Suppose φ = (φ 1 ) . . . (φ p ) is a factorization over the alphabet [k]\{i}. Then we can insert i's appropriately in between factors so that the result starts with i and avoids the pattern. Given a factorization ψ = (ψ 1 ) . . . (ψ p ) which avoids the pattern and has the same number of parts as φ but only uses the symbol i, let W φ,ψ = ψ 1 φ 1 ψ 2 φ 2 . . . ψ p φ p be the concatenation of the alternating factors of φ and ψ. Then W φ,ψ start with i, will not end in i, and avoids τ , so W φ,ψ ∈ W. Furthermore, if W ∈ W, let φ be the restriction W | [k]\{i} , and ψ = W | {i} . Then φ and ψ will have the same number of factors, and W = W φ,ψ . So we see that W coincides with the set of W φ,ψ where φ, ψ are nonempty factorizations over the alphabets [k]\{i} and {i}, respectively, which avoid τ and have the same number of parts.
The words W ∈ W we have described always end in a letter besides i; to get all words avoiding the pattern starting with i, we associate W ∈ W with a class where B(W ) is the number of adjacent i's at the beginning of W . These rotated words will also cyclically avoid the pattern, as we have explained, and begin with at least one i. Furthermore, any word V beginning with i and avoiding the pattern will be in the class of a unique word W : let W = r C V where C is the number of i's on the end of V , if any. Therefore we will count all words W that avoid the pattern and begin with i, but do not end with i, with the multiplicity B(W ), the number of i's at the beginning of the word W . This will account for all words beginning with i that use at least one letter j = i. So the weight of all k-ary words that begin with i, cyclically avoid the pattern τ , and contain at least one letter j = i is where the sum on the right-hand side is taken over all factorizations φ, ψ over the alphabets [k]\{i} and {i}, respectively, which avoid τ and have the same number of parts.
For any 1 j k let A j be the set of nonempty factorizations on the alphabet {j} that avoid the pattern. Define where theÂ i indicates that A i is removed, and let Then by the previous discussion, we see that is the weight of all k-ary words avoiding the pattern τ which begin with i and use at least one letter j = i. It remains to evaluate the right-hand side. We make use of the well-known fact that the generalized Laguerre polynomials obey the orthogonality relation which can be found in, e.g., [20, p. 241]. Although this only holds in general when α > −1, it is true for α = −1 if i 1. We have for i 1. Thus for a function f (t) that is a formal sum of the Laguerre polynomials l p (t), we can extract the coefficient of l p (t) by evaluating Φ(pt −1 l p (t)f (t)), for p 1. Furthermore, we see that if f (t) = p 1 pa p l p (t) and g(t) = p 1 b p l p (t), we have when both sides are well-defined. We require p 1 since the orthogonality relation (7) fails when i = 0. In this case, p 1 b p l p (t) is the Laguerre series for nonempty k-ary words avoiding the pattern that do not use i; it is given by j =i T {H(x j , u, 1)} − 1. To find p 1 pa p l p (t), recall from the Lemma 5.1 that H(x, u, v) = φ∈A i x len(φ) u par(φ) v fst(φ) . So Then applying T , we see that Thus by (8), is the generating function for the number of k-ary words that begin with i, use at least one j = i, and cyclically avoid the pattern. This does not account for the words that use only the letter i and avoid the pattern, which are the words i k , with k < mn. So we must add (9) to get the full generating function for all words that begin with i and cyclically avoid τ . Summing over i and adding 1 to represent the empty factorization gives If we set n = 1, considering k-ary words that cyclically avoid 1 m , the formula simplifies considerably. After some computation, which we omit here, we arrive at the following formula.
Corollary 5.3. Let A be the set of nonempty k-ary words avoiding 1 m . Let w be the weight w(a 1 · · · a l ) = x a 1 x a 2 · · · x a l . Then In the book by Heubach and Mansour [17], the authors define a cyclic Carlitz composition as a Carlitz composition so that the first and last parts are not equal; they ask (Research Direction 3.3) for the generating function for the number of cyclic Carlitz compositions. If we let k approach infinity, m = 2, and x i = x i , we get the following.
Setting x i = x in Corollary 5.3 and simplifying gives the following formula.
This was found by Burstein and Wilf [8]. They go on to show that the number of k-ary words of length n cyclically avoiding 1 m is asymptotically β n , where β is the positive root of x m+1 = (k − 1)(1 + x + x 2 + . . . + x m ). In fact, they extract an explicit formula when n is sufficiently large.
We can also give a cyclic version of Theorem 2.1, which can be derived by extracting the coefficient of a monomial x n 1 1 · · · x n k k in the generating function from Theorem 5.2 for words cyclically avoiding 1 m .
Corollary 5.6. Let n 1 , . . . , n k be positive integers, and let p m,n (t) be defined as before by ∞ n=0 p m,n (t) x n = exp t(x−x m ) is the total number of k-ary words that use the letter i exactly n i times and cyclically avoid 1 m , where N = k i=1 n i is the total number of letters counted with multiplicity.

Questions and future directions
There are a number of related questions that remain open. Is it possible to extend the work of Section 5, finding generating functions for words avoiding other cyclic patterns? Is there a formula generalizing Theorem 4.1 or Theorem 5.2 to to count the number of occurrences of a given pattern of ones? One might also look for a combinatorial interpretation of some form of composition of Laguerre series; empirically, it seems that l i (l j (t)) has nonnegative integer coefficients in the l k -basis for j > 0. Finally, it would be useful to develop bijections from sets of words with restrictions to other combinatorial objects that are not obviously described in terms of words, using the methods outlined here to count sets that may be otherwise difficult to enumerate.