Fine and Wilf's theorem

From testwiki
Jump to navigation Jump to search

Template:Short description

In combinatorics on words, Fine and Wilf's theorem is a fundamental result describing what happens when a long-enough word has two different periods (i.e., distances at which its letters repeat).[1][2] Informally, the conclusion is that such words w have also a third, shorter period. If the periods and length of w satisfy certain conditions, then this third period can equal 1. In this case then, the theorem's conclusion is that w is a power of a single letter. The theorem was introduced in 1963 by Nathan Fine and Herbert Wilf.[3] It is easy to prove, and has uses across theoretical computer science and symbolic dynamics.[4][1]

Herbert Wilf, who introduced the theorem alongside Nathan Fine

Statement

The two most common phrasings of Fine and Wilf's theorem are as follows:[2][4]

Template:Math theoremTemplate:Math theorem

It is folklore that an infinite sequence (an)n having two periods h and k has also gcd(h,k) as a period.[5] Indeed, by Bézout's identity, there are integers r,s0 satisfying rhsk=gcd(h,k) or rksh=gcd(h,k). In the first case, we always have an=an+rh=an+rhsk=an+gcd(h,k). And in the second, we always have an=an+rk=an+rksh=an+gcd(h,k).

Fine and Wilf's theorem refines this result only by bounding the length of the sequence (an) to some large-enough finite value such that the third period must still arise. The finite bound of Fine and Wilf is optimal. Indeed, consider w:=aaabaaa. Then w has periods 4 and 6, since w=aaabaaa=aaabaaa. By Fine and Wilf's theorem, w would also have period gcd(4,6)=2 if its length were at least 4+6gcd(4,6)=8. In fact, the length of w is 7, only one short of this threshold, and w fails to have this short period 2.

Proof

We prove the second phrasing of the theorem above. The proof comes from,[2] and is closely related to the extended Euclidean algorithm, much like the proof of Bézout's identity.

Let u,v be nonempty words over an alphabet Σ. We first reduce to the case gcd(|u|,|v|)=1: If instead we have |u|=dp and |v|=dq, with d>1, gcd(p,q)=1, we consider u and v as elements of (Σd)+. That is, we view them as words over the alphabet Σd whose letters are words of length d in the original alphabet Σ. With respect the larger alphabet gcd(|u|,|v|)=1, and so proving the result for this case will suffice.

So let p:=|u| and q:=|v| with gcd(p,q)=1. Suppose that uuu and vvv have a common prefix of length p+q1. Assume further (by symmetry) that p>q, and consider the image shown below. Here the positions of the words uuu and vvv are numbered 1,2,..,p+q1. The vertical dashed line indicates how far the words uuu and vvv can be compared.

The procedure used in our proof of Fine and Wilf's theorem.

The arrow describes a procedure, the purpose of which is to fix the values of new positions to be the same as a given value of an initial position i0[1,..,q1]. By our premises, the value of the position computed as follows:i0i0+pi1i0+p(modq),where i1 is reduced to the interval [1,...,q], gets the same value as that of i0. So the procedure computes i1 from the number i0. Since gcd(p,q)=1,  i1 differs from i0. If i1 differs from q as well, the procedure can be repeated. The claim is: The new positions obtained will always differ from all the previous ones. Indeed, if i0+npi0+mp(modq)with n,m[0,q1], then necessarily n=m, since gcd(p,q)=1.

Now, if the procedure can be repeated q1 times, then every position in (the first repetition of) v will get covered, meaning that these'll all get the same letter as the initial one at position i0. But this implies that v is a power of a single letter, and thus so is u. Hence, this would complete the proof.

But the procedure can be repeated q1 times if we choose i0 such that i0+(q1)pq(modq).  If this holds, then all the values i0+jp(modq) for j=0,...,q2 differ from q. Clearly, such an i0 can be found.

Variants

Often the following weakening of Fine and Wilf's theorem is formulated:[2]

Template:Math theorem

This variant can be proved using a simplified version of the above argument. It is often strong enough in application.[2]

Another reformulation removes the emphasis on the words' "left-hand-sides" (i.e., the requirement for uuu and vvv to agree from the start). This statement therefore requires only that uuu has a different periodic presentation than the trivial one as a repetition of us. To write it down formally, let (w1,w2) denote the maximal length of a common factor of the words w1 and w2. Then[2]

Template:Math theorem

Variants of the theorem have also been introduced that look at abelian periods.[6] (i.e., consecutive blocks in words that are not necessarily identical, but anagrams of each other). There are also ways to apply the theorem to continuous functions having multiple periods[3][5]

Generalisations

Fine and Wilf's theorem has been generalised to work with words having more than two periods.[7][5] For instance, for three periods p1<p2<p3, the appropriate bound is12(p1+p2+p32gcd(p1,p2,p3)+h(p1,p2,p3)),where h is a function related to the Euclidean algorithm on three inputs[8][5]

The result has also been investigated with respect to "partial words",[9] which are allowed to contain "don't care" positions called holes. Holes match each other and all other letters. The following has been proved:[5]

Template:Math theorem

Relation to Sturmian Words

Let p,q be coprime. Fine and Wilf's Theorem allows for words of length p+q2 to have periods p and q without being a power of a single letter. In fact, given p and q, such a word always exists.[2] Moreover, it is binary and unique (up to renaming its letters).

The proof of this claim follows the proof given above. Indeed, in that proof, the letters in the positions of the shorter word were fixed using the procedure. The procedure could be applied in all but one case, namely when the position was q. Now there are two positions wherein the procedure cannot be applied, viz. q and q1. Accordingly, we are free to choose the letters occurring in two positions of the shorter word, but as soon as we do this, every other position is fixed. Since we want a word that's not a power of a single letter, our only choice (modulo the letters' names) is to put different letters in the two positions we have control over. Uniqueness follows from the fact that every other position is fixed.

The words so obtained are the finite Sturmian words.[2] These words admit many characterisations;[1][8] the above discourse gives a way to compute them.

Applications

One application of Fine and Wilf's theorem is to string-searching algorithms.[5] For instance, the Knuth-Morris-Pratt algorithm finds all occurrences of a pattern p in a text t in time bounded by O(|p|+|t|). It compares p to a portion of t beginning at a position i and, if a mismatch is found, shifts p rightward depending on where the mismatch occurred.[10] The worst-case for the Knuth-Morris-Pratt algorithm comes from "almost-periodic" words, the idea being that – in this case – long sequences of matching letter can occur without a complete match. It turns out that such words are precisely the maximal "counterexamples" to Fine and Wilf's theorem (i.e., the finite Sturmian words, described in the previous section)[5]

Fine and Wilf's theorem can also be used to reason about the solution sets of word equations.[2]

References

Template:Reflist