Constructions of words rich in palindromes and pseudopalindromes

A narrow connection between infinite binary words rich in classical palindromes and infinite binary words rich simultaneously in palindromes and pseudopalindromes (the so-called $H$-rich words) is demonstrated. The correspondence between rich and $H$-rich words is based on the operation $S$ acting over words over the alphabet $\{0,1\}$ and defined by $S(u_0u_1u_2\ldots) = v_1v_2v_3\ldots$, where $v_i= u_{i-1} + u_i \mod 2$. The operation $S$ enables us to construct a new class of rich words and a new class of $H$-rich words. Finally, the operation $S$ is considered on the multiliteral alphabet $\mathbb{Z}_m$ as well and applied to the generalized Thue--Morse words. As a byproduct, new binary rich and $H$-rich words are obtained by application of $S$ on the generalized Thue--Morse words over the alphabet $\mathbb{Z}_4$.


Introduction
In the present paper we concentrate on construction of infinite words which are filled with palindromes or pseudopalindromes to the highest possible level, the so-called rich words. Before we explain the expression "the highest possible level" we recall the basic notions we work with. We understand by an infinite word over a finite alphabet A a sequence u = (u n ) n∈N = u 0 u 1 u 2 . . ., where u n ∈ A for each n ∈ N. A factor of u is a finite sequence w = w 0 w 1 · · · w n−1 of letters from A such that w = u i u i+1 · · · u i+n−1 for some i, n ∈ N. The set of all factors of u is the language of u, usually denoted L(u). A finite word w = w 0 w 1 · · · w n−1 is called palindrome if w coincides with its reversal R(w) = w n−1 w n−2 · · · w 1 w 0 .
Infinite words whose language contains infinitely many palindromes are being studied by many authors. Apart from the impulses from outside mathematics (such as Hof et al. (1995) where these words are used in a model of solid materials with finite local complexity) the main reason of the interest of mathematicians is the variety of characterizations of rich words. To specify the expression "the highest possible level" one can adopt two distinct points of view: local and global.
From the local point of view, one looks at a finite piece of the infinite word, i.e., at a factor of u, and counts the number of distinct palindromes occurring in this factor. A motivation for rich word definition was an inequality due to Droubay and Pirillo, see Droubay and Pirillo (1999), which states that a finite word of length n contains at most n + 1 distinct palindromes (the empty word is counted as a palindrome). An infinite word is rich, or full, if every its factor of length n contains n + 1 distinct palindromes. From the global point of view, one counts the palindromes of length n in the set of all factors of u, i.e., in the language L(u). Let C u (n) and P u (n) denote the number of factors of length n and the number of palindromic factors of length n, respectively. As shown in Baláži et al. (2007), if L(u) is closed under reversal, then the number of palindromes in u is bounded from above by the relation C u (n + 1) − C u (n) + 2 ≥ P u (n + 1) + P u (n) for every n ∈ N. (1) In Bucci et al. (2009), Bucci, De Luca, Glen and Zamboni show that for infinite words with language closed under reversal the local and global points of view coincide. More precisely, u is rich if and only if the inequality in (1) can be written as an equality for every n ∈ N.
Classic examples of rich words on binary alphabets include Sturmian words, i.e., infinite words over binary alphabet with the factor complexity C u (n) = n + 1 for each n ∈ N. Sturmian words can be generalized to multiliteral alphabets in many ways, see for example Balková et al. (2010). Two of these generalizations, namely k-ary Arnoux-Rauzy words and words coding k-interval exchange transformation with symmetric interval permutation, are rich as well. Both mentioned classes have their language closed under reversal.
Blondin Massé, Brlek, Garon and Labbé showed in Blondin Massé et al. (2011) that rich words include complementary-symmetric Rote words. They can be defined as binary words with factor complexity C u (n) = 2n for every nonzero integer n and with language closed under the exchange of letters, see Rote (1993). This implies that the language of a complementary-symmetric Rote word is closed under two mappings acting on the set {0, 1} * of all finite binary words: the first is R and the second is E defined by E(w 0 · · · w n ) = E(w n ) · · · E(w 0 ) for letters w i and E(0) = 1 and E(1) = 0. Thus, the language of a complementary-symmetric Rote word is closed under all elements of a group H = {R, E, ER, Id}. The same property has the language of the famous Thue-Morse word t, nevertheless, it is well-known that t is not rich.
For binary words having language closed under all elements of H, we show in  that C u (n+1) − C u (n) + 4 ≥ P u (n+1) + P u (n) + P E u (n+1) + P E u (n) for every n ≥ 1, where P E u is the function counting E-palindromes -words fixed by E -in the word u. Analogously to the case of equality in (1), we say that an infinite word with language closed under all elements of H is H-rich if in (2) the equality holds for all n ≥ 1. We also demonstrated that the Thue-Morse word t is H-rich. In Starosta (2012) the second author proved that the binary generalization t b,2 of the Thue-Morse word is H-rich for all b ≥ 2 (the definition of t b,2 is recalled in Preliminaries). In fact, the words t b,2 are the only H-rich words that have been found up to now.
One of the main aims of the present article is to describe a procedure which produces new H-rich words. We have found an inspiration in a connection between complementary-symmetric Rote words and Sturmian words due to Rote in Rote (1993). Given an infinite word u = u 0 u 1 . . . ∈ {0, 1} N , we set S(u) = v 1 v 2 . . . ∈ {0, 1} N with v i = (u i−1 + u i ) mod 2 for all positive integer i. The operator S defines the mentioned relation: a word u is a complementary-symmetric Rote word if and only if S(u) is a Sturmian word.
In Section 4, we investigate binary words which are simultaneously H-rich and also rich in the classical sense. In particular, we prove that every complementary-symmetric Rote word is H-rich, see Corollary 14. The main result concerning H-richness is presented in Theorem 24. On the one hand the theorem says that the operator S applied to an H-rich word produces a rich word. Using the examples of H-rich words mentioned earlier, we get a new class of rich words, namely the words S(t b,2 ) for all b ≥ 2. On the other hand, the theorem transforms the task to discover new H-rich words to the task to discover a new class of rich words with special structures of palindromes. One such class is described in Starosta (2016). Section 5 is devoted to the notion of G-richness on a multiliteral alphabet. In particular, the operation S is defined over the alphabet Z m . Theorem 31 illustrates that even on a multiliteral alphabet the operation S connects G-richness and G ′ -richness for, in general, distinct groups G and G ′ . In this sense Theorem 31 is a weaker version of Theorem 24.

