A Robust Class of Linear Recurrence Sequences
Corentin Barloy, Nathanaël Fijalkow, Nathan Lhote, Filip Mazowiecki
AA Robust Class of Linear Recurrence Sequences
Corentin Barloy
École Normale Supérieure de Paris, France
Nathanaël Fijalkow
CNRS, LaBRI, Bordeaux, France, and the Alan Turing Institute of data science, London,United Kingdom
Nathan Lhote
University of Warsaw, Poland
Filip Mazowiecki
LaBRI, Université de Bordeaux, France
Abstract
We introduce a subclass of linear recurrence sequences which we call poly-rational sequencesbecause they are denoted by rational expressions closed under sum and product. We showthat this class is robust by giving several characterisations: polynomially ambiguous weightedautomata, copyless cost-register automata, rational formal series, and linear recurrence sequenceswhose eigenvalues are roots of rational numbers.
F.1.1 Models of Computation
Keywords and phrases linear recurrence sequences, weighted automata, cost-register automata
Digital Object Identifier
The study of sequences of numbers originated in mathematics and has deep connectionswith many fields. A prominent class of sequences is linear recurrence sequences , such as theFibonacci sequence0 , , , , , , , , . . . Despite the simplicity of linear recurrence sequences many problems related to them remainopen, and are the object of active research. In theoretical computer science the two mainquestions are:How to finitely represent sequences?How to algorithmically analyse properties of sequences?In this paper we focus on problems related to the first question. The question ofrepresentation has led to important insights in the structure of linear recurrence sequencesby giving several equivalent characterisations, some of which we briefly review here. We referto Section 2 and the next sections for technical definitions.
Linear recurrence sequences
A sequence of real numbers u = h u n i n ∈ N = h u , u , u , . . . i is a linear recurrence system (LRS) if there exist real numbers a , . . . , a k such that for all n ≥ u n + k = a u n + k − + . . . + a k u n . (1) © C. Barloy and N. Fijalkow and N. Lhote and F. Mazowiecki;licensed under Creative Commons License CC-BY42nd Conference on Very Important Topics (CVIT 2016).Editors: John Q. Open and Joan R. Access; Article No. 23; pp. 23:1–23:16Leibniz International Proceedings in InformaticsSchloss Dagstuhl – Leibniz-Zentrum für Informatik, Dagstuhl Publishing, Germany a r X i v : . [ c s . F L ] A ug In this paper we will consider only sequences of rational numbers, therefore, we additionallyassume that a i are rational numbers. The smallest k for which u satisfies an equation ofthe form (1) is called the order of u . The Fibonacci sequence h F n i n ∈ N is an LRS of order 2satisfying the recurrence F n +2 = F n +1 + F n . Rational expressions
Studying the closure properties of linear recurrence sequences yieldsthe following result, an instance of the Kleene-Schützenberger theorem [19]: linear recurrencesequences form the smallest class of sequences containing the sequences h a, , , . . . i for arational number a and closed under sum, Cauchy product, and Kleene star. Weighted automata
The model of weighted automata is a well studied quantitative exten-sion of classical automata. In general a weighted automaton recognises a function f : Σ ∗ → R ,hence when considering a unary alphabet this becomes f : { a } ∗ → R , and identifying { a } ∗ with N we can see f as a sequence of numbers. Whenever we write about sequences recognisedby models like weighted automata, we implicitly assume that these are over a unary alphabet. Cost-register automata
Several characterisations of weighted automata have been intro-duced [5, 11, 3]. We will be interested in the model of cost-register automata (CRA). Theseare deterministic models with registers whose contents are blindly updated (i.e., withouttransitions like zero tests). It was shown that considering linear updates yields a modelequivalent to weighted automata.We summarise in one theorem the equivalences above, which is the starting point of ourwork. Technical definitions are given in the paper. (cid:73)
Theorem 1 (Folklore, see for instance [4, 19, 6]) . The following classes of sequences areeffectively equivalent.Linear recurrence sequences,Sequences recognised by weighted automata,Sequences recognised by linear cost-register automata,Sequences denoted by rational expressions,Sequences whose formal series are rational, i.e. of the form PQ where P, Q are polynomials.
Algorithmic analysis of linear recurrence sequences
The questions regarding algorithmic analysis are far from being answered. A very simpleand natural problem, the Skolem problem, is still unsolved [20, 17]: given a linear recurrencesequence, does it contain a zero? Recent breakthrough results sharpened our understandingof the Skolem problem [15, 16], but one of the outcomes is that the general problem for thewhole class of linear recurrence sequences is beyond our reach at the moment, since it wouldimpact notoriously difficult problems from number theory. We refer the reader to the recentsurvey about what is known to be decidable for linear recurrence sequences [17].
Our contributions
Since the full class of linear recurrence sequences is too hard to be algorithmically analysed(we only mentioned the Skolem problem but many related problems are also difficult), let usrevise our ambitions, go back to the drawing board, and study tractable subclasses.In this paper we introduce poly-rational sequences which is a strict fragment of linearrecurrence sequences. We give several equivalent characterisations of this class following . Barloy et al. 23:3 the equivalence results stated in Theorem 1. Our results are summarised in the followingtheorem. (cid:73)
Theorem 2.
The following classes of sequences are effectively equivalent.Sequences denoted by poly-rational expressions (Section 2),Sequences recognised by polynomially ambiguous weighted automata (Section 3),Sequences recognised by copyless cost-register automata (Section 4),Sequences whose formal series are of the form PQ where P, Q are polynomials and theroots of Q are roots of rational numbers (Section 5),Linear recurrence sequences whose eigenvalues are roots of rational numbers (Section 5). We do not discuss the efficiency of reductions proving the equivalences. Our constructionsare elementary, and in most cases they yield blow ups in the size of representation.We note that the Skolem problem and its variants are known to be decidable, and NP-hard,for the subclass of poly-rational sequences. The decidability easily follows from the fact thatour class is subsumed by other classes for which such results were obtained (see e.g. [18], forthe case where all eigenvalues are roots of algebraic real numbers). The Skolem problem isknown to be NP-hard already for the class of LRS whose eigenvalues are roots of unity [1].This implies that the Skolem problem for the class of poly-rational sequences is also NP-hard,which is the best known lower bound even for the full class of linear recurrence sequences.
Related works
The intractability of the Skolem problem for linear recurrence sequences also impacts theother equivalent models, leading to the study of several restrictions. A classical approachto tame weighted automata is to bound the ambiguity of weighted automata, i.e. boundingthe number of accepting runs with a function depending on the length of the word. Manypositive results have been obtained in the past years following this approach [10, 9, 7].Another restriction studied in the model of cost-register automata is the copyless restric-tion: registers are not allowed to be copied more than once. It was conjectured that thecopyless restriction would result in good decidability properties [3], but this has been recentlyfalsified [2].
We let u = h u n i n ∈ N = h u , u , u . . . i denote a sequence of rational numbers. Linear recurrence sequences
We will assume that an LRS u is given by the numbers a , . . . , a k and the values of the first k elements: u , . . . , u k − . The recurrence (1) induces the sequence u . We let LRS denotethe class of LRS. Given an LRS we define its characteristic polynomial as Q ( x ) = x k − a x k − − . . . − a k − x − a k . The roots of the characteristic polynomial are called the eigenvalues of the LRS.
Formal series
Formal series are a different representation for sequences. The sequence h u n i n ∈ N inducesthe formal series S ( x ) = P n ∈ N u n x n , with the interpretation that the coefficient of x n is the C V I T 2 0 1 6 value of the n -th element in the sequence. Note that a polynomial represents a sequencewith a finite support. (cid:73) Example 3.
A standard example of an LRS is the Fibonacci sequence h F n i n ∈ N definedby the recurrence F n +2 = F n +1 + F n and initial values F = 0 , F = 1. Its characteristicpolynomial is p ( x ) = x − x −
1, whose roots are √ and −√ . The corresponding formalseries is S ( x ) = P ∞ n =0 F n x n . Using the definition of F we obtain S ( x ) = x + xS ( x ) + x S ( x )and thus S ( x ) = x − x − x . Rational expressions
We start by defining three classes of sequences.
Fin : a sequence u is in Fin , or equivalently u has finite support, if the set { n ∈ N : u n = 0 } is finite; Arith : a sequence u is in Arith , or equivalently u is arithmetic, if u = a , u n +1 = u n + b for some rational numbers a, b ; Geo : a sequence u is in Geo , or equivalent u is geometric, if u = a , u n +1 = λ · u n , forsome rational numbers a, λ .We let Geo λ denote the class of geometric sequences with a fixed parameter λ .We now define some classical operators. Here u , v , u , . . . , u k are sequences. Sum : u + v is the component wise sum of sequences; Cauchy product : u · v = h P p + q = n u p · v q i n ∈ N ; inducing ( u ) n defined by ( u ) = h , , , , . . . i and ( u ) n +1 = ( u ) n · u , in particular ( u ) = u ; Kleene star : ( u ) ∗ = P n ∈ N ( u ) n , it is only defined when u = 0; Hadamard product : u × v is the component wise product of sequences; Shift : h a, u i = h a, u , u , . . . i , defined for any rational number a ; Shuffle : shuffle( u , u , . . . , u k ) = h u , u , . . . , u k , u , u , . . . , u k , u , . . . i .We write Rat [ C , op , . . . , op k ] for the smallest class of sequences containing C and closedunder the operators op , . . . , op k . Rational expressions in Theorem 1 are classically definedas follows [19]: Rat = Rat [ Fin , + , · , ∗ ] . The class
Rat contains all classes defined above, and is closed under all mentioned operators,i.e.
Rat = Rat [ Fin ∪ Arith ∪ Geo , + , · , ∗ , × , shift , shuffle] . We now introduce a class of sequences denoted by a fragment of rational expressions,whose study is the purpose of this article. The class is called poly-rational sequences, becausethey are denoted by rational expressions using sum and product. (cid:73)
Definition 4 (Poly-rational sequences) . PolyRat = Rat [ Arith ∪ Geo , + , × , shift , shuffle] . In other words
PolyRat is the smallest class of sequences containing arithmetic and geometricsequences that is closed under sum, Hadarmard product, shift, and shuffle. A trivialobservation is that
Fin ⊆ PolyRat since using shift one can generate any sequence withfinite support. One could try to simplify the definition of
PolyRat replacing
Arith ∪ Geo . Barloy et al. 23:5 with
Fin . Unfortunately, the operators + , × , shift , shuffle are too restricted, and geometricand arithmetic sequences could not be generated. In fact, the class would collapse to Fin .Since
Rat contains
Arith and
Geo and is closed under Hadamard product, shift, andshuffle, we have
PolyRat ⊆ Rat . We will show that the inclusion is indeed strict. As we willsee in this paper, the class
PolyRat has many equivalent and surprising characterisations.
We refer to e.g. [6] for an excellent introduction to weighted automata. We consider weightedautomata over the rational semiring ( Q , + , · ), where + and · are the standard sum andproduct. For an alphabet Σ, weighted automata recognise functions assigning rationalnumbers to finite words, i.e. f : Σ ∗ → Q . In this paper we will consider only one-letteralphabets so the set of words is { a } ∗ = (cid:8) ε, a, a , . . . (cid:9) , which is identified with N . Therefore,weighted automata recognise functions f : N → Q , i.e. weighted automata recognise sequencesof rational numbers.Formally, a weighted automaton is a tuple A = ( Q, M, I, F ), where Q is a finite set ofstates, M is a Q × Q matrix over Q and I, F are the initial and final vectors, respectively,of dimension Q (for convenience we label the coordinates by elements of Q ). The sequencerecognised by the automaton A is (cid:74) A (cid:75) defined by (cid:74) A (cid:75) ( n ) = I t M n F , where I t is the transposeof I .We give an equivalent definition of A in terms of accepting runs. We say that a state q ∈ Q is an initial state if I ( q ) = 0 and that it is a final state if F ( q ) = 0. If q is initial wesay that its initial weight is I ( q ), and if q is final then its final weight is F ( q ). For two states p, q ∈ Q we say that there is a transition from p to q if M ( p, q ) = 0. Such a transition isdenoted p → q and its weights is M ( p, q ). A run ρ is a sequence of consecutive transitions,and it is accepting if the first state is initial and the last state is final. The value of anaccepting run ρ = q → q → · · · → q n is | ρ | = I ( q ) · n − Y i =0 M ( q i , q i +1 ) ! · F ( q n ) . Let
Runs A ( n ) denote the set of all accepting runs of length n . An alternative and equivalentdefinition of (cid:74) A (cid:75) is (cid:74) A (cid:75) ( n ) = X ρ ∈ Runs A ( n ) | ρ | . (cid:73) Example 5.
Consider the automaton A = ( Q, M, I, F ) represented in Figure 1. We have (cid:74) A (cid:75) ( n ) = F n , where h F n i n ∈ N is the Fibonacci sequence from Example 3. Figure 1
A weighted automaton recognising the Fibonacci sequence.
The ambiguity of an automaton A is the function a A : N → N which associates to n thenumber of accepting runs | Runs A ( n ) | . We consider the following classes: C V I T 2 0 1 6
DetWA – the class of deterministic weighted automata; kWA for fixed k ∈ N – the class of k -ambiguous weighted automata, i.e. when a A ( n ) ≤ k for all n ; FinWA = S k ∈ N kWA – the class of finitely ambiguous weighted automata, i.e. whenthere exists k such that a A ( n ) ≤ k for all n ; PolyWA – class of polynomially ambiguous automata, i.e. when there exists a polynomial P : N → N such that a A ( n ) ≤ P ( n ) for all n ; WA – the full class of weighted automata.For example, the automaton in Example 5 is not polynomially ambiguous because thenumber of accepting runs is exponential. We will see that this is no accident by proving inSection 5 that the Fibonacci sequence is not in PolyWA .We present our first characterisation of
PolyRat . (cid:73) Theorem 6.
PolyRat = PolyWA
Proof of Theorem 6
This subsection is divided into two parts for both inclusions.
PolyRat ⊆ PolyWA
Figure 2 shows how to recognise the arithmetic and the geometric sequences. For each finitely
Figure 2
The weighted automaton on the left recognises the arithmetic sequence with parameters( a, b ) and it is linearly ambiguous. The weighted automaton on the right recognises the geometricsequence with parameters a, λ and it is deterministic. supported sequence a simple weighted automaton can be constructed. It remains to provethat the class
PolyWA is closed under the operators. The sum and products correspondto union and product of automata, it is readily verified that these standard constructionspreserve the polynomial ambiguity. Below we deal with shift and shuffle operators.Suppose we have a polynomially ambiguous automaton A for u and we want to constructa new polynomially ambiguous automaton A for h a, u i . We start with the case when a = 0.Then A has the same state as A plus one new state q , which is the only initial state in A . All transitions from A are inherited. There are additionally only outgoing transitionsfrom q to all states that are initial in A ; the weight of the transition is the initial weight ofthe corresponding state in A . It is readily verified that A recognises h , u i and that A ispolynomially ambiguous. For a = 0 it suffices to add one more state that is both initial andfinal with initial weight 1 and final weight a .To deal with shuffle we start with the following preliminary construction. Fix some k > A recognising u . We construct A [ k ] recognising . Barloy et al. 23:7 u = h u , , . . . , | {z } k , u , , . . . , | {z } k , u , . . . i , i.e. elements u i are separated by k − A is that the set of states have an additional component { , . . . , k − } ,and they behave like A every k -th step; in the remaining steps they only wait. Formally,the set of states of A [ k ] is Q × { , . . . , k − } , where Q is the set of states of A . The initial(final) states are ( q,
0) such that q is initial (final) in A with the same weight. For everytransition p → q in A there is a transition ( p, → ( q,
1) in A [ k ] with the same weight. Theremaining transitions are ( q, i ) → ( q, ( i + 1) mod k ) with weight 1, defined for every i > q ∈ Q . It is readily verified that A [ k ] recognises u .Let A , . . . , A k − be polynomially ambiguous automata recognising u , . . . , u k − . Forevery A i let A i [ k ] be an automaton as above, additionally shifted i times with 0’s. Thenshuffle( u , . . . , u k − ) is recognised by the disjoint union of A i [ k ]. PolyWA ⊆ PolyRat
The first step is to decompose polynomially ambiguous automata into a union of automatathat we will call chained loops . We say that the states p , p , . . . p k − ∈ Q form a loop if M ( p i , p j ) = 0 is equivalent to j = i + 1 mod k and a path if M ( p i , p j ) = 0 is equivalent to j = i + 1 (in particular p k − has no successor). A chained loop of size k is an automatonover the set states of { q , . . . , q k − } ∪ P such that q is the unique initial state; q , . . . , q k − form a path;each q i is contained in at most one loop (the states in P are used only as intermediatestates in the loops); q k − is the unique final state with F ( q k − ) = 1.We define the concatenation of two chained loops A , A : this is the chained loop obtainedby constructing the union of the two automata with the initial state being the initial state of A , the final state being the final state of A , and rewiring the output of A to the initialstate of A , see e.g. Figure 3. Figure 3
Three example chained loops. The initial and final weights are depicted by ingoing andoutgoing edges. The chained loop A recognises the sequence defined by f (2 n ) = 2 · n , f (2 n +1) = 0whose power series is − x . The chained loop A recognises the sequence f ( n ) = 5 n +1 whosepower series is − x . The chained loop A is the concatenation of A and A and it recognises thesequence f ( n ) = P ni =1 f ( i − · f ( n − i ) whose power series is x (1 − x )(1 − x ) . (cid:73) Lemma 7.
Any polynomially ambiguous weighted automaton is equivalent to a union ofchained loops.
Proof.
Let A be a polynomially ambiguous weighted automaton. Without loss of generality A is trimmed, i.e. every state occurs in at least one accepting run. C V I T 2 0 1 6
We first note that any state in A is contained in at most one loop. Indeed, a statecontained in two loops induces a sequence of words with exponential ambiguity. This impliesthat a sequence ( q , q , . . . , q k ) with q i = q j for i = j induces at most one chained loop ofwhich it is the path. There are finitely many such sequences because k < |A| .We claim that A is equivalent to the union of all chained loops induced by such sequences.Indeed, there is a bijection between the runs of A and the runs of all the chained loops,respecting the values of runs. Consider a run ρ of A , where a state q appears multiple times.Then between each occurence of q this is the same run, because they are loops over q andthere can be only one loop containing q . So ρ = uv k w , where v is the (only) loop containing q . Repeating this for u and w , we obtain a unique decomposition of ρ into q · ‘ m · q → q · ‘ m · q → q . . . q k · ‘ m k n · q k , where ‘ i is a loop over q i (we can have m i = 0) and q i = q j for i = j . (cid:74) Our aim is to use the decomposition result stated in Lemma 7 to prove the inclusion
PolyWA ⊆ PolyRat . It will be convenient for reasoning to use formal series. (cid:73)
Lemma 8.
The formal series induced by a chained loop of size is of the form α − λx ‘ , where α = I ( q ) , λ is the product of the weights in the loop and ‘ is the length of the loop. If there is noloop this reduces to α .Let S , S be the formal series induced by the chained loops A and A , then the formalseries induced by the concatenation of A and A is x · S · S .Let S , S be the formal series induced by two automata A and A , then the formalseries induced by the union of A and A is S + S . Proof.
The first and the third item are immediate, we focus on the second. For conveniencelet us assume that A ( −
1) = 0. By definition the concatenation of two chained loopsrecognises the sequence defined by (cid:74) A (cid:75) ( n ) = n X i =0 (cid:74) A (cid:75) ( i − · (cid:74) A (cid:75) ( n − i )since an accepting run in the concatenation is the concatenation of an accepting run in A and an accepting run in A . The only issue is that the output state of A was changed intoa transition, and to include this step we write A ( i −
1) instead of A ( i ). Hence the formalseries is indeed the Cauchy product of S and S , shifted by one. (cid:74) We are now half-way through the proof of the inclusion
PolyWA ⊆ PolyRat : thanks toLemma 7, we can restrict our attention to unions of chained loops, and thanks to Lemma 8,we know what are the formal series induced by the sequences computed by such automata.More specifically, they are obtained from formal series of the form α − λx ‘ by taking sums andCauchy products (with an additional shift).To prove that PolyRat contains such sequences it is tempting to attempt showing thatthe sequences above are in
PolyRat and the closure of
PolyRat under sums and Cauchyproducts. Unfortunately, the closure under Cauchy product is not clear (although it willfollow from the final result that it indeed holds).We sidestep this issue by observing that we only need to be able to do Cauchy productsof formal series of a special form. Indeed, the formal series described above are of the form PQ where P, Q are rational polynomials and the roots of Q are roots of rational numbers: this . Barloy et al. 23:9 is true of α − λx ‘ and is clearly closed under sums and Cauchy products (with the additionalshift).Notice that every chained loop can be obtained as concatenations of chained loops ofsize 1. Thus Lemma 8 gives a characterisation of formal series corresponding to unions ofchained loops: these are sums of products of α − λx ‘ and polynomials. We further simplifythis characterisation applying the following lemma. (cid:73) Lemma 9.
Consider the formal series PQ where P, Q are rational polynomials and the rootsof Q are roots of rational numbers. Then PQ can be written as the sum of formal series of theform R (1 − λx ‘ ) k for rational polynomials R , rational numbers λ , and ‘, k natural numbers. Proof.
This is a direct consequence of the fact that Q [ x ] is a Euclidean ring. The exactstatement following from this is that any product Q ni =1 R i P i where the polynomials P i aremutually prime (meaning, for each i , the polynomials P i and Q j = i P j are coprime) can bewritten as a sum of Q i P i for some rational polynomials Q i .To conclude, we observe that any polynomial whose roots are roots of rational numberscan be written as a product of mutually prime polynomials of the form (1 − λx ‘ ) k . (cid:74) By Lemma 8 and Lemma 9 it follows that for every finite union of chained loops its formalseries is a sum of R (1 − λx ‘ ) k for rational polynomials R , rational numbers λ , and ‘, k naturalnumbers. Combining this with Lemma 7 we get that the formal series computed by PolyWA are of the same form. Thus we have reduced proving the inclusion
PolyWA ⊆ PolyRat toproving that sequences whose formal series are sums of formal series of the form R (1 − λx ‘ ) k arein PolyRat .Since
PolyRat is closed under sum, it suffices to consider one such formal series. Moreover,due to the closure under shifts we can assume that the polynomial R is equal to 1; as statedin the lemma below. (cid:73) Lemma 10.
The sequence whose formal series is − λx ‘ ) k is in PolyRat . Proof.
We know that1(1 − λx ‘ ) k = X n ∈ N (cid:18) n + k − k (cid:19) λ n x ‘ · n . Note that (cid:0) n + k − k (cid:1) is a polynomial in n of degree at most k , i.e. (cid:0) n + k − k (cid:1) = P kp =0 a p n p . Itfollows that1(1 − λx ‘ ) k = k X p =0 a p · X n ∈ N n p λ n x ‘ · n It is enough to prove that for each p the sequence whose formal series is X n ∈ N a p n p λ n x ‘ · n is in PolyRat . Using an arithmetic sequence and Hadamard products we construct h a p n p i n ∈ N . Multiplying it using Hadamard product with the geometric sequence h λ n i n ∈ N yields h a p n p λ n i n ∈ N . Shuffling the obtained sequence with ‘ − (cid:74) C V I T 2 0 1 6
Figure 4
The strict ambiguous hierarchy of weighted automata.
We show that the natural classes of weighted automata defined by ambiguity can be describedusing subclasses of rational expressions. (cid:73)
Lemma 11.
DetWA = S λ ∈ Q Rat [ Geo λ , shift , shuffle ] ; FinWA = Rat [ Geo , + , shift , shuffle ] . Proof.
We start by proving
DetWA = S λ ∈ Q Rat [ Geo λ , shift , shuffle].( ⊆ ) Since the automaton is deterministic it has a shape of a lasso, i.e. the states can bepartitioned into a path such that the last state on the path is in a loop. Let λ be the valueobtained by multiplying all values on the loop, let l be the length of the loop and let m bethe length of the path. Then it is easy to see that the sequence is obtained by first taking ashuffle of l sequences in Geo λ and then shifting it m times.( ⊇ ) We already know that Geo λ are definable by deterministic weighted automata fromFigure 2. Closure under shift follows from the construction in the proof of PolyRat ⊆ PolyWA because it preserves the property of being deterministic. The shuffle constructionpreserves this property only up to a certain point. The construction of each automaton A i [ k ]is deterministic but taking their sum does not yield explicitly a deterministic automaton. Itsuffices to observe that by construction A i [ k ] are all lasso automata with the same lengthsof the loop. Moreover, every word is accepted by at most one A i [ k ]. To define the finalautomaton consider A i [ k ] with the longest path. The final automaton will be A i [ k ] withmodified transitions and final outputs. Indeed we add other automata one by one, and forevery accepting state we readjust the ingoing and outgoing transitions to give the correctvalue.Proof of FinWA = Rat [ Geo , + , shift , shuffle].( ⊆ ) By Lemma 7 we know that each automaton in FinWA is a union of chained loops.It is easy to see that every such chained loop has to be a lasso otherwise it will contradict theassumption that the automaton is finitely ambiguous. Then the construction follows by doingthe construction for every lasso as in the proof of
DetWA = S λ ∈ Q Rat [ Geo λ , shift , shuffle]and using + to deal with the union. . Barloy et al. 23:11 ( ⊇ ) This follows the same steps as the proof of DetWA = S λ ∈ Q Rat [ Geo λ , shift , shuffle].It is even simpler because we can take a union of two automata and remain in the class of FinWA . (cid:74) We give examples witnessing the strict inclusions
DetWA (cid:40)
FinWA (cid:40)
PolyWA (cid:40) WA and kWA (cid:40) ( k + ) WA . (cid:73) Lemma 12. a = shuffle ( h n i n ∈ N , h i n ∈ N ) is in but not in DetWA , u k defined by u n = 1 n + 2 n + · · · + ( k + 1) n is in ( k + ) WA but not in kWA , v defined by v n = n is in PolyWA but not in
FinWA ;Fibonacci is in WA but not in PolyWA . We omit the simple but technical proofs of the first three items. Only the last item willbe proved in Section 5, it follows from the fact that
PolyWA = PolyRat is equal to theclass of LRS whose eigenvalues are roots of rational numbers. As mentioned in Example 3the characteristic polynomial of the Fibonacci sequence is x − x −
1, so its eigenvalues arenot roots of rationals.
Cost-register automata (CRA) [3] are deterministic automata with write-only registers, whereeach transition updates the registers using addition and multiplication. Like in Section 3 wewill consider only the variant of the model over a one-letter alphabet recognising functions f : N → Q .Let X be a set of variables (registers) . The set of expressions Expr ( X ) is generated bythe following grammar e ::= x | r | e + e | e · e, where x ∈ X and r ∈ Q . A substitution is a mapping σ : X →
Expr ( X ). We let Subs ( X )denote the set of all substitutions. A valuation is a function σ : X → Q , it is a special case ofsubstitutions, where expressions are limited to constants. We freely compose these objects:for instance let X = { x } , define the valuation ν ( x ) = 0, the substitution σ ( x ) = x + 1 andthe expression e = 2 x . Then ν ◦ σ n ◦ e = 2 n . We see this computation as the output of a1-register machine which initialises x with 0, increments its value at each step and outputsits double value.Formally, a CRA is a tuple A = ( Q, X , δ, q , ν , µ ), where Q is the set of states, X isthe set of registers, δ : Q → Q × Subs ( X ) is the transition function, q is the initial state, ν : X → Q is the initial valuation and µ : Q → Q is the final output function. The outputof A on n is defined by the unique run of length n : let q → q → · · · → q n such that δ ( q i ) = ( q i +1 , σ i +1 ) (cid:74) A (cid:75) ( n ) = ν ◦ σ ◦ · · · ◦ σ n ◦ µ ( q n ) . A CRA is said to be linear if its transitions and output function use only linear expressions,i.e. such that in the grammar e · e is restricted to e · r . We denote LCRA the class ofsequences recognised by linear CRA, which is known to be equivalent to the class WA [3].For instance, the following linear CRA recognises the Fibonacci sequence.A substitution σ is called copyless if each register is used at most once in all σ ( x ). It iseasy to observe that a composition of copyless substitutions is a copyless substitution. ACRA is said to be copyless if in each transition, each substitution is copyless. For example in C V I T 2 0 1 6 qν ( x i ) = i µ ( q ) = x x := x x := x + x Figure 5
A linear CRA recognising the Fibonacci sequence. There is only one state and twovariables X = { x , x } . Since there is only one state the transitions are presented using only theexpression that is applied every time. Figure 5 the register x is used twice in the substitution so it is not a copyless automaton.We let CCRA denote the class of sequences recognised by copyless cost register automata(CCRA). In [12] it is shown that
CCRA is a subclass of linear CRA. We show that this isanother class characterising
PolyRat . (cid:73) Theorem 13.
PolyRat = CCRA
PolyRat ⊆ CCRA
This inclusion is easy to prove, it requires to perform the classical constructions as in Section 3and to note that they respect the copyless restriction.
CCRA ⊆ PolyRat
We make use of a simple property in [14]. A substitution is in normal form if there exists anorder on the registers x < · · · < x k such that the substitutions updating registers respectthe order: σ ( x i ) can use only registers x j such that x j ≥ x i . A CCRA is in normal form ifall substitutions used by it are in normal form, with the same order on the registers. It isknown that every CCRA has an equivalent CCRA in normal form [14, Proposition 1]. Wewill use this fact only to prove Lemma 14, but in the construction we will assume that theCCRA is in normal form.Consider a CCRA A , we prove that the sequence u it recognises is in PolyRat . Weassume without loss of generality that A is in normal form. Since A is deterministic ithas the shape of a lasso: a tail of length k and a loop of length ‘ . Let us fix n ∈ N and ‘ ∈ { , . . . , ‘ − } , the run is q → · · · → q k → ( p → · · · → p ‘ − ) n → p → · · · → p ‘ . (2)Let δ ( q i ) = ( q i +1 mod ‘ , β i ) for i ∈ { , . . . , k } , with the convention that q k +1 = p , and δ ( p i ) = ( p i +1 mod ‘ , σ i ) for i ∈ { , . . . , ‘ − } . Define ν = ν ◦ β ◦ · · · ◦ β k ; σ = σ ◦ · · · ◦ σ ‘ − ; e = σ ◦ · · · ◦ σ ‘ − ◦ µ ( p ‘ ) . Notice that σ is a copyless substitution since it is a composition of copyless substitutions.We define the sequence u [ ‘ ] by u n [ ‘ ] = ν ◦ σ n ◦ e. We will prove in Lemma 14 that the sequence u [ ‘ ] is in PolyRat . The decomposition ofthe runs into a lasso implies the following equality: u = h u , u , . . . , u k − , shuffle( u [0] , . . . , u [ ‘ − i , . Barloy et al. 23:13 which implies that u is in PolyRat , provided the lemma below is true. (cid:73)
Lemma 14.
For every copyless substitution σ in normal form, for all initial valuation ν and for all expression e , the sequence h ν ◦ σ n ◦ e i n ∈ N is in PolyRat . Proof.
We prove that the sequence u x = ν ◦ σ n ( x ) is in PolyRat for every register x , i.e.the lemma holds for e = x . The general case follows since PolyRat is closed under additionand product.We consider two cases. Suppose x is not used in σ ( x ). We prove that for n big enoughthe sequence stabilises, i.e. σ n ( x ) = σ n +1 ( x ) = c for some constant c . We show this by theinduction on the order < from the assumed normal form. If x is the biggest element in theorder < then σ ( x ) is a constant and thus σ n ( x ) = σ n +1 ( x ). For the induction step suppose x is not the biggest element. If σ ( x ) is a constant then the claim is trivial. Otherwise let x , . . . , x m be registers used in σ ( x ). Since σ is copyless then x i is not used in σ ( x i ) for every i . Hence by the induction assumption for every i there exists n i such that σ n ( x i ) = σ n +1 ( x i )for all n ≥ n i . It suffices to take n = max i { n i | ≤ i ≤ m } + 1. Since constant sequencesare geometric sequences with λ = 1 then u x can be defined in PolyRat using shift.Now suppose that x is used in σ ( x ). The expression σ ( x ) is equivalent to P mi =0 a i · x i forsome constants a i , where x = x and x i are pairwise different. Since σ is copyless then forall i > σ ( x i ) does not use x i . By the previous paragraph there exists N suchthat σ N ( x i ) = σ N +1 ( x i ) = c i for some constants c i for all i >
0. Let n ≥ N . Then ν ◦ σ n +1 ( x ) = ν ◦ σ n ◦ σ ( x ) = ν ◦ m X i =0 a i · σ n ( x i ) ! = a · ( ν ◦ σ n ( x )) + m X i =1 a i · c i . Let a = a and b = P mi =1 a i · c i . We proved that for n ≥ N the sequence u x satisfies u x ( n + 1) = a · u x ( n ) + b . It remains to prove that this sequence is in PolyRat . It is enoughto show that u x ( n ) = u x ( n + N ) is in PolyRat since to obtain u x it suffices to use shift N times. There are two cases. If a = 1 then u x ( n ) is an arithmetic sequence, which concludesthe proof. If a = 1 then u x ( n ) = a n · u x (0) + n − X i =0 a i · b = a n · u x (0) + b · a n − a − . This is a sum of a geometric sequence a n · ( u x (0) + ba − ); and a constant sequence − ba − ;which proves u x is in PolyRat . (cid:74)(cid:73) Remark.
One can extract from this proof the equivalence between linear
CCRA and
Rat [ Arith ∪ Geo , + , shift , shuffle].It was recently shown that CCRA are strictly less expressive than weighted automata [14].The proof goes by analysing the Fibonacci sequence. We will get as a corollary of our resultsa self-contained proof that
LCRA and
CCRA are different.
Our last two characterisations are as follows.
C V I T 2 0 1 6 (cid:73)
Theorem 15.
PolyRat is the class of LRS whose eigenvalues are roots of rational numbers,and equivalently whose formal series are PQ with P, Q rational polynomials and the roots of Q are roots of rational numbers. Before proving the theorem, we note that we can now substantiate the claim that theFibonacci sequence is not in
PolyRat (hence not in
CCRA and
PolyWA ), since itseigenvalues are not roots of rational numbers.We rely on the following classical result about LRS, see e.g. [8]. (cid:73)
Lemma 16.
Let u be an LRS and Q its characteristic polynomial. The formal seriesinduced by u is PQ for some rational polynomial P . For both inclusions we rely on Theorem 6 stating that
PolyRat = PolyWA and thedecompositions obtained in the subsequent lemmas.
PolyRat ⊆ LRS whose eigenvalues are roots of rational numbers
By Lemma 7 and Lemma 8 the formal series of sequences in
PolyWA are sums and Cauchyproducts of formal series of the form R − λx ‘ , where R is a rational polynomial, ‘ ∈ N and λ ∈ Q . The roots of 1 − λx ‘ are roots of λ , so the roots of the characteristic polynomial areroots of rational numbers. LRS whose eigenvalues are roots of rational numbers ⊆ PolyRat
Consider an LRS whose eigenvalues are roots of rational numbers. Thanks to Lemma 16the formal series it induces is PQ with P, Q rational polynomials and the roots of Q areroots of rational numbers. By Lemma 9 the formal series can be written as a sum of formalseries of the form R (1 − λx ‘ ) k for rational polynomials R , rational number λ , and ‘, k naturalnumbers. It follows from Lemma 10 and the closure of PolyRat under sum and shift thatsuch sequences belong to
PolyRat . We introduced a class of linear recurrence sequences and obtained several characterisations.The most surprising equivalence is
CCRA = PolyWA . This equality is very particular toour setting: for instance the two classes are incomparable, i.e. neither of the inclusions hold,for tropical semirings [14, 13]. We also conjecture that these classes are incomparable overthe rational semiring for general alphabets (of size bigger than 1).We leave open the precise complexity of the Skolem problem for
PolyRat . Recentprogress has been made for a subclass of
PolyRat [1]: the Skolem problem for LRS whoseeigenvalues are roots of unity is NP-complete. Our class is more general since we consider LRSwhose eigenvalues are roots of rational numbers, so the NP-hardness also applies. Howeverthe algorithm constructed in [1] does not extend to our class.
References S. Akshay, Nikhil Balaji, and Nikhil Vyas. Complexity of restricted variants of skolem andrelated problems. In , pages 78:1–78:14,2017. URL: https://doi.org/10.4230/LIPIcs.MFCS.2017.78 , doi:10.4230/LIPIcs.MFCS.2017.78 . . Barloy et al. 23:15 Shaull Almagor, Michaël Cadilhac, Filip Mazowiecki, and Guillermo A. Pérez. Weakcost register automata are still powerful. In
Developments in Language Theory - 22ndInternational Conference, DLT 2018, Tokyo, Japan, September 10-14, 2018, Proceed-ings , pages 83–95, 2018. URL: https://doi.org/10.1007/978-3-319-98654-8_7 , doi:10.1007/978-3-319-98654-8\_7 . Rajeev Alur, Loris D’Antoni, Jyotirmoy V. Deshmukh, Mukund Raghothaman, and Yi-fei Yuan. Regular functions and cost register automata. In , pages 13–22, 2013. URL: https://doi.org/10.1109/LICS.2013.65 , doi:10.1109/LICS.2013.65 . Mireille Bousquet-Mélou. Algebraic generating functions in enumerative combinator-ics and context-free languages. In
STACS 2005, 22nd Annual Symposium on Theor-etical Aspects of Computer Science, Stuttgart, Germany, February 24-26, 2005, Pro-ceedings , pages 18–35, 2005. URL: https://doi.org/10.1007/978-3-540-31856-9_2 , doi:10.1007/978-3-540-31856-9\_2 . Manfred Droste and Paul Gastin. Weighted automata and weighted logics.
TheoreticalComputer Science , 380(1-2):69–86, 2007. URL: https://doi.org/10.1016/j.tcs.2007.02.055 , doi:10.1016/j.tcs.2007.02.055 . Manfred Droste, Werner Kuich, and Heiko Vogler.
Handbook of Weighted Automata . Springer, 1st edition, 2009. Nathanaël Fijalkow, Cristian Riveros, and James Worrell. Probabilistic automata ofbounded ambiguity. In Roland Meyer and Uwe Nestmann, editors, ,volume 85 of
LIPIcs , pages 19:1–19:14. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik,2017. URL: https://doi.org/10.4230/LIPIcs.CONCUR.2017.19 , doi:10.4230/LIPIcs.CONCUR.2017.19 . Ronald L. Graham, Donald E. Knuth, and Oren Patashnik.
Concrete mathematics - afoundation for computer science (2. ed.) . Addison-Wesley, 1994. Daniel Kirsten and Sylvain Lombardy. Deciding unambiguity and sequentiality of polynomi-ally ambiguous min-plus automata. In , pages 589–600, 2009. URL: https://doi.org/10.4230/LIPIcs.STACS.2009.1850 , doi:10.4230/LIPIcs.STACS.2009.1850 . Ines Klimann, Sylvain Lombardy, Jean Mairesse, and Christophe Prieur. Deciding un-ambiguity and sequentiality from a finitely ambiguous max-plus automaton.
TheoreticalComputer Science , 327(3):349–373, 2004. URL: https://doi.org/10.1016/j.tcs.2004.02.049 , doi:10.1016/j.tcs.2004.02.049 . Stephan Kreutzer and Cristian Riveros. Quantitative monadic second-order logic. In
Annual ACM/IEEE Symposium on Logic in Computer Science, LICS 2013, New Orleans,LA, USA, June 25-28, 2013 , pages 113–122, 2013. URL: https://doi.org/10.1109/LICS.2013.16 , doi:10.1109/LICS.2013.16 . Filip Mazowiecki and Cristian Riveros. Maximal partition logic: Towards a logical charac-terization of copyless cost register automata. In , pages 144–159,2015. URL: https://doi.org/10.4230/LIPIcs.CSL.2015.144 , doi:10.4230/LIPIcs.CSL.2015.144 . Filip Mazowiecki and Cristian Riveros. Pumping lemmas for weighted automata. In , pages 50:1–50:14, 2018. URL: https://doi.org/10.4230/LIPIcs.STACS.2018.50 , doi:10.4230/LIPIcs.STACS.2018.50 . C V I T 2 0 1 6 Filip Mazowiecki and Cristian Riveros. Copyless cost-register automata: Structure, express-iveness, and closure properties.
Journal of Computer and System Sciences , 100:1–29, 2019.URL: https://doi.org/10.1016/j.jcss.2018.07.002 , doi:10.1016/j.jcss.2018.07.002 . Joël Ouaknine and James Worrell. On the positivity problem for simple linear recur-rence sequences,. In
Automata, Languages, and Programming - 41st International Col-loquium, ICALP 2014, Copenhagen, Denmark, July 8-11, 2014, Proceedings, Part II ,pages 318–329, 2014. URL: https://doi.org/10.1007/978-3-662-43951-7_27 , doi:10.1007/978-3-662-43951-7\_27 . Joël Ouaknine and James Worrell. Ultimate positivity is decidable for simple linearrecurrence sequences. In
Automata, Languages, and Programming - 41st InternationalColloquium, ICALP 2014, Copenhagen, Denmark, July 8-11, 2014, Proceedings, Part II ,pages 330–341, 2014. URL: https://doi.org/10.1007/978-3-662-43951-7_28 , doi:10.1007/978-3-662-43951-7\_28 . Joël Ouaknine and James Worrell. On linear recurrence sequences and loop termination.
SIGLOG News , 2(2):4–13, 2015. URL: http://doi.acm.org/10.1145/2766189.2766191 , doi:10.1145/2766189.2766191 . Rachid Rebiha, Arnaldo Vieira Moura, and Nadir Matringe. On the termination of linearand affine programs over the integers.
CoRR , abs/1409.4230, 2014. URL: http://arxiv.org/abs/1409.4230 , arXiv:1409.4230 . Marcel Paul Schützenberger. On the definition of a family of automata.
Informationand Control , 4(2-3):245–270, 1961. URL: https://doi.org/10.1016/S0019-9958(61)80020-X , doi:10.1016/S0019-9958(61)80020-X . Terence Tao.