Congruence successions in compositions

A \emph{composition} is a sequence of positive integers, called \emph{parts}, having a fixed sum. By an \emph{$m$-congruence succession}, we will mean a pair of adjacent parts $x$ and $y$ within a composition such that $x\equiv y(\text{mod} m)$. Here, we consider the problem of counting the compositions of size $n$ according to the number of $m$-congruence successions, extending recent results concerning successions on subsets and permutations. A general formula is obtained, which reduces in the limiting case to the known generating function formula for the number of Carlitz compositions. Special attention is paid to the case $m=2$, where further enumerative results may be obtained by means of combinatorial arguments. Finally, an asymptotic estimate is provided for the number of compositions of size $n$ having no $m$-congruence successions.


Introduction
Let n be a positive integer. A composition σ = σ 1 σ 2 · · · σ d of n is any sequence of positive integers whose sum is n. Each summand σ i is called a part of the composition. If n, d ≥ 1, then let C n,d denote the set of compositions of n having exactly d parts and C n = ∪ n d=1 C n,d . By convention, there is a single composition of n = 0 having zero parts.
If m ≥ 1 and 0 ≤ r ≤ m − 1, by an (m, r)-congruence succession within a composition σ = σ 1 σ 2 · · · σ d , we will mean an index i for which π i+1 ≡ π i + r (mod m). An (m, r)congruence succession in which r = 0 will be referred to as an m-congruence succession, the m = 2 case being termed a parity succession. A parity-alternating composition is one that contains no parity successions, that is, the parts alternate between even and odd values. This concept of parity succession for compositions extends an earlier one that was introduced for subsets [11] and later considered on permutations [12]. The terminology is an adaptation of an analogous usage in the study of integer sequences (p 1 , p 2 , . . .) in which a succession refers to a pair p i , p i+1 with p i+1 = p i + 1 (see, e.g., [1,17,8]). For other related problems involving restrictions on compositions, the reader is referred to the text [7] and such papers as [3,6].
Enumerating finite discrete structures according to the parity of individual elements perhaps started with the following formula of Tanny [18] for the number g(n, k) of alternating ksubsets of [n] given by This result was recently generalized to any modulus in [9] and in terms of counting by successions in [11]. Tanimoto [16] considered a comparable version of the problem on permutations in his investigation of signed Eulerian numbers. There one finds the formula for the number h(n) of parity-alternating permutations of length n given by h(n) = 3 + (−1) n 2 n 2 ! n + 1 2 !, which has been generalized in terms of succession counting in [12]; see also [10].
In the next section, we consider the problem of counting compositions of n according to the number of (m, r)-congruence successions, as defined above, and derive an explicit formula for the generating function for all m and r (see Theorem 2 below). When r = 0, we obtain as a corollary a relatively simple expression for the generating function F m which counts compositions according to the number of m-congruence successions. Letting m → ∞ and taking the variable in F m which marks the number of m-congruence successions to be zero recovers the generating function for the number of Carlitz compositions, i.e., those having no consecutive parts equal; see, e.g., [5].
In the third section, we obtain some enumerative results concerning the case m = 2. In particular, we provide a bijective proof for a related recurrence and enumerate, in two different ways, the parity-alternating compositions of size n. As a consequence, we obtain a combinatorial proof of a pair of binomial identities which we were unable to find in the literature.
In the final section, we provide asymptotic estimates for the number of compositions of size n having no m-congruence successions as n → ∞, which may be extended to compositions having any fixed number of successions.

