    # Palindromic Ziv-Lempel and Crochemore Factorizations of m-Bonacci Infinite Words

We introduce a variation of the Ziv-Lempel and Crochemore factorizations of words by requiring each factor to be a palindrome. We compute these factorizations for the Fibonacci word, and more generally, for all m-bonacci words.

## Authors

##### This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

## 1 Introduction

The Ziv–Lempel  and Crochemore  factorizations are two well-known factorizations of words used in text compression and other text algorithms. Here we apply them to infinite words. Let denote the length of a finite word . In this paper, we start indexing words at , i.e., if is a finite word over the alphabet , then we write where for all . If is an infinite word and is a finite word, we say there is an occurrence of at position in if for some word of length and some infinite word . Given an infinite word , the Ziv–Lempel or -factorization of is the factorization

 z(w)=(z1,z2,z3,…)

where is the shortest prefix of such that there is no occurrence of in at any position . The Crochemore or -factorization of is the factorization

 c(w)=(c1,c2,c3,…)

where is the longest prefix of such that there is an occurrence of in at some position , or, if this prefix does not exist, the factor is just a single letter.

For instance, if is the Fibonacci word, we have

 z(f)=(0,1,00,101,00100,10100101,…)

and

 c(f)=(0,1,0,010,10010,01010010,…).

Note that if is ultimately periodic the -factorization is not well-defined, since eventually there will be no factors that do not occur previously in . Similarly, if is ultimately periodic the definition of the -factorization will result in some factor being an infinite word. We are not interested in ultimately periodic words in this paper and will therefore ignore this possibility and assume that any infinite word considered in this paper is aperiodic.

In the context of combinatorics on words, these factorizations have been computed for certain important families of words. Berstel and Savelli  computed the -factorizations of all standard Sturmian words. They also observed that the -factorization of the Fibonacci word coincides with the singular factorization of the Fibonacci word introduced by Wen and Wen . Fici  has given an excellent survey of these and other factorizations of the Fibonacci word. Ghareghani, Mohammad–noori, and Sharifani  determined the - and -factorizations of standard episturmian words. Constantinescu and Ilie  used the -factorization to define the Lempel–Ziv complexity of an infinite word.

We introduce the palindromic -factorization and palindromic -factorization by requiring that each of the factors in the previous definitions be palindromes. That is, the palindromic -factorization of is the factorization

 pz(w)=(z1,z2,z3,…)

where is the shortest palindromic prefix of such that there is no occurrence of in at any position . The palindromic -factorization may not exist for certain infinite words . For instance, if only contains palindromes of bounded length, then the palindromic -factorization will not exist. This type of factorization is therefore only interesting when applied to infinite words with arbitrarily long palindromic factors. The palindromic -factorization of is the factorization

 pc(w)=(c1,c2,c3,…)

where is the longest palindromic prefix of such that there is an occurrence of in at some position , or, if this prefix does not exist, the factor is just a single letter.

For instance, if is the Fibonacci word, we have

 pz(f)=(0,1,00,101,00100,10100101,…)

and

 pc(f)=(0,1,0,010,1001,0010100,…).

It turns out that and are the same, and in fact are equal to the singular factorization of (which we define later). However, the factorizations and are not the same. We show that the factors of can also be written in terms of the singular words and the factorization (except for the first few factors) coincides with a nice factorization of that appears in .

We believe that it could be of interest to compare the ordinary - and -factorizations of certain infinite words with their palindromic - and -factorizations, in the same way that one can compare the ordinary complexity function of an infinite word with its palindromic complexity function (see ).

The main results of this paper give a description of the palindromic - and -factorizations of the Fibonacci word and, more generally, the -bonacci word for .

## 2 Basics from combinatorics on words

Let be a finite alphabet, i.e., a finite set made of letters. A (finite) word over is a finite sequence of letters belonging to . If with and for all , then the length of is , i.e., it is the number of letters that contains. We let denote the empty word. This special word is the neutral element for concatenation of words, and its length is set to be . The set of all finite words over is denoted by , and we let denote the set of non-empty finite words over . An infinite word over is any infinite sequence over . The set of all infinite words over is denoted by . Note that in this paper infinite words are written in bold.

A finite word is a prefix (resp., suffix) of another finite word if there exists such that (resp., ). The word is said to be a factor of if there exist such that . If is a finite word over , we write and . Observe that if with , then and . In particular, for any words , we have .

