Enumeration of r -smooth words over a ﬁnite alphabet

In this paper, we enumerate a restricted family of k -ary words called r -smooth words. The restriction is deﬁned through the distance between adjacent changes in the word. Using automata, we enumerate this family of words. Additionally, we give explicit combinatorial expressions to enumerate the words and asymptotic expansions related to the Fibonacci sequence


Introduction
The enumeration of words with a given combinatorial property has been studied extensively from various perspectives in enumerative combinatorics and theoretical computer science. For example, the study of occurrences of a given pattern in words or other structures, such as permutations, is an active area of research (cf. [4,9]). In this paper, we consider a new family of restricted words defined through the distance between adjacent changes in the word. This notion is closely related to one introduced by Knopfmacher et al. [6]. In particular, they considered words such that there are no two adjacent letters with difference greater than 1. This notion was also introduced for compositions [5], integer partitions [7], and polyominoes [8].
For a positive integer k, we denote the set {1, 2, . . . , k} by [k]. A k-ary word of length n is an element of [k] n . Let w = w 1 w 2 · · · w n be a k-ary word. We say that w has a change in the position i if w i = w i+1 . We denote by P(w) the sequence of the position changes that occur in w. For example, P(331154222) = (2,4,5,6). Let r be a positive integer, a k-ary word w = w 1 w 2 · · · w n is r-smooth if either w does not change, there is exactly one change, or p i+1 − p i ≤ r for all p i ∈ P(w) and For example, the word w = 331154222 is 2-smooth. Let S (r) k,n denote the set of r-smooth k-ary words of length n and S (r) The main purpose of this paper is to enumerate the r-smooth words according to the length of the word and the number of changes. We use automata theory, generating functions, bijective arguments, and asymptotic analysis to describe our results.

Counting r-smooth words
Given a r-smooth k-ary word w, we denote the length and number of changes of w by |w| and c(w), respectively. We define the bivariate generating function Notice that the coefficient of x n q i in G k,r (x, q) is the number of r-smooth k-ary words of length n with exactly i changes.
We will identify A k,r with a (labelled) directed graph G k,r with vertices in V r such that there is a (labelled) edge τ → a τ between τ and τ , if τ = δ(τ, a). Proof. In order to prove the theorem, we have to show that δ is a bijection between some classes (we define them next) of the words in S k with prefix τ and n letters. Let σ = σ 1 · · · σ n ∈ S (r) k , we read σ from left to right. First, we read σ 1 . By exchanging the letters 1 and σ 1 in σ, we obtain that |S Now, we assumed we read the first j + 1 ≥ 1 letters of σ = 12 j σ j+2 · · · σ n ∈ S (r) k (12 j , n), where j = 0, 1, . . . , r. Here we distinguish between two cases: • Let σ j+2 ∈ [k]\{2}. Then the distance between first two changes of j + 1 − 1 = j ≤ r, so by removing the first j letters of σ and exchanging the letters 2, σ j+2 to 1, 2, we obtain that |S Hence, we have δ(12 j , a) = 12 for all a ∈ [k]\{2} and j ≤ r.
This completes the proof.
Example 2.1. The directed graphs G 3,2 is given in Figure 1. LetG k,r be the same directed graph G k,r where we weighted each edge 12 j → a 12 j+1 by q whenever a = 2. So, as consequence of Theorem 2.1, we can state the following result. Let M k,r be the (r + 3) × (r + 3) adjacency matrix of the weighted directed graphG k,r . Thus, Let e r = (1, 0, . . . , 0) be a row vector and f r = (1, 1, . . . , 1) be a column vector of r + 3 coordinates. Hence, by Theorem 2.1, we have Note that it is not hard to see the first row of the matrix (1 − xM k,r ) −1 is given by .
Hence, we can state the following result.
Theorem 2.3. The generating function G k,r (x, q) is a rational generating function given by .
For example, for k = 3 and r = 1 we obtain the generating function The corresponding words to the bold coefficient in the above series are There is an alternative way to obtain the generating function by means of the symbolic method. Remember that S (r) k denotes the family (combinatorial class) of all r-smooth k-ary words, then we can write a symbolic equation: where Z i denotes an atomic element (a symbol of the alphabet). For a general background about the symbolic method see the book [3]. In terms of generating functions, the last equation translates into .

Combinatorial expressions
In the following theorems we study the number of r-smooth words of length n. This new counting sequence is denoted by s k,r (n).
Theorem 2.4. The number of r-smooth k-ary words of length n is given by Proof. From Theorem 2.3 we have that for all positive integers n This with n − 2 = + i + j implies the desired result.
In the following theorem we generalize the above recurrence relation. Let a k,r (n) be the recurrence relation of order r defined by a k,r (n) = (k − 1)(a k,r (n − 1) + a k,r (n − 2) + · · · + a k,r (n − r)) (1) for n ≥ r, and the initial values a k,r (n) = 0 for n ≤ r − 2 and a k,r (r − 1) = 1.
Theorem 2.5. For all n ≥ 1 we have Proof. From Theorem 2.3 we have that for all positive integer n .
Notice that the generating function of the sequence (a k,r (n)) n≥0 is the rational function Therefore, the Cauchy product implies the desired result.
Combinatorial proof. Notice that a k,r (m + r − 1) is the number of colored compositions of m with colors in [k − 1] such that each part is in [r]. This can be seen by considering the recursion on those colored partitions when selecting the last part of the component. Adding over all possibilities for the last part, one gets the recursion for a k,r (n). Using this, and the decomposition of a r-smooth k-ary word w given by w = a α1 1 . . . a α with a j = a j+1 and (α 1 , . . . , α ) a composition of n with α 1 + α = i, one can add over all possible choices of i = α 1 + α which gives where k(k − 1) is multiplied for choosing the first and last letters from [k]. The results follow from the change of variable i → n − i. Table 1 shows the number of r-smooth k-ary words for small values of r and k.    Table 2: Some numerical values of the sequences s 5,3 (n) and b 5,3 (n).

The r-rough words
Changing the inequality that defines r-smooth words, one gets r-rough words, i.e., k-ary words of length n such that if P(w) = (p 1 , . . . , p c(w) ) then either c(w) ≤ 1, or p i+1 − p i ≥ r for i ∈ [c(w) − 1]. The set of r-rough k-ary words of size n is denoted as T  Theorem 2.8. The number of r-rough k-ary words of length n is given by Proof. As in the proof of Theorem 2.4, one can understand a r-rough k-ary word w ∈ [k] n as two tuples (a 1 , . . . , a ) and (α 1 , . . . , α ) with α 1 + α = i, a j = a j+1 for j ∈ [ − 1], and α j ≥ r for 1 < j < . Using stars and bars, one can see that if and i are fixed, the number of exponents are given by ( Using the Chu-Vandermonde identity, one gets that the sum over i gives The final summation is given when applied the change of variable → + 1. Notice that k divides t k,r (n). The sequence t k,r (n)/k has been studied before (cf. [2]). Finally, we define the bivariate generating function T k,r (x, q) := w∈T (r) k x |w| q c(w) .
We can write a symbolic equation for the combinatorial class T (r) k : where Z i denotes an atomic element (a symbol of the alphabet). In terms of generating functions, the last equation translates into T k,r (x, q) = 1 + k .