2.
Counting compositions by number of (m, r)-congruence successions We will say that the sequence π = π 1 π 2 · · · π d has an (m, r)-congruence succession at index i if π i+1 ≡ π i + r (mod m), where 0 ≤ r ≤ m − 1. We will denote the number of (m, r)congruence successions within a sequence π by cl m,r (π). Let R m,r;a (x, y, q) = R a (x, y, q) be the generating function for the number of compositions of n with exactly d parts whose first part is a according to the statistic cl m,r , that is, Clearly, we have R m+a (x, y, q) = x m R a (x, y, q) for all a ≥ 1. Let R m,r (x, y, q) = R(x, y, q) = 1 + a≥1 R a (x, y, q). By the definitions, we have for all a ≥ 1, where the sum is taken over all positive integers t such that t ≡ a + r (mod m).
The last two equalities may be expressed as where G j (x, y, q) = i≥0 R im+j (x, y, q).
Theorem 2. If m ≥ 1, 0 ≤ r ≤ m − 1, s = gcd(m, r) and p = m/s, then Note that in general we are unable to simplify the number theoretic product i+ℓ−1 k=ℓ x j+kr appearing in (3).
Let us say that the sequence π = π 1 π 2 · · · π d has an m-congruence succession at index i if π i+1 ≡ π i (mod m) and denote the number of m-congruence successions in a sequence π by cl m (π). Let Taking r = 0 in (3), and noting s = gcd(m, 0) = m, gives the following result.
. Letting q = 0 and m → ∞ in (4) yields the generating function for the number of compositions having no m-congruence successions for all large m. Note that the only possible such compositions are those having no two adjacent parts the same. Thus, we get the following formula for the generating function which counts the Carlitz compositions according to the number of parts.
Corollary 4. We have Let us close this section with a few remarks.
which agrees with the generating function for the number of compositions of n having d parts.
Remark 2. In [2], the generating function for the number c(n, d) of Carlitz compositions of n having d parts was obtained as Note that formulas (5) and (6) are seen to be equivalent since a≥1 x a y 1 + x a y = a≥1 j≥1 Remark 3. Letting m = 1 in (4) gives This formula may also be realized directly upon noting in this case that q marks the number of parts minus one in any non-empty composition, whence

