Advanced Topics · Lesson 10

Autocorrelation and the Guibas–Odlyzko Formula

The autocorrelation word

The avoidance automaton keeps track of every partial match. A second approach records only the ways in which the whole pattern can overlap itself.

For a nonempty pattern P=P[1..m], define its autocorrelation word αP[1]⋯αP[m] by

αP[r]=1P[1..r]=P[m−r+1..m]0otherwise

So αP[r]=1 exactly when the length-r prefix and suffix agree. We include r=m, so αP[m]=1. Write

B(P)={r:1≤r≤m,αP[r]=1}

The autocorrelation word records where a prefix and suffix of 01001 of the same length agree. A 1 marks an overlap; a 0 marks a mismatch.

rprefixsuffixα[r]
1010
201011
30100010
4010010010
501001010011
αP = 01001 B(P) = {2, 5} RP(X) = X + X⁴

For 01001, the only proper border is 01, so αP=01001 and B(P)={2,5}. Two copies of 010 can overlap in a single 0, but not in two positions, because 01 ≠ 10 — that is α010=101.

The autocorrelation polynomial, indexed by overlap length, is

RP(X)=∑r=1mαP[r]Xr−1

For 01001, RP(X)=X+X4.

Two counting identities

Recall that aP(n) counts the length-n words avoiding P. Let hP(n) count the length-n words containing exactly one occurrence of P, which must appear at the end (the first occurrence ends at position n).

For the first identity, take a word x of length n that avoids P. Appending any of the k letters either keeps the result avoiding P or creates exactly one occurrence, ending at the new final position. Deleting the last letter inverts this, proving k·aP(n)=aP(n+1)+hP(n+1).

For the second, append the whole pattern to x. In xP, look at the shortest prefix ending in P, say xP′. The word P′ is a nonempty prefix of the appended P and also a suffix of the occurrence at the end, so P′ is both a prefix and a suffix of P. If r=|P′|, then αP[r]=1 and xP′ is counted by hP(n+r). Summing over all such r gives the identity.

For 01001, since B(P)={2,5}, the second identity reads

aP(n)=hP(n+2)+hP(n+5)

With x=010, xP=01001001, whose shortest prefix ending in P is 01001 = x01. Thus P′=01 and r=2.

Practice

Find the autocorrelation word

What is the autocorrelation word of 0011? Write a 0/1 string.

What is the autocorrelation word of 1110101011? Write a 0/1 string.

Practice this topic →Every quiz from this lesson, at four difficulties.

References