In
combinatorics
Combinatorics is an area of mathematics primarily concerned with counting, both as a means and an end in obtaining results, and certain properties of finite structures. It is closely related to many other areas of mathematics and has many a ...
, a squarefree word is a
word
A word is a basic element of language that carries an objective or practical meaning, can be used on its own, and is uninterruptible. Despite the fact that language speakers often have an intuitive grasp of what a word is, there is no consen ...
(a sequence of symbols) that does not contain any squares. A square is a word of the form , where is not empty. Thus, a squarefree word can also be defined as a word that
avoids the pattern .
Finite squarefree words
Binary alphabet
Over a binary
alphabet
An alphabet is a standardized set of basic written graphemes (called letters) that represent the phonemes of certain spoken languages. Not all writing systems represent language in this way; in a syllabary, each character represents a s ...
, the only squarefree words are the empty word
, and
.
Ternary alphabet
Over a ternary alphabet ''
'', there are infinitely many squarefree words. It is possible to count the number
of ternary squarefree words of length .
This number is bounded by
, where
.
The upper bound on
can be found via
Fekete's Lemma In mathematics, subadditivity is a property of a function that states, roughly, that evaluating the function for the sum of two elements of the domain always returns something less than or equal to the sum of the function's values at each element. T ...
and approximation by
automata
An automaton (; plural: automata or automatons) is a relatively self-operating machine, or control mechanism designed to automatically follow a sequence of operations, or respond to predetermined instructions.Automaton – Definition and Mor ...
. The lower bound can be found by finding a substitution that preserves squarefreeness.
Alphabet with more than three letters
Since there are infinitely many squarefree words over three-letter alphabets, this implies there are also infinitely many squarefree words over an alphabet with more than three letters.
The following table shows the exact growth rate of the -ary squarefree words:
2-dimensional words
Consider a map
from
to , where is an alphabet and
is called a 2-dimensional word. Let
be the entry
. A word
is a line of
if there exists
such that
, and for
.
Carpi proves that there exists a 2-dimensional word
over a 16-letter alphabet such that every line of
is squarefree. A computer search shows that there are no 2-dimensional words
over a 7-letter alphabet, such that every line of
is squarefree.
Generating finite squarefree words
Shur proposes an algorithm called R2F (random-t(w)o-free) that can generate a squarefree word of length over any alphabet with three or more letters. This algorithm is based on a modification of
entropy compression: it randomly selects letters from a k-letter alphabet to generate a -ary squarefree word.
algorithm R2F is
input: alphabet size
'',''
word length ''
''
output: a -ary squarefree word of length .
choose