1 Introduction

A word \(w=w_1w_2\cdots w_n\) over the set of positive integers is called a Catalan word if \(w_1=\texttt {0}\) and \(0\le w_i\le w_{i-1}+1\) for \(i=2, \dots , n\). Let \({\mathcal {C}}_n\) denote the set of Catalan words of length n. For example,

$$\begin{aligned} {\mathcal {C}}_4&=\{ \texttt {0000,0001,0010,0011,} \texttt {0012,0100,0101}, \\&\quad \texttt {0110,0111,0112,0120},\texttt {0121,0122,0123}\}. \end{aligned}$$

The cardinality of the set \({\mathcal {C}}_n\) is given by the Catalan number \(c_n=\frac{1}{n+1}\left( {\begin{array}{c}2n\\ n\end{array}}\right) \), see [19, Exercise 80]. Catalan words have been studied in the context of exhaustive generation of Gray codes for growth-restricted words [12]. Recently, Baril et al. [2, 3] study the distribution of descents on the sets of Catalan words avoiding a pattern of length at most three and a pair of patterns of length 3. Additionally, in [8, 13], the authors started the study of combinatorial statistics on the polyominoes associated with the set of Catalan words of a prescribed length.

A pattern p is a word \(p=p_1p_2\cdots p_k\) with \(p_i\in \{ 0, 1, \dots , k-1\}\) for all i, such that if \(j>0\) appears in p, then \(j-1\) also appears in p. A Catalan word \(w=w_1w_2\cdots w_n\) contains the pattern \(p=p_1p_2\cdots p_k\) if there exists a subsequence \(w_{i_1}w_{i_2}\cdots w_{i_k}\) of w (\(i_1<i_2<\cdots <i_k\)) which is order-isomorphic to p. Otherwise, we say that w avoids p. For example, the Catalan word \(\texttt {0123455543}\) avoids the pattern 001 and contains the pattern 210 three times. A Catalan word \(w=w_1w_2\cdots w_n\) contains the consecutive pattern \(p=\underline{p_1p_2\cdots p_k}\) if there exists a consecutive subsequence (subword) \(w_{i}w_{i+1}\cdots w_{i+k-1}\), where \(1 \le i \le n-k+1\) which is order-isomorphic to p. The study of consecutive patterns in permutations was introduced by Elizalde and Noy [9]. Simultaneously, Burstein and Mansour [5, 6] studied this notion for words. After that several results have been appearing in the literature, like those in [1, 14, 15] and references therein.

Let \({\mathcal {C}}_n(p)\) denote the Catalan words of length n avoids the consecutive pattern p, \({{\varvec{c}}}_{p}(n)\) is the cardinality of \({\mathcal {C}}_n(p)\), and \({\mathcal {C}}(p)=\bigcup _{n\ge 0}{\mathcal {C}}_n(p)\). The consecutive patterns \(p_1\) and \(p_2\) are Wilf equivalent, denoted by \(p_1\sim p_2\), if \({{\varvec{c}}}_{p_1}(n)={{\varvec{c}}}_{p_2}(n)\) for all \(n\ge 0\). By a descent within a word \(w = w_1w_2 \cdots w_n\) over the set of non-negative integers, we mean an index \(1\le \ell \le n-1\) such that \(w_\ell >w_{\ell +1}\). Let \({\textsf {des}}(w)\) denote the number of descents of the word w. We introduce the bivariate generating function

$$\begin{aligned} {{\varvec{C}}}_{p}(x,y)=\sum _{n\ge 0}x^n\sum _{w\in {\mathcal {C}}_n(p)}y^{{\textsf {des}}(w)}. \end{aligned}$$

It is clear that \({{\varvec{C}}}_{p}(x):={{\varvec{C}}}_{p}(x,1)=\sum _{n\ge 0}{{\varvec{c}}}_{p}(n)x^n\). Let \({{\varvec{d}}}_{p}(n)\) denote the total number of descents over all words in \({\mathcal {C}}_n(p)\). The generating function for the sequence \({{\varvec{d}}}_{p}(n)\) is given by

$$\begin{aligned} {{\varvec{D}}}_p(x):=\left. \frac{\partial {{\varvec{C}}}_{p}(x,y) }{\partial y}\right| _{y=1}. \end{aligned}$$

The problem of computing the distribution of the descent statistic in permutations and words has been considered by several authors, see for example [1, 2, 4, 11].

In this paper we compute the bivariate generating function \({{\varvec{C}}}_{p}(x,y)\) for each consecutive pattern of length three. The generating functions that we present throughout the paper, are given using the symbolic method (cf. [10]). These results are the natural continuation of the previous results by Baril, Kirgizov, and Vajnovszki [2, 3]. Notice that the generating functions obtained by Baril et al. [2] are all rational. However, the consecutive patterns that we count in this paper, give that the generating functions are all algebraic (non-rational).