Combinatorial results
We will refer to an m-congruence succession when m = 2 as a parity succession, or just a succession. In this section, we will provide some combinatorial results concerning successions in compositions. Let F (x, y, q) = F 2 (x, y, q) denote the generating function which counts the compositions of n having d parts according to the number of parity successions. Taking m = 2 in Corollary 3 gives Let C n,d,a denote the subset of C n,d whose members contain exactly a successions and let c(n, d, a) = |C n,d,a |. Comparing coefficients of x n y d q a on both sides of (7) yields the following recurrence satisfied by the array c(n, d, a).
We can also provide a combinatorial proof of (8), rewritten in the form To do so, let B n,d,a denote the subset of C n,d,a all of whose members end in a part of size 1 or 2. Note that for all n, d, and a, we have by subtraction, since c(n − 2, d, a) counts each member of C n,d,a whose last part is of size 3 or more (to see this, add two to the last part of any member of C n−2,d,a , which leaves the number of parts and successions unchanged).
So to show (9), we define a bijection between the sets For this, we refine the sets as follows. In the subsequent definitions, x, y, and z will denote an odd number, an even number, or a number greater than or equal three, respectively. First, let B (i) n,d,a , 1 ≤ i ≤ 4, denote, respectively, the subsets of B n,d,a whose members (1) end in either 1 + 1 or x + 1 + 2 for some x, (2) end in y + 2 + 1 or 2 + 2 for some y, (3) end in x + 2 + 1 or y + 1 + 2, or (4) end in z + 1 or z + 2 for some z. Let B denote the subsets of B n−1,d−1,a−1 whose members end in 1, x + 2 for some x, or y + 2 for some y, respectively. Finally, let B (i) n−2,d−1,a−1 , 1 ≤ i ≤ 3, denote the subsets of B n−2,d−1,a−1 whose members end in x + 1, y + 1, or 2, respectively.
So we seek a bijection between Simple correspondences as described below show the following: For (i), we remove the right-most 1 within a member of B (1) n,d,a , while for (ii), we remove the right-most 2 within a member of B (2) n,d,a . To show (iii), we remove the final two parts of λ ∈ B (3) n,d,a to obtain the composition λ ′ . Note that λ ′ ∈ C n−3,d−2,a and that the mapping λ → λ ′ is reversed by adding 1 + 2 or 2 + 1 to a member of C n−3,d−2,a , depending on whether the last part is even or odd, respectively. For (iv), we subtract two from the penultimate part of λ ∈ B (4) n,d,a , which leaves the number of successions unchanged. Finally, for (v), we add either a part of size 1 or 2 to λ ∈ C n−3,d−1,a−2 , depending on whether the last part of λ is odd or even, respectively. Combining the correspondences used to show (i)-(v) yields the desired bijection and completes the proof.
We will refer to a composition having no parity successions as parity-alternating. We now wish to enumerate parity-alternating compositions having a fixed number of parts. Setting q = 0 in (7), and expanding, gives Extracting the coefficient of x n y m in the last expression yields the following result. , otherwise.
It is instructive to give combinatorial proofs of (10) and (11). For the first formula, suppose λ ∈ C n,2d,0 . Then n and d must have the same parity since the parts of λ alternate between even and odd values. In this case, the number of possible λ is twice the number of integral solutions to the equation where each x i is even, each y i is odd, and x i , y i > 0. Note that the number of solutions to (12) is the same as the number of positive integral solutions to d i=1 (u i + v i ) = n+d 2 , which is On the other hand, note that members of C n,2d+1,0 , where n and d are of the same parity, are synonymous with positive integral solutions to where the x i are even, the y i are odd, and z is even. Upon adding 1 to each y i , and halving, the number of such solutions is seen to be 2d members of C n,2d+1,0 when n and d differ in parity, which gives (11).
Let a(n) = n d=0 c(n, d, 0). Note that a(n) counts all parity-alternating compositions of length n. Taking y = 1 and q = 0 in (7) gives and extracting the coefficient of x n yields the following result.  We provide a combinatorial argument for recurrence (14), the initial values being clear. Let us first define two classes of compositions. By a type A (colored) composition of n, we will mean one whose parts are all odd numbers greater than 1 in which a part of size i is assigned one of i−1 2 possible colors. A composition ρ of n is of type B if it is of the form ρ = a + λ, where a is a part of any size (not colored) and λ is a composition of n − a of type A. Given n ≥ 1, let S n denote the (multi-) set consisting of two copies of each composition of n of type A, let T n denote the set consisting of all compositions of n of type B, and let R n = S n ∪ T n . (For convenience, we take R 0 to consist of the empty composition in a set by itself.) If k i denotes the number of the color assigned to some part of size i within a composition of type A, then replacing each part i with either (i − 2k i ) + 2k i or 2k i + (i − 2k i ) yields all members of C n having an even number of parts and no parity successions. Doing the same for every part but the first within a composition of type B (note in this case, the decomposition used for each i is determined by the parity of the first part a) yields all members of C n having an odd number of parts and no parity successions. It follows that |R n | = a(n).
It then remains to show that |R n | satisfies the recurrence (14). By a maximal (colored) part of size i within a member of R n , we will mean one which has been assigned the color i−1 2 (note that any part of size 3 is maximal). Let R ′ n denote the subset of R n consisting of all type A members whose first part is maximal together with all type B members whose first part is 1 or 2. Upon increasing the length of the first part within a member of R n−2 by two (keeping the color the same, if that member belongs to S n−2 ), one sees that |R ′ n | = a(n) − a(n − 2), by subtraction. To complete the proof of (14), we then define a bijection between the sets R n−2 ∪ R n−3 and R ′ n ∪ R n−4 , where n ≥ 4.
We may assume n ≥ 5, for the equivalence of the sets in question is clear if n = 4. Let S ′ n and T ′ n denote the subsets of R ′ n consisting of its type A and type B members, respectively. To complete the proof, it suffices to define bijections between the sets S n−2 ∪ S n−3 and S ′ n ∪ S n−4 and between the sets T n−2 ∪ T n−3 and T ′ n ∪ T n−4 .
For the first bijection, if λ ∈ S n−2 , then we either increase or decrease the length of the first part of λ by two, depending on whether or not this part is maximal (if so, we also increase the color assigned to the part by one, and if not, the color is kept the same). Note that this yields all members of S ′ n whose first part is at least five as well as all members of S n−4 . If λ ∈ S n−3 , then we append a colored part of size three to the beginning of λ, which yields all members of S ′ n starting with three.
For the second bijection, we consider cases concerning λ ∈ T n−2 ∪ T n−3 . If λ ∈ T n−2 starts with 1, then we increase the second part of λ by two (keeping the assigned color the same) to obtain λ * ∈ T ′ n starting with 1 where the second part is not maximal. If λ ∈ T n−3 starts with 1, then we replace this 1 with 2 and increase the second part of λ by two (again, keeping the assigned color the same) to obtain λ * ∈ T ′ n . Combining the previous two cases then yields all members of T ′ n whose second part is not maximal. If λ ∈ T n−2 starts with a part i of size two or more, then we append a 2 to the beginning of λ if i is odd and we append a 1 to the beginning of λ and replace i with i + 1 if i is even. In either case, we take the second part to be maximal in the resulting composition λ * belonging to T ′ n . Finally, if λ ∈ T n−3 starts with a part of size two or more, then we subtract one from this part to obtain λ * ∈ T n−4 . It may be verified that the composite mapping λ → λ * yields the desired bijection.
Summing the formulas in Proposition 6 over d with n fixed, using the fact a b = a−2 b + 2 a−2 b−1 + a−2 b−2 , and equating with the result in Proposition 7 yields a combinatorial proof of the following pair of binomial identities, which we were unable to find in the literature.
where a(m) is given by (14).
Note that both sides of (15) and (16) are seen to count the parity-alternating compositions of length 2n and 2n + 1, respectively, the right-hand side by the number of parts (once one applies the identity a b = a−2 b +2 a−2 b−1 + a−2 b−2 , which has an easy combinatorial explanation, to the binomial coefficient). Using (14), the binomial sums in (15) and (16) can be shown to satisfy fourth order recurrences; see [4] for other examples of recurrent binomial sums.

