\documentclass[11pt,a4paper]{article} \usepackage[margin=1.05in]{geometry} \usepackage{amsmath,amssymb,amsthm} \usepackage[hidelinks]{hyperref} \newtheorem{theorem}{Theorem} \newtheorem{lemma}[theorem]{Lemma} \newtheorem{proposition}[theorem]{Proposition} \newcommand{\floor}[1]{\lfloor #1\rfloor} \newcommand{\ceil}[1]{\lceil #1\rceil} \hypersetup{pdftitle={A quadratic alphabet threshold for non-overlapping codes},pdfauthor={Peiwei Wu and Qian Peng}} \title{A quadratic alphabet threshold for non-overlapping codes} \author{Peiwei Wu \qquad Qian Peng\thanks{Corresponding author.}\\[0.5ex] \small The University of Melbourne} \date{} \begin{document} \maketitle \begin{abstract} Let $q_0(n)$ be the least integer such that every alphabet of size $q\ge q_0(n)$ admits a partition $I\sqcup J$ for which $I^{n-1}J$ is a maximum non-overlapping code of length $n$. Chee proved that $q_0(n)$ exists. We prove $q_0(n)=n^2/2+O(n)$ and the finite bound $q_0(n)\le4n(n-1)$. The upper bound compares a uniform loss in the real partition relaxation with the cost of rounding a single alphabet split. Moving one two-letter word between parts produces an infinite family of exceptions and disproves a conjecture of Stanovnik, Mo\v{s}kon and Mraz. We determine the maximum for every alphabet size at lengths five and six. Their thresholds are $4$ and $10$, respectively. At length six the exceptional alphabet sizes are $2,3,4,9$. On nine symbols the maximum is $33{,}872$, exceeding the best $I^5J$ code by 258. \end{abstract} \section{The alphabet threshold} A code $C\subseteq\Sigma^n$ is \emph{non-overlapping} if a nonempty proper prefix of a word in $C$ never equals a suffix of another word in $C$ or of the same word. Let $S_n(q)$ denote the largest size of such a code when $|\Sigma|=q$. For any partition $\Sigma=I\sqcup J$ into nonempty parts, $I^{n-1}J$ is non-overlapping. The best size given by these Blackburn codes is \[ B_n(q)=\max_{1\le sn\bigl(\floor{n/2}-2\bigr)+\ceil{n/2}. \] For $n\ge564$, $q_0(n)\le\floor{n^2/2+143n}+1$. In particular, $q_0(n)=n^2/2+O(n)$. \end{theorem} Stanovnik, Mo\v{s}kon and Mraz conjectured that some maximum partition code has $R_i=\varnothing$ for all $i>1+n/(q+1)$, in the notation of~\eqref{eq:levels}. For $q\ge n$ this forces every right part above the first level to be empty and gives $S_n(q)=B_n(q)$~\cite[Conjecture~1 and Remark~3]{SMM}. An example of length six already contradicts that prediction. At lengths two, three and four the maximum equals $B_n(q)$ over every alphabet~\cite{Blackburn,SMM}. The next two lengths admit complete classifications. \begin{theorem}\label{th:five} $S_5(2)=2$, $S_5(3)=17$, and $S_5(q)=B_5(q)$ for all $q\ge4$. Thus $q_0(5)=4$. \end{theorem} \begin{theorem}\label{th:six} For $q\ge2$, one has $S_6(q)=B_6(q)$ except at four alphabet sizes, whose maxima are given below. \[ \begin{array}{c|rrrr} q&2&3&4&9\\\hline S_6(q)&3&41&251&33{,}872\\ B_6(q)&1&32&243&33{,}614 \end{array} \] In particular, $q_0(6)=10$. \end{theorem} Table~1 of~\cite{SMM} already gives the maxima for $2\le q\le6$ at both lengths, including the first three exceptional values in Theorem~\ref{th:six}. The accompanying data give an optimal ternary partition at length five with a single-word split at level two, up to reversal~\cite{SMMdata}. Theorems~\ref{th:five} and~\ref{th:six} extend these tables to every alphabet size. \section{An exceptional alphabet for every large length} We use the construction of Fimmel et al.~\cite{Fimmel} in the form analyzed by Stanovnik, Mo\v{s}kon and Mraz~\cite[Construction~6]{SMM}. Partition $W_1=\Sigma$ into $L_1,R_1$. For each $i\ge2$, form \begin{equation}\label{eq:levels} W_i=\bigcup_{j=1}^{i-1}L_jR_{i-j}, \qquad W_i=L_i\sqcup R_i\quad (in-2$ for $n\ge12$. The continuous maximum of $f(s)=s^{n-1}(q-s)$ occurs at $s_*=q(n-1)/n$, with $s_*-a=1-d/n\in(0,1/2]$. In fact $a$ is an integer maximizer. The identity $f'(s)=ns^{n-2}(s_*-s)$ shows that for equal distances from $s_*$ the loss to the right is at least the loss to the left. Since $a+1$ is at least as far from the peak as $a$, $f(a+1)\le f(a)$, and unimodality handles the other integers. Write $v_j=r_j/a^{j-1}$. Then $v_1=b$, $v_2=b-1/a$ and $v_j=v_{j-1}+v_{j-2}/a^2$. All terms are at least $b-1/a$. Summing the increments from $j=3$ to $n$ yields \[ v_n\ge b-\frac1a+\frac{(n-2)(b-1/a)}{a^2} = b+\frac{1}{a^2}-\frac{n-2}{a^3}>b . \] It follows that $r_n>ba^{n-1}=B_n(q)$, so $q_0(n)>q$. Dividing this choice of $q$ by $n^2$ gives $\liminf_{n\to\infty} q_0(n)/n^2\ge1/2$. \end{proof} \section{A uniform loss for moderate partitions} Normalize each level cardinality in~\eqref{eq:levels} by dividing it by $q^i$ and retain the notation $l_i,r_i,w_i$ for the normalized quantities. Write $a=l_1$, $b=r_1$, $M=w_n$; thus $a+b=1$. Put \[ c=\frac{n-1}{n},\qquad m=\frac{1}{n-1},\qquad \delta=\frac{1}{2n(n-1)},\qquad \beta(x)=x^{n-1}(1-x). \] If $\max(a,b)\ge (n-2)/(n-1)$, Chee's skew-partition theorem gives $M\le B_n(q)/q^n$~\cite[Theorem~III.2]{Chee}. For the remaining partitions, both $a$ and $b$ lie in $[m,c-2\delta]$. We call these partitions moderate; the following estimate also holds at the endpoints. Let $L(z)=\sum_{i=1}^{n-1} l_i z^i$, let $\rho>0$ satisfy $L(\rho)=1$, and put $t=1/\rho$. Chee's root identity~\cite[Lemma~II.5]{Chee} reads \begin{equation}\label{eq:root} M=\beta(t)-D,\qquad D=\sum_{\substack{1\le i,jn}} l_i r_j\rho^{i+j-n}. \end{equation} For a nonempty code $M>0$, so $01$. The identity is valid in either orientation of the partition, using the corresponding $L$ and $\rho$. \begin{lemma}\label{lem:gap} If $q\ge2n$ and a moderate partition attains $S_n(q)$, then \[ \beta(c)-M\ \ge\ \frac{1}{96n(n-1)^2}. \] \end{lemma} \begin{proof} First, choose $s=\ceil{qc}$. Then $s/q\ge c$ and $1-s/q\ge1/(2n)$. Since $c^{n-1}\ge1/3$, the Blackburn code of this split has normalized size at least $1/(6n)$, so $M\ge1/(6n)$. We use $(1+1/j)^j\le e<3$ for positive integers $j$. Suppose the endpoint terms $ar_{n-1}+bl_{n-1}$ in $w_n$ account for at least $M/2$. Since $a+b=1$, one of $r_{n-1},l_{n-1}$ is at least $M/2$. Reverse the partition if needed to arrange $r_{n-1}\ge M/2$, then take the root in~\eqref{eq:root}. The terms with $j=n-1$ give \[ D\ge r_{n-1}\sum_{i=2}^{n-1} l_i\rho^{i-1} = r_{n-1}(t-a). \] If $t\ge c-\delta$, then $t-a\ge\delta$ and $\beta(c)-M\ge M\delta/2$. If $tB_n(q)$, Chee's skew-partition theorem makes it moderate. Put \[ \Delta=\beta(c)-M,\qquad P=c^{n-2},\qquad F=\sum_{i=2}^{n-2} l_i r_{n-i}. \] The root identity gives $0\le D\le\Delta$. Let $s$ be a nearest integer to $qc$. The rounding estimate of Section~3 gives $\Delta\le n/(8q^2)\le1/(2n^3)$. For $i+j=n$, $i,j\ge2$, use $w_{i+1}\ge b l_i$ and $w_{j+1}\ge a r_j$ in the interior argument of Lemma~\ref{lem:gap}. Select $l_{i+1}r_j$ if $l_{i+1}\ge b l_i/2$, and otherwise select $l_i r_{j+1}$ if $r_{j+1}\ge a r_j/2$. In the remaining case $l_{j+1}r_{i+1}\ge ab l_i r_j/4$. Each choice is at least $ab l_i r_j/4$, with multiplicity at most two. Hence $D\ge abF/8$. Moderateness gives $ab\ge m(1-m)\ge1/[2(n-1)]$, so $F\le16(n-1)\Delta=O(n^{-2})$. The endpoint terms sum to $M-F=a r_{n-1}+b l_{n-1}$. Reverse the partition if necessary so that $r_{n-1}\ge M-F$, and use the root $\rho$ of this orientation. Reversal preserves $M$ and $F$. The root equation gives $t\ge a$, and the terms with $j=n-1$ in~\eqref{eq:root} give $D\ge(M-F)(t-a)$. Write $u=n^2(c-t)$. For $n\ge4$ we have $|u|\le3$. Indeed, if $t0$, $q=a+b$. Write $x=l_2$, $y=r_2=ab-x$, and $T=ay+bx=w_3$. With $u=l_3$ and $s=l_4$ the last two levels obey \[ w_4=a(T-u)+xy+bu,\qquad w_5=a(w_4-s)+x(T-u)+uy+bs. \] At fixed $x,u$ the coefficient of $s$ is $b-a\le0$, so $s=0$ maximizes $w_5$. The remaining expression is affine in $u$. Its two endpoint values, at $u=0,T$ respectively, are \begin{align*} F_0(x)&=a^4b+a^2(3b-a)x-(2a-b)x^2,\\ F_1(x)&=2a^3b^2-2ab(a-b)x-bx^2 . \end{align*} The maximum for the split is therefore $\max_{0\le x\le ab}\max(F_0(x),F_1(x))$, with $x$ integral. When $a\ge3b$, both polynomials are at most $a^4b$. When $b\le a\le3b$, both are at most $81q^5/1024$. For $F_1$ this follows by bounding it by $2a^3b^2$, whose maximum for real $a+b=q$ is $216q^5/3125$. For $F_0$, complete the square to obtain \[ F_0(x)\le\frac{a^4((a+b)^2+4b^2)}{4(2a-b)}. \] To compare this with $81q^5/1024$, multiply through by the positive denominators. The required nonnegative difference factors as \[ \begin{split} &81(2a-b)(a+b)^5-256a^4((a+b)^2+4b^2) \\ &\quad=(3b-a) \bigl(94a^5+65a^4b+260a^3b^2-30a^2b^3-90ab^4-27b^5\bigr). \end{split} \] The three subtracted terms have sum at most $147a^3b^2$. If $[3q/4,4q/5]$ contains an integer $s$, then $s^4(q-s)\ge81q^5/1024$ by monotonicity up to $4q/5$. This condition holds whenever $q=4h+5j$ with $h,j\ge0$, by taking $s=3h+4j$. It covers $q=4,5,8,9,10$ and every $q\ge12$ (use $12,13,14,15$ and add fours). For $q=6,11$ use $s=5,9$ respectively; direct substitution gives the same lower bound. The remaining small splits are displayed below. Each $F_0$ maximum is obtained from the integer or integers nearest its vertex in $[0,ab]$, and $F_1$ is maximized at zero. \[ \begin{array}{c|c|r|r} q&a&\max F_0&\max F_1\\\hline 2&1&2&2\\ 3&2&17&16\\ 7&4&1088&1152\\ 7&5&1268&1000\\ 7&6&1296&432 \end{array} \] For $q=7$ the maximum is $6^4=B_5(7)$. Every endpoint partition used in the calculation is feasible in~\eqref{eq:levels}, which gives equality in the two exceptional cases as well. \end{proof} \section{Exact optimization at length six} \begin{proof}[Proof of Theorem~\ref{th:six}] We first realize the exceptional sizes. For $q=2$ use the words $001011$, $001101$ and $001111$. Their one-letter prefixes and suffixes differ. At lengths two through five, each prefix starts with $00$, which occurs only at the start of each word. For $q=3,4$ use the single marked pair of Section~2 with $a=q-1$ and $b=1$. Then $r_2=a-1$ and $r_j=ar_{j-1}+r_{j-2}$, giving $r_6=41,251$, respectively. For $q=9$, let $I=\{0,\ldots,6\}$ and $J=\{7,8\}$. Take all words starting in $I$ and ending in $J$ such that every interior letter from $J$ is a 7 immediately preceded by 0 or 1. Exclude the two endings 07 and 17. Any proper prefix ending in $J$ ends with one of these pairs, so it cannot equal a suffix. The first two counts are $r_1=2$ and $r_2=12$. Removing either one initial letter from $I$ or one of the two marked pairs gives $r_j=7r_{j-1}+2r_{j-2}$. Thus $r_6=33{,}872$. With just the pair 07 the recurrence in Section~2 gives $33{,}851$, which already exceeds $B_6(9)$ and refutes Conjecture~1 of~\cite{SMM}. For the upper bound it suffices by Theorem~\ref{th:threshold} to treat $2\le q<120$. Reverse the partition if necessary to ensure $a=l_1\ge b=r_1>0$. Put $x=l_2$, $y=ab-x$, $T=ay+bx=w_3$ and $u=l_3$. Then \[ w_4=a(T-u)+xy+bu. \] At level five we may place all words on the right, since the coefficient of $l_5$ in $w_6$ is $b-a\le0$. For a fixed $u$, a word assigned to $R_4$ has coefficient $a^2+x$ in $w_6$, whereas one assigned to $L_4$ has coefficient $ab+y$. Hence with $D=\max(a^2+x,ab+y)$ the largest objective for these three initial splits is \begin{align*} D w_4+a\bigl(x(T-u)+uy\bigr)+u(T-u) &= A+Ku-u^2,\\ A &= D(aT+xy)+axT,\\ K &= D(b-a)+a(y-x)+T. \end{align*} For nonnegative integral $u$ this is at most $A+\floor{\max(K,0)^2/4}$. The following integer calculation evaluates that upper bound at every remaining $q,a,x$ and records just the strict excesses over $B_6(q)$. \begin{verbatim} exceptions = {} for q in range(2, 120): B = max(s**5 * (q-s) for s in range(1, q)) U = 0 for a in range((q+1)//2, q): b = q-a for x in range(a*b+1): y = a*b-x T = a*y+b*x D = max(a*a+x, a*b+y) A = D*(a*T+x*y)+a*x*T K = D*(b-a)+a*(y-x)+T U = max(U, A+max(K,0)**2//4) if U > B: exceptions[q] = U \end{verbatim} The four entries are $(2,3),(3,41),(4,251),(9,33872)$. The constructions above attain all four bounds. For every other $q$ a Blackburn split attains the upper bound. \end{proof} \paragraph{Formal verification.} The accompanying Lean~4 development defines a code as a finite set of words, constructs the Blackburn codes and the exceptional family of Section~2, and verifies the bounds and limiting ratio for the least threshold $q_0(n)$. It also certifies the maximum at lengths five and six for every alphabet size. For the finite calculation at length six, it bounds the quadratic envelope on intervals of $x$, subdividing any interval until its bound is at most the claimed maximum. For the upper bound the formal proof constructs integer layer counts that dominate each actual code $C$. Begin with each codeword split into single letters. Label a block left if it is a prefix of a word of $C$ and right otherwise. While at least two blocks remain, the first is left and the last is right by non-overlap. Merge an adjacent left--right pair and repeat. This parses every codeword. Counting possible pairs bounds the number of parsed words of length $i$ by the convolution of the shorter left and right counts. Keep the left counts and increase the right counts successively until equality holds in the recurrence. Induction then bounds $|C|$ by the final convolution. This argument permits multiple parses of a word. Lean applies the verified root identity, skew estimate and moderate-partition bounds to the resulting integer profile. The Lean source is available in the \href{https://github.com/PEIWEIWU-AYS/non-overlapping-codes-blackburn-threshold/tree/v1.1.0}{proof repository, version 1.1.0}, and archived with the earlier preprint at \href{https://doi.org/10.5281/zenodo.24590143}{doi:10.5281/zenodo.24590143}. \paragraph{Author contributions and use of AI.} Peiwei Wu and Qian Peng contributed to the research ideas, discussed the mathematical arguments, and reviewed the manuscript and its results. They used OpenAI Codex to develop the mathematical derivations, draft the manuscript, and write the accompanying Lean formalization. \begin{thebibliography}{9} \raggedright \bibitem{Blackburn} S.~R. Blackburn, Non-overlapping codes, \emph{IEEE Trans. Inform. Theory} \textbf{61} (2015), 4890--4894. \href{https://doi.org/10.1109/TIT.2015.2456634}{doi:10.1109/TIT.2015.2456634}. \bibitem{Chee} Y.~M. Chee, A proof of Blackburn's conjecture on non-overlapping codes, 2026. \href{https://arxiv.org/abs/2611.28776v2}{arXiv:2611.28776v2}. \bibitem{Fimmel} E.~Fimmel, C.~J. Michel, F.~Pirot, J.-S. Sereni and L.~Str\"ungmann, \href{https://ajc.maths.uq.edu.au/pdf/86/ajc_v86_p233.pdf}{Diletter and triletter comma-free codes over finite alphabets}, \emph{Australas. J. Combin.} \textbf{86} (2023), 233--270. \bibitem{SMM} L.~Stanovnik, M.~Mo\v{s}kon and M.~Mraz, In search of maximum non-overlapping codes, \emph{Des. Codes Cryptogr.} \textbf{92} (2024), 1299--1326. \href{https://doi.org/10.1007/s10623-023-01344-z}{doi:10.1007/s10623-023-01344-z}. \bibitem{SMMdata} L.~Stanovnik, M.~Mo\v{s}kon and M.~Mraz, \href{https://github.com/magdevska/nono-codes}{Computational data for \emph{In search of maximum non-overlapping codes}}, dataset accompanying~\cite{SMM}. \end{thebibliography} \end{document}