Discrete Mathematics 341 (2018) 1662–1674
Contents lists available at ScienceDirect
Discrete Mathematics journal homepage: www.elsevier.com/locate/disc
On cyclic strings avoiding a pattern Petros Hadjicostas a , Lingyun Zhang b a b
Department of Mathematical Sciences, University of Nevada, Las Vegas, Box 454020, 4505 S. Maryland Pkwy., Las Vegas, NV 89154, USA Unit 35, 25 Tacy Street, Kilbirnie, Wellington 6022, New Zealand
article
info
Article history: Received 23 June 2017 Received in revised form 3 March 2018 Accepted 5 March 2018
Keywords: Autocorrelation of a pattern Avoiding a pattern Cyclic string Euler’s totient function Generating function Necklace
a b s t r a c t We count the number of cyclic strings over an alphabet that avoid a single pattern under two different assumptions. In the first case, we assume that the symbols of the alphabet are on numbered positions on a circle, while in the second case we assume that the symbols can be freely rotated on the circle (i.e., we deal with necklaces). In each case, we provide a generating function, and we explain how these two cases are related. For the situation of avoiding more than one pattern, we formulate a general conjecture for the first case, and a conditional result for the second case. We also explain the differences between our theory and the theory of Edlin and Zeilberger (2000) by emphasizing how we modified the definition of the enumeration of cyclic strings that avoid one or more patterns when their lengths are less than the length of the longest pattern. © 2018 Elsevier B.V. All rights reserved.
1. Introduction When we talk about strings of symbols in an alphabet, we usually mean L-type strings, where ‘L’ stands for ‘Linear’. An L-type string of length n (where n ∈ Z>0 ) is just an array (list) that contains n symbols. We can ‘bend’ an L-type string of length n onto a circle with n numbered positions to create a C-type string, where ‘C’ stands for ‘Cyclic’. Throughout this paper,
• Ω denotes the alphabet, i.e. the set of all symbols that can be used to form strings; • (x1 , . . . , xn )L and (x1 , . . . , xn )C , where xi ∈ Ω for 1 ≤ i ≤ n, denote an L-type and a C-type string, respectively; • pattern A is an arbitrary but fixed L-type string with length |A| = d (where d ∈ Z>0 ). C-type and L-type strings have different properties; e.g., the L-type string (1, 0, 1)L does not contain two consecutive ones, but the C-type string (1, 0, 1)C does. Many authors have considered this problem: (P0) Let fL (n) be the number of L-type strings of length n that avoid pattern A. What is fL (n), and what is the generating function for fL (n)? For example, Rényi [10], Siegel [11] and Zhang [12] examined the special case where Ω = {0, 1} and A = (1, 1)L . Gani and Irle [4] studied problems that are closely related to (P0). We must mention Guibas and Odlyzko [7], because not only did they derive the generating function for fL (n), but also their method is powerful enough to deal with the case of avoiding more than one pattern. The same problem was also solved in full generality by Goulden and Jackson [5]; see also Bassino et al. [1] and Noonan and Zeilberger [9]. Motivated and inspired by Guibas and Odlyzko [7] and Zhang and Hadjicostas [13], in this paper, we solve the following two problems, (P1) and (P2). E-mail addresses:
[email protected] (P. Hadjicostas),
[email protected] (L. Zhang). https://doi.org/10.1016/j.disc.2018.03.007 0012-365X/© 2018 Elsevier B.V. All rights reserved.
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
1663
(P1) Let fC (n) be the number of C-type strings of length n that avoid pattern A. What is fC (n), and what is the generating function for fC (n)? A necklace, called a CR-type cyclic string in Zhang and Hadjicostas [13], is an equivalence class of all C-type strings that can be obtained from each other by a cyclic shift. Note that the C-type strings (1, 0, 1)C , (0, 1, 1)C and (1, 1, 0)C are equivalent because each one can be obtained from the other by rotation. (P2) Let fCR (n) be the number of necklaces of length n that avoid pattern A. What is fCR (n), and what is the generating function for fCR (n)? Problem (P1) was solved by Edlin and Zeilberger [3] for the general case of avoiding more than one pattern. For solving the problem, the authors provide a Maple program, which is available at their personal websites. In this paper, however, we take a different approach regarding the definition of fC (n) for 1 ≤ n ≤ d − 1 = |A| − 1 (when d ≥ 2). By doing that, we derive an elegant generating function for fC (n), which allows us to solve problem (P2) as well. Section 2 contains several results necessary for solving problems (P1) and (P2). In Section 3, using the theory in Guibas and Odlyzko [7], we formulate a general conjecture on the generating function for fC (n) when we avoid more than one pattern. (This is achieved by modifying the definition of fC (n) when the positive integer n is less than the length of the longest pattern.) This conjecture leads to a (conditional) solution of a generalized version of problem (P2) when we avoid more than one pattern. In Section 4, we illustrate the differences between our theory and the theory in Edlin and Zeilberger [3]. In Section 5, we show that a modification of a formula by Burstein and Wilf [2] about the number of C-type cyclic strings without constant blocks > m is a special case of our conjecture, and we use their result to derive the corresponding result for necklaces (see Corollary 5.1 in this paper). Proofs (or references to proofs) of all the results in the paper are given in Section 6. 2. Main results Consider the alphabet Ω = {w1 , w2 , . . . , wq } with q distinct symbols (where q ∈ Z>0 ). The pattern to be avoided is A = (a1 , . . . , ad )L , where d ∈ Z>0 and ai ∈ Ω for i = 1, . . . , d. Under the usual definition of fC (n) for 1 ≤ n ≤ d − 1 (when d ≥ 2), used by Burstein and Wilf [2] and Edlin and Zeilberger [3], we have fC (n) = qn because no C-type string of length n < d can contain pattern A. Zhang and Hadjicostas [13] allowed C-type strings of length n with 1 ≤ n ≤ d − 1 to wrap around themselves when considering whether they avoid pattern A. This is formulated more precisely in the following definition. Definition 2.1. If n ∈ {1, . . . , d − 1} and d ≥ 2, where d = |A|, we say that the C-type string (x1 , . . . , xn )C contains pattern A if (and only if) the L-type string d−1
(
)
(x1 , . . . , xn ), (x1 , . . . , xn ), . . . , (x1 , . . . , xn ), x1 , . . . , xs
kn
(1) L
contains A, where k = ⌊(d − 1)/n⌋ and s = d − 1 − kn. Remark 2.2. The above definition is inspired by the fact that, for n ≥ d, a C-type string (x1 , . . . , xn )C contains pattern A if and only if the L-type string (x1 , . . . , xn , x1 , . . . , xd−1 )L contains A. Let fA (n) be the number of all L-type strings of length n that end with A, but otherwise avoid A. (This notation is used in Guibas and Odlyzko [7].) Hence, fA (n) = 0 for 0 ≤ n ≤ d − 1 and fA (d) = 1. For n ∈ Z>0 , define fA,A (n) = qfA (n − 1) − fA (n).
(2)
Hence, fA,A (n) = 0 for 1 ≤ n ≤ d − 1, and fA,A (d) = −1. For n ≥ d + 1, we can easily show that fA,A (n) is the number of L-type strings of length n that start with A, end with A, but otherwise avoid A. Using terminology from Guibas and Odlyzko [6,7], suppose the autocorrelation of A is given by AA = (cd , . . . , c1 ). In other words, if A = (a1 , . . . , ad )L , we have
{ ci =
1, 0,
if (ad−i+1 , . . . , ad ) = (a1 , . . . , ai ); otherwise
for i = 1, . . . , d. Clearly, cd = 1. When d ≥ 2 and 1 ≤ n ≤ d − 1, define fC (n) to be the number of C-type strings of length n that do not contain A according to Definition 2.1. We then have the following result.
1664
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
Theorem 2.3. For each n ∈ Z>0 , we have fC (n) = fL (n) −
d−1 ∑
gi (n),
i=1
where gi (n) = fA (n) −
i ∑
cj fA,A (n + j) for 1 ≤ i ≤ d − 1.
j=1
Using Theorem 2.3, we can prove the result below. Formula (3) is a special case of a general conjecture about the number of C-type strings of length n that avoid one or more patterns. This conjecture is stated in Section 3. Theorem 2.4. The generating function of the numbers fC (n) is given by ∞ ∑
fC (n) w n =
n=1
−w σ ′ (w) , σ (w )
(3)
where
σ (w) = w + (1 − qw) d
( d−1 ∑
) cd−i w
i
.
(4)
i=0
Remark 2.5. Since cd = 1, we have σ (0) = 1 > 0, and hence there is δ > 0 such that σ (w ) > 0 for all w ∈ (−δ, δ ). This observation is useful for Corollary 2.10. The following result gives a method to calculate fC (n). Along with Theorem 2.4, it gives a complete solution to problem (P1). Corollary 2.6. The numbers (fC (n) : n ∈ Z>0 ) satisfy the recurrence
fC (n) =
⎧ d ∑ ⎪ ⎪ ⎪ ⎪ αℓ fC (n − ℓ) ⎪ ⎨ ℓ=1 n−1 ⎪∑
⎪ ⎪ ⎪ ⎪ ⎩
for n ≥ d + 1,
αℓ fC (n − ℓ) + nαn
for 1 ≤ n ≤ d,
ℓ=1
where
αℓ = qcd+1−ℓ − cd−ℓ for ℓ = 1, . . . , d (with c0 = 1). Remark 2.7. The numbers (fL (n) : n ∈ Z>0 ) and (fA (n) : n ∈ Z>0 ) satisfy the same recurrence as the numbers (fC (n) : n ∈ Z>0 ), but with different initial conditions. We have fL (n) = qn for n = 1, . . . , d − 1, and fL (d) = qd − 1, while fA (n) = 0 for n = 1, . . . , d − 1, and fA (d) = 1. Even though we have ‘solved’ problem (P1), it would be better to give a more explicit formula for fC (n) when 1 ≤ n ≤ d. To achieve that, define
˜ pA = {d − i : i ∈ {1, . . . , d} and ci = 1} and pA = (˜ pA − {0}) ∪ {d}. According to Guibas and Odlyzko [6], pA is the set of all periods of pattern A. In this case, if A = (a1 , . . . , ad )L and π ∈ {1, . . . , d − 1}, then π ∈ pA if and only if aj = aj+π for j = 1, . . . , d − π . Theorem 2.8. For n = 1, . . . , d, we have qn , qn − ξn ,
{ fC (n) =
if n ̸ ∈ pA , if n ∈ pA ,
where ξn is the smallest period of A that divides n. Let φ (n) be Euler’s totient function at positive integer n, which is the number of positive integers less than or equal to n and co-prime to n. We are now ready to attack problem (P2). Theorem 2.9. The numbers (fCR (n) : n ∈ Z>0 ), which count the numbers of necklaces that avoid pattern A, satisfy the following equation: fCR (n) =
1∑ n
h|n
φ (h)fC
(n) h
.
(5)
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
1665
Corollary 2.10. The generating function of the numbers (fCR (n) : n ∈ Z>0 ) is given by ∞ ∑
fCR (n) w n = −
∞ ∑ φ (s)
n=1
s=1
s
log σ (w s ),
where σ (w ) is given by Eq. (4) in Theorem 2.4. 3. A general conjecture Let {A1 , . . . , Aν } be a reduced set of patterns over the alphabet Ω . This means no pattern Ai is a factor (sub-string) of another pattern Aj . Let fL (n) be the number of L-type strings of length n that avoid all patterns in {A1 , . . . , Aν }, and for i = 1, . . . , ν , let fAi (n) be the number of L-type strings that end with Ai and otherwise avoid all patterns in {A1 , . . . , Aν }. Let also FL (w ) =
∞ ∑
fL (n)w n
and FAi (w ) =
n=0
∞ ∑
fAi (n)w n .
n=1
Note that fL (0) = 1 and fAi (0) = 0. For i, j ∈ {1, . . . , ν}, let Ai Aj be the correlation of Ai with Aj as defined by Guibas and Odlyzko [6,7]. Notice that Ai Aj is a string of 0’s and 1’s of length |Ai |, i.e., Ai Aj ∈ {0, 1}|Ai | . In addition, Ai Aj is not necessarily the same as Aj Ai . If Ai Aj = (γ|Ai | , γ|Ai |−1 , . . . , γ1 ), where γℓ ∈ {0, 1} for ℓ = 1, . . . , |Ai |, define |Ai |−1
(Ai Aj )w =
∑
γ|Ai |−ℓ wℓ ;
ℓ=0
note that this is different from the one used in Guibas and Odlyzko [7]. Since, for i ̸ = j, neither Ai nor Aj is a sub-string of the other one, we have γ|Ai | = 0. Define also the following vectors: F(w ) = (FL (w ), w −|A1 | FA1 (w ), . . . , w −|Aν | FAν (w ))T ; w = (w |A1 | , . . . , w |Aν | )T ; 1ν = (1, . . . , 1)T
(a vector having ν elements);
δ1 = (1, 0, . . . , 0)T
(a vector having (ν + 1) elements).
Finally, define the matrices Σ(w ) = (Σi,j (w ) : i, j = 1, . . . , ν )ν×ν = ((Aj Ai )w : i, j = 1, . . . , ν )ν×ν ;
M(w ) =
(
1 − qw 1ν
wT −Σ(w)
) (ν+1)×(ν+1)
.
Note that Σi,j (w ) = (Aj Ai )w , which may not necessarily be the same as (Ai Aj )w . Guibas and Odlyzko [7] have proved a theorem that is equivalent to the result below. Theorem 3.1. The functions FL (w ), w −|A1 | FA1 (w ), . . . , w −|Aν | FAν (w ) satisfy the following system of linear equations: M(w ) F(w ) = δ1 . Because {A1 , . . . , Aν } is a reduced set of patterns over Ω , det(M(w )) is a non-zero polynomial of w ; see Remark 3.4. Therefore, F(w ) = M(w )−1 δ1 , and each one of FL (w ), w −|A1 | FA1 (w ), . . . , w −|Aν | FAν (w ) is a rational function of w with denominator equal to det(M(w )). This proves that fL (n), as well each fAi (n), satisfies a linear recurrence with characteristic polynomial equal to det(M(w )). Remark 3.2. Guibas and Odlyzko [7] state their results using generating functions for fL (n) and fAi (n) in terms of non-positive powers of z, but we let w = z −1 and we express their results using generating functions for fL (n) and fAi (n) in terms of non-negative powers of w . Remark 3.3. Since fAi (n) = 0 for n = 0, 1, . . . , |Ai | − 1, we have
w−|Ai | FAi (w ) = w −|Ai |
∞ ∑ n=|Ai |
fAi (n) w n =
∞ ∑
fAi (n) w n−|Ai | ,
n=|Ai |
and thus all powers of w in the above series are ≥ 0.
1666
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
Remark 3.4. It can be easily proven that det(M(w )) = (−1)ν (1 − qw + wT Σ(w )−1 1ν ) det(Σ(w )) =
(−1)ν det(Σ(w )) F L (w )
.
(6)
Since {A1 , . . . , Aν } is a reduced set of patterns, Σ(0) = Iν and det(M(0)) = (−1)ν . Hence, there is δ > 0 such that Σ(w )−1 exists and |det(M(w ))| > 0 for all w ∈ (−δ, δ ). Corollary 3.5. The generating function FL (w ) of the numbers (fL (n) : n ∈ Z>0 ) satisfies FL (w ) =
1 1 − qw + wT Σ(w )−1 1ν
.
(7)
We are now ready to state a conjecture that generalizes Eq. (3) in Theorem 2.4. Let fC (n) be the number of C-type ∑∞ n strings that avoid all patterns in {A1 , . . . , Aν } and let FC (w ) = n=1 fC (n) w . By generalizing Definition 2.1, for 1 ≤ n < max1≤j≤ν |Aj |, we define fC (n) to be the number of C-type strings (x1 , . . . , xn )C in Ω n such that, for each i ∈ {1, . . . , ν}, the L-type string (x1 , . . . , xn , x1 , . . . , x|Ai |−1 )L does not contain Ai if n ≥ |Ai | and the L-type string (1) in Definition 2.1 (with d = |Ai |) does not contain Ai if 1 ≤ n < |Ai |. Conjecture 3.6. The generating function FC (w ) of the numbers (fC (n) : n ∈ Z>0 ) satisfies FC (w ) =
−w
d dw
det(M(w ))
det(M(w ))
( ) ( ) dM(w ) d(M(w )−1 ) = −w tr M(w)−1 = w tr M(w ) , dw dw
(8)
where tr(·) denotes the trace of a matrix. The second equality in Eq. (8) follows from Jacobi’s formula for the derivative of the determinant of a square invertible matrix; see Magnus and Neudecker [8, Section 8.3]. The third equality follows from the fact that M−1 M = Iν+1 , which implies dM
d(M−1 )
M = 0. dw dw (Here Iν+1 is the (ν + 1) × (ν + 1) identity matrix, while 0 is the (ν + 1) × (ν + 1) zero matrix.) For each ∑n∞∈ Z>0 , letnfCR (n) be the number of all necklaces (CR-type strings) that avoid all patterns in {A1 , . . . , Aν }, and let FCR (w ) = n=1 fCR (n) w . Then we have the following conditional result that generalizes Theorem 2.9 and Corollary 2.10. M−1
+
Corollary 3.7. If Conjecture 3.6 were true, then the generating function FCR (w ) of the numbers (fCR (n) : n ∈ Z>0 ) would satisfy FCR (w ) = −
∞ ∑ φ (s)
s
s=1
=
log|det(M(w s ))|
∞ ∑ φ (s) (
s
s=1
In addition, fCR (n) =
1 n
∑
(9)
log|FL (w s )| − log|det(Σ(w s ))| .
h|n
)
φ (h)fC
(n) h
(10)
.
4. The theory of Edlin and Zeilberger An alternative to the Guibas and Odlyzko [7] method is the Goulden and Jackson [5] method that uses the inclusion– exclusion principle. As illustrated by Noonan and Zeilberger [9], the Goulden–Jackson method can be used to give us the generating function of the number of L-type strings (or words) that avoid all patterns in a reduced set of patterns {A1 , . . . , Aν }. The Goulden–Jackson method, however, is quite general and can be used to solve a number of other problems as well. These two methods, developed in the late seventies and early eighties of the 20th century, have been generalized by a number of authors. We refer readers to the paper by Bassino et al. [1] for further and more recent references. Instead of working with words (strings), Goulden and Jackson [5] and Noonan and Zeilberger [9] work with marked words. For example,
D I S CR ET E is a marked word denoted by (DISCRETE; [3,6], [5,8]). Consider the marked word (W , S), where W ∈ of the ‘markings’
⋃∞
n=1 Ω
n
and S consists
[i1 , j1 ], [i2 , j2 ], . . . , [iℓ , jℓ ] such that j1 < j2 < · · · < jℓ and, for r = 1, . . . , ℓ, we have ir ≤ jr and the sub-word Wir Wir +1 · · · Wjr −1 Wjr is one of the patterns in {A1 , . . . , Aν }. (Here, S may be empty, in which case the marked word (W , S) would be a regular word.) The weight
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
1667
of this marked word in the generating function is (−1)|S | w length(W) . In the Goulden–Jackson method we work with clusters. Roughly, (W , S) is a cluster with respect to {A1 , . . . , Aν } if every two neighboring marked sub-words in S overlap and every symbol (letter) in W belongs to at least one marked sub-word in S. (Hence, the above example is not a cluster, but it becomes one if we remove DI provided A1 = SCRE and A2 = RETE.) If L(w ) is the generating function of the clusters for the linear case, Noonan and Zeilberger [9] derive the formula 1
FL (w ) =
1 − qw − L(w )
.
Comparing the above equation to formula (7) in Corollary 3.5, we see that L(w ) = −wT Σ(w )−1 1ν
(11)
using the notation of Section 3 of this paper. For the cyclic case, Edlin and Zeilberger [3] use a generating function of the form ∞ ∑
FC∗ (w ) =
fC∗ (n)w n ,
n=0
where fC∗ (0) = 1 (rather than 0); fC∗ (n) = fC (n) for all n ≥ max1≤i≤ν |Ai |; but when 1 ≤ n ≤ max1≤i≤ν |Ai | − 1, fC∗ (n) counts all C-type strings in Ω n that avoid all patterns in {A1 , . . . , Aν } without using Definition 2.1 or its generalization in Section 3 (see the paragraph preceding Conjecture 3.6). Edlin and Zeilberger [3] derive the formula
) ν − 1 L(w) ∑ + Chopℓi Ni,i (w ) 1 − qw − L(w )
1+ w
d dw
(
FC (w ) = ∗
i=1
ν ∑
wFL (w) + Chopℓi Ni,i (w ). (12) F L (w ) i=1 (∑∞ ) ∑∞ k Here, Chopr = k=r ak wk for r ∈ Z>0 , and ℓi = |Ai | for i = 1, . . . , ν . Also, Ni,i (w) is the ith diagonal element of k=0 ak w the ν × ν matrix ′
= 1+
N(w ) =
∞ ∑
Ar (w ) w
dA(w ) dw
r =1
= A(w)(Iν − A(w))−1 w
dA(w ) dw
,
where A(w ) = (Aij (w ) : i, j = 1, . . . , ν ) = (δij − w |Aj |−|Ai | (Ai Aj )w : i, j = 1, . . . , ν )ν×ν . Here, δij = 1 if i = j, and 0 otherwise. If Conjecture 3.6 were true, then Eqs. (6) and (8) would imply FC (w ) =
( ) wFL′ (w) −w ddw det Σ(w) wFL′ (w) dΣ(w ) + = − tr Σ(w)−1 w . F L (w ) det Σ(w ) F L (w ) dw
(13)
Given that maxi |Ai |−1
FC∗ (w ) = 1 + FC (w ) +
∑
(fC∗ (n) − fC (n))w n ,
(14)
n=1
one can now compare Edlin and Zeilberger’s formula (12) and our conjectured formulas (13). Remark 4.1. If d = |Ai | is the same for all i ∈ {1, . . . , ν} (and this happens, for example, when ν = 1, like in Section 2 of this paper), then A(w ) = Iν − Σ(w )T . In such a case, N(w ) = Iν − (Σ(w )T )−1 w
(
)
dΣ(w )T dw
.
Note that, for 1 ≤ i ≤ ν ,
(
w
dΣ(w )T dw
) i,i
=w
d(Ai Ai )w dw
,
which is a polynomial of degree at most d − 1. Hence, in this case,
( ) ( ( )) dΣ(w ) dΣ(w ) −1 −1 FC (w ) − 1 − FC (w ) = tr w Σ(w ) − Chopd tr w Σ(w ) . dw dw ∗
1668
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
5. The formula of Burstein and Wilf For a fixed m ∈ Z>0 , Burstein and Wilf [2] derived an explicit formula and a generating function for the number of C-type strings of length n that do not contain any constant substrings of length > m. Like Edlin and Zeilberger [3], they do not allow C-type strings with ‘small’ length n to wrap around themselves like what we do in this paper. Using the notation of Section 4, the formula of Burstein and Wilf [2] is FC∗ (w ) − 1 =
∞ ∑
fC∗ (n) w n
n=1
1 − wm
=
(
1−w
qw + (q − 1)w
(
m + 1 − mqw 1 − qw + (q − 1)w m+1
−
m+1
))
1 − w m+1
.
With Ω = {w1 , . . . , wq }, here we have
ν = q and Ai = (wi , wi , . . . , wi ) ∈ Ω m+1 for i = 1, . . . , q. Clearly, {A1 , . . . , Aν } is a reduced set of patterns, and Burstein and Wilf [2] essentially assume fC∗ (n) = qn
for n = 1, . . . , m.
On the other hand, if we allow C-type strings of length n to wrap around themselves (as was done in Sections 1–3 of this paper), then fC (n) = qn − q for n = 1, . . . , m. Note that fC∗ (n) = fC (n) for n ≥ m + 1. Since |Ai | = m + 1 for i = 1, . . . , q, Eq. (14) gives FC (w ) = FC∗ (w ) − 1 − q
m ∑
wi
i=1 m
=
(q − 1)w (1 − w )
m + 1 − mqw
(
1−w
1 − qw + (q − 1)w m+1
−
m+1
)
1 − w m+1
.
(15)
Next we show that formula (15) follows from Eqs. (8) in our Conjecture 3.6. Here, for 1 ≤ i ̸ = j ≤ ν = q, Ai Ai = (1, . . . , 1)
and Ai Aj = (0, . . . , 0) = Aj Ai .
m+1
m+1
Hence,
( Σ(w ) =
m ∑
) w
ℓ
Iq ,
L(w ) = −w T Σ(w )−1 1q = −
ℓ=0
wm+1 q(1 − w) , 1 − w m+1
(16)
and FL (w ) =
1 1 − qw +
w m+1 q(1−w ) 1−w m+1
=
1 − w m+1 (1 − w m+1 ) − qw (1 − w m )
.
(17)
Here, of course, FL (w ) is the generating function of the numbers (fL (n) : n ∈ Z>0 ), where fL (n) is the number of L-type strings of length n that avoid constant blocks of length > m. In addition, det(Σ(w )) =
(
1 − w m+1 1−w
)q
.
(18)
Plugging equations (17) and (18) into the first equation in (13), we conclude that Conjecture 3.6 implies FC (w ) =
q(q − 1)w 2 (1 − w m )(1 − (m + 1)w m + mw m+1 ) (1 − w )(1 − w m+1 )(1 − w m+1 − qw + qw m+1 )
.
(19)
It is easy to check that the right-hand of (15) matches the right-hand side of Eq. (19). Finally, the previous re-analysis of the formula of Burstein and Wilf allows us to get a result about the generating function for the number of necklaces that avoid long constant blocks.
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
1669
Corollary 5.1. The generating function for the numbers (fCR (n) : n ∈ Z>0 ), where fCR (n) is the number of necklaces with no constant block of length > m, is given by
( ∞ ∑ φ (s)
( )) ws − ws(m+1) + log 1 − (q − 1) s 1 − ws 1 − ws s=1 ( ) ∞ ∑ ws − ws(m+1) φ (s) (q − 1)w (1 − w m ) =− − log 1 − (q − 1) . (1 − w )(1 − w m+1 ) s 1 − ws
FCR (w ) = −
(q − 1) log
1 − w s(m+1)
s=1
6. Proofs In this section, we give proofs (or references to proofs) of all the results in the paper. We begin with the proof of Theorem 2.3, which is a key result and helps us establish many of the results in Section 2. Notice that, when |A| = d = 1, we have fL (n) = fC (n) = (q − 1)n for each n ∈ Z>0 ; in this case, Theorem 2.3 is trivially true. Thus, for the rest of the proof of Theorem 2.3, we assume d ≥ 2. Recall that A = (a1 , . . . , ad )L ∈ Ω d . For n ∈ Z>0 and i ∈ {0, 1, . . . , d − 1}, let
Λn := {all the linear strings in Ω n counted by fA (n)} and
Ψn,i := {(z1 , . . . , zn ) ∈ Ω n : (ad−i+1 , . . . , ad , z1 , . . . , zn ) ∈ Λn+i }. (For i = 0, we have Ψn,0 = Λn .) Let g0 (n) = fA (n), and recall that gi (n) = fA (n) −
i ∑
cj fA,A (n + j)
for i = 1, . . . , d − 1.
j=1
Then gi+1 (n) = gi (n) − ci+1 fA,A (n + i + 1)
for i = 0, 1, . . . , d − 2.
(20)
Lemma 6.1. For d ∈ Z≥2 , n ∈ Z>0 , and i ∈ {0, 1, . . . , d − 1}, we have gi (n) = #Ψn,i .
(21)
Proof. We distinguish two cases: n ≥ d and 1 ≤ n ≤ d − 1. Case 1: n ≥ d. We prove Eq. (21) by finite induction on i ∈ {0, 1, . . . , d − 1}. For i = 0, we have #Ψn,0 = #Λn = fA (n) = g0 (n). Let i ∈ {0, 1, . . . , d − 2} be given, and assume gi (n) = #Ψn,i . Note that (ad−i , ad−i+1 , . . . , ad , z1 , . . . , zn ) ∈ Λn+i+1 if and only if (ad−i+1 , . . . , ad , z1 , . . . , zn ) ∈ Λn+i and the beginning of (ad−i , ad−i+1 , . . . , ad , z1 , . . . , zn ) does not contain A. Thus, (z1 , . . . , zn ) ∈ Ψn,i+1 if and only if (z1 , . . . , zn ) ∈ Ψn,i and the beginning of (ad−i , ad−i+1 , . . . , ad , z1 , . . . , zn ) does not contain A. If (ad−i , . . . , ad ) ̸ = (a1 , . . . , ai+1 ), i.e., if ci+1 = 0, then, for any (z1 , . . . , zn ) ∈ Ω n , the beginning of (ad−i , ad−i+1 , . . . , ad , z1 , . . . , zn ) does not contain A. Hence, by Eq. (20), gi+1 (n) = gi (n) = #Ψn,i = #Ψn,i+1 . If (ad−i , . . . , ad ) = (a1 , . . . , ai+1 ), i.e., if ci+1 = 1, then Eq. (20) implies gi+1 (n) = gi (n) − fA,A (n + i + 1) = #Ψn,i − fA,A (n + i + 1) = #Ψn,i+1 . This is because n + i + 1 ≥ d + 1 and fA,A (n + i + 1) is the number of L-type strings of length n + i + 1 that start with A, end with A, but otherwise avoid A. This completes ∑i the induction step and Case 1. Case 2: 1 ≤ n ≤ d − 1. Then gi (n) = − j=1 cj fA,A (n + j) for i = 0, 1, . . . , d − 1. When 0 ≤ i ≤ d − 1 − n, we have n + i ≤ d − 1, and hence Λn+i = ∅ and #Ψn,i = 0. Also, fA,A (n + j) = 0 for 1 ≤ j ≤ i ∑i (because n + j ≤ n + i ≤ d − 1). Thus, in this case, gi (n) = − j=1 cj · 0 = 0 = #Ψn,i . Assume now n + i ≥ d, i.e., i ≥ d − n. In such a case, gi (n) = −cd−n fA,A (d) −
i ∑ j=d−n+1
cj fA,A (n + j) = cd−n −
i ∑
cj fA,A (n + j).
j=d−n+1
Again, we shall prove by finite induction on i ∈ {d − n, . . . , d − 1} that gi (n) = #Ψn,i .
1670
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
For i = d − n, we have #Ψn,d−n = #{(z1 , . . . , zn ) ∈ Ω n : (an+1 , . . . , ad , z1 , . . . , zn ) ∈ Λd } 1, 0,
if (an+1 , . . . , ad ) = (a1 , . . . , ad−n ), otherwise
{ =
= cd−n = gd−n (n). Let i ∈ {d − n, . . . , d − 2} be given, and assume gi (n) = #Ψn,i . Since n + i + 1 ≥ d + 1, using the same argument as in Case 1, we may prove that gi+1 (n) = #Ψn,i+1 , and the induction step in this case is complete as well. □ Proof of Theorem 2.3. Since the case d = 1 is trivial, assume d ≥ 2. We again consider two cases. Case 1: n ≥ d. For i ∈ {1, . . . , d − 1}, let
Ψn∗,i := {(y1 , . . . , yn ) ∈ Ω n : (y1 , . . . , yn , y1 , . . . , yi ) ∈ Λn+i }. For 1 ≤ i < j ≤ d − 1, we have Ψn∗,i ∩ Ψn∗,j = ∅ because Λn+i counts those strings in Ω n+i that end in A, but otherwise avoid A; and similarly for Λn+j . Also, there is a one-to-one correspondence between Ψn,i and Ψn∗,i of the form
Ψn,i ∋ (z1 , . . . , zn ) ↦→ (y1 , . . . , yn ) = (zn−i+1 , . . . , zn , z1 , . . . , zn−i ) ∈ Ψn∗,i with inverse
Ψn∗,i ∋ (y1 , . . . , yn ) ↦→ (z1 , . . . , zn ) = (yi+1 , . . . , yn , y1 , . . . , yi ) ∈ Ψn.i . It follows from the above observation and from Eq. (21) in Lemma 6.1 that gi (n) = #Ψn,i = #Ψn∗,i for i = 1, . . . , d − 1. Hence, by the definitions of fL (n) and fC (n), fC (n) = fL (n) − #
d−1 ⋃
Ψn∗,i = fL (n) −
i=1
d−1 ∑
#Ψn∗,i = fL (n) −
i=1
d−1 ∑
gi (n).
i=1
Case 2: 1 ≤ n ≤ d − 1. Let k = ⌊(d − 1)/n⌋ and s = d − 1 − kn. Since fC (n) is the number of C-type strings (x1 , . . . , xn )C that avoid A, this means that fC (n) is the number of (x1 , . . . , xn ) ∈ Ω n such that the L-type string (1) in Definition 2.1 avoids A. Define Φn to be the set of all L-type strings (y1 , . . . , yn+d−1 )L ∈ Ω n+d−1 which contain pattern A and which are equal to string (1) for some (x1 , . . . , xn ) ∈ Ω n . Each such string (y1 , . . . , yn+d−1 )L ∈ Φn has a first occurrence of pattern A; i.e., there is a unique i ∈ {d − n, . . . , d − 1} such that string (y1 , . . . , yn+i ) ends with A, but for 1 ≤ ℓ < n + i, the string (y1 , . . . , yℓ ) does not. Denote by Φn,i the set of all (y1 , . . . , yn+d−1 )L ∈ Φn that share the same i with the above ⋃d−property. 1 Clearly, Φn,i ∩ Φn,j = ∅ for d − n ≤ i < j ≤ d − 1, Φn = i=d−n Φn,i , and fC (n) = #Ω n − #
d−1 ⋃
Φn,i = fL (n) −
i=d−n
d−1 ∑
#Φn,i .
(22)
i=d−n
For i ∈ {d − n, . . . , d − 1}, there is a one-to-one correspondence between Φn,i and Ψn,i that we describe below. For (y1 , . . . , yn+d−1 ) ∈ Φn,i , let (z1 , . . . , zn ) = (y1+i , . . . , yn+i ). From the definition of Φn,i , we have yℓ = yℓ+n for ℓ = 1, . . . , i; (yn+i−d+1 , . . . , yn+i ) = (a1 , . . . , ad ) = A; and (y1 , . . . , yn+i−1 ) does not contain A. Thus, (y1 , . . . , yn+i ) = (ad−i+1 , . . . , ad , z1 , . . . , zn ) ∈ Λn+i , and hence, (z1 , . . . , zn ) ∈ Ψn,i . Conversely, for (ζ1 , . . . , ζn ) ∈ Ψn,i , let (y∗1 , . . . , y∗n+i ) := (ad−i+1 , . . . , ad , ζ1 , . . . , ζn ) ∈ Λn+i .
(23)
As a result, = ad−ℓ = for ℓ = 0, 1, . . . , i − 1. This allows us to construct string (ψ1 , . . . , ψn+d−1 ) by defining it to be string (1) with (x1 , . . . , xn ) = (y∗1 , . . . , y∗n ). By (23), the string (ψ1 , . . . , ψn+d−1 ) contains pattern A: y∗n+i−ℓ
y∗i−ℓ
(a1 , . . . , ad ) = (y∗n+i−d+1 , . . . , y∗n+i ) = (ψn+i−d+1 , . . . , ψn+i ). By the definition of Λn+i , however, the string (ψ1 , . . . , ψℓ ) = (y∗1 , . . . , y∗ℓ ) does not contain A when 1 ≤ ℓ < n + i. Thus, (ψ1 , . . . , ψn+d−1 ) ∈ Φn,i . Hence, #Φn,i = #Ψn,i , and using Lemma 6.1 and Eqs. (22), we get fC (n) = fL (n) −
d−1 ∑ i=d−n
#Ψn,i = fL (n) −
d−1 ∑
gi (n).
i=1
Note that the above proof holds even if Φn = ∅ because, in such a case, Φn,i = ∅ for i = d − n, . . . , d − 1 while the above argument shows that, for each i, Φn,i ̸ = ∅ if and only if Ψn,i ̸ = ∅ (which is equivalent to Φn,i = ∅ if and only if Ψn,i = ∅). This completes the proof of the theorem. □
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
Proof of Theorem 2.4. Let FA (w ) =
∞ ∑
fA (n) w n
and FA,A (w ) =
∞ ∑
n=1
fA,A (n) w n .
n=1
Recall that fA (n) = fA,A (n) = 0 for 0 ≤ n ≤ d − 1. From Guibas and Odlyzko [7], we have that FL (w ) =
(AA)w
and
w + (1 − qw)(AA)w ∑d−1 i where (AA)w = i=0 cd−i w . Notice that w
d(AA)w dw
d
=
d−1 ∑
cd−i iw i =
i=1
d−1 ∑
FA (w ) =
wd , w + (1 − qw)(AA)w d
cj (d − j)w d−j .
j=1
Eq. (2) implies
−(1 − qw )wd . wd + (1 − qw)(AA)w
FA,A (w ) = −(1 − qw )FA (w ) = In addition, ∞ ∑
fA,A (n + j) w n+j = FA,A (w )
for j = 1, . . . , d − 1.
n=1
Theorem 2.3 then implies ∞ ∑
fC (n) w = n
∞ ∑
n=1
fL (n) w − n
∞ ∑ d−1 ∑
n=1
⎛ ⎝fA (n) −
n=1 i=1
i ∑
⎞ cj fA,A (n + j)⎠ w n .
j=1
Therefore, FC (w ) = FL (w ) − 1 − (d − 1)FA (w ) +
d−1 ∑
cj (d − j)w −j
j=1
∞ ∑
fA,A (n + j) w n+j
n=1
d(AA)w −wd + qw(AA)w − (d − 1)FA (w) + FA,A (w) w1−d = d w + (1 − qw)(AA)w dw ( ) w −w dwd−1 − q(AA)w + (1 − qw) d(AA) dw = . wd + (1 − qw)(AA)w The last equality above implies Eq. (3), and the proof is complete. □ Proof of Corollary 2.6. From Eq. (4), we have
σ (w ) = 1 −
d−1 ∑
(qcd−i+1 − cd−i )w i − (qc1 − 1)w d .
i=1
If we let c0 = 1, and αi = qcd−i+1 − cd−i for i = 1, . . . , d, we get
σ (w ) = 1 −
d ∑
αi wi and
− w σ ′ (w ) =
i=1
d ∑
iαi w i .
i=1
Thus, ∞ ∑ n=1
fC (n) w = n
∑d
i=1
1−
iαi w i
∑d
i=1
αi wi
.
Cross-multiplying and equating coefficients of like powers of w , we can easily complete the proof of the corollary. □ Next, we turn to the proof of Theorem 2.8. We first need the following lemma. Lemma 6.2. For all 1 ≤ n ≤ d, define Tn = {all the C-type strings of length n}. Then, Tn has at least one string that contains pattern A if and only if n is a period of A.
1671
1672
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
Proof. For n = d, the equivalence in the lemma holds trivially. Thus, for the rest of the proof, assume 1 ≤ n ≤ d − 1. ‘⇐’ Let (x1 , . . . , xn )C ∈ Tn and suppose it contains A. It follows from Definition 2.1 that A is a part of the L-type string (1), and so n must be a period of A. ‘⇒’ If n is a period of A, then A = (a1 , . . . , ad ) can be expressed as ((a1 , . . . , an ), . . . , (a1 , . . . , an ), a1 , . . . , as ),
ℓn
where ℓ = ⌊d/n⌋ and s = d − ℓn. It is clear that the C-type string (a1 , . . . , an )C contains A according to Definition 2.1. □ Proof of Theorem 2.8. If n ̸ ∈ pA , then Lemma 6.2 implies that no C-type string of length n contains A, and hence fC (n) = qn . If n ∈ pA , let ξn be the smallest period of A that can divide n. Since 1 ≤ n ≤ d, let Y be the C-type string that consists of the first n elements of A; i.e., Y = (a1 , . . . , an )C . Then Y and all the other ξn − 1 C-type strings obtained by cyclic shift from Y are C-type strings of length n that contain A according to Definition 2.1. In addition, if (x1 , . . . , xn )C contains A (according to Definition 2.1), then it can be easily proven that (x1 , . . . , xn ) is a permutation of Y . Hence, fC (n) = qn − ξn . □ Proof of Theorem 2.9. If (x1 , . . . , xn ) ∈ Ω n is a representative (member) of a necklace (CR-type string), then we denote the corresponding necklace by [(x1 , . . . , xn )]CR . For example, [(1, 0, 1)]CR = {(1, 0, 1), (0, 1, 1), (1, 1, 0)}. We define the period m of a necklace [(x1 , . . . , xn )]CR to be the length of the shortest substring of xi ’s with consecutive indexes that can reproduce (x1 , . . . , xn ) by repeating itself n/m times. For any positive integers m and n with m|n, let ψn (m) be the number of necklaces of length n and period m that avoid pattern A. We claim
ψn (m) = ψm (m).
(24)
To prove Eq. (24), we establish a one-to-one correspondence between necklaces of length m and period m with necklaces of length n and period m of the form S1 = [(b1 , . . . , bm )]CR ↦ → S2 = [((b1 , . . . , bm ), . . . , (b1 , . . . , bm ))]CR .
n/m
Note first that, if (c1 , . . . , cm ) is a cyclic shift of (b1 , . . . , bm ) ∈ S1 , then it is also in S1 and S2 = [((c1 , . . . , cm ), . . . , (c1 , . . . , cm ))]CR .
n/m
If d ≤ m and S1 contains pattern A, then S2 contains A as well. If 1 ≤ m ≤ d − 1 and S1 contains pattern A according to Definition 2.1, then clearly S2 contains A if n ≥ d, and it contains A according to Definition 2.1 if 1 ≤ n ≤ d − 1. Conversely, if S2 contains A (either literally or according to Definition 2.1), then S1 will do as well. Even if A covers part at the end of (b1 , . . . , bm ) and another part at the beginning of (b1 , . . . , bm ), then this would not matter because S1 contains all cyclic permutations of (b1 , . . . , bm ). Notice that any CR-type string of length n and period m (with m|n) corresponds to m distinct C-type strings. Along with Eq. (24), this observation implies fC (n) =
∑
m ψn (m) =
∑
m|n
m ψm (m).
m|n
By the Möbius inversion principle, m ψm (m) =
∑
µ(h)fC
(m) h
h |m
for all m ∈ Z>0 , where µ(·) is the Möbius function. Thus, fCR (n) =
∑
ψm (m) =
m|n
1∑ n ∑ n
m|n
m
µ(h)fC
(m) h
h |m
=
1∑ n
m|n
φ (m)fC
(n) m
.
The last equality follows from the associativity of Dirichlet convolutions and the fact that φ (n) =
∑
m|n m
µ
(n) m
.
□
Proof of Corollary 2.10. By Remark 2.5, σ (0) = 1 and there is δ > 0 such that σ (w ) > 0 for all w ∈ (−δ, δ ). By Eq. (3), we then have ∞ ∑ n=1
fC (n)
wn n
∫ = 0
∞ w∑ n=1
fC (n) xn−1 dx = −
w
∫ 0
σ ′ (x) dx = − log σ (w ). σ (x)
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
1673
The above equation along with Eq. (5) in Theorem 2.9 implies ∞ ∑
fCR (n) w n =
n=1
∞ ∑ 1∑
n
n=1
=
(n) h
h|n
∞ ∑ ∞ ∑ φ (h)
ht
h=1 t =1
=
φ (h)fC
fC (t) w ht
∞ ∞ ∑ φ (h) ∑
h
h=1
wn
fC (t)
(w h )t
t =1
t
=−
∞ ∑ φ (h) h=1
h
log σ (w h ).
This completes the proof of Corollary 2.10. □ Proof of Theorem 3.1. The result follows from Theorem 1 in Guibas and Odlyzko [7]. As stated in Remark 3.2 of this paper, the authors express their results by using power series in w = z −1 . If we observe that, for correlation Ai Aj = (γ|Ai | , γ|Ai |−1 , . . . , γ1 ) of patterns Ai and Aj , we have |Ai |−1
z
∑
|Ai |−1
γs+1 z s = w−|Ai |
∑
γ|Ai |−ℓ wℓ = w −|Ai | (Ai Aj )w ,
ℓ=0
s=0
then we can easily transform Theorem 1 of Guibas and Odlyzko [7] into our Theorem 3.1. □ Proof of Corollary 3.5. If we let R(w ) =
(
)
wT −Σ(w)
1 0
(ν+1)×(ν+1)
,
then F L (w ) =
det(R(w ))
=
det(M(w ))
det(−Σ(w )) det(M(w ))
=
det(−Σ(w )) (1 − qw + wT Σ(w )−1 1ν ) det(−Σ(w ))
,
from which Eq. (7) follows immediately. □ Proof of Corollary 3.7. An argument similar to the one in the proof of Theorem 2.9 shows that fCR (n) = 1n h|n φ (h)fC nh . Key to this argument is that, for 1 ≤ n ≤ maxi |Ai | − 1, when counting all C-type strings (x1 , . . . , xn )C that avoid all patterns in {A1 , . . . , Aν }, we allow them to wrap around themselves. The proof of Eq. (9) is similar to the proof of Corollary 2.10. A key step in the proof is the following chain of equalities:
∑
∞ ∑
fC (n)
n=1
wn n
w d
∫
dx
=− 0
det(M(x))
det(M(x))
( )
dx = − log|det(M(w ))|.
The last equality follows from the fact that det(M(0)) = (−1)ν and |det(M(w ))| > 0 for all w ∈ (−δ, δ ); see Remark 3.4. Eq. (10) follows from the second equality in (6) in Remark 3.4. □ Proof of Corollary 5.1. By Eq. (6) in Remark 3.4 and Eqs. (16) and (18) in Section 5, we get
)q )( 1 − w m+1 wm+1 q(1 − w) det(M(w )) = (−1) 1 − qw + 1 − w m+1 1−w ( )( )q−1 m+1 (q − 1)(w − w ) 1 − w m+1 = (−1)ν 1 − . 1−w 1−w ν
(
Since the paper by Burstein and Wilf [2] shows that Conjecture 3.6 is true when ν = q and Ai = (wi , . . . , wi ) ∈ Ω m+1 for i = 1, . . . , q, Eq. (9) in Corollary 3.7 holds. It is then easy to prove the first formula for FCR (w ) in Corollary 5.1. Using the identity
−
∞ ∑ φ (s) s=1
s
log(1 − xs ) =
x 1−x
for |x| < 1,
we can prove the second formula for FCR (w ) in Corollary 5.1. □ Acknowledgments The authors would like to thank the referees for their valuable comments that helped to improve the presentation of the paper.
1674
P. Hadjicostas, L. Zhang / Discrete Mathematics 341 (2018) 1662–1674
References [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13]
F. Bassino, J. Clément, P. Nicodème, Counting occurrences for a finite set of words: combinatorial methods, ACM Trans. Algorithms 8 (2012) 31.1–31.28. A. Burstein, H.S. Wilf, On cyclic strings without long constant blocks, Fibonacci Quart. 35 (1997) 240–247. A.E. Edlin, D. Zeilberger, The Goulden-Jackson cluster method for cyclic words, Adv. Appl. Math. 25 (2000) 228–232. J.J. Gani, A. Irle, On patterns in sequences of random events, Monatsh. Math. 127 (1999) 295–309. I.P. Goulden, D.M. Jackson, An inversion theorem for cluster decomposition of sequences with distinguished subsequences, J. Lond. Math. Soc. (2) 20 (1979) 567–576. L.J. Guibas, A.M. Odlyzko, Periods in strings, J. Combin. Theory Ser. A 30 (1981) 19–42. L.J. Guibas, A.M. Odlyzko, String overlaps, pattern matching, and nontransitive games, J. Combin. Theory Ser. A 30 (1981) 183–208. J.R. Magnus, H. Neudecker, Matrix Differential Calculus with Applications in Statistics and Econometrics, Wiley, 1999. J. Noonan, D. Zeilberger, The Goulden-Jackson cluster method: Extensions, applications, and implementations, J. Difference Equ. Appl. 5 (1999) 355–377. A. Rényi, A Diary on Information Theory, John Wiley and Sons, Chichester, 1984. D. Siegel, Bernoulli meets Fibonacci, Math. Sci. 22 (1997) 122–124. L. Zhang, On sequences of independent Bernoulli trials avoiding the pattern 11, Math. Sci. 29 (2004) 65. L. Zhang, P. Hadjicostas, On sequences of independent Bernoulli trials avoiding the pattern ‘11...1’, Math. Sci. 40 (2015) 89–96.