Manuscript Offprint
arXiv:2610.07828Shuffle Squares in Differentiable Words
Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.
MICHAL ZWIERZYŃSKI
Warsaw University of Technology
Faculty of Mathematics and Information Science
ul. Koszykowa 75
00-662 Warsaw, Poland
ABSTRACT. Experiments on binary run-length differentiability lead to sharp computer-assisted criteria for shuffle squares. Every -word of length greater than 16 is a shuffle square exactly when both letter multiplicities are even. All 34 nonempty even-Parikh exceptions are smooth and persist in every higher differentiability class. For the sharp threshold is 48, with 212 nonempty exceptions. At level no global parity threshold exists, but every even-Parikh non-shuffle-square of length at least 36 has proper nonempty shuffle-square prefixes and suffixes. Exactly 230 nonempty even-Parikh -words have no nonempty shuffle-square prefix. The full tree avoiding such prefixes eventually consists of 422 periodic rays. Consequently, a nonempty Kolakoski prefix is a shuffle square exactly when both multiplicities are even, apart from lengths 4 and 8. We also characterize classes of morphisms reflecting shuffle squares. For doubly binary words, we determine the exact deletion distance and largest twins, and prove sharp bounds for single local repairs. Exact recurrences, residual-state checks, and separate Python programs make the finite computations reproducible.
CONTENTS
- Introduction 2
- Shuffle squares and an exact residual-state test 4
- Run-length encoding and differentiability classes 7
- Even prefixes of the Kolakoski word 10
- Shuffle squares in finite differentiability classes 11
- Bounded local factorizations 18
- Characterization of all shuffle-square prefixes 21
- Morphisms reflecting shuffle squares 22
- Local repairs and largest twins in doubly binary words 26
- Scope of the computer assistance 33
Statements and Declarations 34
References 34
E-mail address: Michal.Zwierzynski@pw.edu.pl, ORCID: 0000-0002-9627-1563.
2020 Mathematics Subject Classification. 68R15, 11B83, 68Q45.
Key words and phrases. shuffle square, smooth word, Kolakoski word, run-length encoding, local factorization, computer-assisted proof.
Recognizing shuffle squares is NP-complete even over a binary alphabet [3]. He, Huang, Nam, and Thaper [11] obtained enumerative results and conjectured that almost all binary words with even Parikh vector are shuffle squares. He and Post [12] proved this conjecture. Our results give sharp criteria valid for every sufficiently long word in specified finite differentiability classes.
The classical Kolakoski word is the self-generating binary word equal to its own sequence of run lengths. It was already studied by Oldenburger in 1939 [19] and was later posed as Problem 5304 by Kolakoski [15]. For this reason the name Oldenburger–Kolakoski word is also used. We take the version beginning with 1:
(1)
where denotes run-length encoding. See [20] for a survey and [17] for extensive data and references.
The work of Grytczuk, Pawlik, and Ruciński develops structural and algorithmic aspects of shuffle squares [9, 10]. In its expanded version, the authors study prefixes of the Kolakoski word and formulate Problem 1 concerning the characterization of shuffle squares among doubly binary words [10, Section 6.1]. This problem motivated the present investigation. Although we do not resolve it in full, we obtain partial answers for several natural subclasses and determine exactly which prefixes of the Kolakoski word are shuffle squares.
The starting point was an experimental comparison between the parities of the letter counts and exact shuffle-square recognition for finite Kolakoski prefixes. The short words at lengths 4 and 8 are obstructions, while the first shuffle-square prefix has length 16. The subsequent agreement with the parity condition suggested that these two obstructions might be the only ones. To understand why, we moved from individual prefixes to exhaustive searches in the larger languages of smooth and finitely differentiable words. These searches make it possible to study a local obstruction at every position and then use it in a proof for arbitrary lengths.
For , write
For a finite binary word and , let denote the number of occurrences of in . The pair is the Parikh vector of , in the standard terminology of combinatorics on words [16]. We call this vector even when both coordinates are even.
We use the mnemonic notation
(2)
Thus EPK is the set of even-Parikh Kolakoski lengths. Its increasing enumeration is OEIS A398324 [18]:
(3)
4, 8, 16, 20, 24, 28, 34, 36, 40, 44, 48, 56, 60, 64, 66, 68, 72, 76, 80, ...
One consequence of our general finite-differentiability theorem is the following exact characterization.
Theorem 1.1. For every ,
The proof is given in Section 7, where we deduce the characterization from Theorem 1.2 below.
Finite differentiability provides a natural hierarchy in which to place a stronger statement. Smooth words, also called -words, form the smallest class considered here. The notion originates in Dekking's study of the factor language of the Kolakoski word (see [2, 5, 6, 8, 21]). The argument combines elementary closure and factorization properties with finite computations specified by exact recurrences and pseudocode. The accompanying programs reproduce these computations without external data.
Theorem 1.2. Let and . Then is a shuffle square if and only if
The bound 16 is sharp. Moreover, exactly 34 nonempty even-Parikh -words are not shuffle squares, and all of them are smooth.
The proof is given in Section 5.1.
Since ( ), Theorem 1.2 immediately applies to every -word with , and in particular to every smooth word. The set of nonempty exceptions is the same in all these classes because all -exceptions are themselves smooth. The next level behaves differently but still admits a complete finite answer. By Theorem 5.7, every -word of length greater than 48 satisfies the same parity criterion, the threshold 48 is sharp, and precisely 212 nonempty even-Parikh -words fail to be shuffle squares. At the level, the odd-ABBA family gives arbitrarily long even-Parikh exceptions. Nevertheless, Theorem 5.8 below reduces every sufficiently long exception from either end.
Theorem 1.2 applies to every sufficiently long factor, not merely to a prefix of K. Its induction is driven by the universal length-24 lemma: every -word of length 24 has nonempty shuffle-square prefixes and suffixes. The finite induction base consists of all even-Parikh -words of the twelve even lengths from 18 through 40.
The length-24 lemma has additional local-to-global consequences which do not require an even Parikh vector. It produces bounded-block greedy factorizations in every class with , and from every position in any right-infinite word whose length-24 factors lie in . These statements isolate precisely which parts of the argument are specific to K: the final identification and the sharper gap bound for its even-Parikh prefixes.
The decisive experimental object is the tree of words having no nonempty shuffle-square prefix. At levels and , this tree terminates at lengths 24 and 40, respectively. These finite observations suggest the bounded local lemmas that drive the proofs. At level , the tree instead settles at 422 surviving words per level. Inspecting their continuations reveals the periods 1122 and 2211. Mere stabilization of the counts would not prove eventual periodicity. The residual loops and exits extracted from these experiments form the basis of the finite verification below. Thus each observed pattern leads to a specific mathematical step: a local factorization, an exhaustive extension reduction, or a pumping argument.
Two further directions extend the structural picture. Section 8 studies nonerasing morphisms which reflect shuffle squares. Odd powers and private symbols yield a complete classification for alphabets of equal size. For disjoint private pairs, the ordered-graph method of [10] gives an exact three-run criterion and a sufficient condition for images with more runs. Section 9 determines the deletion distance and largest twins in every doubly binary word. It also proves that each even-Parikh exception admits one adjacent transposition or equal-pair deletion near either endpoint, with sharp windows of 10 and 11 positions. A transposition preserving needs a sharp window of 15 positions, while an equal pair can be inserted before a suffix of length at most 6. Four balanced appended letters always suffice for completion.
All computer assistance is finite and explicit. The and bad-prefix trees used for the bounded local lemmas have 175 and 823 nodes, respectively. The bad-prefix tree is infinite but becomes a union of 422 verified periodic rays. Every finite search and pumping argument is specified by a displayed recurrence, exact counts, and pseudocode.
The shuffle-square recognizers are proved exact. Complete executable implementations are supplied as separate computational files, described in Section 10, while the recurrences, pseudocode, decisive counts, and proofs remain in the article.
Kory Kilpatrick independently proved the smooth-word parity theorem, including the classification of the 34 exceptions, and the Kolakoski prefix characterization in his preprint [14]. We learned of this independent work through private correspondence with Jarosław Grytczuk and Bartłomiej Pawlik. Kilpatrick's proof uses a factorization into parity-return atoms and a finite computational verification. Our proofs use trees of words avoiding shuffle-square prefixes and residual transitions, and establish the results above for the larger finite differentiability classes , , and .
2. SHUFFLE SQUARES AND AN EXACT RESIDUAL-STATE TEST
Throughout, the alphabet is . If , its length is . The empty word is denoted by . Here, a Parikh vector is called even if each of its coordinates is even, or equivalently, if every letter occurs an even number of times. For example, 1221 has Parikh vector , so it is even, whereas 122112 has Parikh vector , whose coordinates are odd.
Definition 2.1 ([16]). Let . The word is a factor of if there are words such that
Thus a factor is a contiguous subword. It is a prefix when one can take , and a suffix when one can take . Empty factors, prefixes, and suffixes are allowed unless “nonempty” is stated. For example,
so 211 is a factor. The word 122 is a prefix, while 112 is a suffix.
Definition 2.2 ([16]). For a word , its reversal is the word
Its binary complement is obtained by interchanging 1 and 2 in every position. We put . For example,
Directly from the definition, and .
For a set , put
The next definition is the standard positional formulation of the notion introduced by Hen-shall, Rampersad, and Shallit [13].
Definition 2.3 ([13]). A nonempty word is a shuffle square if there is a partition
such that . The common word is called a shuffle-square root of w. Either set I or J is called a support of one copy of the root.
The terminology root agrees with the usage in the recent literature (see, for example, Datko and Pawlik [7]).
Equivalently, the letters of w can be colored red and blue so that the red subword and the blue subword, read in their original order, coincide.
Example 2.4. Consider
Take and . Then . Thus is a shuffle square.
We record the following elementary lemma, whose proof is immediate from the definition.
Lemma 2.5. If w is a shuffle square, then is even for every letter a. In particular, every shuffle square has even length.
The converse is false, even over a binary alphabet.
Example 2.6. The word 1221 contains two copies of each letter but is not a shuffle square. A root would have one 1 and one 2, so it would be either 12 or 21. The last 1 cannot belong to a copy of 12, and the first 1 cannot belong to a copy of 21.
We shall repeatedly use the following elementary closure properties.
Lemma 2.7. Let u and v be shuffle squares.
(i) Their concatenation uv is a shuffle square.
(ii) Their reversals rev(u) and rev(v) are shuffle squares.
(iii) Their binary complements and are shuffle squares.
Proof. If is a self-shuffle of and is a self-shuffle of , then the two chosen copies in followed by the corresponding two copies in show that is a self-shuffle of . Reversing a coloring that decomposes into two copies of gives a coloring that decomposes into two copies of . Applying the same letter permutation to both copies gives a coloring of by two copies of , and similarly for .
2.1. An exact recognizer. We recall the queue-automaton characterization of shuffle squares from [4, Section 2]. The sets of residual words below are the buffer sets of He and Post, and recurrence (4) is their Proposition 2.1 [12]. The queue interpretation also appears in [14, Lemma 2.4]. We include a proof and explicit pseudocode to make the subsequent finite verifications self-contained.
For , define finite sets of residual words recursively. The initial state is
and, for ,
(4)
The intended interpretation is as follows. After the first i letters have been assigned to two prospective copies, the two partial subwords must be prefix-comparable in any assignment that can eventually succeed. If the longer one equals the shorter one followed by q, then q is the residual word. The identity of the longer color is irrelevant by symmetry. The next letter may be appended to the longer copy, changing q to , or it may be appended to the shorter copy, which is possible exactly when it matches the first letter of q.
Proposition 2.8. A nonempty word w is a shuffle square if and only if .
Proof. Suppose first that a coloring of the first positions has produced two prefix-comparable subwords. Removing their common prefix leaves a unique residual word , together with the information of which color is longer. Appending to the longer color gives the first transition in (4). Appending it to the shorter color is possible precisely if it cancels the first letter of , giving the second transition. Thus every path in the recurrence records an actual partial coloring, and every prefix-comparable partial coloring gives such a path.
In any successful coloring, both partial subwords after i positions are prefixes of the same final root. Hence they are necessarily prefix-comparable. At the end they are equal exactly when the residual word is empty. This proves both implications.
Remark 2.9. Suppose and a residual is present after letters. Every subsequent transition changes by exactly one. Therefore a state with cannot reach in the remaining steps and may be discarded without changing whether the final empty state is reachable.
All finite verifications below use precisely this logically lossless pruning together with the necessary parity test from Lemma 2.5.
For clarity, the complete decision procedure used in all later finite searches is given below. Its update before the pruning line is exactly recurrence (4). Throughout the listings, * denotes concatenation, epsilon denotes the empty word, and set operations discard repetitions. An assert statement checks the displayed condition and stops the verification if it fails.
procedure SHUFFLE-SQUARE(w) if w is empty or some letter multiplicity is odd then return false Q <- {epsilon} for i <- 1,...,length(w) do NEXT <- {qw_i : q in Q} NEXT <- NEXT union {r : q = w_ir for some q in Q} Q <- {q in NEXT : length(q) <= length(w)-i} return (epsilon is in Q)
LISTING 1. The exact residual-state recognizer
Listing 1 is therefore a literal implementation of Proposition 2.8, including the lossless pruning from Remark 2.9.
For the larger enumeration it is convenient to process a whole run at once. We record an equivalent exact test closely related to the canonical-twins representation in [10]. For a word , a pair of perfect twins is a pair of disjoint sets of positions such that and, writing and , one has
Thus, the two induced subwords are equal and together use every position of w. We call such a pair canonical if, within each run of w, all positions assigned to the first copy precede all positions assigned to the second copy.
Proposition 2.10. The procedure in Listing 2 returns true exactly for the nonempty shuffle squares.
procedure RUN-SHUFFLE-SQUARE(w) if w is empty or some letter multiplicity is odd then return false R <- {epsilon} for each run a^r of w, from left to right, do NEXT <- empty set for q in R and x <- 0,...,r do y <- r-x z <- q*a^x if z begins with a^y then insert z with that prefix removed into NEXT R <- {q in NEXT : length(q) <= number of unprocessed letters} return (epsilon is in R)
LISTING 2. The exact run-capacity recognizer
Proof. Every shuffle square admits a canonical pair of perfect twins with for every . Indeed, pair the positions carrying corresponding letters of the two equal copies and replace each pair by its left and right endpoint. Since the two original support sequences are increasing, the sequences of left and right endpoints are also increasing, and both still induce the same word. If within one run a second-copy position precedes a first-copy position, interchange their assignments. The letters are equal, so neither induced word changes. Moreover, the first-copy count at every initial cut can only increase. Repeating removes all such inversions.
Now scan the canonical pair just constructed from left to right. The partial second copy is always a prefix of the partial first copy. Let be the unmatched suffix. A run is split into assigned to the first copy followed by assigned to the second, where . After the first assignment the unmatched word is . The second assignment is possible exactly when begins with , and deleting this prefix gives the new residual. This is precisely one transition of Listing 2. A residual longer than the unprocessed part cannot be cancelled and is discarded without loss, exactly as in Remark 2.9. Thus canonical perfect twins give a path from to . Conversely, every such path specifies the splits of all runs and maintains the prefix invariant, hence constructs two equal subwords partitioning all positions.
Example 2.11. For , recurrence (4) gives
Since , the word is not a shuffle square. The same computation at length 4 gives , in agreement with Example 2.6.
For comparison, the positive example gives
Here . Indeed, the supports and both induce the root 12.
3. RUN-LENGTH ENCODING AND DIFFERENTIABILITY CLASSES
The finite derivative used in this section is due to Dekking [8]. Its purpose is to apply run-length encoding to a finite factor without pretending that its two endpoint runs are complete. The notation for words derivable arbitrarily many times was already standard in the work of Weakley and Carpi [5, 21]. Such words are now commonly called smooth words [2]. Recent literature sometimes says finite smooth or f-smooth to distinguish this notion from smooth infinite words (see [6, Section 1.2]).
Write a nonempty binary word in its run decomposition
Its run-length encoding is
For example,
The ordinary run-length encoding of a finite factor does not faithfully record a run cut at either endpoint. The finite derivative removes this boundary ambiguity.
Definition 3.1 ([8]). The finite derivative of a binary word is defined as follows. If one of the runs of has length greater than 2, then is undefined. Otherwise start with , delete its first symbol if that symbol is 1, and then delete its last symbol if that symbol is 1. A single symbol is deleted at most once. We also put .
Thus
On the other hand, , and the next derivative is undefined because 111 contains a run of length 3.
Definition 3.2. For an integer , let
We call a member of a -word. Thus , and the convention allows a derivative tower which reaches early to be continued indefinitely.
Definition 3.3 ([8, 21]). A finite binary word is smooth, or a -word, if its finite derivatives remain defined until the empty word is reached. Equivalently,
The first levels of the finite differentiability hierarchy are genuinely different. For example,
and the next derivative is undefined. Hence . Its complement 22122122 gives a second example.
A complete enumeration of the binary words through length 8 shows that these are the two shortest members of .
After relabelling the alphabet as , the doubly binary words of Grytczuk, Pawlik, and Ruciński [10] are precisely the -words. Their central odd-ABBA family illustrates the difference between and . In their alphabet the words are . With our labels put
Its run decomposition gives
Consequently, is smooth, whereas for . In particular, all odd-power members of their infinite non-shuffle-square family lie outside except for . Thus the result below is a complete solution of their Problem 1 on a proper subclass, but it does not settle the problem for all doubly binary words.
Definition 3.4 ([6, 8]). A right-infinite word is smooth if every iterate , , is a right-infinite word over . This is the infinite version of smoothness. It should be distinguished from the finite-word notion in Definition 3.3.
For finite words, smoothness is a finite condition because every nonempty defined derivative is shorter than its input. For instance, the first shuffle-square prefix in Example 2.4 has derivative tower
We record carefully the closure properties needed later. Factoriality is classical for smooth words (see [21, Proposition 2] and the modern account [6, Section 1.2.2]). The same endpoint argument works at every finite level. We include the proof so that the argument is self-contained for the precise convention in Definition 3.1.
Lemma 3.5 ([6, 21]). For every the following statements hold.
(i) Every factor of a -word is a -word.
(ii) A word w belongs to if and only if its reversal rev(w) belongs to , and whenever is defined,
(iii) A word w belongs to if and only if its complement belongs to .
The corresponding three assertions also hold for smooth words.
Proof. Let u be a factor of a word w whose derivative is defined. Every run of u, except possibly its first and last runs, is a complete run of w. If an endpoint run of u is only a one-letter fragment of a run of w, its run length 1 is deleted by D. If an endpoint run survives in , then it has length 2 and is therefore a complete run of w. Moreover, a one-letter endpoint run of w cannot survive as an interior run of u. It follows that
(5)
is a factor of ,
with the empty word allowed. Iterating (5) proves (i).
Reversal reverses the list of run lengths, while the two boundary deletions in Definition 3.1 are symmetric. Hence , and iteration proves (ii). Complementation does not change any run length, so whenever the derivative is defined. This proves (iii). Since every smooth word belongs to for every , and its derivative tower reaches , the same arguments give the final assertion.
The next factor-language inclusion was the original motivation for Dekking’s finite derivative. In the notation of [6, Section 1.2.3], it is the inclusion , where denotes the finite-factor language, the class of smooth infinite words, and the class of finite smooth words. We include the boundary argument, so the cited inclusion is not being used as an unproved black box.
Proposition 3.6 ([6, 8]). Every finite factor of a smooth right-infinite binary word is a finite smooth word.
Proof. Let u be a finite factor of a smooth right-infinite word X. Its endpoint runs may be truncated pieces of runs of X, and Definition 3.1 deletes exactly the ambiguous one-letter endpoint run lengths. All surviving run lengths are complete. Hence
with the empty word allowed. Applying the same argument successively gives
for every for which is nonempty. Since all letters in every belong to , each derivative is defined. A nonempty finite derivative is strictly shorter than its input, so the process reaches . Thus is finite smooth.
Since by (1), all iterates of are right-infinite words over . Thus, is smooth in the sense of Definition 3.4, and Proposition 3.6 immediately yields the following classical result.
Corollary 3.7 ([6, 8]). Every finite factor of the Kolakoski word K is smooth.
4. EVEN PREFIXES OF THE KOLAKOSKI WORD
Recall the set EPK from (2). Since , the following conditions characterize membership in EPK:
We first give an elementary strengthening of the infinitude assertion in OEIS A398324 given by Pawlik.
Proposition 4.1. The set EPK is infinite. If are consecutive elements of EPK, then
Proof. Group the letters of K into aligned pairs
When one passes from to , the parity of the number of ones changes exactly when is mixed, that is, when . An equal pair 11 or 22 leaves this parity unchanged.
Start at an element . If the next aligned pair is equal, then . Otherwise the next pair is mixed and the parity becomes odd. There cannot be three consecutive equal aligned pairs. Indeed, equal aligned pairs are full runs, since all runs of have length at most 2. Consecutive equal pairs must alternate between 11 and 22. Three consecutive equal pairs would therefore give three consecutive runs of length 2. Their run lengths would produce the factor 222 in , impossible because every run of has length at most 2.
Consequently, after a mixed pair, another mixed pair must occur within the next three aligned pairs. At that second mixed pair the parity returns to even.
Thus parity returns after at most four aligned pairs, proving . Since , the argument can be iterated indefinitely.
Example 4.2. The successive differences of the initial terms in (3) are
5. SHUFFLE SQUARES IN FINITE DIFFERENTIABILITY CLASSES
For and , put , and let be the set of -words of length having no nonempty shuffle-square prefix. Factoriality gives the exact recurrence
(6)
Here and below, writing means that is a nonempty shuffle square. Listing 3 is exactly recurrence (6).
procedure BAD-PREFIX-TREE(k, L) B[0] <- {epsilon} for n <- 0, ..., L-1 do B[n+1] <- empty set for w in B[n] and a in {1,2} do if wa is in C^k and wa is not a shuffle square then insert w*a into B[n+1] return B[0], ..., B[L]
LISTING 3. The pruned bad-prefix tree
For the unpruned level and parity checks we use Listing 4. The test SHUFFLE-SQUARE is the exact residual-state test in Listing 1. For each length , the output sets C[n], E[n], and N[n] contain, respectively, all -words, those with even Parikh vector, and those even-Parikh words that fail the shuffle-square test.
procedure PARITY-LEVELS(k, L) C[0] <- {epsilon} for n <- 0, ..., L-1 do C[n+1] <- {wa : w in C[n], a in {1,2}, wa is in C^k} E[n+1] <- {w in C[n+1] : both multiplicities in w are even} N[n+1] <- {w in E[n+1] : SHUFFLE-SQUARE(w) is false} return C, E, N
LISTING 4. Complete level and parity enumeration
5.1. Differentiability of order at least three. The local statement needed for the global induction already holds for .
Lemma 5.1. Every -word of length 24 has a nonempty shuffle-square prefix and a nonempty shuffle-square suffix.
Proof. Listing 3, with k = 3 and L = 24, gives precisely
Thus the complete tree has only 175 nodes and , proving the prefix assertion. The suffix assertion follows by reversal, using Lemmas 3.5(ii) and 2.7(ii).
For sharpness, put
(7)
The last nonempty level is
(8)
All four words are smooth, so the local constant 24 cannot be decreased even in the smooth subclass.

