1 Introduction

Consider a word x of length \(|x|=n\), with its positions numbered 0 through \(n-1\). We say that x has a period p if \(x_i=x_{i+p}\) for all \(0 \le i < n-p\). Our work can be seen as a quest to extend Fine and Wilf’s Periodicity Lemma [14], which is a ubiquitous tool of combinatorics on words.

Lemma 1

(Periodicity Lemma [14]). If a word x has periods p and q and \(|x| \ge p+q-\mathrm {GCD}(p,q)\), then x also has a period \(\mathrm {GCD}(p,q)\).

Other known extensions of this lemma include a variant with three [10] and an arbitrary number of specified periods [11, 16, 17, 23], the so-called new periodicity lemma [3, 13], a periodicity lemma for repetitions that involve morphisms [19], and extensions into periodicity of partial words [4,5,6,7,8,9, 22], into abelian [12] and k-abelian [18] periodicity, into bidimensional words [20], and other variations [15, 21].

We say that a word x of length n is periodic if it has a period p such that \(2p \le n\). For two words x and y of length n, by \( dist (x,y)\) we denote their Hamming distance being the number of positions \(i=0,\ldots ,n-1\) such that \(x_i \ne y_i\). The following folklore fact gives a lower bound on how different are two distinct periodic words. Its proof can be found in [1].

Fact 2

If x and y are distinct periodic words of the same length, then \( dist (x,y) \ne 1\).

We present several generalizations of this fact.

Results similar to Fact 2 were presented recently in the context of quasiperiodicity [1]. We say that a word x has a cover u if each position in x is located inside an occurrence of u in x. The word x is called quasiperiodic if it has a cover u other than x. In [1] the following generalization of Fact fct:folklore was shown: \( dist (x,y)> 1\) for any two distinct quasiperiodic words x, y of the same length. This type of fact has potential applications; see [2].

There is a quantitative difference between periods and covers. For example, there are words x and y of length 1024 with shortest covers of length 4 and 5, respectively, and \( dist (x,y)=2\):

$$x=(abaa)^{256} \quad \text {and}\quad y=aaba(abaa)^{255}$$

with covers abaa and aabaa. However, if x and y are words of length 1024 with shortest periods 4 and 5, respectively, then we must have \( dist (x,y) \ge 357\).