In the same way, a finite word is a prefix of an infinite word if there exist such that . The word is said to be a factor of if there exist and such that .

Let with and for all . The mirror image, or reversal, of is the word over , i.e., the word obtained by reading from right to left. We say that a word over is a palindrome if .

A factorization of a finite word is a finite sequence of finite words over such that

 w=m∏n=0xn.

Similarly, a factorization of an infinite word is a sequence of finite words over such that

 w=∏n≥0xn.

A morphism on is a map such that for all , we have . In order to define a morphism, it suffices to provide the image of letters belonging to . A morphism is said to be prolongable on a letter if with and is non-erasing, i.e., the image of no letter is the empty word. If is prolongable on , then is a proper prefix of for all . Therefore, the sequence of finite words defines an infinite word that is a fixed point of .

In combinatorics on words, given an alphabet , a set of non-empty words is a code on if any word has at most one factorization using words of . For more on this topic, see, for instance, [10, Chapter 6]. The following result can be found in [10, Chapter 6].

###### Proposition 1.

Let be two finite alphabets, and let be an injective morphism. If is a code on , then is a code on .

In the following definition, we introduce two new factorizations of interest.

###### Definition 2.

Let be an infinite word over . The palindromic Ziv–Lempel or palindromic -factorization of is the factorization

 pz(w)=(z1,z2,z3,…)

where is the shortest palindromic prefix of such that there is no occurrence of in at any position . The palindromic Crochemore or palindromic -factorization of is the factorization

 pc(w)=(c1,c2,c3,…)

where is the longest palindromic prefix of such that there is an occurrence of in at some position , or, if this prefix does not exist, the factor is just a single letter.

## 3 The Fibonacci case

### 3.1 Some known results and preliminaries

Before establishing the two palindromic factorizations of the Fibonacci word, we gather some definitions and necessary results. Some of them are well known and can be found in [5, 13]. In the following definition, we follow the lines of .

###### Definition 3.

Let be the (infinite) Fibonacci word, i.e., the fixed point of the morphism , starting with . For all , define the finite word to be the th iteration of on . The first few words of the sequence are . It is well known that the Fibonacci word is the limit of . Let be the sequence of the palindromic prefixes of , which are also called central words. The first few terms of this sequence are . The singular words satisfy , and, for all , and . The first few singular words are .

The following properties of the singular words can be found in .

###### Proposition 4.

Let be the sequence of Fibonacci numbers with initial conditions and .

• For all , is a palindrome.

• For all , .

• For all , .

• For all , is not a factor of .

• For all , is not a factor of .

• Let and let where and . If with , then .

• Let and define to be if

is odd, or

if is even. Then .

The following result can be found in . Note that the first factorization of the Fibonacci word also appears in .

###### Proposition 5.

We have the following two factorizations of the Fibonacci word

 f = ∏n≥1^fn = 0⋅1⋅00⋅101⋅00100⋅10100101⋯ = 010∏n≥2^fn−1^fn^fn−1 = 010⋅(0⋅1⋅0)⋅(1⋅00⋅1)⋅(00⋅101⋅00)⋅(101⋅00100⋅101)⋯.

Moreover, the Ziv–Lempel factorization of the Fibonacci word is given by the sequence of singular words, i.e.,

 z(f)=(^f1,^f2,^f3,…).

As a matter of fact, the palindromic -factorization of is easily deduced from the previous result, as shown in the next section. However, the palindromic -factorization of cannot be obtained from already known results, and, to that aim, we define a sequence of specific prefixes of .

###### Definition 6.

For all , define

 gn:=010∏2≤m≤n−1^fm−1^fm^fm−1.

From (5), observe that, for all , we have

 f=gn⋅(^fn−1^fn^fn−1)⋅∏m≥n+1^fm−1^fm^fm−1.

Interestingly, the prefix of can be factorized as a particular product of singular words.

###### Proposition 7.

For all , we have

 gn=^f1^f2⋯^fn−1^fn^fn−1^fn−2. (3)
###### Proof.

Proceed by induction on . The result holds for because . For , we get by Definition 6 and therefore

 g3=0⋅1⋅00⋅1⋅0=^f1^f2^f3^f2^f1,

as desired. Assume that . Now we suppose the result holds up to and we show it still holds for . Using Definition 6, we have

 gn+1=gn(^fn−1^fn^fn−1).