For the finite induction base, Listing 4 gives Table 1. The third column counts all even-Parikh words. The fourth records how many of them the exact recognizer rejects.
TABLE 1. The complete finite base for the parity theorem
| n | even | rejected | n | even | rejected | ||
|---|---|---|---|---|---|---|---|
| 18 | 284 | 134 | 0 | 30 | 3792 | 1856 | 0 |
| 20 | 440 | 232 | 0 | 32 | 5838 | 2970 | 0 |
| 22 | 674 | 324 | 0 | 34 | 8998 | 4438 | 0 |
| 24 | 1046 | 538 | 0 | 36 | 13822 | 6990 | 0 |
| 26 | 1600 | 778 | 0 | 38 | 21332 | 10550 | 0 |
| 28 | 2470 | 1266 | 0 | 40 | 32740 | 16524 | 0 |
total number of even-Parikh words tested = 46600
Proof of Theorem 1.2. Necessity is Lemma 2.5. For sufficiency, use strong induction over the even lengths. The twelve lengths 18, 20, ..., 40 are the complete base in Table 1. If , the length-24 suffix of belongs to by Lemma 3.5(i). Lemma 5.1 gives it a nonempty shuffle-square suffix with . Write . Both and have even Parikh vector, hence so does . Moreover, and . The induction hypothesis makes a shuffle square, and Lemma 2.7(i) then makes a shuffle square.
For sharpness, consider
(9)
It has eight occurrences of each letter and derivative tower
so it is smooth. The exact residual test rejects . In fact, . Hence the threshold cannot be lowered.
Finally, the complete calculation at the even lengths at most 16 gives exactly 34 nonempty even-Parikh -words rejected by the recognizer. Their distribution is
(10)
Direct iteration of the finite derivative verifies that every one of these 34 words is smooth.
Recurrence (6), Listings 3 and 4, the full bad-tree vector, and Table 1 give a finite verification for every exhaustive step used in this proof.
The single proof contains the smooth case and every intermediate finite differentiability class. For smooth words, the following criterion and exceptional set were also obtained independently in [14].
Corollary 5.2. For every , an even-Parikh -word of length greater than 16 is a shuffle square. The threshold 16 and the set of exactly 34 nonempty exceptions are the same for all and for smooth words.
Corollary 5.3. Let be either a finite -word for some , or a right-infinite smooth binary word. Every factor of with is a shuffle square if and only if its Parikh vector is even.
Proof. In the finite case, Lemma 3.5(i) makes a -word and hence a -word. In the right-infinite case, Proposition 3.6 makes smooth. Apply Theorem 1.2 and Lemma 2.5.
5.2. The class . At the next level, the local threshold increases from 24 to 40.
Lemma 5.4. Every -word of length 40 has a nonempty shuffle-square prefix and a nonempty shuffle-square suffix. The constant 40 is optimal.
Proof. Listing 3, with k = 2 and L = 40, gives
Thus the complete tree has 823 nodes and . This proves the prefix assertion, and reversal gives the suffix assertion. Finally,
(11) 122112112122122122112112112122122122112 = 122(112) (122) (112) (122) 112
belongs to , proving optimality.
The displayed complete vector, together with recurrence (6) and Listing 3, is a finite reproducible verification for this local lemma.
The local lemma also gives a bounded factorization at the level.
Corollary 5.5. Every finite -word w has a factorization
obtained by successively removing the shortest nonempty shuffle-square prefix, where every is a shuffle square satisfying , and the terminal remainder satisfies and . If , then is a shuffle square. Both the remainder bound 39 and the block bound 40 are sharp.
Proof. Repeatedly remove the shortest nonempty shuffle-square prefix. Every intermediate remainder and every removed block is a factor by Lemma 3.5(i). Lemma 5.4 bounds each chosen block by 40 and the terminal remainder by 39. Concatenation gives the last assertion about . The word in (11) proves sharpness of the remainder bound. Table 2 contains eight minimal suffix squares of length 40. Their reversals are minimal shuffle-square prefixes, proving sharpness of the block bound.
To obtain the sharp global parity threshold, let be the set of shuffle squares having no proper nonempty shuffle-square suffix. Lemma 5.4 implies
(12)
because the last 40 letters of a longer member would contain a proper shuffle-square suffix. A extension of a word in is a minimal shuffle-square prefix exactly when the extension itself is a shuffle square. Reversal converts minimal prefixes into minimal suffixes. This enumerates and gives , with the length distribution in Table 2.
Lemma 5.6. Let have even Parikh vector, suppose that is not a shuffle square, and assume . Then for some , where also has even Parikh vector and is not a shuffle square.
Proof. By Lemma 5.4, the length-40 suffix factor of has a nonempty shuffle-square suffix. Choose a shortest nonempty shuffle-square suffix of . Then and . Write . Since is not a shuffle square, , so is nonempty. Factoriality gives . Both and have even Parikh vector, hence so does . If were a shuffle square, then would be one by Lemma 2.7(i), a contradiction.
TABLE 2. Minimal shuffle-square suffixes
| length | number | length | number |
|---|---|---|---|
| 2 | 2 | 22 | 16 |
| 4 | 2 | 24 | 18 |
| 6 | 4 | 26 | 12 |
| 8 | 2 | 28 | 32 |
| 10 | 2 | 30 | 36 |
| 12 | 6 | 32 | 30 |
| 14 | 10 | 34 | 36 |
| 16 | 14 | 36 | 26 |
| 18 | 8 | 38 | 10 |
| 20 | 14 | 40 | 8 |
| total: 288 | |||
The reduction makes the classification finite. Let be the set of nonempty even-Parikh -words of length below 40 which are not shuffle squares, and define
Listing 5 constructs precisely these sets.
E[0] <- all nonempty even-Parikh C^2 non-shuffle-squares of length < 40 B <- BAD-PREFIX-TREE(2, 40) M <- empty set for n <- 1,...,40 and u in B[n-1] and a in {1,2} do v <- ua if v is in C^2 and v is a shuffle square then insert reverse(v) into M end for j <- 0,1 do CANDIDATES <- empty set for u in E[j] and s in M do if us is in C^2 and (j > 0 or length(us) >= 40) then insert us into CANDIDATES E[j+1] <- {w in CANDIDATES : SHUFFLE-SQUARE(w) is false}
LISTING 5. The finite extension verification for
The exact results are summarized in Table 3.
TABLE 3. Summary of the exhaustive computation for the class
| Quantity | Value |
|---|---|
| 208 | |
| Distinct candidates for | 13752 |
| 4 | |
| Distinct candidates for | 200 |
| 0 |
The four words in are , where
(15)
Notice that both representatives are palindromes.
Theorem 5.7. Let and . Then is a shuffle square if and only if its Parikh vector is even. The bound 48 is sharp. Moreover, there are exactly 212 nonempty even-Parikh -words which are not shuffle squares.
Proof. Only sufficiency requires proof. Listing 4 gives all 208 exceptions of length below 40. Lemma 5.6 shows that every longer exception can be reduced, by deleting a member of , to a shorter exception. Repeating eventually reaches , so every exception of length at least 40 belongs to one of the layers in (13). Listing 5 gives and , so there is no further layer. Thus the complete exceptional set is , of cardinality . Its longest members are and , proving both the criterion above length 48 and sharpness.
The finite verification consists of the proved reduction, the complete construction in Listing 5, and the five exact cardinalities displayed above. No unbounded search is being inferred from a cutoff.
For completeness, Table 4 gives the number of exceptions at every length where it is nonzero.
TABLE 4. Nonempty even-Parikh -words which are not shuffle squares
| n | n | n | |||
|---|---|---|---|---|---|
| 4 | 2 | 18 | 16 | 30 | 10 |
| 8 | 6 | 20 | 16 | 32 | 24 |
| 10 | 4 | 22 | 12 | 34 | 12 |
| 12 | 10 | 24 | 20 | 38 | 8 |
| 14 | 6 | 26 | 36 | 46 | 2 |
| 16 | 8 | 28 | 18 | 48 | 2 |
5.3. The class . The qualitative picture changes at the class studied by Grytczuk, Pawlik, and Ruciński in [9, 10]: after relabelling the alphabet, their doubly binary words are precisely the -words. Their odd-ABBA words are even-Parikh non-shuffle-squares of unbounded length [10]. Hence no global threshold can make evenness sufficient throughout .
There is likewise no finite local prefix threshold. The right-infinite word
(17)
has every finite prefix in , and every one of its even-length prefixes has both letter multiplicities odd. Consequently, no nonempty prefix of is a shuffle square. Nevertheless, even-Parikh -words admit a sharp finite reduction.
Theorem 5.8. Let have even Parikh vector and suppose that it is not a shuffle square. If , then has a proper nonempty shuffle-square prefix and a proper nonempty shuffle-square suffix. The maximum length of an even-Parikh -word with no such prefix is 34, so 36 is the sharp threshold among admissible (even) lengths. Moreover, there are exactly 230 nonempty even-Parikh -words having no nonempty shuffle-square prefix, and all of them have length at most 34.
Proof. Apply recurrence (6) with . The complete level sizes through the onset of periodicity are
(18)
The nonzero counts of even-Parikh words in these levels are given in Table 5. They sum to 230, and the last occurs at length 34.
TABLE 5. Nonempty even-Parikh -words with no nonempty shuffle-square prefix
| n | number | n | number | n | number |
|---|---|---|---|---|---|
| 4 | 2 | 16 | 10 | 26 | 28 |
| 8 | 4 | 18 | 14 | 28 | 38 |
| 10 | 2 | 20 | 24 | 30 | 20 |
| 12 | 8 | 22 | 18 | 32 | 24 |
| 14 | 6 | 24 | 28 | 34 | 4 |
| total = 230 | |||||
It remains to prove that no later even-Parikh level can reappear. For a residual and a word whose first run starts after a run boundary, write
when the unpruned run-capacity transitions of Listing 2, initialized at , can finish at . The finite calculation partitions the 422 words in into two classes of size 211. For each seed in the first class, ends in 22, both its multiplicities are odd, the residual 12 is reachable after , and
(19)
For each seed in the second class, the complementary assertions hold: ends in 11, residual 21 is reachable, and
(20)
For a concrete illustration, consider the seed
It contains 19 copies of each letter and reaches residual 12. Appending two periods and then the exit word 12 gives the sequence of transitions
Consequently, the word
is a shuffle square of length 48, with root . An explicit decomposition assigns the initial 12 to the first copy, the first and third positions of each block 1122 to the first copy, the second and fourth positions to the second copy, and the final 12 to the second copy. After U and after each appended period, the first partial copy exceeds the second by the same suffix 12; the exit word supplies precisely this missing suffix.
Returning to the general argument, consider any seed u in the first class. The condition forces the next letter after 22 to be 1. Choosing 2 next completes the exit word 12 and hence a shuffle-square prefix by (19). Choosing 1 is therefore the only bad continuation. The next letter is then forced to be 2. Choosing 1 after it completes the other exit 1121 and gives a shuffle-square prefix. Hence the unique bad four-letter continuation is 1122. This block returns both the last run and the reachable residual to their initial states. Induction makes the unique bad ray from u. Every finite prefix along this ray has at least one odd multiplicity, while each block endpoint has both multiplicities odd, so no full word on the ray is itself a shuffle square. The same argument with (20) gives the unique ray from every seed in the second class. Thus for every , and none of these words has even Parikh vector.
It follows from Table 5 that an even-Parikh -word of length at least 36 with no shuffle-square prefix does not exist. A non-shuffle-square word satisfying the hypotheses must therefore have a proper such prefix. Applying the same conclusion to rev(w) and using reversal closure gives the suffix. Finally,
(21)
has length 34, even Parikh vector, and belongs to , proving the sharpness assertion.
Listing 6 records all finite assertions needed for the count, the pumping step, and the example establishing sharpness.
B <- BAD-PREFIX-TREE(1, 42) assert (size(B[n]))[n=0,...,42] equals the vector in (C1-bad-counts) assert the even-Parikh counts equal Table C1-even-bad and sum to 230
for u in B[38] do V <- {v in B[42] : u is a prefix of v} assert size(V) = 1 p <- the last four letters of the unique word in V if p = 1122 then assert u ends in 22 (q, exits) <- (12, {12,1121}) else assert p = 2211 and u ends in 11 (q, exits) <- (21, {21,2212}) assert both multiplicities of u are odd assert q is reachable after u assert q --p--> q and q --z--> epsilon for every z in exits assert 211 seeds have p = 1122 and 211 have p = 2211 assert the word in (C1-sharp34) belongs to B[34]
LISTING 6. The finite count and pumping argument for
The recurrence, complete level vector, Table 5, transition identities (19)–(20), and Listing 6 together give a finite verification independent of supplementary source code.
The theorem yields a finite terminal core, though unlike at levels and the individual shuffle-square blocks cannot be bounded.
Corollary 5.9. Every nonempty even-Parikh -word w has a greedy factorization
where every is a shuffle square and the terminal remainder is either empty or one of the 230 words counted in Table 5. In particular, . If is not a shuffle square, then . There is no uniform upper bound on the lengths of the blocks .
Proof. Repeatedly remove the shortest nonempty shuffle-square prefix. Every remainder is a factor and retains an even Parikh vector. At termination, a nonempty remainder has no nonempty shuffle-square prefix and is therefore one of the 230 words in Table 5. Concatenation of the proves that would make a shuffle square.
For the absence of a block bound, put
The word U is one of the first-class seeds above and reaches residual 12. The pumping and exit identities in (19) show that every is a shuffle square, whereas every proper nonempty prefix lies on the bad ray from U. Thus is a minimal shuffle-square prefix of length .
Example 5.10. Consider the odd members of the family introduced above. Grytczuk, Pawlik, and Ruciński proved that none of these words is a shuffle square [10]. Put
For , we have . The word is an ordinary square and hence a shuffle square. It is the shortest nonempty shuffle-square prefix: the prefixes of lengths 2 and 6 have odd letter multiplicities, while the length-4 prefix is 2112, the complement of the obstruction in Example 2.6. The greedy factorization therefore removes exactly times and leaves . Thus this infinite family of exceptions reduces to a single irreducible word of length 4.
These statements do not characterize all doubly binary even-Parikh non-shuffle-squares, but they separate a finite irreducible core from the remaining words and locate exactly where the bounded local method valid for and above breaks down.
6. BOUNDED LOCAL FACTORIZATIONS
The finite length-24 lemma also has consequences which do not assume an even Parikh vector. We state them at the level, so all stronger differentiability classes follow at once.
Proposition 6.1. Let be a finite -word.
(i) For every , some factor beginning at position i is a shuffle square of length in .
(ii) For every , some factor ending at position j is a shuffle square of length in .
Consequently, a -word of length contains at least shuffle-square occurrences with distinct starting positions.
Proof. For (i), the length-24 factor belongs to by Lemma 3.5(i). Apply the prefix part of Lemma 5.1. Part (ii) follows from the suffix part applied to . The final count chooses one occurrence for each of the possible starting positions in (i). Occurrences with different starting positions are different intervals.
Theorem 6.2. Every finite -word w has a factorization
obtained by repeatedly removing the shortest nonempty shuffle-square prefix. Here
(i) each is a shuffle square and .
(ii) the terminal remainder r belongs to , has no nonempty shuffle-square prefix, satisfies , and has .
(iii) is a shuffle square whenever .
If for some , then all blocks and the remainder belong to . If is smooth, they are smooth. In particular, every -word of length has a shuffle-square prefix and suffix of length at least .
Proof. Start with the remainder . If has a nonempty shuffle-square prefix, let be its shortest such prefix and write . The choices are deterministic, and the length strictly decreases, so the process terminates in a remainder with no such prefix. Every intermediate remainder and every selected block is a factor of , hence belongs to by Lemma 3.5(i). The same lemma preserves any stronger class and smoothness.
If an intermediate remainder has length at least 24, its first 24 letters form a -word and Lemma 5.1 supplies a shuffle-square prefix of length at most 24. Thus every chosen shortest block has length at most 24, and a terminal remainder cannot have length at least 24. The lower bound 2 follows from Lemma 2.5. Repeated use of Lemma 2.7(i) proves (iii).
When , at least one block is removed and . Applying the established prefix statement to , then using Lemmas 3.5(ii) and 2.7(ii), gives the suffix statement.
Remark 6.3. The constant 23 in Theorem 6.2 is optimal even for smooth words. Each word in (8) is smooth and has no nonempty shuffle-square prefix, so its greedy factorization has no block and leaves the entire length-23 word as its remainder.
Example 6.4. For the smooth word , Theorem 1.1 shows that the shortest shuffle-square prefix is , and the greedy factorization is
The remainder 1221 has no nonempty shuffle-square prefix, by Example 2.6. Nevertheless, itself is a shuffle square, as Table 6 shows. Thus Theorem 6.2 is a canonical bounded-block construction, not a claim that its terminal remainder characterizes whether the original word is a shuffle square.
The preceding construction needs only a local hypothesis in the infinite setting.
Definition 6.5. A right-infinite or bi-infinite binary word X is length-24 locally if every factor of X of length 24 belongs to . Any word whose length-24 factors belong to for some has this property. Proposition 3.6 shows the same for every smooth right-infinite word.
Theorem 6.6. Let be a length-24 locally right-infinite word, and fix a starting position . Put . Recursively, let be the least positive integer for which
is a shuffle square, and put . Then the recursion is defined for all and
Every cumulative factor is a shuffle square. Moreover, if
then
(22)
and hence
Proof. Once is defined, the length-24 factor beginning at belongs to . Lemma 5.1 gives a nonempty shuffle-square prefix, so the least exists and is at most 24. It is at least 2 by parity. The cumulative factor is the concatenation of the first shuffle-square blocks, hence is a shuffle square by Lemma 2.7(i).
Writing , we have . For , the distinct lengths are all at most (with the assertion empty when ). This proves the lower bound in (22). Its upper bound follows from Lemma 2.5, since only even lengths can be shuffle-square lengths. Dividing by and taking lower and upper limits gives the final chain of inequalities.
Corollary 6.7. Let be a length-24 locally bi-infinite word, and fix any cut . There is a strictly increasing sequence of cuts such that
and every block is a shuffle square.
Proof. Starting at , construct the cuts to the right by the proof of Theorem 6.6. Given a cut on the leftward side, apply the suffix part of Lemma 5.1 to the length-24 factor ending at that cut and move left by the length of a shortest shuffle-square suffix. This constructs all negative-indexed cuts, with the same bounds.
Corollary 6.8. Call a right-infinite or bi-infinite word length-40 locally when each of its length-40 factors belongs to . Then all conclusions of Theorem 6.6 and Corollary 6.7 remain valid after replacing “length-24 locally ” by “length-40 locally ”, the upper block bound 24 by 40, and the lower density bound 1/24 by 1/40.
Proof. The proofs are unchanged, with Lemma 5.4 supplying a shuffle-square prefix or suffix of length at most 40 at each step.
7. CHARACTERIZATION OF ALL SHUFFLE-SQUARE PREFIXES
Example 2.4 gives an explicit shuffle decomposition of the first shuffle-square prefix, of length 16. Table 6 gives such decompositions for the next three. In each row, is a support of one copy and its complement in supports the other copy. The two induced subwords both equal the displayed root. These three decompositions are illustrative direct checks, since the universal theorem already covers their lengths.
TABLE 6. Further explicit shuffle decompositions of Kolakoski prefixes
| m | root | support I |
|---|---|---|
| 20 | 1221121221 | {1,2,3,4,5,6,7,8,9,16} |
| 24 | 122112122112 | {1,2,3,4,5,6,7,8,9,16,20,21} |
| 28 | 12211212211221 | {1,2,3,4,5,6,7,8,9,16,20,21,24,25} |
Direct counting in (1) gives
(23)
Examples 2.6 and 2.11 show that the first two words in (23) are not shuffle squares. Example 2.4 and Table 6 handle the other four.
We can now prove the exact characterization announced in Theorem 1.1. This characterization was also obtained independently by Kilpatrick [14, Theorem 1.3].
Proof of Theorem 1.1. If is a shuffle square, then by Lemma 2.5. The two exceptional values are established in Examples 2.6 and 2.11.
Conversely, let . Equation (23) shows that either or . The case is Example 2.4. In the remaining cases, is a smooth factor of by Corollary 3.7, hence belongs to . It has length greater than 16 and even Parikh vector. It is therefore a shuffle square by Theorem 1.2.
Corollary 7.1. The increasing enumeration of EPK , equivalently the sequence of shuffle-square prefix lengths of , begins
It is infinite, and consecutive terms differ by one of 2, 4, 6, 8. If
then, for every ,
(24)
and consequently
Proof. The displayed sequence follows from Theorem 1.1, and (3). Infinitude and the gap bound follow from Proposition 4.1. If the displayed lengths are , then and . Taking proves (24). The lower-density bound follows after division by .
Corollary 7.2. Put . Once is defined, let be the least positive integer for which
is a shuffle square, and put . This recursion is well-defined for every , and
Every is a shuffle square. The initial cumulative endpoints are
16, 34, 36, 48, 56, 66, 68, 88, 90, 104, 110, 116, 124, 134, 136, ...
They form an infinite proper subsequence of the increasing enumeration of EPK . The omitted terms, such as 20, 24, 28, 40, are shuffle-square prefixes but are not endpoints of that particular recursive factorization.
Proof. Corollary 3.7 makes K length-24 locally . Theorem 6.6, with and , proves that the recursion is defined, gives the block-length bounds, and makes every cumulative prefix a shuffle square. Hence for every by Theorem 1.1.
The initial values above are obtained by successively applying the exact recognizer in Listing 1 to the even-length candidate blocks.
Finally, and . The word 1221 has no nonempty shuffle-square prefix by Example 2.6, so 20 is not a recursive endpoint, although is a shuffle square by Theorem 1.1. Hence the subsequence is proper.
Example 7.3. The first block is from Example 2.4. The next block, written with positions relative to that block, is
The support and its complement both induce the root 122121121. The third block is simply , with root 2. Hence the first three cumulative endpoints are 16, 34, 36.
Applying Listing 1 successively to each shorter even-length candidate verifies that none works at any displayed step.
Together with Lemma 2.5, this excludes every shorter block.
8. MORPHISMS REFLECTING SHUFFLE SQUARES
In this section the alphabets need not be binary. Let be finite alphabets, and extend the notation to the nonempty shuffle squares over whichever alphabet is under consideration. A morphism is nonerasing if for every . Every such morphism preserves shuffle squares: applying to the two copies of a root gives a decomposition of the image. We say that reflects shuffle squares if the converse also holds, that is,
(25)
The empty word causes no exception to this convention, since neither side holds for .
We first obtain a necessary condition and a complete answer when the alphabets have the same cardinality. For larger target alphabets, we then derive criteria using the ordered-graph method of Grytczuk, Pawlik, and Ruciński [10]. The graph representation and the path-cycle lemma used below are taken from that work. Regular bipartite matchings and odd-power reduction will allow us to extract a shuffle decomposition of the source word.
8.1. Odd powers and private symbols
Lemma 8.1. Let be a positive odd integer for each . The morphism given by reflects shuffle squares.
Proof. Only reflection requires proof. Suppose that is partitioned into two copies of a word . Write . In each copy of , number the occurrences of a separately and retain exactly those whose numbers are congruent to modulo . Make this selection for every letter. The two retained subwords are identical.
We show that exactly one position survives in each original block . At a boundary between original blocks, suppose that blocks of letter have been processed. If the two copies have used and occurrences of , then . The number of retained occurrences in a prefix containing occurrences is
For all nonnegative with , one has
(26)
Indeed, write with . If , the two remaining floor terms are both zero. If , they are 1 and -1. Thus the total number of retained positions increases by exactly one while an original block of letter a is read. The retained word is therefore w, with a partition into two identical subwords.
Definition 8.2. A symbol is private to a for a morphism if occurs in and does not occur in for any .
Proposition 8.3. If a nonerasing morphism reflects shuffle squares, then every has a private symbol. In particular, .
Proof. Suppose that a has no private symbol, and put . Choose a nonempty word such that every symbol occurring in V occurs in . For some positive , the word is a subword of : for example, one can use at most one required symbol from each successive copy of . Let be the complementary subword, so that is a shuffle of and .
The word VUUV is a shuffle square with root VTV. One copy uses the initial V, the T-positions of the first U, and the V-positions of the second U. The other uses the V-positions of the first U, the T-positions of the second U, and the terminal V. However,
and is not a shuffle square. Its only two occurrences of a are at its ends. A root would contain exactly one a, which would have to be both its first and its last letter, although the root has length greater than one. This is a contradiction. Private symbols of different letters are distinct, giving the cardinality assertion.
Proposition 8.4. Suppose that for each there is a private symbol whose multiplicity is odd. Then reflects shuffle squares.
Proof. Define a morphism by and by erasing the remaining symbols. Then . If is a shuffle square for nonempty , its projection is a nonempty shuffle square. Lemma 8.1 gives .
We record a stronger feature of this proof for later use. Fix any decomposition of into two equal copies and pair corresponding positions. Within each copy retain the occurrences of of ranks congruent to modulo . Formula (26), applied at the boundaries of the images , shows that this retains exactly one position from every image of a and none from other images. The retained positions are unions of whole pairs from the fixed decomposition. This selection can be performed for any chosen subset of the source letters.
Corollary 8.5. Let . A nonerasing morphism reflects shuffle squares if and only if
where is a bijection and every is positive and odd.
Proof. By Proposition 8.3, choose a private symbol for each . These exhaust , so no symbol other than can occur in . Its multiplicity must be odd, since otherwise the one-letter word would have a shuffle-square image. The converse follows from Lemma 8.1 and invariance under relabelling.
Example 8.6. The morphism given by and reflects shuffle squares: the private symbols 2 and 4 each have multiplicity 1, while the symbols 1, 3, 7 occur in both images. In contrast, the mere existence of private symbols is not sufficient. The morphism , has private symbols for both letters but maps a to a shuffle square. The next criteria include cases in which every symbol in every image has even multiplicity.
8.2. Extraction from ordered graphs. An ordered graph is a graph whose vertex set is equipped with a linear order. Loops and parallel edges are allowed. For an edge e, write min e and max e for its smaller and larger endpoints, respectively; these coincide when e is a loop. Two edges form a nest if, after possibly interchanging their names,
Thus both endpoints of f lie strictly between the endpoints of e. If the vertices are placed in order on a horizontal line and edges are drawn as semicircular arcs above it, the arc corresponding to f lies inside the arc corresponding to e. The weak middle inequality allows the inner edge f to be a loop.
An ordered graph is nest-free if it contains no such pair of edges in the terminology of [10]. For example, on vertices , the edges and form a nest, whereas and do not: their endpoints interleave. In particular, nest-free graphs may contain crossing edges.
A word is a shuffle square precisely when its positions admit a nest-free perfect matching that pairs equal symbols. For completeness, pair equal-rank positions of two copies of a root. Both the smaller and the larger endpoint of these pairs increase with the rank, so no nest occurs. Conversely, order the edges of such a matching by their smaller endpoints. Their larger endpoints also increase, and the two endpoint sequences induce identical words. Contracting consecutive equal-letter positions into runs preserves the absence of nests. The degree of each resulting vertex, counting a loop twice, equals the length of its run. This is the run-graph representation of [10, Proposition 1].
We use the following result.
Lemma 8.7 (Grytczuk–Pawlik–Ruciński [10], Lemma 1). Let an ordered nest-free graph contain a path P joining its first and last vertices. Every cycle vertex-disjoint from P has even length.
Lemma 8.8. Let H be a word on two distinct symbols x, y, containing y and beginning and ending with x. Suppose that its first and last x-runs have odd lengths, every other x-run has even length, and all y-runs have the same positive length q. Given any nest-free perfect matching of equal symbols on the positions of H, one can select a subset of its edges that uses exactly one position from each y-run and no x-positions.
Proof. Contract the runs. The resulting nest-free multigraph is the disjoint union of a graph on the x-runs and a graph on the y-runs, with the vertex order inherited from H. Exactly the first and last vertices of have odd degree. They belong to the same connected component, since every component has an even number of odd-degree vertices. Hence contains a path P joining the extreme vertices of the whole graph.
The graph has no loop: a path from the first to the last vertex must have an edge spanning the vertex of any such loop, which would create a nest. By Lemma 8.7, also has no odd cycle of length at least three. Thus is bipartite. This is the parity mechanism used in the proof of [10, Theorem 1].
Every vertex of has degree . If its bipartition is , then counting edges gives and, for each ,
Hall's theorem therefore gives a perfect matching of . For each edge of this matching choose its corresponding edge in the original position matching. Exactly one position in each y-run is selected, as required.
Theorem 8.9. For each , choose distinct symbols , with the pairs disjoint for different letters. Let
(27)
where is positive and odd, , the two endpoint exponents are positive and odd, and all interior exponents are positive and even. Then reflects shuffle squares.
Proof. Suppose that is a shuffle square, and fix a nest-free perfect matching of its positions. For a letter occurring times in , erase all symbols except . Since the pairs of symbols are disjoint, the remaining word is and inherits a perfect matching from .
At a boundary between successive copies of , the two adjacent -runs merge and have even total length . Consequently, in precisely the first and last -runs have odd lengths, all other -runs have even lengths, and all -runs have length . Apply Lemma 8.8. It selects complete edges of , with exactly one endpoint in each -run.
Perform this selection for every letter occurring in w. The union is still a subset of M and therefore contains no nests. Each -run is a contiguous interval of the original word , and each image of a contributes exactly selected positions. Read the selected positions in order and relabel as a. We obtain a nest-free perfect matching of equal letters on
Thus is a shuffle square. Lemma 8.1 gives .
Theorem 8.10. Let
where the symbols satisfy the disjointness assumptions of Theorem 8.9. Then reflects shuffle squares if and only if for every at least one of is odd.

