Decidability and k-Regular Sequences

In this paper we consider a number of natural decision problems involving k-regular sequences. Specifically, they arise from - lower and upper bounds on growth rate; in particular boundedness, - images, - regularity (recognizability by a deterministic finite automaton) of preimages, and - factors, such as squares and palindromes of such sequences. We show that the decision problems are undecidable.


Introduction
A sequence (a(n)) n≥0 over a finite alphabet is said to be k-automatic, for k ≥ 2 an integer, if its k-kernel K k ((a(n)) n≥0 ) = {(a(k e n + i)) n≥0 : e ≥ 0, 0 ≤ i < k e } is of finite cardinality. There are many different equivalent definitions of this class of sequences [1]. It is well-known that many questions about these sequences, such as the growth rate of 0≤n<N a(n), are decidable [5].
The so-called k-regular sequences form a natural generalization of the automatic sequences. These are sequences (a(n)) n≥0 where the kernel K k ((a(n)) n≥0 ) is contained in a finitely generated module. Unlike the case of k-automatic sequences, it is known that some decision problems involving k-regular sequences are recursively unsolvable [2].
In this paper we examine a number of natural decision problems involving k-regular sequences, and show that they are undecidable.
1.1. Recursively solvable decision problems. A decision problem is one with a yes/no answer. To say that a decision problem is solvable means there exists an algorithm (or Turing machine) that unerringly solves it on all inputs. Throughout this paper we use the terms "recursively solvable", "solvable", and "decidable" interchangeably, and similarly for the terms "recursively unsolvable", "unsolvable", and "undecidable".
1.2. Notation. We let N 0 denote the nonnegative integers (natural numbers) and N denote the positive integers.
For a word z with symbols chosen from a finite set D, we let |z| denote its length and |z| d the number of occurrences of the letter d ∈ D in z.
Daniel Krenn is supported by the Austrian Science Fund (FWF): P 28466-N35. This work was partially carried out by the authors during the workshop "Numeration and Substitution 2019" at the Erwin Schrödinger International Institute for Mathematics and Physics (ESI), and they were supported by it.
For a fixed integer k ≥ 2, we consider base-k representations with the usual digit set D = {0, 1, . . . , k − 1}. For a nonnegative integer n, we write (n) k for the standard kary representation of n, most significant digit first, and having no leading zeroes. The representation of 0 is the empty word. Note that (n) k is a word over D and that |(n) k | = log k n + 1 for n > 0.