Preliminaries
The set A * is the set of all finite words over the alphabet A which is a finite set of letters. The length of the word w = w 0 w 1 · · · w n−1 ∈ A * with w i ∈ A for all i is denoted |w| and equals n. The empty wordthe unique word of length 0 -is denoted ε. The set A * together with concatenation forms a free monoid with the neutral element ε. A word v ∈ A * is a factor of w ∈ A * if w = uvz for some word u, z ∈ A * . If, moreover, u = ε, then we say that v is a prefix of w, if z = ε, the word v is a suffix of w. If w has the form w = vz, then z is denoted z = v −1 w and the word v −1 wv is a conjugate of the word w.
The infinite word over A is a sequence u = (u n ) n∈N = u 0 u 1 u 2 . . .. The symbol A N denotes the set of all infinite words over A. A finite word w ∈ A * of length n = |w| is a factor of u if there exists an index i such that w = u i u i+1 · · · u i+n−1 ; the index i is an occurrence of the factor w. The symbol L n (u) stands for the set of all factors of length n occurring in u. The set of all factors of u is the language of u and is denoted by L(u).
An infinite word u is recurrent if any factor of u has at least two occurrences in u. Equivalently, a word is recurrent if any factor has infinitely many occurrences. If moreover for any factor w the gaps between consecutive occurrences of w are bounded, then the word u is uniformly recurrent. Let w and vw be factors of L(u) such that vw has a prefix w and w occurs in vw exactly twice. The word v is a return word of w and vw is a complete return word of w. One can say equivalently: a recurrent word u is uniformly recurrent if any factor w ∈ L(u) has finite number of return words of w.
The factor complexity of u is the mapping C u : N → N, defined by C u (n) = #L n (u). Given a ∈ A and w ∈ A * , a factor wa ∈ L(u) is a right extension of the factor w. Any factor of u has at least one right extension, the set of all right extensions of w is denoted Rext(w). If w has at least two right extensions we call it right special. Analogously one can define left extension and left special and Lext(w). In a recurrent word u any factor has at least one left extension. A factor w which is left and right special is bispecial. Special factors can be used to determine the factor complexity, in particular If A is a binary alphabet, we get ∆C u (n) = #{w ∈ L n (u) : w is right special}. (3) An infinite word u is closed under the mapping µ if µ(w) ∈ L(u) for any factor w ∈ L(u). Domain of a morphism ϕ : A * → A * can be naturally extended to A N by the prescription ϕ(u) = ϕ(u 0 u 1 u 2 . . .) = ϕ(u 0 )ϕ(u 1 )ϕ(u 2 ) . . . . An infinite word u ∈ A N is called fixed point of a morphism ϕ if ϕ(u) = u.
An antimorphism Ψ is involutory if Ψ 2 = Id. The most frequent involutory antimorphism is the reversal mapping R. If the word u is closed under an involutory antimorphism, then u is necessarily recurrent.
If p = Ψ(p), the word p is a Ψ-palindrome or pseudopalindrome, if specification of the mapping Ψ is not needed. In the case Ψ = R, we say only palindrome instead of R-palindrome. The set of all Ψpalindromes occurring as factors of a finite word w is denoted Pal Ψ (w). The Ψ-palindromic complexity of an infinite word u is the mapping If a Ψ-palindrome is centered at ε, then it is of even length.