Proof. If all three exponents for some a are even, divide each of the three runs of equally between two copies. Then is a shuffle square although a is not, so reflection fails.
Conversely, assume the stated parity condition and fix a nest-free perfect matching M associated with a decomposition of . If is odd, use the private symbol and the rank selection in the proof of Proposition 8.4. If is even but is odd, use instead. In each case the selection retains complete edges of M and exactly one position from each image of a.
In the remaining case, and are even. The hypothesis forces both and to be odd. Projecting onto and applying Lemma 8.8, as in the proof of Theorem 8.9, again selects complete edges of with exactly one position from each image of .
Combining these selections over all source letters produces a submatching of , with exactly one position from each image block. Relabel each selected symbol by its unique source letter. The result is a nest-free perfect matching of equal letters on , proving that .
Example 8.11. In particular, a 1221 and b 3443 define a morphism reflecting shuffle squares, although all four target symbols have even multiplicity in their respective images. The same conclusion holds for a and b . The lengths of the images, and the two endpoint exponents within an image, need not coincide.
Example 8.12. Consider the images
They have lengths 16 and 14 and satisfy Theorem 8.9 with and . Hence the word
of length 60 is not a shuffle square: otherwise abba would be one. Nevertheless, the multiplicities of 1, 2, 3, 4 in W are respectively 20, 12, 16, 12, and the projections onto and are the ordinary squares and . The obstruction is therefore detected by the order of the different image blocks, rather than by either projection alone.
Remark 8.13. For a single source letter, the non-square assertion for odd powers of the images in Theorem 8.9 is already covered by [10, Corollary 3]. The reflection statements above additionally handle arbitrary arrangements of images of different letters. The extraction argument uses one fixed matching throughout, so the separate selections remain compatible in the original word. None of the proofs in this section requires a finite computational check.
9. LOCAL REPAIRS AND LARGEST TWINS IN DOUBLY BINARY WORDS
The finite reduction in Theorem 5.8 also controls how far a doubly binary word can be from a shuffle square. We first allow arbitrary deletions, without assuming an even Parikh vector, and then locate single repairs close to an endpoint. Recall that consists precisely of the binary words avoiding 111 and 222.
9.1. Deletion distance and largest twins. For this section put , and define
Thus the retained positions need not be consecutive. A pair of twins in a word w consists of two identical subwords supported on disjoint sets of positions. The positions in each subword need not be consecutive, but are read in their original order. The twins are called perfect if their supports together cover all positions of . Let denote the maximum common length of a pair of twins in , with . Directly from these definitions,
(28)
The parameter is the largest-twins parameter studied by Axenovich, Person, and Puzynina [1]. They proved that every binary word of length has twins covering positions. Deletion distance to shuffle squares is also studied in [10, Sections 5 and 6.2]. Theorem 9.3 gives an exact formula for this distance throughout .
Lemma 9.1. If a residual word q is reachable after reading w in (4), then .
Proof. The corresponding partial coloring partitions w into subwords v and vq, in one order or the other. Delete the positions supporting the final copy of q. The two remaining subwords both equal v.
Put
(29)
We need two finite checks in addition to the periodic-ray description already proved. Here a minimal shuffle-square prefix means a shuffle square with no proper nonempty shuffle-square prefix. Its minimality concerns prefixes, not arbitrary subwords.
Lemma 9.2. The following assertions hold.
(i) Among the 6609 words in , every nonempty word of even length has deletion distance 2. Every word of odd length has deletion distance 1, except and in (29), whose distance is 3.
(ii) There are 2980 minimal shuffle-square prefixes of length at most 38. Among their 5768 concatenations with , every word has deletion distance 1.
Proof. Generate the sets by (6). Their level sizes in (18) sum to 6609 through level 38. For each nonempty even-length word, enumerate pairs of deleted positions and apply Proposition 2.8 to the remaining word. At odd lengths enumerate single deleted positions. The only failures are the two words in (29). Deleting positions 1, 2, 11 from u leaves 21121122, with two copies of 2112 on supports (1, 2, 3, 7) and (4, 5, 6, 8). Complementation handles . Parity and the definition of give all lower bounds in (i).
For (ii), the complete list consists of the words
This gives 2980 words. Test for each of the two choices of , retaining 5768 pairs, and enumerate one deleted position in each retained concatenation. Every test succeeds. These finite enumerations, including all negative single-deletion tests for and , are reproduced by verify_local_repairs.py.
Listing 7 records the finite checks in Lemma 9.2. The predicate SQ0 extends the recognizer from Listing 1 by accepting the empty word.
Theorem 9.3. For every ,
(30)
function SQO(w) return (w = epsilon or SHUFFLE-SQUARE(w))
function DELETABLE(w, d) for each d-element subset I of {1,...,length(w)} do v <- w with the positions in I deleted if SQO(v) then return true return false
B <- BAD-PREFIX-TREE(1, 38) assert sum(size(B[n]) : n = 0,...,38) = 6609 E <- empty set for w in union(B[1],...,B[38]) do if length(w) is even then assert DELETABLE(w, 2) else if not DELETABLE(w, 1) then insert w into E assert E = {12211211221, 21122122112} for r in E do assert DELETABLE(r, 3)
M <- {va : v in union(B[0],...,B[37]), a in {1,2}, va is in C^1 and SHUFFLE-SQUARE(va)} assert size(M) = 2980 P <- {(T,r) : T in M, r in E, Tr is in C^1} assert size(P) = 5768 for (T,r) in P do assert DELETABLE(T*r, 1)
LISTING 7. Finite deletion and absorption checks
Consequently, if , then , except that . If , then for and otherwise.
Proof. First consider a word with no nonempty shuffle-square prefix. Lengths at most 38 are covered by Lemma 9.2(i). By the proof of Theorem 5.8, every longer such word is a prefix of one of the 422 periodic rays. For the 211 rays with period 1122, the length-38 seed U reaches residual 12. The letter transitions
(31)
show that each subsequent odd-length prefix reaches a residual of length 1, and each even-length prefix reaches one of length 2. Here the arrows denote the letter transitions of (4). They are not restricted to run boundaries. The complementary rays have the same property. Lemma 9.1 proves the required upper bounds. No nonempty word under consideration is a shuffle square, so length parity gives equality.
For an arbitrary word, successively remove shortest nonempty shuffle-square prefixes to obtain
This greedy construction does not require even letter multiplicities. If , then . Otherwise, concatenating the unchanged shuffle-square blocks with a repaired remainder gives
. Since each has even length, the only remaining case is
It suffices to repair with one deletion. Write . This is a minimal shuffle-square prefix. If , apply Lemma 9.2(ii).
If , its first 38 letters form a seed of one of the periodic rays, and the rest follows that ray until its first exit. Hence, up to complementation,
with residual 12 reachable after . For a word , let denote deletion of its th position. Direct application of (4) gives the four transitions in Table 7. Thus deleting the indicated position from completes a shuffle-square coloring of . Complementation covers the other 211 rays. Concatenation with proves .
All odd lengths require an odd number of deletions, and all even-length non-shuffle-squares require at least two. The two exceptional words were checked in Lemma 9.2(i). These observations establish (30). The statements about twins follow from (28).
TABLE 7. The four finite transitions absorbing the odd exceptional remainders.
In each row,
| e | r | j |
|---|---|---|
| 12 | u | 11 |
| 12 | 1 | |
| 1121 | u | 3 |
| 1121 | 1 |
9.2. One repair near an endpoint. An adjacent transposition interchanges two consecutive different letters. Deleting or inserting a pair below always means deleting or inserting two consecutive equal letters. Unlike Theorem 9.3, the next result assumes that both letter multiplicities are even.
Theorem 9.4. Let have even Parikh vector and be nonempty.
(i) An adjacent transposition within the last positions makes a shuffle square.
(ii) Deleting an equal pair within the last positions makes a shuffle square.
(iii) An adjacent transposition within the last positions makes a shuffle square that still belongs to .
(iv) Write , with . For some such factorization and some , the word belongs to .
The constants 10, 11, 15, 6 above are all optimal. The corresponding assertions at the left endpoint hold by reversal.
Proof. Let be the set of 230 nonempty even-Parikh words in Table 5. The following finite checks suffice. For each , enumerate the operations specified in Table 8, and test the result with Proposition 2.8. In the last two rows, also require membership in . Each row succeeds for all 230 words. Listing 8 specifies these checks. They are performed independently by verify_local_repairs.py after regenerating .
By Corollary 5.9, write , where . Apply the appropriate operation inside . The resulting remainder is a shuffle square, and concatenation with the unchanged gives a shuffle square. Distances from the right endpoint are unchanged. In (iii) and (iv), the finite checks leave the first two letters of unchanged. Thus they also preserve the condition across the boundary between and . All other boundaries are untouched.
For sharpness, direct enumeration of all eligible operations in the words of Table 9 gives the stated smallest window or suffix length. In particular, the successful transpositions for the first word start at positions 1, 3, 8, 10, 15. Among these, exactly 1, 3, 8, 10 preserve . The successful pair deletions for the second word start at positions 2, 4, 7, 11, 14. These complete lists prove the first three lower bounds. The last lower bound follows by checking both inserted pairs at each of the last six gaps, and finding no repair in there. A repair exists before the suffix of length 6. Reversal preserves shuffle squares and and converts all right-end assertions to left-end assertions.
TABLE 8. Finite checks on each of the 230 terminal remainders. Positions are numbered from 1. In the last row the gap follows position
| Operation | Eligible positions | Additional condition |
|---|---|---|
| Transpose | ||
| Delete | ||
| Transpose, preserve | ||
| Insert 11 or 22, preserve | — |
TABLE 9. Examples establishing the optimal locality constants
| Operation | Word | Optimal constant |
|---|---|---|
| Transposition | 122112112122122122112112 | 10 |
| Pair deletion | 122112112122122112211212 | 11 |
| Transposition preserving | 122112112122122122112112 | 15 |
| Pair insertion preserving | 12211211212212212112 | 6 |
Example 9.5. The distinction between (i) and (iii) is necessary. For the first word of Table 9, the rightmost successful transposition gives
which contains 222. Transposing positions 10, 11 instead gives
Nor can one always strengthen (ii) by requiring the result to remain in : deleting either available equal pair from 12211212 gives 111212 or 122212. The first is a shuffle square and the second is not, but neither is doubly binary.
9.3. Completion at the endpoint and longer runs
Theorem 9.6. For every with even Parikh vector, there is a word
such that . Four appended letters are sometimes necessary, even if the completed word need not remain in .
Proof. For each , testing the six displayed words finds at least one with . This finite check is included in Listing 8 and in verify_local_repairs.py. Apply it to the terminal remainder in Corollary 5.9. No existing letter is changed, so the boundary with the preceding shuffle-square blocks is preserved. If the remainder is empty, append 1122 when is empty or ends in 2, and append 2211 otherwise. Each chosen suffix is itself a shuffle square and creates no run of length 3.
For optimality, let . The word is not a shuffle square. Any appended word of length less than 4 that could complete it to a shuffle square must, by parity, be , 11, or 22. The last two choices fail the exact recognizer, whereas
is a shuffle square with root 12211122.
Listing 8 records the finite checks for Theorems 9.4 and 9.6, including sharpness. Positions are numbered from 1, an insertion gap j follows the first j letters, and slices have inclusive endpoints, with an empty slice when the lower endpoint exceeds the upper one. Each pair records a successful repair at position or gap j. For transpositions and deletions, is the length of the suffix starting at the first affected position; for insertions, is the length of the suffix following the gap. Thus minimizing d locates the successful repair nearest the right endpoint.
For a binary word w with run lengths , put
This quantity counts the equal-pair deletions needed to reduce each run to length 1 or 2 while retaining its parity.
Corollary 9.7. Every binary word w with even Parikh vector can be reduced to a member of by at most deletions of adjacent equal pairs. In particular,
The bound for the number of equal-pair deletions is sharp.
Proof. Reduce every odd run to length 1 and every even run to length 2. Exactly equal-pair deletions produce a word with even Parikh vector. If it does not already belong to , one further pair deletion suffices by Theorem 9.4(ii).
For sharpness, consider , . Until all middle letters have been removed, the only deletable equal pairs consist of two 2's. No word with is a shuffle square: its two copies would each contain one 1, while one would begin with that letter and the other would end with it, which is impossible for equal roots containing 2. Thus exactly pair deletions are necessary. This sharpness concerns adjacent equal pairs. Unrestricted deletions can simply remove the two endpoint letters.
function REPAIRS(r) n <- length(r) S[swap], S[delete], S[swapC1], S[insertC1] <- empty sets for j <- 1,...,n-1 do if r_j != r_{j+1} then v <- r[1:j-1]r_{j+1}r_jr[j+2:n] if SQ0(v) then insert(j,n-j+1) into S[swap] if v is in C^1 then insert(j,n-j+1) into S[swapC1] else v <- r[1:j-1]r[j+2:n] if SQ0(v) then insert(j,n-j+1) into S[delete] for j <- 0,...,n and a in {1,2} do v <- r[1:j]aar[j+1:n] if SQ0(v) and v is in C^1 then insert(j,n-j) into S[insertC1] return S end B <- BAD-PREFIX-TREE(1, 38) R <- {r in union(B[1], ..., B[38]) : r has even Parikh vector} assert size(R) = 230 for r in R do S <- REPAIRS(r) for (op,b,j0) in {(swap,10,1),(delete,11,1), (swapC1,15,3),(insertC1,6,2)} do assert some(j,d) in S[op] has j >= j0 and d <= b assert some z in {1122,1212,1221,2112,2121,2211} satisfies SQ0(rz) and rz is in C^1 end # Sharpness uses all positions, without the restriction j >= j0. for (op,r,b) in the rows of Table 9 do S <- REPAIRS(r) assert S[op] is nonempty assert min{d : (j,d) in S[op]} = b end w <- 122112112122 assert not SQ0(w) and not SQ0(w11) and not SQ0(w22) assert SQ0(w1122) and w*1122 is in C^1
LISTING 8. Local repairs, sharpness, and balanced completions
Remark 9.8. The single-repair conclusion does not extend unchanged to words whose runs have length at most 3. For example, direct enumeration gives . Deleting an equal pair from each of its two length-3 runs leaves 1212. Thus at least two equal-pair deletions are needed in this larger class. It is natural to ask whether two such deletions suffice for every even-Parikh word with run lengths at most 3. The results above do not settle this question.
10. SCOPE OF THE COMPUTER ASSISTANCE
The finite-differentiability and Kolakoski theorems, and the local-repair results of Section 9, use explicitly bounded computations. The proofs specify why these finite tasks suffice for arbitrary lengths: strong induction for , terminating extension layers for , and residual loops and exits for the 422 rays. In Theorem 9.3, the short residual cycle and the four absorption transitions additionally handle every phase of the rays and every long minimal shuffle-square prefix. No unbounded assertion is inferred solely from a cutoff or stabilization of counts. The morphism results in Section 8 have purely mathematical proofs.
The supplementary material contains complete Python implementations of the finite proof computations, a shared recognition module, and a driver script. The programs use only the Python standard library and regenerate their input sets without external data. Their roles are as follows.
(i) verify_c1_c2_c3.py verifies the , , and computations. For , these include the 175-node tree, its 46 600 parity-base words, and 34 exceptions. It also checks that all 34 exceptions and the terminal words of length 23 are smooth. For , the program checks the 823-node tree, 208 short exceptions, 288 minimal suffix squares, and extension layers of 13 752 and 200 candidates, leaving four and zero exceptions, respectively. For , it checks the 230 even-Parikh cores and all 422 periodic seeds, including the residual loops and exits. Three implementations of the exact recognizers agree on every nonempty binary word through length 16.
(ii) verify_local_repairs.py regenerates the 6609 bad-prefix words through length 38, the 2980 minimal shuffle-square prefixes, and all 5768 admissible concatenations with the two odd exceptions. It checks deletion bounds, periodic residuals, absorption transitions, all four sharp locality constants, boundary preservation, and balanced completions, including the finite checks establishing sharpness. These are the finite tasks used in Section 9. The finite deletion and local-modification searches are specified in Listings 7 and 8.
(iii) shuffle_core.py supplies the exact recognition and residual-transition routines used by verify_local_repairs.py. As an implementation check, it compares its run and letter recurrences with independent literal support enumeration on all 8191 binary words through length 12, including the empty word.
(iv) verify_all.py runs the three preceding programs in fresh subprocesses, stops on failure, and records their exit statuses and execution times.
The smooth-word conclusions follow from the theorem and the smoothness checks above, as explained in Corollary 5.2. The Kolakoski characterization follows from the same theorem and the explicit short-word arguments in Section 7. No additional enumeration of smooth words or bounded testing of morphisms is used in these proofs. The Kolakoski arguments use no assumption about letter or factor frequencies.
After extracting the supplementary archive, run python verify_all.py from the directory containing the driver script. This command runs all checks afresh and writes computed JSON data and execution logs. The complete verification succeeded under CPython 3.12.14. The entry point rejects the assertion-disabling options -0 and -00. The file README.md gives requirements, commands, a program-to-result mapping, and expected results.
Computed data and execution logs accompany the programs as reference outputs; they are not inputs to the verification. The article contains the recurrences, pseudocode, decisive counts, and mathematical arguments explaining why the finite verifications establish the stated results.
STATEMENTS AND DECLARATIONS
Funding. The author received no financial support for the research, authorship, or publication of this article.
Competing interests. The author declares that he has no competing interests.
Data availability. The Python programs and computed outputs supporting the finite proof computations are included in the supplementary material described in Section 10. All input sets are generated by the programs; no external datasets are required.
Use of generative artificial intelligence. During the preparation of this manuscript, the author used OpenAI's ChatGPT (GPT-6) as an auxiliary tool to assist with writing the Python verification scripts, literature search, and language editing. All AI-assisted content was independently reviewed and verified by the author, who takes full responsibility for the manuscript.
REFERENCES
[1] M. Axenovich, Y. Person, and S. Puzynina, A regularity lemma and twins in words, J. Combin. Theory Ser. A 120 (2013), no. 4, 733–743, doi:10.1016/j.jcta.2013.01.001.
[2] V. Berthé, S. Brlek, and P. Choquette, Smooth words over arbitrary alphabets, Theoret. Comput. Sci. 341 (2005), nos. 1–3, 293–310, doi:10.1016/j.tcs.2005.04.010.
[3] L. Bulteau and S. Vialette, Recognizing binary shuffle squares is NP-hard, Theoret. Comput. Sci. 806 (2020), 116–132, doi:10.1016/j.tcs.2019.01.012.
[4] S. Buss and M. Soltys, Unshuffling a square is NP-hard, J. Comput. System Sci. 80 (2014), no. 4, 766–776, doi:10.1016/j.jcss.2013.11.002.
[5] A. Carpi, On repeated factors in -words, Inform. Process. Lett. 52 (1994), no. 6, 289–294, doi:10.1016/0020-0190(94)00162-6.
[6] J. Cassaigne and R. Henry, The complexity of smooth words over binary alphabets, arXiv:2603.10733v4 (2026), doi:10.48550/arXiv.2603.10733.
[7] D. Datko and B. Pawlik, Roots of binary shuffle squares, Symmetry 17 (2025), no. 2, article 305, doi:10.3390/sym17020305.
[8] F. M. Dekking, On the structure of self-generating sequences, Seminar on Number Theory, 1980–1981 (Talence, 1980–1981), Exp. No. 31, 6 pp., Univ. Bordeaux I, Talence, 1981, https://www.jstor.org/stable/44166389.
[9] J. Grytczuk, B. Pawlik, and A. Ruciński, Shuffle squares and nest-free graphs, in: G. Gamard and J. Leroy (eds.), Combinatorics on Words, Lecture Notes in Comput. Sci., vol. 15729, Springer, Cham, 2025, pp. 166–178, doi:10.1007/978-3-031-97548-6_15.
[10] J. Grytczuk, B. Pawlik, and A. Ruciński, Shuffle squares and ordered nest-free graphs, arXiv:2503.22043v2 (2025), doi:10.48550/arXiv.2503.22043.
[11] X. He, E. Huang, I. Nam, and R. Thaper, Shuffle squares and reverse shuffle squares, European J. Combin. 116 (2024), article 103883, doi:10.1016/j.ejc.2023.103883.
[12] X. He and L. Post, Asymptotically half of binary words are shuffle squares, arXiv:2512.12077 (2025), doi:10.48550/arXiv.2512.12077.
[13] D. Henshall, N. Rampersad, and J. Shallit, Shuffling and unshuffling, Bull. Eur. Assoc. Theor. Comput. Sci. 107 (2012), 131–142, https://bulletin.eatcs.org/index.php/beatcs/article/view/71.
[14] K. Kilpatrick, Shuffle squares in smooth binary words and the Kolakoski sequence, arXiv.2610.02262 (2026), doi:10.48550/arXiv.2610.02262
[15] W. Kolakoski, Self generating runs, Problem 5304, Amer. Math. Monthly 72 (1965), 674, doi:10.2307/2313883.
[16] M. Lothaire, Combinatorics on Words, Encyclopedia of Mathematics and its Applications, vol. 17, Addison-Wesley, Reading, MA, 1983.
[17] The OEIS Foundation Inc., The On-Line Encyclopedia of Integer Sequences, A000002: Kolakoski sequence, https://oeis.org/A000002, 2026.
[18] B. Pawlik, The On-Line Encyclopedia of Integer Sequences, A398324: Positions k such that the prefix of length k of the Kolakoski sequence contains an even number of 1's and an even number of 2's, https://oeis.org/A398324, 2026.
[19] R. Oldenburger, Exponent trajectories in symbolic dynamics, Trans. Amer. Math. Soc. 46 (1939), no. 3, 453–466, doi:10.1090/S0002-9947-1939-0000352-9.
[20] B. Sing, More Kolakoski sequences, Integers 11B (2011), article A14, 17 pp., https://math.colgate.edu/~integers/vol11b.html.
[21] W. D. Weakley, On the number of -words of each length, J. Combin. Theory Ser. A 51 (1989), no. 1, 55–62, doi:10.1016/0097-3165(89)90076-9.