We say that a period p of a word x is primitive if no proper divisor of p is a period of x, i.e., if \(p' \mid p\) and \(p'\) is a period of x, then \(p'=p\). We define

$$\mathcal {P}_{p}(n) = \{\,|x|=n,\,p\text { is a primitive period of }x\,\}.$$

The ultimate goal of this work is a characterization of the function \({\mathcal D}_{p,q}\) defined for \(p \ne q\) and \(n \ge \max (p,q)\) as:

$${\mathcal D}_{p,q}(n) = \min \,\{\, dist (x,y)\,:\; x\in \mathcal {P}_{p}(n), y\in \mathcal {P}_{q}(n) \,\}.$$

As \({\mathcal D}_{p,q}\) is non-decreasing for given pq, it can be described by the following auxiliary function:

$$N_{p,q}(h) = \max \,\{\, n \,:\; {\mathcal D}_{p,q}(n)\le h\,\}.$$

One can note that Lemma 1 can be equivalently formulated as \(N_{p,q}(0)<p+q-\mathrm {GCD}(p,q)\) (Fig. 1). Similarly, an equivalent formulation of Fact 2 is \(N_{p,q}(1)<2q\).

Fine and Wilf [14] also proved that the bound \(p+q-\mathrm {GCD}(p,q)\) of Lemma 1 cannot be improved. Consequently, \(N_{p,q}(0)=p+q-\mathrm {GCD}(p,q)-1\). On the other hand, we show that \(N_{p,q}(1)=2q-1\) only for \(p \mid q\). Hence, the bound \(N_{p,q}(1)<2q\) of Fact 2 is not tight in general.

Our Results. In Sect. 2 we consider the case that \(p \mid q\). In the remaining sections, we only consider the case of \(p<q\) and \(p \not \mid q\). In Sect. 3 we show exact values of the function \({\mathcal D}_{p,q}\) for \(p+q-\mathrm {GCD}(p,q) \le n \le 2q\). In Sect. 4, we show the following bounds valid for abitrary \(n\ge q\):

$$\left\lfloor \tfrac{n-q}{p} \right\rfloor \ \le \ {\mathcal D}_{p,q}(n)\ \le 2\left\lceil \tfrac{n-q}{p} \right\rceil .$$

We also prove an alternative bound \({\mathcal D}_{p,q}(n)\ge \left\lfloor \frac{2n}{p+q} \right\rfloor \) valid for \(n\ge p+q\).

Fig. 1.
figure 1

Upper table: values of \(N_{3,4}(h)\) for \(h=1,\ldots ,5\) together with pairs of words of length \(N_{3,4}(h)\) that have the Hamming distance h. Lower table: values of \(N_{2,3}(h)\) for \(h=0,\ldots ,7\).

2 Preliminaries

Let us consider a finite alphabet \(\varSigma \). If x is a word of length \(|x|=n\), then by \(x_i \in \varSigma \) for \(i=0,\ldots ,n-1\) we denote its ith letter. We say that a word v is a factor of a word x if there exist words u and w such that \(x=uvw\). A factor v is called a prefix of x if u is an empty word in some such decomposition and a suffix if w is an empty word in some such decomposition. By x[i..j] we denote the factor \(x_i \ldots x_j\).

If \(x_i=x_{i+p}\) for all \(0 \le i < n-p\) for some integer p, then p is called a period of x and the prefix of x of length p is called a string period of x. If x has period p, then y is called a periodic extension of x with period p if y also has period p and has x as a prefix.

We say that a period p is primitive if no proper divisor of p is a period of x. Note that the shortest period (denoted \(p=\mathbf {per}(x)\)) is always primitive.

We say that a word x is primitive if there exists no other word u and integer \(k>1\) such that \(x=u^k\). Note that p is a primitive period of x if and only if the corresponding string period is a primitive word. Two words x and y are each other’s cyclic rotations if there exist words u and v such that \(x=uv\) and \(y=vu\). In this case we also say that |u| is the shift between x and y.

For a sequence of positive integers \((a_1,\ldots ,a_m)\), we define a \((a_1,\ldots ,a_m)\)-decomposition of a word x as a sequence of consecutive factors of x of lengths \(a_1,\ldots ,a_m,a_1,\ldots ,a_m,\ldots \) The sequence ends at the last complete factor that can be cut out of x; see Fig. 2 for an example.

Fig. 2.
figure 2

The (1, 2, 4)-decomposition of ababbababaababaabaab is \(a\,ba\,bbab\,a\,ba\,abab\,a\,ab\).

If \(p \mid q\), we can give a simple complete characterization of functions \(N_{p,q}\) and \({\mathcal D}_{p,q}\).

Fact 3

If \(p \mid q\) and \(p<q\), then \({\mathcal D}_{p,q}(n) = \left\lfloor \frac{n}{q} \right\rfloor \) and \(N_{p,q}(h) = q\cdot (h+1)-1\).

Proof

We first show that \({\mathcal D}_{p,q}(n) \ge \left\lfloor \frac{n}{q} \right\rfloor \). Consider a positive integer n, words \(x\in \mathcal {P}_p(n)\), \(y\in \mathcal {P}_q(n)\), and the (q)-decompositions of x and y: \(\alpha _1,\ldots ,\alpha _k\) and \(\beta _1,\ldots ,\beta _k\). Observe that \(\alpha _1=\ldots =\alpha _k\) and \(\beta _1=\ldots =\beta _k\) because q is a period of both x and y, but \(\alpha _1 \ne \beta _1\) because q is a primitive period of y, but not a primitive period of x. Hence, \( dist (x,y) \ge k\).

As for the other inequality on \({\mathcal D}_{p,q}(n)\), let us take \(x=(a^{p-1}b)^{\left\lfloor n/p \right\rfloor } a^{n\,\bmod \,p}\) and let y be the word that is obtained from x by changing the letters at positions \(i \equiv q-1 \pmod {q}\) from b to c. Then \( dist (x,y) = \left\lfloor \frac{n}{q} \right\rfloor \).

Finally, the formula for \(N_{p,q}(h)\) follows directly from the other one.    \(\square \)

Henceforth, we will always assume that \(p \not \mid q\) and \(q \not \mid p\).

3 Exact Values for Small n

Let us start with the following useful lemma.

Lemma 4

Let x be a word of length n and let y by its cyclic rotation by s characters. If \(x \ne y\), then \( dist (x,y) \ge 2\). Moreover, there are two mismatches between x and y located at least \(\mathrm {GCD}(n,s)\) positions apart.

Proof

Note that \(y_i = x_{(i+s)\,\bmod \,n}\) for \(0\le i < n\). Since \(x\ne y\), we have \(x_{a}\ne y_a = x_{(a+s)\,\bmod \,n}\) for some position a. Let k be the smallest positive integer such that \(x_a = x_{(a+ks)\,\bmod \,n} \). Due to \(x_{(a+s)\,\bmod \,n}\ne x_a\) and \(x_{(a+ns)\,\bmod \,n}=x_a\), we have \(1 < k \le n\). Let \(b=(a+(k-1)s)\bmod n\). Note that \(x_b \ne x_a = x_{(b+s)\,\bmod \,n}=y_b\). Hence, a and b are positions of two distinct mismatches between x and y. Moreover, \(b \equiv (a+(k-1)s)\,\bmod \,n \equiv a \pmod {\mathrm {GCD}(n,s)}\). Consequently, these two mismatches are indeed located at least \(\mathrm {GCD}(n,s)\) positions apart.    \(\square \)

For an illustration of the following Lemma 5, see Fig. 3.

Lemma 5

Consider positive integers pq satisfying \(p< q\) and \(p\not \mid q\). Let x and y be words of length n such that \(p+q-\mathrm {GCD}(p,q)\le n \le q+p\lceil {\frac{q}{p}\rceil }-1\), p is a period of x, and q is a period of y but not a period of x. Then

$$ dist (x,y)\ge \left\lfloor \tfrac{n-q}{p} \right\rfloor +\left\lfloor \tfrac{n-q+\mathrm {GCD}(p,q)}{p} \right\rfloor .$$

Proof

Let \(u=x[0..p-1]\) and let v be the cyclic rotation of u by q characters. Note that u is a string period of x, so \(u\ne v\); otherwise, q would be a period of x. Consequently, Lemma 4 provides two distinct indices ab such that \(u_a \ne v_a\), \(u_b\ne v_b\), and \(a \le b-\mathrm {GCD}(p,q) < p-\mathrm {GCD}(p,q)\). Let us define

$$\begin{aligned} A&=\left\{ kp +a: 0 \le k< \left\lfloor \tfrac{n-q+\mathrm {GCD}(p,q)}{p} \right\rfloor \right\} ,\\ B&= \left\{ kp+b : 0 \le k < \left\lfloor \tfrac{n-q}{p} \right\rfloor \right\} . \end{aligned}$$

Observe that

$$\max A = \left\lfloor \tfrac{n-q+\mathrm {GCD}(p,q)}{p} \right\rfloor p-p+a \le n-q+\mathrm {GCD}(p,q)-p+a < n-q$$

and

$$\max B = \left\lfloor \tfrac{n-q}{p} \right\rfloor p-p+b \le n-q-p+b < n-q.$$

Moreover,

$$\max A \le \left\lfloor \tfrac{p\lceil {q/p}\rceil -1+\mathrm {GCD}(p,q)}{p} \right\rfloor p-p+a=\left\lceil \tfrac{q}{p} \right\rceil p-p+a<q+a\le q+\min (A\cup B),$$

and

$$\max B \le \left\lfloor \tfrac{p\lceil {q/p}\rceil -1}{p} \right\rfloor p-p+b = \left\lceil \tfrac{q}{p} \right\rceil p-p < q \le q+\min (A\cup B).$$

Consequently, for each \(i\in A\cup B\), there are positions \(x_i\) and \(x_{i+q}\), and all these \(2(|A|+|B|)\) positions are distinct. Moreover, observe that for \(i\in A\), we have \(x_{i}=u_a \ne v_a = x_{i+q}\), while for \(i\in B\), \(x_{i}=u_b \ne v_b = x_{i+q}\). Thus, for \(i\in A\cup B\), we have \(x_{i}\ne x_{i+q}\), but \(y_i = y_{i+q}\); hence \(x_{i}\ne y_i\) or \(x_{i+q}\ne y_{i+q}\). The positions we consider are distinct, so \( dist (x,y)\ge |A\cup B| = |A|+|B|=\left\lfloor \tfrac{n-q}{p} \right\rfloor +\left\lfloor \tfrac{n-q+\mathrm {GCD}(p,q)}{p} \right\rfloor \), as claimed.    \(\square \)

For an illustration of the following Lemma 6, see Figs. 4 and 5.

Fig. 3.
figure 3

Illustration of the equalities in the bound in Lemma 5 for \(\lceil {\frac{q}{p}\rceil } = 1\).

Lemma 6

Consider coprime integers pq satisfying \(1<p<q\). Let w be a word of length \(p+q-2\) with periods p and q, but without period 1. Moreover, let n be an integer such that \(p+q-1 \le n \le q+\lceil {\frac{q}{p}\rceil }p-1\), and let x and y be periodic extensions of w of length n preserving periods p and q, respectively. Then \(\mathbf {per}(x)=p\), \(\mathbf {per}(y)=q\), and

$$ dist (x,y)\le \left\lfloor \tfrac{n-q}{p} \right\rfloor +\left\lfloor \tfrac{n-q+1}{p} \right\rfloor ,$$

Proof

Claim. If a position i satisfies \(i<q\) or \((i-q) \bmod p < p-2\), then \(x_i= y_i\).

Proof

The claim is clear for \(i<q+p-2\) since due to the common prefix of x and y. Thus, we consider a position \(i=q+kp+r\) with \(1\le k <\lceil {\frac{q}{p}\rceil }\) and \(0\le r <p-2\). We have \(x_{q+kp+r}=x_{q+r}=y_{q+r}=y_r= x_r = x_{kp+r}=y_{kp+r}=y_{q+kp+r}\). This is because positions \(r< kp+r < q+r\) are within the common prefix of x and y.    \(\square \)

Consequently,

$$\begin{aligned}&\quad dist (x,y)\le \{i : q\le i< n\, \wedge \, (i-q)\bmod p \ge p-2\} = \\&\{j: 0\le j< n -q\, \wedge \, j\bmod p = p-1\}+\{j : 0\le j < n-q\, \wedge \, j\bmod p = p-2\}= \\&\qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \qquad \, \left\lfloor \tfrac{n-q}{p} \right\rfloor +\left\lfloor \tfrac{n-q+1}{p} \right\rfloor , \end{aligned}$$

as claimed. Next, we prove that \(p':=\mathbf {per}(x)\) is equal to p. Note that \(p'\le p\) by definition of x. For a proof by contradiction, suppose that \(p'<p\). Note that w has periods \(p'\) and q. Moreover, \(|w|=p+q-2\ge p'+q-1\), so \(\mathrm {GCD}(p',q)\) is a period of w. Moreover, \(n \ge p+q-1 \ge p+\mathrm {GCD}(p',q)-1\), so \(\mathrm {GCD}(\mathrm {GCD}(p',q),p)\) is a period of x. However, \(\mathrm {GCD}(\mathrm {GCD}(p',q),p)=\mathrm {GCD}(p',\mathrm {GCD}(q,p))=1\) is not a period of w, which is a prefix of x.

Similarly, suppose that \(q' := \mathbf {per}(y) < q\). We observe that \(|w|=p+q-2\ge p+q'-1\), so \(\mathrm {GCD}(p,q')\) is a period of w. Moreover, \(n \ge p+q-1 \ge \mathrm {GCD}(p,q')+q-1\), so \(\mathrm {GCD}(\mathrm {GCD}(p,q'),q)\) is a period of y. However, \(\mathrm {GCD}(\mathrm {GCD}(p,q'),q)=\mathrm {GCD}(q',\mathrm {GCD}(p,q))=1\) is not a period of w, which is a prefix of y.    \(\square \)

Fig. 4.
figure 4

Illustration of the equalities in the lower bound in Lemma 6 for \(n=q+2p-2\).

Fig. 5.
figure 5

A periodic prefix of a Fibonacci word and a power of a Fibonacci word that differ only at two positions.

Theorem 7

If \(p<q\), \(p \not \mid q\), and \(p+q-\mathrm {GCD}(p,q) \le n \le q+\lceil {\frac{q}{p}\rceil }p-1\), then

$$\begin{aligned} {\mathcal D}_{p,q}(n) = \left\lfloor \frac{n-q}{p} \right\rfloor + \left\lfloor \frac{n+\mathrm {GCD}(p,q)-q}{p} \right\rfloor . \end{aligned}$$
(1)

Proof

Lemma 5 gives a lower bound of \({\mathcal D}_{p,q}(n)\). Our upper bound is based on Lemma 6. Let \(d=\mathrm {GCD}(p,q)\), \(p'=\frac{p}{d}\), \(q'=\frac{q}{d}\), and \(n'=\left\lfloor \frac{n}{d} \right\rfloor \). Observe that \(1< p' < q'\) and \(p'+q'-1 \le n' \le q'+\lceil {\frac{q'}{p'}\rceil }p'-1\). Hence, Lemma 6 results in strings \(x'\), \(y'\) with of length \(n'\) with shortest periods \(p'\) and \(q'\) respectively, and with \( dist (x',y')\le \left\lfloor \frac{n'-q'}{p'} \right\rfloor + \left\lfloor \frac{n'-q'+1}{p'} \right\rfloor = \left\lfloor \frac{n-q}{p} \right\rfloor + \left\lfloor \frac{n-q+\mathrm {GCD}(p,q)}{p} \right\rfloor .\)

Let c be a character occurring neither in \(x'\) nor in \(y'\). Let us define x and y so that \(x_{id+d-1}=x'_i\) and \(y=_{id+d-1}=y'_i\), and \(x_{j}=y_j=c\) if \(j\bmod d \ne d-1\). Note that \( dist (x,y)= dist (x',y')\) and \(|x|=|y|=n\). Also, observe that due to the choice of the character c, all periods of x and y are larger than \(dn'\) or multiples of d. Consequently, \(\mathbf {per}(x)=d\mathbf {per}(x')=dp'=p\) and \(\mathbf {per}(y)=d\mathbf {per}(y')=dq'=q\). This completes the construction.    \(\square \)

Corollary 8

The formula (1) of Theorem 7 applies for \(p+q-\mathrm {GCD}(p,q) \le n \le 2q\).

Fact 9

The function \({\mathcal D}_{p,q}(n)\) is non-decreasing for \(n\ge p+q-\mathrm {GCD}(p,q)\). Moreover:

$$\begin{aligned} {\mathcal D}_{p,q}(n)=h \ \Longleftrightarrow \ N_{p,q}(h-1)< n \le N_{p,q}(h) \\ N_{p,q}(h)=n \ \Longleftrightarrow \ {\mathcal D}_{p,q}(n)=h<{\mathcal D}_{p,q}(n+1) \end{aligned}$$

4 Bounds for \({\mathcal D}_{p,q}(n)\) for Arbitrary n

Lemma 10

Let pq be integers such that \(p<q\) and \(p \not \mid q\). Moreover, let x and y be words of length \(n\ge q\) such that p is a period of x, and q is a period of y but not of x. Then \( dist (x,y)\ge \left\lfloor \frac{n-q}{p} \right\rfloor \).

Proof

Since q is not a period of x, we have \(x_i \ne x_{i+q}\) for some position i, \(0\le i < n-q\). Consider a set \(J = \{j : 0\le j < n-q\,\wedge \,j \equiv i \pmod {p}\}\). Since p is a period of x, we have \(x_{j}\ne x_{j+q}\) for each \(j\in J\); on the other hand, \(y_{j}=y_{j+q}\), so \(x_{j}\ne y_{j}\) or \(x_{j+q}\ne y_{j+q}\). Moreover, \(p \not \mid q\) implies that the positions j, \(j+q\) across \(j\in J\) are pairwise distinct. Consequently, \( dist (x,y)\ge |J|\ge \left\lfloor \frac{n-q}{p} \right\rfloor \).   \(\square \)

Theorem 11

If \(p<q\), \(p \not \mid q\), and \(n\ge p+q\), then \(\left\lfloor \frac{n-q}{p} \right\rfloor \le {\mathcal D}_{p,q}(n) \le 2\left\lceil \tfrac{n-q}{p} \right\rceil \).

Proof

The lower bound follows directly from Lemma 10. The upper bound is obtained using words \((x,y) \in \mathcal S_{p,q,n}\) with string periods \(a^{p-1}b\) and \((a^{p-1}b)^ka^r\) where \(q=kp+r\). Indeed, x and y agree on the first q positions. After that, inside each pair of corresponding fragments of length at most p they have at most 2 mismatches.    \(\square \)

Remark 12

In general, it is not true that \({\mathcal D}_{p,q}(n) \ge \lceil {\frac{n-q}{p}\rceil }\). For example, words \(x=cacbcacbcacbcacbcac\) and \(y=cacbcacacbcacacbcac\) of length 19, with shortest periods \(p=4\) and \(q=6\), respectively, satisfy \( dist (x,y)=3<\lceil {\frac{19-6}{4}\rceil }\).

Theorem 13

If \(p<q\) and \(p \not \mid q\) and \(n\ge p+q\), then \({\mathcal D}_{p,q}(n) \ge \left\lfloor \frac{2n}{p+q} \right\rfloor \).

Proof

We use the following claim:

Claim

If \(p< q\) and \(p\not \mid q\), then

  1. (a)

    \(N_{p,q}(1)=q+p-1\),

  2. (b)

    \(N_{p,q}(2)=q+2p-\mathrm {GCD}(p,q)-1\).

Proof

Observe that \(q+p \le q+2p-\mathrm {GCD}(p,q)\le q+\lceil {\frac{q}{p}\rceil }p-1\), so the values below are within the scope of Theorem 7. We have:

$$\begin{aligned} {\mathcal D}_{p,q}(q+p-1)&= \left\lfloor \tfrac{p-1}{p} \right\rfloor + \left\lfloor \tfrac{p+\mathrm {GCD}(p,q)-1}{p} \right\rfloor =0+1=1\\ {\mathcal D}_{p,q}(q+p)&= \left\lfloor \tfrac{p}{p} \right\rfloor + \left\lfloor \tfrac{p+\mathrm {GCD}(p,q)}{p} \right\rfloor =1+1=2. \end{aligned}$$

This concludes the proof of part (a).

$$\begin{aligned} {\mathcal D}_{p,q}(q+2p-\mathrm {GCD}(p,q)-1)&= \left\lfloor \tfrac{2p-\mathrm {GCD}(p,q)-1}{p} \right\rfloor + \left\lfloor \tfrac{2p-1}{p} \right\rfloor =1+1=2\\ {\mathcal D}_{p,q}(q+2p-\mathrm {GCD}(p,q))&= \left\lfloor \tfrac{2p-\mathrm {GCD}(p,q)}{p} \right\rfloor + \left\lfloor \tfrac{2p}{p} \right\rfloor =1+2=3. \end{aligned}$$

This concludes the proof of part (b).    \(\square \)

Consider words \(x\in \mathcal {P}_p(n)\), \(y\in \mathcal {P}_q(n)\) and their \((p+q)\)-decompositions: \(\alpha _1,\ldots ,\alpha _{k}\) and \(\beta _0,\ldots ,\beta _{k-1}\). If \(\alpha _{i}=\beta _{i}\) for some \(1\le i \le k\), then, by the Periodicity Lemma, both \(\alpha _i\), \(\beta _i\) have period \(\mathrm {GCD}(p,q)\); consequently, both x and y have period \(\mathrm {GCD}(p,q)\), a contradiction. Hence, part (a) of the claim implies \( dist (\alpha _i,\beta _i) \ge 2\) for each \(i=1,\ldots ,k\).

Let \(\alpha _{k+1}\) and \(\beta _{k+1}\) be the suffixes of x and y starting immediately after the last factors of the corresponding decompositions. If \(|\alpha _{k+1}|<\frac{p+q}{2}\), then we already have that

$$ dist (x,y) \ge 2\left\lfloor \tfrac{n}{p+q} \right\rfloor = \left\lfloor \tfrac{2n}{p+q} \right\rfloor .$$

Otherwise, by part (b) of the claim applied for the words \(\alpha _k\alpha _{k+1}\) and \(\beta _k\beta _{k+1}\), we have

$$ dist (x,y) \ge 2\left( \left\lfloor \tfrac{n}{p+q} \right\rfloor -1\right) +3 = 2\left\lfloor \tfrac{n}{p+q} \right\rfloor +1 = \left\lfloor \tfrac{2n}{p+q} \right\rfloor .$$

In both cases we obtain the desired inequality.    \(\square \)

5 Conclusions

The paper studies the following general type of question:

How much dissimilar in a whole should be two objects which are different in some specific aspect?

The answer to this type of question heavily depends on the studied type of the objects. Thus sometimes the answer is completely trivial; for example, two different strings of the same length may differ at only a single position. In this work we show that if we consider different strings of the same length that are additionally periodic, then the implied number of positions where the two strings must differ can be large. The exact number depends on the length of the strings and on their periods.