G-defect and G-richness
First, we recall the definition of palindromic defect as it was introduced by Brlek, Hamel, Nivat and Reutenauer in Brlek et al. (2004). This classical definition is based on the inequality where Pal R (w) is the set of all R-palindromic factors of w including the empty word.
The R-defect of a finite word w is and R-defect of an infinite word u is We prefer to use the name R-defect instead of the originally used "defect" because we will introduce an analogous notion for a general antimorphism Ψ as well. An infinite word u with D R (u) = 0 is called R-full or R-rich. If D R (u) is finite, we say that u is almost R-rich. In Brlek and Reutenauer (2011), the inequality (1) is used to introduce the value T u (n) = ∆C u (n) + 2 − P R u (n + 1) − P R u (n) for every n ∈ N and they conjectured that if u is closed under reversal, then Their conjecture was proven in Balková et al. (2013). In particular, it means that D R (u) is finite if and only if there exists N ∈ N such that T u (n) = 0 for all n ≥ N , or in other words in (1) the equality holds for all n ≥ N .
To prove R-richness we will use the characterization of R-rich words given in Balková et al. (2009). It exploits the notion of the bilateral order b(w) of a factor w and the palindromic extension of a palindrome. The bilateral order was introduced in Cassaigne (1997) as b(w) = #{awb ∈ L(u) : a, b ∈ A} − #Rext(w) − #Lext(w) + 1.
The set of all palindromic extensions of a palindrome w ∈ L(u) is defined by Theorem 1 (Balková et al. (2010)). Let u be an infinite word closed under reversal.
1. The word u is R-rich if and only if any bispecial factor w of u satisfies: 2. If the word u is almost R-rich, then (7) is satisfied for all bispecial factors w up to finitely many exceptions.
The first attempt to study the number of Ψ-palindromes for an involutory antimorphism Ψ was made in Blondin Massé et al. (2008). Blondin Massé, Brlek, Garon and Labbé considered the binary alphabet {0, 1} and the antimorphism E. They showed that In Starosta (2011), this results is generalized for an arbitrary involutory antimorphism Ψ and arbitrary alphabet into the inequality where γ Ψ (w) = # {a, Ψ(a)} : a ∈ A, a occurs in w and Ψ(a) = a . Clearly, if Ψ = E we have (8) as γ E (w) = 1 for any w = ε, if Ψ = R we have (4) as γ R (w) = 0 for any w. Based on the inequality (9), the Ψ-defect of w ∈ A * is defined by The Ψ-defect of an infinite word u is defined analogously, i.e., D Ψ (u) = sup{D Ψ (w) : w ∈ L(u)}. Infinite words having finite Ψ-defect can be characterized by several properties, for more details about R-defect see Balková et al. (2011) and about Ψ-defect see Starosta (2011);Pelantová and Starosta (2012). In Pelantová and Starosta (2012) we showed that there exists a very narrow connection between words with finite defect and words with zero defect. We proved that if u is closed under an involutory antimorphism Ψ and D Ψ (u) is finite, then u is a morphic image of a word v with D Φ (v) = 0 for some involutory antimorphism Φ. If moreover u is uniformly recurrent, then Φ = R. In this sense, considering Ψ instead of R does not bring a broader variability into the concept of rich words.
The situation changes when we consider more antimorphisms. In  we defined a generalization of the notion of defect. In what follows, the symbol G stands for a finite group consisting of morphisms and antimorphisms over A * and containing at least one antimorphism. The orbit of w ∈ A * is the set We say that u is closed under G if [w] ⊂ L(u) for any w ∈ L(u). Word p ∈ A * is a G-palindrome if p = Ψ(p) for some antimorphism Ψ ∈ G. The generalization of the set of all palindromic factors of a word is a set consisting of palindromic orbits, namely the set Pal G (w) = [p] : p occurs in w and p is a G-palindrome .
Note that if G = {Id, Ψ} where Ψ is an involutory antimorphism, then Pal Ψ (w) is in one-to-one correspondence with the set Pal G (w) (the only difference is that the latter is a set of orbits instead of factors). Let us stress that in Pal G (w) we count how many different orbits have a G-palindromic representative occurring in w.
Definition 2. Let w be a finite word. The G-defect of w is defined as : a ∈ A, a occurs in w, and a = Ψ(a) for every antimorphism Ψ ∈ G} .
A finite word is G-rich if its G-defect is 0. An infinite word is G-rich if all its factors are G-rich. In , a distinct and equivalent definition of G-richness is used: it is based on a specific structure of graphs representing the factors of same length of the word.
Example 3. We illustrate the previous notions on the Thue-Morse word t, the fixed point of the morphism 0 → 01 and 1 → 10 starting with 0, i.e., t = 011010011001011010 · · ·. The word t is closed under R and E. Let H = {Id, R, E, ER}. For the group H the value γ H (w) = 0 for any w ∈ A * . Consider w = 011010011001, the prefix of t of length 12. We have The corresponding defects of w are In fact, the Thue-Morse word is H-rich, whereas its R-defect and E-defect are both infinite, see Example 8 later.
For G-richness, theorems analogous to the theorems for the classical richness can be stated, c.f. Pelantová and . The list of known G-rich words with G having at least two antimorphisms is modest. It contains the generalized Thue-Morse words t b,m . The word t b,m is defined on the alphabet {0, . . . , m − 1} for all b ≥ 2 and m ≥ 2 as where s b (n) denotes the sum of digits in the base-b representation of the integer n. See for instance Allouche and Shallit (2000); Cusick and Ciungu (2011) where this class of words is studied. The language of t b,m is closed under a group isomorphic to the dihedral group of order 2m, here denoted I 2 (m). In Section 5, we describe the group in details. In Starosta (2012), the second author proved that t b,m is I 2 (m)-rich for any parameters b ≥ 2 and m ≥ 2.
In Corollary 14 we add to the list of H-rich words also complementary-symmetric Rote words. As already mentioned in Introduction, an infinite binary word u is a complementary-symmetric Rote word if its factor complexity satisfies C u (n) = 2n for all n ≥ 1 and its language is closed under the exchange of the two letters E.
In this article, we focus on groups G acting on A * for which the implication is true for any letter a ∈ A and any pair of antimorphisms Ψ 1 , Ψ 2 ∈ G. In , for such a group, the number 1 is called G-distinguishing, since the image of a single letter by an antimorphism from G allows to identify the antimorphism. For example, the number 1 is H-distinguishing for the group H used in Example 3. Also for the dihedral groups I 2 (m) studied in Section 5, the number 1 is I 2 (m)-distinguishing.
If an infinite word u is closed under a group G and 1 is G-distinguishing, then where G (2) denotes the set of all involutory antimorphisms from G, see . Clearly, if G is generated by one antimorphism, say Ψ, then #G = 2 and G (2) = {Ψ}. The inequality (1) is the special case of (12). Similarly, the inequality (2) can be obtained from (12)

Theorem 4. Let an infinite word u be closed under a group G such that the number
is zero if and only if in (12) the equality holds for each n ∈ N, n ≥ 1.
In  we also introduced the notion almost G-rich word. A word u closed under a group G is almost G-rich if there exists N ∈ N such that the equality in (12) takes place for all integers n ≥ N . An infinite word u is almost G-rich if and only if its G-defect Remark 5. In fact, in  the last statement is shown only for uniformly recurrent words. However, one can use the same argument we applied in proof of Theorem 2 in Balková et al. (2013) and show that D G (u) is finite if and only if in (12) the equality takes place from some N on.

