Periods of words (Lists) #
This file defines the notion of a period of a word (list) and proves the Periodicity Lemma.
Implementation notes #
The definition of a period is given in terms of self-overlap. Equivalent characterizations in terms of indices and modular arithmetic are also provided.
Tags #
periodicity lemma, Fine-Wilf theorem, period, periodicity
HasPeriod w p, means that the list w has the period p,
which can be seen in two equivalent ways:
· The list w starts again after the prefix of length p. That is, w overlaps with itself
with offset p.
· The element of w at index i is the same as the element at index i + p, for all i
The definition is given in terms of the self-overlap.
Instances For
The Periodicity Lemma, also known as the Fine and Wilf theorem, shows that
if word w of length at least p + q - gcd p q has two periods p and q,
then it has a period gcd p q.
The proof is similar to the Euclidean algorithm for computing gcd.