\documentclass[12pt,reqno]{article}
\usepackage[usenames]{color}
\usepackage[colorlinks=true,
linkcolor=webgreen,
filecolor=webbrown,
citecolor=webgreen]{hyperref}
\definecolor{webgreen}{rgb}{0,.5,0}
\definecolor{webbrown}{rgb}{.6,0,0}
\usepackage{color}
\usepackage{fullpage}
\usepackage{float}
\usepackage{psfig}
\usepackage{graphics,amsmath,amssymb}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{latexsym}
\usepackage{epsf}
\usepackage{graphicx}
\usepackage{bm}
\usepackage{amscd}
\usepackage{xcolor}
\usepackage{array}
\usepackage{enumerate}
\usepackage{fullpage}
\usepackage{float}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{multicol}
\usepackage{verbatim}
\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{.1in}
\setlength{\evensidemargin}{.1in}
\setlength{\topmargin}{-.5in}
\setlength{\textheight}{8.9in}
\newcommand{\seqnum}[1]{\href{http://oeis.org/#1}{\underline{#1}}}
% Macros
\renewcommand{\div}{/}
\renewcommand{\bar}{\overline}
\DeclareMathOperator{\sign}{sgn}
\newcommand{\R}{{\mathbb R}}
\newcommand{\N}{{\mathbb N}}
\newcommand{\Q}{{\mathbb Q}}
\newcommand{\Alphabet}{\mathcal{A}}
\newcommand{\Pref}{{\rm Pref}}
\newcommand{\Suff}{{\rm Suff}}
\newcommand{\Card}{{\rm Card}}
\newcommand{\pal}{{\rm Pal}}
\newcommand{\ipal}{{\psi}}
\newcommand{\pref}{{\rm Pref}}
\newcommand{\bw}{\mathbf{w}}
\newcommand{\bx}{\mathbf{x}}
\newcommand{\by}{\mathbf{y}}
\newcommand{\br}{\mathbf{r}}
\newcommand{\bfi}{\mathbf{f}}
\newcommand{\bd}{\mathbf{d}}
\newcommand{\bTheta}{{\bm \Theta}}
\newcommand{\bu}{\mathbf{u}}
\newcommand{\bs}{\mathbf{s}}
\newcommand{\bv}{\mathbf{v}}
\newcommand{\A}{{\mathcal A}}
\newcommand{\V}{{\vartheta}}
\newcommand{\bV}{{\bm \vartheta}}
\newcommand{\id}{\rm Id}
\newcommand{\h}{\mathcal H}
\renewcommand{\a}{{\textsc a}}
\newcommand{\e}{{\textsc e}}
\renewcommand{\o}{{\textsc o}}
\renewcommand{\thefootnote}{\fnsymbol{footnote}}
\newcommand{\alp}[1]{{\rm alph}(#1)}
\newcommand{\Type}{\theta}
\newcommand{\Transducer}{{\mathcal T}}
\newcommand{\underdot}{\d}
\newcommand{\ord}{\mathrm{ord}}
\newsavebox{\gauche}
\sbox{\gauche}{\setlength{\unitlength}{1mm}
\begin{picture}(1.5,3)(0,0)
\thicklines
{\put(0,-.5){\line(1,0){1}}}%
{\put(0.15,-.64){\line(0,3){3.48}}}%
{\put(0,2.7){\line(1,0){1}}}%
\end{picture}}
\newcommand{\lbr}{\usebox{\gauche}}
\newsavebox{\droite}
\sbox{\droite}{\setlength{\unitlength}{1mm}
\begin{picture}(1,3)(0,0)
\thicklines
{\put(0,-.5){\line(-1,0){1}}}%
{\put(-0.16,-.64){\line(0,3){3.48}}}%
{\put(0,2.7){\line(-1,0){1}}}%
\end{picture}}
\newcommand{\rbr}{\usebox{\droite}}
\newcommand\Class[1]{\hspace{-1pt}\lbr#1\rbr\hspace{-1pt}}
\renewcommand{\bf}{\textbf}
\begin{document}
\begin{center}
\epsfxsize=4in
\leavevmode\epsffile{logo129.eps}
\end{center}
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newtheorem{example}[theorem]{Example}
\newtheorem{conjecture}[theorem]{Conjecture}
\theoremstyle{remark}
\newtheorem{remark}[theorem]{Remark}
\begin{center}
\vskip 1cm{\LARGE\bf{On Generalized Pseudostandard Words \\
\vskip .13in
Over Binary Alphabets
}} \vskip 1cm
Alexandre Blondin Mass\'e\\
Laboratoire d'informatique formelle\\
Universit\'e du Qu\'ebec \`a Chicoutimi\\
Chicoutimi, QC, G7H 2B1 \\
Canada\\
\href{mailto:ablondin@uqac.ca}{\tt ablondin@uqac.ca}\\
\ \\
Genevi\`eve Paquin\\
D\'epartement de math\'ematiques\\
C\'egep de Saint-J\'er\^ome\\
Saint-J\'er\^ome, QC J7Z 4V2\\
Canada \\
\href{mailto:gpaquin@cstj.qc.ca}{\tt gpaquin@cstj.qc.ca}\\
\ \\
Hugo Tremblay\\
Laboratoire de combinatoire et d'informatique math\'ematique\\
Universit\'e du Qu\'ebec \`a Montr\'eal\\
Montr\'eal, QC H3C 3P8\\
Canada \\
\href{mailto:tremblay.hugo.5@courrier.uqam.ca}{\tt tremblay.hugo.5@courrier.uqam.ca}\\
\ \\
Laurent Vuillon\\
Laboratoire de math\'ematiques\\
Universit\'e de Savoie\\
Le-Bourget-du-Lac 73376\\
France \\
\href{mailto:laurent.vuillon@univ-savoie.fr}{\tt laurent.vuillon@univ-savoie.fr}\\
\end{center}
\vskip .2 in
\begin{abstract}
In this paper, we study generalized pseudostandard words over a two-letter alphabet, which extend the classes of standard Sturmian, standard episturmian and pseudostandard words, allowing different involutory antimorphisms instead of the usual palindromic closure or a fixed involutory antimorphism. We first discuss about \emph{pseudoperiods}, a useful tool for describing words obtained by iterated pseudopalindromic closure. Then, we introduce the concept of {\it normalized} directive bi-sequence $(\Theta, w)$ of a generalized
pseudostandard word, that is the one that exactly describes all the pseudopalindromic prefixes of it. We show that a directive bi-sequence is normalized if and only if its set of factors does not intersect a finite set of forbidden ones. Moreover, we provide a construction to normalize any directive bi-sequence. Next, we present an explicit formula, generalizing the one for the standard episturmian words introduced by Justin, that computes recursively the next prefix of a generalized pseudostandard word in term of the previous one. Finally, we focus on generalized pseudostandard words having complexity $2n$, also called \emph{Rote words}. More precisely, we prove that the normalized bi-sequences describing Rote words are completely characterized by their factors of length $2$.
\end{abstract}
\section{Introduction}
The \emph{Sturmian words} form a well-known class of infinite words over a two-letter alphabet that occurs in many different fields, for instance in astronomy, symbolic dynamics, number theory, discrete geometry, crystallography, and of course, in combinatorics on words (see \cite[Chapter 2]{Lothaire2002}).
{These words have many equivalent characterizations whose usefulness depends on the context.}
In discrete geometry,
they are exactly the words that code the discrete approximations of lines with irrational slopes, using horizontal and diagonal moves. In symbolic dynamics, Sturmian words are obtained from two-intervals exchange transformations. They are also known as the balanced aperiodic infinite words over a two-letter alphabet. A remarkable subclass of the Sturmian words is the class of the so-called \emph{standard Sturmian words}. To each Sturmian word corresponds a standard Sturmian one having the same language, i.e., the same set of factors. Thus, standard Sturmian words are, in a sense, representatives of all Sturmian words having the same language. Geometrically, they correspond to discrete lines starting at the origin. All the words in this subclass can be obtained by a construction called iterated palindromic closure \cite{deLuca1997}. This operation establishes a bijection between standard Sturmian words and {non-eventually} constant infinite words over a binary alphabet. It can also be generalized for an alphabet with more than two letters and yields the standard episturmian words.
Another generalization of the standard episturmian words was introduced by de Luca and De Luca in \cite{deLucaDeLuca2006}, where the authors considered pseudopalindromes instead of palindromes. In the paper, they first define the notion of $\V$-palindrome
(called \emph{pseudopalindrome} when $\V$ is not mentioned), which is a word fixed by an involutory antimorphism $\V$. Moreover, they introduce the pseudopalindromic closure, which extends the usual palindromic closure to pseudopalindromes.
These ideas lead one to naturally define words obtained by \emph{iterated pseudopalindromic closure}. In particular, they consider a generalization of Sturmian and episturmian words: the \emph{pseudostandard words}. Finally, toward the end of their paper, they define an even more general class of infinite words, called \emph{generalized pseudostandard words}, these words being obtained by a directive bi-sequence $(\Theta, w)$, where $\Theta$ is a sequence of involutory antimorphisms and $w$ is an infinite
word. In that case, the type of pseudopalindromic closure changes at each step, applying the $n$th involutory antimorphism for the $n$th pseudopalindromic closure, after having added the $n$th letter of the word $w$. Different generalizations of standard episturmian words have been introduced and studied (see for instance \cite{BuccideLucaDeLucaZamboni20082,BuccideLucaDeLucaZamboni2008,deLucaDeLuca2006}), but not much is known about generalized pseudostandard words except for the remarkable fact that the famous Thue-Morse word falls within this class of words (see \cite{deLucaDeLuca2006}).
In order to study generalized pseudostandard words, it is natural to search for an efficient way to construct it from its directive bi-sequence. In \cite{Justin2005}, Justin gives a formula that
allows one to compute in linear time a prefix of a standard Sturmian (resp., episturmian) word, using its directive sequence, that is the sequence on which the iterated palindromic closure is performed, in order to construct the standard Sturmian (resp., episturmian) word.
The main aim of this paper is to extend Justin's formula to generalized pseudostandard words on binary alphabets. In particular, this formula might be useful in the study of generalized pseudostandard word by mean of computer exploration.
The next sections are organized as follows. As usual, we first introduce the definitions and notation used in the next sections. We recall iterated palindromic and pseudopalindromic closure operators as well as the main topic of this paper: the generalized pseudostandard words. Section \ref{S:pseudoperiodicity} is devoted to the structure of words having pseudoperiods (i.e. words such that $w\Class{i} = \sigma(w\Class{i + p})$ for some permutation $\sigma$ and some positive integer $p$). These results turn out to be very useful for studying generalized pseudostandard words. Next, we introduce in Section \ref{S:normalized} the notion of normalized directive bi-sequence.
Those normalized bi-sequences are representatives of all directive bi-sequences describing the same word, but having the special additional property that the successive prefixes obtained by
pseudopalindromic closure coincide with all pseudopalindromic prefixes of the corresponding generalized pseudostandard word. We first prove the existence of such a normalized bi-sequence and we describe exactly the forbidden factors for a bi-sequence not to be normalized. Then we provide a simple way of constructing a normalized bi-sequence from any directive bi-sequence. In Section \ref{S:justin}, we present a generalization of Justin's formula for generalized pseudostandard words whose proof depends strongly on the normalized form. Section \ref{S:rote} is devoted to the particular case of Rote words.
Notice that this paper is an complete and improved version of two conference communications. The content of Sections \ref{S:normalized} and \ref{S:justin} was presented in Amiens (France) during the 13th Mons Theoretical Computer Science Days \cite{BlondinMassePaquinVuillon2010} (JM 2010), while the content of Section \ref{S:rote} was the main subject of a communication during the conference in honor of the 20th Anniversary of the Laboratoire de combinatoire et d'informatique mathématique \cite{lacim2010} (LaCIM 2010).
\section{Preliminaries}
We introduce the definitions and notation in the next sections.
\subsection{Words}
We first recall notions on words (for more details, see for instance \cite{Lothaire2002}).
An {\it alphabet} $\A$ is a finite set of symbols called {\it letters}. A {\it word over $\A$} is a sequence of letters from $\A$. The {\it empty word} $\varepsilon$ is the empty sequence. Equipped with the concatenation operation, the set $\A^*$ of {\it finite words} over $\A$ is a free monoid with neutral element $\varepsilon$ and set of generators $\A$, and $\A^+=\A^* \setminus \varepsilon$. We denote by $\A^\omega$ the set of {\it (right-) infinite words} over $\A$. The set $\A^\infty$ is defined as the set of finite and infinite words: $\A^\infty= \A^* \cup \A^\omega$. Note that depending on the context, an infinite word is sometimes also called a {\it sequence}. For sake of clarity, variables denoting infinite words appear in bold.
If, for some words $u, s \in \A^\infty$, $v, p \in \A^*$, $u=pvs$, then $v$ is a {\it factor} of $u$, $p$ is a {\it prefix} of $u$ and $s$ is a {\it suffix} of $u$. %If $v\neq u$ (resp. $p\neq u$ and $s \neq u$), $v$ is called a {\it proper factor} (resp. {\it proper prefix} and {\it proper suffix}).
The {\it set of factors} of the word $u$ is denoted by $F(u)$. For $u=vw$, with $v\in \A^*$ and $w \in \A^\infty$, $v^{-1}u$ denotes the word $w$ and $uw^{-1}$ denotes the word $v$. Negative powers are naturally extended by $v^{-n}u = (v^n)^{-1}u$ and $u(w^n)^{-1}$.
As usual, for a finite word $u$ and a positive integer $n$, the \emph{$n$th power of $u$}, denoted by $u^n$, is the word $\varepsilon$ if $n=0$; otherwise $u^n=u^{n-1}u$.
If $u\neq \varepsilon$, $u^\omega$ denotes the infinite word obtained by infinitely repeating $u$. {Given a finite or an infinite word $u$, we denote by $u\Class{i}$ the $i$th letter of $u$ and by $u\Class{i\ldots j}$ the word $u\Class{i}u\Class{i+1}\cdots u\Class{j}$.}
Given a nonempty finite word $u=u\Class{1}u\Class{2}\cdots u\Class{n}$, the {\it length} $|u|$ of $u$ is the integer $n$. One has $|\varepsilon|=0$. The number of occurrences of the letter $a$ in the word $u$ is denoted by $|u|_a$. If $|u|_a=0$, then $u$ is called an {\it $a$-free word}.
The {\it reversal} of the finite word $u=u\Class{1}u\Class{2}\cdots u\Class{n}$, also called the {\it mirror image}, is {$R(u)$}$= u\Class{n}u\Class{n-1}\cdots u\Class{1}$ and if $u=$ {$R(u)$}, then $u$ is called a {\it palindrome}. The {\it right-palindromic closure} ({\it palindromic closure}, for short) of the finite word $u$, denoted by $u^{(+)}$, is defined by $u^{(+)}=u\cdot${$R(p)$}, with $u=ps$ and $s$ is the longest palindromic suffix of $u$. In other words, it is the shortest palindromic word having $u$ as prefix.
Over a two-letter alphabet $\{0,1\}$, there is a usual length preserving morphism, the {\it complementation}, defined by $\overline 0 =1$ and $\overline 1= 0$, which extends to words (finite or infinite). For instance, the complement of $u=u\Class{1}u\Class{2}\cdots u\Class{n}$ is the word $\overline u=\overline{u\Class{1}} \, \overline{u\Class{2}}\cdots \overline{u\Class{n}}$.
Sturmian words may be defined in many equivalent ways (see Chapter 2 in \cite{Lothaire2002} for more details). For instance, they are the non-ultimately periodic infinite words over a two-letter alphabet that have minimal complexity, that is the number of distinct factors of length $n$ is $(n+1)${, for each positive integer $n$}. They are also the set of non-ultimately periodic binary balanced words. Recall that a {word $w$ over $\A$} is {\it balanced} if for all factors $f, f'$ having same length, and for all letters $a \in \A$, one has $\left | |f|_a-|f'|_a\right | \leq 1$.
The Sturmian words are {also infinite words that describe discrete approximations of irrational slopes} (see \cite{Lothaire2002}). {More precisely, an infinite word is \emph{Sturmian} if and only if it is equal to one of the two infinite words ${ s}_{\alpha, \rho}, { s'}_{\alpha, \rho} \in \{a,b\}^\omega$, defined by}
$${ s}_{\alpha, \rho}\Class{n}= \begin{cases}
a, & \mbox{if $\lfloor \alpha(n+1) +\rho \rfloor = \lfloor \alpha n +\rho \rfloor$;} \\
b, & \mbox{otherwise}.
\end{cases}$$
and
$${ s'}_{\alpha, \rho}\Class{n}= \begin{cases}
a, & \mbox{if $\lceil \alpha(n+1) +\rho \rceil = \lceil \alpha n +\rho \rceil$;} \\
b, & \mbox{otherwise},
\end{cases}$$
where $\alpha, \rho \in \R$, $0\leq \alpha <1$ and $\alpha$ irrational.
The parameters $\rho$ and $\alpha$ correspond respectively to the \emph{intercept} and the \emph{slope} of the line approximated by the word $s$. A Sturmian word is called {\it standard} (or {\it characteristic}) if {$\rho=\alpha$}.
%%%%%
\subsection{Pseudopalindromic closure}
Given a finite word $w$, let us denote by $\ipal(w)$ the word obtained by iterating palindromic closure over $w$: $\ipal(\varepsilon) = \varepsilon$ and $\ipal(wa) = (\ipal(w)a)^{(+)}$, for all letters $a$.
Note that the $\ipal$ operator is sometimes denoted by $\pal$ in the works of Justin and Jamet et al (see for instance \cite{JametPaquinRichommeVuillon2010, Justin2005}). By definition of iterated palindromic closure $\ipal$, for any finite word $w$ and letter $a$, $\ipal(w)$ is a prefix of $\ipal(wa)$.
Thus, one can extend the iterated palindromic closure to any infinite word $\bw = (a\Class{n})_{n \geq 1}$ as follows: $$\ipal(\bw) = \lim_{n \to \infty} \ipal(a\Class{1 \ldots n}).$$
We say that the word $w$ {\it directs} the word $\ipal( w)$. Also, we know from \cite{deLuca1997} that
$\ipal$ {gives} a bijection between the set {of infinite words over $\{a,b\}$ not of the form $ua^\omega$ or $ub^\omega$, for some $u\in \{a,b\}^*$, and the set of standard Sturmian words over $\{a,b\}$.} The word $\bw$ is then called the {\it directive sequence} of the standard Sturmian word $\ipal(\bw)$. Note that words of the form $\ipal(ua^\omega)$ are periodic (see \cite{DroubayJustinPirillo2001}).
The $\ipal$ operator is also well-defined over a $k$-letter alphabet, with $k\geq 3$. In this case, it is known \cite{DroubayJustinPirillo2001} that $\ipal(\A^\omega)$ is exactly the set of {\it standard episturmian words}, a generalization over a $k$-letter alphabet, $k\geq 3$, of the family of standard Sturmian words (for more details, see \cite{GlenJustin2009}).
\begin{example}\label{e:fibo} The {\it infinite Fibonacci word}
$${ f}=\ipal((01)^\omega)=\underline 0 \, \underline 10 \underline 010 \underline 10010\underline 01010010\underline 1\cdots$$
is a standard Sturmian word directed by the word $(01)^\omega$. Indeed:
\begin{center}\begin{tabular}{*{2}{>{$}r{$}c{$}l{$}r{$}c{$}l{$}r{$}c{$}l p > q$ and $p = mq$ for some integer $m \geq 2$. Then one of the two following conditions holds:
\begin{enumerate}[\rm(i)]
\item $\sigma_1$ is the identity and $m$ is even;
\item $\sigma_1 = \sigma_2$ and $m$ is odd.
\end{enumerate}
\end{lemma}
\begin{proof}
Let $i$ be an integer such that $1 \leq i \leq |w| - p$. Note that $\sigma_1$ and $\sigma_2$ commute since the alphabet is binary. Therefore,
$$\sigma_R(w\Class{i}) = w\Class{i} = \sigma_1(w\Class{i+p}) = \sigma_1(w\Class{i+mq}) = (\sigma_2^m \circ \sigma_1)(w\Class{i}),$$
so that $\sigma_R = \sigma_2^m \circ \sigma_1$. As a consequence, if $m$ is even, then $\sigma_1 = \sigma_R$, and if $m$ is odd, then $\sigma_R = \sigma_1 \circ \sigma_2$, which implies $\sigma_1 = \sigma_2$.
\end{proof}
It is worth mentioning that Lemma \ref{L:perdiv1} holds for arbitrary alphabets whenever all letters occur in the prefix of length $|w| - p$ of $w$, i.e. whenever we have $\sigma_R(a) = (\sigma_{\V_2}^m \circ \sigma_{\V_1})(a)$ for all letters $a$.
The last lemma is a simple extension of Lemma 8.1.3 of \cite{Lothaire2002} giving condition for a local period to propagate to the whole word. As for Lemma \ref{L:perdiv1}, it could be extended to arbitrary alphabets provided that all letters occur in some prefix of $w$, but since this paper is devoted to binary alphabets, for sake of simplicity, we only present this case.
\begin{lemma} \label{L:perdiv2}
Let $w$ be a finite binary word and $v$ be a factor of $w$. Assume that $p$ is a $\sigma_1$-period of $w$ such that $|v| > p$ and $q$ is a $\sigma_2$-period of $v$ such that $q$ divides $p$, where $\sigma_1, \sigma_2 \in \{\sigma_R, \sigma_E\}$. Then $q$ is a $\sigma_2$-period of $w$.
\end{lemma}
\begin{proof}
First consider the case $q = p$. Then $p = q$ is both a $\sigma_1$-period and a $\sigma_2$-period of $v$ and $|v| > p$. This means that $\sigma_1 = \sigma_2$ and the lemma follows. For the rest of the proof, we may suppose $q < p$ and $p = qm$ for some positive integer $m \geq 2$.
Let $k$ be an integer, $1 \leq k \leq |w|$, such that $v = w\Class{k}w\Class{k+1}\cdots w\Class{k+|v|-1}$. Let $V = \{k,k+1,\ldots,k+|v|-1\}$ be the set of indices of $v$ in $w$. Moreover, let $i$ be an integer such that $1 \leq i \leq |w| - q$. Since $|v| > p$, there exists an integer $i' \in V$ such that $i' \equiv i \bmod p$.
Therefore, since $p$ is a $\sigma_1$-period of $w$, we have $w\Class{i'} = \sigma_1^{|\ell|}(w\Class{i})$, where $\ell$ is the integer satisfying $i' - i = p\ell$. Since $\sigma_1$ is involutory, we have $w\Class{i} = \sigma_1^{|\ell|}(w\Class{i'})$ as well.
Let $j = i + q$. Using a similar argument as above, we find that there exists at least one integer $j' \in V$ such that $j' \equiv j \bmod p$. In particular, we may choose $j'$ so that $j' \in \{i' + q, i' + q - p\}$. Indeed, we have $i' + q \equiv i' + q - p \equiv i + q \bmod p$ and at least one value among $i' + q$ and $i' + q - p$ must fall in $V$ (since $|v| > p$ and $i' \in V$). Thus, we may write $j' - j = p\ell'$, for some integer $\ell' \in \{\ell - 1, \ell\}$, so that $w\Class{j'} = \sigma_1^{|\ell'|}(w\Class{j})$.
We distinguish two cases. Assume first that $\ell' = \ell$ so that $j' = i' + q$. Since $q$ is a $\sigma_2$-period of $v$, we have $w\Class{i'} = \sigma_2(w\Class{j'})$. Then $w\Class{j} = (\sigma_1^{|2\ell|} \circ \sigma_2)(w\Class{i}) = \sigma_2(w\Class{i})$. On the other hand, suppose that $\ell' = \ell - 1$ so that $j' = i' + q - p$. Recall that $p = qm$. Then $j' = i' + (1 - m)q$ so that $w\Class{i'} = \sigma_2^{|1-m|}(w\Class{j'})$. This implies $w\Class{j} = (\sigma_1^{|2\ell-1|} \circ \sigma_2^{|1-m|})(w\Class{i}) = (\sigma_1 \circ \sigma_2^{|1-m|})(w\Class{i})$. We know from Lemma \ref{L:perdiv1} that either $\sigma_1 = R$ and $m$ is even or $\sigma_1 = \sigma_2$ and $m$ is odd. Both cases imply $w\Class{j} = \sigma_2(w\Class{i})$. Hence, we have shown that $w\Class{i + q} = \sigma_2(w\Class{i})$ for any integer $i$ such that $1 \leq i \leq |v| - q$, i.e. $q$ is a $\sigma_2$-period of $w$.
\end{proof}
%%%%%%%%%%%%%%
\section{Normalized form} \label{S:normalized}
Words obtained by iterated palindromic closure are the limit of a sequence of palindromes that are prefixes of each other. The idea is the same when considering iterated pseudopalindromic closure. A first trivial and useful observation is the following.
\begin{lemma} \label{L:nomiss}
Let $\bu = \ipal(\bw)=\ipal_{R^\omega}(\bw)$ be a word on an arbitrary alphabet. The word $v$ is a palindromic prefix of $\bu$ if and only if there exists a nonnegative integer $n$ such that $v = \ipal_{R^n}(\bw\Class{1\ldots n})$.
\end{lemma}
\begin{proof}
$(\Rightarrow)$ By contradiction, assume that such a word $v$ exists. Let $n$ be the integer such that $|\ipal_{R^{n-1}}(\bw\Class{1\ldots n - 1})| < |v| < |\ipal_{R^n}(\bw\Class{1\ldots n})|$. Then $\ipal_{R^n}(\bw\Class{1\ldots n})$ is not the shortest palindromic suffix having $\ipal_{R^{n-1}}(\bw\Class{1\ldots n-1})\bw\Class{n}$ as a prefix, contradicting the definition of the palindromic closure. $(\Leftrightarrow)$ By definition of palindromic closure, $\ipal_{R^n}(\bw\Class{1\ldots n})$ is a palindrome for any integer $n \geq 0$.
\end{proof}
Roughly speaking, Lemma \ref{L:nomiss} states that no palindromic prefix is missed by the iterated palindromic closure. In the following, Lemma \ref{L:nomiss} is used several times without being referenced. This fact also holds for any $\V$-standard word (see Proposition 4.1, \cite{deLucaDeLuca2006}), i.e. no $\V$-palindromic prefix is missed by the iterated $\V$-palindromic closure. However, this is not the case if different pseudopalindromic closures are allowed. For instance, the word $w = \ipal_{RERE}(0011) = \underline 0 \d {\rm 0}11 \underline 100 \d {\rm 1}100011$ misses the palindrome $00$ while the word $u=\ipal_{RRE}(011)=\underline 0\, \underline 10\d {\rm 1}$ misses the $E$-palindrome $01$. On the other hand, $w = \ipal_{RRERE}(00111)$ and $u=\ipal_{RERE}(0101)$, i.e. it is possible to rewrite the directive bi-sequences of $w$ and $u$ so that they do not miss any pseudopalindromic prefixes. As we will see (and prove) in the sequel, it is always possible to rewrite any directive bi-sequence of a generalized pseudostandard word in a ``normalized'' form.
\begin{definition} A finite or infinite directive bi-sequence $(\Theta, w)$ is called \emph{normalized} if it verifies the following condition: $v$ is a pseudopalindromic prefix of $\psi_\Theta(w)$ if and only if there exists a non negative integer $n$ such that $v = \psi_{\Theta\Class{1..n}}(w\Class{1..n})$. A pseudopalindromic prefix $v$ that does not satisfy the previous condition is called a \emph{missed pseudopalindrome} and the we say that $(\Theta, w)$ \emph{misses} $v$.
\end{definition}
The length of any missed pseudopalindrome is constrained.
\begin{lemma}\label{L:longueurMissed} Let $(\Theta, w)$ be a finite directive bi-sequence describing a prefix of a generalized pseudostandard word on any alphabet. If $(\Theta, w)$ is normalized and $(\Theta \tau, wx)$ is not, with $x \in \A$ and $\tau \in \{E, R\}$, any missed $\V$-palindromic prefix $p$ is such that $|\ipal_\Theta(w)| < |p| < |\ipal_{\Theta \tau}(wx)|$.
\end{lemma}
\begin{proof} It is obvious that $|p| < |\ipal_{\Theta \tau}(wx)|$. If $|p|\leq |\ipal_\Theta(w)|$, then a contradiction occurs, since $(w, \Theta)$ is supposed normalized.
\end{proof}
The next results only apply to binary alphabets. First, the following fact is easily observed.
\begin{lemma}\label{L:prefNorm} The shortest prefixes of a normalized directive bi-sequence containing exactly two different letters are of the form:
$$(R^{i+1},a^i\overline a) {\rm \, \, \, for \, \, \, } i\geq 2, {\rm\, \, \, or \, \, \, } (R^i E, a^i {\overline a}) {\rm \, \, \, for \, \, \, } i\geq 1 {\rm \, \, \, and \, \, \, } a \in \{0,1\}.$$
\end{lemma}
\begin{proof}
By direct inspection. One notices in particular that no normalized bi-sequence starts with the antimorphism $E$.
\end{proof}
Generalized pseudostandard words have periods to different scale. In particular, if a bi-sequence is not normalized, we can extract useful information about the antimorphisms and the letters involved.
\begin{lemma} \label{L:not normalized}
Let $(\Theta,w)$ be a finite normalized directive bi-sequence of length $n \geq 1$ of a prefix of a generalized pseudostandard binary word. Suppose that $(\Theta\tau,wa)$ is not normalized, where $\tau \in \{R,E\}$ and $a \in \A$. Let $u = \ipal_\Theta(w)$, $v = \ipal_{\Theta\tau}(wa)$ and $t$ be a pseudopalindromic prefix missed by $(\Theta\tau,wa)$. Finally, let $p = |v| - |u|$, $q = |v| - |t|$ and $g = \gcd(p,q)$. Then exactly one of the following conditions hold.
\begin{enumerate}[\rm(i)]
\item $g$ is an $\sigma_E$-period of $v$, $p = 2g$, $q = g$ and $\V_n = \tau$, where $\V_n$ is the last antimorphism of $\Theta$;
\item $(\Theta\tau, wa) = (R^nE,a^{n+1})$;
\end{enumerate}
\end{lemma}
\begin{proof}
\begin{figure}
\centering
\includegraphics{tikz-demo-non-normalise}
\caption{Illustration of the proof of Lemma \ref{L:not normalized}.}
\label{F:not normalized}
\end{figure}
The situation is depicted in Figure \ref{F:not normalized}. Notice that $t$ is a $\overline{\tau}$-palindrome, otherwise $v$ would not be the shortest $\tau$-palindrome having $ua$ as a prefix. Moreover, it follows from Lemma \ref{L:fperiod} that $p$ is a $(\sigma_{\V_n} \circ \sigma_\tau)$-period of $v$, since $v$ is a $\tau$-palindrome and $u$ is a $\V_n$-palindrome, where, $\V_n$ is the last antimorphism of $\Theta$. Similarly, $q$ is a $(\sigma_\tau \circ \sigma_{\overline{\tau}})$-period (i.e. an $\sigma_E$-period) of $v$.
First, suppose that $|v| \geq p + q$. Then Theorem \ref{T:fineandwilf} applies so that $v$ has the $\sigma_E$-period $g = \gcd(p,q)$. By Lemma \ref{L:pal and antipal}, we conclude that the prefix $y$ of $v$ of length $|v| - 2g$ is a $\tau$-palindrome. Since no $\tau$-palindrome occurs between $u$ and $v$ (otherwise $v$ would not be the shortest $\tau$-palindrome having $ua$ as a prefix), we must have $|y| \leq |u|$, i.e. $p = |v| - |u| \leq 2g$.
Since $0 < q < p \leq 2g$ and $g$ divides both $p$ and $q$, we have $p, q \in \{g,2g\}$. But $q < p$, so that $q = g$ and $p = 2g$. In particular, $u = y$ is a $\tau$-palindrome and we are in case (i).
It remains to consider the case $|v| < p + q$. Notice that, by definition of pseudopalindromic closure, one has $|v| \leq 2|u| + 2$, with $|v| = 2|u| + 2$ only if $v$ is an $E$-palindrome. We first show that $|v| = 2|u| + 2$. Arguing by contradiction, suppose that $|v| \leq 2|u| + 1$. Then
\begin{align}
|v|
& < p + q \notag \\
& = |v| - |u| + |v| - |t| \notag \\
& \leq 2|u| + 1 - |t| + |v| - |u| \notag \\
& = |u| + 1 - |t| + |v| \notag \\
& \leq |u| + 1 - |u| - 1 + |v| \label{E:cons} \\
& = |v|, \notag
\end{align}
which is absurd. Note that Inequality \eqref{E:cons} follows from the inequality $|t| \geq |u| + 1$. Hence, $|v| = 2|u| + 2$. This implies that $\tau = E$ and $t$ is a $R$-palindrome (since $\overline{\tau} = R$).
Next, suppose that $|t| \geq |u| + 2$. Then $q \leq |u|$. Since $u$ is a $\V_n$-palindrome and $q$ is a $\sigma_E$-period of $u$, Lemma \ref{L:pal and antipal} implies that the prefix of $v$ of length $|u| + q$ is a $\overline{\sigma_{\V_n}}$-palindrome. Therefore, $\overline{\sigma_{\V_n}} \neq \tau$, otherwise, $v$ would not be of minimum length, which implies $\V_n \neq \tau$ and then $\V_n = R$. As a consequence, $p - q$ is a $\sigma_E$-period of $t$. Moreover, we know that $q$ is a $\sigma_E$-period of $t$ as well since it is a period of $v$. We can apply Theorem \ref{T:fineandwilf} to $t$ since $q + (p - q) = p = |u| + 2 \leq |t|$, so that $\gcd(q, p - q) = \gcd(q,p) = g$ is a $\sigma_E$-period of $t$ which propagates to $v$, by Lemma \ref{L:perdiv2}. Once again by Lemma \ref{L:pal and antipal}, we conclude that the prefix of $v$ of length $|u| + 2g$ is a $\V_n$-palindrome, i.e. a $\tau$-palindrome. This implies $|u| + 2g \geq |v| = 2|u| + 2$, so that $2g \geq |u| + 2 = p$. Since $g$ divides both $p$ and $q$ and since $q < p$, this means that $q = g$ and $p = 2g$, which corresponds also to case (i).
Finally, assume that $|t| = |u| + 1$. There are two cases to consider. If $\V_n = R$, then Lemma \ref{L:fperiod} implies that $1$ is a $\sigma_R$-period of $t$, so that $t = a^{n+1}$, $u = a^n$, $v = a^{n+1}\overline{a^{n+1}}$ and $(\Theta\tau,wa) = (R^nE,a^{n+1})$, which yields case (ii). Otherwise, again by Lemma \ref{L:fperiod}, $\V_n = E$ and $1$ is a $\sigma_E$-period of $t$. Since $t$ is an $R$-palindrome, we must have $t = (a\bar{a})^ka$ for some positive integer $k$. But every prefix of $t$ is either an $R$-palindrome or an $E$-palindrome and $(\Theta,w)$ is normalized: Therefore, $|u| = n$ which implies $u = (a\overline{a})^{n/2}$, $t = (a\overline{a})^{n/2}a$ and $v = (a\overline{a})^{n/2+1}$. But $n + 2 = |v| = 2|u| + 2 = 2n + 2$, so that $n = 0$, a contradiction.
\end{proof}
There are forbidden patterns that necessarily lead to non normalized bi-sequences.
\begin{lemma}\label{L:not normalized alternate}
Let $\Theta$ be a sequence of involutory antimorphisms, $\V \in \{R, E\}$, $w \in \A^*$ and $a, b \in \A$, where $\A$ is a binary alphabet. Suppose that $(\Theta\V\bar{\V}, wab)$ is normalized. Also, let $u = \ipal_{\Theta\V}(wa)$, $v = \ipal_{\Theta\V\bar{\V}}(wab)$, $p = |v| - |u|$ and $s$ be the suffix of length $p$ of $v$. Then
\begin{enumerate}[\rm(i)]
\item $p$ is the minimum $\sigma_E$-period of $v$;
\item $\ipal_{\Theta\V\bar{\V}\V}(uab\bar{b}) = v\bar{s}$;
\item $\ipal_{\Theta\V\bar{\V\V}}(uab\bar{b}) = v\bar{s}s$;
\item $(\Theta\V\bar{\V\V}, uab\bar{b})$ is not normalized, $(\Theta\V\bar{\V}\V\bar{\V}, uab\bar{b}b)$ is normalized and both bi-sequences generate the same word.
\end{enumerate}
\end{lemma}
\begin{proof}
(i) It follows from Lemma \ref{L:fperiod} that $p$ is a $\sigma_E$-period of $v$ since $\sigma_{\V} \circ \sigma_{\bar{\V}} = \sigma_E$. It remains to show that $p$ is minimal. By contradiction, assume that there exists a $\sigma_E$-period $p' < p$. Let $s'$ be the word of length $p'$ such that $us'$ is a prefix of $v$. By Lemma \ref{L:pal and antipal}, $us'$ is a $\bar{\V}$-palindrome and, by construction of $v$, $b$ is the first letter of $s'$, contradicting the fact that $v$ is the shortest $\bar{\V}$-palindrome having $ub$ as a prefix.
(ii) Since $v$ is a $\bar{\V}$-palindrome having $p$ as a $\sigma_E$-period, it follows from Lemma \ref{L:pal and antipal} that $v\overline{s}$ is a $\V$-palindrome. Now, assume that $v\overline{s}$ is not the shortest $\V$-palindrome having $v\bar{b}$ as a prefix. Let $x$ be the longest $\V$-palindrome suffix of $v$. Then $|x| > |v| - p$ and, by Lemma \ref{L:fperiod}, $v$ has the $\sigma_E$-period $|v| - |x| < p$, contradicting the minimality of $p$.
(iii) It suffices to apply the same reasoning as in part (ii).
(iv) Parts (ii) and (iii) implies that $(\Theta\V\bar{\V\V}, uab\bar{b})$ is not normalized since it misses the pseudopalindrome $v\bar{s}$. Moreover, $(\Theta\V\bar{\V}\V\bar{\V}, uab\bar{b}b)$ is normalized since it does not verify any of the conditions of Lemma \ref{L:not normalized}. Finally, applying twice part (ii) and once part (iii) shows that both bi-sequence generate the same word.
\end{proof}
Let $(\Theta, w)$ be an infinite (resp., a finite) directive bi-sequence of a (resp., prefix of a) generalized pseudostandard word. The concept of factor is naturally extended to bi-sequences. More precisely, $(\V_i\cdots \V_{i+k}, w\Class{i \ldots i+k})$ is called a {\it factor} of $(\Theta, w)$ for any integers $i, k \geq 1$.
We are now ready to describe the forbidden factors and prefixes of normalized bi-sequences.
\begin{proposition}\label{L:motifInt} A finite directive bi-sequence $s$ on a binary alphabet is normalized if and only if it does not have a prefix of one of the following forms:
\begin{multicols}{2} \begin{enumerate}[\rm (i)]
\item $(RR, a\overline{a})$,
\item $(R^{i-1}E, a^i)$,
\item $( R^iEE, a^i\overline{a}\,\overline{a})$,
\item $(\Theta REE, wab\overline{b})$ or $(\Theta ERR, wab\overline{b})$,
\end{enumerate} \end{multicols}
\noindent where $a,b \in \{0,1\}$, $i \geq 1$ is an integer and $(\Theta,w)$ is a finite directive bi-sequence.
\end{proposition}
\begin{proof}
$(\Rightarrow)$ We prove the contrapositive, i.e. we suppose that the prefix of the directive bi-sequence is of one of these four forms and prove that it is not normalized. Clearly, (i) $\ipal_{RR}(a\overline{a}) = a\overline{a}a$ misses the $E$-palindromic prefix $a\overline{a}$, (ii) $\ipal_{R^{i-1}E}(a^i) = a^{i}\overline{a}^{i}$ misses the palindromic prefix $a^i$ and (iii) $\ipal_{R^iEE}(a^i\overline{a}\, \overline {a}) = a^i\overline{a}^{i+1}a^{i+1}\overline{a}^i$ misses the palindromic prefix $a^i\overline{a}^{i+1}a^i$. Case (iv) follows directly from Lemma \ref{L:not normalized alternate}.
\begin{figure}
\centering
\includegraphics{tikz-forbidden}
\caption{Illustration of Part $(\Leftarrow)$ in the proof of Proposition \ref{L:motifInt}. It follows from Lemma \ref{L:not normalized} that $p = 2g$ and $q = g$, where $g = \gcd(p,q)$. Also, $\V_{n-1} = \V_n$.}
\label{F:forbidden}
\end{figure}
$(\Leftarrow)$ We prove the contrapositive, i.e. we suppose that $s$ is not normalized. If $|s| \leq 2$, then inspection shows that the only possible non-normalized directive bi-sequences fall in case (i) or (ii). Now, assume that $|s| \geq 3$.
Let $(\Theta,w)$ be the shortest non-normalized prefix of $s$ and $n = |w|$. Let
\begin{eqnarray*}
u & = & \ipal_{\V_1\V_2\cdots\V_{n-1}}(w\Class{1}w\Class{2}\cdots w\Class{n-1}),\\
v & = & \ipal_{\Theta}(w)
\end{eqnarray*}
and $t$ be a $\overline{\V_n}$-palindrome missed by $(\Theta,w)$ (see Figure \ref{F:forbidden}). Moreover, let $p = |v| - |u|$, $q = |v| - |t|$ and $g = \gcd(p,q)$. By Lemma \ref{L:not normalized}, either we are in case (ii) or (iv), or $(\Theta,w)$ ends with a factor in $\{(RRR, abc), (EEE, abc), (ERR,abc), (REE, abc)\}$, where $a,b,c$ are letters. On the other hand, Lemma \ref{L:not normalized} implies that $|v| \geq p + q$, $g$ is an $\sigma_E$-period of $v$, $p = 2g$, $q = g$ and $u$ is a $\V_n$-palindrome, i.e. $\V_{n-1}=\V_n$. Let $y$ be the prefix of lenght $n - 2$ of $\ipal_\Theta(w)$, that is $y = \ipal_{\V_1\V_2\cdots\V_{n-2}}(w\Class{1}w\Class{2}\cdots w\Class{n-2})$.
Notice that $|u| - |y| \leq g$. Otherwise, there would exist a $\overline{\V_n}$-palindromic prefix between $y$ and $u$, namely the suffix of $v$ of length $|v| - 3g$ by Lemma \ref{L:pal and antipal}, contradicting the fact that $(\V_1\V_2\cdots \V_{n-1}, w\Class{1}w\Class{2}\cdots w\Class{n-1})$ is normalized. Let $g' = |u| - |y|$. If $g' = g$, then $\V_{n-2} = \overline{\V_n}$ and $c = \overline{b}$, i.e. $s$ ends with $(ERR,ab\overline b)$ or $(REE, ab\overline b)$. By Lemma \ref{L:not normalized alternate}, we know that $s$ is not normalized, and this corresponds to case (iv). It remains to consider the case $g' < g$. We show in the next paragraphs that this implies case (iii).
First, we show that $|y| < g$. Proceeding by contradiction, assume that $|y| \geq g$. This implies $|u| \geq g + g'$. Since $g$ is an $\sigma_E$-period of $v$ and in particular an $\sigma_E$-period of $u$ and, by Lemma \ref{L:fperiod}, $g'$ is a $(\sigma_{\V_{n-2}} \circ \sigma_{\V_n})$-period of $u$, it follows from Theorem \ref{T:fineandwilf} that $g'' = \gcd(g,g')$ is an $\sigma_E$-period of $u$. Moreover, that $\sigma_E$-period $g''$ propagates to the whole word $v$ in virtue of Lemma \ref{L:perdiv2} applies, yielding a contradiction: this would imply that there is a $\V_n$-palindrome between the $\V_n$-palindromes $u$ and $v$, namely the prefix of $v$ of length $|v| - 2g''$ (by Lemma \ref{L:pal and antipal}). But $g'' < g$ (since $g' < g$). Hence, the claim $|y| < g$ is proved.
Now, we prove that $|v| = 4g - 2$. Recall that by definition of pseudopalindromic closure, $|v| \leq 2|u| + 2$. Moreover, $|v| = |u| + 2g$, $|y| \leq g - 1$ and $g' = |u| - |y| \leq g - 1$. On the first hand, we have $|v| \leq 2|u| + 2 = 2|v| - 4g + 2$ which implies $|v| \geq 4g - 2$. On the other hand, $|v| = |u| + 2g \leq |y| + g - 1 + 2g \leq g - 1 + g - 1 + 2g = 4g - 2$, thus $|v| = 4g - 2$. In particular, in virtue of the equalities and inequalities $|v| = 4g - 2$, $|v| - |u| = 2g$, $|u| - |y| \leq g - 1$ and $|y| \leq g - 1$, we have $|y| = g - 1$, $|u| = 2g - 2$ and $|v| = 2|u| + 2$. Hence, $\V_n = E$ and $g' = |u| - |y| = g - 1$.
Finally, notice that, since $|v| \geq p + q = 3g$, the prefix $z$ of $v$ of length $|v| - 3g$ is a $\overline{\V_n}$-palindrome, i.e. an $R$-palindrome, by Lemma \ref{L:pal and antipal}. But Lemma \ref{L:fperiod} implies that $|y| - |z| = g - g' = 1$ is an $(\sigma_{\V_{n-2}} \circ \sigma_R)$-period of $y$, i.e. an $\sigma_{\V_{n-2}}$-period of $y$. If $\V_{n-2} = R$ and since $y$ has length $g - 1$, contains the letter $\overline{b}$ and $\V_1 = R$, we find $y = \overline{b}^{g-1}$, so that $u = \overline{b}^{g-1}b^{g-1}$ and $v = \overline{b}^{g-1}b^g\overline{b}^gb^{g-1}$, which corresponds to case (iii). It only remains to consider the case $\V_{n-2} = E$. Then $y = (d\bar{d})^{(g - 1)/2}$ for some letter $d$, since $1$ is a $\sigma_E$-period of $y$ and $|y| = g - 1$. But $\V_n = \V_{n-1} = E$ and $(\V_1\V_2\cdots\V_{n-1},w\Class{1}w\Class{2}\cdots w\Class{n-1})$ is normalized, which implies that $w\Class{n-1} \neq d$ (otherwise the palindrome $(d\bar{d})^{(g-1)/2}d$ would be missed). Therefore, $u = (d\bar{d})^{(g-1)/2}(\bar{d}d)^{(g-1)/2}$. Finally, notice that the condition $|v| = 2|u| + 2$ implies that the longest $\sigma_E$-palindromic suffix of $uw\Class{n} = \varepsilon$. This is impossible since $d\bar{d}$ is a $\sigma_E$-palindromic suffix of $u\bar{d}$ and $\bar{d}\bar{d} (d\bar{d})^{(g-1)/2 - 1}dd$ is a $\sigma_E$-palindromic suffix of $ud$.
%Hence, $w\Class{n} \neq \bar{d}$, i.e. $w\Class{n} = d$ and
%$$v = (d\bar{d})^{(g-1)/2}(\bar{d}d)^{(g-1)/2}(d\bar{d})^{(g-1)/2}(d\bar{d})^{(g-1)/2}.$$
%But $(\V_1\V_2\cdots\V_{n-2},w\Class{1}w\Class{2}\cdots w\Class{n-2})$ is normalized and all prefixes of $y$ are pseudopalindromes, which implies that $y$ ends with $a$. Hence, $y = (\bar{a}a)^{(g - 1)/2}$. Similarly, since $(\V_1\V_2\cdots\V_{n-1},w\Class{1}w\Class{2}\cdots w\Class{n-1})$ is normalized and $|u| = 2g - 2$, one finds that $u = (\bar{a}a)^{(g-1)/2}(a\bar{a})^{(g-1)/2}$.
%assume that $\V_{n-2} = E$. Since $\V_n = \V_{n-1} = R$ and ...., we conclude that $(\Theta,w)$ ends with $(ERR, a\overline bb)$, with $a \in \A$ and we fall back in case (iv), which concludes the proof.
\end{proof}
The following theorem explains how to replace the forbidden factors in order to normalize a directive bi-sequence.
\begin{theorem}\label{T:reecriture}
Let $(\Theta, w)$ be a directive bi-sequence, with $\Theta$ a finite or infinite sequence of involutory antimorphisms and $w$ a binary word having same length as $\Theta$. Then there exists a normalized directive bi-sequence $(\Theta', w')$ such that $\psi_\Theta(w)=\psi_{\Theta'}(w')$. Moreover, in order to get the normalized directive bi-sequence $(\Theta', w')$ from $(\Theta, w)$, it is sufficient to replace the prefix (if it is of one of the following forms):
\begin{enumerate}[\rm (i)]
\item $(RR, a\overline{a})$ by $(RER, a\overline a a)$;
\item $(R^{i-1}E, a^i)$ by $(R^iE, a^i \overline a)$;
\item $(R^iEE, a^i\overline{a}\,\overline{a})$ by $(R^iERE,a^i\overline a\, \overline a a)$;
\end{enumerate}
for $i\geq 1$ and then, to replace from left to right any factor
\begin{enumerate}[\rm(i)]
\setcounter{enumi}{3}
\item $(\V \bar{\V} \bar{\V}, ab\overline b)$ by $(\V \bar{\V} \V \bar{\V}, ab\overline b b)$,
\end{enumerate}
where $\V \in \{R,E\}$ and $a, b \in \{0,1\}$.
\end{theorem}
\begin{proof}
Proposition \ref{L:motifInt} indicates precisely which prefixes and factors cannot occur in a normalized directive bi-sequence, while Lemma \ref{L:not normalized alternate} tells us how to replace any factor of the form $(\V \bar{\V} \bar{\V}, ab\overline b)$ in order to normalize the directive bi-sequence. It remains to prove how to correct the non-normalized prefixes of the form (i), (ii) and (iii). By Proposition \ref{L:motifInt}, we know that the prefixes $(RER,a\overline a a)$, $(R^iE, a^i \overline a)$ and $(R^iERE, a^i \overline a \, \overline a a)$ are normalized, since they are not in the set of forbidden prefixes and factors. In order to conclude the proof, we let the reader verify that $\ipal_{RR}(a\overline a)=\ipal_{RER}(a\overline aa)$, $\ipal_{R^{i-1}E}(a^i)=\ipal_{R^iE}(a^i \overline a)$ and $\ipal_{R^iEE}(a^i\overline{a}\,\overline{a})=\ipal_{R^iERE}(a^i\overline a\, \overline a a)$.
\end{proof}
\begin{example} Let us normalize the directive bi-sequence $d=(RRR,011).$ Since it has a prefix of the form (i) in Theorem \ref{T:reecriture}, we rewrite $d$ as $d'=(RER\cdot R, 010\cdot 1)$, with $(RER, 010)$ normalized. The second step is to replace all the factors of the form $(\V \bar{\V} \bar{\V}, ab\overline b)$ by $(\V \bar{\V} \V \bar{\V}, ab\overline b b)$. There is only one factor of this form: $(ERR, 101)$. We then obtain the new directive bi-sequence $d''=(RERER, 01010)$, which is normalized. Indeed, one can verify that $d''$ does not contain any forbidden prefix or factor. Finally, $d$ and $d''$ direct the same generalized pseudostandard word:
$$\psi_{RRR}(011)=\underline 0 \, \underline 1 0 \underline 1 0 \quad \text{and} \quad \psi_{RERER}(01010)=\underline 0 \d {\rm 1} \underline 0 \d {\rm 1} \underline 0.$$
\end{example}
%%%%%%%%%%%%%%%%%
\section{A generalization of Justin's formula} \label{S:justin}
The previous section gives us the main tool to prove Theorem \ref{T:main}, that is the existence of the normalization of a directive bi-sequence: Given a generalized pseudostandard word, it is always possible to find a directive bi-sequence that describes all its pseudopalindromic prefixes.
As pointed out in previous sections, the naive way to compute $\ipal_{\Theta R}(wa)$ (resp., $\ipal_{\Theta E}(wa)$) when $\ipal_\Theta (w)$ is known, is to find the longest palindromic (resp., $E$-palindromic) suffix $p$ of $\ipal_\Theta(w)$ preceded by $a$. Then $\ipal_{\Theta R}(wa) = \ipal_\Theta(w) p^{-1}\ipal_\Theta(w)$ (resp., $\ipal_{\Theta E}(wa) = \ipal_\Theta(w) p^{-1}\overline{\ipal_\Theta(w)}$). However, this turns out to be very costly since at each step, one must find the longest pseudopalindromic suffix of words that grow more and more in size. We are now ready to state and prove one of the main theorem of this paper, thus providing an efficient way to compute binary generalized pseudostandard words.
\begin{theorem}\label{T:main}
Let $(\Theta,w)$ be a normalized finite directive bi-sequence of length $n$ on a binary alphabet and, for $i=1,2,\ldots,n$, let $\ipal_i = \ipal_{\V_1\V_2\cdots\V_i}(w\Class{1 \ldots i})$, $\ipal_0 = \varepsilon$ and $\alpha_i$ be the last letter of $\psi_i$ for $1\leq i \leq n$.
\begin{enumerate}[\rm(i)]
\item If $|w\Class{1}w\Class{2}\cdots w\Class{n-1}|_{w\Class{n}} = 0$ or $|\V_1\V_2\cdots \V_{n-1}|_{\V_n} = 0$, then
$$\ipal_{n} = \begin{cases} \ipal_{n-1} w\Class{n} \ipal_{n-1}, & \mbox{if $\V_n = R$;} \\ \ipal_{n-1}\overline{\ipal_{n-1}}, & \mbox{if $\V_n = E$ and $\alpha_{n-1} \neq w\Class{n}$;} \\ \ipal_{n-1}w\Class{n}\overline{w\Class{n}}\, \overline{\ipal_{n-1}}, & \mbox{if $\V_n = E$ and $\alpha_{n-1} = w\Class{n}$.} \end{cases}$$
\item If one can write $(\Theta,w) = (\Theta' \V_n \Theta'', w' (\V_{n-1} \circ \V_n)(w\Class{n}) w'')$ such that $i := |w'| = |\Theta'| + 1$ with $|\Theta'|$ maximum, then $$\ipal_n = \ipal_{n-1} (\V_{n-1} \circ \V_n)\left(\ipal_i^{-1} \ipal_{n-1}\right).$$
\item Otherwise, $$\ipal_{n} = \begin{cases} \ipal_{n-1} \V_n(\ipal_{n-1}), & \mbox{if $\V_n = R$ or $\alpha_{n-1} \neq w\Class{n}$;} \\ \ipal_{n-1}w\Class{n}\bar{w\Class{n}}\,\bar{\ipal_{n-1}}, & \mbox{if $\V_n = E$ and $\alpha_{n-1} = w\Class{n}$.} \end{cases}$$
\end{enumerate}
\end{theorem}
\begin{proof}
(i) Assume first that $w = a^{n-1}\overline{a}$ for some $a \in \A$. Then $\Theta \in \{R^n, R^{n-1}E\}$, otherwise $(\Theta, w)$ would not be normalized by Lemma \ref{L:prefNorm}. The result follows according to the value of $\Theta_n$, $w_n$ and $\alpha_n$. If $|\V_1\V_2\cdots\V_{n-1}|_{\V_n} = 0$ and $|w\Class{1}w\Class{2}\cdots w\Class{n-1}|_{w\Class{n}} \neq 0$, again by Lemma \ref{L:prefNorm}, since $(\Theta, w)$ is normalized, we know that $\V_1 = R$ so that $\V_n = E$, except if $n = 1$. But since no $E$-palindrome occurs as a prefix, and then as a suffix of $\psi_{n-1}$, we deduce that the longest $E$-palindromic suffix of $\ipal_{\V_1\V_2\cdots \V_{n-1}}(w\Class{1}w\Class{2}\cdots w\Class{{n-1}})w\Class{n}$ is either $\varepsilon$ or $\alpha_{n-1}\overline{\alpha_{n-1}}$ and the result follows.
(ii) By hypothesis, there exists a $\V_n$-palindromic prefix $\psi_i$ of $\psi_{n-1}$ followed by the letter $(\V_{n-1} \circ \V_n)(w\Class{n})$. Moreover, since $(\Theta, w)$ is normalized, $|\Theta'|$ is maximum and by its construction, $\psi_i$ is exactly the longest $\V_n$-palindromic prefix of $\psi_{n-1}$ followed by the letter $(\V_{n-1} \circ \V_n)(w\Class{n})$. But $\psi_{n-1}$ is a $\V_{n-1}$-palindrome, so that $\V_{n-1}(\psi_i)$ is the longest $(\V_{n-1} \circ \V_n)$-palindromic suffix of $\psi_{n-1}$ preceded by $\V_n(w\Class{n})$. Then $s = \V_n(w\Class{n})\V_{n-1}(\psi_i)w\Class{n}$ is the longest $\V_n$-palindromic suffix of $\psi_{n-1}w\Class{n}$. Therefore,
\begin{eqnarray}
\psi_n & = & \psi_{n-1}w\Class{n}(s^{-1})\V_n(w\Class{n})\V_n(\psi_{n-1}) \nonumber \\
& = & \psi_{n-1}w\Class{n} (\V_n(w\Class{n})\V_{n-1}(\psi_i)w\Class{n})^{-1}\V_n(w\Class{n})\V_n(\psi_{n-1}) \label{lgn2} \\
& = & \psi_{n-1}w\Class{n} w\Class{n}^{-1}\V_{n-1}(\psi_i)^{-1}\V_n(w\Class{n})^{-1}\V_n(w\Class{n})\V_n(\psi_{n-1}) \label{lgn3}\\
& = & \psi_{n-1}\V_{n-1}(\psi_i)^{-1}\V_n(\psi_{n-1}) \label{lgn4} \\
& = & \psi_{n-1}(\V_{n-1} \circ \V_n)(\psi_i^{-1}\psi_{n-1}), \label{lgn5}
\end{eqnarray}
which concludes this part. Notice that Equation (\ref{lgn3}) is obtained from Equation (\ref{lgn2}), using the fact that for any word $u, v \in \A^*$, $(uv)^{-1}= v^{-1}u^{-1}$, and that Equation (\ref{lgn5}) follows from Equation (\ref{lgn4}), since $\psi_i$ is a $\V_n$-palindrome and $\psi_{n-1}$ is a $\V_{n-1}$-palindrome.
(iii) Since the hypothesis of cases (i) and (ii) are not satisfied, we can assume here that $\psi_{n-1}$ does not have a nonempty $\V_n$-palindromic suffix that is preceded by the letter $\V_n(w\Class{n})$ and that $|w\Class{1}w\Class{2}\cdots w\Class{n-1}|_{w\Class{n}}\geq 1$. Let us first suppose that $\V_n=R$. Then $w\Class{n}=\alpha_{n-1}$, otherwise we contradict the hypothesis, since it implies that $\psi_{n-1}$ necessarily has a palindromic suffix that is preceded by the letter $\V_n(w\Class{n})=w\Class{n}$, namely a suffix of the form $w\Class{n}\overline {w\Class{n}} ^i$. Thus, $\V_n=R$ implies $w\Class{n}=\alpha_{n-1}$ and consequently, $\psi_{n}=\psi_{n-1}R(\psi_{n-1})$.
Let us now suppose that $\V_n=E$. If $w\Class{n}=\alpha_{n-1}$, one deduces that $\psi_n=\psi_{n-1}w\Class{n} \overline{w\Class{n}}\, \overline {\psi_{n-1}}$, while if $w\Class{n}\neq \alpha_{n-1}$, one obtains $\psi_n=\psi_{n-1}\overline {\psi_{n-1}}$. Combining all those cases yields the statement.
\end{proof}
It is worth mentioning that Proposition \ref{P:justin} is a special case of Theorem \ref{T:main}. Indeed, if $\Theta=R^n$, then $(\Theta, w)$ directs a standard Sturmian sequence and we retrieve case (i) if $w=a^{n-1}\overline a$, for $a \in \{0,1\}$ and then, $\psi_n=\psi_{n-1}w\Class{n}\psi_{n-1}$. Otherwise, case (ii) applies and we get $\psi_n=\psi_{n-1}\psi_i^{-1}\psi_{n-1}$.
On the other hand, if $\Theta=E^n$, the directive bi-sequence $(E^n, w)$ cannot be a normalized one, by Lemma \ref{L:prefNorm}. In this case, we can use the same idea as in the proof of Theorem \ref{T:main} in order to get the following generalization of Justin's formula for $E$-standard words.
\begin{proposition} Let $(E^{n+1}, wa)$ be a directive bi-sequence of a $E$-standard word, with $w \in \{0,1\}^n$. If $w$ is not $a$-free, then we write $w=v_1 a v_2$ with $v_2$ $a$-free and we have
$$\ipal (wa) =
\begin{cases}
\ipal(w)a \bar{a} E(\ipal(w)), & \mbox{if $w$ is $a$-free;}\\
\ipal(w)\ipal(v_1)^{-1}E(\ipal(w)), & \mbox{otherwise.}
\end{cases}
$$
\end{proposition}
Notice that the algorithms of normalization and of computation of generalized pseudostandard words have been implemented in Python by the first author and should be included soon in the Sage words library \cite{sage}.
To conclude this section, let us see how Theorem \ref{T:main} may be used in order to construct the Thue-Morse word.
\begin{example} Theorem \ref{T:TM} tells us that the Thue-Morse word is a generalized pseudostandard word $T=\psi_{(ER)^\omega}(01^\omega)$. In order to apply Theorem \ref{T:main} to the construction of $T$, we have to normalize the directive bi-sequence $d=((ER)^\omega, 01^\omega)$. Using Theorem \ref{T:reecriture}, we get $d'=((RE)^\omega, 01^\omega)$, which is normalized. Theorem \ref{T:main} yields the successive prefixes $t_i$ of $T$, with $t_0=\varepsilon$:
\begin{eqnarray*}
t_1 & = & 0;\\
t_2 & = & t_1\overline{t_1} = 01, \mbox{by Theorem \ref{T:main} (i), second case;}\\
t_3 & = & t_2 E(t_0 ^{-1}t_2) = 01 E(01) = 0110, \mbox{by Theorem \ref{T:main} (ii);}\\
t_4 & = & t_3E(t_3)=01101001, \mbox{by Theorem \ref{T:main} (iii), first case;} \\
t_5 & = & t_4E(t_4)=0110100101101001, \mbox{by Theorem \ref{T:main} (iii), first case}
\end{eqnarray*}
and so on, which corresponds to the usual construction of the Thue-Morse word.
\end{example}
\section{Rote words} \label{S:rote}
This section is devoted to the study of Rote words obtained by iterated pseudopalindromic closure. They deserve some attention since they provide a natural characterization of the palindromic prefixes in standard Sturmian words. Moreover, their corresponding normalized bi-sequences are easy to characterize. The so-called \emph{Rote words} or \emph{complementary-symmetric words} are sequences of letters having complexity $2n$ and such that their language is closed under the complementation operator. Let $w$ be a binary word on $\{0,1\}$. The \emph{difference of $w$}, denoted by $\Delta(w)$, is the word $v = v_1v_2\cdots v_{|w| - 1}$ defined by
\[v_i = (w_{i+1} - w_i) \bmod 2, \quad \mbox{for $i = 1,2,\ldots,|w| - 2$}.\]
Complementary-symmetric words are connected to Sturmian words by a structural theorem.
\begin{theorem}[Rote~\rm\cite{Rote}] \label{T:rote}
An infinite word $\bw$ is a complementary-symmetric Rote word if and only if the infinite word $\Delta(\bw)$ is a Sturmian word.
\end{theorem}
We say that a complementary-symmetric words $\br$ is a \emph{standard Rote word} if both $0\br$ and $1\br$ are complementary-symmetric words. Equivalently, a word $\br$ is standard Rote if and only if $\Delta(\br)$ is standard Sturmian.
The aim of this section is to provide an explicit construction of standard Rote words by iterated pseudopalindromic closure. The key idea is to exploit the link with Sturmian words by looking at the palindrome and antipalindrome prefixes of the Rote word. First, we state without proof some elementary properties of the operator $\Delta$.
\begin{lemma} \label{L:delta}
Let $u,v \in \varSigma^*$, where $|u|,|v| \geq 2$. Then
\begin{enumerate}[\rm(i)]
\item \label{SL:equal} $\Delta(u) = \Delta(v)$ if and only if $v = u$ or $v = \overline{u}$,
\item \label{SL:pal or antipal} $u$ is either a palindrome or an antipalindrome if and only if $\Delta(u)$ is a palindrome and
\item $u$ is an antipalindrome if and only if $\Delta(u)$ is an odd palindrome with central letter $1$.
\end{enumerate}
\end{lemma}
Now, we study the palindrome prefixes of standard Sturmian words.
For instance, consider the Fibonacci word:
$$\bfi = 010010100100101001010\cdots$$
Its palindrome prefixes are:
$$\varepsilon, 0, 010, 010010, 01001010010, \ldots$$
We may divide them into three categories
\begin{enumerate}[(i)]
\item palindromes of even length,
\item palindromes of odd length with central letter $0$ and
\item palindromes of odd length with central letter $1$.
\end{enumerate}
Thus, we consider a three-letters alphabet $T = \{\a,\e,\o\}$ and we define a map $\Type : \A^* \rightarrow T^*$ by $\Type(\varepsilon) = \e$ and, for $w \in \A^*$ and $\alpha \in \A$,
$$\Type(w\alpha) = \Type(w) \cdot \begin{cases}
\e, & \mbox{if $\ipal(w\alpha)$ is an even palindrome and;} \\
\a, & \mbox{if $\ipal(w\alpha)$ is a palindrome with central letter $1$;} \\
\o, & \mbox{if $\ipal(w\alpha)$ is a palindrome with central letter $0$.}
\end{cases}$$
We call $\Type(w)$ the \emph{palindrome type word} of $w$.
\begin{example}
One may verify that the Fibonacci word $\bfi$ satisfies $\Type(\bfi) = (\e\o\a)^\omega$.
\end{example}
The next proposition establishes an important link between $w$ and $\Type(w)$.
\begin{proposition} \label{P:pal type}
We have $\Type(0) = \e\o$ and $\Type(1) = \e\a$. Let $c, d \in \A$, $u \in \A^*$ and $\Type(uc) = x\alpha\beta$ for $x \in T^*$, $\alpha,\beta \in T$. Then the two last letters of $\Type(ucd)$ are distinct and
\begin{equation} \label{E:type}
\Type(ucd) = \begin{cases}
x\alpha\beta\alpha, & \mbox{if $c = d$;} \\
x\alpha\beta\gamma, & \mbox{if $c \neq d$.}
\end{cases}
\end{equation}
where $\gamma$ is the unique letter distinct from $\alpha$ and $\beta$.
\end{proposition}
\begin{proof}
The proof is done by induction on $|u|$. Clearly, the two palindrome prefixes of $\ipal(0) = 0$ are $\varepsilon, 0$, so that $\Type(0) = \e\o$. Similarly, one notices that $\Type(1) = \e\a$. Now, there are three cases to consider:
\begin{enumerate}[(i)]
\item Suppose that $c = d$. Then $\ipal(ucd) = \ipal(uc)\ipal(u)^{-1}\ipal(uc)$ by Proposition \ref{P:justin}. Therefore, $|\ipal(ucd)|$ and $|\ipal(u)|$ have same parity. If they are even, then $\Type(ucd)$ ends with $\e\beta\e$. If they are odd, they share the same central letter, so that $\Type(ucd)$ ends with $\alpha\beta\alpha$, where $\alpha \in \{\o,\a\}$. In both cases, by the induction hypothesis, the two last letters of $\Type(uc)$ are distinct, and so are the two last letters of $\Type(ucd)$.
\item Suppose that $c \neq d$ and $|uc|_d = 0$. Then $\ipal(ucd) = \ipal(uc)d\ipal(uc)$ by Proposition \ref{P:justin}. In particular $|\ipal(ucd)|$ is odd. Moreover, $uc$ is the power of a letter, which means that the previous palindrome prefixes are all powers of the same letter. Hence, one of the two previous palindrome prefixes is of odd length while the other is of even length, so that $\alpha \neq \beta$. Finally, $|\ipal(ucd)|$ is of odd length and has central letter different from all shorter odd palindrome prefixes. Hence, $\gamma \neq \alpha,\beta$, as desired.
\item Suppose that $c \neq d$ and $|uc|_d > 0$. Write $u = u_1dc^k$ with $u_1 \in \A^*$ and $k$ a non negative integer, so that $ucd = u_1dc^{k+1}d$. Again by Proposition \ref{P:justin}, one deduces $\ipal(ucd) = \ipal(uc)\ipal(u_1)^{-1}\ipal(uc)$, which means that $\ipal(ucd)$ and $\ipal(u_1)$ share the same parity and, if odd, the same central letter. Hence, it suffices to show that $\Type(u_1)$ ends with $\gamma$.
It follows from (i) that $\Type(uc)$ ends with $(\alpha\beta)^{k/2}$ if $k$ is even and with $\beta(\alpha\beta)^{k/2}$ otherwise. Moreover, by the induction hypothesis $\Type(uc)$ ends with $\gamma(\alpha\beta)^{k/2}$ if $k$ is even, or with $\gamma\beta(\alpha\beta)^{k/2}$ otherwise. In both cases, this implies that $\Type(u_1)$ ends with $\gamma$. But $\ipal(u_1)$ and $\ipal(ucd)$ are of the same type, so that $\Type(u_1)$ ends with $\gamma$, as desired. In particular, $\beta$ and $\gamma$ are distinct.
\end{enumerate}
The values of $\Type(uc)$ are represented in Figure \ref{F:pal type tree} for short words.
\end{proof}
\begin{figure}
\centering
\includegraphics{tikz-palindrome-type-tree}
\caption{Representation of Proposition \ref{P:pal type} by a tree, describing the possible palindrome type sequences for any finite binary word. Each node is a couple $(\ipal(w),\Type(w))$, where $w$ is a binary word. For instance, if $w = 010$, then its corresponding node is $(\underline{0}\,\underline{1}\,0\,\underline{0}\,1\,0, \e\o\a\e)$ and one verifies that the palindrome prefixes $\varepsilon$, $0$, $010$ and $010010$ of $\ipal(w)$ are indeed of types $\e$, $\o$, $\a$ and $\e$.}
\label{F:pal type tree}
\end{figure}
\begin{example} \label{E:prefixes}
Consider once again the Fibonacci word on $\{0,1\}$
$$\bfi = 0100101001001010010\cdots$$
and the Rote word $\br$ starting with $0$ such that $\Delta(\br) = \bfi$
$$\br = 00111001110001100011\cdots$$
By inspection, we may enumerate the palindromic prefixes of $\bfi$, which are in bijections with the palindromic and antipalindromic prefixes of $\br$, except for the empty word prefix of $\br$
\begin{center} \begin{tabular}{>{$}l{$}l i$. This is impossible since the prefix $q$ of $\br$ such that $\Delta(q) = p_i$ is a pseudopalindrome, again by Lemma \ref{L:delta}(ii), i.e. there would exist a pseudopalindrome $q$ having length between $|q_i|$ and $|q_{i+1}|$.
\end{proof}
Therefore, standard complementary-symmetric words are generalized pseudostandard words.
\begin{lemma} \label{L:piqi}
Let $\bs$ be a standard Sturmian word directed by some infinite binary sequence $\bx$ and $\br$ be the standard Rote words starting with $0$ such that $\Delta(\br) = \bs$. Then there exists an infinite bi-sequence $(\bTheta,\bw)$ such that $\br = \ipal_\bTheta(\bw)$, i.e. $\br$ is a generalized pseudostandard word.
\end{lemma}
\begin{proof}
As in Lemma \ref{L:pal antipal}, let $p_0 = \varepsilon$, $p_1$, $p_2$, $p_3$, $\ldots$ be the palindrome prefixes of $\bs$ and $q_0 = \varepsilon$, $q_1$, $q_2$, $q_3$, $\ldots$, be the list of pseudopalindrome prefixes of $\br$ enumerated with increasing length. For $i = 0,1,2,\ldots$, let $w_{i+1} = \br\Class{|q_i|+1}$ , i.e. $w_{i+1}$ is the letter following the pseudopalindrome prefix $q_i$. Finally, let
$$\V_i = \begin{cases}
R, & \mbox{if $q_i$ is an $R$-palindrome;} \\
E, & \mbox{if $q_i$ is an $E$-palindrome.}
\end{cases}$$
We show that $(\bTheta,\bw) = (\V_1\V_2\V_3\cdots, w_1w_2w_3\cdots)$ is a directive bi-sequence of $\br$. Let $\psi_i = \psi_{\V_1\V_2\cdots\V_i}(w_1w_2\cdots w_i)$ for $i = 1,2,\ldots$.
It suffices to prove that $q_{i+1} = \psi_{i+1}$ for $i = 1,2,\ldots$. Arguing by contradiction, suppose that $i$ is the smallest integer such that $q_i = \ipal_i$ but $q_{i+1} \neq \ipal_{i+1}$. Clearly, $q_{i+1}$ and $\psi_{i+1}$ are both $\V_{i+1}$-palindromes and share the prefix $q_iw_{i+1}$. Therefore, $|\ipal_{i+1}| < |q_{i+1}|$, otherwise $\psi_{i+1}$ would not be the shortest $\V_{i+1}$-palindrome having $q_iw_{i+1} = \psi_iw_{i+1}$. By Lemma \ref{L:piqi}, we have $\Delta(q_{i+1}) = p_i$ which implies that $\Delta(q_iw_{i+1}) = p_{i-1}a$, with $a \in \A$, is a prefix of both $p_i$ and $\Delta(\psi_{i+1})$. But $\Delta(\psi_{i+1})$ is a palindrome and $|\Delta(\psi_{i+1})| < |p_i|$, contradicting the fact that $p_i$ is the shortest palindrome having prefix $p_{i-1}a$.
\end{proof}
\begin{figure}[ht]
\centering
\includegraphics{tikz-transducer}
\caption{Transducer computing the directive bi-sequence of a Rote standard word $\br$ starting with $0$ from the directive sequence of a Sturmian standard word $\bs$ such that $\Delta(\br) = \bs$.}
\label{F:transducer}
\end{figure}
Consider the transducer $\Transducer$ on $\{0,1\} \times (\{R,E\} \times \{0,1\})$ represented in Figure \ref{F:transducer}. The next lemma states some observations about $\Transducer$.
\begin{lemma} \label{L:transducer}
Let $x = x_1x_2\cdots x_n$ be an input word of length $n \geq 1$ of $\Transducer$ and
$$(\V_1\V_2\cdots\V_n,y_1y_2\cdots y_n)$$
be its associated output word. Let $q=ab\alpha\neq i,q'=cd\beta$ be the two last states visited when reading $x$. Then $c = b$, $\beta = x_n$ and $\Type(x)$ ends with $cd$.
\end{lemma}
\begin{proof}
The proof is done by induction on $n$. For $n = 1$, we have $q = \o\e 0$. There are two cases to consider according to the value of $x_1$. If $x_1 = 0$, then $q' = \e\o0$ so that $c = b = \e$, $\beta = x_1 = 0$ and $\Type(x) = \Type(0) = \e\o$. On the other hand, if $x_1 = 1$, then $q' = \e\a 1$ so that $c = b = \e$, $\beta = x_1 = 1$ and $\Type(x) = \Type(1) = \e\a$.
Consider now the general case. By inspection of $\Transducer$, one observes that $c = b$ and $\beta = x_i$ for any transition, except the one starting with the initial state $i$. The fact that $\Type(x)$ ends with $cd$ follows from inspection of $\Transducer$ and Proposition \ref{P:pal type}.
\end{proof}
We are now ready to show the main theorem of this section. The key idea is to observe that one may derive the directive bi-sequence from the directive sequence of the Sturmian word by looking at the palindrome types ($\a$, $\e$ or $\o$) at each step.
\begin{theorem}
Let $\bx$ be an infinite binary sequence directing some Sturmian word $\bs$ and let $\br$ be the Rote word starting with $0$ and such that $\Delta(\br) = \bs$. Then the output word $(\Theta,\by)$ obtained from $\bx$ in the transducer $\Transducer$ is a directive bi-sequence of $\br$.
\end{theorem}
\begin{proof}
We know from Lemma \ref{L:pal antipal} that the palindrome prefixes of $\bs$ and the pseudopalindromic prefixes of $\br$ are in 1-to-1 correspondence. It only remains to describe the letters and type of pseudopalindromes involved in the iterated pseudopalindromic closure.
For every positive integer $n$, let $x = x_1x_2\cdots x_n$ and $(\Theta,\by) = (\V_1\V_2\cdots \V_n,y_1y_2\cdots y_n)$. Moreover, let $q = ab\alpha$ and $q' = cd\beta$ be the two last states visited when reading $x$. We prove by induction on $n$ that $(\Theta,\by)$ is the output word obtained from $\Transducer$ by reading $x$. This is clear for $n = 1$.
For the general case, we know from Lemma \ref{L:transducer} that $q'$ remembers the two last palindrome type encountered in $\ipal(x)$, i.e. $\Type(x)$ ends with $ab$. Moreover, $c = b$ and $\beta = x_n$. Next, observe that since $\ipal(x)$ is a palindrome of type $c = b$, we deduce by inspection of $\Transducer$ that $\ipal_{\V_1\V_2\cdots\V_n}(y_1y_2\cdots y_n)$ is a $R$-palindrome if $c = b \in \{\o,\e\}$ and is a $E$-palindrome if $c = b = \a$. Finally, one verifies in $\Transducer$ that $y_{n+1} = x_n$ if $c = b \in \{\o,\e\}$ and $y_{n+1} = (x_n + 1) \bmod 2$ if $c = b = \a$.
%Combining these observations, Proposition \ref{P:pal type}, Lemma \ref{L:pal antipal} and inspection of the transducer $\Transducer$ together with Lemma \ref{L:transducer} yields the result.
%First, we show by induction on $n \geq 1$ that $\e\Type(x)$ ends with $ab$. If $n = 1$, then
%$$(x,\Type(x),y,q) \in \{(0;\o;(RR,00),\e\o 0),(1;\a;(RE,01),\e\a 1)\},$$
%as desired. Now assume that this holds for any input word of length less than $n$. Let $q' = cd\beta$, where $c,d \in \{\a,\o,\e\}$ and $\beta \in \{0,1\}$ be the last state visited before $q$ when reading $x$. By the induction hypothesis and in virtue of Proposition \ref{P:pal type}, one concludes that $c = b$, $\beta = x_n$ and $d$ is the last letter of $\Type(x)$ which concludes this part.
% and Lemma \ref{L:pal antipal}
%Let $d_s$ be a finite word of length $n$ on $\{0,1\}$ directing the standard Sturmian prefix $s$. We show by induction on $n$ that the output obtained from $d_s$ in the transducer $\Transducer$ is exactly the prefix $d_r$ of the directive bi-sequence $\bd_\br$ of length $n + 1$. Since the transducer $\Transducer$ is deterministic and the transition function is well-define from every state for both values $0$ and $1$, let $p = (i,d_s,d_r,q)$ be the path of length $n + 1$ obtained by reading $d_s$.
%
%If $n = 0$, then $q = \a\o1$, $d_s = \varepsilon$ and $d_r = (R,0)$, so that $d_r$ is indeed the prefix of length $1$ of $\bd_\br$, since $\br$ starts with $0$ by definition.
%
%Consider now the general case. Let $p' = (i,d'_s,d'_r,q')$ be the path of length $n$ such that $d'_s$ is the prefix of length $n - 1$ of $d_s$, $d'_r$ is the prefix of length $n$ of $d_r$ and $q'$ is the last state visited before $q$ with respect in the path $p$. Finally, let $(\V,\alpha)$ be the last symbol of $d_r$.
%
%It follows from Lemma \ref{L:prefixes} that $\V$ is exactly given by the palindrome type of $\ipal(d_s)$
%Follows from Proposition \ref{P:pal type}. (AJOUTER DES DETAILS)
\end{proof}
\begin{example}
Let $x = 001101$. When reading $x$ in $\Transducer$, one visits states $i$, $\o\e 0 $, $\e\o 0 $, $\o\e 0$, $\e\a 1$, $\a\e 1$, $\e\o 0$ and $\o\a 1$ and obtains the output word
$$(\V,y) = (RRRERRE,0001001).$$
Moreover,
\begin{eqnarray*}
\ipal(x) & = & \underline{0}\,\underline{0}\,\underline{1}00\underline{1}00\underline{0}100100\underline{1}000100100 \\
\ipal_{\V}(y) & = & \underline{0}\,\underline{0}\,\underline{0}\underdot{$1$}11\underline{0}00\underline{0}111000\underdot{$1$}111000111
\end{eqnarray*}
and we indeed have $\Delta(\ipal_\V(y)) = \ipal(x)$.
\end{example}
As a consequence, we have a complete characterization of standard Rote words obtained from iterated pseudopalindromic closure.
\begin{corollary}
Let $(\Theta,w)$ be a directive bi-sequence. Then $\ipal_{\Theta}(w)$ is a standard Rote word if and only if no factor of length $2$ of $(\Theta, w)$ is in the set
$$D = \{(EE,ab) \mid a,b \in \A\} \cup \{(RR,a\bar{a}) \mid a \in \A\} \cup \{(RE,aa) \mid a \in \A\}.$$
Moreover, $(\Theta,w)$ is normalized.
\end{corollary}
\begin{proof}
If $\psi_\Theta(w)$ is a standard Rote word, then it must be obtained from $\Transducer$. But every path of length $2$ in $\Transducer$ yields an output word in
\begin{center} \begin{tabular}{*{3}{>{$}r{$}l