G-richness in binary alphabet
In this section we suppose A = {0, 1}. On binary alphabet we have only two antimorphisms R and E. Therefore, only the groups  2008), that there exist only two E-rich infinite words, namely the periodic word u = (01) ω and its shift (10) ω . The two mentioned words are also R-rich and H-rich as the equalities hold in (1) and (2) for all n ∈ N, n ≥ 1.
Examples of infinite words with finite E-defect are E-standard words with seed (see Bucci et al. (2008) for their definition and Pelantová and Starosta (2012) for a proof). This class also includes very simple examples of words with finite E-defect: periodic words having the form w ω with w = E(w). One can easily show that in this case D E (w ω ) = D E (w 2 ) (see Corollary 8 in Brlek et al. (2004) for R-defect, a modification for E is straightforward). If b is odd, then t b,2 = (01) ω and hence t b,2 is also R-rich and E-rich. If b is even, the word is aperiodic and D R (t b,2 ) = D E (t b,2 ) = +∞. To prove it for any even b we use the fact that t b,2 is a fixed point of the morphism ϕ determined by It is readily seen that the factor w = (01) b 2 is strong, i.e., its bilateral order b(w) is positive, specifically b(w) = 1, as all four words 0w1, 0w0, 1w1, and 1w0 belong to L(u). Moreover w is an E-palindrome. The form of the morphism ensures that These properties imply that for any k ∈ N, the factor ϕ 2k w is an E-palindrome and hence it is not an R-palindrome. Thus there exist infinitely many non-palindromic bispecial factors with non-zero bilateral order. Using Theorem 1 one may see that D R (t b,2 ) = +∞.
To prove that D E (t b,2 ) = +∞ we may proceed analogously. The factors ϕ 2k+1 w are R-palindromes but they are not E-palindromes for all k > 0. These factors are bispecial with the same bilateral order 1. A modification of Theorem 1 for the antimorphism E (which can be found in full generality in , Proposition 45) gives the result. Now we look at the question whether a word can be simultaneously (almost) G-rich for two groups on the binary alphabet. We will discuss the connection between finiteness of defects D R , D E and D H . In what follows we will consider words invariant under R and E simultaneously. First we study the relationship between Rand E-palindromes.
Lemma 9. Let p, q ∈ A * be R-palindromes such that the word pq is an E-palindrome, i.e., Proof: We will induce on the difference of |p| and |q|. First, suppose that |p| = |q|, then (13) implies that q = E(p) and it suffices to set c = p and i = j = 0. Suppose now that |p| = |q|. We can suppose without loss of generality that |p| < |q|. Set q = q 1 q 2 with |p| = |q 2 |. It follows from (13) This equation on words, written in general as xz = zy, has a well-known solution: there exist words u, v ∈ A * and k ∈ N such that x = uv, y = vu and z = (uv) k u. If the word z is palindrome, then the form of z implies that u and v are palindromes as well. To use the solution of xz = zx to solve (14), we set z = q 2 , x = q 1 and y = R(q 1 ) and we get the solutions q 1 = uv = E(uv) and q 2 = (uv) k u.
We apply the induction hypothesis on the palindromes u and v satisfying E(uv) = uv and we get that Substituting for p and q one can find that it suffices to set c = E(d) and the claim is proved.
Corollary 10. If p and q are palindromes such that pq = E(pq), then there exists c ∈ A * such that pq = (cE(c)) j for some j ∈ N.
Proposition 11. If an infinite recurrent word u has finite R-defect and finite E-defect, then u is periodic with a period conjugate to rE(r), where r is an R-palindrome.
Proof: Let u be an infinite recurrent word with finite Rand E-defects. Using Proposition 5 in Pelantová and Starosta (2012), it follows that u is closed under R and E and there exists an integer h such that ∆C u (n) + 2 = P R (n + 1) + P R (n) and for all n ≥ h. Since u is also closed under all elements of the group H, combining the two previous equalities with (2) we get 0 ≥ ∆C u (n) for all n ≥ h, i.e., the word u is eventually periodic. Since u is recurrent and closed under R, the word u is purely periodic, i.e., u = w ω . As u is closed under E, the word E(w) is a factor of ww. It implies that w = w 1 w 2 with E(w 1 ) = w 1 and E(w 2 ) = w 2 . As the length of any E-palindrome is even, the concatenation of two E-palindromes is conjugate to an E-palindrome, in other words, the word w is conjugate to an E-palindrome, say v.
As v ω has language closed under R as well, by the same reasoning we have v = pq, where R(p) = p and R(q) = q. Applying Corollary 10 we get v = pq = (cE(c)) j for some j ∈ N. It is enough to set r = c.
The following proposition treats another combination of two G-defects.
Proposition 12. Let u ∈ {0, 1} N be a word having its language closed under the group H and let Ψ = R or Ψ = E. If D Ψ (u) is finite (resp. zero), then D H (u) is finite (resp. zero) as well.
Before giving a proof of the last proposition, we recall Proposition 4.3 of Balková et al. (2011) which will be needed.
Proposition 13. Let u be an infinite word with language closed under reversal. Suppose that there exists an integer N such that for all n ≥ N the equality P R u (n) + P R u (n + 1) = C u (n + 1) − C u (n) + 2 holds. The complete return words of any palindromic factor of length n ≥ N are palindromes.
Proof of Proposition 12: Let us realize that closedness of u under R and E ensures that the numbers P E u (n) and P R u (n) are even. Indeed, if w ∈ L(u) is an E-palindrome of length n, then R(w) is an E-palindrome as well, and analogously for R-palindromes.
First we consider Ψ = R. Let us suppose that there exists a positive integer N such that ∆C u (n) + 2 = P R u (n) + P R u (n + 1) for all n ≥ N and ∆C u (N ) + 4 > P R u (N ) + P R u (N + 1) + P E u (N ) + P E u (N + 1).
We will show that this assumption leads to a contradiction.
In particular the assumption yields the inequality 2 > P E u (N ) + P E u (N + 1), which implies that there is no E-palindrome of length at least N . Let w ∈ L(u) be an R-palindrome of length at least N . We say that a factor f has Property π if it satisfies all of the following: 1) w occurs in f exactly once, 2) E(w) occurs in f exactly once, 3) w is a suffix or a prefix of f , 4) E(w) is a suffix or a prefix of f .
Let u be a factor with Property π. Such factor must exist as L(u) is closed under E and thus E(w) ∈ L(u) as well. As w is an R-palindrome and u is closed under reversal, the factor R(u) has Property π as well. Since ER(w) = E(w), we can assume without loss of generality that u is the factor starting in w and ending in E(w). Let us look at the complete return word of w, say p, with prefix u. The fact that the equality ∆C u (n) + 2 = P R u (n) + P R u (n + 1) is valid for all n ≥ N implies according to Proposition 13 that the complete return word p of w is an R-palindrome. Thus the factor R(u) is a suffix of p. Moreover p contains only two factors (namely u and R(u)) with Property π.
We have shown for every factor u ′ with Property π that its closest right neighbor in u with Property π is its mirror image R(u ′ ). Therefore, there exist only two factors with Property π, namely u and R(u).
On the other hand, if u has Property π, then E(u) has Property π as well and thus E(u) ∈ {u, R(u)}. As E(w) is a suffix of u, the factor E(u) has a prefix w. It implies that E(u) = u which contradicts the fact that there is no E-palindrome longer than |w|.
We have shown that If u is R-rich, then N = 1 and thus u is also H-rich. If its defect D(u) is finite but nonzero, then N > 1 and u has finite H-defect.
In the case Ψ = E the proof is analogous.
According to Proposition 11, the finiteness of both defects D E (u) and D R (u) forces the word u to be periodic. The Rote words illustrate that there exist aperiodic words with finite D H (u) and D R (u).