By the induction hypothesis, we get

 gn+1 =(^f1^f2⋯^fn−1^fn^fn−1^fn−2)(^fn−1^fn^fn−1) =^f1^f2⋯^fn−1^fn(^fn−1^fn−2^fn−1)^fn^fn−1.

Since , Proposition 4 implies that , and we deduce that

 gn+1=^f1^f2⋯^fn−1^fn^fn+1^fn^fn−1,

which ends the proof. ∎

### 3.2 The palindromic z-factorization of the Fibonacci word

In this (very) short section, we obtain the palindromic -factorization of the Fibonacci word, which easily follows from already known results.

###### Theorem 8.

The palindromic -factorization of the Fibonacci word is

 pz(f)=(^f1,^f2,^f3,…).
###### Proof.

From Proposition 5, . Since the factors are all palindromes by Proposition 4, this factorization is also . ∎

### 3.3 The palindromic c-factorization of the Fibonacci word

In this section, we show that, after the prefix of length , the factorization (5) coincides with the factorization . Note that in this case and are not the same, since the factors in are not palindromes.

###### Lemma 9.

For all , the only suffix of that is also a prefix of is the empty word.

###### Proof.

We proceed by induction on . From Definition 3, the first two singular words are and , so the result can be checked by hand for .

Now suppose that , and that the only suffix of that is also a prefix of is the empty word, for all . We show that the result still holds for . Proceed by contradiction and suppose there exists a word which is a non-empty suffix of and a non-empty prefix of . We have . Using Proposition 4(6), starts and ends with .

If , then is a prefix of (recall that is a prefix of ). Consequently, is a non-empty suffix of and a non-empty prefix of . This contradicts the inductive assumption.

If , then is a prefix of (recall that is a prefix of ). In particular, is a factor of , and also a factor of (recall that is a suffix of ). This contradicts Proposition 4(4). ∎

In the following lemma, recall that we start indexing words at .

###### Lemma 10.

Let . There are exactly two occurrences of the factor inside the word : one at position , the other at position .

###### Proof.

If , then and the factor occurs in at positions and . If , then with for all . There are exactly two occurrences of in starting either at position or .

Suppose that . Using (3), let us write with . Thanks to this factorization, we immediately see that occurs at least twice as a factor of : one starting at position , the other beginning at position . We now show that there are no other occurrences of as a factor of . There are several cases to consider.

Case 1. The word cannot be a factor of , otherwise it contradicts Proposition 4(5).

Case 2. The word cannot be a factor of , otherwise it contradicts Proposition 4(4).

Case 3. The word cannot be a factor of since by Proposition 4(2) (note that ).

Case 4. Suppose that is a factor of , overlapping and . Using Proposition 4(2) (), we know that

 |^fn|=Fn=Fn−1+Fn−2=|^fn−1|+|^fn−2|.

Consequently, is a factor of . If starts somewhere within , or if starts with the first letter of , then is a factor of , which contradicts Proposition 4(4). Therefore must be a factor of , i.e., there exist a non-empty suffix of and a non-empty prefix of such that . Then is also a non-empty prefix of , which contradicts Lemma 9.

Case 5. Suppose that is a factor of , overlapping and . This case is similar to the fourth case above. Indeed, observe that, since , Proposition 4(3) gives

 ^fn+1=^fn−1^fn−2^fn−1.

Using Proposition 4 again, we know that . Consequently, is a factor of , so is a factor of , which is impossible due to the fourth case.

Case 6. Suppose that is a factor of , overlapping and . In this case, is a factor of since the singular words are palindromes. As in the fifth case, we raise a contradiction.

Case 7. Suppose that is a factor of , overlapping and . In this case, is a factor of since the singular words are palindromes. As in the fourth case, we reach a contradiction. ∎

We prove a technical result before getting the palindromic -factorization of .

###### Proposition 11.

Let . Let be a non-empty common finite prefix of the infinite words

 ^fn−1⋅(^fn^fn+1^fn)⋅(^fn+1^fn+2^fn+1)⋯

and

 (^fn+1^fn+2^fn+1)⋅(^fn+2^fn+3^fn+2)⋯.

Then is not a palindrome.

###### Proof.

Let us define

 un+1:=^fn^fn+1^fnw

where is taken as in the statement. Using Proposition 4, since and , we know that . Now proceed by contradiction and suppose that is a palindrome. Then we have

 ^fn^fn+1^fnw=un+1=uRn+1=wR^fn^fn+1^fn. (4)