Asymptotics
We recall from (4) that F m (x, y, q) is a rational function. Specializing variables we obtain F m (x, 1, 0) = n≥0 a n x n , which we have seen in the previous section. The exact formulae given there for the coefficient a n are complemented here by asymptotic results. These are analogous to known results for Smirnov words and Carlitz compositions.
x a 1+x a −x m . Each 1 + x a − x m is analytic and so its modulus over each closed disk centered at 0 is maximized on the boundary circle. It can be shown that when |x| is fixed, |1 + x a − x m | is maximized when x a − x m is positive real, and minimized when x a − x m is negative real. Furthermore, the maximum over a of this maximum value occurs when a = 1, and similarly for the minimum.
By Pringsheim's theorem, there is a minimal singularity of F m on the positive real axis, and this is precisely the smallest real zero ρ m of H m . Furthermore, because F m is not periodic, this singularity is the unique one of that modulus. Thus F m is analytic in the open disk centered at 0 with radius ρ m . Note that ρ m ≥ 1/2 because the exponential growth rate of unrestricted compositions is 2, and so our restricted class of compositions must grow no faster. However ρ m ≤ 1 because the sum defining H m has value m when x = 1. Since ρ m is the smallest positive real solution of m a=1 ρ a 1 + ρ a − ρ m = 1, it follows that ρ m is an algebraic number of degree at most m 2 . Note that the sum defining H m shows that H m (x) > H m+1 (x) for all m and all 0 < x < 1. Thus in fact ρ m ≤ ρ 2 < 0.68 for all m.
The rest of the proof should proceed according to a familiar outline: apply Rouché's theorem to locate the dominant singularity of F m (x, 1, 0), by approximating H m with a simpler function having a unique zero inside an appropriately chosen disk of radius c, where ρ m < c < 1; derive asymptotics for the coefficients a n via standard singularity analysis. This technique has been used in several similar problems, for example for Carlitz compositions.
There are some difficulties with this approach in our case. If we attack F m directly, we must derive a result for all m. Since F m is rational with numerator and denominator of degree at most m 2 , for fixed m, we could consider using numerical root-finding methods, but for arbitrary symbolic m this will not work. It is intuitively clear that for sufficiently large m, F m should be close to F ∞ and so by using Rouché's theorem, we could reduce to the Carlitz case.
However, even the Carlitz case is not as easy as claimed in the literature, and we found several unconvincing published arguments. Some authors simply assert that F ∞ has a single root, based on a graph of the function on a given circle. This can be made into a proof, by approximately evaluating F ∞ at sufficiently many points and using an upper bound on the best Lipschitz constant for the function, but this is somewhat unpleasant. We do not know a way of avoiding this problem -the minimum modulus of a function on a circle in the complex plane must be computed somehow. We use an approach similar to that taken in [5].
The obvious approximating function to use is an initial segment with k terms of the partial sum defining F m . However, it seems easier to use the initial segment of the sum defining F ∞ , which we denote by S k . We will take k = 7 and c = 0.7 and denote S 7 by h. By using the Jenkins-Traub algorithm as implemented in the Sage command maxima.allroots(), we see that all roots of h, except the real positive root (approximately 0.572) have real or imaginary part with modulus more than 0.7, so they certainly lie outside the circle C given by |x| = c.
To apply Rouché's theorem, we need an upper bound for |H m − h| on C which is less than the lower bound for |h| on C. We first claim that the lower bound for |h| on C is at least 0.43. This can be proved by evaluation at sufficiently many points of C. Since |h ′ (z)| is bounded by 100 on C, N := 1000 points certainly suffice. This is because the minimum of |h| at points of the form 0.7 exp(2πij/N ), for 0 ≤ j ≤ N , is more than 0.51 (computed using Sage), and the distance between two such points is at most 8 × 10 −4 , by Taylor approximation. In fact, it seems that the minimum indeed occurs at x = 0.7, but this is not obvious to us.
We now compute an upper bound for |H m − h|. To this end, we compute, when m ≥ 7, The sum ∞ a=8 c a 1−c 8 has value less than 0.204 when c = 0.7. The second sum is smaller than 0.2 which can be verified by a similar argument to the above, by evaluating at sufficiently many points.
We still need to deal with the cases m < 7 and these can be done directly via inspection after computing all roots numerically as above.
The above arguments show that ρ m is a simple zero of H m and hence a simple pole of the rational function F m (x, 1, 0). The asymptotics now follow in the standard manner by a residue computation, and we obtain a n ∼ ρ −n m 1 −ρ m H ′ (ρ m ) .
For example, when n = 20, the relative error in this approximation is already less than 0.2%. The exponential rate 1/ρ m approaches the rate for Carlitz compositions, namely 1.750 · · · , as m → ∞.
We can in fact derive asymptotics in the multivariate case. For each m, it is possible in principle to compute asymptotics in a given direction by analysis of F m (x, y, q), for example, using the techniques of Pemantle and Wilson [13]. To do this for arbitrarily large m is computationally challenging, and so in order to limit the length of this article, we give a sketch only for m = 2, and refer the reader to the above reference or the more recent book [14]. In this case we have (1 − x 2 − xy(q − 1))(1 − x 2 − x 2 y(q − 1)) 1 − 2x 2 − qxy + x 4 − qx 2 y − x 3 y 2 + qx 3 y + qx 4 y + q 2 x 3 y 2 .
By standard algorithms, for example as implemented in Sage's solve command, one can check that the partial derivatives H x , H y , H q never vanish simultaneously, so that the variety defined by H m is smooth everywhere. The critical point equations are readily solved by the same method. For example, for the special case when n = 2d = 4t, where t denotes the number of congruence successions, we obtain (using the Sage package amgf [15]) the first order asymptotic (0.379867842273)(15.8273658508862) t /(πt), which has relative error just over 1% when n = 32 (the number of such compositions being 54865800). Bivariate asymptotics when q = 0, or when y = 1, could be derived similarly. The smoothness of the variety defined by H m leads quickly to Gaussian limit laws in a standard way as described in [14], and we leave the reader to explore this further.