Borders, Palindrome Prefixes, and Square Prefixes
Daniel Gabric, Jeffrey Shallit

TL;DR
This paper establishes bijections between words with no even palindromic prefixes and unbordered words, providing asymptotic counts and extending results to words with no square prefixes, including a conjecture resolution.
Contribution
It introduces explicit bijections linking palindromic prefix restrictions to unbordered words and solves a conjecture on words with no square prefix.
Findings
Number of words with no even palindromic prefix equals unbordered words.
Asymptotic enumeration for words with no palindromic prefixes.
Resolution of a 2013 conjecture on words with no square prefix.
Abstract
We show that the number of length-n words over a k-letter alphabet having no even palindromic prefix is the same as the number of length-n unbordered words, by constructing an explicit bijection between the two sets. A slightly different but analogous result holds for those words having no odd palindromic prefix. Using known results on borders, we get an asymptotic enumeration for the number of words having no even (resp., odd) palindromic prefix . We obtain an analogous result for words having no nontrivial palindromic prefix. Finally, we obtain similar results for words having no square prefix, thus proving a 2013 conjecture of Chaffin, Linderman, Sloane, and Wilks.
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2 | 4 | 4 | 8 | 12 | 24 | 40 | 80 | 148 | 296 | 568 | 1136 | |
| 2 | 2 | 4 | 6 | 12 | 20 | 40 | 74 | 148 | 284 | 568 | 1116 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |
| 3 | 6 | 12 | 30 | 78 | 222 | 636 | 1878 | 5556 | 16590 | 49548 | 148422 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2 | 2 | 4 | 6 | 12 | 20 | 40 | 74 | 148 | 284 | 568 | 1116 | |
| 2 | 2 | 4 | 6 | 12 | 20 | 40 | 74 | 148 | 286 | 572 | 1124 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2 | 2 | 4 | 6 | 10 | 20 | 36 | 72 | 142 | 280 | 560 | 1114 | |
| 0 | 2 | 4 | 10 | 20 | 44 | 88 | 182 | 364 | 738 | 1476 | 2972 |
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
Borders, Palindrome Prefixes, and Square Prefixes
Daniel Gabric and Jeffrey Shallit111Research supported by NSERC under grant 2018-04118.
School of Computer Science
University of Waterloo
Waterloo, ON N2L 3G1
Canada
Abstract
We show that the number of length- words over a -letter alphabet having no even palindromic prefix is the same as the number of length- unbordered words, by constructing an explicit bijection between the two sets. A slightly different but analogous result holds for those words having no odd palindromic prefix. Using known results on borders, we get an asymptotic enumeration for the number of words having no even (resp., odd) palindromic prefix . We obtain an analogous result for words having no nontrivial palindromic prefix. Finally, we obtain similar results for words having no square prefix, thus proving a 2013 conjecture of Chaffin, Linderman, Sloane, and Wilks.
1 Introduction
In this note, we work with finite words over a finite alphabet . For reasons that will be clear later, we assume without loss of generality that for some integer .
We index words starting at position , so that denotes the first symbol of , and is the factor beginning at position and ending at position .
We let denote the reverse of a word; thus, for example, . A word is a palindrome if ; an example in English is the word radar. A palindrome is even if it is of even length, and odd otherwise. If a palindrome is of length , then its order is defined to be . A palindrome is trivial if it is of length , and nontrivial otherwise. We are not interested in trivial palindromic prefixes in this paper, since every nonempty word has such prefixes of length [math] and .
A word has an even palindromic prefix (resp., odd palindromic prefix) if there is some nonempty prefix (possibly equal to ) that is a palindrome of even (resp., odd) length. Thus, for example, the English word diffident has the even palindromic prefix diffid of order , and the English word selfless has an odd palindromic prefix selfles of order .
A border of a word is a word , , that is both a prefix and suffix of . If a word has a border, we say it is bordered, and otherwise it is unbordered. For example, alfalfa is bordered, but chickpea is unbordered. Bordered and unbordered words have been studied for almost fifty years; see, for example, [12, 4].
Call a border of a word long if and short otherwise. If a word has a long border , then by considering the overlap of the two occurrences of , one as prefix and one as suffix, we see that also has a short border. Given a word , its set of short border lengths is .
By explicit counting for small , one quickly arrives at the conjecture that , the number of length- words over that are unbordered, equals , the number of length- words over having no even palindromic prefix. This seems to be true, despite the fact that the individual words being counted differ in the two cases. As an example consider , which has an even palindromic prefix but is unbordered. Similarly, if denotes the number of length- words over having no nontrivial odd palindromic prefix, it is natural to conjecture that for odd, and for even. The first few terms of the sequences and are given in the following table.
The sequence is sequence A308528 in the On-Line Encyclopedia of Integer Sequences (OEIS) [9], and the sequence is sequence A003000.
In fact, even more seems to be true: if is any set of positive integers, then the number of length- words for which specifies the lengths of all the short borders of is exactly the same as the number of length- words having even palindromic prefixes with orders given by . A similar, but slightly different claim seems to hold for the odd palindromic prefixes. How can we explain this?
The obvious attempts at a bijection (e.g., map to ) don’t work, because (for example) and both map to . Nevertheless, there is a bijection, as we will see below, and this bijection provides even more information.
2 A bijection on
The perfect shuffle of two words and , both of length , is written , and is defined as follows: if and , then
[TABLE]
Thus, for example, = calliope.
Clearly , a fact we use below.
Lemma 1**.**
Let be an even-length word, and (uniquely) write for words with . Then is a palindrome iff .
Proof.
Suppose is palindrome. Then for some word .
By “unshuffling”, write as , for words and , where is either empty or a single letter, depending on whether is even or odd. Then
[TABLE]
It follows that and , and hence .
Similarly, suppose . Write , where are words of equal length, and is either empty or a single letter, depending on whether is even or odd. Then . Hence
[TABLE]
Letting , we see that , and so is a palindrome. ∎
For a related result, see [10].
We now define a certain map from to , as follows:
[TABLE]
if with and empty or a single letter (depending on whether is even or odd). Thus, for example, and . Clearly this map is a bijection.
Theorem 2**.**
Let be a word and let . Then has a border of length iff has an even palindromic prefix of order .
Roughly speaking, this theorem says that “maps borders to orders”.
Proof.
Suppose has a border of length . Then , where . Write , where and is either empty, or a single letter, depending on whether is even or odd. Then
[TABLE]
which by Lemma 1 has a palindromic prefix of length and order .
Suppose has an even palindromic prefix of order . Write , so that . Write and such that . Now
[TABLE]
It follows that is a palindrome and thus by Lemma 1. Hence has a length- border, namely . ∎
Corollary 3**.**
Let . Then the number of length- words whose short borders are exactly those in equals the number of length- words whose even palindromic prefixes are of orders exactly those in .
In particular, this holds for , so the equality holds for all and : the number of length- words that are unbordered is the same as the number of length- words having no even palindromic prefix.
Proof.
As we have seen in Theorem 2, the map is a bijection from the the first set to the second. ∎
Example 4**.**
As an example, consider the length- binary words with short borders of length and only. There are 8 of them:
[TABLE]
By applying the map to each word, we get the length- binary words having even palindromic prefixes of orders and only:
[TABLE]
Let denote the number of length- words over a -letter alphabet having even palindromic prefixes of order for each , and no other orders.
Proposition 5**.**
We have for even.
Proof.
Let be even. Let be a word over a -letter alphabet with even palindromic prefix orders given by , and let be a single letter. Then clearly has exactly the same palindromic prefixes as . Since is arbitrary, the result follows. ∎
3 Odd palindromic prefixes
Let be any subset of . Let denote the number of length- words over a -letter alphabet having odd palindromic prefixes of order for each , and no others. Notice that we are not concerned here with those words having the trivial odd palindromic prefix of a single letter.
Proposition 6**.**
We have for odd.
Proof.
Exactly like the proof of Proposition 5. ∎
Theorem 7**.**
We have
- (a)
* for odd; and*
- (b)
* for even.*
Proof.
We begin by proving for odd. We do this by creating a to map from the length- words with odd palindromic prefix orders given by to the length- words with even palindromic prefix orders given by .
Here is the map. Let be a word of odd length, and define , where the addition is performed modulo . We claim that this is a to map, and furthermore, it maps words with odd palindromic prefix orders given by to words with even palindromic prefix orders also given by .
To see the first claim, observe that if both and are given, then we can uniquely reconstruct . Since is arbitrary, this gives a to map.
To see the second claim, suppose has an odd palindromic prefix of order . Then for . Hence, applying the map to a prefix of we get
[TABLE]
which is clearly an even palindrome of order .
On the other hand, if is a palindrome, then by examining the two elements in the middle, we get , which forces . Continuing from the middle out to the end, we successively obtain , …, , which shows that starts with an odd palindrome of order .
Hence for odd we get
[TABLE]
where we have used Proposition 5.
For even we get
[TABLE]
which completes the proof. ∎
Corollary 8**.**
Consider words over a -letter alphabet.
For odd, we have ; that is, the number of length- words having no nontrivial odd palindromic prefix is the same as the number of length- words that are unbordered.
For even, we have ; that is, the number of length- words having no nontrivial odd palindromic prefix is times the number of length- unbordered words.
Remark 9*.*
It is seductive, but wrong, to think that the map also maps even-length palindromic prefixes in a to manner to odd-length palindromic prefixes, but this is not true (consider what happens to the center letter).
4 An application
As an application of our results we can (for example) determine the asymptotic fraction of length- words having no nontrivial even palindromic prefix (resp., having no nontrivial odd palindromic prefix).
Corollary 10**.**
For all there is a constant such that the number of length- words having no nontrivial even palindromic prefix (resp., having no nontrivial odd palindromic prefix) is asymptotically equal to .
Proof.
Follows immediately from the same result for unbordered words; see [8, 1, 5]. For related results, see [11]. ∎
5 Interlude: the permutation defined by
The map defined in Section 2 can be considered as a permutation on . In this case, we write it as . For example, if , the resulting permutation is
[TABLE]
This is an interesting permutation that has been well-studied in the context of card-shuffling, where it is called the milk shuffle. A classic result about the milk shuffle is the following [6]:
Theorem 11**.**
The order of the permutation is the least such that (mod ).
This is sequence A003558 in the OEIS.
6 No palindromic prefix
In this section we consider the words having no nontrivial palindromic prefix. (Recall that a palindrome is trivial if it is of length .) This is only of interest for alphabet size , for if , the only such words are of the form and .
Let denote the number of such words over a -letter alphabet. We use the technique of [1, 5] to show that for a constant and large . First we need a lemma, which can essentially be found in (for example) [2, Prop. 6].
Lemma 12**.**
Let be a palindrome and let be a proper palindromic prefix of . If , then also has a nonempty palindromic prefix of length .
Proof.
If is a prefix of , then is a suffix of . Since both and are palindromes, this means is a suffix of . Hence there exist nonempty words such that . By the Lyndon-Schützenberger theorem [7] there exist with nonempty, and an integer such that , , and . Since , it follows that . Since is a palindrome, we have . Since is a palindrome, we have . So , and so . Thus is a nonempty palindromic prefix of , which is a prefix of , and . ∎
Lemma 13**.**
Let be words with . Then has a nontrivial palindromic prefix iff has a nontrivial proper palindromic prefix.
Proof.
One direction is trivial.
For the other direction, let the shortest nontrivial proper palindromic prefix of be . If , then is a prefix of as desired. Otherwise we have . Then by Lemma 12, the word also has a nontrivial palindromic prefix of length , contradicting the definition of . ∎
Proposition 14**.**
For we have
[TABLE]
Proof.
Consider the words of length having no nontrivial palindromic prefix. By appending a new letter, we get words. However, some of these words can be palindromes of length , and we do not want to count these. By Lemma 13, the number of length- palindromes having no proper palindromic prefix is . This gives (2).
A similar argument works to prove (3). ∎
For the corresponding sequence is given below and is sequence A252696 in the OEIS:
Now define by . From (2) and (3) we get
[TABLE]
It now follows that
[TABLE]
By telescoping cancellation applied to (4), we now get
[TABLE]
or
[TABLE]
Next, define . Since for all , it follows that the series defining is convergent for . Then
[TABLE]
where is the limiting frequency of words having no nontrivial palindromic prefix.
Using (4), we now get
[TABLE]
and so we get a functional equation for :
[TABLE]
By iterating this functional equation, and using the fact that for small real , we get an expression for :
[TABLE]
This is very rapidly converging; for only terms are enough to get 60 decimal places of :
[TABLE]
7 Square prefixes
It is natural to conjecture that our bijections connecting words with no border and no even palindromic prefix might also apply to words having no square prefix. However, this is not the case. Let denote the number of length- words over having no square prefix. When , for example, the two sequences and differ for the first time at , as the following table indicates.
The sequence is sequence A122536 in the OEIS.
Chaffin, Linderman, Sloane, and Wilks [3, §3.7] conjectured that for a constant . In this section we prove this conjecture in more generality.
Theorem 15**.**
The limit exists and equals a constant with .
Proof.
Let be the number of length- words over having a nonempty square prefix, and let be the number of squares of length over having no nonempty proper square prefix. Hence and .
The first few values of and are given in the following table.
The sequence is sequence A216958 in the OEIS, and the sequence is sequence A121880.
Let be a word of length . Either its shortest square prefix is of length 2 (and there are such words), or of length 4 (and there are such words), and so forth.
So , the number of words of length having a nonempty square prefix, is exactly . Hence . Thus exists iff the infinite sum converges. But, since , this sum converges to some constant , by comparison with the sum . It follows that . Letting , the result follows. ∎
To estimate the value of (and hence ) we use the inequalities
[TABLE]
For example, if we take , we get and hence . This can be compared to the analogous constant for even palindromes.
Acknowledgments
We are grateful to the referees for their helpful comments.
The reference list from the paper itself. Each links out to its DOI / PubMed record.
- 1[1] G. Blom. Overlapping binary sequences (problem 94-20). SIAM Review 37 (1995), 619–620.
- 2[2] A. Blondin Massé, S. Brlek, A. Garon, and S. Labbé. Equations on palindromes and circular words. Theoret. Comput. Sci. 412 (2011), 2922–2930.
- 3[3] B. Chaffin, J. P. Linderman, N. J. A. Sloane, and A. R. Wilks. On curling numbers of integer sequences. J. Integer Sequences 16 (2013), 13.4.3 (electronic), Available at https://cs.uwaterloo.ca/journals/JIS/VOL 16/Sloane/sloane 3.html .
- 4[4] A. Ehrenfeucht and D. M. Silberger. Periodicity and unbordered segments of words. Discrete Math. 26 (1979), 101–109.
- 5[5] Š. Holub and J. Shallit. Periods and borders of random words. In N. Ollinger and H. Vollmer, editors, 33rd Symposium on Theoretical Aspects of Computer Science (STACS 2016) , Vol. 47 of Leibniz International Proceedings in Informatics (LIP Ics) , pp. 44:1–44:10. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, Dagstuhl, Germany, 2016. Available at http://drops.dagstuhl.de/opus/volltexte/2016/5745 .
- 6[6] P. Lévy. Sur quelques classes de permutations. Compositio Math. 8 (1951), 1–48.
- 7[7] R. C. Lyndon and M. P. Schützenberger. The equation a M = b N c P superscript 𝑎 𝑀 superscript 𝑏 𝑁 superscript 𝑐 𝑃 a^{M}=b^{N}c^{P} in a free group. Michigan Math. J. 9 (1962), 289–298.
- 8[8] P. Tolstrup Nielsen. A note on bifix-free sequences. IEEE Trans. Inform. Theory IT-19 (1973), 704–706.
