Improved Bounds on the Sum of Exponents of Runs in a String
Abstract
A substring of a word is a run if it is at least twice as long as its minimum period and cannot be extended to either side with the same period. The exponent of a run is the quotient of its length and its minimum period. is the maximum number of runs in a string of length , while is the maximum sum of exponents of runs in a string of length . While quite tight bounds on are known (), the best upper bound on is whereas the best lower bound on is . In this paper, we improve the upper bound on to and the lower bound on to . We also provide an improved upper bound on of in the case of a binary alphabet. Our results are achieved using a combination of theoretical and computer-based approaches.
Keywords and phrases:
strings, runs, sum of exponents of runs, Lyndon words, L-roots, maximal repetitions, combinatorics on words2012 ACM Subject Classification:
Theory of computation Pattern matching ; Mathematics of computing Combinatorics on wordsSupplementary Material:
Software (Source Code): https://github.com/Markadiusz/runsarchived at
swh:1:dir:4c7ea1dea83b8d0be4e187b11862bd5de304a7e8
Funding:
Supported by the Polish National Science Center, grant no. 2022/46/E/ST6/00463.Editors:
Philip Bille and Nicola PrezzaSeries and Publisher:
Leibniz International Proceedings in Informatics, Schloss Dagstuhl – Leibniz-Zentrum für Informatik
1 Introduction
For a string over some alphabet , we call a triple a run if the substring has a minimum period of , has length at least and cannot be extended to either left or right with the same period within . Moreover, for a run , we define to be its exponent.
For example, the string contains two runs – , corresponding to the substring , with an exponent of , and , corresponding to the substring , with an exponent of .
Runs, in a sense, capture all information about repetitions in a string, and their study is important in the design of string algorithms [5] [2]. Two quantities of particular interest are:
-
– the maximum possible number of runs in a string of length
-
– the maximum possible sum of exponents of runs in a string of length
Two related quantities are:
-
– the maximum possible number of runs in a string of length over an alphabet of size
-
– the maximum possible sum of exponents of runs in a string of length over an alphabet of size
Note 1.
Clearly, and for any .
Due to the exponential number of distinct strings of length , the exact values of and are not known for even moderately big . Much of the previous work was hence focused on obtaining bounds on those quantities.
From the definition, one can see that both and are at most polynomial in . Kolpakov and Kucherov [11] proved an upper bound on both and . The upper bound on has been further refined as follows:
While many of the above approaches were very technical and often were computer-assisted, the bound proven by Bannai et al. [1] was based on a very elegant argument that related the runs with the occurrences of so-called Lyndon words in strings.
Other noteworthy results are the papers of Fischer et al. [7] and S. Holub [10], who showed upper bounds on of and , respectively.
On the other hand, researchers have been trying to come up with run-rich words to obtain a lower bound on . Here, the most relevant results are:
All of the above lower bounds are achieved by binary strings – strings over an alphabet of size .
With the upper bound on being so close to the lower bound, especially in the case of binary strings, the problem of bounding seems to be practically solved. However, the problem of bounding is quite far from being solved.
The history of improving the upper bound on includes the results:
The result by Bannai et al. [1] was achieved by showing that . By a similar argument, one can show an analogous inequality for binary strings. This means that the upper bound on established by S. Holub in [10] in turn gives an upper bound of on .
On the other hand, the best lower bound on is by Crochemore, Kubica, Radoszewski, Rytter, Waleń [6].
2 Preliminaries
This section is heavily based on Sections and of the Bannai et al. paper [1], which contains the omitted proofs of some of the lemmas.
Let be a finite set called the alphabet. An element of is called a string. The length of a string is denoted by . The empty string is a string of length . For a string , , and are called a prefix, substring, and suffix of , respectively. A prefix (resp. suffix) of is called a proper prefix (resp. suffix) of if . The -th character of a string is denoted by , where . For a string and two integers , let denote the substring of that begins at position and ends at position . For convenience, let when . An integer is said to be a period of a string if for all .
Definition 2 ([11, maximal repetition]).
A triple is a run of string , if is the smallest period of , , the periodicity cannot be extended to the left or right, i.e., or , and or . The rational number is called the exponent of .
Example 3.
The string contains runs , .
Let denote the set of runs of string . Let denote the sum of exponents of runs of string . Let denote the maximum possible number of runs in a string of length . Let denote the maximum possible sum of exponents of runs in a string of length . Similarly, let denote the maximum possible number of runs in a string of length over the binary alphabet and denote the maximum possible sum of exponents of runs in a string of length over the binary alphabet.
Let us now quickly prove two lemmas about exponents of runs that will be useful later.
Lemma 4.
Let be two arbitrary strings. We have .
Proof.
Let and let be a run of . Consider the string where . If or , then clearly is still a run in . Otherwise, is a run in (here ). An analogous argument holds for prepending a character to .
Let . For each position of let
Similarly, for each position of let
From the period-maximality of runs, we know that there can be at most one run for a given pair or pair. Sets and describe all runs from and , respectively, that include position . From the previous argument, we see that those sets can only expand when calculated for . It follows that the contribution of each position to is no smaller than it was to either or .
Note 5.
A similar inequality does not hold for runs. For example, the string has one run – , while its square has only one run – .
From the above lemma, we can conclude that:
Corollary 6.
For , we have .
Corollary 7.
For , we have , by induction on .
Lemma 8.
Let . If for all the inequality holds, then is true as well.
Proof.
Note 9.
It is important to note that Lemma 8 holds also for , since we did not assume anything about the alphabet.
While the definition of a run requires only an equivalence relation on , introducing an order on lets us study runs in more detail.
Let denote some total order on , as well as the lexicographic order induced on .
Definition 10 ([12, Lyndon Word]).
A non-empty string is said to be a Lyndon word with respect to , if for any non-empty proper suffix of .
Note 11.
A Lyndon word cannot have any period , since its existence would imply for some non-empty and some , and .
Definition 12 ([1, Definition 4]).
Let be a run in a string . An interval of length is an L-root of with respect to if and is a Lyndon word with respect to .
It is easy to see that for any run and lexicographic order , there exists at least one L-root with respect to .
Let denote some pair of total orders on such that for any pair of characters , we have . For , let .
For any string , let , where is a special character that satisfies (and thus ) for any .
Remark 13.
The character is introduced mainly to simplify the following lemmas and definitions. Notice that appending such a character to a string does not affect the structure of its runs in any way.
Definition 14 ([1, Definition 5]).
For any string and position , let where . Notice that is well defined since one-character strings are Lyndon words.
This definition is illustrated in Example A.1 in the Appendix.
Lemma 15 ([1, Lemma 7]).
Let be an arbitrary run in a string of length . Then, for a unique such that , any L-root of with respect to is equal to .
For any run of , let r with respect to , , where is such that , i.e. is the set of all L-roots of with respect to such that , except for the one that starts from if it exists. For any set of intervals, let denote the set of beginning positions of intervals in . Additionally, let denote for any run . The set is called the set of special positions of the run .
Example 16.
Consider the string . The special positions of its runs, along with related L-roots, are as follows:
Lemma 17 ([1, Lemma 8]).
For any two distinct runs and of string , is empty.
From Lemma 17 it follows that each position of a string is a special position for at most one run and since each run contains at least one special position, this gives the upper bound proven by Bannai et al. [1, Theorem 9].
This relation between runs and special positions is not only theoretical, but it can often also be efficiently computed locally without having to consider the whole string.
First, consider some run of a string . One can find its set of special positions by
-
determining an appropriate order , by comparing and
-
checking which substrings of of length are Lyndon words with respect to
Second, consider some position of a string . One can find a run for which is special (or determine that there is no such run) by the following method adapted from [7, Lemma 2] to work for general alphabets (the original lemma considered a binary alphabet):
-
Assume that is a special position of .
-
If , we know that is a special position of the unique run with period that contains position .
-
If , we would like to know with respect to which order the interval is an L-root of . Since , we must have , because otherwise would not be a Lyndon word with respect to . Now that we know the only possible order , it is sufficient to check whether the unique period-maximal extension of is a run with period , i.e. whether its length is at least twice the period.
3 Upper bound
3.1 Main idea
The main idea of the Bannai et al. paper [1] was to establish a mapping from runs to disjoint sets of positions of the string. The strategy for improving the upper bound on , which we present here, will be based on designing a similar mapping from exponents of runs to rational values assigned to positions of the string.
Consider some run of a string along with its set of special positions . This run contributes to . From another perspective, each character of is contributing to through . The main idea will be to partition the interval into intervals and have each of the special positions of account for the contributions from its respective part.
Let be the special positions of in increasing order. Notice that for . We want to partition the interval into the following intervals:
If there is only one special position for , this position alone will be assigned the full exponent of .
Definition 18.
Let be a string. Let be a special position of some run of . Let be a partial function defined on special positions of as follows:
Let be a partial function defined on special positions of as follows:
Let be a function defined on all positions of as follows:
Note 19.
Notice that .
Example 20.
Consider the following string , which contains, among others, the run .
Since must be less than , we consider the L-roots of with respect to . This means the set of special positions of the run is . Notice that is not a special position of since we cannot have a special position at the start of a run. The interval is then partitioned into three intervals: and . This means that , , and . For positions we have as they are the only special positions in their two-character runs with period . All other positions will be assigned the value of since there are no more runs in .
Notice that in the above example, all values of are quite small. Indeed, it turns out not to be a coincidence.
Lemma 21.
For each , we have .
Proof.
Let be a run and be its special position. By definition, . By definition, , since . In total, we get that . It follows that .
Remark 22.
Notice that since the first position of a string can never be special, from the above lemma we can conclude that , which is the upper bound established in [1, Theorem 10].
An interesting property of the above mapping is that the values assigned to positions are local and often can be deduced from the neighbourhood of the position of size proportional to the period of the corresponding run.
This leads us to the following strategy of improving the upper bound on . Consider some string . We want to split string into a sequence of smaller strings and obtain a bound for each of the smaller strings separately. Here, and are some prefix and suffix of , respectively, that we want to be of constant size. Assume that for each we are able to bound the sum of the values assigned to positions of by , where . Then by Lemma 21 we would get the following upper bound on :
If we are able to get such a bound for each possible string, then by Lemma 8 it will follow that .
Our task is now reduced to efficiently splitting any string into strings , and then bounding the sum of values assigned to positions of each . Let us cover the bounding methods first.
3.2 Basic bounding method
Consider some string that is part of a larger string . Let be the value assigned to the -th position of when mapping from exponents of runs of to positions of . More specifically, assuming that corresponds to for some , we have for . Our goal is to bound .
While some runs of might not be runs when restricted to (since they would be shorter than twice their period), sometimes a run of will also be a run of . Let be such a run in . Let us consider a few cases.
-
1.
and
This is the simplest and most pleasant case. Notice that since is contained strictly within , the influence of on will always be the same no matter what is. This means that we can determine ’s respective order, find all its L-roots, and assign appropriate values to its special positions.
This case is illustrated in Example A.2.1 in the Appendix.
-
2.
and
In this case, since , we can still determine the respective order for . However, since , we do not know how far to the left the run goes within . This is not that much of a problem as it might seem. For all but the leftmost special position contained in we can easily compute their assigned values. For the leftmost position, we know that the left end of its interval is at most to its left, because otherwise there would be another special position.
This case is illustrated in Example A.2.2 in the Appendix.
-
3.
This case could be further split based on the relation between and , but we omit it here since the method for the leftmost special position is the same as in the previous two cases.
Now, we do not know how far to the right the run goes in . What is worse, we do not know which order we should use. Again, this turns out not to be much of an issue. We can just consider both cases and take the worst of the two bounds we get for both potential sets of special positions. While considering an order , we will assume that the special positions for the other order are all bounded using the naive bound of .
This case is illustrated in Example A.2.3 in the Appendix.
3.3 Efficient splitting for binary strings
Let us focus on binary strings for now. They are easier to work with and allow for a simpler introduction of some new ideas.
Theorem 23.
We have .
Proof.
Consider all possible 4-character words over the binary alphabet .
Except for and , every such string contains a run with period , which allows us to bound the value assigned to at least one of its positions by . This gives us a total bound of .
In the case of and , either the second or the third position is a special position of a run with period , so its value can be bounded by . This gives us a total bound of .
It follows that we get an average bound per character.
Remark 24.
This already improves on the previously best upper bound of established in [10, Theorem 1].
The above proof can be extended by considering strings of greater length. However, it is very inefficient to consider all strings of a given length, since there is an exponential number of them. This approach gets even worse when we consider strings over a general alphabet.
To remedy this issue, we prune unnecessary cases by building a trie of the considered strings as follows:
Example 25.
Consider the following pruned trie corresponding to the strings considered in the proof of Theorem 23.
All leaves of the trie contain strings that can be bounded by per character. Consider the string
We split it by each time cutting off some leaf of the above tree as follows:
Here, the unmatched string has constant size, so it does not matter by Lemma 8.
In general, our goal is to build a full binary tree and calculate the per-character bounds for each of its leaves. Then, such a tree can be used to split any string by following the edges with appropriate labels downwards from the root until we reach a leaf, cutting off the travelled path, and continuing again from the root until we get to the end of the string.
To save some space, let us focus on the left part of the tree for now. The other part is symmetric and has the same bounds in the case of binary strings.
Algorithm for constructing the trie
To build this tree efficiently, we start with a single node containing a one-character string . Now, each time we choose a leaf of the tree with the worst bound, and expand from this node by adding its two children and computing their bounds. The bound of a node is the minimum of the bounds of each of its prefixes, since while splitting the string, we can choose to split at any node in the tree with a satisfactory bound.
This approach is illustrated in Example A.3 in the Appendix.
This approach of always expanding the worst bounded leaves allows us to most efficiently reduce the upper bound on while considering a much smaller number of cases than the naive exponential approach.
This method can be quite easily implemented to run on a computer. While the computer assistance greatly improves the bounds we get, the results for binary strings seem to plateau around . To go further, we will need to develop new bounding methods.
3.4 Other bounding methods
3.4.1 Detection of non-special positions
The previously considered basic bounding method works great when the strings we consider have plenty of runs. With increased string lengths, we are able to consider even more runs and further improve our bounds. Problems begin when the strings we analyse have very few runs.
As we can see in the Example A.4 in the Appendix, determining that some position is not a special position improves the bound drastically since we are changing the naive to a . Let us describe in detail when we can perform such a deduction.
Let be a substring of , and be a position of that we want to examine. First, we compare with to determine which one of and to use (see final remarks of Section 2). Notice that cannot be equal to since otherwise would be a special position for a run with period . Second, we need to find some such that and is not a prefix of . This allows us to bound the length of the longest Lyndon word with respect to starting at no matter what is. After that, we find the longest Lyndon word with respect to starting at and find its period-maximal extension . If and and , then we can conclude that never is a special position irrespective of .
Example 26.
Consider the following string that is part of some other string .
Let us focus on the second position of . We choose , since we want . However, because , we see that the longest Lyndon word with respect to starting at the second position has length and cannot be extended to either left or right. It follows that this is not a special position, so it is assigned a value of . This gives a per-character bound of for .
This example provides some intuition for why non-binary strings often have small sums of exponents of runs as compared to binary strings.
3.4.2 Expanding the context window
Example 27.
Let us have a closer look at the string , which is part of some binary string . Previously in Example 36, we used the naive per-character bound of for it. There are no runs in , but at the same time, we have too little information to determine that some of its positions are not special. To provide a better bound for , we need to expand our context window.
Let us consider two cases based on the character of that is just before . Let us denote this character . Notice that we can assume that there is a sufficient number of characters in before , as long as they are of constant length, by making sure the naively bounded prefix of is long enough.
-
Since , we have a run , which means is a special position of a run with period and can be bounded by .
-
Since , we have a run , which means either or is a special position of a run with period and can be bounded by .
In total, we get can be bounded by , which is an per-character bound.
The general idea of this method is to look ahead a couple of characters to the left and right of and branch on their values. We can assume that there is a sufficient number of characters in before and after , as long as they are of constant length, by making sure the naively bounded prefix and suffix of are long enough. Then, we can refine the bound for to be the maximum over the bounds for all those cases, which often turns out to be lower than the basic bound, since all those cases have access to more context.
Since there is an exponential number of cases to consider for a given extension length, the actual method used resembles the trie construction described in Section 3.3 and is covered in Section 3.6.
In Section B of the Appendix, we prove by hand the following theorem, which improves the result from Theorem 23:
Theorem 28.
We have .
All of the above methods quite easily translate to a computer program that allows us to expand our search to millions of cases. Efficiently implementing the covered approaches gives us the claimed bound. The details of the implementation are covered in Section 3.6.
3.5 General alphabet
A natural next step is to adapt the techniques developed for bounding binary strings to strings over a general alphabet.
The first issue we need to tackle is how to iterate over strings with arbitrary characters. The main idea is that when analysing a small substring of some string , we do not care about the exact values of the characters, but only their relative order in and . This allows us to renumber the considered values, which makes all of them bounded by the length of the considered strings.
The first three levels of a splitting trie for general strings could then look as follows:
It is important to note that in addition to appending an already present character, we also need to consider putting the value of the new character between the values of already present characters. This might cause us to renumber some of the existing values. For example, this is how we get from to – we append a value smaller than , and this causes us to renumber the resulting string to . It is also important to remember that we need to use the same expansion scheme when considering longer context windows to make sure we consider all possible cases.
Unfortunately, after implementing the above approach, we encounter a much bigger issue – there are strings for which the best per-character bound we get is .
Consider the string that is part of some string . There are no runs in . Moreover, for each position of , its longest Lyndon word goes all the way to the end of . This means we cannot definitely say that they are not special positions, because that depends on the rest of . We are left with the naive per-character bound of .
All hope is not lost yet. Recall that in Example 26 we showed a per-character bound of for the string . Similarly, for , its middle characters are not special positions. This gives us a per-character bound of for .
While in the previous sections we chose to be the alphabetical order, for it would be much better for to be such an order that . Unfortunately, we cannot just choose a different order for each string . What we can do instead is to choose some order for the whole . It would be nice to choose the order that allows us to best bound . However, this is quite tricky since we only see small sections of and they can occur in in arbitrary proportions.
The approach that turns out to work well for this problem is to choose the order at random. More specifically, we want to calculate the expected bound on when is chosen uniformly at random from the set of all possible total orders on . It follows that there exists an order which achieves a bound on no worse than the expected bound, and this is the one that we use. By the linearity of the expected value, the expected bound on is the sum of the expected bounds on the small segments of .
This leads us to the actual way we generalize the bounding method for binary strings to arbitrary strings:
-
1.
We build the splitting trie based on equivalence classes over the string . The first four levels of the splitting trie for general strings then look as follows:
Remark 29.
Actually, we would never expand from the node, since it already has an expected per-character bound of , which is lower than the per-character lower bound on .
-
2.
To bound some node , we first consider possible context expansions to gain more information about the neighbourhood of . In this expansion, we again expand only based on the equivalence between characters of . We do not care about their relative order yet.
-
3.
Next, for a string which has different characters, we consider all possible total orders on those characters and separately bound each of those orders. Because each of those orders on characters is equally likely among all total orders on characters of , we just need to calculate their arithmetic mean to get the expected bound.
-
4.
Finally, to get a bound for string along with some order , we use the previously developed methods of assigning values to special positions of runs and determining that some positions are not special.
Efficiently implementing the above approach gives us the claimed bound. The details of the implementation are covered in Section 3.6.
3.6 Implementation details
Our final results about the upper bound are the following two theorems:
Theorem 30.
We have .
Theorem 31.
We have .
The proofs of both of them relied on heavy computer assistance and required a few days of CPU time to finish.
A notable idea here is that instead of always expanding the worst bounded node, it’s much more efficient to aim to prove some target upper bound, because then we can expand from any node of the tree. Because of that we do not have to keep the whole tree in memory, and the whole procedure can be implemented easily using recursion. This approach allows also for easy parallelization of computations.
4 Lower bound
4.1 Result
Consider the following context-free grammar with productions:
in which are the terminals, are the non-terminals and is the start variable. Each uniquely produces some binary string of s and s. The start symbol produces a binary string of length , whose sum of exponents of runs has been verified by a computer program to be greater than . This has been done using an approach similar to the linear time method of finding all runs described in [1, Section 4]. This result improves upon the previously best lower bound on of from [6, Theorem 4.1].
References
- [1] Hideo Bannai, Tomohiro I, Shunsuke Inenaga, Yuto Nakashima, Masayuki Takeda, and Kazuya Tsuruta. The “runs” theorem. SIAM J. Comput., 46(5):1501–1514, 2017. doi:10.1137/15M1011032.
- [2] Panagiotis Charalampopoulos, Tomasz Kociumaka, Jakub Radoszewski, Wojciech Rytter, Tomasz Walen, and Wiktor Zuba. Efficient enumeration of distinct factors using package representations. In Christina Boucher and Sharma V. Thankachan, editors, String Processing and Information Retrieval - 27th International Symposium, SPIRE 2020, Orlando, FL, USA, October 13-15, 2020, Proceedings, volume 12303 of Lecture Notes in Computer Science, pages 247–261. Springer, 2020. doi:10.1007/978-3-030-59212-7_18.
- [3] Maxime Crochemore and Lucian Ilie. Maximal repetitions in strings. J. Comput. Syst. Sci., 74(5):796–807, 2008. doi:10.1016/j.jcss.2007.09.003.
- [4] Maxime Crochemore, Lucian Ilie, and Liviu Tinta. The “runs” conjecture. Theor. Comput. Sci., 412(27):2931–2941, 2011. doi:10.1016/J.TCS.2010.06.019.
- [5] Maxime Crochemore, Costas S. Iliopoulos, Marcin Kubica, Jakub Radoszewski, Wojciech Rytter, and Tomasz Walen. Extracting powers and periods in a word from its runs structure. Theor. Comput. Sci., 521:29–41, 2014. doi:10.1016/J.TCS.2013.11.018.
- [6] Maxime Crochemore, Marcin Kubica, Jakub Radoszewski, Wojciech Rytter, and Tomasz Walen. On the maximal sum of exponents of runs in a string. J. Discrete Algorithms, 14:29–36, 2012. doi:10.1016/J.JDA.2011.12.016.
- [7] Johannes Fischer, Stepan Holub, Tomohiro I, and Moshe Lewenstein. Beyond the runs theorem. In Costas S. Iliopoulos, Simon J. Puglisi, and Emine Yilmaz, editors, String Processing and Information Retrieval - 22nd International Symposium, SPIRE 2015, London, UK, September 1-4, 2015, Proceedings, volume 9309 of Lecture Notes in Computer Science, pages 277–286. Springer, 2015. doi:10.1007/978-3-319-23826-5_27.
- [8] Frantisek Franek and Qian Yang. An asymptotic lower bound for the maximal number of runs in a string. Int. J. Found. Comput. Sci., 19(1):195–203, 2008. doi:10.1142/S0129054108005620.
- [9] Mathieu Giraud. Not so many runs in strings. In Carlos Martín-Vide, Friedrich Otto, and Henning Fernau, editors, Language and Automata Theory and Applications, Second International Conference, LATA 2008, Tarragona, Spain, March 13-19, 2008. Revised Papers, volume 5196 of Lecture Notes in Computer Science, pages 232–239. Springer, 2008. doi:10.1007/978-3-540-88282-4_22.
- [10] Stepan Holub. Prefix frequency of lost positions. Theor. Comput. Sci., 684:43–52, 2017. doi:10.1016/J.TCS.2017.01.026.
- [11] Roman M. Kolpakov and Gregory Kucherov. Finding maximal repetitions in a word in linear time. In 40th Annual Symposium on Foundations of Computer Science, FOCS ’99, 17-18 October, 1999, New York, NY, USA, pages 596–604. IEEE Computer Society, 1999. doi:10.1109/SFFCS.1999.814634.
- [12] Roger Lyndon. On Burnside’s problem. Transactions of the American Mathematical Society, 77:202–215, 1954. URL: https://api.semanticscholar.org/CorpusID:51747091.
- [13] Wataru Matsubara, Kazuhiko Kusano, Hideo Bannai, and Ayumi Shinohara. A series of run-rich strings. In Adrian-Horia Dediu, Armand-Mihai Ionescu, and Carlos Martín-Vide, editors, Language and Automata Theory and Applications, Third International Conference, LATA 2009, Tarragona, Spain, April 2-8, 2009. Proceedings, volume 5457 of Lecture Notes in Computer Science, pages 578–587. Springer, 2009. doi:10.1007/978-3-642-00982-2_49.
- [14] Simon J. Puglisi, Jamie Simpson, and William F. Smyth. How many runs can a string contain? Theor. Comput. Sci., 401(1-3):165–171, 2008. doi:10.1016/J.TCS.2008.04.020.
- [15] Wojciech Rytter. The number of runs in a string: Improved analysis of the linear upper bound. In Bruno Durand and Wolfgang Thomas, editors, STACS 2006, 23rd Annual Symposium on Theoretical Aspects of Computer Science, Marseille, France, February 23-25, 2006, Proceedings, volume 3884 of Lecture Notes in Computer Science, pages 184–195. Springer, 2006. doi:10.1007/11672142_14.
- [16] Wojciech Rytter. The number of runs in a string. Inf. Comput., 205(9):1459–1469, 2007. doi:10.1016/J.IC.2007.01.007.
- [17] Jamie Simpson. Modified Padovan words and the maximum number of runs in a word. Australas. J Comb., 46:129–146, 2010. URL: http://ajc.maths.uq.edu.au/pdf/46/ajc_v46_p129.pdf.
Appendix A Examples
A.1 Definition of
Example 32.
Consider the string . Its values are as follows:
A.2 Basic bounding method
A.2.1 Case and
Example 33.
Consider the following string , which contains the run .
Since , the special positions of are and we have . Since we do not know much about other positions (yet), let us bound their values by . This gives us a bound on , which is a average bound per a character of .
A.2.2 Case and
Example 34.
Consider the following string , which contains the run .
Since , the special positions of are and we have and . This gives us a bound on , which is an average bound per a character of .
A.2.3 Case
Example 35.
Consider the following string , which contains the run .
In the figure on the left, we use the order, and in the right figure, we use the order. In the first case, we have , while in the second case we have . The bound for the left case is for the positions contained in those sets, while the right case gives a bound of . We pick the worse of those bounds and along with the bounds for the first and seventh position we get a bound of on , which is an average bound per a character of .
A.3 Algorithm for contructing the trie
Example 36.
Consider the following left side of the tree that is in the process of being built.
After starting at node with a bound of , we expanded to two leaves and . Since has a great per-character bound of , there is no need to touch it right now. Instead, we focus on gaining new context for the case. After that, we expand from the node and then from the node. Notice that while the string has a per-character bound of , we assign it the value from its parent , since we could have made the cut earlier.
A.4 Detection of non-special positions
Example 37.
Consider the following string that is part of some other string .
String has runs , and which allow us to assign values of , and to positions , and , respectively. This gives us a bound of , which is a per-character bound of .
However, let us focus on the third position and consider its assigned value. For to be a special position we consider the order in which . We can see that the longest Lyndon word with respect to that starts at position is of length . It cannot be longer, because the suffix starting three positions later will always be smaller. However, the period-maximal extension of the interval is , which is one character short of being a run. We can thus conclude that is never a special position and is assigned a value of . This improves our bound for to , which is a per-character bound of .
Appendix B Proof of Theorem 28
Proof.
To prove this result, we give improved bounds for those leaves of the trie from Example 36 whose basic per-character bound is worse than . Those are and . The negated strings and have the same bounds by symmetry.
Let us start with , which is part of some string . Let us consider two cases based on the character of that is just before . Let us denote this character .
-
Since , we have a run , which means is a special position of a run with period and can be bounded by . Position can also be bounded by as a special position for the run .
-
Since , we have a run , which means is a special position of a run with period and can be bounded by . Position can also be bounded by as a special position for the run .
It total, we get that is bounded by , which gives a per-character bound of .
Now, we consider , which is part of some string . Let us consider two cases based on the character of that is just before . Let us denote this character .
-
Since , we have a run , which means is a special position of a run with period and can be bounded by . We consider two cases based on which set out of and is the set of special positions of the run . We get a bound of .
-
Since , we have just the run . We consider two cases based on which set out of and is the set of special positions of the run . We get a bound of .
It total, we get that is bounded by , which gives a per-character bound of .
Appendix C Lower bound
C.1 Discovery
Let us outline the approach used in the discovery of the sequence, which was based on heavy experimentation.
While analysing the best strings up to some length, one of the first observations one can make is that there are some patterns that are not present in them. One such pattern is . This has a good theoretical justification – the value assigned to each starting from the third one can be bounded by just . In general, having runs with more than one special position is a highly inefficient use of the positions of the string. Assuming that we prohibit such runs, we can see that the remaining sensible binary strings can mostly be made of and – non-terminals and .
Now, we can repeat this procedure but with and . We consider the best strings up to some length over the alphabet and look for patterns in them. This allows us to create new building blocks , which we use in the next iteration.
After a few iterations, we reach a point where the improvements to the lower bound become negligible. This process generates the described grammar. It is also easy to verify the result since the cost of generating is proportional to its length due to the way the sequence is defined.
C.2 Comparison with the previously best result
The previously best lower bound was achieved by Crochemore et al. [6] by a sequence of strings, the best of which had a sum of exponents greater than . We present it below.
Let us define two morphisms and as follows:
Let . A comparison of the sequence and the sequence is presented in Figure 1.