1.3.
Hilbert's tenth problem. Showing that a certain decision problem is recursively unsolvable is often carried out by constructing a (Turing) reduction from another decision problem already known to be recursively unsolvable. One such problem is Hilbert's tenth problem [6,16]: Theorem (Hilbert's tenth problem; variant). The decision problem "Given a multivariate polynomial p with integer coefficients, do there exist natural numbers x 1 , x 2 , . . . , x t such that p(x 1 , . . . , x t ) = 0?" is recursively unsolvable.
The analogous problem, where the x i need to be positive, is also recursively unsolvable. We will reduce from this problem quite frequently, namely in Theorems B, H, I, J and L.
1.4. Representation of k-regular sequences. A k-regular sequence (f (n)) n≥0 can be finitely represented in a number of different ways, of which two are the most useful. First, a set of identities in terms of sequences in the k-kernel, where each identity represents a subsequence (f (k e n + i)) n≥0 , 0 ≤ i < k e , as a linear combination of subsequences in the k-kernel, and a set of initial values. Together it must be possible to compute f (n) for all n from this set of identities and initial values.
Second, a linear representation for (f (n)) n≥0 , which consists of an 1 × r row vector v, an r × 1 column vector w, and k square matrices M 0 , M 1 , . . . , M k−1 of dimension r × r such that f (n) = vM n 0 · · · M n s−1 w, for all n, where (n) k = n s−1 · · · n 0 . Of course, the empty product of matrices is the identity matrix. The rank of a linear representation is r. See [1,Theorem 2.2]. A linear representation is minimal if it has smallest possible rank for the corresponding sequence.
For example, consider the 2-regular sequence (s 2 (n)) n≥0 , which counts the number of 1's in the binary representation of n. Then it is easy to see that is an example of the former representation, and is an example of the latter. From now on, when we say an algorithm is "given" a k-regular sequence as input, we actually mean that the input is either one of these two representations. Note that we can transform between these two representations effectively, that is, with an algorithm [3]. Some of our theorems involve algebraic numbers. When we say we are "given" a real algebraic number α, we mean we are given the minimal polynomial for α, together with a rational interval that contains α and none of its conjugates. As is well-known [9,10], we can effectively carry out arithmetic on algebraic numbers represented in this way.
1.5. Closure properties of k-regular sequences. In this section we recall some closure properties of k-regular sequences: that is, which operations on sequences preserve the property of k-regularity. For more details, see [1]. It is important to note that not only do these operations preserve k-regularity; they also are effectively k-regular. Let • be some operation on sequences. By the operation • being "effectively k-regular", we mean that there is an algorithm that, given some representation of k-regular sequences a = (a(n)) n≥0 and b = (b(n)) n≥0 , computes a representation for a • b.
Theorem. The class of k-regular sequences is (effectively) closed under the following operations: The same is true for t-way perfect shuffle, where we combine t sequences analogously.
For proofs, see [1]. with z = (n) k , is (effectively) a k-regular sequence in n ∈ N 0 over Z. This is true because the number of occurrences |z| d of a digit d in the standard k-ary expansion z = (n) k is a k-regular sequence by [1, Theorem 6.1] and, as above, k-regular sequences are closed under term-by-term addition and multiplication.

Equality of k-regular sequences
Before we consider growth of k-regular sequences in the next section, we study decidability of whether one k-regular sequence equals another.
Theorem A. Let k ≥ 2 be an integer and S ⊇ N 0 be a set. The decision problem "Given two k-regular sequences (f (n)) n≥0 and (g(n)) n≥0 over S, does f (n) = g(n) for all n?" is recursively solvable.
Proof. The sequence (f (n) − g(n)) n≥0 is k-regular by the closure properties of k-regular sequences. We compute a linear representation of this sequence and apply a minimization algorithm (see Berstel and Reutenauer [3]) to it. This results in a linear representation of minimum rank. This rank is 0 iff we started with the zero sequence, iff f (n) = g(n) for all n.

Growth of k-regular sequences
We use the standard notation for asymptotic growth of sequences. Let (f (n)) n≥0 and (g(n)) n≥0 be sequences. Then • f (n) ∈ O(g(n)) means that there exist n 0 , c > 0 such that f (n) ≤ cg(n) for all n ≥ n 0 , and • f (n) ∈ Ω(g(n)) means that there exist n 0 , c > 0 such that f (n) ≥ cg(n) for all n ≥ n 0 . For simplicity, we sometimes say that the sequence (f (n)) n≥0 is in O(g(n)) or Ω(g(n)).
In what follows, A denotes the set of real algebraic numbers.

Lower bounds.
Theorem B. Let k ≥ 2 be an integer and S be a set with N ⊆ S ⊆ A. The decision problem "Given a k-regular sequence (f (n)) n≥0 over S, is f (n) in Ω(n)?" is recursively unsolvable.
Proof. We reduce from Hilbert's tenth problem. For a given multivariate polynomial p in t variables over Z, we choose r ∈ N such that K = k r ≥ t + 2, and we construct the sequence The sequence (f (n)) n≥0 is K-regular (see Remark 1.1) and therefore k-regular as well [1,Theorem 2.9].
The following claim shows that the above indeed provides a reduction.
To see this, note that f (n) = 0 iff at least one factor is zero, but the first and third factors defining f are never zero. Hence f (n) = 0 iff p(|z| 1 , |z| 2 , . . . , |z| t ) = 0. Moreover, note that if a zero of (f (n)) n≥0 occurs once, it occurs infinitely often by the third factor of the definition for f . Thus, if p(x 1 , . . . , x t ) = 0 has at least one solution, then f (n) = 0 for infinitely many n, and hence f (n) is not in Ω(n). Otherwise, if p(x 1 , . . . , x t ) = 0 does not have any solution, then its absolute value is at least 1, so the value of f (n) is at least n + 1, and hence f (n) is in Ω(n). This completes the proof of the claim and consequently the proof of Theorem B.
Theorem B can be extended to other growth rates as well.
Corollary C. Let k ≥ 2 be an integer. Suppose σ is a real number and is a nonnegative integer, not both zero. Assume that k σ is an algebraic number. Let S be a ring with Z ⊆ S ⊆ A and containing k σ . The decision problem "Given a k-regular sequence (f (n)) n≥0 over S, is f (n) in Ω n σ (log n) ?" is recursively unsolvable.
Remark 3.1. For a real number σ and a nonnegative integer we construct a k-regular sequence (h σ, (n)) n≥0 with positive terms (except for the first few terms, which may be 0) satisfying h σ, (n) ∈ Θ(n σ (log n) ), as follows.
is a Jordan block, of size + 1, corresponding to the eigenvalue k σ . We set where H(n) = H n 0 · · · H n −1 for (n) k = n −1 · · · n 0 , and the e i are the ith unit vectors. Therefore, the sequence h σ, (n) is k-regular, as it is defined by a linear representation. Explicitly, we have where s = log k n + 1. Thus, this sequence's asymptotic behavior is Θ(n σ (log n) ). If = 0, then no term is 0. If = 0, then only terms with n ≤ k −1 are 0.
Proof of Corollary C. The proof runs along the same lines as the proof of Theorem B. For a given multivariate polynomial p in t variables over Z, we instead choose r ∈ N such that K = k r ≥ t + 2, and we define with z = (n) K and (h σ, (n)) n≥0 of Remark 3.1. Note that the factor (h σ, (n) + 1) of f (n) is increasing and always positive.

Upper bounds.
Let (h(n)) n≥0 be a sequence. We say that a sequence (M (n)) n≥0 of matrices with entries in a set S ⊆ A is in O(h(n)), formally written as usual as if each sequence of a fixed entry (fixed row and column) of the matrices is in O(h(n)).
Rephrased, this means that the sequence of maximum norms of the matrices lies in O(h(n)).
By the equivalence of norms, this is also true for any other norm. As in the one-dimensional case, we say that the sequence (M (n)) n≥0 is bounded if it lies in O(1).
Remark 3.2. Let σ ∈ R and ∈ N 0 , and set h(n) = n σ (log n) . If m(n) = cn + τ (n) for some constant c = 0 and some sequence τ (n) ∈ o(n), then as n → ∞. This follows from Theorem D. Let k ≥ 2 be an integer and S be a ring with Q ⊆ S ⊆ A. The decision problem "Given a k-regular sequence (f (n)) n≥0 over S, is f (n) bounded?" is recursively unsolvable.
Remark 3.3. The above problem is decidable for k-regular sequences that have a linear representation with integer matrices; see the algorithm of Mandel and Simon [15] for matrices with nonnegative entries and the algorithm of Jacob [12,13,14] for general integer matrices.
Given square matrices F 0 , . . . , F k−1 over a ring S all of the same dimension, we set F (n) = F n 0 · · · F n s−1 for (n) k = n s−1 · · · n 0 , and we call the sequence (F (n)) n≥0 the matrixvalued linear representation sequence of the set {F 0 , . . . , F k−1 }. We use this notion in the following lemma, which extends decidability from k-regular sequences to matrix-valued linear representation sequences.
Lemma 3.4. Let S be a ring. Let P be a property of a sequence over S, i.e., P for each sequence over S is either true or false. Suppose we can extend property P to sequences of matrices over S in one of the following ways: Property P holds for a sequence of matrices iff P holds for (1) all sequences or (2) any sequence consisting of a fixed entry (fixed row and column).
If P is recursively solvable for k-regular sequences over S, then P is recursively solvable for matrix-valued linear representation sequences of a set of k square matrices over S, all of the same dimension.
We will use this lemma in the proof of Theorem D with the property P being the boundedness of a sequence and in the proof of Theorem F, where P is true iff a sequence does not have at least polynomial growth.
Proof of Lemma 3.4. We show (1). Then (2) follows by using the negation of property P .
We define f i,j (n) = e i F (n)e j with F (n) as above and where e i is the ith unit vector. Therefore, (f i,j (n)) n≥0 is the sequence of entries in row i and column j of (F (n)) n≥0 . All sequences (f i,j (n)) n≥0 are k-regular, as they are defined by a linear representation. Clearly all these sequences (f i,j (n)) n≥0 satisfy P iff F (n) satisfies P .
As the question of deciding property P of a k-regular sequence is recursively solvable, we can decide P for each of the (finitely many) distinct sequences (f i,j (n)) n≥0 and therefore can decide P for (F (n)) n≥0 .
Proof of Theorem D. We reduce from the question of boundedness of all products of matrices over the rationals, which is not recursively solvable; see Blondel and Tsitsiklis [4].
For a given set of matrices {F 0 , . . . , F k−1 }, for all n 0 , . . . , n s−1 ∈ {0, . . . , k − 1}, there is either a largest index j ∈ {1, . . . , s} with n j−1 = 0 or j = 0 and such that F n 0 · · · F n s−1 = F n 0 · · · F n j−1 F s−j 0 . Whenever we are now deciding the boundedness of matrix products, we split as above and consider the factors F s−j 0 on the right-hand side and the remaining product separately. As for the F s−j 0 , we can decide the boundedness of powers of a single matrix from knowledge of its Jordan decomposition. And, as for the remaining factors, the statement of the theorem follows by using the reduction that is provided by Lemma 3.4 with property P being the boundedness of a sequence.
Corollary E. Let k ≥ 2 be an integer, σ a real number and a nonnegative integer. Assume that k σ is an algebraic number. Let S be a ring with Q ⊆ S ⊆ A and containing k σ . The decision problem "Given a k-regular sequence (f (n)) n≥0 over S, is f (n) in O(n σ (log n) )?" is recursively unsolvable.
Proof. We reduce from the decision problem stated in Theorem D. For a k-regular sequence (g(n)) n≥0 , we construct f (n) = g(n) h σ, (n) with h σ, (n) as defined in Remark 3.1. Then, the k-regular sequence (f (n)) n≥0 is in O(n σ (log n) ) iff g(n) is in O(1), i.e., bounded. Therefore deciding if a k-regular sequence is in O(n σ (log n) ) implies deciding the boundedness of a k-regular sequence, which contradicts Theorem D.
Let σ ∈ R and ∈ N 0 . We say that a sequence (f (n)) n≥0 has exact growth n σ (log n) if f (n) ∈ O n σ (log n) but for all σ ∈ R and ∈ N 0 with (σ , ) lexicographically smaller than (σ, ) we have f (n) ∈ O n σ (log n) .
Proposition 3.5. Let (f (n)) n≥0 be a k-regular sequence over a field S ⊆ A with matrices F 0 , . . . , F k−1 of a minimal linear representation, and set F (n) = F n 0 · · · F n s−1 for (n) k = n s−1 · · · n 0 . Let σ ∈ R and ∈ N 0 , and set h(n) = n σ (log n) . Then if and only if F (n) ∈ O(h(n)).
In particular, both f (n) and F (n) have exactly the same growth rate.
Proof. Let λ and γ be the vectors of our minimal representation, i.e., f (n) = λ F (n)γ for all n ∈ N 0 . We start with the easy direction: As f (n) is a finite linear combination of the entries in the matrix F (n) and each of these entries is in O(h(n)), we have f (n) is in O(h(n)). Conversely, suppose F (n) is not in O(h(n)). As there are only finitely many entries in each matrix F (n), we can assume that one entry of F (n) is not in O(h(n)). Let (g(n)) n≥0 denote the sequence of this fixed entry of the matrices. Now, as our linear representation is minimal, there exist finite subsets P , Q ⊆ N 0 and coefficients c p , d q ∈ S \ {0} for p ∈ P , q ∈ Q such that for all n ∈ N 0 ; see [3, Corollary 2.3]. As g(n) is not in O(h(n)), one of the finitely many summands c p d q · λ F (p) F (n) F (q)γ of (3.1), where p ∈ P and q ∈ Q, is not in O(h(n)). Dividing this summand by c p d q yields a subsequence of (f (n)) n≥0 , namely with m(n) = pk |(n) k |+|(q) k | + nk |(q) k | + q for all n ∈ N 0 . As |(n) k | = log k n + 1, we have m(n) = cn + o(n) for some constant c, and therefore, by Remark 3.2, we obtain that the subsequence f (m(n)) is not in O(h(n)) = O(h(m(n))). Thus the sequence (f (n)) n≥0 itself is not in O(h(n)).

Polynomial growth.
The growth of a k-regular sequence is always at most polynomial. To be precise, for a k-regular sequence (f (n)) n≥0 with values in A, there exists a real constant σ ≥ 0 such that f (n) ∈ O(n σ ); see [1, Theorem 2.10].
Theorem F. Let k ≥ 2 be an integer and S be a ring with Q ⊆ S ⊆ A. The decision problem "Given a k-regular sequence (f (n)) n≥0 over S, does f (n) have at least polynomial growth, i.e., does there exist σ > 0 such that f (n) is not in O(n σ )?" is recursively unsolvable.
Consequently, the decision problem in this theorem is whether a k-regular sequence has polynomial growth or a smaller growth.
Recall that the joint spectral radius of a finite set S of square matrices is defined to be where · is any matrix norm.
Proposition 3.6. Let S ⊆ A be a ring, let ρ ∈ R be positive, let F 0 , . . . , F k−1 be square matrices over S all of the same dimension, and set F (n) = F n 0 · · · F n s−1 for (n) k = n s−1 · · · n 0 . Then the following two statements are equivalent: (1) The joint spectral radius of F 0 , . . . , F k−1 is ρ.
If S is a field and the matrices F 0 , . . . , F k−1 are of a minimal representation of a k-regular sequence (f (n)) n≥0 , then we may replace F (n) by f (n) in the statements of this proposition.
Corollary G. Let the assumptions of Proposition 3.6 hold and suppose F 0 is the zero-matrix. Then the joint spectral radius ρ of F 1 , . . . , F k−1 is bounded by some positive ρ ∈ R, i.e., ρ ≤ ρ , iff for all ε > 0 we have F (n) ∈ O n (log k ρ )+ε as n → ∞.
We will use this corollary with ρ = 1 in the proof of Theorem F to connect polynomial growth with the joint spectral radius ρ.
Proof of Proposition 3.6. In this proof, we suppose that s and n are related by s = log k n +1. Then, by Remark 3.2, we have O(n σ ) = O(k sσ ) as n → ∞ for any σ.
We have that for any fixed real σ, as n → ∞ is equivalent to as s → ∞, because s is the same for all n within the given range of the argument of the maximum and the right-hand side O(k sσ ) only depends on s (and not on n).

1/s
Then the bound (3.2) together with F s 0 ∈ O(k sσ ) is equivalent to (3.3) k s log k ρs = ρ s s ∈ O(k sσ ) as s → ∞, because there is a constant c > 0 (only depending on the used norm) such that for all n 0 , . . . , n s−1 ∈ {0, . . . , k − 1}, there is either a largest index j ∈ {1, . . . , s} with n j−1 = 0 or j = 0 and Consequently, the bound (3.3) is equivalent to the existence of an S ∈ N 0 such that for all s ≥ S, the inequality log k ρ s ≤ σ holds. So much for our preliminary considerations. Now let ε > 0. Then F (n) ∈ O n (log k ρ)−ε , F (n) ∈ O n (log k ρ)+ε and F s 0 ∈ O (k s ) (log k ρ)+ε iff there is an S ∈ N 0 such that for all s ≥ S, the inequalities (log k ρ) − ε < log k ρ s ≤ (log k ρ) + ε hold. But this is equivalent to log k ρ = lim s→∞ log k ρ s and therefore equivalent to which completes the proof of the equivalence.
If f (n) is as in the proposition, then by Proposition 3.5 we have the equivalence of as n → ∞ for any fixed real algebraic σ, so it is allowed to replace F (n) by f (n) in our statements.
Proof of Corollary G. As F 0 is the zero-matrix, F s 0 ∈ O (k s ) (log k ρ )+ε as s → ∞ holds trivially, and the result therefore follows from Proposition 3.6.
Proof of Theorem F. We reduce from the recursively unsolvable question whether the joint spectral radius of a set of matrices over the rationals is bounded by 1; see Blondel and Tsitsiklis [4].
So let us assume the decision problem of Theorem F is recursively solvable. Let F 1 , . . . , F k−1 be square matrices over the rationals, let F 0 be the zero-matrix, and set F (n) = F n 0 · · · F n s−1 for (n) k = n s−1 · · · n 0 . By the reduction of Lemma 3.4, where property P is whether a sequence does not have at least polynomial growth, we can decide whether F (n) does not have at least polynomial growth. This is equivalent to deciding whether for all σ > 0 we have F (n) ∈ O(n σ ). By Corollary G with ρ = 1, this is equivalent to deciding whether the joint spectral radius ρ of F 1 , . . . , F k−1 being at most 1, a contradiction.

Images and preimages
By [1, Theorem 5.2], it is undecidable whether a given k-regular sequence (f (n)) n≥0 has a zero term, i.e., whether there exists an n ∈ N 0 with f (n) = 0.

4.1.
Preimages. In this section we use closure properties of regular languages without further comment. See, for example, [11].
Theorem H. Let k ≥ 2 be an integer and S ⊇ N 0 be a set. The decision problem "Given a k-regular sequence (f (n)) n≥0 over S and a number q ∈ S, is the language associated with f −1 (q) regular, i.e., can it be recognized by a deterministic finite automaton?" is recursively unsolvable.
Above, the language associated with f −1 (q) is {(n) k : f (n) = q}, where (n) k is the standard k-ary expansion of n.
Proof of Theorem H. We can assume that q = 0 by subtracting q from the k-regular sequence. In order to prove the theorem, we reduce from Hilbert's tenth problem.
For a given multivariate polynomial p in t variables over Z, we choose r ∈ N such that K = k r ≥ t + 3, and we construct where z = (n) K . The sequence (f (n)) n≥0 is K-regular (see Remark 1.1) and therefore k-regular as well by [1,Theorem 2.9].
The following claim shows that the above indeed provides a reduction.
If p(x 1 , . . . , x t ) = 0 has no solution in N t 0 , then f (n) = 0 by its construction. Thus f −1 (0) is the empty set and is accepted by a deterministic finite automaton.
As L is regular, so is which is not regular; see [7,Examples 2.8 and 5.2]. This contradiction proves the desired result. Now, if we can decide whether the language associated with f −1 (q) is regular, then we can decide whether a solution of p exists, and therefore decide Hilbert's tenth problem. This completes the proof of Theorem H.

Images.
Theorem I. Let k ≥ 2 be an integer and S ⊇ N 0 be a set. The decision problem "Given a k-regular sequence (f (n)) n≥0 over S, is {f (n) : n ∈ N 0 } = N 0 ?" is recursively unsolvable.
Proof. In order to prove the theorem, we again reduce from Hilbert's tenth problem. For a given multivariate polynomial p in t variables over Z, we choose r ∈ N such that K = k r ≥ t, and we construct f (n) = n/2 + 1, if n is even; The sequence (f (n)) n≥0 is K-regular (Remark 1.1 and [1, Theorem 2.7]) and therefore k-regular as well by [1,Theorem 2.9].
Once we have shown the following claim, we have a reduction to Hilbert's tenth problem and therefore the proof of Theorem I is completed.
If p(x 1 , . . . , x t ) = 0 has no solution in N t 0 , then f (n) = 0 by its construction. Thus 0 is not in the set {f (n) : n ∈ N 0 }, so this set cannot be equal to N 0 .
Otherwise, suppose we have nonnegative integers x 1 , . . . , x t with p(x 1 , . . . , x t ) = 0, then there exists an n ∈ N 0 with f (n) = 0. As {f (n) : n ∈ N 0 is even} already contains all the positive integers, all nonnegative integers appear as a value f (n) somewhere.
Theorem J. Let k ≥ 2 be an integer and S ⊇ Z be a set. The decision problem "Given a k-regular sequence (f (n)) n≥0 over S, is {f (n) : n ∈ N 0 } = Z?" is recursively unsolvable.
Proof. The proof runs along the same lines as the proof of Theorem I, but for a given multivariate polynomial p in t variables over Z, we choose r ∈ N such that K = k r ≥ t, and we construct where z = (n − 2)/3 K . Then the set {f (n) : n ∈ N 0 } equals Z iff there exist nonnegative integers x 1 , x 2 , . . . , x t such that p(x 1 , . . . , x t ) = 0.
We can extend the above to the question whether two k-regular sequences have the same image.
Proof. We reduce from the decision problem of Theorem I, so let (f (n)) n≥0 be a k-regular sequence over S and set g(n) = n. If we can decide whether these two sequences have the same image, then we decide whether {f (n) : n ∈ N 0 } = {g(n) : n ∈ N 0 } = N 0 , which contradicts Theorem I.
Theorem L. Let k ≥ 2 be an integer and S ⊇ N 0 be a set. The decision problem "Given a k-regular sequence (f (n)) n≥0 over S, does f (n) take the same value twice?" is recursively unsolvable.
Proof. In order to prove the theorem, we reduce from Hilbert's tenth problem. For a given multivariate polynomial p in t variables over Z, we choose r ∈ N such that K = k r ≥ t, and we construct g(m) = p(|z| 1 , |z| 2 , . . . , |z| t ) 2 where z = (m) K and The sequence (f (n)) n≥0 is K-regular (Remark 1.1 and [1, Theorem 3.1]) and therefore k-regular as well by [1, Theorem 2.9]. Once we have shown the following claim, we have a reduction to Hilbert's tenth problem and therefore the proof of Theorem L is completed.
If p(x 1 , . . . , x t ) = 0 has no solution in N t 0 , then g(m) is strictly positive, and therefore f (n) strictly increasing. So no value is taken twice.

Squares and other α-powers
Given a sequence (f (n)) n≥0 and an integer α ≥ 2, an α-power is a nonempty contiguous subsequence (f (j)) i≤j<i+αm of length α, for some i and m, such that f (i + t) = f (i + sm + t) for all 0 ≤ s < α and 0 ≤ t < m. We call a 2-power a square. For example, the fractional part of the decimal representation of e contains the square 18281828.
A palindrome is a nonempty contiguous subsequence that reads the same forwards and backwards. A palindrome is nontrivial if it is of length ≥ 2.
For automatic sequences, the presence of squares, higher powers, and nontrivial palindromes is decidable (see, e.g., [8]). We now show that, in contrast, the existence of these patterns is undecidable for k-regular sequences.
Proof. We reduce from the problem of deciding whether a k-regular sequence has a 0 term.
Using the same technique, we can prove following theorem for palindromes.
Proof. The same proof given for squares above works unchanged.