 # A Unique Extension of Rich Words

A word w is called rich if it contains | w|+1 palindromic factors, including the empty word. We say that a rich word w can be extended in at least two ways if there are two distinct letters x,y such that wx,wy are rich. Let R denote the set of all rich words. Given w∈ R, let K(w) denote the set of all words such that if u∈ K(w) then wu∈ R and wu can be extended in at least two ways. Let ω(w)=min{| u|t | u∈ K(w)} and let ϕ(n)=max{ω(w)| w∈ R| w|=n}, where n>0. Vesti (2014) showed that ϕ(n)≤ 2n. In other words, it says that for each w∈ R there is a word u with | u|≤ 2| w| such that wu∈ R and wu can be extended in at least two ways. We prove that ϕ(n)≤ n. In addition we prove that for each real constant c>0 and each integer m>0 there is n>m such that ϕ(n)≥ (2/9-c)n. The results hold for each finite alphabet having at least two letters.

## 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

A word is called a palindrome if it is equal to its reversal. Two examples of palindromes are “noon” and “level”. It is known that a word can contain at most distinct palindromic factors, including the empty word [DrJuPi]. If the bound is attained, the word is called rich. Quite many articles investigated the properties of rich words in recent years, for example [BuLuGlZa2, DrJuPi, GlJuWiZa, RukavickaRichWords2019, Vesti2014]. Some of the properties of rich words are stated in the next section; see Propositions 2.1, 2.2, and 2.3.

In [GlJuWiZa] it was proved that if is rich then there is a letter such that is also rich. In [Vesti2014] it was proved that if is rich then there is a word and two distinct letters such that and are rich. Concerning this result, the author of [Vesti2014] formulated an open question:

• Let be a rich word. How long is the shortest such that can always be extended in at least two ways?

In the current article we improve the result from [Vesti2014] and as such, to some extent, we answer to the open question. Let denote the set of all rich words. We say that a rich word can be extended in at least two ways if there are two distinct letters such that are rich. Given , let denote the set of all words such that if then and can be extended in at least two ways; contains the empty word if can be extended in at least two ways. Let and let , where . The result from [Vesti2014] can be presented as .

We show that . It is natural to ask how good this bound is. The rich word is called a unique rich extension of if there is no proper prefix of such that can be extended in at least two ways. In Remark in [Vesti2014] there is an example which shows that there are such that is a unique rich extension of and , where . However in the given example the length of grows significantly more rapidly than the length of as tends towards infinity. This could suggest that ; we show that this suggestion is false. We prove that for each real constant and each integer there is such that .

We explain the idea of the proof. Let denote the reversal of the word . We construct rich words , where such that

1. The word is the longest palindromic suffix of .

2. For every factor of we have that is a factor of , where are distinct letters and is a palindrome.

3. .

Let be a prefix of , where is a letter. Let be a letter distinct from and let be the longest palindromic suffix of . Property 1 implies that is a suffix of , since is the longest palindromic suffix of . Property 2 implies that is not unioccurrent in . In consequence is not rich; see Proposition 2.3. Hence there is no proper prefix of such that can be extended in at least two ways. It follows that . Property 3 implies that for each there is such that .

We will see that to find for given is quite straightforward. The crucial part of our construction is the word . To be specific, the word that we will present contains only a “small” number of factors defined in Property 2. As a result the length of grows almost linearly with the length of as tends towards infinity.

## 2 Preliminaries

Consider an alphabet with letters, where . Let denote the set of all nonempty words over . Let denote the empty word, and let . We have that .

Let be the set of all factors of the word ; we define that . Let and be the set of all prefixes and all suffixes of respectively; we define that .

Let , where . The set is the union of sets of suffixes of , where is a nonempty prefix of .

We define yet the reversal that we have already used in the introduction: Let denote the reversal of ; formally if then , where and .

Let and denote the longest palindromic suffix and the longest palindromic prefix of respectively. We define that . Let and denote the longest proper palindromic suffix and the longest proper palindromic prefix of respectively, where . If then we define .

Let , where , , , and . Let , where , , , and . The functions and remove the last and the first letter of respectively.

Let be the number of occurrences of in , where ; formally . We call a factor unioccurrent in if .

We list some known properties of rich words that we use in our article. All of them can be found, for instance, in [GlJuWiZa]. Recall the notion of a complete return [GlJuWiZa]: Given a word and factors , we call the factor a complete return to in if contains exactly two occurrences of , one as a prefix and one as a suffix.

###### Proposition 2.1.

If , , and is a palindrome then all complete returns to in are palindromes.

If and then .

###### Proposition 2.3.

A word is rich if and only if every prefix has a unioccurrent palindromic suffix.

From Proposition 2.2 and Proposition 2.3 we have an obvious corollary.

###### Corollary 2.4.

A word is rich if and only if every suffix has a unioccurrent palindromic prefix.

## 3 Standard Extension

