Palindromic length sequence of the ruler sequence and of the period-doubling sequence
aa r X i v : . [ m a t h . C O ] J u l Palindromic length sequence of the ruler sequence and of theperiod-doubling sequence
Shuo LI ∗ Institut de math´ematiques de Jussieu - Paris Rive GaucheSorbonne UniversityParis, France
Abstract
In this article, we study the palindromic length sequences of the ruler sequence and of theperiod-doubling sequence. We give a precise formula of the palindromic length sequence of thefirst one and find a lower bound of the limit superior of the palindromic length sequence of thelast one.
The palindromic length of a finite word was firstly introduced and defined in [FPZ13], whichis the minimal number of palindromes needed to be concatenated to express the word. The palin-dromic length sequence can be defined as a sequence of the palindromic lengths of each prefix of an(infinite) word. in [FPZ13] authors conjectured that
Conjecture 1
The palindromic length sequence of an infinite word is bounded if and only if theinfinite word is ultimately periodic.
Up to now, this conjecture reminds open. However, it was proven for a large class of words.Combining the results in [Saa17] and [FPZ13], the conjecture was proven for all word containing along p -power-free factor. In [Fri18], the author proved the conjecture for all Sturmian words.Concerning the palindromic length sequence in general, most published papers are on algorithmicaspects. Particularly, several effective algorithms for computing palindromic length sequences wereintroduced in [FGKK14][RS18][BKRS17]. However, there are few sequences the palindromic lengthsequences of which are calculated. Also, it seems difficult to find a lower bound of lim sup of thepalindromic length sequence for morphic sequences, like Fibonacci sequence. In [Fri19] the authorfirstly gave a precise formula of the palindromic length sequence of the Thue-Morse sequence. In[Li19] the author found all sequences which have the same palindromic length sequence as the oneof Thue-Morse’s. To the author’s knowledge, there are no other palindromic length sequences ofnon-trivial morphic sequences are computed. ∗ [email protected]
1n this article, we study the palindromic length sequence of two sequences in OEIS. The firstone is the “ruler sequence” (A007814 in OEIS), which will be denoted as ( a [ n ]) n ∈ N + in this article.It is a sequence such that its n -th element is the exponent of highest power of 2 dividing n −
1. Thefirst elements of A007814 are:0 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , .. The other one is the period-doubling sequence (A096268 in OEIS), which can be defined as the fixedpoint of the two substitution 0 →
01, 1 →
00 with initial word 0.The first elements of A096268 are:0 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , .. Let us denote this sequence by ( b [ n ]) n ∈ N + . We know that this sequence can also be defined as thesequence ( a [ n ]) n ∈ N + modulo 2.The main result of this article consists two parts. In the first part we find a precise formula ofthe palindromic length sequence of ( a [ n ]) n ∈ N + : if we define a sequence ( c [ n ]) n ∈ N + such that c [ i ] isthe number of runs in the binary expansion of n , then we can prove that the palindromic lengthsequence of ( a [ n ]) n ∈ N + is ( c [ n ]) n ∈ N + . To clarify the definition of ( c [ n ]) n ∈ N + , let us consider thefollowing example: take n = 1000 then the binary expansion of n is (11111)(0)(1)(000), as thereare 4 constant blocs in the string, we get b [1000] = 4. The first elements of ( b [ n ]) n ∈ N + are:1 , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , .. We remark that by adding a 0 in front of the sequence ( c [ n ]) n ∈ N + , we get the sequence A005811in OEIS. In the second part, using the same method, we prove that ⌊ log( n )3 ⌋ ≤ lim sup b [ n ] ≤ ⌊ log( n ) ⌋ , where ⌊ x ⌋ represents the largest integer smaller than x . As a result, this partially answers a ques-tion asked in [Fri19]. To clarify the notion of the palindromic length sequence, let us recall some definitions and notionin language theory.
Definition
Let E be a set of letters, let E ∗ be the set of the free monoid of E generated byconcatenation. We call p a finite or infinite word if p ∈ E ∗ . Let p [ i ] be the i -th letter in p and let p [ i, j ] be the word p [ i ] , p [ i + 1] , ...p [ j ], we call p [ i, j ] a subword of p . Let | p | be the length of p . Definition
Let p be a word and q be a subword of p . A subword of p is called as a q -run if it is amaximal repetition of word q in p . If we denote the number of repetitions by i , then we can denotethe q -run by ( q ) i or q i . 2 efinition Let e p denote the reversal of p , that is to say, if p = p [1] p [2] ...p [ k ] then e p = p [ k ] p [ k − ...p [1]. We say a word p is palindromic if p = e p . Let P al denote the set of all palindromic words.We define the palindromic length of a word p , which will be denoted by | p | pal , to be: | p | pal = min { k | p = p p ...p k , p i ∈ P al, ∀ i ∈ [1 , k ] } , in this case we say p = p p ...p k is an optimal palindromic decomposition of p . Definition
Let us define the palindromic length sequence ( pl x [ n ]) n ∈ N + of the sequence ( x [ n ]) n ∈ N + to be a sequence such that pl x [ n ] = | x [1 , n ] | pal . In this section we introduce two types of masque operations.
Definition
A masque of type A of length n is a binary word of type0 , , ..., | {z } t times , , ..., | {z } n − t times . Let us denote the above masque by M An ( t ), where t ≥ Definition
A masque of type B of length n is a binary word of type0 , , ..., | {z } t − times , , ..., | {z } s − times , , ..., | {z } n − t − s times . Let us denote the above masque by M Bn ( t, s ), where t ≥ s ≥ Definition
Let M .n ( . ) be one of the masques defined as above, we define a masque operation M .n ( . ) : { , } n → { , } n such that for any binary word of length n , say p , its image M .n ( . )( p )satisfies the condition that M .n ( . )( p )[ i ] = ( p [ i ] if M .n ( . )[ i ] = 01 − p [ i ] if M .n ( . )[ i ] = 1 Lemma 1
Let M Bn ( t, s ) be a masque operation of type B then there are three masque operationsof type A , M An ( t − , M An ( t + s − , M An ( t + s ) such that: M Bn ( t, s )( . ) = M An ( t − M An ( t + s − M An ( t + s )( . ))) Proposition 1
For any finite binary word p beginning by , we can apply k times masque operationsof type A to get the sequence , , ... , where k is the number of runs in p . Moreover, this number k is optimal. roof Let us prove the statement by induction on the number of runs in p , here we denote thisnumber by i . Firstly, if i = 1, then, because of the hypothesis that s begins by 1, we induce that p is in the form of 1 , , ...
1. As a result, we can apply once M A | p | (0) to get 0 , , ..., i = k , we prove the statement for i = k + 1.Firstly, it is trivial that we can change the word p to 0 , , ..., k + 1 timesmasque operations: we can apply k times masque operation to change first k runs to 0-runs andwe need to apply at most one more operation to change the last run to 0-run. Now we prove theoptimality. To achieve 0 , , ...,
0, a necessary condition is that we have to change the first k -runs to0-runs. To do so, by the hypothesis of the induction, we need to apply at least k operations of type M A | p | ( t i ) on the word p such that, for every i , | p | − t i is larger than the length of the last run in p .Here let us discuss the problem in two cases. If k is even, then by the hypothesis that p begins by a1-run, we can see that the last run of p is also 1-run. However, after applying k times operations asabove, the last run remains 1 , , ...,
1, so a k + 1 operation is necessary. If k is odd, then by the sameway, we can see that the last run of p is a 0-run. After applying k times operations as above, thelast run changes from 0-run to 1-run, so we also need one more masque operation. To conclusion,for any binary word p containing k + 1 runs, we need and only need to apply k + 1 times masqueoperation of type A to get the word 0 , , ..., Corollary 1
For any finite binary word p beginning by , we should apply at least ⌊ k ⌋ times masqueoperations of type A or of type B to get the sequence , , ... , where k is the number of runs in p . Proof
From Lemma 1 and Proposition 1, a masque operation of type B can reduce at most 3 runsin the binary word p . As a result, in the optimal case, we should apply at least ⌊ k ⌋ times masqueoperations of type B to change the binary word p to 0 , , ..., ( a [ n ]) n ∈ N + and its palindromiclength sequence We firstly recall two facts involving the sequence ( a [ n ]) n ∈ N + : FACT1 : Let p be a word of length n then | p | pal = min {| p [1 , i ] | pal + 1 | p [ i + 1 , n ] ∈ P al } FACT2 : a [ n ] is the 2-adic valuation of n . As a consequence, if a [ x ] < a [ y ], then for any integer i , a [ x + iy ] = a [ x ] Lemma 2
Let n , n be two positive integers such that n ≤ n , then a [ n , n ] is palindromic ifand only if | a [ n , n ] | is odd. Moreover, a [ n + n ] > a [ i ] for all i ∈ [ n , n ] such that i = n + n . Proof
For the first part, it is enough to prove that for all n , a [ n ] = a [ n + 1], which is trivial becauseone of the two elements a [ n ] , a [ n + 1] is 0 and the other is larger than 0.For the second part, let e be a positive integer such that e ∈ [ n , n ] and a [ e ] = max { a [ k ] | k ∈ [ n , n ] } .By symmetry, n + n − e ∈ [ n , n ] and a [ e ] = a [ n + n − e ]. Let us denote a [ e ] by r . So there are4wo odd numbers o , o such that e = o r and n + n − e = o r . As a result, n + n = ( o + o )2 r and o + o is odd. If o = o , then take o = min { o , o } + 1. We have that o r ∈ [ n , n ] and o iseven. Consequently, a [ o r ] = r + 1 > r , which contradicts the maximality of a [ e ]. To conclude, theonly possibility is o = o = n + n , so that e = n + n . Proposition 2
Let n be an integer such that its binary expansion is p = p [1] p [2] ...p [ k ] , then forany positive integer n ′ ≤ n , a [ n ′ , n ] ∈ P al if and only if the binary expansion of n ′ − is M Ak ( s )( p ) with p [ s ] = 1 . Proof
Let n ′ be a positive integer smaller than n such that a [ n ′ , n ] ∈ P al . From Lemma 1, if a [ n ′ , n ] is palindromic, then a [ n ′ + n ] > a [ n ]. Let us write down the binary expansion of n ′ + n as p ′ [1] p ′ [2] ...p ′ [ s ] 0 , , ..., | {z } r times with p ′ [ s ] = 1 and a [ n ′ + n ] = r . We prove here p ′ [1] p ′ [2] ...p ′ [ s ] is a prefix of p . Otherwise, take n = n + n + 2 r , then n < n . However, a [ n ] ≥ r + 1, which contradicts themaximality of n ′ + n proven in Lemma 1.To conclude, the binary expansion of n ′ + n is p [1] p [2] ...p [ s ] 0 , , ..., | {z } r times with p ′ [ s ] = 1. So the thebinary expansion of n ′ + n − p [1] p [2] ...p [ s − , , ..., | {z } r times . Consequently, the binary expansionof n ′ − p [1] p [2] ...p [ s − − p [ s ])(1 − p [ s + 1]) ... (1 − p [ k ]), which equals M Ak ( s )( p ).Now let us suppose that the binary expansion of n ′ − M k ( s )( p ) with p [ s ] = 1 and thebinary expansion of n is p = p [1] p [2] ...p [ k ], let q be the integer the binary expansion of which is p [1] p [2] ...p [ s ] 0 , , ..., | {z } r times . We can check that n + n ′ = 2 q , and from Lemma 1, a [ q ] > a [ i ] for all i ∈ [ n ′ , n ] such that i = q . As a [ n ] is the 2-adic valuation of n , we have that for all integer i suchthat i ∈ [ n ′ , n ] a [ i ] = a [ − i ] = a [2 q − i ] . As a result, a [ n ′ , n ] is palindromic. Theorem 1
Let n be a positive integer, | a [1 , n ] | pal is the minimal number of masque operations oftype A needed to change the binary expansion of n to , , .., . As a result, | a [1 , n ] | pal = c [ n ] . Proof
It follows FACT 1, Proposition 2 and Proposition 1. For an integer n the binary ex-pansion of which is (1) i (0) i (1) i ... ( . ) i c [ n ] , we can apply a sequence of masque operations as M Ax (0), M Ax ( i ), M Ax ( i + i ),... M Ax ( i + i + ... + i c [ n ] − ) to get 0 , , ...,
0, where x = ⌊ log ( n ) ⌋ + 1. Proposition 3 c [ n ] ≤ ⌊ log ( n ) ⌋ . Moreover, when n = P ki =0 i , c [ n ] = 2 k . consequently, lim sup C [ n ] = ⌊ log ( n ) ⌋ Proof
It follows the fact that the number of runs in a binary string is no larger than the numberof bits in the string. 5
Palindromes in the sequence ( b [ n ]) n ∈ N + and its palindromiclength sequence Lemma 3
Let b [ i, j ] be a sub word of ( b [ n ]) n ∈ N + . b [ i, j ] is palindromic, if and only if the word isin one of the three cases:- there exists a positive odd number o and two positive integers v and x , with x < v , such that i = o v − x and j = o v + x - there exists a positive odd number o and three positive integers v , v and x , with v > v and x < v , such that i = o v − x and j = o v + 2 v + x - there exists a positive odd number o and three positive integers v , v and x , with v > v and x < v , such that i = o v − v − x and j = o v + x . Proof
Firstly, if a [ i, j ] is palindromic, then from Lemma 2, there exists a positive odd number o and two positive integers v and x , with x < v , such that i = o v − x and j = o v + x . In this case b [ i, j ] is automatically palindromic.Secondly, if a [ i, j ] is not palindromic, then either i + j is not an integer or a [ i + j ] = max { a [ k ] | i ≤ k ≤ j } .Let us denote v = max { a [ k ] | i ≤ k ≤ j } and let t be an integer such that i ≤ t ≤ j and a [ t ] = v . By symmetry, b [ i + j − t ] = b [ t ]. Here we claim that a [ i + j − t ] < a [ t ]. Infact, if a [ i + j − t ] = a [ t ], then there are two odd integers o , o such that t = o v and i + j − t = o v , therefor i ≤ min { i + j − t, t } < (min { o , o } + 1)2 v < max { i + j − t, t } ≤ j , sothat a [(min { o , o } + 1)2 v ] = v + 1, which contradicts the maximality of v .Now let us suppose that a [ i + j − t ] = v , and we know v < v . Here we prove that i + j − t iseither t + 2 v or t − v . The fact a [ i + j − t ] < a [ t ] implies that | i + j − t | ≥ v . If i + j − t > t + 2 v then a [ i + j − t − v ] = v + 1 and a [ t + 2 v ] = v , so that b [ i + j − t − v ] = b [ t + 2 v ], whichcontradicts the fact that b [ t, i + j − t ] is palindromic. Similarly, if i + j − t < t − v , we have b [ i + j − t + 2 v ] = b [ t − v ] which contradicts the fact that b [ i + j − t, t ] is palindromic. As aconclusion, | i + j − t | = 2 v .For now we proved that the interval [ i, j ] is either of the form [ o v − x, o v + 2 v + x ] or ofthe form [ o v − v − x, o v + x ], where o is an odd integer and x is an arbitrary positive integer.Here we show that x < v . Otherwise, [ o v − v , o v + 2 v + 2 v ] ⊂ [ o v − x, o v + 2 v + x ] but a [ o v − v ] = v , a [ o v + 2 v + 2 v ] = v + 1 therefor b [ o v − v ] = b [ o v + 2 v + 2 v ]. Similarly[ o v − v − v , o v + 2 v ] ⊂ [ o v − v − x, o v + x ], and b [ o v − v − v ] = b [ o v + 2 v ]. Soin both case x < v . Proposition 4
Let n be an integer such that its binary expansion is p = p [1] p [2] ...p [ k ] , then forany positive integer n ′ ≤ n such that a [ n ′ , n ] ∈ P al :- if [ n ′ , n ] is of type [ o v − x, o v + x ] , then the binary expansion of n ′ − is M Ak ( k − v )( p ) ;- if [ n ′ , n ] is of type [ o v − x, o v + 2 v + x ] or [ o v − v − x, o v + x ] , then the binary expansionof n ′ − is M Bk ( k − v , k − v )( p ) . Proof
If [ n ′ , n ] is of type [ o v − x, o v + x ], then a [ n ′ , n ] is palindromic, and in this case the resultis proven in Proposition 2.If [ n ′ , n ] is of type [ o v − x, o v + 2 v + x ], then n ′ − o v − − v − x . Therefor, binary6xpansion of n ′ − p [1] p [2] ...p [ k − v − , , ..., | {z } v − v times , , (1 − p [ k − v + 1]) , (1 − p [ k − v + 2]) , ..., (1 − p [ k ]) , which equals M Bk ( k − v , k − v )( p ). Similarly, if [ n ′ , n ] is of type [ o v − x, o v + 2 v + x ], then n ′ − o v − − x . Therefor, binary expansion of n ′ − p [1] p [2] ...p [ k − v − , , ..., | {z } v − v times , , (1 − p [ k − v + 1]) , (1 − p [ k − v + 2]) , ..., (1 − p [ k ]) , which also equals M Bk ( k − v , k − v )( p ). Theorem 2
Let n be a positive integer, | b [1 , n ] | pal is the minimal number of masque operationsof type A or type B needed to change the binary expansion of n to , , .., . As a result, c [ n ]3 ≤| b [1 , n ] | pal ≤ c [ n ] . consequently ⌊ log( n )3 ⌋ ≤ lim sup b [ n ] ≤ ⌊ log( n ) ⌋ . Proof | b [1 , n ] | pal ≤ c [ n ] follows the fact that a [ n ′ , n ] is palindromic implies that b [ n ′ , n ] is palindromic. c [ n ]3 ≤| b [1 , n ] | pal follows FACT 1, Proposition 5 and Corollary 1. Although we know the exact positions of all palindromic words in ( b [ n ]) n ∈ N + , it is still difficultto detect a precise formula of the palindromic length sequence of ( b [ n ]) n ∈ N + . The difficulty consiststwo parts. Firstly, when we apply masque operations, each time the operation we choose dependsstrongly on previous operations, which means we can not permute the order of the operations. Forexample, let us consider the prefix b [1 ,
17] of ( b [ n ]) n ∈ N + . We can check that | b [1 , | pal = 2. Infact, as the binary expansion of 17 is 1 , , , ,
1, we may apply M B (0 ,
5) and M A (1) to achieve0 , , , ,
0. However, we can not apply firstly M A (1), otherwise we get 1 , , , ,
0, which is thebinary expansion of 34. But 34 is out of the rang [1 , b [1 , B , we can decrease the numberof runs up to 3, but also, we can increase the number of runs. To achieve the minimality of thenumbers of masque operations, we can not expect that the number of runs decrease strictly aftereach masque operation, which is different from the case of ( a [ n ]) n ∈ N + .However, there are some similar points between these two sequences. Here let us recall thedefinition of the regular languages. Definition
The set of regular languages over an alphabet P is defined recursively as follows:a) The empty language and the set of empty word are regular languages.b) For each element a ∈ P , the language { a } is a regular language.c) If A and B are regular languages, then the union, the concatenation and the free monoid generatedby one of them are regular languages.d) No other languages over P are regular.It is not difficult to prove that: 7 roposition 5 For a given positive integer n , the set of the binary expansions of numbers in thefollowing set forms a regular language. S ( n ) = { i | c [ i ] = n, i ≥ } . Proof
For a given positive integer n , the set of binary expansions of numbers in the set S ( n ) is { r r ... r n } if n is odd, and { r r ... r n } if n is even. Therefor, the language of the binaryexpansions of numbers in S ( n ) is1 { } ∗ { } ∗ { } ∗ { } ∗ ... { } ∗ | {z } n times when n is odd, and is 1 { } ∗ { } ∗ { } ∗ { } ∗ ... { } ∗ | {z } n times when n is even.We may expect that the palindromic length sequence of ( b [ n ]) n ∈ N + have the same property. Wecan check easily that for small integers n , the property is true, and we believe that there is a formalproof for all integers. We may ask the following question: Problem
Let ( a [ n ]) n ∈ N + be a k -automatic (or k -regular) sequence, let ( p a [ n ]) n ∈ N + be its palin-dromic length sequence. Then for each number ǫ appearing in the sequence ( p a [ n ]) n ∈ N + , does theset of k -expansions of numbers in the following set form a regular language? S ( n ) = { i | p a [ i ] = ǫ, i ≥ } . We may compare this question with the Problem 21 in [Fri19]:
Problem
Is the palindromic length sequence of any k -automatic sequence k -regular? References [BKRS17] K. Borozdin, D. Kosolobov, M. Rubinchik, and A. M. Shur. Palindromic Length in Lin-ear Time. In ,volume 78, pages 23:1–23:12, Dagstuhl, Germany, 2017. Schloss Dagstuhl–Leibniz-Zentrum fuer Informatik.[FGKK14] G. Fici, T. Gagie, J. K¨arkk¨ainen, and D. Kempa. A subquadratic algorithm for minimumpalindromic factorization.
Journal of Discrete Algorithms , 28:41–48, 2014.[FPZ13] A.E. Frid, S. Puzynina, and L.Q. Zamboni. On palindromic factorization of words.
Advances in Applied Mathematics , 50(5):737–748, 2013.[Fri18] A. E. Frid. Sturmian numeration systems and decompositions to palindromes.
EuropeanJournal of Combinatorics , 71:202–212, 2018.[Fri19] A.E. Frid. Prefix Palindromic Length of the Thue-Morse Word.
Journal of IntegerSequences , 22:19.7.8, 2019. 8Li19] S. Li. Palindromic length complexity and a generalization of thue-morse sequences,2019. preprint, http://arxiv.org/abs/1907.12543 .[RS18] M. Rubinchik and A. M. Shur. EERTREE: An efficient data structure for processingpalindromes in strings.
European Journal of Combinatorics , 68:249–265, 2018.[Saa17] A. Saarela. Palindromic length in free monoids and free groups. In