The mapping S on binary words
In this section we introduce and study the basic properties of the mapping S : A * \ {ε} → A * that is given by S(u 0 · · · u n ) = v 1 · · · v n , where v i = (u i−1 + u i ) mod 2 for i = 1, . . . , n.
In particular, S(a) = ε for every a ∈ A. The following list contains some elementary properties of S.

III. S(w)
is an R-palindrome if and only w is an R-palindrome or an E-palindrome.

Proof: Points I and II give
The operation S is naturally extended to A N by setting To describe the factor complexity of S(u) we study special factors in Proof: Let S(v) be right special in L(S(u)). Then S(v0) and S(v1) belong to L(S(u)). It may happen that either both v0 and v1 belong to L(u), which means that v is right special in L(u), or both ER(v0) and ER(v1) belong to L(u), which means that ER(v) is right special in L(u).
Otherwise v and ER(v) are not right special in L(u), but necessarily both belong to L(u). Let va and ER(v)b be the unique right prolongations in L(u) of v and ER(v) respectively. Since S(va) and S ER(v)b must be distinct right prolongations of S(v) = S ER(v) , we have a = ER(b), i.e., a = b. Since ER(v) has a unique extension to the right ER(v)a, we get ER(v)(1 − a) = ER(va) / ∈ L(u).

Lemma 17. Let u ∈ {0, 1} N . The word u is uniformly recurrent if and only if S(u) is uniformly recurrent.
Proof: (⇒): Let w be a factor of S(u). Then w = S(v) for some v ∈ L(u). The gaps between the neighboring occurrences of v in u are bounded by some constant. The gaps between the occurrences of w in S(u) are bounded by the same constant.
(⇐): Let v be a factor of u. Then w = S(v) is a factor of S(u) and the gaps between the occurrences of w are bounded, say by K. If v is the only factor of u such that w = S(v), i.e., v is the only preimage of w by S in u, then the occurrences of v in u are bounded by K as well. Let us suppose that w has more preimages in u. According to Property II, there are only two preimages of w, namely v and ER(v). Let f be a factor of u such that v is a prefix of f and ER(v) is a suffix of f and v and ER(v) occur in f only once. Then S(f ) is a complete return word of w = S(v) = S(ER(v)). As S(u) is uniformly recurrent, the gaps between the occurrences of the factor S(f ) are bounded, say by C. Both possible preimages of S(f ) in u, namely f and ER(f ), contain v either as its prefix or its suffix. Thus the gaps between the occurrences of v in u are bounded by C as well.

Proof:
Let v be a prefix of u. The word S(v) is a factor of S(u). According to the assumption, RS(v) = SR(v) belongs to L S(u) as well. Due to Property II, either R(v) or E RR(v) = E(v) belong to L(u). Thus a) either there exist infinitely many prefixes v ∈ L(u) such that R(v) ∈ L(u); b) or there exist infinitely many prefixes v ∈ L(u) such that E(v) ∈ L(u).
Let us suppose that a) happens. For any w ∈ L(u) we may find a prefix v such that R(v) ∈ L(u) and w is a factor of v. Thus, R(w) ∈ L(u) and we can conclude that u is closed under R.
The case b) is analogous.
Example 19. The period doubling word is the fixed point of the primitive morphism ϕ P D : 0 → 11 and 1 → 10.
It is well-known that the period doubling word is the image of the Thue-Morse word t by S. The word u P D = S(t) is closed under R, the word t is closed under R and E. It illustrates that in the previous lemma the simultaneous closedness under R and E is not excluded.
The previous lemma guarantees that u is closed at least under one of the antimorphisms E and R. We now focus on a property of S(u) that ensures that u is closed under both of them.

Lemma 20.
Let v = S(u) ∈ {0, 1} N . The language L(u) contains infinitely many E-palindromes and R-palindromes if and only if L(v) contains infinitely many R-palindromes centered at the letter 1 and infinitely many R-palindromes not centered at the letter 1.
Proof: Let u be a finite non-empty word and let v = S(u). It suffices to realize the following: 1. u is an E-palindrome if and only if v is an R-palindrome centered at the letter 1;

u is an R-palindrome of even length if and only if v is an R-palindrome centered at the letter 0;
3. u is an R-palindrome of odd length if and only if v is an R-palindrome of even length, i.e., centered at ε.

Corollary 21.
Let v = S(u) ∈ {0, 1} N be uniformly recurrent. If L(v) contains infinitely many Rpalindromes centered at the letter 1 and infinitely many R-palindromes not centered at the letter 1, then u is closed under all elements of H.

Proof:
The previous lemma implies that L(u) contains infinitely many E-palindromes and R-palindromes. Let w ∈ L(u). Since L(u) contains R-palindromes of arbitrary length and u is uniformly recurrent by Lemma 17, the factor w is a factor of an R-palindromic factor of u, thus R(w) also occurs in u. Analogously, E(w) is factor of an E-palindromic factor and thus E(w) ∈ L(u).
An example of application of the last corollary are Sturmian words. It is known that they contain infinitely many R-palindromes centered at 1 and 0, which implies that their preimages by S, namely the complementary-symmetric Rote words, have their language closed under H.
Another example is the period doubling word defined in Example 19. One can easily see can that given an R-palindrome w centered at x ∈ {0, 1}, the word ϕ P D (w)1 is also an R-palindrome centered at 1 − x. Therefore, the period doubling word satisfies the assumptions of the corollary and it follows that the language of one of its preimage by S, namely the Thue-Morse word, is closed under H.
The following definition is inspired by Balková et al. (2016). Given a finite word v and a letter a, the notation |w| a stands for the number of occurrences of the letter a in v.

Proposition 23.
Let v ∈ {0, 1} N have WELLDOC(2) and be closed under reversal. If u is a word such that v = S(u), then u is closed under all elements of H.

