\documentclass[11pt]{article} \pdftrailerid{} \usepackage[T1]{fontenc} \usepackage{lmodern,microtype} \usepackage[margin=1in]{geometry} \usepackage{amsmath,amssymb,amsthm} \usepackage[colorlinks=true,linkcolor=blue,citecolor=blue,urlcolor=blue]{hyperref} \hypersetup{pdfauthor={Peter Graham},pdftitle={Every morphic infinite word has cost zero}} \newtheorem{theorem}{Theorem} \newtheorem{lemma}[theorem]{Lemma} \newtheorem{remark}{Remark} \newcommand{\Fac}{\operatorname{Fac}} \title{Every morphic infinite word has cost zero} \author{Peter Graham\\ \small\url{https://orcid.org/0009-0007-8493-1505}} \date{December 4, 2026\\[2pt] \small Zenodo archive: \url{https://doi.org/10.5281/zenodo.24830141}\\ \small \href{https://github.com/6/clank-lab/tree/morphic-word-cost-zero-v1/results/morphic-word-cost-zero/checks}{Computer checks}\\ \small \href{https://github.com/6/clank-lab/tree/morphic-word-cost-zero-v1/results/morphic-word-cost-zero/lean}{Lean development}} \begin{document} \maketitle \begin{abstract} The cost of an infinite word is the infimum of the exponents \(\alpha\) for which a dictionary with \(O(n^\alpha)\) words of length \(n\) spells every finite factor (contiguous subword) in a bounded number of pieces. A morphic word is the letter-to-letter image of an infinite word generated by iterating a substitution on a letter. We prove that every morphic word has cost zero. One dictionary and one piece bound work for all positive exponents. This answers a question of Cassaigne, Frid, Puzynina and Zamboni, who established cost zero for words of factor complexity \(O(n\log n)\) and bounded the zero-dimension of their increasing-run example between four and six. For polynomial growth, Smith's description of the word reduces the dictionary count to a divisor bound. For exponential growth, the same argument covers the stretches between exponentially growing letters. The remaining prefixes and suffixes come from only logarithmically many levels at each length. Lean checks the cost theorem and the uniform dictionary bound with three published results of Durand, Deviatov and Smith stated as axioms. This work has not yet been reviewed by experts. The proof, Lean formalization, finite tests and text were produced by AI models from OpenAI and Anthropic, working under the author's direction. \end{abstract} \medskip \noindent\textit{2020 Mathematics Subject Classification.} 68R15. \quad\textit{Keywords.} Morphic words, factor complexity, cost. \section{Introduction} For a one-sided infinite word \(x\) on a finite alphabet \(A\), let \(\Fac(x)\) be the set of its finite contiguous subwords, or \emph{factors}. For a language \(D\subseteq A^*\), write \(p_D(n)=|D\cap A^n|\) and \(D^k=\{w_1\cdots w_k:w_1,\ldots,w_k\in D\}\). The factor complexity \(p_x(n)=p_{\Fac(x)}(n)\) counts the distinct length-\(n\) factors. Cassaigne, Frid, Puzynina and Zamboni (CFPZ) ask how economically a language can describe these factors by concatenation \cite[\S3]{cfpz}. For \(\alpha\ge0\), their dimension \(d_\alpha(x)\) is the least positive integer \(k\) for which \(\Fac(x)\subseteq D^k\) with \(p_D(n)=O(n^\alpha)\), or infinity if no such dictionary exists. The cost \(c(x)\) is the infimum of the \(\alpha\) with finite \(d_\alpha(x)\) \cite[Definition 3.1]{cfpz}. A substitution \(h\) maps letters to finite words and acts on words by concatenation. It is \emph{prolongable} on \(a\) if \(h(a)\) begins with \(a\) and \(|h^t(a)|\to\infty\). The nested prefixes \(h^t(a)\) then define the pure morphic word \(h^\omega(a)\). A morphic word is the image of such a word under a coding \(\pi\) sending each letter to one letter. CFPZ ask whether every word of complexity \(O(n^2)\) has cost zero. They then ask, ``Is it true at least for morphic words, like the example from Section 5?'' \cite[\S7, p.~659]{cfpz}. Their Section~5 treats the word \(\prod_{i\ge1}ab^i=ababbabbb\cdots\). \begin{theorem}\label{th:main} For each morphic infinite word \(x\) over \(A\) there exist \(D\subseteq A^*\) and \(K\ge1\) such that \(\Fac(x)\subseteq D^K\) and, for every \(\varepsilon>0\), \(p_D(n)=O_\varepsilon(n^\varepsilon)\). In particular \(c(x)=0\). \end{theorem} When \(p_x(n)=O(n\log n)\), CFPZ's Corollary~4.5 gives \(\Fac(x)\subseteq D_1D_2\) with \(p_{D_1}(n),p_{D_2}(n)=O(\log^2(n+1))\), so \(c(x)=0\).\footnote{The corollary applies to recurrent aperiodic one-sided words and aperiodic two-sided words. For a general aperiodic one-sided word, left-pad with a new letter as in the proof of their Corollary~4.6. This adds \(n\) factors of length \(n\), and the pieces of a factor in \(A^*\) still belong to \(A^*\). Ultimately periodic words have bounded factor complexity.} Using Pansiot's classification \cite{pansiot}, their Corollary~4.7 settles all pure morphic words except those of quadratic complexity. Immediately after the corollary (p.~651) they conjecture that these fixed points also have cost zero. For \(u=\prod_{i\ge1}ab^i\) they prove the stronger bounds \(4\le d_0(u)\le6\) \cite[Theorem 5.1]{cfpz}. For morphic words in general, the orders above \(O(n\log n)\) are \(\Theta(n^{1+1/k})\), \(k\ge1\), by R.~Devyatov (also transliterated Deviatov) \cite[Theorem 1.1]{dev}. A set \(F\) of finite words is \emph{covered} by \((D,K)\) if \(K\ge1\), \(F\subseteq D^K\), the empty word belongs to \(D\), and \(p_D(n)=O_\varepsilon(n^\varepsilon)\) for every \(\varepsilon>0\). We call \(K\) the \emph{piece bound}. \begin{remark}\label{rem:cover} A finite union of covered sets uses the union of their dictionaries and the maximum of the piece bounds, with empty words for padding. If the factors of each of \(r\) consecutive blocks are covered by \((D,K)\), then any factor of their concatenation splits along block boundaries into at most \(rK\) pieces. \end{remark} \paragraph{Proof overview.} The outstanding pure case is the quadratic fixed point. We treat it and its codings by one construction, independently of the complexity classifications. In Durand's nonerasing presentation each letter grows polynomially or exponentially. For a polynomially growing seed, Lemma~\ref{lem:poly} uses Smith's zigzag representation. The number of complete intervals of length \(n\) is controlled by the divisors of a fixed multiple of \(n\). For an exponential seed, Lemma~\ref{lem:gaps} applies this count to the polynomial stretches between exponential letters. The remaining prefixes and suffixes come from \(O(\log n)\) heights, and splitting at the lowest common ancestor of a factor's endpoints gives the piece bound. Section~\ref{sec:formal} gives the Lean statements and the three published inputs they assume. \section{Substitutions of polynomial growth} In Smith's description \cite{smith}, a \emph{zigzag word} has the form \(qL(1)L(2)\cdots\), with \(q\) a finite word and \(L\) a finite nonempty list of terms. The value \(L(i)\) concatenates their values in order. A static term is a fixed nonempty word. A repetition term uses a child list \(M\) and has one of the values \[ M(1)\cdots M(i),\qquad M(i)\cdots M(1). \] The lists are built by finite nesting. A static term has depth one, a repetition adds one to its child list's depth, and a list has the maximum depth of its terms. For example, take \(M\) to have the single static term \(b\), and \(L\) to consist of \(a\) followed by the forward repetition of \(M\). Then \(L(i)=ab^i\), giving CFPZ's word at depth two. A \emph{complete interval} consists of consecutive whole values of a list, in either order. \begin{lemma}\label{lem:poly} Let \(x=\pi(h^\omega(a))\) with \(|h^t(a)|=\Theta(t^k)\) for an integer \(k\ge1\). Then \(\Fac(x)\) is covered. \end{lemma} \begin{proof} Smith's Theorem~3 gives \(x\) a zigzag representation of depth \(k\). Include in \(D\) all factors of \(q\) and of the static words. For every list \(M\) in the representation include all \(M(i+1)\cdots M(j)\) and \(M(j)\cdots M(i+1)\), \(0\le i0\) with \(Q=s\Phi\in\mathbb Z[X]\). At interval length \(n\), the difference \(\delta=j-i\) divides \(Q(j)-Q(i)=sn\), since \(a-b\) divides \(Q(a)-Q(b)\) for distinct integers \(a,b\) and \(Q\in\mathbb Z[X]\). For each positive divisor \(\delta\) of \(sn\), the polynomial \(Q(X+\delta)-Q(X)-sn\) has degree \(\deg\Phi-1\), so there are at most that many possible starting indices \(i\). Each specifies one word per orientation. The number of divisors of \(sn\) is \(O_\varepsilon(n^\varepsilon)\).\footnote{In the divisor formula \(\prod_{p^\nu\parallel N}(\nu+1)\), use \(\nu+1\le2^\nu\le p^{\varepsilon\nu}\) for \(p\ge2^{1/\varepsilon}\). For each of the finitely many smaller primes, the ratio \((\nu+1)/p^{\varepsilon\nu}\) is bounded independently of \(\nu\).} Summing over the finitely many lists gives the required dictionary count. Assign one piece to a static term and add the bounds of a list's terms to obtain \(K_M\). A repetition of \(M\) needs at most \(2K_M+1\) pieces for any factor: either it lies in one child or it consists of two end fragments and the complete interval between them. This works in either order. Applying the same cut to a sufficiently long prefix of the outer product and allowing one piece from \(q\) gives \(2K_L+2\) pieces. \end{proof} \section{Polynomial gaps in the exponential case} Cobham's nonerasing normalization \cite{cobham}, in the form of Durand's Theorem~5(1)--(2) \cite{durand}, writes \(x\) as a coding of \(h^\omega(a)\) with \(h\) nonerasing. Deviatov's letter-order lemma \cite[Lemma 1, p.~147]{order} partitions the alphabet into sets \(P,E\). For \(p\in P\), the \emph{degree} of \(p\) is the integer \(d_p\ge0\) such that \(|h^t(p)|=\Theta((t+1)^{d_p})\). For \(e\in E\), \(|h^t(e)|\ge c_e\lambda_e^t\) eventually for some \(c_e>0,\lambda_e>1\). Since \(h\) is nonerasing, decreasing \(c_e\) if necessary gives the bound for all \(t\ge0\). Thus \(h(P)\subseteq P^*\), and each \(h(e)\) contains an \(E\)-letter, for otherwise its iterates would have polynomially bounded length. Every iterate of an \(E\)-letter therefore contains an \(E\)-letter. If \(a\in P\), then \(d_a\ge1\) by prolongability, and Lemma~\ref{lem:poly} applies. Assume henceforth that \(a\in E\). Let \(f,g:E\to E\) select the first and last \(E\)-letters in each image. For \(h^m\) the corresponding maps are \(f^m,g^m\) by closure of \(P\). Choose \(m\) divisible by all cycle lengths of both maps and at least their maximum transient length. For \(H=h^m\) the new maps, again denoted \(f,g\), are idempotent. The infinite fixed point is unchanged. Write \(u_e,v_e\) for the maximal \(P\)-prefix and \(P\)-suffix of \(H(e)\). The substitution tree of \(H^t(e)\) has root \(e\) at height \(t\). A node labeled \(b\) at height \(j>0\) has as children the letters of \(H(b)\), in order, at height \(j-1\). The leaves below the node spell its \emph{tile} \(H^j(b)\), so the leaves of the tree spell \(H^t(e)\). An \(E\)-leaf has its label in \(E\), and a \(P\)-only word belongs to \(P^*\). \begin{lemma}\label{lem:gaps} There is a common dictionary with the count in Theorem~\ref{th:main} and a bound \(K_P\) covering all \(P\)-only factors of \(H^t(e)\), \(e\in E,\ t\ge0\). \end{lemma} \begin{proof} Let \(w\) range over the nonempty words among \(u_e,v_e\) and the blocks between consecutive \(E\)-letters of \(H(e)\), for all \(e\in E\). We first cover every factor of the two words \[ H^i(w)H^{i+1}(w)\cdots H^j(w),\qquad H^j(w)H^{j-1}(w)\cdots H^i(w) \qquad (0\le i\le j). \] For the increasing order, extend \(H|_P\) by a fresh letter \(z\mapsto zw\). Its fixed point is \(zwH(w)H^2(w)\cdots\). If \(d_w\) is the largest degree of a letter in \(w\), the \(t\)-th iterate of \(z\) has length \(1+\sum_{i=0}^{t-1}|H^i(w)|=\Theta(t^{d_w+1})\), since \(H^i=h^{mi}\). Lemma~\ref{lem:poly} covers its factors. For the decreasing order apply the same argument to \(J(p)=\operatorname{rev}(H(p))\) on \(P\) and \(z\mapsto z\operatorname{rev}(w)\). Here \(\operatorname{rev}\) reverses letters, so \(J^i(\operatorname{rev}(w))=\operatorname{rev}(H^i(w))\). Reversing each factor, its pieces and their order gives the cover for the decreasing run. Discard dictionary words containing \(z\) and take the union over the finite choices. Write \(K_0\) for the common piece bound, taking the dictionary consisting of the empty word and \(K_0=1\) if there are no nonempty choices. Let \(B^\ell_t(e),B^r_t(e)\) be the maximal initial and terminal \(P\)-blocks in \(H^t(e)\). Both are empty for \(t=0\). For \(t\ge1\), \[ B^\ell_t(e)=H^{t-1}(u_e)B^\ell_{t-1}(f(e)),\qquad B^r_t(e)=B^r_{t-1}(g(e))H^{t-1}(v_e). \] Idempotence fixes \(f(e)\) and \(g(e)\) on the next application. Thus for \(t\ge2\) the two blocks unroll as \[ \begin{aligned} B^\ell_t(e)&=H^{t-1}(u_e)\, \underbrace{H^{t-2}(u_{f(e)})\cdots H^0(u_{f(e)})}_{\text{decreasing run}},\\ B^r_t(e)&=\underbrace{H^0(v_{g(e)})\cdots H^{t-2}(v_{g(e)})}_{\text{increasing run}}\, H^{t-1}(v_e). \end{aligned} \] Each is a concatenation of at most two runs. By Remark~\ref{rem:cover}, its factors use at most \(2K_0\) pieces. In the ordered substitution tree for \(H^t(e)\), consider two consecutive \(E\)-leaves. At their lowest common ancestor they belong to distinct child subtrees of equal height \(s\), with root letters \(b,c\in E\). Every intervening child is in \(P\), since an \(E\)-child has an \(E\)-leaf. The chosen leaves are the last \(E\)-leaf under \(b\) and the first under \(c\). Hence the entire intervening word is \[ B^r_s(b)\,H^s(w)\,B^\ell_s(c), \] where \(w\) is the intervening block of children, possibly empty. A factor in this gap uses at most \(2K_0+K_0+2K_0\) pieces. The initial and terminal blocks already satisfy the same bound. These exhaust the positions of a \(P\)-only factor, proving the lemma with \(K_P=5K_0\). \end{proof} \section{Completing the cover in the exponential case} \begin{proof}[Proof of Theorem~\ref{th:main}] For \(a\in E\), augment the dictionary of Lemma~\ref{lem:gaps} by all letters and by the following prefixes and suffixes. At height \(j\ge1\) include in \(D\) those of each \(H^j(e)\), \(e\in E\), whose length \(n\) satisfies \begin{equation}\label{eq:threshold} n\ \ge\ \min_{b\in E}|H^{j-1}(b)|. \end{equation} There are constants \(c>0,\lambda>1\) common to the finite set \(E\) with \(|H^i(b)|\ge c\lambda^i\). Thus only \(O(1+\log(n+1))\) heights can contribute at length \(n\), each adding at most \(2|E|\) words. Take a prefix of \(H^t(e)\) containing an \(E\)-leaf. At a current tile \(H^j(b)\) of positive height, its endpoint either lies in the first \(E\)-child subtree or follows it, since the prefix contains an \(E\)-leaf. In the former case remove \(H^{j-1}(u_b)\) and descend into that child: the remaining prefix still contains an \(E\)-leaf. In the latter case the remaining prefix contains the entire first \(E\)-child subtree and meets \eqref{eq:threshold}, so it belongs to \(D\). At height zero the remaining letter also belongs to \(D\). All removed words together form one \(P\)-only factor of the original tile, covered by Lemma~\ref{lem:gaps}. Thus every such prefix uses at most \(K_P+1\) pieces. Following last \(E\)-children from the other end gives the same bound for suffixes. Prefixes or suffixes lying in \(P^*\) already satisfy the lemma. Every factor of \(h^\omega(a)\) occurs in some \(H^t(a)\). Single letters and \(P\)-only factors have been treated. For any other factor, take the lowest common ancestor of its two endpoints. Its root is in \(E\), since its descendants include an \(E\)-leaf. Cut the factor at the boundaries of that root's children. There are at most \(\max_{e\in E}|H(e)|\) intersections, each a prefix, suffix or whole child tile. An \(E\)-child has the preceding bound (a whole tile is a prefix). Each intersection in a \(P\)-child is a \(P\)-only factor of the original tile. Consequently \(K=\max(2,\max_{e\in E}|H(e)|)(K_P+1)\) suffices. Finally a letter coding \(\pi\) maps any factorization to one of the same number of pieces, and every coded factor lifts on its own interval. Since \(\pi\) preserves length, \(p_{\pi(D)}(n)\le p_D(n)\). \end{proof} \section{The Lean statements and their inputs}\label{sec:formal} For a finite alphabet \(A\) and an infinite word \(x\) over \(A\), the two Lean theorems in the namespace \texttt{MorphicWordCost} have the following statements, with the finite-alphabet quantifiers suppressed: \[ \begin{aligned} \texttt{morphicSubpowerCover}:&\quad \texttt{IsMorphic}\ x \ \Longrightarrow\ \texttt{HasSubpowerCover}\ x,\\ \texttt{cost\_eq\_zero\_of\_isMorphic}:&\quad \texttt{IsMorphic}\ x \ \Longrightarrow\ \texttt{cost}\ x=0 . \end{aligned} \] Here \(\texttt{IsMorphic}\ x\) means that \(x\) is a coding of a fixed point generated by a prolongable, possibly erasing substitution. The conclusion \(\texttt{HasSubpowerCover}\ x\) expands to \[ \exists\, K\ge1,\ D\ni [\,],\quad \texttt{DictionaryCovers}\ x\ D\ K \quad\land\quad \forall\,\varepsilon>0,\ \texttt{HasGrowth}\ D\ \varepsilon . \] The first predicate requires each contiguous factor to concatenate exactly \(K\) dictionary pieces. The empty word \([\,]\) supplies padding for shorter decompositions. The second requires \(p_D(n)\le Cn^\varepsilon\) for all \(n\ge1\), with \(C>0\) allowed to depend on \(\varepsilon\). The definition of \texttt{cost} takes the infimum of the admissible nonnegative exponents, as in CFPZ's Definition~3.1. In the accompanying files, \path{lean/Challenge.lean} contains these definitions, \path{lean/Morphic.lean} the theorems, and \path{lean/Audit.lean} the axiom checks. From the result directory run \texttt{sh checks/check-lean.sh} to build the proof and replay the checks. Both theorems use Lean's \texttt{propext}, \texttt{Classical.choice} and \texttt{Quot.sound}, together with three published results stated as axioms in \path{lean/PublishedInputs.lean}. \begin{itemize} \item \texttt{durand\_theorem5} assumes parts (1)--(2) of Durand's Theorem~5 \cite{durand}, a form of Cobham's normalization \cite{cobham}. If \(\sigma\) is prolongable on \(a\) and \(\phi\) is a possibly erasing morphism such that \(\phi(\sigma^\omega(a))\) is infinite, this image equals \(\psi(\tau^\omega(b))\) for a nonerasing substitution \(\tau\) prolongable on \(b\) and a letter coding \(\psi\). See also \cite[Theorem 7.5.1 and Corollary 7.7.5]{as} and \cite[Theorem 4.6.1(i)--(ii)]{cn}. \item \texttt{deviatov\_lemma1\_growth} assumes the first assertion of Deviatov's Lemma~1 \cite{order}. For a nonerasing substitution generating a pure fixed point, the lengths of the $t$-th iterates of each letter are either \(\Theta(t^d)\) for some integer \(d\ge0\), or eventually at least \(cq^t\) for some \(c>0,\ q>1\). For the growth estimates see Salomaa and Soittola \cite[Ch.~III, \S7]{ss}, cited in Durand's Proposition~3, and the residue-class formulation in \cite[Theorem 2]{cmn}. \item \texttt{smith\_theorem3} states Smith's Theorem~3 \cite{smith}. A word \(x\) has a presentation \(x=\pi(h^\omega(a))\) with \(|h^t(a)|=\Theta(t^d)\), \(d\ge1\), if and only if it has a zigzag representation of depth \(d\). Only the forward implication is used. \end{itemize} Independent AI readers checked the written and formal proofs. Finite tests exercised the constructions on 13 zigzag grammars and 19 morphisms with codings. \paragraph{Open questions.} Does every word of complexity \(O(n^2)\) have cost zero? CFPZ also ask for an upper bound on the zero-dimension \cite[\S7, p.~659]{cfpz}. Even for morphic words it remains open whether \(d_0(x)\) is always finite, that is, whether boundedly many pieces can suffice with \(O(1)\) dictionary words of each length. \begin{thebibliography}{99} \bibitem{as} J.-P. Allouche and J. Shallit, \emph{Automatic Sequences: Theory, Applications, Generalizations}, Cambridge University Press, 2003, \href{https://doi.org/10.1017/CBO9780511546563.008}{Ch.~7}. \bibitem{cfpz} J. Cassaigne, A. E. Frid, S. Puzynina and L. Q. Zamboni, \href{https://doi.org/10.24033/bsmf.2794}{Cost and dimension of words of zero topological entropy}, Bull. Soc. Math. France \textbf{147} (2019), 639--660. \href{https://arxiv.org/abs/1607.04728}{arXiv:1607.04728}. \bibitem{cmn} J. Cassaigne, C. Mauduit and F. Nicolas, \href{https://arxiv.org/abs/0804.1327}{Asymptotic behavior of growth functions of D0L-systems}, arXiv preprint 0804.1327, 2009. \bibitem{cn} J. Cassaigne and F. Nicolas, \href{https://doi.org/10.1017/CBO9780511777653.005}{Factor complexity}, in \emph{Combinatorics, Automata and Number Theory}, Cambridge University Press, 2010. \bibitem{cobham} A. Cobham, \href{https://doi.org/10.1109/SWAT.1968.20}{On the Hartmanis--Stearns problem for a class of tag machines}, Ninth Annual Symposium on Switching and Automata Theory (1968), 51--60. \bibitem{order} R. Deviatov, \href{https://doi.org/10.1007/978-3-540-79709-8_17}{On subword complexity of morphic sequences}, Computer Science in Russia, LNCS \textbf{5010} (2008), 146--157. \bibitem{dev} R. Devyatov, \href{https://doi.org/10.17323/1609-4514-2018-18-2-211-303}{On factor complexity of morphic sequences}, Mosc. Math. J. \textbf{18} (2018), 211--303. \bibitem{durand} F. Durand, \href{https://doi.org/10.4171/JEMS/294}{Cobham's theorem for substitutions}, J. Eur. Math. Soc. \textbf{13} (2011), 1799--1814. \bibitem{pansiot} J.-J. Pansiot, \href{https://doi.org/10.1007/3-540-13345-3_34}{Complexit\'e des facteurs des mots infinis engendr\'es par morphismes it\'er\'es}, ICALP, LNCS \textbf{172} (1984), 380--389. \bibitem{ss} A. Salomaa and M. Soittola, \href{https://doi.org/10.1007/978-1-4612-6264-0}{Automata-Theoretic Aspects of Formal Power Series}, Springer, 1978. \bibitem{smith} T. Smith, \href{https://arxiv.org/abs/1903.09905}{A characterization of morphic words with polynomial growth}, Discrete Math. Theor. Comput. Sci. \textbf{22}(1), (2020), paper 3. \href{https://doi.org/10.23638/DMTCS-22-1-3}{doi:10.23638/DMTCS-22-1-3}. \end{thebibliography} \end{document}