<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">\documentclass[12pt,reqno]{article}

\usepackage[usenames]{color}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amsfonts}
\usepackage{amscd}
\usepackage{graphicx}

\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}
\usepackage{latexsym}
\usepackage{epsf}
\usepackage{breakurl}

\setlength{\textwidth}{6.5in}
\setlength{\oddsidemargin}{.1in}
\setlength{\evensidemargin}{.1in}
\setlength{\topmargin}{-.1in}
\setlength{\textheight}{8.4in}

\newcommand{\seqnum}[1]{\href{https://oeis.org/#1}{\rm \underline{#1}}}

\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}
\newtheorem{question}[theorem]{Question}

\begin{center}
\vskip 1cm{\LARGE\bf 
Squarefree Extensions of Words
}
\vskip 1cm
\large
Jaros\l aw Grytczuk and Hubert Kordulewski\\
Faculty of Mathematics and Information Science\\
Warsaw University of Technology\\
00-662 Warsaw \\ Poland \\
\href{mailto:j.grytczuk@mini.pw.edu.pl}{\tt j.grytczuk@mini.pw.edu.pl}\\
\href{mailto:apostatajulian@gmail.com}{\tt apostatajulian@gmail.com}\\
\ \\
Bart\l omiej Pawlik\\
Institute of Mathematics\\
Silesian University of Technology\\
44-100 Gliwice \\
Poland \\
\href{mailto:bpawlik@polsl.pl}{\tt bpawlik@polsl.pl}\\
\end{center}

\vskip .2 in
	
\begin{abstract}
		A word is \emph{squarefree} if it does not contain nonempty factors of the form $XX$. In 1906 Thue proved that there exist arbitrarily long squarefree words over a $3$-letter alphabet. It was proved recently that among these words there are infinitely many \emph{extremal} ones, that is, having a square in every single-letter extension.
		
		We study diverse problems concerning extensions of words preserving the property of avoiding squares. Our main motivation is the conjecture stating that there are no extremal words over a $4$-letter alphabet. We also investigate a natural recursive procedure of generating squarefree words by a single-letter rightmost extension. We present the results of computer experiments supporting a supposition that this procedure gives an infinite squarefree word over any alphabet of size at least three.
\end{abstract}
	
	\section{Introduction}
	
	A \emph{square} is a finite nonempty word of the form $XX$. For instance, the word $\mathtt{hotshots}$ is a~square with $X=\mathtt{hots}$. A word $W$ \emph{contains} a square if it can be written as $W=UXXV$ for some words $U,V$, and a nonempty word $X$. A word is \emph{squarefree} if it does not contain any squares. For instance, the word $\mathtt{repetition}$ contains the square $\mathtt{titi}$, while $\mathtt{recreation}$ is squarefree.
	
	It is easy to check that there are no binary squarefree words of length greater than $3$. However, there exist ternary squarefree words of any length, as proved by Thue \cite{Thue,BerstelThue}. This result is the starting point of combinatorics on words, a wide discipline with many exciting problems, deep results, and important applications \cite{AlloucheShallit,BeanEM,BerstelPerrin,Currie TCS,Lothaire,LothaireAlgebraic}.
	
	In this paper we study problems concerning \emph{squarefree extensions} of words, a concept introduced recently by Grytczuk, Kordulewski, and Niewiadomski \cite{GrytczukKN}. Let $\mathbb A$ be a fixed alphabet and let $W$ be a finite word over $\mathbb A$. The~set of all finite words over $\mathbb{A}$ is denoted by~$\mathbb{A}^*$. An \emph{extension} of $W$ over $\mathbb{A}$ is any word of the form $W'\mathtt{x}W''$, where $\mathtt{x}$ is any letter from~$\mathbb A$ and $W=W'W''$ (words $W'$ and $W''$ are possibly empty). For instance, the word $\mathtt{bear}$ is an~extension of the word $\mathtt{bar}$ by inserting the~letter $\mathtt{e}$ between letters $\mathtt{b}$ and $\mathtt{a}$. A~squarefree word $W\in\mathbb{A}^*$ is {\it maximal} if for every $\mathtt{x}\in\mathbb{A}$ the extensions $\mathtt{x}W$ and $W\mathtt{x}$ contain a square. A~squarefree word $W$ is called \emph{extremal} over $\mathbb{A}$ if there is no squarefree extension of $W$. For instance, the word $$H=\mathtt {1231213231232123121323123}$$is the shortest extremal word over the alphabet $\{\mathtt{1,2,3}\}$. This means that inserting any letter from the alphabet $\{\mathtt{1,2,3}\}$ at any position in the word $H$, including the beginning as well as the end of $H$, results with a square.
	
	A natural intuition is that extremal words should be rare or even should have bounded length. However, in the case of a $3$-letter alphabet, this intuition turned out to be faulty.
	
	\begin{theorem}[Grytczuk, Kordulewski, and Niewiadomski \cite{GrytczukKN}]\label{TheoremExtremal3Words}
		There exist infinitely many extremal squarefree words over a $3$-letter alphabet.
	\end{theorem}
	
	The proof of this theorem is by a recursive construction whose validity is partially based on computer verification. Mol and Rampersad \cite{MolRamp} determined all positive integers $k$ for which there exist extremal ternary words of length exactly $k$. In particular, they proved that for every $k\geq87$ there exists an extremal ternary word of length $k$.
	
	One may naturally wonder what the case is for larger alphabets. Actually, we do not know if there are any extremal words over a $4$-letter alphabet. Computational experiments prompted us to state the following conjecture.
	
	\begin{conjecture}[Grytczuk, Kordulewski, and Niewiadomski \cite{GrytczukKN}]\label{Conjecture4Extremal}
		Every squarefree word over a $4$-letter alphabet can be extended to a squarefree word.
	\end{conjecture}
	
	A weaker version of this statement was recently confirmed by Hong and Zhang \cite{HongZhang} who proved that there are no extremal squarefree words over an alphabet of size $15$.
	
	In the forthcoming sections we shall present some results and effects of computer experiments inspired by Conjecture \ref{Conjecture4Extremal}.
	
	\section{Nonchalant words}
	\subsection{The main conjectures}
	
	The problem of extremal squarefree words is connected to the following recursive construction.
	
	Given a fixed ordered alphabet $\mathbb A$, we start with the first letter from $\mathbb A$ and continue by inserting the earliest possible letter at the rightmost position of the previous word so that the~new word is squarefree. For instance, for the alphabet $\{\mathtt{1,2,3}\}$ this greedy procedure starts with the following sequence of squarefree words: $$\mathtt {1, 12, 121, 1213, 12131, 121312, 1213121, 12131231}.$$ The last word was obtained by inserting $\mathtt 3$ at the penultimate position of the previous word.
	
	We conjecture that the aforementioned procedure never stops. To state it formally, let us define recursively a sequence of \emph{nonchalant words} $N_i$ over the alphabet $\mathbb A_n=\{\mathtt{1,2,\ldots,n}\}$ by putting $N_1=\mathtt 1$, and letting $N_{i+1}=N_i'\mathtt{x}N_i''$ to be a squarefree extension of $N_i$ such that in the first instance $N_i''$ is the shortest possible suffix of $N_i$ and then $\mathtt{x}\in \mathbb A_n$ is the earliest possible letter.
	
	\begin{conjecture}[Grytczuk, Kordulewski, and Niewiadomski \cite{GrytczukKN}]\label{ConjectureNonchalant}
		The sequence of nonchalant words over $\mathbb A_n$ is infinite for every $n\geq 3$.
	\end{conjecture}
	
	In other words, we believe that the nonchalant algorithm never produces an extremal word. The results of computer experiments support this conjecture. For instance, for $n=3$ a~nonchalant word of length $10000$ was obtained. Moreover, the new letter was never inserted more than $20$ positions from the end of the previous word (Appendix \ref{apA} contains more details). Therefore the following conjecture also seems plausible.
	
	\begin{conjecture}[Grytczuk, Kordulewski, and Niewiadomski \cite{GrytczukKN}]\label{ConjectureNonchalantInfinite}
		The sequence of nonchalant words over $\mathbb A_n$ converges to an infinite word $\mathcal{N}_n$ for every $n\geq 3$.
	\end{conjecture}
	
	Here are the first $70$ terms of the presumably infinite limit word for $n=3$: $$\mathcal{N}_3=\mathtt{1213123132123121312313231213123212312131231321231213123212312132123132...}$$
	
	\subsection{Playing with initial words}
	The above version of the nonchalant algorithm with the two corresponding conjectures were stated by Grytczuk, Kordulewski, and Niewiadomski~\cite{GrytczukKN}. Our numerical experiments led us to introduce a more general approach.
	
	Starting with the word $\mathtt{1}$ is the most natural approach, because such word can be considered as a result of performing the nonchalant procedure on an empty word. Let us consider starting the nonchalant algorithm with a different initial word. Namely, let the~nonchalant word $N_1$ be some squarefree word over a fixed alphabet. From now on $N_1$ will be called the~{\it initial word} of the nonchalant algorithm. The results of testing $10000$ iterations of the~nonchalant algorithm over the ternary alphabet for various initial words are presented in Table \ref{nai}. The first column contains the initial words, while the other columns show how many times the procedure moved back by the given number of positions (the column initialized by $0$ shows how many times a new letter is inserted at the rightmost position, by $1$ - at the~penultimate position, etc.). These experimental results suggest that sequences of nonchalant words still bear many similarities. For example, for each considered initial word, a~new letter is inserted $33$ to $36$ times right before the suffix of length $4$. More data from our experiments is presented in Appendix~\ref{apA}.
	
	\begin{table}\centering
		\scalebox{0.9}{ \begin{tabular}{|c||ccccccccccc|}\hline
				$N_1$&amp;0&amp;1&amp;2&amp;3&amp;4&amp;7&amp;9&amp;12&amp;14&amp;15&amp;20\\ \hline
				$\mathtt{1}$&amp;9457&amp;310&amp;184&amp;1&amp;33&amp;11&amp;1&amp;0&amp;0&amp;1&amp;2\\
				$\mathtt{2}$&amp;9457&amp;309&amp;186&amp;1&amp;33&amp;11&amp;0&amp;0&amp;1&amp;0&amp;2\\
				$\mathtt{3}$&amp;9457&amp;307&amp;185&amp;0&amp;34&amp;13&amp;1&amp;0&amp;1&amp;0&amp;2\\
				$\mathtt{13}$&amp;9454&amp;310&amp;185&amp;0&amp;34&amp;13&amp;1&amp;0&amp;1&amp;0&amp;2\\
				$\mathtt{23}$&amp;9458&amp;307&amp;185&amp;1&amp;34&amp;11&amp;0&amp;1&amp;1&amp;0&amp;2\\
				$\mathtt{32}$&amp;9458&amp;309&amp;185&amp;1&amp;33&amp;11&amp;0&amp;0&amp;1&amp;0&amp;2\\
				$\mathtt{3213}$&amp;9455&amp;309&amp;185&amp;0&amp;34&amp;13&amp;1&amp;0&amp;1&amp;0&amp;2\\
				$\mathtt{2313213}$&amp;9455&amp;309&amp;185&amp;0&amp;34&amp;13&amp;1&amp;0&amp;1&amp;0&amp;2\\
				$\mathtt{32132313213}$&amp;9455&amp;309&amp;185&amp;0&amp;34&amp;13&amp;1&amp;0&amp;1&amp;0&amp;2\\
				\hline
		\end{tabular}}
		\vskip0.5cm
		\caption{Number of steps in which a new letter was inserted before the~suffix of given length (10000 iterations).}\label{nai}
	\end{table}
	
	
	\subsection{Nonchalant words over four letters}
	In the case of a $4$-letter alphabet the situation looks even more exciting. In our experiments for the initial word $\mathtt{1}$ the~procedure never moved back by more than one position. In fact, through 50000 iterations the word was extended on the penultimate position only $33$ times (in other cases, the word was extended at the last position).
	
	The squarefree word $W$ over given alphabet $\mathbb{A}$ is \emph{almost extremal} if for all nonempty words $W'$ and $W''$ such that $W=W'W''$, the word $W'\mathtt{x}W''$ contains a square for every $\mathtt{x}\in\mathbb{A}$.  Given that, let us consider another variant of the nonchalant algorithm. Namely, let $\mathtt{12}$ be the initial word of the nonchalant algorithm over $\mathbb{A}_4$ and let us allow for word extensions only at internal positions (extension of a word at the end or at the beginning is forbidden). This procedure starts with the following sequence of squarefree words: $$\mathtt {12, 132, 1312, 13142, 131412, 1314132, 13141312, 131413212}.$$
	The last word was obtained by inserting $\mathtt{2}$ right before the suffix $\mathtt{12}$. Through $50000$ iterations, the~procedure never moved back by more than two positions (in this case the number of iterations in which procedure moved back by two positions is approximately equal to 10\% of all iterations).
	
	\subsection{Extensions close to the ends}
	
	The above experiments led us to the following two suppositions: (1) every quaternary squarefree word can be extended at the end or at the penultimate position, and (2) every quaternary squarefree word (of length at least 3) can be extended at one of the two rightmost internal positions. However, both suppositions turned out not to be true.
	
	\begin{proposition}\label{Proposition4Non-entendable} There exists a quaternary squarefree word $S$ which cannot be extended, neither at the last, nor at the penultimate position. 
	\end{proposition}
	\begin{proof} 
		Let $A = \mathtt{1213121}$ and $B = \mathtt{121312}$. Next, let $Y = \mathtt{3}B\mathtt{4}$ and $Z = \mathtt{41}YA\mathtt{4}YB\mathtt{341}$. Finally, put $S=ZYA\mathtt{4}YA$, which gives the word $$S=\mathtt{4231213124121312143121312412131231423121312412131214312131241213121}.$$
		It can be verified (by a computer) that $S$ is indeed squarefree. Now, $A\mathtt{x}$ contains a square for every $\mathtt{x}\in \{\mathtt{1,2,3}\}$. Also $S\mathtt{4}=Z(YA\mathtt{4})(YA\mathtt{4})$ is not squarefree. For the penultimate position it suffices to check only letters $\mathtt{3}$ and $\mathtt{4}$. So, the suffix $A$ in $S$ will turn to one of the~forms, $B\mathtt{31}$ or $B\mathtt{41}$, respectively. In the latter case we get the word
		\begin{equation}
			ZYA\mathtt{4}YB\mathtt{41}=ZYA\mathtt{4}\mathtt{3}(B\mathtt{4})(B\mathtt{4})\mathtt{1}.
		\end{equation}
		In the former case we obtain
		\begin{equation}
			ZYA\mathtt{4}YB\mathtt{31}=(\mathtt{41}YA\mathtt{4}YB\mathtt{3})(\mathtt{41}YA\mathtt{4}YB\mathtt{3})\mathtt{1}.
		\end{equation}
		The assertion is proved.
	\end{proof}
	
	The proof of Proposition \ref{Proposition4Non-entendable} could be verified entirely with the use of a computer. However, we decided to include some explanations to give a better insight into the structure of the word $S$.
	
	In the case of the second supposition, we will present a more general result. We use the well known \emph{Zimin words} $Z_n$, defined recursively over an infinite alphabet of variables $\{\mathtt{1,2,3,\ldots}\}$ by $Z_1=\mathtt{1}$ and $Z_{n}=Z_{n-1}\mathtt{n}Z_{n-1}$ for every $n\geq2$. Let us notice that the~Zimin word $Z_n$ is maximal over the alphabet $\{\mathtt{1,2,\ldots,n}\}$. In the following proposition, the construction in the~proof is more clear when we analyze the \emph{leftmost} internal positions instead of the~\emph{rightmost} ones. Obviously, the result holds in the latter case as well.
	
	\begin{theorem}\label{TheoremZimin}
		For all natural numbers $n$ and $t$, with $n\geq4$ and $1\leq t&lt;n$, there exists a~squarefree word $W$ over the alphabet $\mathbb{A}_n$, which cannot be extended at any of its $t$ leftmost internal positions. 
	\end{theorem}
	
	\begin{proof}
		Let $A=\mathtt{12\cdots n}$ be a word over alphabet $\mathbb{A}_n$. This word has exactly  $N=(n-1)(n-2)$ distinct internal squarefree extensions. Let $Z_{N}$ be the Zimin word over the~alphabet~$\mathbb{A}_{N}$. Consider the homomorphism
		$\varphi:\mathbb{A}_{N}^*\to\mathbb{A}_n^*$
		defined so that the image of every letter in $\mathbb{A}_{N}$ is a unique internal extension of the word $A$ assigned in a natural way as follows:
		\begin{align*}
			\varphi(\mathtt{1})&amp;=\mathtt{1\mathbf{3}23\cdots n},\\
			\varphi(\mathtt{2})&amp;=\mathtt{1\mathbf{4}23\cdots n},\\
			&amp;\vdots\\
			\varphi(\mathtt{n-2})&amp;=\mathtt{1\mathbf{n}23\cdots n},\\
			\varphi(\mathtt{n-1})&amp;=\mathtt{12\mathbf{1}3\cdots n},\\
			\varphi(\mathtt{n})&amp;=\mathtt{12\mathbf{4}3\cdots n},\\
			&amp;\vdots\\
			\varphi(\mathtt{N})&amp;=\mathtt{123\cdots (n-1)\mathbf{(n-2)}n}.\\
		\end{align*}
		For every $\mathtt{i}\in \mathbb{A}_N$ the word $\varphi(\mathtt{i})$ has a unique factor $\mathtt{je(j+1)}$, where $\mathtt{e}$ is the inserted letter that extended the word $A$. Moreover, if $\mathtt{j}\neq\mathtt{1}$, then $\varphi(\mathtt{i})$ has also a unique factor $\mathtt{(j-1)je}$ and if $\mathtt{j+1}\neq\mathtt{n}$, then $\varphi(\mathtt{i})$ has a unique factor $\mathtt{e(j+1)(j+2)}$.
		
		Let us assume that the word $\varphi(Z_{N})$ contains a square $XX$. It is not hard to verify that for any $\mathtt{x,y}\in\mathbb{A}_{N}\backslash\{\mathtt{1}\}$, $\mathtt{x}\neq \mathtt{y}$, the words $\varphi(\mathtt{1x})$, $\varphi(\mathtt{x1})$, $\varphi(\mathtt{1x1})$, $\varphi(\mathtt{x1y})$, $\varphi(\mathtt{1x1y})$ and $\varphi(\mathtt{x1y1})$ are squarefree. It follows that the length of $XX$ has to be greater than $3n+2$ and $XX$ has to contain a block $\varphi(\mathtt{u})$ for possibly the largest $\mathtt{u}\neq\mathtt{1}$. Moreover, this block is unique in $XX$ since every factor of a Zimin word contains a unique single letter of the greatest value (in that factor). In consequence, the square $XX$ contains a unique factor $\mathtt{je(j+1)}$, which must occupy the~middle of the word $XX$. This fact gives us two possible cases for the form of the~word~$X$, namely
		$$X=\mathtt{(j+1)}Y\mathtt{je}\ \mbox{ or }\ X=\mathtt{e(j+1)}Y\mathtt{j},$$
		for some nonempty word $Y$. We may also assume that $\mathtt{j}=1$ or $\mathtt{j+1}=\mathtt{n}$, since otherwise one of the parts of the square $XX$ would have to contain another unique factor, which is clearly impossible.
		
		Let us consider the case $\mathtt{j}=\mathtt{1}$. Then we have $$\varphi(\mathtt{u})=\mathtt{1e23\cdots n}.$$ To avoid a second unique factor, the word $X$ has to be of the form
		$$X=\mathtt{e23\cdots n}B\mathtt{1}$$
		for some nonempty word $B$, which gives
		$$XX=\mathtt{e23\cdots n}B\varphi(\mathtt{u})B\mathtt{1}.$$
		Let us notice that $XX$ is a factor of the word $$\varphi(\mathtt{u})B\varphi(\mathtt{u})B\mathtt{1},$$
		since the only word of form $\varphi(\mathtt{y})$ with the suffix $\mathtt{e23\cdots (n-1)n}$ is $\varphi(\mathtt{u})$. Between any two occurrences of the same letter in the Zimin word there is a letter of greater value, so the~word~$XX$ contains a factor $\varphi(\mathtt{z})$ for some $\mathtt{z}$ greater than $\mathtt{u}$, and this fact creates a~contradiction.
		
		The reasoning in the case $\mathtt{j+1}=\mathtt{n}$ goes analogously.
		
		Thus we have proved that the word $\varphi(Z_{N})$ is squarefree. In a similar way one may prove that the word $A\varphi(Z_{N})$ is also squarefree. Inserting a single letter at one of the internal positions of the~prefix~$A$ in the word $A\varphi(Z_{N})$ generates a square (by the fact that Zimin words are maximal).
	\end{proof}
	
	The above results lead naturally to the following question.
	
	\begin{question}\label{ProblemtLastPositions}
		Is it true that there is some constant $t\geq3$ such that every quaternary squarefree word can be extended at one of its rightmost $t$ positions?
	\end{question}
	
	We can only prove that the answer is negative over a $5$-letter alphabet for sufficiently large~$t$ and provided that we omit the~very last position in the process of extension.
	
	\begin{proposition}\label{PropositionLasttInternalPositions} For every $t\geq87$ there exists a squarefree word over a $5$-letter alphabet which cannot be extended at any of its $t$ rightmost internal positions. 
	\end{proposition}
	
	\begin{proof} Let $A=\mathtt{a_1a_2\cdots a_t}$ be any extremal word of length $t$ over the alphabet $\{\mathtt{1,2,3}\}$. Consider the morphism $\alpha:\mathbb{A}_{2t-2}^*\to\mathbb{A}_5^*$ defined similarly as in the previous proof, that is, its blocks are all possible extensions of the word $A$ by the letters $\mathtt{4}$ or $\mathtt{5}$ at the internal positions of $A$. Let us denote $A_i= \mathtt{4}\alpha (\mathtt{i})\mathtt{5}$ for all $i=1,2,\ldots,2t-2$, and additionally $A_{2t-1}=\mathtt{4}A\mathtt{45}$. Now, consider the word $W$ obtained as an effect of a substitution $\mathtt{i}\to A_i$ of words $A_i$ for the corresponding letters of the Zimin word $Z_{2t-1}$. Finally, let us denote $S=\mathtt{4}A\mathtt{5}$ and let $P=WS$.
		
		We claim that the word $P$ satisfies the assertion of the proposition. Indeed, consider any extension of $P$ at any of its $t$ final internal positions. If the inserted letter is from the~alphabet~$\{\mathtt{1,2,3}\}$, then we get a square by the extremality of $A$. Otherwise, if the~inserted letter is from $\{\mathtt{4,5}\}$, then the suffix $S$ of $P$ becomes one of the words $A_i$ and we get a square by the~structure of the Zimin word $Z_{2t-1}$.
		
		It is also not hard to demonstrate that the word $P$ is indeed squarefree, by a reasoning similar to the one in the proof of Theorem \ref{TheoremZimin}.
	\end{proof}
	
	\section{The number of squarefree extensions}
	
	\subsection{The squarefree potential}
	The problem of squarefree extensions leads to some naturally defined functions on words. For instance, given a squarefree word $W$ over alphabet $\mathbb{A}$, let $\AE (W)$ and $\ae (W)$ denote\footnote{Such designation of the functions, borrowed from the Norwegian alphabet, was chosen in order to honor Axel Thue.}, respectively, the number of different squarefree extensions and the number of different \emph{internal} squarefree extensions of $W$. The quantities $\AE (W)$ and $\ae (W)$ will be called a \emph{squarefree potential} and an~\emph{internal squarefree potential} of the~word~$W$, respectively. We can rephrase some definitions in the terms of squarefree potentials: the~squarefree word $W$ is \emph{extremal} if $\AE(W)=0$, \emph{almost extremal} if $\ae(W)=0$, and \emph{maximal} if $\AE(W)=\ae(W)$.
	
	Let us notice that for every squarefree word $W$ over the alphabet $\mathbb{A}_n$, the inequality $$\AE(W)\leq\ae(W)+2(n-1)$$ holds.
	
	As we already know, $\AE(W)=0$ for infinitely many squarefree ternary words. But how large can values of this function be for words of length $n$?
	
	Let $\mathcal{S}_n$ denote the set of all finite squarefree words over the alphabet $\mathbb{A}_n$. Let $\AE_n(k)$ and $\ae_n(k)$ be the maximum values of $\AE(W)$ and $\ae(W)$ for words of length $k$ in $\mathcal{S}_n$. Clearly, $\AE_3(k)\leq k+3$ and $\ae_3(k)\leq k-1$ for all $k\geq 1$, by definition (every ternary squarefree word can be potentially extended at every internal position by just one letter, and at any of the border positions by at most two distinct letters). However, notice that the number of internal positions where such word may be extended is limited by the number of palindromic factors of the form $\mathtt{xyx}$, with $\mathtt{x},\mathtt{y}\in \mathbb{A}$. Indeed, if $W=U\mathtt{xyx}V$ is a squarefree ternary word, then it cannot be extended at the bordering positions of $\mathtt{xyx}$, unless $U$ or $V$ is the empty word. Such palindromic factors occur very often in squarefree ternary words, at least once in every factor of length $7$, which gives the following upper bound on the function $\AE_3(k)$.
	
	\begin{proposition}\label{PropositionAE_3(k)}
		For every sufficiently large $k$, we have $\AE_3(k)\leq \frac{5}{7}k+2$.
	\end{proposition}
	
	This upper bound can be easily improved by a more careful counting of palindromic factors in words of $\mathcal{S}_3$. For instance, by using structural observations made by Shur \cite{Shur}, one may improve the multiplicative constant to at least $4/7$. We omit the details since we feel that it is still far from the optimum, as suggested by Table \ref{AE3ae3}. Also, any non-trivial lower bound for $\AE_3(k)$ would be interesting.
	
	\begin{conjecture}\label{ConjectureAE_3(k)lowerbound}
		There exists a constant $\eta&gt;0$ such that $\AE_3(k)\geq \eta k$ holds for all sufficiently large $k$.
	\end{conjecture}
	
	A position in a squarefree word $W$ at which it can be extended will be called \emph{extensible}. We will also say that $W$ is \emph{extensible} at that position. Let us consider the following squarefree word $M$ of length $35$
	$$M=\mathtt{1\_213\_123\_132\_312\_321\_231\_213\_123\_132\_312\_321\_2},$$
	where the symbol ``$\_$'' stands for an extensible position in $M$. It is worth noticing that for every $k\in\{7,8,\ldots,35\}$, the prefix $M_k$ of length $k$ of the word $M$ satisfies $\ae(M_k)=\ae_3(k)$. Moreover, the internal positions at which the words $M_k$ are extensible coincide with internal extensible positions of the word $M$.
	
	\begin{table}\centering
		\scalebox{0.9}{\begin{tabular}{|c||cccccccccccccccc|}\hline
				$k$&amp;3&amp;4&amp;5&amp;6&amp;7&amp;8&amp;9&amp;10&amp;11&amp;12&amp;13&amp;14&amp;15&amp;16&amp;17&amp;18\\
				$\ae_3(k)$&amp;2&amp;3&amp;4&amp;3&amp;2&amp;3&amp;3&amp;3&amp;4&amp;4&amp;4&amp;5&amp;5&amp;5&amp;6&amp;6\\
				$\AE_3(k)$&amp;6&amp;7&amp;6&amp;6&amp;6&amp;6&amp;6&amp;6&amp;6&amp;7&amp;7&amp;7&amp;8&amp;8&amp;8&amp;9\\\hline
				$k$&amp;19&amp;20&amp;21&amp;22&amp;23&amp;24&amp;25&amp;26&amp;27&amp;28&amp;29&amp;30&amp;31&amp;32&amp;33&amp;34\\
				$\ae_3(k)$&amp;6&amp;7&amp;7&amp;7&amp;8&amp;8&amp;8&amp;9&amp;9&amp;9&amp;10&amp;10&amp;10&amp;11&amp;11&amp;11\\
				$\AE_3(k)$&amp;9&amp;9&amp;10&amp;10&amp;10&amp;11&amp;11&amp;11&amp;12&amp;12&amp;12&amp;13&amp;13&amp;13&amp;14&amp;14\\\hline
				$k$&amp;35&amp;36&amp;37&amp;38&amp;39&amp;40&amp;41&amp;42&amp;43&amp;44&amp;45&amp;46&amp;47&amp;48&amp;49&amp;50\\
				$\ae_3(k)$&amp;12&amp;11&amp;11&amp;11&amp;12&amp;12&amp;12&amp;12&amp;12&amp;13&amp;13&amp;13&amp;14&amp;14&amp;14&amp;15\\
				$\AE_3(k)$&amp;14&amp;15&amp;14&amp;15&amp;16&amp;15&amp;14&amp;15&amp;15&amp;15&amp;16&amp;16&amp;16&amp;17&amp;17&amp;17\\\hline
		\end{tabular}}
		\vskip0.5cm
		\caption{Values of the functions $\ae_3(k)$ and $\AE_3(k)$ for $k\leq50$.}\label{AE3ae3}
	\end{table}
	
	Analogously, one may consider the minimum values of the functions $\ae$ and $\AE$ for words of given length $k$. Theorem \ref{TheoremExtremal3Words} implies that over the alphabet $\{\mathtt{1,2,3}\}$ these values are equal to $0$ for infinitely many $k$. In the case of a $4$-letter alphabet, minimum values for words of small lengths seem to support Conjecture \ref{Conjecture4Extremal}.
	
	It is also interesting to look for the values of the function $\AE$ or $\ae$ for the nonchalant words $N_i$. For instance, our numerical experiments shows that in the first $1000$ iterations of the procedure, the values of $\ae(N_i)$ are ``gradually increasing'' in the sense that when the new maximal value is obtained for the~nonchalant word $N_i$, then the value of $\ae$ for the following words is never less than $\ae(N_i)-2$ (more details are presented in Tables \ref{aen} and \ref{aemax}). 
	
	\begin{table}\centering
		\scalebox{0.9}{\begin{tabular}{|c||ccccccccccccccccccc|}\hline
				$i$&amp;2&amp;3&amp;4&amp;5&amp;6&amp;7&amp;8&amp;9&amp;10&amp;11&amp;12&amp;13&amp;14&amp;15&amp;16&amp;17&amp;18&amp;19&amp;20\\
				$\ae(N_i)$&amp;1&amp;2&amp;2&amp;2&amp;2&amp;2&amp;3&amp;3&amp;3&amp;3&amp;3&amp;2&amp;2&amp;1&amp;1&amp;1&amp;2&amp;2&amp;2\\\hline
				$i$&amp;21&amp;22&amp;23&amp;24&amp;25&amp;26&amp;27&amp;28&amp;29&amp;30&amp;31&amp;32&amp;33&amp;34&amp;35&amp;36&amp;37&amp;38&amp;39\\
				$\ae(N_i)$&amp;3&amp;3&amp;3&amp;3&amp;3&amp;4&amp;4&amp;4&amp;4&amp;4&amp;4&amp;5&amp;4&amp;4&amp;4&amp;4&amp;5&amp;5&amp;5\\\hline
		\end{tabular}}
		\vskip0.5cm
		\caption{Values of the function $\ae$ for nonchalant words $N_i$ for $i\leq39$.}\label{aen}
	\end{table}
	
	\begin{table}\centering
		\scalebox{0.9}{\begin{tabular}{|c||ccccccccccccccc|}\hline
				$i$&amp;2&amp;3&amp;8&amp;26&amp;32&amp;40&amp;46&amp;64&amp;79&amp;100&amp;108&amp;111&amp;117&amp;135&amp;172\\
				$\ae(N_i)$&amp;1&amp;2&amp;3&amp;4&amp;5&amp;6&amp;7&amp;8&amp;9&amp;10&amp;11&amp;12&amp;13&amp;14&amp;15\\\hline
				$i$&amp;175&amp;183&amp;189&amp;222&amp;243&amp;251&amp;254&amp;260&amp;279&amp;286&amp;314&amp;338&amp;346&amp;352&amp;370\\
				$\ae(N_i)$&amp;16&amp;17&amp;18&amp;19&amp;20&amp;21&amp;22&amp;23&amp;24&amp;25&amp;26&amp;27&amp;28&amp;29&amp;30\\\hline
				$i$&amp;385&amp;406&amp;414&amp;417&amp;423&amp;445&amp;469&amp;477&amp;489&amp;496&amp;524&amp;548&amp;556&amp;562&amp;580\\
				$\ae(N_i)$&amp;31&amp;32&amp;33&amp;34&amp;35&amp;36&amp;37&amp;38&amp;39&amp;40&amp;41&amp;42&amp;43&amp;44&amp;45\\\hline
				$i$&amp;595&amp;616&amp;624&amp;627&amp;633&amp;655&amp;687&amp;706&amp;712&amp;737&amp;740&amp;743&amp;764&amp;779&amp;800\\
				$\ae(N_i)$&amp;46&amp;47&amp;48&amp;49&amp;50&amp;51&amp;52&amp;53&amp;54&amp;55&amp;56&amp;57&amp;58&amp;59&amp;60\\\hline
				$i$&amp;808&amp;811&amp;817&amp;835&amp;850&amp;872&amp;875&amp;878&amp;881&amp;902&amp;917&amp;938&amp;967&amp;973&amp;997\\
				$\ae(N_i)$&amp;61&amp;62&amp;63&amp;64&amp;65&amp;66&amp;67&amp;68&amp;69&amp;70&amp;71&amp;72&amp;73&amp;74&amp;75\\\hline
		\end{tabular}}
		\vskip0.5cm
		\caption{Indices $i&lt;1000$ for which the nonchalant procedure gave new maximum values of $\ae(N_i)$.}\label{aemax}
	\end{table}
	
	This fact led us to the following version of Conjecture \ref{ConjectureNonchalant}.
	
	\begin{conjecture}
		If $\ae(N_1)&gt;2$ for the starting word $N_1$ of the nonchalant algorithm, then the~respective sequence of nonchalant words is infinite.
	\end{conjecture}
	
	\subsection{The squarefree potential of Zimin words}
	
	Let us consider the squarefree potential of Zimin words $Z_n$. Since Zimin words are non-extensible on the external positions, we have $\AE(Z_n)=\ae(Z_n)$. It is easy to verify that $\AE(Z_1)=\AE(Z_2)=0$ and $\AE(Z_3)=2$. Let $n\geq4$. Since $Z_{n}=Z_{n-1}\mathtt{n}Z_{n-1}$, we get that the~only extensions of $Z_n$ by the letters $\mathtt{1,2,\ldots,n-1}$ are those induced by the~prefix or suffix $Z_{n-1}$ (the letter $\mathtt{n}$ in the center of the word $Z_n$ occurs only once). Thus
	$$\AE(Z_{n})=2\cdot\AE(Z_{n-1})+t(n),$$
	where $t(n)$ stands for the number of different squarefree extensions of the word $Z_n$ by inserting the letter $\mathtt{n}$. Let us notice that the extension of $Z_n$ by the letter $\mathtt{n}$ would generate a~square if and only if we insert this letter right after the last appearance of any other letter in the prefix $Z_{n-1}\mathtt{n}$ or, analogously, right before the first appearance of any other letter in the suffix $\mathtt{n}Z_{n-1}$. Since there are $2^n-2$ internal positions in the word $Z_n$, we have $$t(n)=(2^n-2)-2(n-1).$$ This leads us to the following statement.
	
	\begin{proposition}
		Let $Z_n$ be a Zimin word over the alphabet $\mathbb{A}_n$. Then $\AE(Z_1)=\AE(Z_2)=0$, $\AE(Z_3)=2$, and
		\begin{equation}
			\AE(Z_n)=2^n-2n+2\cdot\AE(Z_{n-1}),
		\end{equation}
		for all $n\geq4$.
	\end{proposition}
	
	Before we came up with the presented formula, our computer calculations gave us the~following sequence of the squarefree potentials of Zimin words:
	$$0,0,2,12,46,144,402.$$
	Excluding the first two 0's, there is only one sequence \seqnum{A006742} in Sloane's {\it OEIS} \cite{OEIS} which is initialized by such integers. The sequence is described as {\it series for second perpendicular moment of hexagonal lattice}, which sounds rather distant from combinatorics on words. Needless to say, the next term of the {\it OEIS} sequence is equal to $1040$ and, as it turned out, the next term of our sequence is equal to $1044$. Thus, for a~brief moment, the authors became victims of the well known \emph{Strong Law of Small Numbers}.
	
	\section{Final discussion}
	
	Let us conclude the paper with some remarks and more general open problems. 
	
	First notice that one may consider extremal words and nonchalant words with respect to any \emph{avoidable pattern}. For instance, a close relative to the notion of the square is that of the~\emph{overlap}, which is a word consisting of two identical intersecting factors. Equivalently, this is any word of the form $\mathtt{x}B\mathtt{x}B\mathtt{x}$, where $\mathtt{x}$ is a single letter and $B$ is an arbitrary word. A word is \emph{overlap-free} if none of its factors is an overlap. Such word is called \emph{extremal} (over a fixed alphabet) if any of its extensions (by a single letter) contains an overlap.
	
	A classical result of Thue \cite{Thue2} asserts that there exist arbitrarily long overlap-free binary words. Recently, Mol, Rampersad, and Shallit \cite{MolRS} proved that among them there are infinitely many extremal ones. Moreover, they determined exactly the set of possible lengths of such extremal overlap-free words, which, unlike in the case of squares, does not contain all sufficiently large integers. In analogy to the case of squarefree words one may ask the~following questions.
	
	\begin{question}
		Is there any extremal overlap-free word over a $3$-letter alphabet?
	\end{question}
	
	\begin{question}
		Is the sequence of nonchalant overlap-free binary words infinite?
	\end{question}

	Another generalization of squares is that of \emph{$k$-powers}, which are words of the form $XX\cdots X$ consisting of $k$ copies of any nonempty word $X$. By the mentioned result of Thue~\cite{Thue2}, there exist infinitely many \emph{cube-free} words over a $2$-letter alphabet. Is the sequence of cube-free nonchalant \emph{binary} words infinite? Is it true that every cube-free \emph{ternary} word is extensible?
	
	To state a general conjecture let us recall briefly some basic notions of pattern avoidance as introduced independently by Bean, Ehrenfeucht, and McNulty \cite{BeanEM} and Zimin \cite{Zimin}. Let $\mathbb V$ be an alphabet of variables. A \emph{pattern} $P=p_1p_2\cdots p_r$, with $p_i\in \mathbb V$, is any nonempty word over $\mathbb V$. A~word $W$ \emph{realizes} a pattern $P$ if it can be split into nonempty factors $W=W_1W_2\cdots W_r$ so that $W_i=W_j$ if and only if $p_i=p_j$, for all $i,j=1,2,\ldots,r$. A~word~$W$ \emph{avoids} a pattern $P$ if no factor of $W$ realizes $P$. For instance, a squarefree word avoids a pattern $P=xx$. The pattern $P$ is \emph{avoidable} if there exist arbitrarily long words avoiding $P$ over some finite alphabet. The least size of such an alphabet is denoted by $\mu(P)$ and called the \emph{avoidability index} of $P$. For instance, $\mu(xx)=3$. A~complete characterization of avoidable patterns was provided independently by Zimin \cite{Zimin} and Bean, Ehrenfeucht, and McNulty \cite{BeanEM}.
	
	Now, given a fixed pattern $P$, we may define \emph{extremal $P$-avoiding} words and \emph{$P$-nonchalant words} analogously as in the case of squares. The following conjectures are worth consideration.
	
	\begin{conjecture}\label{ConjectureExtremalPatterns}
		For every avoidable pattern $P$, there are no extremal $P$-avoiding words over an $(\mu(P)+1)$-letter alphabet.
	\end{conjecture}
	
	\begin{conjecture}\label{ConjectureNonchalantPatterns}
		For every avoidable pattern $P$ and any integer $n\geq \mu(P)$, the sequence of $P$-nonchalant words over $\mathbb{A}_n$ is infinite and converges to a unique infinite word $\mathcal{N}^{(P)}_n$.
	\end{conjecture}
 
 The avoidability index $\mu(P)$ is quite a mysterious parameter. A pattern $P$ with $\mu(P)=4$ was found already by Bean, Ehrenfeucht, and McNulty in \cite{BeanEM}. A current record is only slightly better and belongs to Clark \cite{Clark}, who found a pattern $P$ with $\mu(P)=5$. It is not known if there exist patterns with avoidability index six or more. Is it possible that every avoidable pattern can be avoided over just $5$-letter alphabet?
 
 Actually, one may consider similar problems with respect to any reasonable ``property'' of words. For instance, Ter-Saakov and Zhang \cite{Ter-SaakovZhang} considered extremal words avoiding \emph{abelian squares} (these are words of the form $XY$, where $Y$ is a permutation of $X$). They conjecture that there are infinitely many such words over a $4$-letter alphabet. It is however not true that every abelian squarefree word over a sufficiently large alphabet is extensible. Indeed, every Zimin word $Z_n$ is extremal. This implies that the nonchalant procedure (starting from the empty word) stops over any finite alphabet.
 
	\section{Acknowledgments}
	
	We would like to thank the anonymous referee for careful reading of the manuscript and many valuable comments and suggestions.
	
	\appendix
	
	\section{10000 iterations of the nonchalant procedure}\label{apA}
	
	We consider a 3-letter alphabet. Let $p$ be the number of positions that the procedure moved back in the $i$-th iteration. Tables \ref{TabNon1} and \ref{TabNon2} contain information about the~first 10000 iterations of the procedure with initial word $\mathtt{1}$. For example, in the seventh iteration, the~8-letter long word was obtained by inserting a single letter in the penultimate position of the previous, 7-letter long, word. The~three iterations with the~biggest number of positions moved back are bolded (in fact, these are the only iterations in which the procedure moved back more than 9 positions (cf.\ Table \ref{nai}).
	
	Table \ref{T2} contains an example of more detailed common results for various initial words. Let us focus on the distances between consecutive iterations, in which the procedure moved back by exactly four positions (the number 4 was chosen arbitrarily). We present the~number of occurrences of such distances with respect to various initial words (for each initial word we, again, analyze the first 10000 iterations of the procedure). For example, for initial word~$\mathtt{1}$, procedure moves back by four positions in iteration 480. It happens again 659 iterations later, i.e., in iteration 1139 (Table \ref{TabNon1}). Such number of steps between two consecutive iterations does not happen again, so for the initial word~$\mathtt{1}$ we have a number 1 in the column started by 659. As we can see, the most common distances among considered iterations are about 210-211 steps.
	
	\begin{table}[H]\centering
		\scalebox{0.9}{\begin{tabular}{|r|c||r|c||r|c||r|c||r|c||r|c||r|c||r|c|}\hline
				$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$\\\hline
				7&amp;1&amp;640&amp;1&amp;1307&amp;2&amp;1965&amp;1&amp;2592&amp;4&amp;3253&amp;1&amp;3861&amp;1&amp;{\bf4436}&amp;{\bf20}\\
				25&amp;2&amp;648&amp;2&amp;1338&amp;1&amp;1986&amp;1&amp;2625&amp;1&amp;3256&amp;2&amp;3883&amp;2&amp;4453&amp;1\\
				32&amp;1&amp;676&amp;1&amp;1349&amp;7&amp;1994&amp;2&amp;2657&amp;1&amp;3279&amp;4&amp;3890&amp;2&amp;4485&amp;1\\
				64&amp;1&amp;698&amp;2&amp;1382&amp;1&amp;2025&amp;1&amp;2662&amp;1&amp;3312&amp;1&amp;3921&amp;1&amp;4490&amp;1\\
				69&amp;1&amp;705&amp;2&amp;1387&amp;1&amp;2036&amp;4&amp;2665&amp;2&amp;3344&amp;1&amp;3953&amp;1&amp;4493&amp;2\\
				72&amp;2&amp;764&amp;1&amp;1390&amp;2&amp;2040&amp;7&amp;2696&amp;1&amp;3349&amp;1&amp;3958&amp;1&amp;4524&amp;1\\
				103&amp;1&amp;769&amp;1&amp;1421&amp;1&amp;2067&amp;2&amp;2728&amp;1&amp;3352&amp;2&amp;3961&amp;2&amp;4556&amp;1\\
				135&amp;1&amp;772&amp;2&amp;1453&amp;1&amp;2074&amp;2&amp;2730&amp;2&amp;3383&amp;1&amp;3992&amp;1&amp;4558&amp;2\\
				140&amp;1&amp;803&amp;1&amp;1458&amp;1&amp;2105&amp;1&amp;2732&amp;2&amp;3415&amp;1&amp;4013&amp;1&amp;4560&amp;2\\
				{\bf143}&amp;{\bf15}&amp;835&amp;1&amp;1461&amp;2&amp;2137&amp;1&amp;2761&amp;2&amp;3417&amp;9&amp;4021&amp;2&amp;4589&amp;2\\
				144&amp;2&amp;840&amp;1&amp;1484&amp;4&amp;2142&amp;1&amp;2792&amp;1&amp;3438&amp;2&amp;4052&amp;1&amp;4620&amp;1\\
				175&amp;1&amp;843&amp;2&amp;1517&amp;1&amp;2145&amp;2&amp;2824&amp;1&amp;3445&amp;2&amp;4063&amp;4&amp;4652&amp;1\\
				207&amp;1&amp;902&amp;1&amp;1549&amp;1&amp;2176&amp;1&amp;2829&amp;1&amp;3476&amp;1&amp;4093&amp;2&amp;4657&amp;1\\
				212&amp;1&amp;907&amp;1&amp;1554&amp;1&amp;2197&amp;1&amp;2832&amp;2&amp;3508&amp;1&amp;4100&amp;2&amp;4660&amp;2\\
				215&amp;2&amp;910&amp;2&amp;1557&amp;2&amp;2205&amp;2&amp;2863&amp;1&amp;3513&amp;1&amp;4131&amp;1&amp;4691&amp;1\\
				246&amp;1&amp;931&amp;2&amp;1588&amp;1&amp;2236&amp;1&amp;2884&amp;1&amp;3516&amp;2&amp;4163&amp;1&amp;4712&amp;1\\
				270&amp;4&amp;959&amp;2&amp;1620&amp;1&amp;2247&amp;4&amp;2892&amp;2&amp;3547&amp;1&amp;4168&amp;1&amp;4720&amp;2\\
				300&amp;2&amp;966&amp;2&amp;1622&amp;2&amp;2277&amp;2&amp;2923&amp;1&amp;3568&amp;1&amp;4171&amp;2&amp;4751&amp;1\\
				307&amp;2&amp;997&amp;1&amp;1624&amp;2&amp;2284&amp;2&amp;2934&amp;4&amp;3576&amp;2&amp;4202&amp;1&amp;4762&amp;4\\
				338&amp;1&amp;1029&amp;1&amp;1653&amp;2&amp;2315&amp;1&amp;2964&amp;2&amp;3607&amp;1&amp;4223&amp;1&amp;4792&amp;2\\
				370&amp;1&amp;1034&amp;1&amp;1684&amp;1&amp;2347&amp;1&amp;2971&amp;2&amp;3618&amp;4&amp;4231&amp;2&amp;4799&amp;2\\
				375&amp;1&amp;1037&amp;2&amp;1716&amp;1&amp;2352&amp;1&amp;3002&amp;1&amp;3648&amp;2&amp;4262&amp;1&amp;4830&amp;1\\
				378&amp;2&amp;1068&amp;1&amp;1721&amp;1&amp;2355&amp;2&amp;3034&amp;1&amp;3655&amp;2&amp;4273&amp;4&amp;4862&amp;1\\
				409&amp;1&amp;1089&amp;1&amp;1724&amp;2&amp;2386&amp;1&amp;3039&amp;1&amp;3686&amp;1&amp;4274&amp;1&amp;4867&amp;1\\
				430&amp;1&amp;1097&amp;2&amp;1755&amp;1&amp;2407&amp;1&amp;3042&amp;2&amp;3718&amp;1&amp;4275&amp;1&amp;4870&amp;2\\
				438&amp;2&amp;1128&amp;1&amp;1776&amp;1&amp;2415&amp;2&amp;3073&amp;1&amp;3723&amp;1&amp;4278&amp;2&amp;4901&amp;1\\
				469&amp;1&amp;1139&amp;4&amp;1784&amp;2&amp;2446&amp;1&amp;3094&amp;1&amp;3726&amp;2&amp;4296&amp;2&amp;4922&amp;1\\
				480&amp;4&amp;1169&amp;2&amp;1815&amp;1&amp;2457&amp;7&amp;3102&amp;2&amp;3757&amp;1&amp;4303&amp;2&amp;4930&amp;2\\
				510&amp;2&amp;1176&amp;2&amp;1826&amp;4&amp;2490&amp;1&amp;3133&amp;1&amp;3778&amp;1&amp;4342&amp;1&amp;4961&amp;1\\
				517&amp;2&amp;1207&amp;1&amp;1856&amp;2&amp;2495&amp;1&amp;3144&amp;7&amp;3786&amp;2&amp;4347&amp;1&amp;4972&amp;4\\
				548&amp;1&amp;1239&amp;1&amp;1863&amp;2&amp;2498&amp;2&amp;3177&amp;1&amp;3817&amp;1&amp;4350&amp;2&amp;4976&amp;7\\\cline{15-16}
				580&amp;1&amp;1244&amp;1&amp;1894&amp;1&amp;2529&amp;1&amp;3182&amp;1&amp;3828&amp;4&amp;4381&amp;1\\
				585&amp;1&amp;1247&amp;2&amp;1926&amp;1&amp;2561&amp;1&amp;3185&amp;2&amp;3829&amp;1&amp;4413&amp;1\\
				588&amp;2&amp;1278&amp;1&amp;1931&amp;1&amp;2566&amp;1&amp;3216&amp;1&amp;3830&amp;1&amp;4418&amp;1\\
				619&amp;1&amp;1299&amp;1&amp;1934&amp;2&amp;2569&amp;2&amp;3248&amp;1&amp;3833&amp;2&amp;4421&amp;2\\\cline{1-14}
		\end{tabular}}
		\vskip0.5cm
		\caption{Nonzero positions moved back by the nonchalant procedure in iterations 1-5000.}\label{TabNon1}
	\end{table}
	
	\begin{table}[H]\centering
		\scalebox{0.9}{\begin{tabular}{|r|c||r|c||r|c||r|c||r|c||r|c||r|c||r|c|}\hline
				$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$&amp;$i$&amp;$p$\\\hline
				5003&amp;2&amp;5632&amp;1&amp;6249&amp;2&amp;6852&amp;2&amp;7483&amp;2&amp;8144&amp;1&amp;8835&amp;1&amp;9485&amp;2\\
				5010&amp;2&amp;5664&amp;1&amp;6280&amp;1&amp;6883&amp;1&amp;7514&amp;1&amp;8147&amp;2&amp;8843&amp;2&amp;9516&amp;1\\
				5041&amp;1&amp;5666&amp;2&amp;6291&amp;4&amp;6904&amp;1&amp;7535&amp;1&amp;8178&amp;1&amp;8874&amp;1&amp;9527&amp;4\\
				5073&amp;1&amp;5668&amp;2&amp;6321&amp;2&amp;6912&amp;2&amp;7543&amp;2&amp;8205&amp;2&amp;8885&amp;4&amp;9557&amp;2\\
				5078&amp;1&amp;5697&amp;2&amp;6328&amp;2&amp;6943&amp;1&amp;7574&amp;1&amp;8238&amp;1&amp;8915&amp;2&amp;9564&amp;2\\
				5081&amp;2&amp;5728&amp;1&amp;6359&amp;1&amp;6954&amp;4&amp;7585&amp;7&amp;8261&amp;3&amp;8922&amp;2&amp;9595&amp;1\\
				5112&amp;1&amp;5760&amp;1&amp;6391&amp;1&amp;6984&amp;2&amp;7618&amp;1&amp;8267&amp;2&amp;8953&amp;1&amp;9627&amp;1\\
				5133&amp;1&amp;5765&amp;1&amp;6396&amp;1&amp;6991&amp;2&amp;7623&amp;1&amp;8298&amp;1&amp;8985&amp;1&amp;9632&amp;1\\
				5141&amp;2&amp;5768&amp;2&amp;6399&amp;2&amp;7022&amp;1&amp;7626&amp;2&amp;8330&amp;1&amp;8990&amp;1&amp;9635&amp;2\\
				5172&amp;1&amp;5799&amp;1&amp;6430&amp;1&amp;7054&amp;1&amp;7657&amp;1&amp;8335&amp;1&amp;8993&amp;2&amp;9666&amp;1\\
				5183&amp;4&amp;5820&amp;1&amp;6451&amp;1&amp;7059&amp;1&amp;7689&amp;4&amp;8338&amp;2&amp;9024&amp;1&amp;9687&amp;1\\
				5213&amp;2&amp;5828&amp;2&amp;6459&amp;2&amp;7062&amp;2&amp;7716&amp;2&amp;8369&amp;1&amp;9045&amp;1&amp;9695&amp;2\\
				5220&amp;2&amp;5859&amp;1&amp;6490&amp;1&amp;7093&amp;1&amp;7723&amp;2&amp;8390&amp;1&amp;9053&amp;2&amp;9726&amp;1\\
				5251&amp;1&amp;5870&amp;4&amp;6501&amp;7&amp;7114&amp;1&amp;7754&amp;1&amp;8398&amp;2&amp;9084&amp;1&amp;9737&amp;4\\
				5283&amp;1&amp;5900&amp;2&amp;6534&amp;1&amp;7122&amp;2&amp;7786&amp;1&amp;8429&amp;1&amp;9123&amp;2&amp;9738&amp;1\\
				5288&amp;1&amp;5907&amp;2&amp;6539&amp;1&amp;7153&amp;1&amp;7791&amp;1&amp;8440&amp;4&amp;9130&amp;2&amp;9739&amp;1\\
				5291&amp;2&amp;5938&amp;1&amp;6542&amp;2&amp;7164&amp;4&amp;7794&amp;2&amp;8470&amp;2&amp;9161&amp;1&amp;9742&amp;2\\
				5322&amp;1&amp;5970&amp;1&amp;6573&amp;1&amp;7168&amp;7&amp;7825&amp;1&amp;8477&amp;2&amp;9193&amp;1&amp;9770&amp;1\\
				5343&amp;1&amp;5975&amp;1&amp;6605&amp;1&amp;7195&amp;2&amp;7846&amp;1&amp;8508&amp;1&amp;9198&amp;1&amp;9792&amp;2\\
				5351&amp;2&amp;5978&amp;2&amp;6610&amp;1&amp;7202&amp;2&amp;7854&amp;2&amp;8540&amp;1&amp;9201&amp;2&amp;9799&amp;2\\
				5382&amp;1&amp;6009&amp;1&amp;6613&amp;2&amp;7233&amp;1&amp;7885&amp;1&amp;8545&amp;1&amp;9232&amp;1&amp;9830&amp;1\\
				5393&amp;7&amp;6030&amp;1&amp;{\bf6628}&amp;{\bf20}&amp;7265&amp;1&amp;7896&amp;4&amp;8548&amp;2&amp;9253&amp;1&amp;9862&amp;1\\
				5426&amp;1&amp;6038&amp;2&amp;6645&amp;1&amp;7270&amp;1&amp;7926&amp;2&amp;8579&amp;1&amp;9261&amp;2&amp;9867&amp;1\\
				5431&amp;1&amp;6069&amp;1&amp;6677&amp;1&amp;7273&amp;2&amp;7933&amp;2&amp;8600&amp;1&amp;9292&amp;1&amp;9870&amp;2\\
				5434&amp;2&amp;6080&amp;4&amp;6682&amp;1&amp;7304&amp;1&amp;7964&amp;1&amp;8608&amp;2&amp;9294&amp;1&amp;9901&amp;1\\
				5465&amp;1&amp;6084&amp;7&amp;6685&amp;2&amp;7325&amp;1&amp;7996&amp;1&amp;8639&amp;1&amp;9328&amp;4&amp;9922&amp;1\\
				5497&amp;1&amp;6111&amp;2&amp;6716&amp;1&amp;7333&amp;2&amp;8001&amp;1&amp;8650&amp;4&amp;9347&amp;2&amp;9930&amp;2\\
				5502&amp;1&amp;6118&amp;2&amp;6748&amp;1&amp;7364&amp;1&amp;8004&amp;2&amp;8705&amp;2&amp;9354&amp;2&amp;9961&amp;1\\
				5505&amp;2&amp;6149&amp;1&amp;6750&amp;2&amp;7375&amp;4&amp;8035&amp;1&amp;8712&amp;2&amp;9385&amp;1&amp;9972&amp;4\\\cline{15-16}
				5528&amp;4&amp;6181&amp;1&amp;6752&amp;2&amp;7405&amp;2&amp;8056&amp;1&amp;8743&amp;1&amp;9417&amp;1\\
				5561&amp;1&amp;6186&amp;1&amp;6781&amp;2&amp;7412&amp;2&amp;8064&amp;2&amp;8775&amp;1&amp;9422&amp;1\\
				5593&amp;1&amp;6189&amp;2&amp;6812&amp;1&amp;7443&amp;1&amp;8095&amp;1&amp;8780&amp;1&amp;9425&amp;2\\
				5598&amp;1&amp;6220&amp;1&amp;6844&amp;1&amp;7475&amp;1&amp;8106&amp;7&amp;8783&amp;2&amp;9456&amp;1\\
				5601&amp;2&amp;6241&amp;1&amp;6849&amp;1&amp;7480&amp;1&amp;8139&amp;1&amp;8814&amp;1&amp;9477&amp;1\\\cline{1-14}
		\end{tabular}}
		\vskip0.5cm
		\caption{Nonzero positions moved back by the nonchalant procedure in iterations 5001-10000.}\label{TabNon2}
	\end{table}
	
	\begin{table}[H]\centering
		\scalebox{0.9}{ \begin{tabular}{|c||cccccccccccc|}\hline
				$N_1$&amp;199&amp;207&amp;210&amp;211&amp;233&amp;235&amp;314&amp;339&amp;342&amp;345&amp;443&amp;460\\ \hline
				$\mathtt{1}$&amp;1&amp;1&amp;9&amp;4&amp;0&amp;3&amp;1&amp;1&amp;3&amp;4&amp;1&amp;0\\
				$\mathtt{2}$&amp;2&amp;1&amp;8&amp;5&amp;0&amp;3&amp;1&amp;0&amp;3&amp;4&amp;1&amp;1\\
				$\mathtt{3}$&amp;1&amp;1&amp;8&amp;6&amp;0&amp;1&amp;1&amp;1&amp;5&amp;6&amp;0&amp;1\\
				$\mathtt{13}$&amp;1&amp;1&amp;8&amp;6&amp;0&amp;1&amp;1&amp;1&amp;5&amp;6&amp;0&amp;1\\
				$\mathtt{23}$&amp;2&amp;1&amp;9&amp;5&amp;0&amp;3&amp;1&amp;0&amp;3&amp;4&amp;1&amp;1\\
				$\mathtt{32}$&amp;2&amp;1&amp;8&amp;5&amp;0&amp;3&amp;1&amp;0&amp;3&amp;4&amp;1&amp;1\\
				$\mathtt{3213}$&amp;1&amp;1&amp;8&amp;6&amp;0&amp;1&amp;1&amp;1&amp;5&amp;6&amp;0&amp;1\\
				$\mathtt{2313213}$&amp;1&amp;1&amp;8&amp;6&amp;0&amp;1&amp;1&amp;1&amp;5&amp;6&amp;0&amp;1\\
				$\mathtt{32132313213}$&amp;1&amp;1&amp;8&amp;6&amp;0&amp;1&amp;1&amp;1&amp;5&amp;6&amp;0&amp;1\\
				\hline
		\end{tabular}}
	\end{table}
	
	\begin{table}[H]\centering
		\scalebox{0.9}{\begin{tabular}{|c||cccccc|}\hline
				$N_1$&amp;489&amp;544&amp;659&amp;663&amp;688&amp;806\\ \hline
				$\mathtt{1}$&amp;1&amp;1&amp;1&amp;1&amp;0&amp;0\\
				$\mathtt{2}$&amp;0&amp;1&amp;0&amp;1&amp;1&amp;0\\
				$\mathtt{3}$&amp;1&amp;0&amp;0&amp;1&amp;0&amp;0\\
				$\mathtt{13}$&amp;1&amp;0&amp;0&amp;1&amp;0&amp;0\\
				$\mathtt{23}$&amp;1&amp;1&amp;0&amp;1&amp;0&amp;0\\
				$\mathtt{32}$&amp;0&amp;1&amp;0&amp;1&amp;1&amp;0\\
				$\mathtt{3213}$&amp;1&amp;0&amp;0&amp;1&amp;0&amp;0\\
				$\mathtt{2313213}$&amp;1&amp;0&amp;0&amp;1&amp;0&amp;0\\
				$\mathtt{32132313213}$&amp;1&amp;0&amp;0&amp;1&amp;0&amp;0\\
				\hline
		\end{tabular}}
		\vskip0.5cm
		\caption{Numbers of occurrences of distances (first row) between two consecutive iterations in which the nonchalant procedure moved back by exactly four positions, for various initial words (for 10000 iterations of the procedure).}\label{T2}
	\end{table}
	
	\begin{thebibliography}{99}
		
		\bibitem{AlloucheShallit} J.-P. Allouche, J. Shallit, {\it Automatic Sequences: Theory, Applications, Generalizations}, Cambridge University Press, 2003.
		
		\bibitem{BeanEM} D. R. Bean, A. Ehrenfeucht, and G. F. McNulty, Avoidable patterns in strings of symbols, {\it Pacific J. Math.} {\bf85} (1979), 261--294.
		
		\bibitem{BerstelThue} J. Berstel, Axel Thue's papers on repetitions in words: a translation, {\it Publications du LaCIM} {\bf20},
		Universit\'e du Qu\'ebec \`a Montr\'eal, 1995.
		
		\bibitem{BerstelPerrin} J. Berstel, D. Perrin, The origins of combinatorics on words, {\it Europ. J. Combin.} {\bf 28} (2007), 996--1022.
		
		\bibitem{Clark} R. J. Clark, The existence of a pattern which is 5-avoidable but 4-unavoidable, {\it Int. J. Alg. Comput.} {\bf 16} (2006), 351--367.
		
\bibitem{Currie TCS} J. Currie, Pattern avoidance: themes and variations, 
{\it Theoret. Comput. Sci.} {\bf 339} (2005), 7--18.
		
\bibitem{GrytczukKN} J. Grytczuk, H. Kordulewski, and A. Niewiadomski, Extremal squarefree words, {\it Electron. J. Combin.} {\bf27} (2020), Paper P1.48.
		
\bibitem{HongZhang} L. Hong and S. Zhang, No extremal squarefree words over large alphabets, preprint, September 2021.  Available
at \url{https://arxiv.org/abs/2107.13123}.
		
		\bibitem{Lothaire} M. Lothaire, {\it Combinatorics on Words}, Addison-Wesley, 1983.
		
		\bibitem{LothaireAlgebraic} M. Lothaire, {\it Algebraic Combinatorics on Words}, Cambridge University Press, 2002.
		
\bibitem{MolRamp} L. Mol and N. Rampersad, Lengths of extremal squarefree ternary words, {\it Contrib. Discrete Math.} {\bf 16} (2020), 8--19.
		
		\bibitem{MolRS} L. Mol, N. Rampersad, and J. Shallit, Extremal overlap-free and extremal $\beta$-free binary words, {\it Electron. J. Combin.} {\bf 27} (2020), Paper P4.42.
		
		\bibitem{Ter-SaakovZhang} N. Ter-Saakov and E. Zhang,
Extremal pattern-avoiding words, preprint, 2020. Available at \url{https://arxiv.org/abs/2009.10186}.
		
		\bibitem{Shur} A. M. Shur, On ternary square-free circular words, {\it Electron. J. Comb.} {\bf17} (2010), Paper R1.40.
		
		\bibitem{OEIS} N. J. A. Sloane et al., {\it The On-Line Encyclopedia of Integer Sequences},  published electronically at \url{https://oeis.org}.
		
		\bibitem{Thue} A. Thue, \"{U}ber unendliche Zeichenreihen, {\it Norske vid. Selsk. Skr. Mat. Nat. Kl.} {\bf 7} (1906), 1--22. Reprinted in {\it Selected Mathematical Papers of Axel Thue}, T. Nagell, editor, Universitetsforlaget, Oslo, 1977, pp.~139--158.
		
		\bibitem{Thue2} A. Thue, \"{U}ber die gegenseitige Lage gleicher Teile gewisser Zeichenreihen, {\it Norske vid. Selsk. Skr. Mat. Nat. Kl.} {\bf 1} (1912), 1--67. Reprinted in {\it Selected Mathematical Papers of Axel Thue}, T. Nagell, editor, Universitetsforlaget, Oslo, 1977, pp.~413--478.
		
		\bibitem{Zimin} A. I. Zimin, Blocking sets of terms, {\it Mat. Sb.} {\bf119} (1982), 363--375. Translated in {\it Sb. Math.} {\bf47} (1984), 353--364.
		
	\end{thebibliography}
	
	\bigskip
	\hrule
	\bigskip
	
	\noindent 2020 {\it Mathematics Subject Classification}: 68R15.
	
	\noindent \emph{Keywords: } squarefree word, extremal word, Zimin word, word extension.
	
	\bigskip
	\hrule
	\bigskip
	
	
	\noindent
	(Concerned with sequence \seqnum{A006742}.)
	
	
	\bigskip
	\hrule
	\bigskip
	
	
	
\vspace*{+.1in}
\noindent
Received May 1 2021;
revised versions received  May 4 2021; August 17 2021; 
August 30 2021.
Published in {\it Journal of Integer Sequences},
September 23 2021.

\bigskip
\hrule
\bigskip

\noindent
Return to
\htmladdnormallink{Journal of Integer Sequences home page}{https://cs.uwaterloo.ca/journals/JIS/}.
\vskip .1in


\end{document}

                                                                                

</pre></body></html>