We define a left standard extension and a right standard extension of a rich word. The construction of a standard extension has already been used in [Vesti2014]. The name “standard extension” has been introduced later in [RukavickaRichWords2019]. Here we use a different notation and we distinguish a left and a right standard extension.

###### Definition 3.1.

Let be a nonnegative integer, , and . We define , as follows:

• .

• , where is such that .

• , where is such that .

• , where .

• , where .

Let . We call a left standard extension of . Let . We call a right standard extension of .

###### Remark 3.2.

It is easy to see that and , where .

If then , since .

###### Example 3.3.

Let and . Then we have:

• and .

• , ,
, ,
, ,
.

• , ,
, ,
, ,
, .

A left and a right standard extension of a rich word is rich. In consequence, every rich word can be extended to rich words for some letters ; this has already been proved in [GlJuWiZa, RukavickaRichWords2019, Vesti2014].

If and then .

###### Proof.

Since and since for every there is a rich word such that , it is enough to prove that .

Let , where . Because , Proposition 2.3 implies that we need to prove that is unioccurrent in . Realize that ; it means that is either unioccurrent in or is a complete return to . In either case is unioccurrent in . This completes the proof. ∎

## 4 A unique rich extension

We formally define a unique rich extension mentioned in the introduction. In addition we define a flexed point of a rich word.

###### Definition 4.1.

If , , and

 Prf(rtrim(u))∩{vt∣t∈ω(v)}=∅

then we call a unique rich extension of .

Given with , let

 T(v)={ux∣ux∈Prf(v) and x∈A and ux≠ER(u)}.

We call a flexed point of .

###### Remark 4.2.

Note that if and is a flexed point of a rich word then can be extended in at least two ways. A similar notion of a “flexed palindrome” has been used in [RukavickaRichWords2019].

###### Example 4.3.

Let .

• The rich word can be extended in at least two ways, because , , and are rich.

• The rich word cannot be extended in at least two ways because and are not rich. Only the right standard extension is rich. Hence is a unique rich extension of .

• If then is unique rich extension of ; this example is a modification of the example in Remark in [Vesti2014].

• If then the set of flexed points of is:

 T(w)={20,201,20101,201011,2010110111,20101101110111,201011011101111}.

There is a connection between a unique rich extension and a right standard extension.

###### Lemma 4.4.

If is a unique rich extension of then .

###### Proof.

Suppose there is such that , , and . Then obviously can be extended in at least two ways, since both and are rich. Hence cannot be a unique rich extension of . The lemma follows. ∎

To simplify the formulation of next lemmas and propositions concerning a unique rich extension we define an auxiliary set as follows: if is a unique rich extension of and , where .

We show that if is unique rich extension of , then is unioccurrent in .

If then .

###### Proof.

The proposition follows from the proof of Theorem in [Vesti2014]. The author shows that a rich word can be extended into a rich word in such a way that is a suffix of , where is the largest power of some letter . It is proved that can be extended in at least two ways. In both cases distinguished in the proof of Theorem in [Vesti2014] it is easy to see that . The proposition follows. ∎

We present two simple properties of a unique rich extension.

Let .

1. If then .

2. If then .

###### Proof.

Obviously . Lemma 4.4 implies that . The lemma follows. ∎

The next proposition discusses words of the form , where is unique rich extension of , is a letter, is the longest proper palindromic suffix of , and is a flexed point of . The proposition asserts that there are words such that , is a proper suffix of , and is a flexed point of . In particular it implies that .

###### Proposition 4.7.

If and then there exist such that

• ,

• , and

• .

###### Proof.

Let and let be such that . Since we have that .

Obviously because is a unique rich extension of and thus . Hence the palindromic suffix of is not unioccurrent in , see Proposition 2.3.

We have that is unioccurrent in and , since and is unioccurrent in , see Proposition 4.5. It follows that there are such that , and is unioccurrent in . Thus .

From the fact that follows that . Lemma 4.6 implies that and . Just consider that would imply that .

Since , , , and it follows that ; hence Proposition 2.1 implies that . It follows that . Consequently and thus . This completes the proof. ∎

We step to the main result of this section. The theorem says that if is a unique rich extension of and is the longest proper palindromic suffix of then is not longer than .

If then .

###### Proof.

Let . If then clearly . For the rest of the proof suppose that . We show that the set of flexed points is nonempty. Let . Proposition 4.5 implies that , because . Since it follows that there are and such that and ; just realize that . We showed that .

Without lost of generality, suppose that is the longest flexed point from the set and suppose that . Proposition 4.7 asserts that there are such that , , and . If , then , see Lemma 4.6. This is a contradiction, since we supposed that is the longest flexed point of . We conclude that . This completes the proof. ∎

The simple corollary is that if is a unique rich extension of then is not longer than .

If then .

###### Proof.

The corollary is obvious for . If is a unique rich extension of , , and then there is clearly such that . Then the corollary follows from Theorem 4.8. ∎

