On Polynomial Recursive Sequences

We study the expressive power of polynomial recursive sequences, a nonlinear extension of the well-known class of linear recursive sequences. These sequences arise naturally in the study of nonlinear extensions of weighted automata, where (non)expressiveness results translate to class separations. A typical example of a polynomial recursive sequence is bn = n!. Our main result is that the sequence un = nn is not polynomial recursive.


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 f 0 = 0, f 1 = 1, and the recurrence relation f n+2 = f n+1 + f n . It is well known that every linear recursive sequence can be defined by a system of k mutually 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 nth elements of all the sequences [15]. For example, to define the Fibonacci sequence f n in this way, one needs one auxiliary sequence: we set f 0 = 0, g 0 = 1, and postulate f n+1 = g n , g n+1 = f n + g n . (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), but on the right hand side we allow arbitrary polynomial expressions, rather than just linear combinations. For example, the sequence b n = n! can be defined in this way using one auxiliary sequence: we may set b 0 = c 0 = 1 and write b n+1 = b n · c n , c n+1 = c n + 1. ( Thus, the recurrence relation uses two polynomials: P 1 (x 1 , x 2 ) = x 1 x 2 and P 2 (x 1 , x 2 ) = x 2 +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. 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 O(n) , while already the sequence b n = n! grows faster. In fact, already the recurrence relation a 0 = 2, a n+1 = (a n ) 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 u n = n n . The second example is the sequence of Catalan numbers C n = 1 n+1 2n n . Note that by Stirling's approximation, n n is asymptotically very close to n!, while C n is, up to factors polynomial in n, roughly equal to 4 n . For these reasons, simple asymptotic considerations cannot prove the sequences u n = n n and C n 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 = n i=0 C i C n−i and (n + 2)C n+1 = (4n + 2)C n . Note that these formulas are not of the form of recurrence formulas considered in this work. Additionally, it is known that Catalan numbers C n are not linear recursive (see e.g. [8]), despite having growth 2 O(n) .
Our results. We show that both the sequence of Catalan numbers C n and the sequence u n = n n 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 n n is more algebraic in nature: we show that for every polynomial recursive sequence there exists k ∈ N such that every k consecutive elements of the sequence satisfy a nontrivial polynomial equation. The fact that u n = n n 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 [12,4,7] 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 n n . 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, b n = 1 and b n+1 = (n + 1)b n defines b n = n!. The expressiveness of this class has also been studied and in particular the sequence n n 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 2 p(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: C 0 = 1 and (n + 2)C n+1 = (4n + 2)C n . In Section 7 we discuss the class of rational recurrence sequences that generalises both holonomic and polynomial recursive sequences. On polynomial recursive sequences 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 C n and the sequence u n = n n are not polynomial recursive. We conclude in Section 7. In Appendix 6 we explain in details our corollaries for weighted automata.

Preliminaries
By N we denote the set of nonnegative integers. A sequence over a set D is a function u : N → D; all the sequences considered in this work are over the field of rationals Q. We use the notation u n n∈N for elements of sequences, where u n = u(n). Also, we use bold-face letters as a short-hand for sequences, e.g., u = u n n∈N . We now introduce the two main formalisms for describing sequences: linear recursive sequences and polynomial recursive sequences.

Linear recursive sequences.
for some a 1 , . . . , a k ∈ Q. A sequence of rationals u is a linear recursive sequence if there exist k ∈ N and a k-variate linear form L such that u satisfies the recurrence relation Observe that such a sequence is uniquely determined by the form L and its first k elements: u 0 , . . . , u k−1 ∈ Q. The minimal k for which a description of u as in (3) can be given is called the order of u. For example, Fibonacci numbers are uniquely defined by the recurrence relation f n+2 = f n+1 + f n and starting elements f 0 = 0, f 1 = 1. Note that this recurrence relation corresponds to the linear form L(x 1 , We now present a second definition of linear recursive sequences which, as we will explain, is equivalent to the first definition. Suppose u 1 , u 2 , . . . , u k are sequences of rationals. We say that these sequences satisfy a system of linear recurrence equations if there are k-variate linear forms L 1 , . . . , L k such that: for all n ∈ N. Note that such a system can be equivalently rewritten in the matrix form where u n = (u 1 n , . . . , u k n ) T and M is the k×k matrix over Q such that M x = (L 1 ( x), . . . , L k ( x)) T for all x ∈ Q k . Note that then u n = M n u 0 for all n ∈ 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 1 ([15]). A sequence u is a linear recursive sequence if and only if there exists
k ∈ N and sequences u 1 , . . . , u k that satisfy a system of linear recurrence equations, where u 1 = 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 a n = n 2 . Since (n + 1) 2 = n 2 + 2n + 1, we consider two auxiliary sequences b n = n and c n = 1. The initial values of these sequences are a 0 = b 0 = 0 and c 0 = 1. Thus, a n can be defined by providing these initial values together with a system of linear equations In the matrix form, we could equivalently write that (a n , b n , It can be readily verified that a n is also defined by the recurrence a n+3 = 3a n+2 − 3a n+1 + a n . The difference between the two definitions is that in (3) we have only one sequence, but the depth of the recursion can be any k. Conversely, in (4) we are allowed to have k sequences, but the depth of recursion is 1. The equivalence provided by Proposition 1 is quite convenient and is often used in the literature, see e.g. [20].
We give a short proof of Proposition 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 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 u n+k = L(u n , . . . , u n+k−1 ), where L is a k-variate linear form. Define the sequences u 1 , . . . , u k by setting . . , k} and n ∈ N.
Then u 1 = u and the sequences u 1 , . . . , u k satisfy the system of equations as in (4), where For the right-to-left implication, suppose that there exist k ∈ N and sequences u 1 , . . . , u k that satisfy the system of equations (4) for some linear forms L 1 , . . . , L k , such that u = u 1 . Let M be a k ×k matrix over Q that encodes the linear forms L 1 , . . . , L k ; that is, Observe that R is a linear map from Q k to Q k+1 , hence the image of R is a linear subspace of Q k+1 of co-dimension at least 1. Hence, there exists a nonzero linear form K : Let a 0 , a 1 , . . . , a k ∈ Q be such that Since K is nonzero there exists the largest index t such that a t = 0. From (7) we infer that so u is a linear recursive sequence of order at most t.
? ? ? ??:6 On polynomial recursive sequences Remark 2. One could imagine setting up all the definitions presented above using affine forms instead of linear forms, that is, functions A : Q k → Q of the form where a 1 , . . . , a k , c ∈ 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 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 (4).

Definition 3.
A sequence of rationals u is polynomial recursive (or poly-recursive for short) if there exist k ∈ N, sequences of rationals u 1 , . . . , u k satisfying u = u 1 , and polynomials Again, notice that polynomials P 1 , . . . , P k and the initial values u 1 0 , . . . u k 0 uniquely determine the sequences u 1 , . . . , u k , hence in particular the sequence u = u 1 .
Let us examine a few examples. First, recall the sequences a n = 2 2 n and b n = 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 d 0 = e 0 = 1 and let The polynomials used in the last definition are P 1 (x 1 , x 2 ) = 2x 1 (x 2 ) 2 and P 2 (x 1 , x 2 ) = 2x 2 . Notice that this idea can be easily generalised to define any sequence of the form r Q(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 , b n = n!, d n = 2 n 2 are not linear recursive for simple asymptotic reasons (from the discussion in Section 1).

Simple poly-recursive sequences
The following notion is a natural generalisation of the definition (3) of linear recursive sequences to the setting of recurrences defined using polynomials.
Again, note that if u is simple poly-recursive as above, then the polynomial P and the first k values u 0 , . . . , u k−1 uniquely determine the sequence u.
Clearly, every linear recursive sequence is a simple poly-recursive sequence. In fact, by Proposition 1 and Remark 2, 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 1 shows that every simple poly-recursive sequence is poly-recursive. We now prove that this inclusion is strict.
Let us write 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 ∈ N such that Thus, for all n > 2c we have Since by (10) it follows that using (11) we may conclude that for all n > 2c the following inequality holds: 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 numberb n := bn m = n! m is an integer. Furthermore, we have thatb n dividesb n for all n n. Since every monomial in the expansion of Q has total degree at least 2, we infer that for all n > m, we have By combining (13) with the left inequality of (12), we conclude that for all n > max(2c, m), This bound together with the right inequality of (12) implies that This inequality, however, is not true for every sufficiently large n, a contradiction.

Modular periodicity
Recall that a sequence of numbers r is ultimately periodic if there exist N, k ∈ N such that for all n N , we have r n = r n+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 6. Suppose u is a poly-recursive sequence of integers. Then there exists a ∈ N such that for every prime p > a, the sequence r n := u n mod p is ultimately periodic.
Proof. Let u be defined by the system of recursive equations where u 1 , . . . , u k are sequences such that u 1 = u and P 1 , . . . , Without loss of generality we may assume that the initial values u 1 0 , . . . , u k 0 are integers. Indeed, this is certainly the case for u 1 0 = u 0 , while for every i > 1, we may rewrite the system so that it uses the sequence u i = q i · u i instead of u i , where q i is the denominator of u i 0 . For this, the starting condition for u i can be set as u i 0 = q i · u i 0 , which is an integer, in all polynomials P 1 , . . . , P k we may substitute x i with x i /q i , and the polynomial P i can be replaced with q i · P i .
Further, without loss of generality we may assume that all the monomials present in the expansions of all the polynomials P 1 , . . . , P k have the same total degree d > 1. Indeed, let d > 1 be any integer that is not smaller than the degrees of all the polynomials P 1 , . . . , P k . To the system (14) we add a new sequence u k+1 , defined by setting Thus u k+1 is constantly equal to 1. Then each monomial M (x 1 , . . . , x k ) appearing in the expansion of any of the polynomials P i (x 1 , . . . , x k ) can be replaced by the monomial where t is the total degree of M . It is straightforward to see that the modified system of recursive equations still defines u = u 1 , 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 ∈ N be a positive integer such that the polynomials P i := a · P i all belong to Z[x 1 , . . . , 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 P 1 , . . . , P k . For all i ∈ {1, . . . , k} and n ∈ N, let us definẽ By a straightforward induction we show that the sequencesũ 1 , . . . ,ũ k satisfy the system of recursive equations Indeed, the induction base is trivial and for the induction step recall that all monomials have the same degree d, hencẽ Observe that since the initial valuesũ i 0 = u i 0 are integers, and the polynomialsP i have integer coefficients, we can infer that all the entries of sequencesũ 1 , . . . ,ũ k are integers.
We now show that for every prime p > a, the sequence r defined as r n = u n mod p is ultimately periodic; this will conclude the proof. For every i ∈ {1, . . . , k} and n ∈ N, let r i n :=ũ i n mod p.
By (15) and the fact that polynomialsP i have integer coefficients, for every n ∈ N the vector of entries (r 1 n+1 , . . . ,r k n+1 ) is uniquely determined by the vector (r 1 n , . . . ,r k n ). Since this vector may take only at most p k different values, it follows that the sequencesr 1 , . . . ,r k are ultimately periodic. Now note that for every n ∈ N, we have 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 Observe that the sequence b n = b hence the sequence (b n mod p) is ultimately periodic. Sincer 1 is ultimately periodic as well, from (16) we conclude that the sequence r is ultimately periodic.
We use Theorem 6 to prove that the Catalan numbers are not poly-recursive. Recall that the nth Catalan number C n is given by the formula C n = 1 n+1 2n n . 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 C n 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 C n consisting of entries divisible by p. The p-blocks can be naturally ordered along the sequence C n , so let L p k be the length of the kth p-block. Then Alter and Kubota proved the following.

Theorem 7 ([2]). For every prime p > 3 and k 1, we have
where m is the largest integer such that p+1 2 m divides k.
Note that Theorem 7 in particular implies that for every prime p > 3, the sequence C n contains arbitrary long p-blocks. This means that C n taken modulo p cannot be ultimately periodic. By combining this with Theorem 6, we conclude the following. 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 9.
A sequence of rationals u admits a cancelling polynomial if there exist k ∈ N and a nonzero polynomial P ∈ Q[x 0 , . . . , x k ] such that P (u n , u n+1 , . . . , u n+k ) = 0 for all n ∈ N.
Remark 10. A cancelling polynomial P can be always assumed to have integer coefficients, i.e. to belong to Z[x 0 , . . . , 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 4) in the following sense: a sequence is simple polyrecursive if and only if it admits a cancelling polynomial P (x 0 , . . . , x k ) whose expansion into a sum of monomials involves only one term containing x k , namely the monomial x k itself. This particular form of the considered algebraic constraint was vitally used in the proof of Proposition 5, where we showed that the sequence b n = n! is not simple poly-recursive. In fact, if one drops this restriction, then it is easy to see that the sequence b n = n! actually admits a cancelling polynomial: for instance P (x 0 , x 1 , We now prove that the above example is not a coincidence.

Theorem 11. Every poly-recursive sequence admits a cancelling polynomial.
Proof. The proof follows the same basic idea as the proof of Proposition 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 K ⊆ L is a field extension, then elements a 1 , . . . , a k ∈ L are algebraically dependent over K if there is a nonzero polynomial P ∈ K[x 1 , . . . , x k ] such that P (a 1 , . . . , a k ) = 0 in L. We will use the following well-known fact; see e.g. [18, Chapter VIII, Theorem 1.1]. Claim 12. If K is a field and k ∈ N, then in the field of rational expressions K(x 1 , . . . , x k ) every k + 1 elements are algebraically dependent over K.
We proceed to the proof of the theorem. Let u be the poly-recursive sequence in question. By definition, for some k ∈ N there are sequences u 1 , . . . , u k and polynomials P 1 , . . . , P k ∈ Q[x 1 , . . . , x k ] such that for all n ∈ N, We inductively define polynomials P The following claim follows from the construction by a straightforward induction. By Claim 12, these polynomials (treated as elements of Q(x 1 , . . . , x k )) are algebraically dependent over Q, so there exists a nonzero polynomial Q ∈ Q[y 0 , y 1 , . . . , y k ] such that the polynomial 1 (x 1 , . . . , x k ), . . . , P (k) . . . , x k )) is identically zero. It now remains to observe that by Claim 13, for every n ∈ N we have hence Q is a cancelling polynomial for u.

Remark 14.
Notice that a given polynomial can be the cancelling polynomial of many different sequences. For example, the polynomial (x 0 ) 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 numbers p, and thus are not poly-recursive by Theorem 6. Hence, the converse direction of Theorem 11 does not hold.
We now present an application of Theorem 11 by showing that the sequence u n = n n is not poly-recursive. By Theorem 11, 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 n n sequence turns out to be a somewhat challenging task.
We first observe that when we apply a multivariate polynomial to consecutive entries of u n , we can rewrite the result in another form: Proof. By expanding Z as a sum of monomials, we may write where for all i ∈ {1, . . . , m}, c i = 0 and are pairwise different monomials. Now observe that for every n ∈ N, we have ? ? ? ??:12

On polynomial recursive sequences
Hence, if we define then, by (17) and (18), we conclude that Z n n , (n + 1) n+1 , . . . , as required. It now suffices to observe that (1) all polynomials P i and Q i are nonzero, because c i = 0 and the monomial M i is nonzero, and (2) the polynomials P i are pairwise different, because they have pairwise different multisets of roots.
With Lemma 15 established, we move to the main result of this section.
Theorem 16. The sequence u n = n n is not poly-recursive.
Proof. Suppose, for the sake of contradiction, that the sequence u n = n n is poly-recursive. By Theorem 11 and Remark 10, there exists a nonzero polynomial Z ∈ Z[x 0 , x 1 , . . . , x k ] that is cancelling for u n . By Lemma 15, we can find nonzero polynomials P 1 , . . . , P m , This system of equations seems somewhat unwieldy due to the presence of the term P i (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 equations (19) modulo any prime, then the bases and the exponents of these terms can be made independent.
Claim 17. For every prime p and all a, b ∈ Z where b > 0, it holds that Proof. Since p and p − 1 are coprime, there is an n ∈ Z such that n ≡ a mod p and n ≡ b mod p − 1. Thus for any 1 i m: the second part holding by Fermat's Little Theorem. The claim now follows by considering equality (19) modulo p.
Let a ∈ N and let D a = [d ij ] 1 i,j m be the m × m matrix defined by d ij = P j (a) i . Since this is essentially a Vandermonde matrix, its determinant has a simple expression, as expressed in the following claim.
Then S is nonzero and det(D a ) = S(a).
Proof. That S is nonzero follows from the fact that the polynomials P i are all nonzero and pairwise different. Now observe that D a is a Vandermonde matrix with columns consisting of consecutive powers of P j (a), for 1 j m, where additionally every jth column is multiplied by P j (a). It is well known that the determinant of the Vandermonde matrix [P j (a) i−1 ] 1 i,j m is Further, multiplying the jth column by P j (a), for all j, results in the determinant being multiplied by m i=1 P i (a). This proves the claim.
We will need the following classical definition.
This means that for every prime p and every 1 i m, the following assertion holds: every a ∈ F p is a zero of the polynomial S · Q i considered as a polynomial over F p . Recall that the polynomials S, Q 1 , . . . , Q m ∈ Z[x] are nonzero. Consider a prime p that is larger than every coefficient occurring in the expansion of the polynomials S, Q 1 , . . . , Q m into sums of monomials, and that is further larger than deg(S) + max j∈{1,...,m} deg(Q j ). Then the polynomials S, Q 1 , . . . , Q m are nonzero even when regarded as polynomials over F p , hence the same can be said also about the polynomials S · Q i , for all 1 i m. However, by (20), for every 1 i m the polynomial S · Q i has at least p > deg(S) + deg(Q i ) roots over F p . This is a contradiction.

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]  I and F are the initial and the final vector in S d , respectively. In this paper we only consider the semiring S = Q. A weighted automaton defines a function A : Σ * → S as follows: if w = a 1 . . . a n ∈ Σ * , then Note that when |Σ| = 1, this definition coincides with (the matrix form of) the definition (4) of linear recursive sequences. Assuming |Σ| = 1, one can identify each word with its length, which means that a weighted automaton defines a sequence A : N → 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 : Σ * → 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 : N → 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 [21,4,7]. To avoid technical details, we simply observe that CRAs over unary alphabets recognize exactly poly-recursive sequences, as defined in Definition 3. Since [21,4,7] discuss several variants of CRAs, to avoid ambiguity we refer to the definition of a CRA that can be found in [19] 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 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 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 Q.
Consider the grammar with one nonterminal X (which is also the starting nonterminal) and one terminal a with the following rules: X → a, X → aXX. Both rules are assigned weight 1. Therefore, for every word a n the output is the number of derivation trees. It is easy to see that if we denote the output on the word a n by C n , then C 0 = 1 and C n+1 = n i=0 C i C n−i for all n ∈ N, hence C n is just the nth Catalan number. This proves that Catalan numbers can be defined by a unary-alphabet WCFG over Q. By Corollary 8, we can now conclude the following. Corollary 20. The class of sequences definable by unary-alphabet WCFGs over Q is not contained in the class of sequences recognizable by unary-alphabet CRAs over 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 S = Q. Similarly as for weighted automata, every WMSO formula ϕ over Q defines a function ϕ : Σ * → Q. As for atomic formulas, every c ∈ Q is an atomic formula that defines the constant function c (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 x and the product quantifier x . Then for all w = a 1 . . . a n ∈ Σ * , and similarly for x ϕ (w). For example, x 1 (a n ) = n. It follows that x y 1 (a n ) = n n .
This proves that the sequence n n can be defined in unary-alphabet WMSO over Q, so by Theorem 16 we may conclude the following.

Corollary 21.
The class of sequences definable in unary-alphabet WMSO over Q is not contained in the class of sequences recognizable by unary-alphabet CRAs over Q.

Conclusion
We proved that two sequences, the Catalan numbers C n and u n = n n , 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. Going further than poly-recursive sequences, one can consider the class of rational recursive sequences. These are specified like polynomial recursive sequences (Definition 3) but on the right hand side of the system of equations (8) we allow the P i 's to be taken from the field of fractions of the polynomial ring. That is, each P i is of the form P i (x 1 , . . . , x k ) = Qi(x1,...,x k ) Ri(x1,...,x k ) , where Q i , R i ∈ Q[x 1 , . . . , x k ] and R i = 0.
This class extends both poly-recursive sequences and holonomic sequences (see Section 1). For example one can express the sequence of Catalan numbers, since C n+1 = 4n+2 n+2 · C n and an ancillary sequence can hold the value n. On the other hand, the proof of the existence of cancelling polynomials for poly-recursive sequences (Theorem 11) carries over to rational recursive sequences. In particular, u n = n n is not even rational recursive.
This discussion points to the notion of rational recursive sequences as a natural object for future research.