Some properties of $k$-bonacci words on infinite alphabet

The Fibonacci word $W$ on an infinite alphabet was introduced in [Zhang et al., Electronic J. Combinatorics 2017 24(2), 2-52] as a fixed point of the morphism $2i\rightarrow (2i)(2i+1)$, $(2i+1) \rightarrow (2i+2)$, $i\geq 0$. Here, for any integer $k>2$, we define the infinite $k$-bonacci word $W^{(k)}$ on the infinite alphabet as the fixed point of the morphism $\varphi_k$ on the alphabet $\mathbb{N}$ defined for any $i\geq 0$ and any $0\leq j\leq k-1$, as \begin{equation*} \varphi_k(ki+j) = \left\{ \begin{array}{ll} (ki)(ki+j+1)&\text{if } j = 0,\cdots ,k-2,\\ (ki+j+1)&\text{otherwise}. \end{array} \right. \end{equation*} We consider the sequence of finite words $(W^{(k)}_n)_{n\geq 0}$, where $W^{(k)}_n$ is the prefix of $W^{(k)}$ whose length is the $(n+k)$-th $k$-bonacci number. We then provide a recursive formula for the number of palindromes occur in different positions of $W^{(k)}_n$. Finally, we obtain the structure of all palindromes occurring in $W^{(k)}$ and based on this, we compute the palindrome complexity of $W^{(k)}$, for any $k>2$.

We consider the sequence of finite words (W is the prefix of W (k) whose length is the (n + k)-th k-bonacci number. We then provide a recursive formula for the number of palindromes that occur in different positions of W

Introduction
Finite and infinite Fibonacci words are among the most studied ones in combinatorics of words and have important roles in computer science, based on their optimal properties and various applications, see for example [13,3,14,5]. The sequence of finite Fibonacci words (F n ) n −1 is given by F −1 = 1, F 0 = 0 and the recurrence relation F n = F n−1 F n−2 which holds for n 1. An equivalent way to give these words for n 0, is using F n = ψ n (0), where ψ is the binary morphism 0 → 01, 1 → 0. The infinite Fibonacci word is then given by F ∞ = lim n→∞ F n or equivalently by F ∞ = ψ ω (0). The infinite Fibonacci word belongs to the class of infinite aperiodic binary words having the minimal complexity (i.e. the minimal number of factors of each given length); any such word is called a Sturmian word. Sturmian words are well-studied in the literature; they admit some equivalent definitions and have several interesting properties, see [4,12,10] for instance.
A natural extension of finite Fibonacci words to k-letter alphabet, k > 2, is defining finite k-bonacci words (F Alternatively, these words may be given by F The infinite k-bonacci word is then given by F While the infinite Fibonacci word is the simplest example of Sturmian words, the infinite k-bonacci word is similarly related to the most natural extension of Sturmian words, namely episturmian words. More precisely, the k-bonacci word is the simplest example of non-ultimately periodic episturmian words on the k-letter alphabet; to see the definition and properties of episturmian words see [6,4,11,8,7]. The infinite Fibonacci word over the infinite alphabet of nonnegative integers, N, denoted here as W (2) , is presented in [15] as the fixed point of the morphism ϕ 2 starting with 0, where ϕ 2 is given by ϕ 2 (2i) = (2i)(2i + 1) and ϕ 2 (2i + 1) = 2i + 2 for i 0. More precisely, we have W (2) = ϕ ω 2 (0). The authors of [15] have also studied the finite Fibonacci words over N, namely the words W (2) n = ϕ n 2 (0). It is obvious that when the digits of W (2) n and W (2) are calculated mod 2, these words are reduced to F n and F ∞ , respectively. Among several properties of words W (2) n and W (2) studied in [15], the authors characterized palindromic factors of W (2) n and W (2) . Particularly, the authors showed that in contrast to the ordinary infinite Fibonacci word which contains palindromic factors of the electronic journal of combinatorics 27(3) (2020), #P3.59 arbitrary length, the word W (2) has no palindrome of length greater than 3. Some more properties of these words were consequently studied by Glen et al. in [9]. Among other results, they computed the number of palindromes in W (2) n . In this paper, we introduce finite and infinite k-bonacci words on the infinite alphabet N, denoted respectively as W (k) n and W (k) . Studying theses words, we characterize the palindromic factors of W (k) for any fixed integer k 3. More precisely we show that the length of a palindromic factor of W (k) belongs to the set L k = {2} ∪ {2i − 1 : 2 i 3.2 k−2 }. Conversely, for each element of L k we give the structure of palindromes of W (k) with length . We also enumerate the total number of palindromes of W (k) n .

Definitions and notation
In this paper, the alphabet, which can be a finite or a countable infinite set, is denoted as A. When the alphabet is infinite, we simply take A = N. Each element of the alphabet A is called a letter. When A = N, we equivalently use the term digit instead of letter. We denote by A * the set of finite words over A and we let A + = A * \{ }, where is the empty word. We denote by A ω the set of all infinite words over A and we let A ∞ = A * ∪ A ω . If a ∈ A and W ∈ A ∞ , then the symbols |W | and |W | a denote respectively the length of W , and the number of occurrences of letter a in W (It is obvious that when W ∈ A ω , |W | = ∞). For any word W ∈ A ∞ , Alph(W ) is defined to be the set of letters which have at least one occurrence in W , that is . We denote the prefix (resp. suffix) V of length j of W ∈ A + by Pref j (W ) (resp. Suff j (W )). If W ∈ A * and W = V U (resp. W = U V ,) we merely write V = W U −1 (resp. V = U −1 W ). For a finite word W = w 1 w 2 . . . w n , with w i ∈ A and for 1 j j n, we denote W [j, j ] = w j . . . w j , and for simplicity we denote W [j, j] by W [j]. The reversal of a finite word W = w 1 w 2 . . . w n , with w i ∈ A, is W R = w n w n−1 . . . w 1 . A word W ∈ A * is called palindrome if W = W R . The set of all palindromic factors of the word W ∈ A ∞ is denoted by Pal(W ). When the alphabet is finite, for any word U ∈ A ∞ , the number of palindromic factors of length n of U , called the palindrome complexity of U , is denoted by pal U (n) (for more information about the palindrome complexity see [1,2] and the references therein). When the alphabet is infinite (i.e. A = N), the definition of palindrome complexity can naturally be extended to all words U ∈ A ∞ with the same notation.
Let P be a palindrome of odd length 2k + 1 and W = Pref k (P ). Then the letter a ∈ A satisfying P = W aW R , is called the center of the palindrome P . If P is a palindrome of even length, then the center of P is defined to be the empty word. For any occurrence of a palindromic factor P ∈ A * in a word W ∈ A ∞ such as W = U P V with U ∈ A * , V ∈ A ∞ , the center position of this occurrence of P in W is denoted by c p (P, W ) and defined to be |U | + |P |+1 2 . We notice that when |P | is even the center-position is a non-integer. A palindromic factor P ∈ A * of W ∈ A ∞ is called a maximal palindromic factor of W if there is no longer palindromic factor of W with the same center position. We note that a maximal palindromic factor of a word W , could be a factor of another palindromic factor P of W . For instance, the only maximal palindromic factors of W = 1213121 are 1, 121 and 1213121. For 1 i n, let U i ∈ A * ; then 1 i=n U i is defined to be U n U n−1 . . . U 1 . For a finite word W and an integer n, n ⊕ W denotes the word obtained by adding n to each letter of W . For example, let W = 01023 and n = 5, then n ⊕ W = 56578. For a finite set S = {S 1 , . . . , S m } ⊂ A + , we define n ⊕ S to be the set {n ⊕ S 1 , . . . , n ⊕ S m }.
For any integer k 2 the sequence of k-bonacci numbers, denoted by {f (k) n } n 0 , is given as The last recurrence relation which holds eventually, states that the n-th term of the sequence is the summation of the k previous ones. This reminds the Fibonacci and Tribonacci recurrence relations in the special cases k = 2 and k = 3. In fact, f n and f (3) n are essentially the well-known Finonacci and Tribonacci numbers. It is easy to prove that regardless of the first k − 1 zero terms, the above sequence of k-bonacci numbers can be given as We define the finite (resp. infinite) k-bonacci words W (k) n (resp. W (k) ) on the infinite alphabet N, using the morphism ϕ k given below for integers i 0 and 0 j < k, More precisely, W mod k, that is for a fixed value of k, the k-bonacci words over the infinite alphabet are reduced to k-bonacci words over a finite alphabet when the digits are calculated mod k. It can be shown that for n 0, We end this section with two examples giving some initial k-bonacci words on finite and infinite alphabets.  3 Some properties of W (k) n In this section, we give some recursive identities which state the word W (k) n as the concatenation of previous words of the same type. These identities will help us to discover the structure of palindromes in k-bonacci words in the future sections. First we present a simple lemma stating a property of the morphism ϕ k which can be easily deducted from the definition.
the electronic journal of combinatorics 27(3) (2020), #P3.59 Proof. We use induction on n. It is easy to check that the statement is true for n = 1. Suppose the lemma is true for all i with 1 i n < k − 1. Then 0 (n + 1) since n < k − 1 and ϕ k (n) = 0(n + 1) Lemma 5. For 1 n k − 1, Proof. By Lemma 4, we have In the next lemma we give a recursive formula for W (k) n when n k. Lemma 6. For n k, Proof. We use induction on n. If n = k, the statement is true since Now, suppose Equation (6) holds for all n with k n j; we prove it below for n = j +1.
Proof. By Lemmas 4 and 6, for any integer n 0, W n+1 . Hence, the result follows by induction on n.
n |. Furthermore, the following identity holds.
Proof. Considering the definition of k-bonacci numbers in Equation (2) and using Lemmas 4 and 6, we conclude that |W n+k holds for all n 0. The other statements follow from Equation (3).
Lemma 9. For any n 0, the digit n is the largest one of W (k) n and appears once at the end of this word.
Proof. We prove this using induction on n. When n = 1, W (k) 1 = ϕ k (0) = 01 and it is obvious that the claim is true. Now suppose the result holds for n m. We prove it for n = m + 1 below.

Now, by induction hypothesis all digits of W
(k) m m −1 are less than m. Hence, by definition of ϕ k , all digits of ϕ k (W (k) m m −1 ) are less than m + 1. Again using definition of ϕ k , the largest digit of ϕ k (m) is m + 1 which occurs once at the end of ϕ k (m) and the proof is complete.
The following notation simplifies some definitions and proofs appearing in the rest of the paper. Notation. For any integer i, we let (i) * = max{i, 0}.
Definition 10. Let n be a positive integer. Considering factorizations of W (k) n given in the Equations (5) and (6), we divide the set of factors of W (k) n into three following types.
• Included factors. The digit n or the factors of W (k) n which are included in any of the words W (k) i . We call any such factor, a bordering factor of type j of W n−k if n k; these are called (A, B)-straddling factors (or straddling factors for short, if there is no danger of confusion) of W (k) n . Definition 11. Let n be a positive integer. Considering Definition 10, we call a palindromic factor P of W (k) n an included (resp. a bordering, a straddling) palindrome if P is an included (resp. a bordering, a straddling) factor of W (k) n .
The following definition helps us to detect factors of length two of W (k) n and will be used in some lemmas.
n , then B ∈ B (k) . Proof. By Definition 12, it is easy to see that B (k) ⊕ k ⊂ B (k) . We prove the lemma by induction on n. If n = 1, then W (k) 1 = 01 has just one factor of length 2, namely 01 ∈ B (k) 2 . Now let m > 1 and suppose that the lemma is true for all n, 1 n < m. To conclude its validity for m, let B be a factor of length 2 of W (k) n . Considering Definition 10, one of the following cases hold.
The former case leads to B ∈ B (k) by the induction hypothesis, while the latter case leads to • B is a bordering factor of W (k) m . Then by Definition 10, B = j0, for some (n − k + 1) * + 1 j n − 1. This means that B ∈ B  Corollary 15. Let s, t ∈ N and let n, k be two positive integers with k > 2. If st ≺ W (k) n , then either k | t or s < t.
The following theorem gives us the suffix of length two of the word W (k) n .
Theorem 16. Let n 1 and j = (n mod k). Then . We prove the theorem using induction on n. If n = j = 1, we have 01 ϕ 1 k (0). Suppose that the result holds for all n, n m. The validity of the result for n = m + 1 is then proved in the following two cases.
• If m + 1 ≡ j (mod k), and 0 < j < k then by Lemma 9, m is the last digit of ϕ m k (0) or m ϕ m k (0). Hence, So, the proof is complete. Let P (k) (n) denote the total number of palindromes in W (k) n occurring in different positions and B (k) (n, j) and S (k) (n) denote the number of bordering palindromes of type j and straddling palindromes of W (k) n , respectively. Then by Definition 11, the following recurrence relation holds The following theorem gives a recurrence formula for computing P (k) (n). The proof which is formally stated in Section 4.4, is based on considering several cases with respect to values of n and k. This is done in Sections 4.1-4.3.
Theorem 17. Let k > 2 and n 1 be given integers. Then the following holds To prove the theorem we divide the rest of this section into some subsections with respect to the values of n and k. Proof. We prove this by induction on n. Since for every k > 2 we have W (k) 1 = 01, the first step of the induction is true. Suppose n = j < k − 1, the word W (k) j j −1 is a palindrome. Now using Lemma 5, we have which is a palindromic word by induction hypothesis.
Proof. Since the digit n just occurs in the last position of W (k) n , every palindromic factor of W (k) n either equals to n or is a palindromic factor of W (k) n n −1 . By Lemma 5, for every n k − 1, we have the electronic journal of combinatorics 27(3) (2020), #P3.59 From Equation (8), we conclude that n − 1 occurs once in W (k) n n −1 . Using Lemma 18 and again using Equation (8), we find that a factor P of W (k) n n −1 is a palindromic word if and only if it is either a palindromic factor of W Theorem 20. For every 0 n k − 1, P (k) (n) = n2 n−1 + 1.
Proof. The proof is easy by induction on n.

Bordering Palindromes of W (k)
n In this section, we consider the bordering palindromes of W and j is the center of B j .
Proof. By Definition 11, we know that B j is a factor of W = W n−k+1 , and it contains the last digit of W (k) j , which is j. By Lemma 9, |W | j = 1. Hence |B j | is an odd integer and j is the center of B j . Moreover Using Definition 10 and Equation (6), we have B j [c + 1] = 0. If j = 0, then by definition of c, we obtain B j [c + 1] = B j [c − 1] = j − j . Since B j [c + 1] = 0, j = j , which shows that 0 j k − 1. Moreover, by Equation (6), n − k + 2 j n − 1. Hence  Proof. By Definition 11, B j is a palindromic factor of the following word and by Lemma 21, j is the center of B j . Using Lemma 22, j k − 1 and n − k + 1 j − 1. On the other hand by Lemma 4, we have W Lemma 24. Let n and j be two integers with k n 2k − 3 and n − k + 2 j k − 1 and B j be a maximal bordering palindrome of type j of W Proof. By Lemma 23, we have Using Equation (5), Hence, Lemma 25. Let n k, then Proof. If n 2k − 3 and n − k + 2 j k − 1 and B j be the maximal bordering palindrome of type j of W (k) n . then by Lemmas 23 and 24, we have The last equality holds using Corollary 8. In other cases, by Lemma 22, B (k) (n, j) = 0, as desired.

Straddling Palindromes of W (k)
n In this subsection, we are going to count the number of straddling palindromes of W Proof. First we note that (k ⊕ W (k) n−k ) starts with k and W (k) n−k+1 ends with n − k + 1. Hence, the sequence (n − k + 1).k occurs in any straddling palindrome P of W (k) n . Since P is a palindrome, the sequence B = k.(n − k + 1) also occurs in P . Hence, by Lemma 13, B ∈ B (k) . Since n k, using Definition 12, we provide B ∈ B  Proof. Let i = n − 2k. Then, by Equation (6), Hence, the electronic journal of combinatorics 27(3) (2020), #P3.59 i+2 |. By definition of the (A, B)straddling palindrome of W (k) 2k+i and using Equation (9), we conclude that A V W k+i |. We claim that j > . For the contrary, let j . The letter following i + 2 in Equation (9) is k. Hence, (i + 2)k ≺ W and so k(i + 2) ≺ W , but this is impossible by Corollary 15, since 1 < i + 2 < k. Therefore, A (k ⊕ W Proof. Let be the largest digit of P and for contrary suppose that > i + 1. Using Lemma 9, we have < i + k. Hence, i+k . We note that + 1, which is the last digit of W On the other hand W n−2k+2 (n − 2k + 2) −1 ) and hence |B| 2 n−2k+2 − 1. Proof. Let i = n − 2k. Then, using Equation (6) we have Hence, k + i + 2 ∈ Alph(A). We claim that k + i + 2 ∈ Alph(B). For contrary suppose that k + i + 2 ∈ Alph(B). We note that (k ⊕ W i+2 |, then by Lemma 9, B[m] = k + i + 2 and for all m < m, B[m ] < k + i + 2. On the other hand by Equation (11), k + i + 2 ∈ Alph(A), hence c p (W, W ) |A| + m. Therefore, (k + i + 1)B contains a palindrome prefix P with k + i + 2 ∈ Alph(P ), which is impossible by Lemma 29. Hence, k + i + 2 ∈ Alph(B), which implies that B k ⊕ (W (k) i+2 (i + 2) −1 ) and by Corollary 8, |B| 2 i+2 − 1 = 2 n−2k+2 − 1. Now, we are ready to prove the following lemma.
Lemma 31. Let 2k − 1 < n < 3k − 2. Then W (k) n has exactly two maximal straddling palindromes, one of which is the (k ⊕ W n−2k+1 (n − 2k + 1) −1 ))-straddling palindrome and the other is the (k ⊕ W i+2 (i + 2) −1 ). Then by Lemmas 28 and 30, we conclude that S ≺ W . Moreover, by Equation (5) we have By the last equation and using Lemma 9, we conclude that |W | k+i+1 = 2. Let c 1 and c 2 be two integers with k+i ) in the previous expression. Thus, the first occurrence of k + i + 1 in W is the last letter of (k ⊕ W (k) k+i ). Since S is a straddling palindrome of W (k) 2k+i , the first occurrence of the digit has to be in S. Therefore, either c p (S, W ) = c 1 or c p (S, W ) = c 1 +c 2 2 . In other words, the center position of S is either the corresponding position of the first occurrence of k + i + 1, or is the position of the middle digit between the two occurrences of k + i + 1 in W . So, we have the following two cases • S has only one digit k + i + 1: in this case we show that A = k ⊕ W (k) is a palindrome and this is true by Lemma 18.
Lemma 34. Let n = 3k − 2. Then W (k) n has exactly two maximal straddling palindromes which are respectively the (k ⊕ W Proof. Let W be an (A, B)-maximal straddling palindrome of W (k) 3k−2 . Using Equation (6) we have the electronic journal of combinatorics 27(3) (2020), #P3.59 Therefore, using Lemmas 33 and 34 every (A, B)-straddling palindrome S of W By Lemma 9 and Equation (14) the digit 2k − 1 occurs twice in W . Let c 1 and c 2 be two integers with 3k−2 , S should contain the first occurrence of 2k − 1 in W . Therefore, either we have c p (S, W ) = c 1 or c p (S, W ) = c 1 +c 2 2 . In other words the center position of S is either the position of the first occurrence of 2k − 1 in W or exactly the position of the digit in the middle of the two occurrences of 2k − 1 in W . So, we have the following two cases is a palindrome and this is true by Lemma 18.
• |S| 2k−1 = 2 : In this case we show that is a palindrome and using Lemmas 32 and 33, S = AB is a maximal straddling palindrome as desired.

Proof of Theorem 17
Theorem 12. Let k > 2 and n 0 be given integers. Then the following holds (i) If 0 n k − 1, then P (k) (n) = n2 n−1 + 1, Proof. (i) This part is true according to Theorem 20.

Examples
In the following example in the case k = 4 for some different values of n we give all of the maximal straddling palindromes and the maximal bordering palindromes of W

Palindrome Structure
In this section, based on finding the structure of all palindromic factors of W (k) , we compute its palindrome complexity, pal W (k) (n). We recall that for a fixed word U ∈ A ∞ , pal U (n) is the number of palindromic factors of length n of U . Hence, pal U (n) is a function from N to N ∪ {∞}.
Definition 38. For a set P of palindromic words, we define Remark 39. It is obvious from Definition 38 that any element of CPal(P ) is a palindromic factor of some word of P , but there may exist other palindromic factors of words of P which do not belong to CPal(P ) as is seen from the following example. Note that the words 1, 2, 33 and 121 are palindromic factors of some words of P but they are not elements of CPal(P ).
Proof. Since any element of P is a palindrome, by Definition 38, any element W ∈ CPal(P ) is also a palindromic factor of U , whence the result follows.
Lemma 42. For any integer k > 2 we have j+k . Hence, using induction on i, for every nonnegative integer i we provide the electronic journal of combinatorics 27(3) (2020), #P3.59 To complete the proof, we need to show that holds for all integers n. But since m < n implies that W n ), it suffices to prove that Equation (17) holds from a point on, say that it holds for all n > 3k − 3. To prove this, we use strong induction on n. The basis step n = 3k − 2 is obviously true because Pal(W (k) 3k−2 ) appears in the right side of Equation (17). For the inductive step, let n > 3k − 2 and assume that Equation (17) holds for all integers j, 3k − 2 j < n. Since 3k − 2 < n, using Lemma 25 and Theorem 35, W (k) n has neither a straddling palindrome nor a bordering palindrome. Hence, by Equation (6), we have n−k ))).
By the induction hypothesis we have Therefore, Equation (17) holds for j = n, as desired.
To present the next results we need the following definition. Definition 43. Let k > 2. We define the following sets of words: Proof. Let m ∈ N and m = (j mod k). If j = 0 or j = 1, then by Definition 43, we have 0, 010 ∈ P (k) 1 and hence m ∈ CPal(P (k) 1 ). Otherwise 2 j k − 1 and using Lemma 23, for every integer n satisfying k n k + j − 2 we have Hence, j ∈ CPal(P Lemma 45. Let k > 2. Then Proof. Using Lemma 18, By Lemma 23, the set By Lemma 31, 2k n 3k − 3} ⊆ Pal(W (k) ).
The following six lemmas give the structure of the palindromes of W (k) n , when n 3k − 2.
Lemma 46. Let k > 2, 1 n < k and P be a maximal palindromic factor of W (k) n of length at least 2. Then P ∈ P (k) 1 .
Proof. By Lemma 18, W (k) n n−1 (n − 1) −1 is a maximal palindrome with center n − 1. Therefore, it is easy to see that the maximal palindromes appearing in W Lemma 47. Let 2 < k n 2k − 3 and P be a maximal palindromic factor of W (k) n of length at least 2, then P ∈ P (k) Proof. We prove the result using induction on n. For the basis step let n = k and P ∈ P n . Since P / ∈ P (k) 1 , using Lemma 46, we conclude that P is not an included palindromic factor of W Lemma 52. Let k > 2 and let P be a maximal palindromic factor of W (k) of length at Proof. By Lemma 42, there exist i 0 and 1 j 3k − 2 such that P is a maximal palindrome of W (k) j and P = ki ⊕ P . Now, using Lemmas 46-51, P ∈ Theorem 53. For any integer k > 2 we have Proof. First we prove that the left side of Equation (22) is a subset of its right side. For this, consider any element P ∈ Pal(W (k) ). If |P | = 1, then by Lemma 44, P ∈ CPal( 4 i=1 P (k) i ). Otherwise, consider a maximal palindromic factor factor U of W (k) such that P ∈ CPal({U }). By Lemma 52, U ∈ 4 i=1 P (k) i . therefore, using Lemma 41, P ∈ CPal( 4 i=1 P (k) i ) as required.

Length of Palindromes in W (k)
In this section, we want to compute all possible values for the lengths of palindromes in W (k) .
Definition 57. Let k > 2, and for 1 i 4. Let P Proof. We just prove L(P then L(P (k) 1 ) = {1, 3, 5, · · · , 1 }. Therefore, to prove this part it suffices to show that 1 = 2 k−1 − 1. By Definition 43 and Corollary 8, we have Theorem 59. For every integer k 3, the palindrome complexity of W (k) is given by Proof. Let A = {2} ∪ {2i − 1 : 1 i 3 · 2 k−2 − 1}. Using Theorem 53 and Lemma 58, we find that if n ∈ A, then there is no palindromic factor in W (k) of length n, in other words pal W (k) (n) = 0. If n ∈ A, then by Theorem 53 and Lemma 58, W (k) has at least one palindromic factor of length n or equivalently pal W (k) (n) = 0. By Definitions 43 and 57, it is easy to see that in this case pal W (k) (n) = ∞.