It follows that
for all k > 0 and j ∈ N. Suppose that s and ℓ are two distinct occurrences of a factor f ∈ L(v) of length n. We have If u s−1 = u ℓ−1 , then we have u s−1 · · · u s+n = u ℓ−1 · · · u ℓ+n . On the other hand if u s−1 = u ℓ−1 , then u s−1 · · · u s+n = ER(u ℓ−1 · · · u ℓ+n ). Note that u s−1 = u 0 + s−1 i=1 v i and v 1 · · · v s−1 f is a prefix of v, and analogously for the index ℓ. Since v has WELLDOC(2), we may choose the indices s and ℓ such that It implies that with every factor w ∈ L(u), the factor ER(w) also occurs in u. As v = S(u) is closed under reversal, Lemma 18 implies that u is closed under R or E. This together with the closedness under ER already implies that u is closed under all elements of H.

Richness of u versus richness of S(u)
This section is devoted to the study of images and preimages of almost rich words by the mapping S. Proof: Let v = S(u). Since u is closed under ER, any factor of L(v) has two preimages in L(u). Moreover, v is right special in L(u) if and only if ER(v) is right special in L(u) as well. Thus by Lemma 16, any right special factor in L(v) of length n is image of two right special factors of length n + 1.
Analogously, v is an Ror E-palindrome in L(u) if and only if ER(v) is an Ror E-palindrome in L(u). According to Property III we have 2P R v (n) = P R u (n + 1) + P E u (n + 1). Thus the equality ∆C v (n) + 2 = P R v (n + 1) + P R v (n), testifying that v is R-rich, holds if and only if the equality ∆C u (n + 1) + 4 = P R u (n + 1) + P E u (n + 1) + P R u (n + 2) + P E u (n + 2), testifying that u is H-rich, is satisfied.
As already noted above, the word t b,2 is H-rich. Thus, using the last theorem with u = t b,2 and (15) together with the equality valid for any infinite word w, we obtain the following corollary: Corollary 25. For every integer b greater than 1 the word v = S(t b,2 ) is R-rich. Its factor complexity satisfies Using the factor complexity of the word t b,2 described in Starosta (2012), one can see that the binary R-rich word S(t b,2 ) is not Sturmian. Remark 26. Since a complementary-symmetric Rote word u is closed under all elements of H and S(u) is Sturmian, which is R-rich, Theorem 24 provides an alternative proof of Corollary 14 without exploiting the result that every Rote word u is R-rich.
Theorem 27. Let u ∈ {0, 1} N be a uniformly recurrent word. If u is almost R-rich, then the word S(u) is almost R-rich.
Proof: Since u is almost rich, its language contains infinitely many palindromes. This fact for uniformly recurrent words implies that u is closed under reversal. If u is closed under E as well, then according to Proposition 12 the word u is almost H-rich, and the claim follows from Theorem 24.
It is enough to consider u that is not closed under E. We will show that the set {w ∈ L(u) : ER(w) ∈ L(u)} is finite. Assume the opposite. Let v be a factor of length n. As u is uniformly recurrent there exists a number r(n) such that any factor of u longer than r(n) contains all factors of length n. Since {w ∈ L(u) : ER(w) ∈ L(u)} is not finite, there exists w belonging to this set and being longer than r(n). And thus the factor v of length n occurs in w and ER(v) occurs in ER(w). Since both w and ER(w) belong to L(u), the factor v and ER(v) belongs to L(u) as well -a contradiction with assumption that u is not closed under E.
Let N be the maximal length of an element of the finite set {w ∈ L(u) : ER(w) ∈ L(u)}. Any factor of S(u) longer than N has unique preimage in L(u). According to Lemma 16 for any n > N there is one-to-one correspondence between L n (S(u)) and L n+1 (u). Thus, ∆C u (n + 1) = ∆C S(u) (n) for all n > N.
Moreover, there exists no E-palindrome of length n > N and thus we have one-to-one correspondence between the set of all R-palindromes in L(S(u)) of length n and the set of all R-palindromes in L(u) of length n + 1. It gives Since u has language closed under reversal and is almost rich using (5) there exists a constant M such that ∆C u (n) + 2 = P u (n) + P u (n + 1) for all n ≥ M.
It follows that the word S(u) is almost R-rich.
Corollary 28. If u is a Sturmian word, then S k (u) is almost R-rich for all k > 0.
We add two more examples related to images (Example 29) and preimages (Example 30) of words constructed by iterated operation S. However, we do not give any proofs of their properties and we just state them as hypotheses given by computer evidence.
Example 29. As stated in Corollary 25, the word S(t b,2 ) is R-rich. Theorem 27 then implies that S k (t b,2 ) is almost R-rich for all k > 0. Our computer experiments suggest that in this case the word S k (t b,2 ) is in fact R-rich.
As we have already mentioned, the list of known H-rich words is very modest: complementarysymmetric Rote words and generalized binary Thue-Morse words t b,2 . Theorem 24, Proposition 23 and Corollary 21 give us a recipe for construction of an (almost) H-rich word: take a binary (almost) R-rich word with property WELLDOC(2) or a binary (almost) R-rich word with suitable structure of palindromes and find its preimage by the operation S. The complementary-symmetric Rote words were obtained by this procedure applied to the Sturmian words. The Thue-Morse word t = t 2,2 can be obtained by this procedure applied to the period doubling word.
Example 30. Let u be a Sturmian word. Let u (k) be an infinite word such that S k (u (k) ) = u for all k ∈ N. The word u (1) is a complementary-symmetric Rote word which is, as already mentioned, H-rich and R-rich. According to our computer experiments, so is the word u (2) . The word u (3) is not R-rich, but it is still H-rich. The word u (k) for k > 3 is not H-rich nor R-rich. However, the symmetries of u (k) are preserved: u (k) is closed under all elements of H. This is witnessed by the following difference of its factor complexity ∆C u (k) (n) = 2 n−1 for 0 < n ≤ k and ∆C u (k) (n) = 2 k for n > k which is suggested by our experiments.

