Chapter 3

Algebraic Generating Functions for Languages Avoiding Riordan Patterns

This chapter is an extended version of our paper D. Merlini and M. Nocentini. Algebraic Generating Functions for Languages Avoiding Riordan Patterns. Journal of Integer Sequences, 21(18.1.3), 2018. URL https://cs.uwaterloo.ca/journals/JIS/VOL21/Merlini/merlini5.html that studies languages 𝔏[𝔭]⊂{0,1}∗\mathfrak{L}^{[\mathfrak{p}]}\subset \{0,1\}^* of binary words ww avoiding a given pattern 𝔭\mathfrak{p} such that ∣w∣0≤∣w∣1|w|_0\leq |w|_1 for any w∈𝔏[𝔭],w\in \mathfrak{L}^{[\mathfrak{p}]}, where ∣w∣0|w|_0 and ∣w∣1|w|_1 correspond to the number of 11-bits and 00-bits in the word ww, respectively. In particular, we concentrate on patterns 𝔭\mathfrak{p} related to the concept of Riordan arrays. These languages are not regular and can be enumerated by algebraic generating functions corresponding to many integer sequences which are unknown in the OEIS. We give explicit formulas for these generating functions expressed in terms of the autocorrelation polynomial of 𝔭\mathfrak{p} and also give explicit formulas for the coefficients of some particular patterns, algebraically and combinatorially.

3.1Introduction

