1 Introduction

Sequences defined recursively arise naturally in many areas, particularly in mathematics and computer science. One of the most studied classes is that of linear recursive sequences. Such sequences are defined by fixing the values of the first k elements, while every subsequent element can be obtained as a linear combination of the k elements preceding it. The most famous example is the Fibonacci sequence, defined by setting f0 = 0, f1 = 1, and the recurrence relation fn+ 2 = fn+ 1 + fn.

It is well known that every linear recursive sequence can be defined by a system of k jointly recursive sequences, where for every sequence we fix the initial value and provide a recurrence relation expressing the (n + 1)st element as a linear combination of the n th elements of all the sequences [15]. For example, to define the Fibonacci sequence fn in this way, one needs one auxiliary sequence: we set f0 = 0, g0 = 1, and postulate

$$ \left\{\begin{array}{l} f_{n+1} = g_{n}, \\ g_{n+1} = f_{n} + g_{n}. \end{array}\right. $$
(1.1)

In this paper we study polynomial recursive sequences over rational numbers that generalise linear recursive sequences. They are defined by systems of sequences like (1.1), but on the right hand side we allow arbitrary polynomial expressions, rather than just linear combinations. For example, the sequence bn = n! can be defined in this way using one auxiliary sequence: we may set b0 = c0 = 1 and write

$$ \left\{\begin{array}{l} b_{n+1} = b_{n} \cdot c_{n}, \\ c_{n+1} = c_{n} + 1. \end{array}\right. $$
(1.2)

Thus, the recurrence relation uses two polynomials: P1(x1,x2) = x1x2 and P2(x1,x2) = x2 + 1.

The two classes of linear and polynomial recursive sequences appear naturally in automata theory, and in particular in connection with weighted automata and higher-order pushdown automata. Weighted automata over the rational semiring are a quantitative variant of finite automata that assign rational numbers to words [10]. In the special case of a 1-letter alphabet, each word can be identified with its length. Then a weighted automaton defines a mapping from natural numbers (possible lengths) to rationals, and this can be seen as a sequence. It is known that sequences definable in this way by weighted automata are exactly the linear recursive sequences [6]. Pushdown automata of order k can be used for defining mappings from words to words [21]; in particular, for k = 2 and 1-letter alphabets, such automata compute exactly the linear recursive sequences of natural integers [11].

Thus, nonlinear extensions of linear recursive sequences may correspond to nonlinear extensions of weighted automata. For the latter, consider three examples:

  • polynomial recurrent relations that generalise pushdown automata of order 3 [12, 21];

  • cost-register automata which arose as a variant of streaming transducers [3, 4];

  • polynomial automata, connected to reachability problems for vector addition systems [7].

Surprisingly, these three models, although introduced in different contexts, are all equivalent.Footnote 1 Moreover, over unary alphabets they define exactly polynomial recursive sequences, in the same fashion as weighted automata (respectively order 2 pushdown automata) over unary alphabets define linear recursive sequences.

The goal of this paper is to study the expressive power of polynomial recursive sequences. Clearly, this expressive power extends that of linear recursive sequences: it is easy to see that every linear recursive sequence has growth bounded by \(2^{\mathcal {O}(n)}\), while already the sequence bn = n! grows faster. In fact, already the recurrence relation \(a_{0}=2,\ a_{n+1}=\left (a_{n}\right )^{2}\) defines the sequence \(2^{2^{n}}\), whose growth is doubly-exponential. However, there are well-known integer sequences related to these examples for which definability as a polynomial recursive sequence seems much less clear. The first example is the sequence un = nn. The second example is the sequence of Catalan numbers \(C_{n}=\frac {1}{n+1}\binom {2n}{n}\). Note that by Stirling’s approximation, nn is asymptotically very close to n!, while Cn is, up to factors polynomial in n, roughly equal to 4n. For these reasons, simple asymptotic considerations cannot prove the sequences un = nn and Cn to be not polynomial recursive. Recall that the Catalan numbers admit multiple combinatorial interpretations, which can be used to derive the recurrence formulas \(C_{n+1}={\sum }_{i=0}^{n} C_{i}C_{n-i}\) and (n + 2)Cn+ 1 = (4n + 2)Cn. Note that these formulas are not of the form of recurrence formulas considered in this work. Additionally, it is known that Catalan numbers Cn are not linear recursive (see e.g. [8]), despite having growth \(2^{\mathcal {O}(n)}\).

Our Results

We show that both the sequence of Catalan numbers Cn and the sequence un = nn are not polynomial recursive. For this, we present two techniques for proving that a sequence is not polynomial recursive. The first technique for Catalan numbers is number-theoretical: we show that a polynomial recursive sequence of integers is ultimately periodic modulo any large enough prime. The second technique for nn is more algebraic in nature: we show that for every polynomial recursive sequence there exists \(k\in \mathbb {N}\) such that every k consecutive elements of the sequence satisfy a nontrivial polynomial equation. The fact that un = nn is not polynomial recursive is our main result. These inexpressibility results were announced without proofs by the fifth coauthor in an invited talk in 2007 [21]. The present paper contains proofs and extensions of these results.

Applications

The discussed models of cost-register automata [4, 7, 12] are not the only nonlinear extensions of weighted automata that appear in the literature. We are aware of at least two more extensions: weighted context-free grammars [5, 8] and weighted MSO logic [9, 17]. As it happens, over the 1-letter alphabet, weighted context-free grammars can define Catalan numbers, and weighted MSO logic can define nn. Therefore, as a corollary of our results we show that functions expressible in pushdown-automata of level 4, weighted context-free grammars and weighted MSO logic are not always expressible in the class of cost-register automata.

The class of holonomic sequences is another extension of linear recursive sequences [16]. These sequences are defined recursively with one sequence, but the coefficients in the recursion are polynomials of the element’s index. For example, bn = 1 and bn+ 1 = (n + 1)bn defines bn = n!. The expressiveness of this class has also been studied and in particular the sequence nn is known to be not in the class of holonomic sequences [14]. As a corollary of our results one can show that there are no inclusions between the classes of holonomic sequences and polynomial recursive sequences. On the one hand every holonomic sequence is asymptotically bounded by 2p(n) for some polynomial p [16], and the sequence \(a_{n} = 2^{2^{n}}\) is polynomial recursive. On the other hand, Catalan numbers admit a definition as a holonomic sequence: C0 = 1 and (n + 2)Cn+ 1 = (4n + 2)Cn.

Organisation

In Section 2 we give basic definitions and examples of linear and polynomial recursive sequences. In Section 3 we show that the definition of polynomial recursive sequences requires a system of sequences and, unlike linear recursive sequences, cannot be equivalently defined using only one sequence. Then in Sections 4 and 5 we show that the sequence of Catalan numbers Cn and the sequence un = nn are not polynomial recursive. In Section 6 we explain in details our corollaries for weighted automata. In Section 7 we discuss the class of rational recurrence sequences that generalises both holonomic and polynomial recursive sequences. We conclude in Section 8.

2 Preliminaries

By \(\mathbb {N}\) we denote the set of nonnegative integers. A sequence over a set \(\mathbb {D}\) is a function \(u \colon \mathbb {N} \to \mathbb {D}\); all the sequences considered in this work are over the field of rationals \(\mathbb {Q}\). We use the notation \(\langle u_{n} \rangle _{n \in \mathbb {N}}\) for elements of sequences, where un = u(n). Also, we use bold-face letters as a short-hand for sequences, e.g., \(\mathbf {u} = \langle u_{n} \rangle _{n \in \mathbb {N}}\).

We now introduce the two main formalisms for describing sequences: linear recursive sequences and polynomial recursive sequences.

Linear Recursive Sequences

A k-variate linear form (or linear form if k is irrelevant) over \(\mathbb {Q}\) is a function \(L\colon \mathbb {Q}^{k}\to \mathbb {Q}\) of the form

$$ L(x_{1},\ldots,x_{k})=a_{1}x_{1}+\ldots+a_{k}x_{k} $$

for some \(a_{1},\ldots ,a_{k}\in \mathbb {Q}\). A sequence of rationals u is a linear recursive sequence if there exist \(k\in \mathbb {N}\) and a k-variate linear form L such that u satisfies the recurrence relation

$$ \begin{array}{@{}rcl@{}} u_{n+k} = L(u_{n},\ldots,u_{n+k-1})\qquad\text{for all }n\in \mathbb{N}. \end{array} $$
(2.1)

Observe that such a sequence is uniquely determined by the form L and its first k elements: \(u_{0},\ldots ,u_{k-1} \in \mathbb {Q}\). The minimal k for which a description of u as in (2.1) can be given is called the order of u. For example, Fibonacci numbers are uniquely defined by the recurrence relation fn+ 2 = fn+ 1 + fn and starting elements f0 = 0, f1 = 1. Note that this recurrence relation corresponds to the linear form L(x1,x2) = x1 + x2.

We now present a second definition of linear recursive sequences which, as we will explain, is equivalent to the first definition. Suppose u1,u2,…,uk are sequences of rationals. We say that these sequences satisfy a system of linear recurrence equations if there are k-variate linear forms L1,…,Lk such that:

$$ \begin{array}{@{}rcl@{}} \left\{\begin{array}{l} u^{1}_{n+1} = L_{1}({u^{1}_{n}},\ldots,{u^{k}_{n}}),\\ {\vdots} \\ u^{k}_{n+1} = L_{k}({u^{1}_{n}},\ldots,{u^{k}_{n}}). \end{array}\right. \end{array} $$
(2.2)

for all \(n\in \mathbb {N}\). Note that such a system can be equivalently rewritten in the matrix form

$$ \mathbf{u}_{n+1} = M \mathbf{u}_{n} $$

where \(\mathbf {u}_{n}=({u^{1}_{n}},\ldots ,{u^{k}_{n}})^{\mathsf {T}}\) and M is the k × k matrix over \(\mathbb {Q}\) such that Mx = (L1(x),…,Lk(x))T for all \(\mathbf {x}\in \mathbb {Q}^{k}\). Note that then \(\mathbf {u}_{n}=M^{n} \mathbf {u}_{0}\) for all \(n\in \mathbb {N}\).

It is well known that systems of linear recurrence equations can be equivalently used to define linear recursive sequences, as explained in the following result.

Proposition 2.1

[15] A sequence u is a linear recursive sequence if and only if there exists \(k\in \mathbb {N}\) and sequences u1,…,uk that satisfy a system of linear recurrence equations, where u1 = u. Moreover, the smallest k for which this holds is the order of u.

To get more accustomed with this equivalent definition, let us consider the sequence an = n2. Since (n + 1)2 = n2 + 2n + 1, we consider two auxiliary sequences bn = n and cn = 1. The initial values of these sequences are a0 = b0 = 0 and c0 = 1. Thus, an can be defined by providing these initial values together with a system of linear equations

$$ \left\{\begin{array}{l} a_{n+1} = a_{n} + 2b_{n} + c_{n}, \\ b_{n+1} = b_{n} + c_{n}, \\ c_{n+1} = c_{n}. \end{array}\right. $$
(2.3)

In the matrix form, we could equivalently write that (an,bn,cn)T = Mne, where

$$ \begin{array}{@{}rcl@{}} M = \left( \begin{array}{lll} 1 & 2 & 1\\ 0 & 1 & 1 \\ 0 & 0 & 1 \end{array}\right), \mathbf{e} = \left( \begin{array}{l} 0\\ 0 \\ 1 \end{array}\right). \end{array} $$

It can be readily verified that an is also defined by the recurrence an+ 3 = 3an+ 2 − 3an+ 1 + an.

The difference between the two definitions is that in (2.1) we have only one sequence, but the depth of the recursion can be any k. Conversely, in (2.2) we are allowed to have k sequences, but the depth of recursion is 1. The equivalence provided by Proposition 2.1 is quite convenient and is often used in the literature, see e.g. [20].

We give a short proof of Proposition 2.1, different from the proof in [15]. The reason is that this proof provides us with intuition that will turn out to be useful later on.

Proof of Proposition 2.1

For the left-to-right implication, suppose u is a linear recursive sequence of order k; say it is defined by the recursive formula un+k = L(un,…,un+k− 1), where L is a k-variate linear form. Define the sequences u1,…,uk by setting

$$ {u^{i}_{n}}:= u_{n+i-1}\qquad\text{for all }i\in \{1,\ldots,k\}\text{ and }n\in \mathbb{N}. $$

Then u1 = u and the sequences u1,…,uk satisfy the system of equations as in (2.2), where Lk = L and Li(x1,…,xk) = xi+ 1 for i ∈{1,…,k − 1}.

For the right-to-left implication, suppose that there exist \(k\in \mathbb {N}\) and sequences u1,…,uk that satisfy the system of (2.2) for some linear forms L1,…,Lk, such that u = u1. Let M be a k × k matrix over \(\mathbb {Q}\) that encodes the linear forms L1,…,Lk; that is, \(\mathbf {u}_{n}=M^{n} \mathbf {u}_{0}\), where \(\mathbf {u}_{n}=({u^{1}_{n}},\ldots ,{u^{k}_{n}})^{\mathsf {T}}\in \mathbb {Q}^{k}\). Consider the linear map \(R\colon \mathbb {Q}^{k}\to \mathbb {Q}^{k+1}\) defined as

$$ R(\mathbf{x}) = (\ \mathbf{e} M^{0} \mathbf{x} , \mathbf{e} M^{1} \mathbf{x} ,\ \ldots\ , \mathbf{e} M^{k} \mathbf{x}\ )^{\mathsf{T}}, $$

where \(\mathbf {e}=(1,0,\ldots ,0)\in \mathbb {Q}^{k}\). Note that

$$ \begin{array}{@{}rcl@{}} R(\mathbf{u}_{n})=({u^{1}_{n}},u^{1}_{n+1},\ldots,u^{1}_{n+k})=(u_{n},u_{n+1},\ldots,u_{n+k})\qquad\text{for all }n\in \mathbb{N}. \end{array} $$
(2.4)

Observe that R is a linear map from \(\mathbb {Q}^{k}\) to \(\mathbb {Q}^{k+1}\), hence the image of R is a linear subspace of \(\mathbb {Q}^{k+1}\) of co-dimension at least 1. Hence, there exists a nonzero linear form \(K\colon \mathbb {Q}^{k+1}\to \mathbb {Q}\) such that \(\text {im} R \subseteq \ker K\), or equivalently K(R(x)) = 0 for all \(\mathbf {x}\in \mathbb {Q}^{k}\). By (2.4), we have

$$ \begin{array}{@{}rcl@{}} K(u_{n},u_{n+1},\ldots,u_{n+k})=0\qquad\text{for all }n\in \mathbb{N}. \end{array} $$
(2.5)

Let \(a_{0},a_{1},\ldots ,a_{k}\in \mathbb {Q}\) be such that

$$ K(x_{0},\ldots,x_{k})=a_{0}x_{0}+\ldots+a_{k}x_{k}. $$

Since K is nonzero there exists the largest index t such that at≠ 0. From (2.5) we infer that

$$ u_{n+t}= - \frac{a_{t-1}}{a_{t}}\cdot u_{n+t-1} - \frac{a_{t-2}}{a_{t}}\cdot u_{n+t-2} - {\ldots} -\frac{a_{0}}{a_{t}}\cdot u_{n} \qquad\text{for all }n\in \mathbb{N}, $$

so u is a linear recursive sequence of order at most t. □

Remark 2.1

One could imagine setting up all the definitions presented above using affine forms instead of linear forms, that is, functions \(A\colon \mathbb {Q}^{k}\to \mathbb {Q}\) of the form

$$ A(x_{1},\ldots,x_{k})=a_{1}x_{1}+\ldots+a_{k}x_{2}+c, $$

where \(a_{1},\ldots ,a_{k},c\in \mathbb {Q}\). However, as we may always add constant sequences to the system of recurrence equations defining a sequence, considering affine forms does not increase the expressive power. In fact, from Proposition 2.1 it can be easily derived that we obtain exactly the same class of linear recursive sequences, regardless of whether we use linear or affine forms in both definitions.

Poly-Recursive Sequences

We now generalise the concept of linear recursive sequences by allowing polynomial functions instead of only linear forms. The starting point of the generalisation is the definition via a system of recurrence equations, as in (2.2).

Definition 2.1

A sequence of rationals u is polynomial recursive (or poly-recursive for short) if there exist \(k\in \mathbb {N}\), sequences of rationals u1,…,uk satisfying u = u1, and polynomials \(P_{1},\ldots ,P_{k}\in \mathbb {Q}[x_{1},\ldots ,x_{k}]\) such that for all \(n\in \mathbb {N}\), we have

$$ \begin{array}{@{}rcl@{}} \left\{\begin{array}{l} u^{1}_{n+1} = P_{1}({u^{1}_{n}},\ldots,{u^{k}_{n}}),\\ {\vdots} \\ u^{k}_{n+1} = P_{k}({u^{1}_{n}},\ldots,{u^{k}_{n}}). \end{array}\right. \end{array} $$
(2.6)

Again, notice that polynomials P1,…,Pk and the initial values \({u^{1}_{0}}, {\ldots } {u^{k}_{0}}\) uniquely determine the sequences u1,…,uk, hence in particular the sequence u = u1.

Let us examine a few examples. First, recall the sequences \(a_{n} = 2^{2^{n}}\) and bn = n! defined in Section 1.

Another example is the sequence \(d_{n} = 2^{n^{2}}\). Since \(2^{(n+1)^{2}} = 2^{n^{2} + 2n + 1}\), we define d0 = e0 = 1 and let

$$ \left\{\begin{array}{l} d_{n+1} = d_{n} \cdot (e_{n})^{2} \cdot 2, \\ e_{n+1} = e_{n} \cdot 2. \end{array}\right. $$

The polynomials used in the last definition are P1(x1,x2) = 2x1(x2)2 and P2(x1,x2) = 2x2. Notice that this idea can be easily generalised to define any sequence of the form rQ(n), where r is a rational number and Q is a polynomial with rational coefficients. We remark that all three sequences \(a_{n}=2^{2^{n}}\), bn = n!, \(d_{n} = 2^{n^{2}}\) are not linear recursive for simple asymptotic reasons (from the discussion in Section 1).

3 Simple Poly-Recursive Sequences

The following notion is a natural generalisation of the definition (2.1) of linear recursive sequences to the setting of recurrences defined using polynomials.

Definition 3.1

A sequence of rationals u is simple poly-recursive if there exists \(k\in \mathbb {N}\) and a polynomial \(P\in \mathbb {Q}[x_{1},x_{2},\ldots ,x_{k}]\) such that

$$ \begin{array}{@{}rcl@{}} u_{n+k} = P(u_{n},u_{n+1},\ldots,u_{n+k-1})\qquad\text{for all }n\in \mathbb{N}. \end{array} $$
(3.1)

Again, note that if u is simple poly-recursive as above, then the polynomial P and the first k values u0,…,uk− 1 uniquely determine the sequence u.

Clearly, every linear recursive sequence is a simple poly-recursive sequence. In fact, by Proposition 2.1 and Remark 2.1, the two notions would coincide if we required that the polynomial P in the definition above has degree at most 1. On the other hand, observe that the same construction as in the first paragraph of the proof of Proposition 2.1 shows that every simple poly-recursive sequence is poly-recursive. We now prove that this inclusion is strict.

Theorem 3.1

The sequence bn = n! is not simple poly-recursive.

Proof

Towards a contradiction, suppose there is \(k\in \mathbb {N}\) and a polynomial \(P\in \mathbb {Q}[x_{1},\ldots ,x_{k}]\) such that

$$ \begin{array}{@{}rcl@{}} b_{n+k}=P(b_{n},b_{n+1},\ldots,b_{n+k-1})\qquad\text{for all }n\in \mathbb{N}. \end{array} $$
(3.2)

Let us write

$$ P=Q+A, $$

where \(Q,A\in \mathbb {Q}[x_{1},\ldots ,x_{k}]\) are such that A is the sum of all the monomials in the expansion of P that have degree at most 1, while Q is the sum of all the remaining monomials in the expansion of P. Thus, A is an affine form, while every monomial in the expansion of Q has total degree at least 2.

Since A is an affine form, there exists a number \(c\in \mathbb {N}\) such that

$$ |A(q_{1},\ldots,q_{k})|<c+c\cdot \max_{1\leq i\leq k} |q_{i}|\qquad \text{for all }q_{1},\ldots,q_{k}\in \mathbb{Q}. $$

Thus, for all n > 2c we have

$$ \begin{array}{@{}rcl@{}} |A(b_{n},b_{n+1},\ldots,b_{n+k-1})| \leq c+c\cdot (n+k-1)!<(n+k)!=b_{n+k}. \end{array} $$
(3.3)

Since by (3.2) it follows that

$$ Q(b_{n},b_{n+1},\ldots,b_{n+k-1}) = b_{n+k}-A(b_{n},b_{n+1},\ldots,b_{n+k-1}), $$

using (3.3) we may conclude that for all n > 2c the following inequality holds:

$$ \begin{array}{@{}rcl@{}} 0 < Q(b_{n},b_{n+1},\ldots,b_{n+k-1}) < 2b_{n+k}. \end{array} $$
(3.4)

Let m be the product of all denominators of all the coefficients appearing in the expansion of P into a sum of monomials. Note that for all n > m, the number \(\tilde {b}_{n}:= \frac {b_{n}}{m}=\frac {n!}{m}\) is an integer. Furthermore, we have that \(\tilde {b}_{n}\) divides \(\tilde {b}_{n^{\prime }}\) for all \(n^{\prime }\geq n\). Since every monomial in the expansion of Q has total degree at least 2, we infer that for all n > m, we have

$$ \begin{array}{@{}rcl@{}} \left( \tilde{b}_{n}\right)^{2}\ |\ Q(b_{n},b_{n+1},\ldots,b_{n+k-1}). \end{array} $$
(3.5)

By combining (3.5) with the left inequality of (3.4), we conclude that for all \(n>\max \limits (2c,m)\),

$$ Q(b_{n},b_{n+1},\ldots,b_{n+k-1}) \geq \left( \tilde{b}_{n}\right)^{2}. $$

This bound together with the right inequality of (3.4) implies that

$$ \left( \frac{n!}{m}\right)^{2} = \left( \tilde{b}_{n}\right)^{2} < 2b_{n+k} = 2\cdot (n+k)!. $$

This inequality, however, is not true for every sufficiently large n, a contradiction. □

4 Modular Periodicity

Recall that a sequence of numbers r is ultimately periodic if there exist \(N,k\in \mathbb {N}\) such that for all \(n\geqslant N\), we have rn = rn+k. In this section we prove the following periodicity property of poly-recursive sequences, which, by means of contradiction, provides a basic technique for proving that a given sequence is not poly-recursive.

Theorem 4.1

Suppose u is a poly-recursive sequence of integers. Then there exists \(a\in \mathbb {N}\) such that for every prime p > a, the sequence rn := un mod p is ultimately periodic.

Proof

Let u be defined by the system of recursive equations

$$ \begin{array}{@{}rcl@{}} \left\{\begin{array}{l} u^{1}_{n+1} = P_{1}({u^{1}_{n}},\ldots,{u^{k}_{n}}),\\ {\vdots} \\ u^{k}_{n+1} = P_{k}({u^{1}_{n}},\ldots,{u^{k}_{n}}), \end{array}\right. \end{array} $$
(4.1)

where u1,…,uk are sequences such that u1 = u and \(P_{1},\ldots ,P_{k}\in \mathbb {Q}[x_{1},\ldots ,x_{k}]\).

Without loss of generality we may assume that the initial values \({u_{0}^{1}},\ldots ,{u_{0}^{k}}\) are integers. Indeed, this is certainly the case for \({u_{0}^{1}}=u_{0}\), while for every i > 1, we may rewrite the system so that it uses the sequence \(\widetilde {\mathbf {u}}^{i}=q_{i}\cdot \mathbf {u}^{i}\) instead of ui, where qi is the denominator of \({u^{i}_{0}}\). For this, the starting condition for \(\widetilde {\mathbf {u}}^{i}\) can be set as \(\widetilde {u}^{i}_{0}=q_{i}\cdot {u^{i}_{0}}\), which is an integer, in all polynomials P1,…,Pk we may substitute xi with xi/qi, and the polynomial Pi can be replaced with qiPi.

Further, without loss of generality we may assume that all the monomials present in the expansions of all the polynomials P1,…,Pk have the same total degree d > 1. Such polynomials are called homogeneous of degree d and they have the property that Pi(ax1,…,axk) = adPi(x1,…,xk) for all \(a \in \mathbb {Q}\). Indeed, let d > 1 be any integer that is not smaller than the degrees of all the polynomials P1,…,Pk. To the system (4.1) we add a new sequence uk+ 1, defined by setting

$$ u^{k+1}_{0}=1\qquad\text{and}\qquad u^{k+1}_{n+1}=\left( u^{k+1}_{n}\right)^{d}\ \text{for }n\in \mathbb{N}. $$

Thus uk+ 1 is constantly equal to 1. Then each monomial M(x1,…,xk) appearing in the expansion of any of the polynomials Pi(x1,…,xk) can be replaced by the monomial \(M(x_{1},\ldots ,x_{k})\cdot x_{k+1}^{d-t}\in \mathbb {Q}[x_{1},\ldots ,x_{k},x_{k+1}]\), where t is the total degree of M. It is straightforward to see that the modified system of recursive equations still defines u = u1, while all monomials appearing in all the polynomials used in it have the same degree d.

After establishing these two assumptions, we proceed to the main proof. Let \(a\in \mathbb {N}\) be a positive integer such that the polynomials

$$ \tilde{P}_{i}:= a\cdot P_{i} $$

all belong to \(\mathbb {Z}[x_{1},\ldots ,x_{k}]\), that is, have integer coefficients. For instance, one can take a to be product of all the denominators of all the rational coefficients appearing in the polynomials P1,…,Pk. For all i ∈{1,…,k} and \(n\in \mathbb {N}\), let us define

$$ \tilde{u}^{i}_{n}:= a^{\frac{d^{n}-1}{d-1}}\cdot {u^{i}_{n}}. $$

By a straightforward induction we show that the sequences \(\tilde {\mathbf {u}}^{1},\ldots ,\tilde {\mathbf {u}}^{k}\) satisfy the system of recursive equations

$$ \begin{array}{@{}rcl@{}} \left\{\begin{array}{l} \tilde{u}^{1}_{n+1} = \tilde{P}_{1}(\tilde{u}^{1}_{n},\ldots,\tilde{u}^{k}_{n}),\\ {\vdots} \\ \tilde{u}^{k}_{n+1} = \tilde{P}_{k}(\tilde{u}^{1}_{n},\ldots,\tilde{u}^{k}_{n}). \end{array}\right. \end{array} $$
(4.2)

Indeed, the induction base is trivial and for the induction step recall that all monomials have the same degree d, hence

$$ \begin{array}{@{}rcl@{}} \tilde{P}_{i}(\tilde{u}^{1}_{n},\ldots,\tilde{u}^{k}_{n}) & =& a\cdot P_{i}(a^{\frac{d^{n}-1}{d-1}}\cdot {u^{1}_{n}},\ldots,a^{\frac{d^{n}-1}{d-1}}\cdot {u^{k}_{n}}) \\ & =& a\cdot a^{\frac{d^{n+1} - d}{d-1}}\cdot u^{i}_{n+1} \\ & =& a^{\frac{d^{n+1} - 1}{d-1}}\cdot u^{i}_{n+1} \\ &=&\tilde{u}^{i}_{n+1}. \end{array} $$

Observe that since the initial values \(\tilde {u}^{i}_{0}={u^{i}_{0}}\) are integers, and the polynomials \(\tilde {P}_{i}\) have integer coefficients, we can infer that all entries of the sequences \(\tilde {\mathbf {u}}^{1},\ldots ,\tilde {\mathbf {u}}^{k}\) are integers.

We now show that for every prime p > a, the sequence r defined as rn = un mod p is ultimately periodic; this will conclude the proof. For every i ∈{1,…,k} and \(n\in \mathbb {N}\), let

$$ \tilde{r}^{i}_{n}:= \tilde{u}^{i}_{n}\bmod p. $$

By (4.2) and the fact that the polynomials \(\tilde {P}_{i}\) have integer coefficients, for every \(n\in \mathbb {N}\) the vector of entries \((\tilde {r}^{1}_{n+1},\ldots ,\tilde {r}^{k}_{n+1})\) is uniquely determined by the vector \((\tilde {r}^{1}_{n},\ldots ,\tilde {r}^{k}_{n})\). Since this vector may take only at most pk different values, it follows that the sequences \(\tilde {\mathbf {r}}^{1},\ldots ,\tilde {\mathbf {r}}^{k}\) are ultimately periodic.

Now note that for every \(n\in \mathbb {N}\), we have

$$ a^{\frac{d^{n}-1}{d-1}}\cdot r_{n} \equiv a^{\frac{d^{n}-1}{d-1}} \cdot u_{n} = \tilde{u}^{1}_{n} \equiv \tilde{r}^{1}_{n} \mod p. $$

Since p > a and p is a prime, we have that a and p are coprime. Therefore, there exists an integer b such that ab ≡ 1 mod p. By multiplying the above congruence by \(b^{\frac {d^{n}-1}{d-1}}\), we have

$$ \begin{array}{@{}rcl@{}} r_{n}\equiv b^{\frac{d^{n}-1}{d-1}}\cdot \tilde{r}^{1}_{n} \mod p. \end{array} $$
(4.3)

Observe that the sequence \(b_{n}=b^{\frac {d^{n}-1}{d-1}}\) satisfies the recursive equation \(b_{n+1}=b\cdot \left (b_{n}\right )^{d}\), hence the sequence (bn mod p) is ultimately periodic. Since \(\tilde {\mathbf {r}}^{1}\) is ultimately periodic as well, from (4.3) we conclude that the sequence r is ultimately periodic. □

We use Theorem 4.1 to prove that the Catalan numbers are not poly-recursive. Recall that the n th Catalan number Cn is given by the formula \(C_{n}=\frac {1}{n+1} \left (\begin {array}{c}{2n}\\{n} \end {array}\right )\).

Alter and Kubota [2] studied the behaviour of the Catalan numbers modulo primes. It is easy to see (and proved in [2]) that for every prime p, the sequence Cn contains infinitely many numbers divisible by p, and infinitely many numbers not divisible by p. Let a p-block be a maximal contiguous subsequence of the sequence Cn consisting of entries divisible by p. The p-blocks can be naturally ordered along the sequence Cn, so let \({L_{k}^{p}}\) be the length of the k th p-block. Then Alter and Kubota proved the following.

Theorem 4.2

[2] For every prime p > 3 and k ≥ 1, we have

$$ {L_{k}^{p}}=\frac{p^{m+1}-3}{2}, $$

where m is the largest integer such that \(\left (\frac {p+1}{2}\right )^{m}\) divides k.

Note that Theorem 4.2 in particular implies that for every prime p > 3, the sequence Cn contains arbitrary long p-blocks. This means that Cn taken modulo p cannot be ultimately periodic. By combining this with Theorem 4.1, we conclude the following.

Corollary 4.1

Catalan numbers are not poly-recursive.

5 Cancelling Polynomials

Consider the following definition, which can be seen as a variation of the definition of simple poly-recursive sequences, which we discussed in Section 3.

Definition 5.1

A sequence of rationals u admits a cancelling polynomial if there exist \(k\in \mathbb {N}\) and a nonzero polynomial P ∈ ℚ[x0,…,xk] such that

$$ P\left( u_{n}, u_{n+1}, \ldots, u_{n+k} \right) = 0\qquad \text{for all }n \in \mathbb{N}. $$

Remark 5.1

A cancelling polynomial P can be always assumed to have integer coefficients, i.e. to belong to \(\mathbb {Z}[x_{0},\ldots ,x_{k}]\), because one may multiply P by the product of all denominators that occur in its coefficients.

Observe that the notion of a cancelling polynomial extends the definition of simple poly-recursive sequences (Definition 3.1) in the following sense: a sequence is simple poly-recursive if and only if it admits a cancelling polynomial P(x0,…,xk) whose expansion into a sum of monomials involves only one term containing xk, namely the monomial xk itself. This particular form of the considered algebraic constraint was vitally used in the proof of Proposition 3.1, where we showed that the sequence bn = n! is not simple poly-recursive. In fact, if one drops this restriction, then it is easy to see that the sequence bn = n! actually admits a cancelling polynomial: for instance P(x0,x1,x2) = x0x2 − (x1)2x0x1.

We now prove that the above example is not a coincidence.

Theorem 5.1

Every poly-recursive sequence admits a cancelling polynomial.

Proof

The proof follows the same basic idea as the proof of Proposition 2.1 that we gave in Section 2. The difference is that instead of linear maps we work with maps defined by polynomial functions, hence instead of linear independence we shall work with the notion of algebraic independence.

Recall that if \(\mathbb {K}\subseteq \mathbb {L}\) is a field extension, then elements \(a_{1},\ldots ,a_{k}\in \mathbb {L}\) are algebraically dependent over \(\mathbb {K}\) if there is a nonzero polynomial \(P\in \mathbb {K}[x_{1},\ldots ,x_{k}]\) such that P(a1,…,ak) = 0 in \(\mathbb {L}\). We will use the following well-known fact; see e.g. [18, Chapter VIII, Theorem 1.1].

Theorem 5.2

If \(\mathbb {K}\) is a field and \(k\in \mathbb {N}\), then in the field of rational expressions \(\mathbb {K}(x_{1},\ldots ,x_{k})\) every k + 1 elements are algebraically dependent over \(\mathbb {K}\).

We proceed to the proof of the theorem. Let u be the poly-recursive sequence in question. By definition, for some \(k\in \mathbb {N}\) there are sequences u1,…,uk and polynomials \(P_{1},\ldots ,P_{k}\in \mathbb {Q}[x_{1},\ldots ,x_{k}]\) such that for all \(n\in \mathbb {N}\),

$$ \begin{array}{@{}rcl@{}} \left\{\begin{array}{l} u^{1}_{n+1} = P_{1}({u^{1}_{n}},\ldots,{u^{k}_{n}}),\\ {\vdots} \\ u^{k}_{n+1} = P_{k}({u^{1}_{n}},\ldots,{u^{k}_{n}}). \end{array}\right. \end{array} $$

We inductively define polynomials \(P^{(t)}_{1},\ldots ,P^{(t)}_{k}\in \mathbb {Q}[x_{1},\ldots ,x_{k}]\) as follows. For t = 0, set

$$ \begin{array}{@{}rcl@{}} P^{(0)}_{i}(x_{1},\ldots,x_{k}) = x_{i}\qquad \text{for all }i\in \{1,\ldots,k\}, \end{array} $$

and for t ≥ 1, set for all i ∈{1,…,k}

$$ \begin{array}{@{}rcl@{}} P^{(t)}_{i}(x_{1},\ldots,x_{k}) = P_{i}(P^{(t-1)}_{1}(x_{1},\ldots,x_{k}),\ldots,P^{(t-1)}_{k}(x_{1},\ldots,x_{k})). \end{array} $$

The following lemma follows from the construction by a straightforward induction.

Lemma 5.1

For all \(n,t\in \mathbb {N}\) and i ∈{1,…,k}, we have \(P^{(t)}_{i}({u^{1}_{n}},\ldots ,{u^{k}_{n}})=u^{i}_{n+t}\).

Consider the polynomials

$$ \begin{array}{@{}rcl@{}} P^{(0)}_{1},P^{(1)}_{1},\ldots,P^{(k)}_{1}\in \mathbb{Q}[x_{1},\ldots,x_{k}]. \end{array} $$

By Theorem 5.2, these polynomials (treated as elements of \(\mathbb {Q}(x_{1},\ldots ,x_{k})\)) are algebraically dependent over \(\mathbb {Q}\), so there exists a nonzero polynomial \(Q\in \mathbb {Q}[y_{0},y_{1},\ldots ,y_{k}]\) such that the polynomial

$$ R(x_{1},\ldots,x_{k})=Q(P^{(0)}_{1}(x_{1},\ldots,x_{k}),P^{(1)}_{1}(x_{1},\ldots,x_{k}),\ldots,P^{(k)}_{1}(x_{1},\ldots,x_{k})) $$

is identically zero. It now remains to observe that by Lemma 5.1, for every \(n\in \mathbb {N}\) we have

$$ 0=R({u^{1}_{n}},\ldots,{u^{k}_{n}})=Q({u^{1}_{n}},u^{1}_{n+1},\ldots,u^{1}_{n+k})=Q(u_{n},u_{n+1},\ldots,u_{n+k}), $$

hence Q is a cancelling polynomial for u. □

Remark 5.2

Notice that a given polynomial can be the cancelling polynomial of many different sequences. For example, the polynomial (x0)2 − 1 is a cancelling polynomial of any sequence over {− 1,1}. In particular, some of those sequences are not ultimately periodic modulo p, for any prime number p, and thus are not poly-recursive by Theorem 4.1. Hence, the converse direction of Theorem 5.1 does not hold.

We now present an application of Theorem 5.1 by showing that the sequence un = nn is not poly-recursive. By Theorem 5.1, it suffices to show that there is no cancelling polynomial for this sequence. Contrary to the reasoning presented in Section 4, where we used off-the-shelf results about modular (non) periodicity of Catalan numbers, proving the nonexistence of a cancelling polynomial for the nn sequence turns out to be a somewhat challenging task.

We first observe that when we apply a multivariate polynomial to consecutive entries of un, we can rewrite the result in another form:

Lemma 5.2

Let \(Z\in \mathbb {Z}[x_{0},x_{1},\ldots ,x_{k}]\) be a nonzero polynomial. Then there exist nonzero polynomials \(P_{1},\ldots ,P_{m},Q_{1},\ldots ,Q_{m}\in \mathbb {Z}[x]\) such that the polynomials P1,…,Pm are pairwise different and for every \(n\in \mathbb {N}\),

$$ Z\left( n^{n},(n+1)^{n+1},\ldots,(n+k)^{n+k}\right) = \sum\limits_{i=1}^{m} P_{i}(n)^{n}\cdot Q_{i}(n). $$

Proof

By expanding Z as a sum of monomials, we may write

$$ \begin{array}{@{}rcl@{}} Z(x_{0},\ldots,x_{k}) = \sum\limits_{i = 1}^{m} c_{i}\cdot M_{i}(x_{0},\ldots,x_{j}), \end{array} $$
(5.1)

where for all i ∈{1,…,m}, ci≠ 0 and

$$ M_{i}(x_{0},\ldots,x_{k}) = \prod\limits_{j=0}^{k} x_{j}^{d_{i,j}} $$

are pairwise different monomials. Now observe that for every \(n\in \mathbb {N}\), we have

$$ \begin{array}{@{}rcl@{}} &&M_{i}\left( n^{n},(n+1)^{n+1},\ldots,(n+k)^{n+k}\right)\\ & =& \prod\limits_{j=0}^{k} (n+j)^{d_{i,j}\cdot (n+j)}\\ & =& \left( \prod\limits_{j=0}^{k} (n+j)^{d_{i,j}}\right)^{n}\cdot \prod\limits_{j=0}^{k} (n+j)^{d_{i,j}\cdot j}. \end{array} $$
(5.2)

Hence, if we define

$$ P_{i}(x)=\prod\limits_{j=0}^{k} (x+j)^{d_{i,j}}\qquad\text{and}\qquad Q_{i}(x)=c_{i}\cdot \prod\limits_{j=0}^{k} (x+j)^{d_{i,j}\cdot j}, $$

then, by (5.1) and (5.2), we conclude that

$$ Z\left( n^{n},(n+1)^{n+1},\ldots,(n+k)^{n+k}\right) = \sum\limits_{i=1}^{m} P_{i}(n)^{n}\cdot Q_{i}(n)\qquad\text{for all }n\in \mathbb{N}, $$

as required. It now suffices to observe that (1) all polynomials Pi and Qi are nonzero, because ci≠ 0 and the monomial Mi is nonzero, and (2) the polynomials Pi are pairwise different, because they have pairwise different multisets of roots. □

With Lemma 5.2 established, we move to the main result of this section.

Theorem 5.3

The sequence un = nn is not poly-recursive.

Proof

Suppose, for the sake of contradiction, that the sequence un = nn is poly-recursive. By Theorem 5.1 and Remark 5.1, there exists a nonzero polynomial \(Z\in \mathbb {Z}[x_{0},x_{1},\ldots ,x_{k}]\) that is cancelling for un. By Lemma 5.2, we can find nonzero polynomials \(P_{1},\ldots ,P_{m},Q_{1},\ldots ,Q_{m}\in \mathbb {Z}[x]\), where P1,…,Pm are pairwise different, such that

$$ \begin{array}{@{}rcl@{}} \sum\limits_{i=1}^{m} P_{i}(n)^{n}\cdot Q_{i}(n) = 0 \qquad\text{for all }n\in \mathbb{N}. \end{array} $$
(5.3)

This system of equations seems somewhat unwieldy due to the presence of the term Pi(n)n, where n is involved both in the base and in the exponent. The following claim formulates the key idea of the proof: if we consider the (5.3) modulo any prime, then the bases and the exponents of these terms can be made independent.

Claim 1

For every prime p and all a,b ∈ ℤ where b > 0, it holds that

$$ \sum\limits_{i=1}^{m} P_{i}(a)^{b}\cdot Q_{i}(a) \equiv 0 \mod p\enspace. $$

Proof

Since p and p − 1 are coprime, there is an n ∈ ℕ such that n > b, na mod p and nb mod p − 1. Thus for any 1 ≤ im:

$$ Q_{i}(n)\equiv Q_{i}(a)\mod p \qquad\text{and}\qquad P_{i}(n)^{n}\equiv P_{i}(a)^{n}\equiv P_{i}(a)^{b}\mod p\enspace, $$

the second part holding by Fermat’s Little Theorem. The claim now follows by considering equality (5.3) modulo p. □

Let a ∈ ℕ and let Da = [dij]1≤i,jm be the m × m matrix defined by dij = Pj(a)i. Since this is essentially a Vandermonde matrix, its determinant has a simple expression, as expressed in the following claim.

Claim 2

Let S ∈ ℤ[x] be defined as

$$ S(x) = \prod\limits_{i=1}^{m} P_{i}(x)\cdot \prod\limits_{1\leq i<j\leq m} (P_{i}(x)-P_{j}(x))\enspace. $$

Then S is nonzero and det(Da) = S(a).

Proof

That S is nonzero follows from the fact that the polynomials Pi are all nonzero and pairwise different.

Now observe that Da is a Vandermonde matrix with columns consisting of consecutive powers of Pj(a), for 1 ≤ jm with columns consisting of consecutive powers of Pj(a), starting with Pj(a)1 (whereas the Vandermonde matrix starts with Pj(a)0).

It is well known that the determinant of the Vandermonde matrix [Pj(a)i− 1]1≤i,jm is

$$ \prod\limits_{1\leq i<j\leq m} (P_{i}(a)-P_{j}(a))\enspace. $$

Further, multiplying the j th column by Pj(a), for all j, results in the determinant being multiplied by \(\prod_{i=1}^{m} P_{i}(a)\). This proves the claim. □

We will need the following classical definition.

Definition 5.2

Let R be a ring and M be a m × m matrix over R. The adjugate matrix M̂ of M is an m × m matrix over R that satisfies M̂M = det(M) ⋅ I, where I is the m × m identity matrix.

It is well known that the adjugate matrix always exists. Now let

$$ u_{a}=(Q_{1}(a),\ldots,Q_{m}(a))^{\mathsf{T}}. $$

Section 5 implies that for every prime p,

$$ D_{a} u_{a} \equiv \mathbf{0} \mod p, $$

where 0 is the m-dimensional zero vector. By multiplying both sides of this equation by the adjugate matrix of Da taken over ℤp, we conclude that for every prime p, we have

$$ \det(D_{a})\cdot u_{a} \equiv \mathbf{0} \mod p\qquad\text{for all }a\in \mathbb{N}. $$

This is equivalent to

$$ \begin{array}{@{}rcl@{}} S(a)\cdot Q_{i}(a)\equiv 0 \mod p\qquad \text{for all }a\in \mathbb{N}\text{ and }1\le i \le m. \end{array} $$
(5.4)

This means that for every prime p and every 1 ⩽ im, the following assertion holds: every a ∈ Fp is a zero of the polynomial SQi considered as a polynomial over Fp.

Recall that the polynomials \(S,Q_{1},\ldots ,Q_{m}\in \mathbb {Z}[x]\) are nonzero. Consider a prime p that is larger than every coefficient occurring in the expansion of the polynomials S, Q1,…,Qm into sums of monomials, and that is further larger than deg(S) + maxj∈{1,…,m}deg(Qj). Then the polynomials S,Q1,…,Qm are nonzero even when regarded as polynomials over Fp, hence the same can be said also about the polynomials SQi, for all \(1\leqslant i\leqslant m\). However, by (5.4), for every 1 ⩽ im the polynomial SQi has at least p > deg(S) + deg(Qi) roots over Fp. This is a contradiction. □

6 Applications in Weighted Automata

In this section we discuss the implications of the results we presented in the previous sections for various questions regarding the expressive power of extensions of weighted automata. We will briefly describe the model of weighted automata and focus only on its expressive power. We refer an interested reader to e.g. [1, 10] for an introduction to the area.

Given a semiring \(\mathbb {S}\), a weighted automaton \(\mathcal {A}\) is a tuple (d,Σ,{Ma}aΣ,I,F), where:

  • \(d\in \mathbb {N}\) is the dimension;

  • Σ is a finite alphabet;

  • every Ma is a d × d matrix over \(\mathbb {S}\); and

  • I and F are the initial and the final vector in \(\mathbb {S}^{d}\), respectively.

In this paper we only consider the semiring \(\mathbb {S}=\mathbb {Q}\). A weighted automaton defines a function \(\left [\!\left [{\mathcal {A}}\right ]\!\right ] \colon {{{\varSigma }}}^{*} \to \mathbb {S}\) as follows: if \(w = a_{1} {\ldots } a_{n} \in {{{\varSigma }}}^{*}\), then

$$ \begin{array}{@{}rcl@{}} \left[\!\left[{\mathcal{A}}\right]\!\right](w) = I^{\mathsf{T}} \cdot M_{a_{1}}M_{a_{2}}{\ldots} M_{a_{n}} \cdot F. \end{array} $$
(6.1)

Note that when |Σ| = 1, this definition coincides with (the matrix form of) the definition (2.2) of linear recursive sequences. Assuming |Σ| = 1, one can identify each word with its length, which means that a weighted automaton defines a sequence \(\left [\!\left [{\mathcal {A}}\right ]\!\right ] \colon \mathbb {N} \to \mathbb {S}\). Therefore, weighted automata recognise exactly linear recursive sequences. See [6] for a broader discussion of the connection between linear recursive sequences and weighted automata.

We now discuss three nonlinear extensions of weighted automata that can be found in the literature. These extensions are studied in different areas and, as far as we are aware, they have never been compared in terms of expressive power before. We show that the results we presented in Sections 4 and 5 can be used to prove separation results, in terms of the expressive power, for some of these classes.

Like in the case of weighted automata, any automaton within the considered classes defines a function \(f \colon {{{\varSigma }}}^{*} \to \mathbb {Q}\), where Σ is the working alphabet. For our purposes, we restrict attention to the case of unary alphabets, that is, |Σ| = 1. Thus, the three considered classes of extended weighted automata correspond to three separate classes of sequences \(f \colon \mathbb {N} \to \mathbb {Q}\), similarly as standard weighted automata correspond to the class of linear recursive sequences.

Cost-Register Automata (CRA)

Cost-register automata (CRA) were introduced in at least three contexts [4, 7, 21]. To avoid technical details, we simply observe that CRAs over unary alphabets recognize exactly poly-recursive sequences, as defined in Definition 2.1. Since [4, 7, 21] discuss several variants of CRAs, to avoid ambiguity we refer to the definition of a CRA that can be found in [19].Footnote 2

Weighted Context-Free Grammars (WCFG)

Weighted automata can be equivalently defined as an extension of finite automata, where each translation is labelled by an element of the semiring \(\mathbb {S}\) (see e.g. [1]). In short, each run is assigned a value: the semiring product of the labels of all the transitions used in the run. Given a word w, the automaton outputs the semiring sum of the values assigned to all runs accepting w.

Weighted context-free grammars are an extension of context-free grammars in the same way weighted automata are an extension of finite automata. Every grammar rule is assigned a label from \(\mathbb {S}\). Then every derivation tree is assigned the semiring product of the labels of all the rules used in the tree. The output for a word w is defined as the semiring sum of all values assigned to derivation trees of w. See e.g. [13] for more details. Here we present only one example from [13] over the semiring \(\mathbb {Q}\).

Consider the grammar with one nonterminal X (which is also the starting nonterminal) and one terminal a with the following rules: Xa, XXX. Both rules are assigned weight 1. Therefore, for every word an the output is the number of derivation trees. It is easy to see that if we denote the output on the word an by Dn, then Dn is the number of full binary trees with n leaves, which is the sequence of Catalan numbers shifted by one, i.e. D0 = 0 and Dn+ 1 = Cn. By Corollary 4.1 and since it is easy to see that poly-recursive sequences are closed under shifts, we conclude the following.

Corollary 6.1

The class of sequences definable by unary-alphabet WCFGs over \(\mathbb {Q}\) is not contained in the class of sequences recognizable by unary-alphabet CRAs over \(\mathbb {Q}\).

Weighted MSO (WMSO)

Weighted MSO logic [9, 17] was introduced as a logic involving weights that intended to capture the expressive power of weighted automata, similarly as finite automata are characterized by MSO. In general, WMSO turns out to be strictly more expressive than weighted automata. We will not define the whole syntax of WMSO, only a simple fragment that does not even use variables. See [9, 17] for the full definition.

Fix the semiring \(\mathbb {S} = \mathbb {Q}\). Similarly as for weighted automata, every WMSO formula φ over \(\mathbb {Q}\) defines a function \(\left [\!\left [{\varphi }\right ]\!\right ]\colon {{{\varSigma }}}^{*}\to \mathbb {Q}\). As for atomic formulas, every \(c \in \mathbb {Q}\) is an atomic formula that defines the constant function \(\left [\!\left [{c}\right ]\!\right ](w) = c\). Instead of the boolean connectives ∨ and ∧, WMSO formulas can be added using + and multiplied using ⋅, with the obvious semantics. Instead of having the existential quantifier ∃x and the universal quantifier ∀x, we have the sum quantifier \({\sum }_{x}\) and the product quantifier \({\prod }_{x}\). Then

$$ \left[\!\left[{\sum\limits_{x} \varphi}\right]\!\right] (w) = \sum\limits_{i=1}^{n} \left[\!\left[{\varphi[x \to a_{i}]}\right]\!\right](w)\qquad\text{for all }w = a_{1}{\ldots} a_{n}\in {{{\varSigma}}}^{*}, $$

and similarly for \(\left [\!\left [{{\prod }_{x} \varphi }\right ]\!\right ] (w)\). For example, \(\left [\!\left [{{\sum}_{x} 1}\right ]\!\right ] (a^{n}) = n\). It follows that

$$ \left[\!\left[{\prod\limits_{x} \sum\limits_{y} 1}\right]\!\right] (a^{n}) = n^{n}. $$

This proves that the sequence nn can be defined in unary-alphabet WMSO over \(\mathbb {Q}\), so by Theorem 5.3 we may conclude the following.

Corollary 6.2

The class of sequences definable in unary-alphabet WMSO over \(\mathbb {Q}\) is not contained in the class of sequences recognizable by unary-alphabet CRAs over \(\mathbb {Q}\).

7 Rational Recursive Sequences

We now turn to a natural generalisation of poly-recursive sequences: rational recursive sequences. These are specified like poly-recursive sequences (Definition 2.1) but on the right hand side of the system of (2.6) we allow the Pi’s to be taken from the field of fractions of the polynomial ring. That is, each Pi is of the form \(P_{i}(x_{1},\ldots ,x_{k})=\frac {Q_{i}(x_{1},\ldots ,x_{k})}{R_{i}(x_{1},\ldots ,x_{k})}\), where \(Q_{i},R_{i}\in \mathbb {Q}[x_{1},\ldots ,x_{k}]\) and Ri≠ 0.

As discussed in Section 1, this class extends both poly-recursive sequences and holonomic sequences. For example one can express the sequence of Catalan numbers, since \(C_{n+1} = \frac {4n+2}{n+2}\cdot C_{n}\) and an ancillary sequence can hold the value n. However, the limitation of poly-recursive expressiveness we identified still applies:

Theorem 7.1

Every rational recursive sequence admits a cancelling polynomial.

Proof

We inspect the proof of the existence of cancelling polynomials for poly-recursive sequences (Theorem 5.1) and show that it carries over to rational recursive sequences. Indeed, the proof of Theorem 5.1 relies on Theorem 5.2 about algebraic dependency; this theorem holds for the field of rational expressions. Later in the proof the only property of polynomials from Definition 2.1 we use is that they are rational expressions. Therefore, the proof carries over if we replace polynomials with rational functions. □

As a corollary of the previous theorem and the proof of Theorem 5.3, we have:

Corollary 7.1

The sequence un = nn is not rational recursive.

Another direction towards a more expressive framework was taken in [12, 21]. Let us introduce the class (S3({a}, ℕ)) defined therein as one of the most expressive classes of sequences; we will simply write for that class. First, let us say that a poly-recursive sequence is defined over K, with K ∈{ℤ, ℕ}, if its initial values and the coefficients of its defining polynomials are all in K. A sequence u is in if there are poly-recursive sequences a,b,c,d defined over ℕ such that:

$$ u_{n} = \frac{a_{n}-b_{n}}{c_{n}-d_{n}}. $$

The class is naturally included in the class of rational recursive sequences. In [21, Example 4], it is claimed without proof that un = nn is not in ; Corollary 7.1 thus closes that gap. It is however not entirely obvious whether generalises poly-recursive sequences; we now show that this is the case, and even that:

Proposition 7.1

The class coincides with the class of rational recursive sequences.

Proof

Let u be a rational recursive sequence, we show that it is in . Let u be defined by u1,…,up via

$$ u^{(i)}_{n+1}= \frac{P_{i}\left( u^{(1)}_{n},\ldots,u^{(p)}_{n}\right)}{Q_{i}\left( u^{(1)}_{n},\ldots,u^{(p)}_{n}\right)}, $$

where u = u1 and \(P_{i} , Q_{i} \in \mathbb {Q}[X_{1},\ldots ,X_{p}]\).

We start by proving that u can be defined as

$$ u_{n} = \frac{N_{n}}{D_{n}}, $$

where Nn and Dn are poly-recursive sequences defined over ℤ.

There exist polynomials, with coefficients in \(\mathbb {Z}\) and with 2p variables

$$ \hat{P_{i}},\hat{Q_{i}} \in \mathbb{Z}[X_{1},\ldots,X_{p},Y_{1},\ldots,Y_{p}] $$

such that

$$ \frac{P_{i}(X_{1}/Y_{1},\ldots,X_{p}/Y_{p})}{Q_{i}(X_{1}/Y_{1},{\ldots} X_{p}/Y_{p})}= \frac{\hat{P_{i}}(X_{1},\ldots,X_{p},Y_{1},\ldots,Y_{p})}{\hat{Q_{i}}(X_{1},\ldots,X_{p},Y_{1},\ldots,Y_{p})}. $$

Now we define the sequences of integers N(i),D(i), for i = 1,…,p. We start with the initial values, that are chosen such that

$$ u_{0}^{(i)}= \frac{N^{(i)}_{0}}{D^{(i)}_{0}}. $$

The values for \(N^{(i)}_{0},D^{(i)}_{0}\) come from the irreducible positive fraction associated to \(u_{0}^{(i)}\). The remaining elements are defined by

$$ \begin{array}{@{}rcl@{}} N^{(i)}_{n+1}&=& \hat{P}_{i}\left( N_{n}^{(1)}, \ldots,N_{n}^{(p)}, D_{n}^{(1)}, \ldots,D_{n}^{(p)}\right), \\ D^{(i)}_{n+1}&=& \hat{Q}_{i}\left( N_{n}^{(1)}, \ldots,N_{n}^{(p)}, D_{n}^{(1)}, \ldots,D_{n}^{(p)}\right). \end{array} $$

A simple induction shows that

$$ \begin{array}{@{}rcl@{}} \frac{N^{(i)}_{n+1}}{D^{(i)}_{n+1}} & =& \frac{\hat{P}_{i}\left( N_{n}^{(1)}, \ldots,N_{n}^{(p)}, D_{n}^{(1)}, \ldots,D_{n}^{(p)}\right)}{\hat{Q}_{i}\left( N_{n}^{(1)}, \ldots,N_{n}^{(p)}, D_{n}^{(1)}, \ldots,D_{n}^{(p)}\right)} \\ & =& \frac{P_{i}\left( N_{n}^{(1)} / D_{n}^{(1)}, \ldots,N_{n}^{(p)} / D_{n}^{(p)}\right)}{Q_{i}\left( N_{n}^{(1)} / D_{n}^{(1)}, \ldots,N_{n}^{(p)} / D_{n}^{(p)}\right)} \\ & =& \frac{P_{i}\left( u_{n}^{(1)}, \ldots,u_{n}^{(p)}\right)}{Q_{i}\left( u_{n}^{(1)}, \ldots,u_{n}^{(p)}\right)} = u^{(i)}_{n+1}. \end{array} $$

This implies that u can be expressed using quotients of poly-recursive sequences defined over ℤ.

It remains to show that every poly-recursive sequence defined over ℤ can be defined as a difference of two poly-recursive sequences over ℕ. The argument follows the same steps as the first part, but the extra variables in the polynomials \(\hat {P_{i}}\), \(\hat {Q_{i}}\) are used as differences rather than quotients. □

8 Conclusion

We proved that two sequences, the Catalan numbers Cn and un = nn, are not polynomial recursive. For this, we exhibited two properties that poly-recursive sequences always satisfy: ultimate periodicity modulo large prime numbers and admitting a cancelling polynomial. In Section 7 we discussed the class of rational recursive sequences, a natural class for future investigation.