The mapping S on multiliteral alphabets
In this section we study the mapping S acting on a larger alphabet Z m = {0, . . . , m − 1}. The mapping S is defined for every word w = w 0 · · · w n with w i ∈ Z m by where v i = (w i−1 + w i ) mod m for every i ∈ {1, . . . , n}.
The alphabet Z m allows many finite groups generated by involutory antimorphisms. We restrict our attention to groups isomorphic to groups of symmetries of a regular polyhedron. The reason is simple: we have examples of G-rich words only for such groups, namely the generalized Thue-Morse words. We demonstrate that at least for these words the mapping S transforms a G-rich word to an almost G ′ -rich word (cf. Theorems 24 and 27 for an analogue on the binary alphabet).
Let us describe the elements of the mentioned group explicitly. For all x ∈ Z m denote by Ψ x the antimorphism given by Ψ x (k) = x − k for all k ∈ Z m and by Π x the morphism given by The group I 2 (m) is the union of these antimorphisms and morphisms: The definition of the generalized Thue-Morse words is recalled in Preliminaries. It is known that the word t b,m is a fixed point of the morphism ϕ b,m : Z * m → Z * m defined by ϕ b,m : a → a(a + 1)(a + 2) · · · (a + b − 1) for all a ∈ Z m .
Let us stress that all operations on letters in this section are taken modulo m. As shown in Starosta (2012), the word t b,m is closed under all elements of I 2 (m) and moreover t b,m is I 2 (m)-rich. We will focus on images of t b,m by S with parameters b ≥ 3 and m ≥ 3. Let I ′ 2 (m) denote the group generated by antimorphisms {Ψ 2y : y ∈ Z m }; it can be easily seen that If m is odd, then I ′ 2 (m) = I 2 (m), if m is even, then I ′ 2 (m) is isomorphic to I 2 ( m 2 ).
The aim of this section is to prove the following theorem.
Theorem 31. Let m, b ∈ Z such that m ≥ 3 and b ≥ 3.

The word
The first part of Theorem 31 is a direct consequence of Proposition 34, the second part follows from Lemma 35 and the description of factors of S(t b,m ) up to the length 3 presented at the end of this section.
We start with a list of observations concerning properties of the mapping S. To deduce some of the observations we exploit a peculiar property of generalized Thue-Morse words. The form of morphism ϕ b,m forces the language of u = t b,m to have the following property (A) SΨ y = Ψ 2y S for any y ∈ Z m . If m is even, then SΨ y = SΨ y+ m 2 for any y ∈ Z m .
(C) Let u be closed under all elements of I 2 (m) and satisfy (20). Consider w = S(v) for some v = v 0 v 1 · · · v n ∈ L(u) with n ≥ 3.
If m is odd, then v is the only preimage of w by S in u.
Proof: Let S(u) = S(v) for a factor u = u 0 u 1 · · · u n ∈ L(u). As n ≥ 3, property (20) implies that there exists j ∈ {1, 2, 3} such that u j − u j−1 = v j − v j−1 = 1. From Property (B), we obtain v j −v j−1 = u j −u j−1 +(−1) j 2x, thus 2x = 0. If m is odd, then necessarily x = 0. If m is even, then also x = m 2 satisfies 2x = 0. As the morphism Ψ 0 Ψ m 2 maps a to a + m 2 , the language of u is closed under addition of m 2 to all letters of any factor of u, i.e., (D) Let u be closed under all elements of I 2 (m) and satisfy (20). Consider u ∈ L(u).
(a) If u is a Ψ y -palindrome, then S(u) is a Ψ 2y -palindrome.
(b) If S(u) is a Ψ 2y -palindrome with |S(u)| ≥ 3 and m is odd, then u is a Ψ y -palindrome.
To prove Theorem 31 we use the notion of complete G-return word of an orbit, as introduced in Pelantová and . Let us recall that the orbit [w] of a factor w ∈ L(u) is defined by (11).
• a prefix and a suffix of v belong to [w], and • v contains no other elements of [w].
Theorem 33 ). If u is an infinite word closed under all elements of G, then 1. u is G-rich if and only if for all w ∈ L(u) every complete G-return word of [w] is a G-palindrome.