The notion of a pattern can be formalized in several ways and in this paper we consider factor patterns, that is, patterns whose letters must appear in an exact order and contiguously in the sequence under observation. The set of binary words avoiding a pattern, without the restriction ∣w∣0≤∣w∣1,|w|_0\leq |w|_1, is defined by a regular language and can be enumerated in terms of the number of 11-bits and 00-bits by using classical results (see, e.g., L. J. Guibas and A. M. Odlyzko. Long repetitive patterns in random sequences. Zeitschrift für Wahrscheinlichkeitstheorie und Verwandte Gebiete, 53(3):241–262, January 1980. ISSN 1432-2064. doi: 10.1007/BF00531434. URL https://doi.org/10.1007/BF00531434L. J. Guibas and A. M. Odlyzko. String overlaps, pattern matching, and nontransitive games. Journal of Combinatorial Theory, Series A, 30(2):183–208, 1981. ISSN 0097-3165. doi: 10.1016/0097-3165(81)90005-4. URL http://www.sciencedirect.com/science/article/pii/0097316581900054R. Sedgewick and P. Flajolet. An Introduction to the Analysis of Algorithms. Addison-Wesley Longman Publishing Co., Inc., Boston, MA, USA, 1996. ISBN 0-201-40009-X). However, when we consider the additional restriction that the words have no more 00-bits than 11-bits, the language is no longer regular and enumerating it is a harder problem.

In this paper we are interested in Riordan patterns, a concept which has been defined in D. Merlini and R. Sprugnoli. Algebraic aspects of some Riordan arrays related to binary words avoiding a pattern. Theoretical Computer Science, 412(27):2988–3001, 2011. ISSN 0304-3975. doi: 10.1016/j.tcs.2010.07.019. URL http://www.sciencedirect.com/science/article/pii/S0304397510004056. Combinatorics on Words (WORDS 2009) in terms of the autocorrelation polynomial C[𝔭](x,y)C^{[\mathfrak{p}]}(x,y) of pattern 𝔭=p0⋯ph−1\mathfrak{p}=p_{0}\cdots p_{h-1}. The coefficients of this polynomial are given by the autocorrelation vector associated to 𝔭\mathfrak{p}, that is, the vector c=(c0,…,ch−1)c=(c_0,\ldots ,c_{h-1}) of bits defined in terms of Iverson’s bracket notation (for a predicate PP, the expression [ ⁣[P] ⁣][\![P]\!] has value 11 if PP is true and 00 otherwise) as follows:

ci=[ ⁣[p0p1⋯ph−1−i=pipi+1⋯ph−1] ⁣]; c_i=[\![p_0p_1\cdots p_{h-1-i}=p_{i}p_{i+1}\cdots p_{h-1}]\!];

in words, the bit cic_i is determined by shifting 𝔭\mathfrak{p} to the right by ii positions, setting ci=1c_i=1 if and only if the remaining letters match the original.

Table 3.1: The autocorrelation vector for the pattern 𝔭=10101\mathfrak{p}= 10101.
10101Tailscic_{i}
101011
101010
101011
101010
101011

For example, when 𝔭=10101\mathfrak{p}= 10101 the autocorrelation vector is c=(1,0,1,0,1)c=(1,0,1,0,1), as illustrated in Table 3.1, and C[𝔭](x,y)=1+xy+x2y2C^{[\mathfrak{p}]}(x,y)=1+xy+x^2y^2, namely we add a term xjyix^jy^i for each tail of the pattern with jj 11-bits and ii 00-bits, where cj+i=1c_{j+i}=1. For each pattern 𝔭,\mathfrak{p}, we can compute the complement pattern 𝔭¯\bar{\mathfrak{p}} by changing every 11 to 00 and every 00 to 11; for example, if 𝔭=10101\mathfrak{p}= 10101 then 𝔭¯=01010\bar{\mathfrak{p}}=01010, therefore C[𝔭](x,y)=C[𝔭¯](y,x)C^{[\mathfrak{p}]}(x,y)=C^{[\bar{\mathfrak{p}}]}(y,x).

Addition of constraints to the nature of a pattern 𝔭\mathfrak{p} yields the following

Definition 3.1 (Riordan pattern). We say that 𝔭=p0⋯ph−1\mathfrak{p}=p_0\cdots p_{h-1} is a Riordan pattern if and only if

C[𝔭](x,y)=C[𝔭¯](y,x)=∑i=0⌊(h−1)/2⌋c2ixiyi, C^{[\mathfrak{p}]}(x,y)=C^{[\bar{\mathfrak{p}}]}(y,x)=\sum_{i=0}^{\lfloor(h-1)/2\rfloor}c_{2i}x^iy^i,

with ∣n1[𝔭]−n0[𝔭]∣∈{0,1},|n_1^{[\mathfrak{p}]}-n_0^{[\mathfrak{p}]}|\in \left\{0,1 \right\}, where n1[𝔭]n_1^{[\mathfrak{p}]} and n0[𝔭]n_0^{[\mathfrak{p}]} correspond to the number of 11-bits and 00-bits in the pattern, respectively.

For example, Table 3.1 corresponds to a Riordan pattern and 𝔭=1100110110011000\mathfrak{p}= 1100110110011000 is another Riordan pattern having n1[𝔭]=n0[𝔭]=8n_1^{[\mathfrak{p}]}=n_0^{[\mathfrak{p}]}=8 and C[𝔭](x,y)=1.C^{[\mathfrak{p}]}(x,y)=1. Moreover, in Table 3.2 we give all the Riordan patterns of length 77 with first bit equal to 11 and their correlation polynomials, the corresponding complement patterns can be easily determined.

Table 3.2: The Riordan patterns of length 7 with first bit equal to 11 and their correlation polynomials.
𝔭\mathfrak{p}C[𝔭](x,y)C^{[\mathfrak{p}]}(x,y)
1010100, 1011000, 1011100, 1100010, 1100100, 1101000, 1101010, 1101100, 1110000, 1110010, 1110100, 111100011
1001100, 11001101+x2y21+x^2y^2
1000111, 1001011, 1001101, 1010011, 1011001, 1100101, 1101001, 11100011+x3y31+x^3y^3
10101011+xy+x2y2+x3y31+xy+x^2y^2+x^3y^3

The name Riordan in the above definition is due to the connection with the well-known concept of Riordan arrays, introduced in Chapter 1. Consider the languages 𝔏[𝔭]⊂{0,1}∗\mathfrak{L}^{[\mathfrak{p}]}\subset \{0,1\}^* of binary words avoiding a pattern 𝔭\mathfrak{p} and let Rn,k[𝔭]R_{n,k}^{[\mathfrak{p}]} be the number of words avoiding 𝔭\mathfrak{p} and having nn 11-bits and n−kn-k 00-bits; additionally, let ℛ[𝔭]=(Rn,k[𝔭])n,k∈ℕ\mathcal{R}^{[\mathfrak{p}]}=\left(R_{n,k}^{[\mathfrak{p}]}\right)_{n,k\in\mathbb{N}} the enclosing matrix. The following theorem, which is proved in D. Merlini and R. Sprugnoli. Algebraic aspects of some Riordan arrays related to binary words avoiding a pattern. Theoretical Computer Science, 412(27):2988–3001, 2011. ISSN 0304-3975. doi: 10.1016/j.tcs.2010.07.019. URL http://www.sciencedirect.com/science/article/pii/S0304397510004056. Combinatorics on Words (WORDS 2009), shows the importance of Riordan patterns:

Theorem 3.2. Matrices ℛ[𝔭]\mathcal{R}^{[\mathfrak{p}]} and ℛ[𝔭¯]\mathcal{R}^{[\bar{\mathfrak{p}}]} are Riordan arrays if and only if 𝔭\mathfrak{p} is a Riordan pattern.

By previous theorem, matrices ℛ[𝔭]\mathcal{R}^{[\mathfrak{p}]} and ℛ[𝔭¯]\mathcal{R}^{[\bar{\mathfrak{p}}]} can be defined as

ℛ[𝔭]=(d[𝔭](t),h[𝔭](t)) and ℛ[𝔭¯]=(d[𝔭¯](t),h[𝔭¯](t)) \mathcal{R}^{[\mathfrak{p}]}=(d^{[\mathfrak{p}]}(t),h^{[\mathfrak{p}]}(t)) \text{ and } \mathcal{R}^{[\bar{\mathfrak{p}}]}=(d^{[\bar{\mathfrak{p}}]}(t),h^{[\bar{\mathfrak{p}}]}(t))

for the appropriate d[𝔭],d^{[\mathfrak{p}]}, h[𝔭],h^{[\mathfrak{p}]}, d[𝔭¯],d^{[\bar{\mathfrak{p}}]}, h[𝔭¯],h^{[\bar{\mathfrak{p}}]}, given a Riordan pattern 𝔭\mathfrak{p}; moreover, they represent the lower and upper part of the array ℱ[𝔭]=(Fn,k[𝔭])n,k∈ℕ\mathcal{F}^{[\mathfrak{p}]}=(F_{n,k}^{[\mathfrak{p}]})_{n,k \in \mathbb{N}}, where Fn,k[𝔭]F_{n,k}^{[\mathfrak{p}]} denotes the number of words avoiding pattern 𝔭\mathfrak{p} and having nn 11-bits and kk 00-bits.

Remark 3.3. Riordan patterns are not the only patterns related to Riordan arrays; for example, given the pattern 𝔭=0100100\mathfrak{p}=0100100 corresponding to C[𝔭](x,y)=1+xy2+x2y4C^{[\mathfrak{p}]}(x,y)=1+xy^2+x^2y^4, matrix ℛ[𝔭]\mathcal{R}^{[\mathfrak{p}]} is still a Riordan array but ℛ[𝔭¯]\mathcal{R}^{[\bar{\mathfrak{p}}]} is not, as illustrated in Example 5.4 of D. Baccherini, D. Merlini, and R. Sprugnoli. Binary words excluding a pattern and proper Riordan arrays. Discrete Mathematics, 307:1021–1037, 2007. However, in these situations it is not easy to find functions d[𝔭](t)d^{[\mathfrak{p}]}(t) and h[𝔭](t)h^{[\mathfrak{p}]}(t) while for Riordan patterns it is always possible, as shown in Theorem 3.2 and Theorem 3.5.

As already observed, the enumeration of the set of binary words avoiding a pattern, without the restriction about the number of 11-bits and 00-bits can be done by using classical results and gives the following rational bivariate generating function for the sequence (Fn,k[𝔭])n,k∈ℕ:(F_{n,k}^{[\mathfrak{p}]})_{n,k \in \mathbb{N}}:

F[𝔭](x,y)=C[𝔭](x,y)(1−x−y)C[𝔭](x,y)+xn1[𝔭]yn0[𝔭], F^{[\mathfrak{p}]}(x,y) =\frac{C^{[\mathfrak{p}]}(x,y)}{(1-x-y)C^{[\mathfrak{p}]}(x,y) +x^{n_1^{[\mathfrak{p}]}}y^{n_0^{[\mathfrak{p}]}}},

where n1[𝔭]n_1^{[\mathfrak{p}]} and n0[𝔭]n_0^{[\mathfrak{p}]} correspond to the number of 11-bits and 00-bits, respectively, and C[𝔭](x,y)C^{[\mathfrak{p}]}(x,y) is the autocorrelation polynomial, all relative to pattern 𝔭\mathfrak{p}. Consequently, F[𝔭](t,1)F^{[\mathfrak{p}]}(t,1) and F[𝔭](t,t)F^{[\mathfrak{p}]}(t,t) count the words avoiding 𝔭\mathfrak{p} according to the number of 11-bits and to length of each word, respectively.

Using the theory of Riordan arrays and the results in D. Merlini and R. Sprugnoli. Algebraic aspects of some Riordan arrays related to binary words avoiding a pattern. Theoretical Computer Science, 412(27):2988–3001, 2011. ISSN 0304-3975. doi: 10.1016/j.tcs.2010.07.019. URL http://www.sciencedirect.com/science/article/pii/S0304397510004056. Combinatorics on Words (WORDS 2009), we give explicit algebraic generating functions enumerating the set of binary words avoiding a Riordan pattern with the restriction ∣w∣0≤∣w∣1|w|_0\leq |w|_1 according to various parameters, in particular to the number of 11-bits and to the words length. Most of the corresponding sequences are new in the On-Line Encyclopedia of Integer Sequences (OEIS for short) N. J. A. Sloane. The Encyclopedia of Integer Sequences. URL http://oeis.org/, which uses the convention to identify each sequence with a label of the form Ax1x2x3x4x5x6Ax_{1}x_{2}x_{3}x_{4}x_{5}x_{6}, where xi∈{0,…,9}x_{i}\in \lbrace 0,\ldots,9 \rbrace; moreover, we also give explicit formulas for the coefficients of some particular patterns by providing algebraic and combinatorial proofs.

Finally, our results can be interpreted in the theory of paths and codes in light of the bijection among binary words and paths, which maps a 00-bit to a south-east step ╲\diagdown and a 11-bit to a north-east step ╱\diagup. From this point of view, a coefficient Rn,k[𝔭]∈ℛ[𝔭]R_{n,k}^{[\mathfrak{p}]} \in \mathcal{R}^{[\mathfrak{p}]} counts the number of paths containing nn steps of ╱\diagup kind and n−kn-k steps of ╲\diagdown kind, avoiding the subpath corresponding to pattern 𝔭\mathfrak{p}, allowed to cross the xx axis but required to end at coordinate (2n−k,k)(2n-k, k) such that 0≤k≤n0 \leq k \leq n. In particular, d[𝔭](t)d^{[\mathfrak{p}]}(t) is the generating function of paths which avoid 𝔭\mathfrak{p} and end on the xx axis.

Example 3.4. The Riordan pattern 𝔭=10101\mathfrak{p}=10101 entails the matrices shown in Table 3.3.

Table 3.3: Matrices ℱn,k[𝔭]=ℛn,n−k[𝔭¯]\mathcal{F}_{n,k}^{[\mathfrak{p}]} = \mathcal{R}_{n, n-k}^{[\bar{\mathfrak{p}}]} if k≤nk\leq n and ℱn,k[𝔭]=ℛk,k−n[𝔭¯]\mathcal{F}_{n,k}^{[\mathfrak{p}]} = \mathcal{R}_{k, k-n}^{[\bar{\mathfrak{p}}]} if n≤kn\leq k for the Riordan pattern 𝔭=10101\mathfrak{p}=10101.
MatrixEntries (8×88\times 8 leading minor)
ℱ[𝔭]\mathcal{F}^{[\mathfrak{p}]}[111111111234567813610152128361491832527911415133060109184293161846102204377654172467163354708132418319424858012452490]\left[\begin{array}{cccccccc} 1 & 1 & 1 & 1 & 1 & 1 & 1 & 1 \\ 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ 1 & 3 & 6 & 10 & 15 & 21 & 28 & 36 \\ 1 & 4 & 9 & 18 & 32 & 52 & 79 & 114 \\ 1 & 5 & 13 & 30 & 60 & 109 & 184 & 293 \\ 1 & 6 & 18 & 46 & 102 & 204 & 377 & 654 \\ 1 & 7 & 24 & 67 & 163 & 354 & 708 & 1324 \\ 1 & 8 & 31 & 94 & 248 & 580 & 1245 & 2490 \end{array}\right]
ℛ[𝔭]\mathcal{R}^{[\mathfrak{p}]}[121631189416030135120410246186170835416367247124901245580248943181]\left[\begin{array}{cccccccc} 1 & & & & & & & \\ 2 & 1 & & & & & & \\ 6 & 3 & 1 & & & & & \\ 18 & 9 & 4 & 1 & & & & \\ 60 & 30 & 13 & 5 & 1 & & & \\ 204 & 102 & 46 & 18 & 6 & 1 & & \\ 708 & 354 & 163 & 67 & 24 & 7 & 1 & \\ 2490 & 1245 & 580 & 248 & 94 & 31 & 8 & 1 \end{array}\right]
ℛ[𝔭¯]\mathcal{R}^{[\bar{\mathfrak{p}}]}[12163118104160321551204109522161708377184792871249013246542931143681]\left[\begin{array}{cccccccc} 1 & & & & & & & \\ 2 & 1 & & & & & & \\ 6 & 3 & 1 & & & & & \\ 18 & 10 & 4 & 1 & & & & \\ 60 & 32 & 15 & 5 & 1 & & & \\ 204 & 109 & 52 & 21 & 6 & 1 & & \\ 708 & 377 & 184 & 79 & 28 & 7 & 1 & \\ 2490 & 1324 & 654 & 293 & 114 & 36 & 8 & 1 \end{array}\right]

3.2Riordan arrays for Riordan patterns

We start with a result which is a direct consequence of Theorems 2.3 and 3.3 in D. Merlini and R. Sprugnoli. Algebraic aspects of some Riordan arrays related to binary words avoiding a pattern. Theoretical Computer Science, 412(27):2988–3001, 2011. ISSN 0304-3975. doi: 10.1016/j.tcs.2010.07.019. URL http://www.sciencedirect.com/science/article/pii/S0304397510004056. Combinatorics on Words (WORDS 2009):

Theorem 3.5. Let Rn,k[𝔭]R_{n,k}^{[\mathfrak{p}]} be the number of binary words with nn 11-bits and n−kn-k 00-bits, avoiding a Riordan pattern 𝔭.\mathfrak{p}. Then the triangle ℛ[𝔭]=(Rn,k[𝔭])\mathcal{R}^{[\mathfrak{p}]}=(R_{n, k}^{[\mathfrak{p}]}) is a Riordan array ℛ[𝔭]=(d[𝔭](t),h[𝔭](t)).\mathcal{R}^{[\mathfrak{p}]}=(d^{[\mathfrak{p}]}(t),h^{[\mathfrak{p}]}(t)). In particular, if n1[𝔭]n_1^{[\mathfrak{p}]} and n0[𝔭]n_0^{[\mathfrak{p}]} correspond to the number of 11-bits and 00-bits in the pattern, C[𝔭](x,y)C^{[\mathfrak{p}]}(x,y) is the autocorrelation polynomial of 𝔭\mathfrak{p} and C[𝔭](t)=C[𝔭](t,t),C^{[\mathfrak{p}]}(t)=C^{[\mathfrak{p}]}(\sqrt{t},\sqrt{t}), then:

  • if n1[𝔭]−n0[𝔭]=1n_1^{[\mathfrak{p}]}-n_0^{[\mathfrak{p}]}=1 we have:

    d[𝔭](t)=C[𝔭](t)C[𝔭](t)2−4tC[𝔭](t)(C[𝔭](t)−tn0[𝔭]), d^{[\mathfrak{p}]}(t)={C^{[\mathfrak{p}]}(t) \over \sqrt{C^{[\mathfrak{p}]}(t)^2-4tC^{[\mathfrak{p}]}(t)(C^{[\mathfrak{p}]}(t)-t^{n_0^{[\mathfrak{p}]}})}}, h[𝔭](t)=C[𝔭](t)−C[𝔭](t)2−4tC[𝔭](t)(C[𝔭](t)−tn0[𝔭])2C[𝔭](t); h^{[\mathfrak{p}]}(t)={C^{[\mathfrak{p}]}(t) -\sqrt{C^{[\mathfrak{p}]}(t)^2-4tC^{[\mathfrak{p}]}(t)(C^{[\mathfrak{p}]}(t)-t^{n_0^{[\mathfrak{p}]}})} \over 2 C^{[\mathfrak{p}]}(t)};
  • if n1[𝔭]−n0[𝔭]=0n_1^{[\mathfrak{p}]}-n_0^{[\mathfrak{p}]}=0 we have:

    d[𝔭](t)=C[𝔭](t)(C[𝔭](t)+tn0[𝔭])2−4tC[𝔭](t)2, d^{[\mathfrak{p}]}(t)={C^{[\mathfrak{p}]}(t) \over \sqrt{( C^{[\mathfrak{p}]}(t)+t^{n_0^{[\mathfrak{p}]}})^2-4tC^{[\mathfrak{p}]}(t)^2}}, h[𝔭](t)=C[𝔭](t)+tn0[𝔭]−(C[𝔭](t)+tn0[𝔭])2−4tC[𝔭](t)22C[𝔭](t); h^{[\mathfrak{p}]}(t)= {C^{[\mathfrak{p}]}(t)+ t^{n_0^{[\mathfrak{p}]}} - \sqrt{( C^{[\mathfrak{p}]}(t)+t^{n_0^{[\mathfrak{p}]}})^2-4tC^{[\mathfrak{p}]}(t)^2} \over 2 C^{[\mathfrak{p}]}(t)};
  • if n0[𝔭]−n1[𝔭]=1n_0^{[\mathfrak{p}]}-n_1^{[\mathfrak{p}]}=1 we have:

    d[𝔭](t)=C[𝔭](t)C[𝔭](t)2−4tC[𝔭](t)(C[𝔭](t)−tn1[𝔭]), d^{[\mathfrak{p}]}(t)={C^{[\mathfrak{p}]}(t) \over \sqrt{C^{[\mathfrak{p}]}(t)^2-4tC^{[\mathfrak{p}]}(t)(C^{[\mathfrak{p}]}(t)-t^{n_1^{[\mathfrak{p}]}})}}, h[𝔭](t)=C[𝔭](t)−C[𝔭](t)2−4tC[𝔭](t)(C[𝔭](t)−tn1[𝔭])2(C[𝔭](t)−tn1[𝔭]). h^{[\mathfrak{p}]}(t)={C^{[\mathfrak{p}]}(t) -\sqrt{C^{[\mathfrak{p}]}(t)^2-4tC^{[\mathfrak{p}]}(t)(C^{[\mathfrak{p}]}(t)-t^{n_1^{[\mathfrak{p}]}})} \over 2 (C^{[\mathfrak{p}]}(t)- t^{n_1^{[\mathfrak{p}]}})}.

If R[𝔭](t,w)R^{[\mathfrak{p}]}(t,w) denotes the bivariate generating function of the Riordan array ℛ[𝔭],\mathcal{R}^{[\mathfrak{p}]}, as already mentioned in Section 3.1, we have:

R[𝔭](t,w)=∑n,k∈ℕRn,k[𝔭]tnwk=d[𝔭](t)1−wh[𝔭](t) R^{[\mathfrak{p}]}(t,w)=\sum_{n,k\in\mathbb{N}} R_{n, k}^{[\mathfrak{p}]}t^n w^k={d^{[\mathfrak{p}]}(t) \over 1-wh^{[\mathfrak{p}]}(t)}

and Theorem 3.5 allows us to state the following results.

Theorem 3.6. Let 𝔭\mathfrak{p} be a Riordan pattern and S[𝔭](t)=∑n≥0Sn[𝔭]tnS^{[\mathfrak{p}]}(t)=\sum_{n\geq 0}S_n^{[\mathfrak{p}]}t^n the generating function enumerating the set of binary words {w∈{0,1}∗:∣w∣0≤∣w∣1}\left\lbrace w\in \lbrace 0,1 \rbrace^{*}: |w|_0\leq |w|_1\right\rbrace avoiding a Riordan pattern 𝔭\mathfrak{p} according to the number of 11-bits. Then we have:

  • if n1[𝔭]=n0[𝔭]+1:n_1^{[\mathfrak{p}]}=n_0^{[\mathfrak{p}]}+1:

    S[𝔭](t)=2C[𝔭](t)Q(t)(C[𝔭](t)+Q(t)) S^{[\mathfrak{p}]}(t)={2C^{[\mathfrak{p}]}(t) \over \sqrt{Q(t)}\left(\sqrt{C^{[\mathfrak{p}]}(t)}+ \sqrt{Q(t)} \right)}

    where Q(t)=(1−4t)C[𝔭](t)2+4tn1[𝔭];Q(t)={(1-4t)C^{[\mathfrak{p}]}(t)^2+4t^{n_1^{[\mathfrak{p}]}}};

  • if n0[𝔭]=n1[𝔭]+1:n_0^{[\mathfrak{p}]}=n_1^{[\mathfrak{p}]}+1:

    S[𝔭](t)=2C[𝔭](t)(C[𝔭](t)−tn1[𝔭])Q(t)(C[𝔭](t)−2tn1[𝔭]+Q(t)) S^{[\mathfrak{p}]}(t)={2C^{[\mathfrak{p}]}(t)(C^{[\mathfrak{p}]}(t)-t^{n_1^{[\mathfrak{p}]}}) \over \sqrt{Q(t)} \left(C^{[\mathfrak{p}]}(t)-2t^{n_1^{[\mathfrak{p}]}}+ \sqrt{Q(t)} \right) }

    where Q(t)=(1−4t)C[𝔭](t)2+4tn0[𝔭]C[𝔭](t);Q(t)={ (1-4t)C^{[\mathfrak{p}]}(t)^2+4t^{n_0^{[\mathfrak{p}]}}C^{[\mathfrak{p}]}(t)};

  • if n1[𝔭]=n0[𝔭]:n_1^{[\mathfrak{p}]}=n_0^{[\mathfrak{p}]}:

    S[𝔭](t)=2C[𝔭](t)2Q(t)(C[𝔭](t)−tn0[𝔭]+Q(t)) S^{[\mathfrak{p}]}(t)={2C^{[\mathfrak{p}]}(t)^2 \over \sqrt{Q(t)} \left(C^{[\mathfrak{p}]}(t)-t^{n_0^{[\mathfrak{p}]}}+ \sqrt{Q(t)} \right) }

    where Q(t)=(1−4t)C[𝔭](t)2+2tn0[𝔭]C[𝔭](t)+t2n0[𝔭].Q(t)=(1-4t)C^{[\mathfrak{p}]}(t)^2+2t^{n_0^{[\mathfrak{p}]}}C^{[\mathfrak{p}]}(t)+t^{2n_0^{[\mathfrak{p}]}}.

Proof. For the proof we can observe that S[𝔭](t)=∑n≥0Sn[𝔭]tn=R[𝔭](t,1),S^{[\mathfrak{p}]}(t)=\sum_{n\geq 0}S_n^{[\mathfrak{p}]}t^n=R^{[\mathfrak{p}]}(t,1), or, equivalently, that Sn[𝔭]=∑k=0nRn,k[𝔭]S_n^{[\mathfrak{p}]}=\sum_{k=0}^nR_{n, k}^{[\mathfrak{p}]} and apply the fundamental rule (1.2) with fk=1.f_k=1. The statement of the theorem can be found after some algebraic simplification. □

Theorem 3.7. Let 𝔭\mathfrak{p} be a Riordan pattern and L[𝔭](t)=∑n≥0Ln[𝔭]tnL^{[\mathfrak{p}]}(t)=\sum_{n\geq 0}L_n^{[\mathfrak{p}]}t^n the generating function enumerating the set of binary words {w∈{0,1}∗:∣w∣0≤∣w∣1}\left\lbrace w\in \lbrace 0,1 \rbrace^{*}: |w|_0\leq |w|_1\right\rbrace avoiding a Riordan pattern 𝔭\mathfrak{p} according to the length. Then we have:

  • if n1[𝔭]=n0[𝔭]+1:n_1^{[\mathfrak{p}]}=n_0^{[\mathfrak{p}]}+1:

    L[𝔭](t)=2tC[𝔭](t2)2Q(t)((2t−1)C(t2)+Q(t)), L^{[\mathfrak{p}]}(t)= {2tC^{[\mathfrak{p}]}(t^2)^2 \over \sqrt{Q(t)}\left((2t-1)C(t^2)+ \sqrt{ Q(t) } \right)},

    where Q(t)=C[𝔭](t2)((1−4t2)C[𝔭](t2)+4t2n1[𝔭]);Q(t)=C^{[\mathfrak{p}]}(t^2)\left( (1-4t^2)C^{[\mathfrak{p}]}(t^2)+4t^{2n_1^{[\mathfrak{p}]}}\right);

  • if n0[𝔭]=n1[𝔭]+1:n_0^{[\mathfrak{p}]}=n_1^{[\mathfrak{p}]}+1:

    L[𝔭](t)=2tC[𝔭](t2)(t2n1[𝔭]−C[𝔭](t2))Q(t)((1−2t)C[𝔭](t2)+2tn0[𝔭]+n1[𝔭]−C[𝔭](t2)Q(t)), L^{[\mathfrak{p}]}(t)={2t\sqrt{C^{[\mathfrak{p}]}(t^2)}(t^{2n_1^{[\mathfrak{p}]}}-C^{[\mathfrak{p}]}(t^2)) \over \sqrt{ Q(t) }\left((1-2t)C^{[\mathfrak{p}]}(t^2)+2t^{n_0^{[\mathfrak{p}]} +n_1^{[\mathfrak{p}]}} - \sqrt{C^{[\mathfrak{p}]}(t^2) Q(t) } \right)},

    where Q(t)=(1−4t2)C[𝔭](t2)+4t2n0[𝔭];Q(t)=(1-4t^2)C^{[\mathfrak{p}]}(t^2)+4t^{2n_0^{[\mathfrak{p}]}};

  • if n1[𝔭]=n0[𝔭]:n_1^{[\mathfrak{p}]}=n_0^{[\mathfrak{p}]}:

    L[𝔭](t)=2tC[𝔭](t2)2Q(t)((2t−1)C(t2)−t2n0[𝔭]+Q(t)), L^{[\mathfrak{p}]}(t)= {2tC^{[\mathfrak{p}]}(t^2)^2 \over \sqrt{ Q(t) }\left((2t-1)C(t^2)-t^{2n_0^{[\mathfrak{p}]}} + \sqrt{ Q(t) } \right)},

    where Q(t)=(1−4t2)C[𝔭](t2)2+2t2n0[𝔭]C[𝔭](t2)+t4n0[𝔭].Q(t)=(1-4t^2)C^{[\mathfrak{p}]}(t^2)^2+2t^{2n_0^{[\mathfrak{p}]}}C^{[\mathfrak{p}]}(t^2)+t^{4n_0^{[\mathfrak{p}]}}.

Proof. For the proof we can observe that the application of generating function R[𝔭](t,w)R^{[\mathfrak{p}]}(t, w) as

R[𝔭](tw,1w)=∑n,k∈ℕRn,k[𝔭]tnwn−k R^{[\mathfrak{p}]}\left(tw,{1 \over w}\right)=\sum_{n,k\in\mathbb{N}} R_{n, k}^{[\mathfrak{p}]}t^n w^{n-k}

entails that [trws]R[𝔭](tw,1w)=Rr,r−s[𝔭][t^{r}w^{s}]R^{[\mathfrak{p}]}\left(tw,{1 \over w}\right)=R_{r, r-s}^{[\mathfrak{p}]} which is the number of binary words with rr 11-bits and ss 00-bits. To enumerate according to the length let t=wt=w, therefore L[𝔭](t)=∑n≥0Ln[𝔭]tn=R[𝔭](t2,1/t)L^{[\mathfrak{p}]}(t)=\sum_{n\geq 0}L_n^{[\mathfrak{p}]}t^n=R^{[\mathfrak{p}]}(t^2,1/t). The statement of the theorem can be found after some algebraic simplification. □

Theorem 3.6 and Theorem 3.7 allows us to find the generating functions S[𝔭](t)S^{[\mathfrak{p}]}(t) and L[𝔭](t)L^{[\mathfrak{p}]}(t) in terms of the autocorrelation polynomial for any Riordan pattern 𝔭.\mathfrak{p}. In what follows, we study some special classes of patterns characterized by an autocorrelation polynomial which can be easily computed, as in the case C[𝔭](x,y)=1.C^{[\mathfrak{p}]}(x,y)=1. For such particular patterns, Theorem 3.5 simplifies as follows.

Corollary 3.8. Let ℛ[𝔭]=(Rn,k[𝔭])n,k∈ℕ=(d[𝔭](t),h[𝔭](t))\mathcal{R}^{[\mathfrak{p}]}=(R_{n, k}^{[\mathfrak{p}]})_{n,k\in\mathbb{N}}=(d^{[\mathfrak{p}]}(t),h^{[\mathfrak{p}]}(t)) be the Riordan array corresponding to the number of binary words with nn 11-bits and n−kn-k 00-bits which avoid the Riordan pattern 𝔭.\mathfrak{p}. Then we have the following particular cases:

  • for 𝔭=1j+10j\mathfrak{p}=1^{j+1}0^j we have the Riordan array:

    d[𝔭](t)=11−4t+4tj+1,h[𝔭](t)=1−1−4t+4tj+12; d^{[\mathfrak{p}]}(t)={1 \over \sqrt{1-4t+4t^{j+1}}}, \quad h^{[\mathfrak{p}]}(t)={1 -\sqrt{1-4t+4t^{j+1}} \over 2 };
  • 𝔭=0j+11j\mathfrak{p}=0^{j+1}1^j we have the Riordan array:

    d[𝔭](t)=11−4t+4tj+1,h[𝔭](t)=1−1−4t+4tj+12(1−tj); d^{[\mathfrak{p}]}(t)={1 \over \sqrt{1-4t+4t^{j+1}}}, \quad h^{[\mathfrak{p}]}(t)={1 -\sqrt{1-4t+4t^{j+1}} \over 2(1-t^j) };
  • 𝔭=1j0j\mathfrak{p}=1^{j}0^j and 𝔭=0j1j\mathfrak{p}=0^{j}1^j we have the Riordan array:

    d[𝔭](t)=11−4t+2tj+t2j,h[𝔭](t)=1+tj−1−4t+2tj+t2j2; \begin{aligned} d^{[\mathfrak{p}]}(t)&={1 \over \sqrt{1-4t+2t^j+t^{2j}}}, \\ h^{[\mathfrak{p}]}(t)&={{1+t^j -\sqrt{1-4t+2t^j+t^{2j}} } \over 2 }; \end{aligned}
  • 𝔭=(10)j1\mathfrak{p}=(10)^j1 we have the Riordan array:

    d[𝔭](t)=∑i=0jti1−2∑i=1jti−3(∑i=1jti)2,h[𝔭](t)=∑i=0jti−1−2∑i=1jti−3(∑i=1jti)22∑i=0jti; \begin{aligned} d^{[\mathfrak{p}]}(t) &= { \sum_{i=0}^j t^i \over \sqrt{1-2\sum_{i=1}^jt^i-3 \left( \sum_{i=1}^j t^i \right)^2}},\\ h^{[\mathfrak{p}]}(t) &= {\sum_{i=0}^jt^i -\sqrt{1-2\sum_{i=1}^jt^i-3\left( \sum_{i=1}^j t^i \right)^2} \over 2 \sum_{i=0}^jt^i}; \end{aligned}
  • 𝔭=(01)j0\mathfrak{p}=(01)^j0 we have the Riordan array:

    d[𝔭](t)=∑i=0jti1−2∑i=1jti−3(∑i=1jti)2,h[𝔭](t)=∑i=0jti−1−2∑i=1jti−3(∑i=1jti)22∑i=0j−1ti. \begin{aligned} d^{[\mathfrak{p}]}(t) &= { \sum_{i=0}^j t^i \over \sqrt{1-2\sum_{i=1}^jt^i-3 \left( \sum_{i=1}^j t^i \right)^2}},\\ h^{[\mathfrak{p}]}(t) &= {\sum_{i=0}^jt^i -\sqrt{1-2\sum_{i=1}^jt^i-3\left( \sum_{i=1}^j t^i \right)^2} \over 2 \sum_{i=0}^{j-1}t^i}. \end{aligned}

As a peculiar instance, observe that when we instantiate a pattern from family 𝔭=1j0j\mathfrak{p}=1^{j}0^{j} with j=1j=1 we get a Riordan array ℛ[10]=(d[10](t),h[10](t))\mathcal{R}^{[10]} = \left(d^{[10]}(t), h^{[10]}(t)\right) such that

d[10](t)=11−tandh[10](t)=t, d^{[10]}(t)=\frac{1}{1-t} \quad \text{and} \quad h^{[10]}(t) = t,

so the number Rn,0[10]R_{n, 0}^{[10]} of words containing nn 11-bits and nn 00-bits, avoiding pattern 𝔭=10\mathfrak{p}=10, is [tn]d[10](t)=1[t^{n}] d^{[10]}(t) = 1 for n∈ℕn\in\mathbb{N}. If we consider the combinatorial interpretation of Rn,0[𝔭]R_{n,0}^{[\mathfrak{p}]} as lattice paths as illustrated in the last paragraph of Section 3.1, this corresponds to the fact that there is exactly one valley-shaped path having nn steps of both kinds ╱\diagup and ╲\diagdown, avoiding 𝔭=10\mathfrak{p}=10 and terminating at coordinate (2n,0)(2n, 0) for each n∈ℕn\in\mathbb{N}, formally the path 0n1n0^{n}1^{n}.

By applying Theorem 3.6 to the same patterns as before we state the

Corollary 3.9. Let S[𝔭](t)=∑n≥0Sn[𝔭]tnS^{[\mathfrak{p}]}(t)=\sum_{n\geq 0}S_n^{[\mathfrak{p}]}t^n the generating function enumerating the set of binary words {w∈{0,1}∗:∣w∣0≤∣w∣1}\left\lbrace w\in \lbrace 0,1 \rbrace^{*}: |w|_0\leq |w|_1\right\rbrace avoiding a Riordan pattern 𝔭\mathfrak{p} according to the number of 11-bits. We have the following particular cases:

  • for 𝔭=1j+10j\mathfrak{p}=1^{j+1}0^j we have:

    S[𝔭](t)=21−4t+4tj+1(1+1−4t+4tj+1) S^{[\mathfrak{p}]}(t)={2 \over \sqrt{1-4t+4t^{j+1}}\left(1+ \sqrt{1-4t+4t^{j+1}}\right) }
  • for 𝔭=0j+11j\mathfrak{p}=0^{j+1}1^j we have:

    S[𝔭](t)=2(1−tj)1−4t+4tj+1(1−2tj+1−4t+4tj+1) S^{[\mathfrak{p}]}(t)={2(1-t^j) \over \sqrt{1-4t+4t^{j+1}} \left(1-2t^j+ \sqrt{1-4t+4t^{j+1}}\right)}
  • for 𝔭=1j0j\mathfrak{p}=1^{j}0^j and 𝔭=0j1j\mathfrak{p}=0^{j}1^j we have:

    S[𝔭](t)=21−4t+2tj+t2j(1−tj+1−4t+2tj+t2j) S^{[\mathfrak{p}]}(t)={2 \over \sqrt{1-4t+2t^j+t^{2j}} \left(1-t^j+\sqrt{1-4t+2t^j+t^{2j}} \right)}
  • for 𝔭=(10)j1\mathfrak{p}=(10)^j1 we have:

    S[𝔭](t)=2(1−tj+1)1−4t+3tj+1+1−4t+2tj+1+4tj+2−3t2j+2; S^{[\mathfrak{p}]}(t)={2 (1-t^{j+1})\over 1-4t+3t^{j+1}+\sqrt{1-4t+2t^{j+1}+4t^{j+2}-3t^{2j+2}}};
  • for 𝔭=(01)j0\mathfrak{p}=(01)^j0 we have:

    S[𝔭](t)=2(1−tj−tj+1+t2j+1)Q(t)(1−2tj+tj+1+Q(t)) S^{[\mathfrak{p}]}(t)={2 (1-t^j-t^{j+1}+t^{2j+1})\over \sqrt{Q(t)} \left(1-2t^j+t^{j+1}+\sqrt{Q(t)} \right)}

    where Q(t)=1−4t+2tj+1+4tj+2−3t2j+2Q(t)={1-4t+2t^{j+1}+4t^{j+2}-3t^{2j+2}}.

We observe that the case 𝔭=(10)j1\mathfrak{p}=(10)^j1 in Corollary 3.9 corresponds to the sequence studied in S. Bilotta, E. Pergola, and E. Grazzini. Counting Binary Words Avoiding Alternating Patterns. Journal of Integer Sequences, 16, 2013; moreover, in Table 3.4, Table 3.5, Table 3.6, Table 3.7 and Table 3.8 we report some series developments related to S[𝔭](t)S^{[\mathfrak{p}]}(t) functions just defined, respectively.

j/nj/n01234567891011
0100000000000
1137153163127255511102320474095
2131032106357122242301477051918183472651191
31310351234421611593122010821873084271162218
41310351264591696633023806900683424301307138
51310351264621713641524205918743504061341782
61310351264621716643224290922733522121349768
71310351264621716643524307923583526111351574
81310351264621716643524310923753526961351973
Table 3.4: Series developments for S[1j+10j](t)S^{[1^{j+1}0^j]}(t) where j∈{0,…,8}j\in \lbrace 0,\ldots,8 \rbrace, avoiding pattern 𝔭=110\mathfrak{p}=110; moreover, when j=2j=2 the sequence corresponds to A261058A261058.
j/nj/n01234567891011
0111111111111
1138204811225657612802816614413312
2131033111378130245251584155783197389701286
31310351244471632601522336834393132161180511
41310351264601701635123890903983437131312108
51310351264621714642024226919583507361343069
61310351264621716643324295922943522961350098
71310351264621716643524308923633526321351658
81310351264621716643524310923763527011351994
Table 3.5: Series developments for S[0j+11j](t)S^{[0^{j+1}1^j]}(t) where j∈{0,…,8}j\in \lbrace 0,\ldots,8 \rbrace, avoiding pattern 𝔭=001\mathfrak{p}=001; moreover, when j=1j=1 the sequence corresponds to A001792A001792.
j/nj/n01234567891011
01310351264621716643524310923783527161352078
1123456789101112
21392782253791249979602552082248266221
3131034118417149354001968472196266122985003
41310351254541671621123261876413318211261398
51310351264611708639024086913283479651331072
61310351264621715642724265921543516661347326
71310351264621716643424302923333524921351028
81310351264621716643524309923703526711351854
Table 3.6: Series developments for S[0j1j](t)S^{[0^{j}1^j]}(t) (or, equivalently, S[1j0j](t)S^{[1^{j}0^{j}]}(t)) where j∈{0,…,8}j\in \lbrace 0,\ldots,8 \rbrace, avoiding pattern 𝔭=01\mathfrak{p}=01 (or, equivalently, 𝔭=10\mathfrak{p}=10); moreover, when j=0j=0 the sequence corresponds to A001700A001700.
j/nj/n01234567891011
0100000000000
113718481313631017287381692334967024
2131032109377132446971679560425218485793259
31310351234451631603622511844603184381205457
41310351264591699635023911905723447371317397
51310351264621713641824225919793509101344092
61310351264621716643224293922933523171350272
71310351264621716643524307923613526311351679
81310351264621716643524310923753526991351993
Table 3.7: Series developments for S[(10)j1](t)S^{[(10)^{j}1]}(t) where j∈{0,…,8}j\in \lbrace 0,\ldots,8 \rbrace, avoiding pattern 𝔭=101\mathfrak{p}=101; moreover, when j=1j=1 the sequence corresponds to A225034A225034.
j/nj/n01234567891011
0111111111111
1138226117148313733923112573241893644
2131033113393138449201761863456229642834342
31310351244491647609922754853943220221219205
41310351264601703636623974908183456911321092
51310351264621714642224241920423511561345049
61310351264621716643324297923093523801350518
71310351264621716643524308923653526471351742
81310351264621716643524310923763527031352009
Table 3.8: Series developments for S[(01)j0](t)S^{[(01)^{j}0]}(t) where j∈{0,…,8}j\in \lbrace 0,\ldots,8 \rbrace, avoiding pattern 𝔭=010\mathfrak{p}=010; moreover, when j=1j=1 the sequence corresponds to A025566A025566.
Table 3.9: Set of words with 3,3,8,33, 3, 8, 3 and 33 occurrences of 11-bits avoiding patterns 110,001,01,101110, 001, 01, 101 and 010010, respectively.
CoefficientWords
[t3]S[110](t)[t^{3}]S^{[110]}(t)111, 0111, 1011, 00111, 01011, 10011, 10101, 000111, 001011, 010011, 010101, 100011, 100101, 101001, 101010
[t3]S[001](t)[t^{3}]S^{[001]}(t)111, 0111, 1011, 1101, 1110, 01011, 01101, 01110, 10101, 10110, 11010, 11100, 010101, 010110, 011010, 011100, 101010, 101100, 110100, 111000
[t8]S[01](t)[t^{8}]S^{[01]}(t)11111111, 111111110, 1111111100, 11111111000, 111111110000, 1111111100000, 11111111000000, 111111110000000, 1111111100000000
[t3]S[101](t)[t^{3}]S^{[101]}(t)111, 0111, 1110, 00111, 01110, 10011, 11001, 11100, 000111, 001110, 010011, 011001, 011100, 100011, 100110, 110001, 110010, 111000
[t3]S[010](t)[t^{3}]S^{[010]}(t)111, 0111, 1011, 1101, 1110, 00111, 01101, 01110, 10011, 10110, 11001, 11100, 000111, 001101, 001110, 011001, 011100, 100011, 100110, 101100, 110001, 111000

Finally, by applying Theorem 3.7 to the pattern families already examined, we find the following result.

Corollary 3.10. Let L[𝔭](t)=∑n≥0Ln[𝔭]tnL^{[\mathfrak{p}]}(t)=\sum_{n\geq 0}L_n^{[\mathfrak{p}]}t^n the generating function enumerating the set of binary words {w∈{0,1}∗:∣w∣0≤∣w∣1}\left\lbrace w\in \lbrace 0,1 \rbrace^{*}: |w|_0\leq |w|_1\right\rbrace avoiding a Riordan pattern 𝔭\mathfrak{p} according to the length. We have the following particular cases:

  • for 𝔭=1j+10j\mathfrak{p}=1^{j+1}0^j we have:

    L[𝔭](t)=2t1−4t2+4t2(j+1)(2t−1+1−4t2+4t2(j+1)) L^{[\mathfrak{p}]}(t)={2t \over \sqrt{1-4t^2+4t^{2(j+1)}}\left(2t-1+ \sqrt{1-4t^2+4t^{2(j+1)}}\right) }
  • for 𝔭=0j+11j\mathfrak{p}=0^{j+1}1^j we have:

    L[𝔭](t)=2t(t2j−1)1−4t2+4t2(j+1)(1−2t+2t2j+1−1−4t2+4t2(j+1)) L^{[\mathfrak{p}]}(t)={2t(t^{2j}-1) \over \sqrt{1-4t^2+4t^{2(j+1)}} \left(1-2t+2t^{2j+1} -\sqrt{1-4t^2+4t^{2(j+1)}}\right)}
  • for 𝔭=1j0j\mathfrak{p}=1^{j}0^j and 𝔭=0j1j\mathfrak{p}=0^{j}1^j we have:

    L[𝔭](t)=2t1−4t2+2t2j+t4j(−1+2t−t2j+1−4t2+2t2j+t4j) L^{[\mathfrak{p}]}(t)={2 t \over \sqrt{1-4t^2+2t^{2j}+t^{4j}} \left(-1+2t-t^{2j}+\sqrt{1-4t^{2}+2t^{2j}+t^{4j}} \right)}
  • for 𝔭=(10)j1\mathfrak{p}=(10)^j1 we have:

    L[𝔭](t)=2t(t2j+2−1)1−4t2+3t2j+2+(2t−1)Q(t) L^{[\mathfrak{p}]}(t)={2 t (t^{2j+2}-1)\over 1-4t^2+3t^{2j+2}+(2t-1)\sqrt{Q(t)} }
  • for 𝔭=(01)j0\mathfrak{p}=(01)^j0 we have:

    L[𝔭](t)=2t(t2j+2−1)(t2j−1)Q(t)(t2j+2−2t2j+1+2t−1+Q(t)) L^{[\mathfrak{p}]}(t)={2 t (t^{2j+2}-1)(t^{2j}-1)\over \sqrt{Q(t)} (t^{2j+2}-2t^{2j+1}+2t-1+ \sqrt{Q(t)}) }

where Q(t)=1−4t2+2t2j+2+4t2j+4−3t4j+4Q(t)={1-4t^2+2t^{2j+2}+4t^{2j+4}-3t^{4j+4}}.

In Table 3.10, Table 3.11, Table 3.12, Table 3.13 and Table 3.14 we report some series developments related to L[𝔭](t)L^{[\mathfrak{p}]}(t) functions just defined, respectively.

j/nj/n01234567891011121314
0100000000000000
1113377151531316363127127255
2113411153855135201483736174226996313
3113411164263159247610969235438029117
41134111642641632556341015248240419752
51134111642641632566381023250640879880
61134111642641632566381024251040959904
71134111642641632566381024251040969908
Table 3.10: Series developments for L[1j+10j](t)L^{[1^{j+1}0^j]}(t) where j∈{0,…,7}j\in \lbrace 0,\ldots,7 \rbrace.
j/nj/n01234567891011121314
0111111111111111
111349132639731122013135468591469
2113411164061147231542870200432697423
3113411164264161253622999241439429396
41134111642641632566361021249440719812
51134111642641632566381024250840939892
61134111642641632566381024251040969906
71134111642641632566381024251040969908
Table 3.11: Series developments for L[0j+11j](t)L^{[0^{j+1}1^j]}(t) where j∈{0,…,7}j\in \lbrace 0,\ldots,7 \rbrace.
j/nj/n01234567891011121314
01134111642641632566381024251040969908
1112233445566778
2113410143348109163362552120718684036
3113411164162154240583928221735878459
41134111642641622546291008245540009614
51134111642641632566371022250140809853
61134111642641632566381024250940949899
71134111642641632566381024251040969907
Table 3.12: Series developments for L[0j1j](t)L^{[0^{j}1^j]}(t) (or, equivalently, L[1j0j](t)L^{[1^{j}0^j]}(t)) where j∈{0,…,7}j\in \lbrace 0,\ldots,7 \rbrace.
j/nj/n01234567891011121314
0100000000000000
1113378192353661501914295551235
2113411153856139210511790189229737034
3113411164263159248614978238238579273
41134111642641632556341016248640509780
51134111642641632566381023250640889884
61134111642641632566381024251040959904
71134111642641632566381024251040969908
Table 3.13: Series developments for L[(10)j1](t)L^{[(10)^{j}1]}(t) where j∈{0,…,7}j\in \lbrace 0,\ldots,7 \rbrace.
j/nj/n01234567891011121314
0111111111111111
1113491328428713427142584413422628
2113411164061149234558895209834207909
31134111642641612536241002243039679492
41134111642641632566361021249640749828
51134111642641632566381024250840939894
61134111642641632566381024251040969906
71134111642641632566381024251040969908
Table 3.14: Series developments for L[(01)j0](t)L^{[(01)^{j}0]}(t) where j∈{0,…,7}j\in \lbrace 0,\ldots,7 \rbrace.

3.3Code for enumeration and construction of Riordan arrays

>>> w_1, w_0 = 3, 2
>>> binary_words = words(avoiding=[1,1,0],
...                      ones=[1]*w_1,
...                      zeros=[0]*w_0)
>>> sorted(binary_words)
[[0, 0, 1, 1, 1], [0, 1, 0, 1, 1],
 [1, 0, 0, 1, 1], [1, 0, 1, 0, 1]]

>>> words_as_strings(binary_words)
['00111', '01011', '10011', '10101']

>>> {w_0: sorted(words(avoiding=[1,1,0],
...                    ones=[1]*w_1,
...                    zeros=[0]*w_0))
...  for w_0 in range(w_1+1)}
{0: [[1, 1, 1]],
 1: [[0, 1, 1, 1], [1, 0, 1, 1]],
 2: [[0, 0, 1, 1, 1], [0, 1, 0, 1, 1],
     [1, 0, 0, 1, 1], [1, 0, 1, 0, 1]],
 3: [[0, 0, 0, 1, 1, 1], [0, 0, 1, 0, 1, 1],
     [0, 1, 0, 0, 1, 1], [0, 1, 0, 1, 0, 1],
     [1, 0, 0, 0, 1, 1], [1, 0, 0, 1, 0, 1],
     [1, 0, 1, 0, 0, 1], [1, 0, 1, 0, 1, 0]]}

After the initial imports

from collections import namedtuple
from functools import wraps

import sympy

J_index = namedtuple('J_index', ['j'])
W_index = namedtuple('W_index', ['w_1', 'w_0'])

we introduce the definition words to be a simple implementation of a word generator, in the sense of Python generator, inspired by a tableau schema. If exausted, words yields all binary words that don’t contain pattern avoiding, using the given occurrences of ones and zeros, respectively.

def words(avoiding, ones, zeros):

    a = len(avoiding)

    def W(word, ones, zeros):

        if ones:
            one = ones[0]
            new_word = word + [one]
            if new_word[-a:] != avoiding:
                yield from W(new_word, ones[1:], zeros)

        if zeros:
            zero = zeros[0]
            new_word = word + [zero]
            if new_word[-a:] != avoiding:
                yield from W(new_word, ones, zeros[1:])

        if not ones and not zeros: yield word

    return W([], ones, zeros)

A decorator is a function returning another function, usually applied as a function transformation using the @wrapper syntax.

The decorator syntax is merely syntactic sugar, the following two function definitions are semantically equivalent with respect to the staticmethod decorator:

>>> def f(*args):
...     pass
>>> f = staticmethod(f)

>>> @staticmethod
... def f(*args):
...     pass

Decorators provides metaprogramming capabilities and modularity; for example, a memoized version of Fibonacci numbers recursion can be coded using the lru_cache decorator:

from functools import lru_cache

@lru_cache(maxsize=None)
def fibonacci(n):
    '''
    Fibonacci's numbers, memoized.

    >>> fibonacci(100)
    354224848179261915075

    >>> list(map(fibonacci, range(20)))
    ... # doctest: +NORMALIZE_WHITESPACE
    [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,
     144, 233, 377, 610, 987, 1597, 2584, 4181]

    '''
    if n < 2:
        return n

    return fibonacci(n-1) + fibonacci(n-2)

Together with the decorator avoiding

class avoiding:

    def __init__(self, pattern, G):
        self.pattern = pattern
        self.G = G # `G` stands for *generator*

    def __call__(self, post):

        @wraps(post)
        def A(n_domain, j_domain, *args, **kwds):

            T = {J_index(j):
                    {W_index(w_1, w_0): sorted(words)
                     for w_1 in n_domain
                     for w_0 in range(w_1+1)
                     for words in [self.G(pattern,
                                          ones=[1]*w_1,
                                          zeros=[0]*w_0)]}
                 for j in j_domain
                 for pattern in [self.pattern(j)]} # implicit `let`

            res = post(T, *args, **kwds)
            return res if res else T

        return A

with the two helper definitions words_as_strings and rows_sums

def words_as_strings(bws):
    J = lambda w: ''.join(map(str, w))
    return sorted(map(J, bws), key=len)

def rows_sums(M):
    return list(M * sympy.ones(M.rows, 1))

it allows us to enumerate words in our families with

@avoiding(pattern=lambda j: [1]*(j+1) + [0]*j, G=words)
def ones_then_zeros_words(table): pass

@avoiding(pattern=lambda j: [0]*(j+1) + [1]*j, G=words)
def zeros_then_ones_words(table): pass

@avoiding(pattern=lambda j: [0]*j + [1]*j, G=words)
def zeros_equals_ones_words(table): pass

@avoiding(pattern=lambda j: [1,0]*j + [1], G=words)
def one_zero_star_one_words(table): pass

@avoiding(pattern=lambda j: [0,1]*j + [0], G=words)
def zero_one_star_zero_words(table): pass

over the domains for the number of 11-bits, the length and jj params

>>> n_domain, l_domain, j_domain = (list(range(11)),
                                    list(range(13)),
                                    list(range(3)))

respectively. Counting words grouped by the number of 11-bits and by their length by definitions

def group_by_ones(n_domain, words):

    Z = sympy.zeros(len(n_domain), len(n_domain))

    for o in n_domain:
        for z in range(o+1):
            Z[o, o-z] += len(words[W_index(o, z)])

    return Z

def group_by_length(n_domain, words):

    rows = len(n_domain)
    Z = sympy.zeros(2 * rows, 2 * rows)

    for o in n_domain:
        for z in range(o+1):
            Z[o+z,o-z] += len(words[W_index(o, z)])

    return Z[:rows,:rows]

respectively, we justify the content of previous tables with the following computationsProves the set of words already enumerated in the first row of Table 3.9.

>>> binary_words = ones_then_zeros_words(n_domain, j_domain)
>>> words_as_strings([w for w_1 in [3]
...                     for w_0 in range(w_1+1)
...                     for J,W in [(J_index(1),W_index(w_1, w_0))]
...                     for w in binary_words[J][W]])
['111', '0111', '1011', '00111', '01011', '10011', '10101',
 '000111', '001011', '010011', '010101', '100011', '100101',
 '101001', '101010']

>>> M = group_by_ones(n_domain, binary_words[J_index(1)])
>>> rows_sums(M)
[1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047]
>>> M

Proves the series development in row j=1j=1 of Table 3.4 as row summation M ⋅𝟏\,\cdot\boldsymbol{1}.

[121421842116842132168421643216842112864321684212561286432168421512256128643216842110245122561286432168421] \left[\begin{array}{ccccccccccc}1 & & & & & & & & & & \\2 & 1 & & & & & & & & & \\4 & 2 & 1 & & & & & & & & \\8 & 4 & 2 & 1 & & & & & & & \\16 & 8 & 4 & 2 & 1 & & & & & & \\32 & 16 & 8 & 4 & 2 & 1 & & & & & \\64 & 32 & 16 & 8 & 4 & 2 & 1 & & & & \\128 & 64 & 32 & 16 & 8 & 4 & 2 & 1 & & & \\256 & 128 & 64 & 32 & 16 & 8 & 4 & 2 & 1 & & \\512 & 256 & 128 & 64 & 32 & 16 & 8 & 4 & 2 & 1 & \\1024 & 512 & 256 & 128 & 64 & 32 & 16 & 8 & 4 & 2 & 1\end{array}\right]
>>> binary_words = ones_then_zeros_words(l_domain, j_domain)
>>> M = group_by_length(l_domain, binary_words[J_index(1)])
>>> rows_sums(M)
[1, 1, 3, 3, 7, 7, 15, 15, 31, 31, 63, 63, 127]
>>> M

Proves the series development in row j=1j=1 of Table 3.10 as row summation M ⋅𝟏\,\cdot\boldsymbol{1}.

[1121214214218421842116842116842132168421321684216432168421] \left[\begin{array}{ccccccccccccc}1 & & & & & & & & & & & & \\ & 1 & & & & & & & & & & & \\2 & & 1 & & & & & & & & & & \\ & 2 & & 1 & & & & & & & & & \\4 & & 2 & & 1 & & & & & & & & \\ & 4 & & 2 & & 1 & & & & & & & \\8 & & 4 & & 2 & & 1 & & & & & & \\ & 8 & & 4 & & 2 & & 1 & & & & & \\16 & & 8 & & 4 & & 2 & & 1 & & & & \\ & 16 & & 8 & & 4 & & 2 & & 1 & & & \\32 & & 16 & & 8 & & 4 & & 2 & & 1 & & \\ & 32 & & 16 & & 8 & & 4 & & 2 & & 1 & \\64 & & 32 & & 16 & & 8 & & 4 & & 2 & & 1\end{array}\right]
>>> M = group_by_length(l_domain, binary_words[J_index(2)])
>>> rows_sums(M)
[1, 1, 3, 4, 11, 15, 38, 55, 135, 201, 483, 736, 1742]
>>> M

Proves the series development in row j=2j=2 of Table 3.10 as row summation M ⋅𝟏\,\cdot\boldsymbol{1}.

[112131641951181361291871584424819664319119215190391013252281234811165052433316458121] \left[\begin{array}{ccccccccccccc}1 & & & & & & & & & & & & \\ & 1 & & & & & & & & & & & \\2 & & 1 & & & & & & & & & & \\ & 3 & & 1 & & & & & & & & & \\6 & & 4 & & 1 & & & & & & & & \\ & 9 & & 5 & & 1 & & & & & & & \\18 & & 13 & & 6 & & 1 & & & & & & \\ & 29 & & 18 & & 7 & & 1 & & & & & \\58 & & 44 & & 24 & & 8 & & 1 & & & & \\ & 96 & & 64 & & 31 & & 9 & & 1 & & & \\192 & & 151 & & 90 & & 39 & & 10 & & 1 & & \\ & 325 & & 228 & & 123 & & 48 & & 11 & & 1 & \\650 & & 524 & & 333 & & 164 & & 58 & & 12 & & 1\end{array}\right]

3.4Some combinatorial interpretations

In the previous section we proved results about the enumeration of words avoiding patterns from an algebraic point of view. The aim of this section is to analyze in more details some particular cases of the various pattern families. We approach these problems either combinatorially by providing an interpretation, or algebraically by computing the coefficients of the involved generating functions explicitly.

3.4.1Enumeration with respect to the number of 11-bits

Corollary 3.11. Consider pattern 𝔭=1j+10j\mathfrak{p}=1^{j+1}0^{j}, there is only one word in 𝔏[𝔭]\mathfrak{L}^{[\mathfrak{p}]} for j=0j=0; on the other hand, there are Sn[𝔭]=2n+1−1S_{n}^{[\mathfrak{p}]} = 2^{n+1}-1 words for j=1j=1.

Proof. When j=0j=0 the pattern to avoid is 𝔭=1\mathfrak{p}=1, therefore only words ww in {ε}∪{0}+\lbrace \varepsilon \rbrace\cup\lbrace 0 \rbrace^{+} are suitable choices; however, the constraint ∣w∣0≤∣w∣1|w|_{0} \leq |w|_{1} makes w=εw = \varepsilon the only one.

When j=1j=1 the pattern to avoid is 𝔭=110\mathfrak{p}=110 and we observe that the generic binomial (rk){r \choose k} can be interpreted as the number of binary words with rr 00-bits containing kk occurrences of the substring 1010, which we call an inversion with respect to pattern 𝔭=110\mathfrak{p}=110. In order to build a word in the language we start from the substring 0r0^{r} for r∈{0,⋯ ,n}r\in\lbrace 0,\cdots,n\rbrace and select k∈{0,…,r}k\in \lbrace 0, \ldots,r \rbrace 00-bits, transforming each one using the mapping 0↦100 \mapsto 10, while preventing the transformation of the 00-bit in the 1010 just introduced. This maneuver introduces kk inversions and the selection can be done in (rk){r \choose k} ways; finally, we pad on the right with a strip 1n−k1^{n-k}, because it is mandatory for a word to have nn 11-bits, hence there is one padding for each set of inversions and there is no other way to avoid 𝔭\mathfrak{p}. Therefore

∑r=0n∑k=0r(rk)=2n+1−1=Sn[𝔭], \sum_{r=0}^{n}{\sum_{k=0}^{r}{{r \choose k}}} = 2^{n+1}-1 = S_{n}^{[\mathfrak{p}]},

as can be verified algebraically by extracting the coefficient of the generating function S[𝔭](t)=11−3t+2t2=21−2t−11−t\displaystyle S^{[\mathfrak{p}]}(t)={1 \over 1-3t+2t^2}={2 \over 1-2t}-{1 \over 1-t}, as required. □

The same argument can be rewritten in term of sets which allows us give a constructive approach. Let 𝒮n,k,i\mathcal{S}_{n, k, i} be the set of binary words containing nn and kk occurrences of 11-bits and 00-bits, respectively, with ii inversions, namely an occurrence of the subsequence 1010. By union respect to ii and kk we get sets 𝒮n,k[𝔭]\mathcal{S}_{n, k}^{[\mathfrak{p}]} and 𝒮n[𝔭]\mathcal{S}_{n}^{[\mathfrak{p}]}, formally:

𝒮n[𝔭]=⋃k∈{0,…,n}𝒮n,k[𝔭]=⋃i∈{0,…,k}𝒮n,k,i[𝔭]=(⋃i∈{0,…,k}𝒮k,k,i[𝔭])×{1n−k} \mathcal{S}_{n}^{[\mathfrak{p}]} = \bigcup_{k\in \lbrace 0,\ldots,n \rbrace} {\mathcal{S}_{n, k}^{[\mathfrak{p}]}} = \bigcup_{i\in \lbrace 0,\ldots,k \rbrace} {\mathcal{S}_{n, k, i}^{[\mathfrak{p}]}} = {\left(\bigcup_{i\in \lbrace 0,\ldots,k \rbrace}{ \mathcal{S}_{k, k, i}^{[\mathfrak{p}]}}\right)\times \left\lbrace 1^{n-k} \right\rbrace}

For the sake of clarity, we enumerate all binary words avoiding 𝔭=110\mathfrak{p}=110 containing n=3n=3 11-bits, formally we partition 𝒮3[𝔭]\mathcal{S}_{3}^{[\mathfrak{p}]} as follows

𝒮3[𝔭]=𝒮0,0,0[𝔭]×{111}∪(𝒮1,1,0[𝔭]∪𝒮1,1,1[𝔭])×{11}∪(𝒮2,2,0[𝔭]∪𝒮2,2,1[𝔭]∪𝒮2,2,2[𝔭])×{1}∪(𝒮3,3,0[𝔭]∪𝒮3,3,1[𝔭]∪𝒮3,3,2[𝔭]∪𝒮3,3,3[𝔭])×{ε} \begin{aligned} \mathcal{S}_{3}^{[\mathfrak{p}]} &= \mathcal{S}_{0, 0, 0}^{[\mathfrak{p}]}\times\lbrace 111 \rbrace\\ &\cup{\left(\mathcal{S}_{1, 1, 0}^{[\mathfrak{p}]}\cup\mathcal{S}_{1, 1, 1}^{[\mathfrak{p}]}\right)\times \lbrace 11 \rbrace}\\ &\cup{\left(\mathcal{S}_{2, 2, 0}^{[\mathfrak{p}]}\cup\mathcal{S}_{2, 2, 1}^{[\mathfrak{p}]}\cup\mathcal{S}_{2, 2, 2}^{[\mathfrak{p}]}\right)\times \lbrace 1 \rbrace}\\ &\cup{\left(\mathcal{S}_{3, 3, 0}^{[\mathfrak{p}]}\cup\mathcal{S}_{3, 3, 1}^{[\mathfrak{p}]}\cup\mathcal{S}_{3, 3, 2}^{[\mathfrak{p}]}\cup\mathcal{S}_{3, 3, 3}^{[\mathfrak{p}]}\right)\times \lbrace \varepsilon \rbrace} \end{aligned}

where

𝒮3,0[𝔭]=𝒮0,0,0[𝔭]×{111}={ε}×{111}={111}𝒮3,1[𝔭]=(𝒮1,1,0[𝔭]∪𝒮1,1,1[𝔭])×{11}={0111}∪{1011}𝒮3,2[𝔭]=(𝒮2,2,0[𝔭]∪𝒮2,2,1[𝔭]∪𝒮2,2,2[𝔭])×{1}={00111}∪{10011,01011}∪{10101}𝒮3,3[𝔭]=(𝒮3,3,0[𝔭]∪𝒮3,3,1[𝔭]∪𝒮3,3,2[𝔭]∪𝒮3,3,3[𝔭])×{ε}={000111}∪{001011,100011,010011}∪{101001,100101,010101}∪{101010} \begin{aligned} \mathcal{S}_{3, 0}^{[\mathfrak{p}]}=\mathcal{S}_{0, 0, 0}^{[\mathfrak{p}]}\times\lbrace 111 \rbrace &= \lbrace \varepsilon \rbrace\times\lbrace 111 \rbrace= \{111\}\\ \mathcal{S}_{3, 1}^{[\mathfrak{p}]}={\left(\mathcal{S}_{1, 1, 0}^{[\mathfrak{p}]}\cup\mathcal{S}_{1, 1, 1}^{[\mathfrak{p}]}\right)\times \lbrace 11 \rbrace} &= \{0111\}\cup\{1011\}\\ \mathcal{S}_{3, 2}^{[\mathfrak{p}]}={\left(\mathcal{S}_{2, 2, 0}^{[\mathfrak{p}]}\cup\mathcal{S}_{2, 2, 1}^{[\mathfrak{p}]}\cup\mathcal{S}_{2, 2, 2}^{[\mathfrak{p}]}\right)\times \lbrace 1 \rbrace} &=\{00111\}\cup\{10011, 01011\}\cup\{10101\}\\ \mathcal{S}_{3, 3}^{[\mathfrak{p}]}={\left(\mathcal{S}_{3, 3, 0}^{[\mathfrak{p}]}\cup\mathcal{S}_{3, 3, 1}^{[\mathfrak{p}]}\cup\mathcal{S}_{3, 3, 2}^{[\mathfrak{p}]}\cup\mathcal{S}_{3, 3, 3}^{[\mathfrak{p}]}\right)\times \lbrace \varepsilon \rbrace} &= \{000111\}\cup\{001011, 100011, 010011\} \\ &\cup\{101001, 100101, 010101\}\cup\{101010\} \end{aligned}

the same set of words shown in Table 3.4.

Corollary 3.12. Consider pattern 𝔭=0j+11j\mathfrak{p}=0^{j+1}1^{j}, there is one word Sn[𝔭]=1S_{n}^{[\mathfrak{p}]} = 1 for each n∈ℕn\in\mathbb{N} in 𝔏[𝔭]\mathfrak{L}^{[\mathfrak{p}]} when j=0j=0; on the other hand, there are (n+2)2n−1(n+2)2^{n-1} words for j=1j=1.

Proof. When j=0j=0 the pattern to avoid is 𝔭=0\mathfrak{p}=0, therefore only words w=1nw = 1^{n} are suitable, hence there is one of them for each n∈ℕn\in\mathbb{N}.

When j=1j=1 the pattern to avoid is 𝔭=001\mathfrak{p}=001, therefore we extract the nn-th coefficient after instantiation of the corresponding generating function [tn]Sn[𝔭](t)=[tn]1−t(1−2t)2=(n+2)2n−1\displaystyle [t^{n}] S_{n}^{[\mathfrak{p}]}(t) = [t^{n}]\frac{1-t}{(1-2t)^{2}} = (n+2)2^{n-1}, as required.

We also provide a combinatorial interpretation of the theorem; first of all, we observe that sequence Sn[𝔭]S_{n}^{[\mathfrak{p}]} is the binomial transform of the sequence of the positive integers (n+1)n∈ℕ(n+1)_{n\in\mathbb{N}}, formally

Sn[𝔭]=(n+2)2n−1=∑k=0n(nk)(k+1) S_{n}^{[\mathfrak{p}]} =(n+2)2^{n-1}= \sum_{k=0}^{n}{{n \choose k}(k+1)}

where the generic summand (nk)(k+1){{n \choose k}(k+1)} can be interpreted as the number of binary words with nn 11-bits containing n−kn-k occurrences of the substring 0101, which we call an inversion respect to pattern 𝔭=001\mathfrak{p}=001. We construct the set of words avoiding 𝔭\mathfrak{p} to show the bijection with the previous assert as follows: if in a word ww there are n−kn-k occurrences of the substring 0101 then ww contains 2n−2k2n-2k bits in total, n−kn-k of both kind. Since it is mandatory that the number of 11 is nn, we add kk 11-bits to it, resulting in a new word w′w' of length 2n−k2n-k which can be augmented with at most kk additional 00-bits, according to the constraint ∣w′∣0≤∣w′∣1|w'|_{0}\leq |w'|_{1}. In order to build a word with the structure of w′w', we start from the substring 1n1^{n} and select n−kn-k 11-bits, transforming each one using the mapping 1↦011 \mapsto 01, simultaneously to prevent transforming 11-bit in 0101 just introduced. This maneuver introduces n−kn-k inversions and the selection can be done in (nk){n \choose k} ways; moreover, we are free to pad on the right with 0i0^{i} strips, for i∈{0,⋯ ,k},i\in\lbrace 0,\cdots,k\rbrace, hence there are k+1k+1 paddings for each set of inversions. Therefore, since there can be up to nn inversions,

∑k=0n(nn−k)(k+1)=(n+2)2n−1 \sum_{k=0}^{n}{{n \choose n-k}(k+1)} = (n+2)2^{n-1}

concludes the proof by symmetry of binomial coefficients. □

Corollary 3.13. Consider pattern 𝔭=0j1j\mathfrak{p}=0^{j}1^{j} (or, equivalently, 𝔭=1j0j\mathfrak{p}=1^{j}0^{j}), there are

Sn[𝔭]=∑k=0n(n+kk)=(2n+1n) S_{n}^{[\mathfrak{p}]}=\sum_{k=0}^{n}{{n+k \choose k}}={2n+1 \choose n}

words in 𝔏[𝔭]\mathfrak{L}^{[\mathfrak{p}]} for j=0j=0; on the other hand, there are Sn[𝔭]=n+1S_{n}^{[\mathfrak{p}]} = n+1 words for j=1j=1.

Proof. When j=0j=0 there is no pattern to avoid and this situation corresponds to the enumeration of binary words {w∈{0,1}∗:∣w∣0≤∣w∣1=n}\left\lbrace w\in \lbrace 0,1 \rbrace^{*}: |w|_{0} \leq |w|_{1}=n\right\rbrace. After instantiating the generating function S[𝔭](t)S^{[\mathfrak{p}]}(t), we extract the nn-th coefficient

[tn]Sn[𝔭](t) = [tn]1−1−4t2t1−4t [t^{n}] S_{n}^{[\mathfrak{p}]}(t)~=~[t^{n}]\frac{1-\sqrt{1-4t}}{2t\sqrt{1-4t}}

obtaining 12(2(n+1)n+1)=(2n+1n+1)=(2n+1n)\displaystyle\frac{1}{2}{2(n+1) \choose n+1} = {2n+1 \choose n+1} = {2n+1 \choose n} which simplifies by the identity (r+s+1s)=∑q=0s(r+qq)\displaystyle{r+s+1 \choose s} = \sum_{q=0}^{s}{{r+q \choose q}} as desired. It is possible to state the following combinatorial interpretation: since the maximum number of 00-bits is nn, we reserve nn boxes for them. To the left of each box reserve one more box and, finally, another one to the right of the very last box. In this way we have reserved 2n+12n+1 boxes where we can put nn 11-bits in (2n+1n){2n+1 \choose n} ways, as required.

When j=1j=1 the pattern to avoid is 𝔭=01\mathfrak{p}=01 (or, equivalently, 𝔭=10\mathfrak{p}=10), therefore only words w∈{1n}×⋃s∈{0,…,n}{0s}w \in \lbrace 1^{n} \rbrace\times\bigcup_{s\in \lbrace 0,\ldots,n \rbrace}\lbrace 0^{s} \rbrace are suitable, which are n+1n+1, one for each value that ss can take. □

Last two patterns 𝔭=(10)j1\mathfrak{p}=(10)^{j}1 and 𝔭=(01)j0\mathfrak{p}=(01)^{j}0 are harder to study: for j=0j=0 there are Sn[𝔭]=[ ⁣[n=0] ⁣]S_{n}^{[\mathfrak{p}]}=[\![n=0]\!] and Sn[𝔭]=1S_{n}^{[\mathfrak{p}]}=1 words, respectively. On the other hand, when j=1j=1 we report only the instantiated generating functions

S[101](t)=(1+t)(1−3t−1−2t−3t2)2t(3t−1),S[010](t)=1−2t−3t2−(1−t)1−2t−3t22t2(3t−1). \begin{aligned} S^{[101]}(t) &=\frac{(1+t)\left(1-3t-\sqrt{1-2t-3t^{2}}\right)}{2t(3t-1)}, \\ S^{[010]}(t) &=\frac{1-2t-3t^{2}-(1-t)\sqrt{1-2t-3t^{2}}}{2t^{2}(3t-1)}. \end{aligned}

As pointed out by an anonymous referee, previous functions can be rewritten as

S[101](t)=(1+t)(1−tM(t))1−3t,S[010](t)=(1+tM(t))(1−tM(t))1−3t \begin{aligned} S^{[101]}(t) &=\frac{(1+t)(1- t M(t))}{1-3t},\\ S^{[010]}(t) &=\frac{(1+t M(t))(1-t M(t))}{1-3t} \end{aligned}

respectively, where M(t)=1−t−1−2t−3t22t2M(t)=\frac{1 - t - \sqrt{1-2t-3t^{2}} }{2t^{2}} is the Motzkin numbers’ generating function. Such rewriting shows a relation among Motzkin numbers and powers of 33; however, a combinatorial argument is not easy to state to the best of our knowledge.

3.4.2Enumeration with respect to the length

Corollary 3.14. Consider pattern 𝔭=1j+10j\mathfrak{p}=1^{j+1}0^{j}, there is one word in 𝔏[𝔭]\mathfrak{L}^{[\mathfrak{p}]} for j=0j=0; on the other hand, there are 2m+1−12^{m+1}-1 words, where n=2m+[ ⁣[n is odd] ⁣]n=2m + [\![\text{n is odd}]\!], for j=1j=1.

Proof. When j=0j=0 the pattern to avoid is 𝔭=1\mathfrak{p}=1, therefore instantiating the generating function we have L[𝔭](t)=1L^{[\mathfrak{p}]}(t) = 1, as required.

When j=1j=1 the pattern to avoid is 𝔭=110\mathfrak{p}=110, therefore we instantiate and extract the nn-th coefficient

Ln[𝔭]=[tn]21−2t2+[tn−1]21−2t2−[tn]11−t L_{n}^{[\mathfrak{p}]} = [t^{n}]\frac{2}{1-2t^{2}} + [t^{n-1}]\frac{2}{1-2t^{2}} - [t^{n}]\frac{1}{1-t}

and proceed by cases on the parity of nn. If n=2mn=2m then the second term in the rhs disappears, otherwise if n=2m+1n=2m+1 the first term disappears; in both cases it is required to perform [um]21−2u=2m+1[u^{m}]\frac{2}{1-2u} = 2^{m+1} where u=t2u=t^{2}, as required.

It is possible to state a combinatorial interpretation using an argument similar to the one given in the proof of Corollary 3.11. Let n=2mn=2m, therefore a word ww needs to have m+jm+j 11-bits, where j∈{0,…,m}j\in \lbrace 0,\ldots,m \rbrace; conversely, ww needs to have n−m−j=m−jn-m-j=m-j 00-bits. Fixing jj in the given range, from the substring 0m−j0^{m-j} we select i∈{0,…,m−j}i\in \lbrace 0,\ldots,m-j \rbrace 00-bits to introduce ii inversions, namely ii occurrences of 1010, applying the mapping 0↦100\mapsto 10 simultaneously. This maneuver keeps the original 00-bits and introduces at most m−jm-j 11-bits, so we pad with 11-bits on the right in order to have the required m+jm+j 11-bits in the entire word; finally, selections can be done in

∑j=0m∑i=0m−j(m−ji)=∑j=0m2m−j=2m+1−1 \sum_{j=0}^{m}{\sum_{i=0}^{m-j}{ {m-j \choose i}} } = \sum_{j=0}^{m}{2^{m-j}} = 2^{m+1}-1

ways, because padding can be done in only one way, completing the case for nn even.

Let n=2m+1n=2m+1, therefore a word ww needs to have m+1+jm+1+j 11-bits, where j∈{0,…,m}j\in \lbrace 0,\ldots,m \rbrace; conversely, ww needs to have n−m−1−j=m−jn-m-1-j=m-j 00-bits. Fixing jj in the given range, from the substring 0m−j0^{m-j} we select i∈{0,…,m−j}i\in \lbrace 0,\ldots,m-j \rbrace 00-bits to introduce ii inversions as done in the even case, introducing at most m−jm-j 11-bits, and padding as necessary to have m+1+jm+1+j 11-bits, the total number of selections equals the one given for the even case, completing the case for nn odd. □

Corollary 3.15. Consider pattern 𝔭=0j+11j\mathfrak{p}=0^{j+1}1^{j}, there is one word Ln[𝔭]=1L_{n}^{[\mathfrak{p}]} = 1 for each n∈ℕn\in\mathbb{N} in 𝔏[𝔭]\mathfrak{L}^{[\mathfrak{p}]} when j=0j=0; on the other hand, there are Ln[𝔭]=Fn+3−2mL_{n}^{[\mathfrak{p}]} = F_{n+3}-2^{m} words if n=2mn=2m else Ln[𝔭]=Fn+3−2m+1L_{n}^{[\mathfrak{p}]} = F_{n+3}-2^{m+1} words if n=2m+1n=2m+1, for j=1j=1, where FnF_{n} is the nn-th Fibonacci number.

Proof. When j=0j=0 the pattern to avoid is 𝔭=0\mathfrak{p}=0, therefore suitable words of length nn are of the form w=1nw=1^{n}, hence Ln[𝔭]=1L_{n}^{[\mathfrak{p}]} = 1 for each n∈ℕn\in\mathbb{N}.

When j=1j=1 the pattern to avoid is 𝔭=001\mathfrak{p}=001, therefore we instantiate and extract the nn-th coefficient

Ln[𝔭]=2[tn+1]t1−t−t2+[tn]t1−t−t2−[tn]11−2t2−2[tn−1]11−2t2 \begin{aligned} L_{n}^{[\mathfrak{p}]} &= 2[t^{n+1}]\frac{t}{1-t-t^{2}} + [t^{n}]\frac{t}{1-t-t^{2}}\\ &- [t^{n}]\frac{1}{1-2t^{2}} - 2[t^{n-1}]\frac{1}{1-2t^{2}} \end{aligned}

in order to have Ln[𝔭]=2Fn+1+Fn−an=Fn+3−anL_{n}^{[\mathfrak{p}]} = 2F_{n+1} + F_{n} - a_{n} = F_{n+3} - a_{n}, where a2m=2ma_{2m}=2^{m} and a2m+1=2m+1a_{2m+1}=2^{m+1}.

It is possible to state a combinatorial interpretation using an argument similar to the one given in the proof of Corollary 3.12. Let n=2mn=2m, therefore a word ww needs to have m+jm+j 11-bits, where j∈{0,…,m}j\in \lbrace 0,\ldots,m \rbrace; conversely, ww needs to have n−m−j=m−jn-m-j=m-j 00-bits. Fixing jj in the given range, from the substring 1m+j1^{m+j} we select i∈{0,…,m−j}i\in \lbrace 0,\ldots,m-j \rbrace 11-bits to introduce ii inversions, namely ii occurrences of 0101, applying the mapping 1↦011\mapsto 01 simultaneously. This maneuver keeps the original 11-bits and introduces at most m−jm-j 00-bits; finally, selections can be done in ∑j=0m∑i=0m−j(m+ji)\sum_{j=0}^{m}{\sum_{i=0}^{m-j}{ {m+j \choose i}} } ways. In order to find a closed form for the double summation, we inspect the region of the Pascal triangle taken into account; marking with ∘\circ the involved binomials

n/j01…m−1mm+1…2m−12m…0⋮m−1m∘∘…∘∘m+1∘∘…∘⋮⋮⋮...2m−1∘∘2m∘2m+1⋮ \begin{array}{c|cccccccccc} n/j & 0 & 1 & \ldots & m-1 & m & m+1 & \ldots & 2m-1 & 2m & \ldots\\ \hline 0 & \\ \vdots & \\ m-1 & \\ m & \circ & \circ & \ldots & \circ & \circ \\ m+1 & \circ & \circ & \ldots & \circ \\ \vdots & \vdots & \vdots & \mathinner{\raisebox{0pt}{.}\raisebox{0.35em}{.}\raisebox{0.7em}{.}} \\ 2m-1 & \circ & \circ \\ 2m & \circ \\ 2m+1 & \\ \vdots & \\ \end{array}

and using identity (r+1k+1)−(sk+1)=∑i=sr(ik){r+1 \choose k+1}-{s \choose k+1} = \sum_{i=s}^{r}{{i \choose k}} for rearranging the summation and identities 2n=∑i=0n(ni)2^{n}=\sum_{i=0}^{n}{{n \choose i}} and Fn+1=∑i=0n(n−ii)F_{n+1}=\sum_{i=0}^{n}{{n-i \choose i}} to collect terms, we obtain

∑j=0m∑i=0m−j(m+ji)=∑k=0m(2m+1−kk+1)−(mk+1) \sum_{j=0}^{m}{\sum_{i=0}^{m-j}{ {m+j \choose i}} } = \sum_{k=0}^{m}{{2m+1-k \choose k+1}-{m \choose k+1}}

which equals F2m+3−2m=L2m[𝔭]F_{2m+3}-2^{m} = L_{2m}^{[\mathfrak{p}]}, closing the case for nn even.

Let n=2m+1n=2m+1, therefore a word ww needs to have m+1+jm+1+j 11-bits, where j∈{0,…,m}j\in \lbrace 0,\ldots,m \rbrace; conversely, ww needs to have n−m−1−j=m−jn-m-1-j=m-j 00-bits. Fixing jj in the given range, from the substring 1m+1+j1^{m+1+j} select i∈{0,…,m−j}i\in \lbrace 0,\ldots,m-j \rbrace 11-bits to introduce ii inversions as done for the even case; in parallel, selections can be done in ∑j=0m∑i=0m−j(m+1+ji)\sum_{j=0}^{m}{\sum_{i=0}^{m-j}{ {m+1+j \choose i}} } ways. The involved region in the Pascal triangle has the same shape as the one shown for the even case translated one row to the bottom, so binomials lying on row mm are excluded and binomials (2m+1−kk){2m+1-k \choose k} are included, for k∈{0,…,m}k\in \lbrace 0, \ldots, m \rbrace. Therefore we rewrite

∑j=0m∑i=0m−j(m+1+ji)=∑k=0m(2m+2−kk+1)−(m+1k+1) \sum_{j=0}^{m}{\sum_{i=0}^{m-j}{ {m+1+j \choose i}} } = \sum_{k=0}^{m}{{2m+2-k \choose k+1}-{m+1 \choose k+1}}

which equals F2m+4−2m+1=L2m+1[𝔭]F_{2m+4}-2^{m+1} = L_{2m+1}^{[\mathfrak{p}]}, closing the case for nn odd. □

Corollary 3.16. Consider pattern 𝔭=0j1j\mathfrak{p}=0^{j}1^{j} (or, equivalently, 𝔭=1j0j\mathfrak{p}=1^{j}0^{j}), there are 2n−12^{n-1} words in 𝔏[𝔭]\mathfrak{L}^{[\mathfrak{p}]} if nn is odd else 2n−1+12(2mm)2^{n-1} +\frac{1}{2}{2m \choose m} where n=2mn=2m, for j=0j=0; on the other hand, there are Ln[𝔭]=m+1L_{n}^{[\mathfrak{p}]} = m+1 words, where n=2m+[ ⁣[n is odd] ⁣]n=2m + [\![\text{n is odd}]\!], for j=1j=1.

Proof. When j=0j=0 the pattern to avoid is 𝔭=ε\mathfrak{p}=\varepsilon, namely the empty word, therefore instantiating the generating function we have

L[𝔭](t)=12(1−2t)+121−4t2 L^{[\mathfrak{p}]}(t) =\frac{1}{2(1-2t)} +\frac{1}{2\sqrt{1-4t^{2}}}

we extract the coefficient Ln[𝔭]=2n−1+an2L_{n}^{[\mathfrak{p}]} = 2^{n-1} + \frac{a_{n}}{2}, where a2m+1=0a_{2m+1}=0 and a2m=(2mm)a_{2m}={2m \choose m}, as required. We observe that these values correspond to the summation ∑i=0m(ni)\sum_{i=0}^m {n \choose i} for n=2m,2m+1,⋯ ,n=2m,2m+1,\cdots, where the binomial coefficient computes the number of ways to choose ii 00-bits among nn bits, and this gives the combinatorial interpretation.

When j=1j=1 the pattern to avoid is 𝔭=01\mathfrak{p}=01 (or, equivalently, 𝔭=10\mathfrak{p}=10), therefore after instantiation

L[𝔭](t)=14(1−t)+12(1−t)2+14(1+t) L^{[\mathfrak{p}]}(t) =\frac{1}{4(1-t)} + \frac{1}{2(1-t)^{2}} +\frac{1}{4(1+t)}

we extract the nn-th coefficient Ln[𝔭]=14+(−1)n4+n+12L_{n}^{[\mathfrak{p}]} = \frac{1}{4} + \frac{(-1)^{n}}{4} +\frac{n+1}{2}, so either n=2mn=2m or n=2m+1n=2m+1 entails Ln[𝔭]=m+1L_{n}^{[\mathfrak{p}]} = m+1, as required.

A combinatorial interpretation can be given as follows. If n=2mn=2m then suitable words have structure 1m1j0m−j1^{m}1^{j}0^{m-j} for j∈{0,…,m}j\in \lbrace 0, \ldots,m \rbrace, and there are m+1m+1 of them. On the contrary, if n=2m+1n=2m+1 holds then suitable words have structure 1m+11j0m−j1^{m+1}1^{j}0^{m-j} for j∈{0,…,m}j\in \lbrace 0, \ldots,m \rbrace, they are m+1m+1 in number again, as required. □

As before, last two patterns 𝔭=(01)j0\mathfrak{p}=(01)^{j}0 and 𝔭=(10)j1\mathfrak{p}=(10)^{j}1 are harder to study and we avoid to report formulas about L[𝔭](t)L^{[\mathfrak{p}]}(t) functions because we have not a meaningful combinatorial interpretation: we only point out that these functions can be expressed in terms of M(t2)M(t^{2}), where M(t)M(t) is the generating function of Motzkin numbers, similarly to the corresponding S[𝔭](t)S^{[\mathfrak{p}]}(t) functions.

Conclusions

As a final remark, we observe a structural properties of matrices ℛ[𝔭]\mathcal{R}^{[\mathfrak{p}]} against the studied families of patterns. Recall that the Pascal triangle and its inverse correspond to the Riordan arrays

P=(11−t,t1−t)andP−1=(11+t,t1+t), P =\left(\frac{1}{1-t},\frac{t}{1-t}\right) \quad\text{and}\quad P^{-1}=\left(\frac{1}{1+t},\frac{t}{1+t}\right),

respectively; therefore, for any Riordan array ℛ[𝔭]\mathcal{R}^{[\mathfrak{p}]} we can compute B[𝔭]=P−1∗ℛ[𝔭],B^{[\mathfrak{p}]}= P^{-1} \ast \mathcal{R}^{[\mathfrak{p}]}, which is equivalent to say that ℛ[𝔭]\mathcal{R}^{[\mathfrak{p}]} is the binomial transform of B[𝔭],B^{[\mathfrak{p}]}, or ℛ[𝔭]=P∗B[𝔭]\mathcal{R}^{[\mathfrak{p}]}=P \ast B^{[\mathfrak{p}]}.

For the sake of clarity, consider the pattern family 𝔭=1j+10j\mathfrak{p}=1^{j+1}0^{j}, so for j=1j=1 we have the minor

ℛ[110]=[121421842116842132168421643216842112864321684212561286432168421512256128643216842110245122561286432168421] \mathcal{R}^{[110]} = \left[\begin{array}{ccccccccccc}1 & & & & & & & & & & \\2 & 1 & & & & & & & & & \\4 & 2 & 1 & & & & & & & & \\8 & 4 & 2 & 1 & & & & & & & \\16 & 8 & 4 & 2 & 1 & & & & & & \\32 & 16 & 8 & 4 & 2 & 1 & & & & & \\64 & 32 & 16 & 8 & 4 & 2 & 1 & & & & \\128 & 64 & 32 & 16 & 8 & 4 & 2 & 1 & & & \\256 & 128 & 64 & 32 & 16 & 8 & 4 & 2 & 1 & & \\512 & 256 & 128 & 64 & 32 & 16 & 8 & 4 & 2 & 1 & \\1024 & 512 & 256 & 128 & 64 & 32 & 16 & 8 & 4 & 2 & 1\end{array}\right]

which corresponds to

B[110]=[11110111−11102−2111−24−31103−67−4111−39−1311−51104−1222−2416−6111−416−3446−4022−71105−2050−8086−6229−81] B^{[110]} = \left[\begin{array}{ccccccccccc} 1 & & & & & & & & & & \\ 1 & 1 & & & & & & & & & \\ 1 & 0 & 1 & & & & & & & & \\ 1 & 1 & -1 & 1 & & & & & & & \\ 1 & 0 & 2 & -2 & 1 & & & & & & \\ 1 & 1 & -2 & 4 & -3 & 1 & & & & & \\ 1 & 0 & 3 & -6 & 7 & -4 & 1 & & & & \\ 1 & 1 & -3 & 9 & -13 & 11 & -5 & 1 & & & \\ 1 & 0 & 4 & -12 & 22 & -24 & 16 & -6 & 1 & & \\ 1 & 1 & -4 & 16 & -34 & 46 & -40 & 22 & -7 & 1 & \\ 1 & 0 & 5 & -20 & 50 & -80 & 86 & -62 & 29 & -8 & 1\end{array}\right]

defined by functions d[110](t)=11−td^{[110]}(t)=\frac{1}{1-t} and h[110](t)=t1+th^{[110]}(t)=\frac{t}{1+t}.

On the other hand, the Riordan array ℛ[11100]\mathcal{R}^{[11100]}, that is j=2j=2 in the family, is the binomial transform of

B[11100]=[11131153111573113116931187431711311201101551813311543271119671915311133166634114179201731135331766826411167912119311] B^{[11100]} =\left[\begin{array}{ccccccccccc}1 & & & & & & & & & & \\1 & 1 & & & & & & & & & \\3 & 1 & 1 & & & & & & & & \\5 & 3 & 1 & 1 & & & & & & & \\15 & 7 & 3 & 1 & 1 & & & & & & \\31 & 16 & 9 & 3 & 1 & 1 & & & & & \\87 & 43 & 17 & 11 & 3 & 1 & 1 & & & & \\201 & 101 & 55 & 18 & 13 & 3 & 1 & 1 & & & \\543 & 271 & 119 & 67 & 19 & 15 & 3 & 1 & 1 & & \\1331 & 666 & 341 & 141 & 79 & 20 & 17 & 3 & 1 & 1 & \\3533 & 1766 & 826 & 411 & 167 & 91 & 21 & 19 & 3 & 1 & 1\end{array}\right]

defined by functions

d[11100](t)=1+t1−t−5t2+t3and d^{[11100]}(t)=\sqrt{\frac{1+t}{1-t-5t^{2}+t^{3}}} \quad \text{and} h[11100](t)=1+2t+t2−(1−t−5t2+t3)(1+t)2(1+t)2; h^{[11100]}(t)=\frac{1+2t+t^{2}-\sqrt{(1-t-5t^{2}+t^{3})(1+t)}}{2(1+t)^{2}};

in particular, the latter expands to

h[11100](t)=t+2t4−t5+7t6+24t8+17t9+98t10+𝒪(t11). h^{[11100]}(t)=t + 2 t^{4} - t^{5} + 7 t^{6} + 24 t^{8} + 17 t^{9} + 98 t^{10} + \mathcal{O}\left(t^{11}\right).

Riordan arrays B[𝔭]B^{[\mathfrak{p}]} can be completely defined by using the results of Theorem 3.5 and the product rule of the Riordan group. Doing so, for each pattern family studied in this work with j>1j>1, the Riordan array ℛ[𝔭]\mathcal{R}^{[\mathfrak{p}]} appears to be the binomial transform of another Riordan array B[𝔭]B^{[\mathfrak{p}]} with non-negative integer coefficients, although it is not easy to spot this property looking at the corresponding hh functions because their series expansions might contain negative coefficients, as shown for matrices B[110]B^{[110]} and B[11100]B^{[11100]}. This fact could be further investigated from an algebraic and combinatorial point of view and possibly yield interesting combinatorial interpretations also in the case j>1.j>1.