## 5 Construction of a Uniquely Extensible Rich Word I

###### Definition 5.1.

We call a word a switch if , , and is a palindrome. Let . Let , where .

Given , let

 rdc(S)={w∣w∈S and w∉⋃u∈S∖{w}F(u)}.

We call a reduction of .

Suppose is a switch, let , where . We call a switch palindromic closure of the switch . If is a set of switches then we define .

###### Remark 5.2.

Note that if is a switch, then can be the empty word.

The set is a set of switches that are suffixes of for all nonempty prefixes of .

The reduction of the set is a subset of and contains only elements that are not proper factors of other elements of .

The switch palindromic closure of a set is a reduction of the union of all switch palindromic closures of switches from the set .

###### Example 5.3.

Let , , and . Then we have:

• .

• .

• , , ,
.

• .

The following proposition clarifies the importance of switches for a unique rich extension of rich words. The proposition says that if

• is a rich word and

• is the longest palindromic suffix of and

• is a factor of for every letter and

• for every switch which is a suffix of for some we have that is a factor of

then is unique rich extension of .

###### Proposition 5.4.

If , , , , and then is a unique rich extension of .

###### Proof.

We show that there is no prefix , where . Suppose that there is . Let be such that and . Let . We distinguish two cases:

• . The assumptions of the proposition guarantee that .

• for some palindrome . Clearly and the assumptions of the proposition guarantee that .

It follows that the longest palindromic suffix is not unioccurrent, hence is not rich; see Proposition 2.3. This completes the proof. ∎

Given a factor of a word , for us it will not be important if or is unioccurrent in . For this purpose we define a special notion.

###### Definition 5.5.

If then we say that the word is reverse-unioccurrent in , where .

###### Remark 5.6.

The notion of reverse-unioccurrence has also been used in [RukavickaRichWords2019].

We show that if the switch is a suffix of the word and is reverse-unioccurrent in then is a flexed point of .

###### Lemma 5.7.

If , , , and is reverse-unioccurrent in then .

###### Proof.

Suppose that . If then and . It follows that and , since . Consequently , which is a contradiction, because is reverse-unioccurrent in . The lemma follows. ∎

There is an obvious corollary of Lemma 5.7 saying that if is a switch of , then there is a flexed point of such that either or is a suffix of .

###### Corollary 5.8.

If , then there is such that .

###### Proof.

If and , then there is obviously such that and is reverse-unioccurrent in . Then Lemma 5.7 implies that . This completes the proof. ∎

In order to construct a word with a prefix containing all switch palindromic closures of its switches we introduce two functions and .

###### Definition 5.9.

If and is a palindrome then we define

 Σw,t={u∣u∈Prf(w) and |u|≥|lppp(w)| and rtrim(t)∈Suf(u)}.

If then let denote the shortest element of and let be such that .

Let and let

 ewp(w,t)={x(πw,t)Rwif Σw,t≠∅ and t∉F(vRw)wotherwise.

 ewp(w,t1,t2,…,tm)=ewp(…(ewp(ewp(w,t1),t2),…),tm),

where is a nonempty rich word and are rich nonempty palindromes.

Given and , let such that and .

Suppose , , and . Let .

###### Remark 5.10.

The notation “ewp” stands for “extension with prefix”. It is clear that is a left standard extension of that has as a prefix .

The notation “maxPow” stands for “maximal power”. If then .

The notation “elpp” stands for “extension with letter power prefix”. The function is the word where is a left standard extension of such that is a prefix. If then .

###### Example 5.11.

Let , , , and . Then we have:

• , , .

• , .

• .

• Let . Then

• .

• , , and .

• .

• .

• .

We prove that are rich words.

If and then .

###### Proof.

Because it suffices to prove that . From the definition of it is clear that we need to verify only the case where and . Obviously , since , see Lemma 3.4. Let . Then and since we have . Hence Corollary 2.4 implies that . ∎

## 6 Construction of a Uniquely Extensible Rich Word II

In this section we consider that . Let , where and . For we show that the words are rich and that are the only flexed points of that are not flexed points of . Let .

###### Proposition 6.1.

If then and

 ¯Tn={0kgn−101,0kgn−101n}.
###### Proof.

Obviously . Suppose that , where . We show that . We have that . Note that . It follows that and hence . It is easy to see that

 lps(0kgn−101)=lps(0kgn−201n−10gn−201)=10gn−201

and that . Hence we have ; see Proposition 2.3. It follows that . Also we have that and thus .

Obviously . Since is a palindrome we have that ; see Proposition 2.3. Since is a palindrome we have that for each . This implies that and in particular . Clearly and thus .

Consequently for each , we conclude that and

We present all switches of . Let , where .

###### Proposition 6.2.

If and then

 Sn={00gn−101,01n−10gn−201n,01n}.
###### Proof.

Proposition 6.1 states that