2 Consecutive patterns of length 3

The goal of the current section is to enumerate Catalan words avoiding each given consecutive pattern of length 3. From definition, any Catalan word avoids the consecutive patterns \(\underline{021}\) and \(\underline{102}\). The first few values of the sequence \({{\varvec{c}}}_{\underline{p}}(n)\) for the remaining 11 consecutive patterns of length 3 are provided in Table 1.

Table 1 Catalan words avoiding a consecutive pattern of length three

From the definition of a Catalan word w, we have that w is either the empty word \(\epsilon \), or w can be written as \(\texttt {0}(w' + 1)w''\), where \(w'\) and \(w''\) are Catalan words, and \(w' + 1\) is obtained from the word \(w'\) by adding one to each of its entries. This recursive decomposition is called the first return decomposition of a Catalan word (cf. [2]).

2.1 The consecutive pattern \(\underline{012}\)

Theorem 2.1

We have

$$\begin{aligned} {{\varvec{C}}}_{\underline{012}}(x,y)=\frac{1-x-x^2+x^2y-\sqrt{(1-x-x^2+x^2y)^2-4x^2y}}{2x^2y}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(\underline{012})\). From the first return decomposition \(w=\texttt {0}w'\) or \(w=\texttt {01}(w'+1)w''\), where \(w', w''\in {\mathcal {C}}(\underline{012})\). Notice that the second factorization guarantees that \(\texttt {012}\) is not a prefix of w. If \(w'' = \epsilon \), then the number of descents in w is the same as that of \(w'\); otherwise, we have \({\textsf {des}}(w) = {\textsf {des}}(w')+{\textsf {des}}(w'')+1\).

Therefore, we have the functional equation

$$\begin{aligned} {{\varvec{C}}}_{\underline{012}}(x,y)= & {} 1 + x{{\varvec{C}}}_{\underline{012}}(x,y) + x^2{{\varvec{C}}}_{\underline{012}}(x,y) \\{} & {} \quad + x^2 y{{\varvec{C}}}_{\underline{012}}(x,y)({{\varvec{C}}}_{\underline{012}}(x,y)-1). \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \({{\varvec{C}}}_{\underline{012}}(x,y)\) is

$$\begin{aligned}{} & {} 1 + x + 2 x^2 + (3 + y) x^3 + {\varvec{(5 + 4 y)}} x^4 + (8 + 12 y + y^2) x^5 \\{} & {} \quad + (13 + 31 y + 7 y^2) x^6 +O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficient in the above series are

The descents are colored in red. The generating function of the total number of elements in \({\mathcal {C}}(\underline{012})\) is

$$\begin{aligned} {{\varvec{C}}}_{\underline{012}}(x)=\frac{1 - x - \sqrt{1 - 2 x - 3 x^2}}{2 x^2}. \end{aligned}$$

This generating function coincides with the generating function of the Motzkin numbers

$$\begin{aligned} m_n=\sum _{k=0}^{\lfloor n/2\rfloor } \left( {\begin{array}{c}n\\ 2k\end{array}}\right) c_k={{\varvec{c}}}_{\underline{012}}(n). \end{aligned}$$

Additionally, the generating function of the total number of descents on the set \({\mathcal {C}}(\underline{012})\) is given by

$$\begin{aligned} {{\varvec{D}}}_{\underline{012}}(x)=\frac{1 - 2x - 2x^2 + x^3 - (1-x-x^2)\sqrt{1-2x-3 x^2}}{2 x^2 \sqrt{1-2x-3 x^2}}. \end{aligned}$$

The sequence corresponds to A005775, that is,

$$\begin{aligned} {{\varvec{d}}}_{\underline{012}}(n)=\sum _{k=0}^{n-1}\left( {\begin{array}{c}n-1\\ k\end{array}}\right) \left( {\begin{array}{c}k\\ \lfloor k/2\rfloor \end{array}}\right) . \end{aligned}$$

A Dyck path of semilength n is a lattice path of \(\mathbb {Z \times Z}\) running from (0, 0) to (2n, 0) that never passes below the x-axis and whose permitted steps are \(U=(1, 1)\) and \(D=(1,-1)\). The Dyck paths of semilength n are in bijection with the Catalan words of length n: record the heights above ground level of the initial points of the up steps U taken left to right. For example, in Fig. ef 1 we show the Dyck path associated to the Catalan word \(\texttt {0110012343201}\in {\mathcal {C}}_{14}\).

Fig. 1
figure 1

Dyck path of the Catalan word 0110012343201

Using this bijection, it is clear that the sequence \({{\varvec{c}}}_{\underline{012}}(n)\) also counts the number of all Dyck paths of semilength n that avoid UUU (see [17]). For a bijective proof of the above result, see [7].

2.2 The consecutive pattern \(\underline{010}\)

Theorem 2.2

We have

$$\begin{aligned} {{\varvec{C}}}_{\underline{010}}(x,y)=\frac{(1 - x + 2 x y)(1 - x)-\sqrt{(1 - x)^4 - (1 - x) 4 x^2 y}}{2 x y (1 - x)}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(\underline{010})\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(\underline{010})\). If \(w''=\epsilon \) and \(w'\) is non empty, then the generating function for this case is \(x({{\varvec{C}}}_{\underline{010}}(x,y)-1)\). If \(w'\) is empty, then the generating function is \(x{{\varvec{C}}}_{\underline{010}}(x,y)\). Finally, if \(w'\) and \(w''\) are non-empty, then \(w'\ne \texttt {0}\), and the number of descents is given by \({\textsf {des}}(w) = {\textsf {des}}(w')+{\textsf {des}}(w'')+1\). Hence the generating function of this last case is \(xy({{\varvec{C}}}_{\underline{010}}(x,y)-(1+x))({{\varvec{C}}}_{\underline{010}}(x,y)-1)\). Therefore, we have the functional equation

$$\begin{aligned} {{\varvec{C}}}_{\underline{001}}(x,y)= & {} 1 + x({{\varvec{C}}}_{\underline{001}}(x,y)-1) + x{{\varvec{C}}}_{\underline{001}}(x,y) \nonumber \\{} & {} + xy({{\varvec{C}}}_{\underline{010}}(x,y)-(1+x))({{\varvec{C}}}_{\underline{010}}(x,y)-1). \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \({{\varvec{C}}}_{\underline{010}}(x,y)\) is

$$\begin{aligned}{} & {} 1 + x + 2 x^2 + 4 x^3 + {\varvec{(8 + 2 y)}} x^4 + (16 + 12 y) x^5 \\{} & {} \quad + (32 + 48 y + 2 y^2) x^6 +O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficient in the above series are

The generating function of the total number of elements in \({\mathcal {C}}(\underline{010})\) is

$$\begin{aligned} {{\varvec{C}}}_{\underline{010}}(x)=\frac{1 + x^2 - \sqrt{(1 + x^2)(1 - 4 x + x^2)}}{2 x}. \end{aligned}$$

This generating function coincides with the generating function of the number of peakless Motzkin paths of length n such that the up steps come in two colors (A187256), that is

$$\begin{aligned} {{\varvec{c}}}_{\underline{010}}(n)=\sum _{k=0}^{\lfloor (n-1)/2\rfloor } \frac{(-1)^k}{n - 2 k} \left( {\begin{array}{c}n - k - 1\\ k\end{array}}\right) \left( {\begin{array}{c}2n - 4k\\ n -2k- 1\end{array}}\right) , \ n\ge 1. \end{aligned}$$

The generating function of the total number of descents on the set \({\mathcal {C}}(\underline{010})\) is

$$\begin{aligned} {{\varvec{D}}}_{\underline{010}}(x) =\frac{1 - 4 x + 3 x^2 - 2 x^3 - (1-2x)\sqrt{1 - 4 x + 2 x^2 - 4 x^3 + x^4}}{2 x \sqrt{1 - 4 x + 2 x^2 - 4 x^3 + x^4}}. \end{aligned}$$

2.3 The consecutive patterns \(\underline{001}\) and \(\underline{011}\)

In this section we prove that consecutive patterns \(\underline{001}\) and \(\underline{011}\) are Wilf equivalent, that is, \(\underline{001}\sim \underline{011}\).

Theorem 2.3

We have

$$\begin{aligned} {{\varvec{C}}}_{\underline{001}}(x,y)=\frac{(1 - x + 2 x y)(1 - x)-\sqrt{(1 - x)^4 - (1 - x) 4 x^2 y}}{2 x y (1 - x)}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(\underline{001})\). From the first return decomposition \(w=\texttt {0}^k\) (\(k\ge 1\)) or \(w=\texttt {0}(w'+1)w''\), where \(w', w''\in {\mathcal {C}}(\underline{001})\) and \(w'\) is non-empty. If \(w'' = \epsilon \), then the number of descents in w is the same as that of \(w'\); otherwise, we have \({\textsf {des}}(w) = {\textsf {des}}(w')+{\textsf {des}}(w'')+1\). From this decomposition we have the functional equation

$$\begin{aligned} {{\varvec{C}}}_{\underline{001}}(x,y) = 1 + \frac{x}{1-x} + x({{\varvec{C}}}_{\underline{001}}(x,y)-1) + x y({{\varvec{C}}}_{\underline{001}}(x,y)-1)({{\varvec{C}}}_{\underline{001}}(x,y)-1). \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \({{\varvec{C}}}_{\underline{001}}(x,y)\) is

$$\begin{aligned}{} & {} 1 + x + 2 x^2 + (3 + y) x^3 + {\varvec{(4 + 5 y)}} x^4 + (5 + 15 y + 2 y^2) x^5 \\{} & {} \quad + (6 + 35 y + 16 y^2) x^6 +O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficient in the above series are

Theorem 2.4

There is a bijection between the sets \({\mathcal {C}}(\underline{001})\) and \({\mathcal {C}}(\underline{011})\).

Proof

Let w be any Catalan word in \({\mathcal {C}}_n(\underline{011})\). We define a word f(w) on \({\mathcal {C}}_n(\underline{001})\) recursively, as follows. By reading the symbols of w from left to right, any subword \(\texttt {0}^j\texttt {1}\) (\(j\ge 2\)) of w is replaced by the word \(\texttt {0}{} \texttt {1}^j\). From the word obtained in the last step, we repeat the search and replace the subword \(\texttt {1}^j\texttt {2}\) by the word \(\texttt {1}{} \texttt {2}^j\), and so on. This algorithm defines a bijection and preserves the number of descents. For example, for \(w=\texttt {0001232223}\in {\mathcal {C}}_{10}(\underline{011})\), we have \(f(w)=\texttt {0123332333}\in {\mathcal {C}}_{10}(\underline{001})\). Indeed, we have the following transformation:

\(\square \)

The generating function of the total number of elements in \({\mathcal {C}}(p)\) for \(p\in \{\underline{001}, \underline{011}\}\) is

$$\begin{aligned} {{\varvec{C}}}_{\underline{p}}(x)=\frac{1 - x^2 - \sqrt{(1 - x)(1 - 3 x - x^2 - x^3)}}{2 (1 - x) x}. \end{aligned}$$

Using the bijection between Catalan words and Dyck path, the sequence \({{\varvec{c}}}_{\underline{011}}(n)\) counts the Dyck paths of semilength n avoiding UUDU and \({{\varvec{c}}}_{\underline{001}}(n)\) counts the Dyck paths of semilength n avoiding UDUU (sequence A105633). Therefore, we have the combinatorial expression (cf. [17])

$$\begin{aligned} {{\varvec{c}}}_{\underline{001}}(n)={{\varvec{c}}}_{\underline{011}}(n)=\sum _{k=0}^{\lfloor (n-1)/2\rfloor } \frac{(-1)^k}{n - k}\left( {\begin{array}{c}n - k\\ k\end{array}}\right) \left( {\begin{array}{c}2 n - 3 k\\ n - 2 k-1\end{array}}\right) , \quad n\ge 1. \end{aligned}$$

Additionally, the generating function of the total number of descents on the set \({\mathcal {C}}(p)\) for \(p\in \{\underline{001}, \underline{011}\}\) is

$$\begin{aligned} {{\varvec{D}}}_{p}(x)=\frac{1 - 3x + x^2 - x^3 - (1-x)\sqrt{1 - 4 x + 2 x^2 + x^4}}{2 x \sqrt{1 - 4 x + 2 x^2 + x^4}}. \end{aligned}$$

2.4 The consecutive pattern \(\underline{201}\)

Theorem 2.5

We have

$$\begin{aligned}{} & {} {{\varvec{C}}}_{\underline{201}}(x,y)\\{} & {} \quad =\frac{(1 - x + xy) (1 - 2 x) + 2 x^2 y^2 - (1 - x (1 - y)) \sqrt{(1 - 2 x)^2 - 4 x^2 y (1 - x)}}{2 x^2y(1 - x + y)}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(\underline{201})\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(\underline{201})\). If \(w''=\epsilon \) and \(w'\) is non empty, then the associated generating function is \(x({{\varvec{C}}}_{\underline{201}}(x,y)-1)\). If \(w'\) is empty, then the generating function is \(x{{\varvec{C}}}_{\underline{201}}(x,y)\). Finally, if \(w'\) and \(w''\) are non-empty, then \(w'\) can not finish with the symbol j for \(j\ge 1\) and \(w''\) can not start with \(\texttt {01}\). Note that in this case \({\textsf {des}}(w) = {\textsf {des}}(w')+{\textsf {des}}(w'')+1\). By counting the complement, the generating function for this case is given by

$$\begin{aligned} xy({{\varvec{C}}}_{\underline{201}}(x,y)-1)^2 - xy{{\varvec{C}}}_{\underline{201},\ge 1}(x,y)\underbrace{({{\varvec{C}}}_{\underline{201}}(x,y)-1-x{{\varvec{C}}}_{\underline{201}}(x,y))}_{(a)}, \end{aligned}$$

where \({{\varvec{C}}}_{\underline{201},\ge 1}(x,y)\) is the bivariate generating function of the Catalan words in \({\mathcal {C}}(\underline{201})\), whose last symbol is greater than or equal to 1. Notice that the factor (a) corresponds to the generating function of the Catalan words in \({\mathcal {C}}(\underline{201})\) that starts with \(\texttt {01}\).

Therefore, we have the functional equation

$$\begin{aligned} {{\varvec{C}}}_{\underline{201}}(x,y)= & {} 1 + x({{\varvec{C}}}_{\underline{201}}(x,y)-1) + x{{\varvec{C}}}_{\underline{201}}(x,y) + xy({{\varvec{C}}}_{\underline{201}}(x,y)-1)^2 \\ {}{} & {} \quad -xy{{\varvec{C}}}_{\underline{201},\ge 1}(x,y)({{\varvec{C}}}_{\underline{201}}(x,y)-1-x{{\varvec{C}}}_{\underline{201}}(x,y)). \end{aligned}$$

If we denote by \({{\varvec{C}}}_{\underline{201},0}(x,y)\) the bivariate generating function of the Catalan words in \({\mathcal {C}}(\underline{201})\), whose last symbol is equal to 0, then

$$\begin{aligned} {{\varvec{C}}}_{\underline{201},\ge 1}(x,y)= {{\varvec{C}}}_{\underline{201}}(x,y) - {{\varvec{C}}}_{\underline{201},0}(x,y) -1. \end{aligned}$$

The Catalan words w enumerated by \({{\varvec{C}}}_{\underline{201},0}(x,y)\) can be decomposed as \(\texttt {0}, \texttt {0}w_1\), or \(\texttt {0}w_2\), where \(w_1, w_2 \in {\mathcal {C}}(\underline{201})\), and \(w_1\) ends with \(\texttt {0}\) and \(w_2\) ends with a symbol greater than or equal to 1. Notice that \({\textsf {des}}(w)={\textsf {des}}(w_1)\) and \({\textsf {des}}(w)={\textsf {des}}(w_2)+1\), respectively. Therefore we have the functional equation

$$\begin{aligned} {{\varvec{C}}}_{\underline{201},0}(x,y)= x + x {{\varvec{C}}}_{\underline{201},0}(x,y)+ xy({{\varvec{C}}}_{\underline{201}}(x,y) - 1- {{\varvec{C}}}_{\underline{201},0}(x,y)). \end{aligned}$$

Solving the system of equations we obtain the desired result. \(\square \)

The series expansion of the generating function \({{\varvec{C}}}_{\underline{201}}(x,y)\) is

$$\begin{aligned}{} & {} 1 + x + 2 x^2 + (4 + y) x^3 + {\varvec{(8 + 6 y)}} x^4 + (16 + 23 y + 2 y^2) x^5 \\{} & {} \quad + (32 + 73 y + 19 y^2) x^6 +O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficient in the above series are

The generating function of the total number of elements in \({\mathcal {C}}(\underline{201})\) is

$$\begin{aligned} {{\varvec{C}}}_{\underline{201}}(x)=\frac{1 - 2 x + 2 x^2- \sqrt{1 - 4 x + 4 x^3}}{2 (2 - x) x^2}. \end{aligned}$$

The sequence \({{\varvec{c}}}_{\underline{201}}(n)\) coincides with the sequence A159769, and it is related to the enumeration of trees avoiding a consecutive pattern [16]. Finally, the generating function of the total number of descents on the set \({\mathcal {C}}(\underline{201})\) is

$$\begin{aligned} {{\varvec{D}}}_{\underline{201}}(x)=\frac{3 - 15 x + 17 x^2 + 2 x^3 - 10 x^4 + 4 x^5-(3 - 9 x + 5 x^2)\sqrt{1 - 4 x + 4 x^3}}{2 (2 - x)^2 x^2\sqrt{1 - 4 x + 4 x^3)}}. \end{aligned}$$

2.5 The consecutive patterns \(\underline{120}, \underline{100}\), and \(\underline{110}\)

Theorem 2.6

For \(p\in \{\underline{120}, \underline{100}, \underline{110}\}\) we have

$$\begin{aligned}{} & {} {{\varvec{C}}}_{p}(x,y)\\{} & {} \quad =\frac{1 - 2 x + 2 x y - 2 x^2 y-\sqrt{(1 - 2 x)^2 - 4 x^2 y (1 - x)}}{2 xy (1 - x)}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(\underline{120})\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(\underline{120})\). If \(w''=\epsilon \) and \(w'\) is non empty, then the generating function for this case is \(x({{\varvec{C}}}_{\underline{120}}(x,y)-1)\). If \(w'\) is empty, then the generating function is \(x{{\varvec{C}}}_{\underline{120}}(x,y)\). Finally, if \(w'\) and \(w''\) are non-empty, then \(w'\) can not finish with an ascent \(a(a+1)\). Moreover, \({\textsf {des}}(w) = {\textsf {des}}(w')+{\textsf {des}}(w'')+1\). By counting the complement, the generating function for this case is given by \(xy({{\varvec{C}}}_{\underline{120}}(x,y)-1)^2-x^2y({{\varvec{C}}}_{\underline{120}}(x,y)-1)^2\).

Therefore, we have the functional equation

$$\begin{aligned} {{\varvec{C}}}_{\underline{120}}(x,y) = 1 + x({{\varvec{C}}}_{\underline{120}}(x,y)-1) + x{{\varvec{C}}}_{\underline{120}}(x,y) + xy(1-x)({{\varvec{C}}}_{\underline{120}}(x,y)-1)^2. \end{aligned}$$

Solving this equation we obtain the desired result. For the cases \(\underline{100}\) and \(\underline{110}\) we can follow a similar argument. \(\square \)

The series expansion of the generating function \({{\varvec{C}}}_{p}(x,y)\), for \(p\in \{\underline{120}, \underline{100}, \underline{110}\}\), is

$$\begin{aligned}{} & {} 1 + x + 2 x^2 + (4 + y) x^3 + {\varvec{(8 + 5 y)}} x^4 + (16 + 18 y + 2 y^2) x^5 \\{} & {} \quad + (32 + 56 y + 16 y^2) x^6 +O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficient in the above series are

Moreover, the generating function of the total number of Catalan words in \({\mathcal {C}}_n(p)\) is

$$\begin{aligned} {{\varvec{C}}}_{p}(x)=\frac{1 - 2 x^2-\sqrt{1 - 4 x + 4 x^3}}{2 x (1 - x)}. \end{aligned}$$

This generating function corresponds with the sequence A087626. This is a new combinatorial interpretation for this sequence. Additionally, the generating function of the total number of descents on the set \({\mathcal {C}}(p)\) is

$$\begin{aligned} {{\varvec{D}}}_{p}(x)=\frac{1 - 4 x + 2 x^2 + 2 x^3 - (1 - 2 x)\sqrt{1 - 4 x + 4 x^3}}{2 (1 - x) x\sqrt{1 - 4 x + 4 x^3}}. \end{aligned}$$

2.6 The consecutive pattern \(\underline{101}\)

Theorem 2.7

We have

$$\begin{aligned}{} & {} {{\varvec{C}}}_{\underline{101}}(x,y)\\{} & {} \quad =\frac{(1 - x)(1 - 2 x + 3 xy) - x^3 y (1 - y) - (1 - x + xy) \sqrt{(1 - 2 x)^2 - x^2 y (2 + 4 x - x^2 y)}}{2 x y (1 - x + x^2 y)}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(\underline{101})\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(\underline{101})\). If \(w''=\epsilon \) and \(w'\) is non empty, then the generating function for this case is \(x({{\varvec{C}}}_{\underline{101}}(x,y)-1)\). If \(w'\) is empty, then the generating function is \(x{{\varvec{C}}}_{\underline{101}}(x,y)\). Finally, if \(w'\) and \(w''\) are non-empty then \(w'\) can not finish with \(\texttt {0} \) and \(w''\) can not start with \(\texttt {01}\). Moreover, \({\textsf {des}}(w) = {\textsf {des}}(w')+{\textsf {des}}(w'')+1\). By counting the complement we have \(xy({{\varvec{C}}}_{\underline{101}}(x,y)-1)^2 - xy {{\varvec{C}}}_{\underline{101},0}(x,y)({{\varvec{C}}}_{\underline{101}}(x,y)-1-x{{\varvec{C}}}_{\underline{101}}(x,y))\), where \({{\varvec{C}}}_{\underline{101},0}(x,y)\) is the bivariate generating function of the Catalan words in \({\mathcal {C}}(\underline{101})\), whose last symbol is equal to 0. Therefore, we have the functional equation

$$\begin{aligned} {{\varvec{C}}}_{\underline{101}}(x,y)= & {} 1 + x({{\varvec{C}}}_{\underline{101}}(x,y)-1) + x{{\varvec{C}}}_{\underline{101}}(x,y) + xy({{\varvec{C}}}_{\underline{101}}(x,y)-1)^2\\ {}{} & {} \quad - xy {{\varvec{C}}}_{\underline{101},0}(x,y)({{\varvec{C}}}_{\underline{101}}(x,y)-1-x{{\varvec{C}}}_{\underline{101}}(x,y)). \end{aligned}$$

Moreover,

$$\begin{aligned} {{\varvec{C}}}_{\underline{101},0}(x,y)=x + x {{\varvec{C}}}_{\underline{101},0}(x,y) + x ( {{\varvec{C}}}_{\underline{101}}(x,y) - 1 - {{\varvec{C}}}_{\underline{101},0}(x,y)) y \end{aligned}$$

Solving this system of equations we obtain the desired result. \(\square \)

The series expansion of the generating function \({{\varvec{C}}}_{\underline{101}}(x,y)\) is

$$\begin{aligned}{} & {} 1 + x + 2 x^2 + (4 + y) x^3 + {\varvec{(8 + 5 y)}} x^4 + (16 + 19 y + y^2) x^5 \\{} & {} \quad + (32 + 63 y + 10 y^2) x^6 +O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficient in the above series are

The generating function of the total number of elements in \({\mathcal {C}}(\underline{101})\) is given by

$$\begin{aligned} {{\varvec{C}}}_{\underline{101}}(x)=\frac{1 - x^2 - \sqrt{(1 + x^2) (1 - 4 x + x^2)}}{2 x (1 - x + x^2)}. \end{aligned}$$

This generating function coincides with the sequence A114465. Moreover, the generating function of the total number of descents on the set \({\mathcal {C}}(\underline{101})\) is

$$\begin{aligned} {{\varvec{D}}}_{\underline{101}}(x)=\frac{a(x)-b(x)\sqrt{(1 + x^2) (1 - 4 x + x^2)}}{2 x (1 - x + x^2)^2\sqrt{(1 + x^2) (1 - 4 x + x^2)}}, \end{aligned}$$

where \(a(x)=1 - 6 x + 14 x^2 - 20 x^3 + 17 x^4 - 13 x^5 + 6 x^6 - x^7\) and \(b(x)=1 - 4 x + 7 x^2 - 6 x^3 + 2 x^4 - x^5\).

2.7 The consecutive pattern \(\underline{000}\)

Theorem 2.8

We have

$$\begin{aligned} {{\varvec{C}}}_{\underline{000}}(x,y)=\frac{1 - x - x^2 + 2 x y + 2 x^2 y - \sqrt{(1 - x - x^2)^2 - 4 x^2 (1 + x)^2 y}}{2xy(1+x)}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(\underline{000})\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(\underline{000})\). If \(w''=\epsilon \), then the generating function for this case is \(x{{\varvec{C}}}_{\underline{000}}(x,y)\). If \(w'\) is empty, then the generating function is \(x({{\varvec{C}}}_{\underline{000}}(x,y)-1-{{\varvec{C}}}_{\underline{000},00}(x,y))\), where \({{\varvec{C}}}_{\underline{000},00}(x,y))\) is the generating function for the words in \({\mathcal {C}}(\underline{000})\), whose last symbols are \(\texttt {00}\). Finally, if \(w'\) and \(w''\) are non-empty then \({\textsf {des}}(w) = {\textsf {des}}(w')+{\textsf {des}}(w'')+1\), and the generating function is \(xy({{\varvec{C}}}_{\underline{000}}(x,y)-1)^2\).

Therefore, we have the functional equation

$$\begin{aligned} {{\varvec{C}}}_{\underline{000}}(x,y)&= 1 + x{{\varvec{C}}}_{\underline{000}}(x,y) + x({{\varvec{C}}}_{\underline{000}}(x,y)-1-{{\varvec{C}}}_{\underline{000},00}(x,y)) \\&\quad + xy({{\varvec{C}}}_{\underline{000}}(x,y)-1)^2. \end{aligned}$$

Moreover,

$$\begin{aligned} {{\varvec{C}}}_{\underline{000},00}(x,y)=x^2 + x^2 ({{\varvec{C}}}_{\underline{000}}(x,y) - 1) + x^2y ({{\varvec{C}}}_{\underline{000}}(x,y) - 1)({{\varvec{C}}}_{\underline{000}}(x,y) - 1). \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \({{\varvec{C}}}_{\underline{000}}(x,y)\) is

$$\begin{aligned}{} & {} 1 + x + 2 x^2 + (3 + y) x^3 + {\textbf {(5 + 6 y)}} x^4 + (8 + 21 y + 2 y^2) x^5 \\{} & {} \quad + (13 + 59 y + 20 y^2) x^6 +O(x^7). \end{aligned}$$

The Catalan words corresponding to the bold coefficient in the above series are

The generating function of the total number of elements in \({\mathcal {C}}(\underline{000})\) is

$$\begin{aligned} {{\varvec{C}}}_{\underline{000}}(x)=\frac{1 + x + x^2 - \sqrt{1 - 2 x - 5 x^2 - 6 x^3 - 3 x^4}}{2 x (1 + x)}. \end{aligned}$$

Using the bijection between Catalan words and Dyck path, the sequence \({{\varvec{c}}}_{\underline{000}}(n)\) counts the Dyck paths of semilength n avoiding UDUDU (sequence A247333). Therefore, we have the combinatorial expression (cf. [17]), that is

$$\begin{aligned} {{\varvec{c}}}_{\underline{000}}(n)=\sum _{k=1}^{n}\left( {\begin{array}{c} k \\ n-k\end{array}}\right) m_{k-1}, \quad n\ge 1, \end{aligned}$$

where \(m_k\) is the k-th Motzkin number. The generating function of the total number of descents on the set \({\mathcal {C}}(\underline{000})\) is

$$\begin{aligned} {{\varvec{D}}}_{\underline{000}}(x)=\frac{1 - 2 x - 3 x^2 - 2 x^3 - x^4-(1 - x - x^2)\sqrt{1 - 2 x - 5 x^2 - 6 x^3 - 3 x^4}}{2 x (1 + x)\sqrt{1 - 2 x - 5 x^2 - 6 x^3 - 3 x^4}}. \end{aligned}$$

2.8 The consecutive pattern \(\underline{210}\)

Theorem 2.9

We have

$$\begin{aligned} {{\varvec{C}}}_{\underline{210}}(x,y)=\frac{1 - 2 x + 3 x^2 y - \sqrt{(1 - 2 x)^2 - x^2 y (2 + 4 x - x^2 y)}}{4 x^2 y}. \end{aligned}$$

Proof

Let w denote a non-empty Catalan word in \({\mathcal {C}}(\underline{210})\), and let \(w=\texttt {0}(w'+1)w''\) be the first return decomposition, where \(w', w''\in {\mathcal {C}}(\underline{210})\). If \(w''=\epsilon \) and \(w'\) is non empty, then the generating function for this case is \(x({{\varvec{C}}}_{\underline{210}}(x,y)-1)\). If \(w'\) is empty, then the generating function is \(x {{\varvec{C}}}_{\underline{210}}(x,y)\). Finally, if \(w'\) and \(w''\) are non-empty then \({\textsf {des}}(w) = {\textsf {des}}(w')+{\textsf {des}}(w'')+1\), and by counting the complement the generating function is

$$\begin{aligned}{} & {} xy ({{\varvec{C}}}_{\underline{210}}(x,y) - 1)^2 - xy(({{\varvec{C}}}_{\underline{210}}(x,y) - 1) - ( {{\varvec{C}}}_{\underline{210}}(x,y)- 1 ) x \nonumber \\{} & {} \quad - {{\varvec{C}}}_{\underline{210}}(x,y)x) ({{\varvec{C}}}_{\underline{210}}(x,y) - 1). \end{aligned}$$

Therefore, we have the functional equation

$$\begin{aligned}{} & {} {{\varvec{C}}}_{\underline{210}}(x,y) = 1 + x({{\varvec{C}}}_{\underline{210}}(x,y)-1) + x{{\varvec{C}}}_{\underline{210}}(x,y) + xy ({{\varvec{C}}}_{\underline{210}}(x,y) - 1)^2 \\{} & {} \quad - xy(({{\varvec{C}}}_{\underline{210}}(x,y) - 1) - ( {{\varvec{C}}}_{\underline{210}}(x,y)- 1 ) x - {{\varvec{C}}}_{\underline{210}}(x,y)x) ({{\varvec{C}}}_{\underline{210}}(x,y) - 1) \end{aligned}$$

Solving this equation we obtain the desired result. \(\square \)

The series expansion of the generating function \({{\varvec{C}}}_{\underline{210}}(x,y)\) is

$$\begin{aligned}{} & {} 1 + x + 2 x^2 + (4 + y) x^3 + {\textbf {(8 + 6 y)}} x^4 + (16 + 24 y + y^2) x^5 \\{} & {} \quad + (32 + 80 y + 12 y^2) x^6 +O(x^7). \end{aligned}$$

The generating function of the total number of elements in \({\mathcal {C}}(\underline{210})\) is

$$\begin{aligned} {{\varvec{C}}}_{\underline{210}}(x)=\frac{1 - 2 x + 2 x^2- \sqrt{1 - 4 x + 4 x^3}}{2 (2 - x) x^2}. \end{aligned}$$

This generating function coincides with the generating function of the sequence A159771, then

$$\begin{aligned} {{\varvec{c}}}_{\underline{210}}(n)=\sum _{k=0}^{\lfloor n/2\rfloor } \frac{1}{n - k}\left( {\begin{array}{c}n - k\\ k\end{array}}\right) \left( {\begin{array}{c}n - k\\ k+1\end{array}}\right) 2^{n-2k-1}, \quad n\ge 1. \end{aligned}$$

Finally, the generating function of the total number of descents on the set \({\mathcal {C}}(\underline{210})\) is given by

$$\begin{aligned} {{\varvec{D}}}_{\underline{210}}(x)=\frac{1 - 4 x + 3 x^2 - 2 x^3 - (1 - 2 x)\sqrt{(1 + x^2) (1 - 4 x + x^2)}}{4 x^2\sqrt{(1 + x^2) (1 - 4 x + x^2)}}. \end{aligned}$$