u is almost G-rich if and only if there exists and integer N such that for all
Using the previous theorem, we can easily prove the proposition which directly implies the validity of the first part of Theorem 31 because the generalized Thue-Morse words satisfy its assumption.
Proposition 34. Let A = Z m and let u ∈ A N be closed under all elements of I 2 (m). If L(u) satisfies (20) and u is I 2 (m)-rich, then the word S(u) is almost I ′ 2 (m)-rich.
As u satisfies (20), we can apply Property (D) to each palindrome S(u) in S(u) with length |S(u)| ≥ 3. Property (D) implies that u ∈ L(u) is a G-palindrome if and only if S(u) is a G ′ -palindrome in L(S(u)). Let S(u) be a G ′ -palindrome in S(u) and S(v) be a complete G ′ -return word of [S(u)] in S(u). Then v is a complete G-return word in u of [u]. The word u is G-rich and due to Theorem 33, the factor v is a G-palindrome. According to Property (D), the complete G ′ -return word S(v) is a G ′ -palindrome. Thus S(u) is almost G ′ -rich.
In the remaining part of this section we focus on G ′ -richness of S(t b,m ) in the case when m or b is odd.
. If for n = 1 and n = 2 the equality Proof: We combine the results of . It is easy to see that Ψ 2x (a) = Ψ 2y (a) for any a ∈ Z m and any pair of distinct antimorphisms Ψ 2x and Ψ 2y from G ′ . This property guarantees that the number 1 is G ′ -distinguishing in the sense of Definition 7 of . In the proof of Proposition 34 we verify that any complete G ′ -return word of [w] in v is a G ′ -palindrome for each G ′ -palindrome w ∈ L(v) of length at least 3. As 1 is G ′ -distinguishing, Lemma 28 of  says that this fact implies equality (21) for all n ≥ 3. According to Proposition 42 of  the word v is G ′ -rich if the equality in (21) holds for each n ∈ N, n ≥ 1.
In the case m or b odd and n = 1 and n = 2, we will confirm the equality (21) in the next lemma. To ease the notation we put and ρ : Z m → Z m denotes the permutation We will use the following statements from Starosta (2012). Let q denote the order of ρ, i. e., the least positive integer q such that q(b − 1) ≡ 0 (mod m). The factors of length 2 of t b,m are and of length 3 It is easy to deduce the set of all factors of length 4: If m is odd, then we have directly that L 1 (v) = Z m (for k = 0).
First, let us see the number of factors of type 1. Fix r ∈ Z m . Suppose 2r + 1 = 2r + 1 for somer. This equation has 1 solution for m odd and 2 solutions for m even. It is easy to see that if m is odd, there are qm distinct factors of type 1 and if m is even their number is qm 2 . The counts for the second type are exactly the same.
Analogously to the previous case n = 2, it can be shown that there are qm distinct factors of each type if m is odd, and qm 2 distinct factors of each type if m is even. When investigating the common factors of each type, one can show that each pair has m common factors if m is odd, and m 2 common factors otherwise. Overall, we find that #L 3 (v) = 3qm − 2m if m is odd and #L 3 (v) = 3qm 2 − m if m is even. Proof: n = 1: It is not hard to show that every factor of length 1 is a Ψ-palindrome for a unique Ψ ∈ G ′ . n = 2: Suppose that the first type of factor of length 2 from the proof of Lemma 36 is a Ψ ℓ -palindrome. We have which leads to ℓ = 4r − 2 + k(b − 1), i.e., every factor of length 2 is a Ψ-palindrome for some Ψ ∈ G ′ except for the case of m even and b even where one may find such ℓ only if k is even. As one can see in the proof of Lemma 36, the case of k even is when the two types of factors of length 2 overlap, thus the total number of G ′ -palindromes is qm 4 in this case. n = 3: We will refer to the 3 types of factors of length 3 as given in the proof of Lemma 36 above. The first two types can be a Ψ-palindrome for some Ψ ∈ I 2 (m) if and only if k = 0 or k ′ = 0. This case is also included in the third type for k ′′ = 0, so we need just to check this type.
Suppose that a factor of the third type is a Ψ ℓ -palindrome: Both equalities yield ℓ = 4r ′′ + 2 − 2k ′′ (b − 1). Thus, every factor of type 3 is a Ψ-palindrome for some Ψ ∈ I 2 (m). According to the proof of Lemma 36, there are qm such factors if m is odd, and qm 2 such factors otherwise. • S 2 (t 2b+1,4 ) is an infinite word over the binary alphabet {0, 2} and it is R-rich (R stands for the reversal mapping over the binary alphabet {0, 2}).
• S k (t 2b+1,4 ) is an infinite word over the binary alphabet {0, 2} and it is almost R-rich for any k ∈ N, k ≥ 2.
Proof: The fact that the alphabet of S(t 2b+1,4 ) is {1, 3} is shown in the proof of Lemma 36, where L 1 (v) is described for any generalized Thue-Morse word v. According to the second part of Theorem 31, the word S(t 2b+1,4 ) is I ′ 2 (4)-rich. The group I ′ 2 (4) defined by (19) is isomorphic to H. It is easy to see that the operation S assigns to any word u ∈ {1, 3} N the word over the alphabet {0, 2}. The second part of the corollary follows from Theorem 24, the third one from Theorem 27.

Comments and open questions
For infinite words over the binary alphabet {0, 1}, we illustrated that the operation S puts into a broader context the classical richness (here usually referred to as R-richness) and H-richness. The main open question is which other operation acting on infinite words behaves analogously. Let us mention here some open questions connected with S.
• The operation S on {0, 1} applied to an almost R-rich word gives an almost R-rich word, see Theorem 27. In particular, any iteration of S applied to a Sturmian word u gives an almost rich word, cf. Corollary 28. Is the R-defect of S k (u) zero as suggested by our computer experiments?
• The operation S on {0, 1} applied to an H-rich word gives an R-rich word. In particular, S(t b,2 ) is rich for any generalized Thue-Morse word t b,2 . Our computational experiments suggest that S k (t b,2 ) is R-rich for any k ∈ N, k ≥ 1, see Example 29. Is it true?
• On the other hand, any preimage by S of each Sturmian word u is H-rich and R-rich simultaneously, in fact it is a complementary-symmetric Rote word. Our computer experiments suggest that even the second preimage S −2 (u) is simultaneously Hand R-rich, whereas S −3 (u) is only H-rich, but not R-rich, see Example 30. Is it true?
We have introduced the operation S over the alphabet Z m with m ≥ 3 as well. But our results on multiliteral alphabet are restricted to special groups and words.
• We have considered G-richness for G = I 2 (m) only. Proposition 34 connects I 2 (m)-richness of u and I ′ 2 (m)-richness of S(u) for words u satisfying the assumption (20). Is the proposition valid without the assumption?
• It would be interesting to study behaviour of ternary episturmian words with respect to operation S on Z 3 . For example, which group of symmetries G has the preimage of the Tribonacci word by S? Is the preimage G-rich? Are images of the Tribonacci word by S still R-rich?
• Corollary 38 illustrates that the operation S over the alphabet Z 4 can produce binary almost R-rich words as well. What is the R-defect of the words S k (t 2b+1,4 )?
The last comment we want to state here concerns the palindromic closure operator. It is used for construction of standard episturmian words. The construction is governed by a directive sequence of letters ∆. Any episturmian word u is closed under reversal and u is rich in the classical sense. In de Luca and De Luca (2006), the authors introduced the concept of generalized pseudopalindromic closure operator, where multiple involutory antimorphisms are used. It means that the construction is governed by two sequences: a directive sequence of letters ∆ and a directive sequence of antimorphisms Θ. Let us denote the resulting infinite word by u(∆, Θ).
In general, u(∆, Θ) is closed under the group G generated by the involutory antimorphisms occurring infinitely many times in the directive sequence Θ, but the word u(∆, Θ) need not to be G-rich. Nevertheless, several examples of G-rich words constructed by generalized pseudopalindromic closure operator are already known. De Luca and de Luca showed that the Thue-Morse word t = t 2,2 can be constructed in this way. In Jajcayová et al. (2014) the generalized Thue-Morse words t b,m with the same property are characterized. The concept of generalized pseudopalindromic closure on binary alphabet is systematically studied by Blondin Massé, Paquin, Tremblay and Vuillon in Blondin Massé et al. (2013). In particular, they proved that any standard complementary-symmetric Rote word can be constructed by using generalized pseudopalindromic closure operator. Nevertheless, the question which pairs (∆, Θ) produce H-rich words is open and requires a deeper study.