The bounds on the length of lead to an overlap between the occurrence of at position (in the leftmost word in (4)), and the occurrence at position (in the rightmost word in (4)). This is impossible due to either Proposition 4(4), or Lemma 9. ∎

###### Theorem 12.

Let denote the palindromic -factorization of the Fibonacci word . Then, we have , , and, for all ,

 cn=^fn−1^fn^fn−1.
###### Proof.

By definition of the palindromic -factorization of the Fibonacci word , we clearly have , and . For the second part of the result, proceed by induction on . Suppose . Let us find the factor of the palindromic -factorization of . We have

 f=0⋅1⋅0⋅01010010010100101⋯

and the longest palindrome starting with and occurring before is

 c2=010=0⋅1⋅0=^f1^f2^f1,

as expected.

For the induction step, suppose and assume that, for all , we have . We show it is still true for . On the one hand, by the induction hypothesis, we have

 f = c−1c0c1c2⋯cncn+1cn+2⋯ (5) = 010(∏2≤m≤ncm)cn+1cn+2⋯ = 010(∏2≤m≤n^fm−1^fm^fm−1)cn+1cn+2⋯

and the goal is to find the next factor of the palindromic -factorization of , i.e., the word . On the other hand, using (5) first and then (3) since is large enough, we get

 f = 010(∏2≤m≤n^fm−1^fm^fm−1)(^fn^fn+1^fn)(^fn+1^fn+2^fn+1)⋯ (6) = gn+1(^fn^fn+1^fn)(^fn+1^fn+2^fn+1)⋯ = (^f1^f2⋯^fn−1^fn^fn+1^fn^fn−1)(^fn^fn+1^fn)(^fn+1^fn+2^fn+1)⋯.

Using (6), it is clear that since is a palindrome occurring before. Therefore, there exists a word such that . We claim that is in fact the empty word and proceed by contradiction.

By Lemma 10, we know that there are exactly two occurrences of in : one starts at position , and the other at position .

Case 1. Let us deal with the occurrence of in at position . In this case, must be a common prefix of the infinite words

 ^fn−1⋅(^fn^fn+1^fn)⋅(^fn+1^fn+2^fn+1)⋯

and

 (^fn+1^fn+2^fn+1)⋅(^fn+2^fn+3^fn+2)⋯.

By Proposition 11, we know that is not a palindrome if is non-empty, a contradiction.

Case 2. Let us consider the occurrence of in at position . In this case, must be a common prefix of the infinite words

 ^fn^fn−1⋅(^fn^fn+1^fn)⋅(^fn+1^fn+2^fn+1)⋯

and

 (^fn^fn+1^fn)⋅(^fn+1^fn+2^fn+1)⋅(^fn+2^fn+3^fn+2)⋯.

Using Proposition 4, we know that

 |^fn+1|=Fn+1=Fn+Fn−1=|^fn|+|^fn−1|.

Consequently, , which violates Proposition 4 (items (4) or (6)).

As a conclusion, the longest palindrome starting with the first letter of and occurring before is

 cn+1=^fn^fn+1^fn,

as required. ∎

## 4 The m-bonacci case

In this section, we extend the results obtained for the Fibonacci word to any -bonacci word, namely we get the palindromic - and -factorizations of any -bonacci word. The strategy is similar to the one adopted in the previous case: we define a particular sequence of finite words that we will call p-singular words, and we write the palindromic - and -factorizations of any -bonacci word in terms of this sequence. In the case , the words turn out to be the singular words (see Proposition 22).

### 4.1 Preliminaries

###### Definition 13.

Let . We define the morphism on by

 ϕm:0↦01,1↦02,⋯,(m−2)↦0(m−1),(m−1)↦0.

When , then , and we fall into the Fibonacci case above.

Let be the (infinite) -bonacci word, i.e., the fixed point of the morphism , starting with . For all , define to be the th iteration of on . It is well known that the -bonacci word is the limit of . For the sake of simplicity, when the context is clear, we write instead of .

From now on, is a fixed integer greater than unless otherwise specified.

###### Example 14.

If , then is the Fibonacci word. See also Definition 3. If , then , and the infinite word is called the Tribonacci word. If , then , and the infinite word is called the Quadribonacci word. In Table 1, the first few words of the sequences