In
computer science
Computer science is the study of computation, automation, and information. Computer science spans theoretical disciplines (such as algorithms, theory of computation, information theory, and automation) to practical disciplines (includin ...
, the complexity function of a ''word'' or ''
string
String or strings may refer to:
*String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects
Arts, entertainment, and media Films
* ''Strings'' (1991 film), a Canadian anim ...
'' (a finite or infinite sequence of symbols from some
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 ...
) is the function that counts the number of distinct ''factors'' (substrings of consecutive symbols) of that string. More generally, the complexity function of a
formal language
In logic, mathematics, computer science, and linguistics, a formal language consists of words whose letters are taken from an alphabet and are well-formed according to a specific set of rules.
The alphabet of a formal language consists of s ...
(a set of finite strings) counts the number of distinct words of given length.
Complexity function of a word
Let ''u'' be a (possibly infinite) sequence of symbols from an alphabet. Define the function
''p''
''u''(''n'') of a positive integer ''n'' to be the number of different factors (consecutive substrings) of length ''n'' from the string ''u''.
[Lothaire (2011) p.7][Pytheas Fogg (2002) p.3][Berstel et al (2009) p.82][Allouche & Shallit (2003) p.298]
For a string ''u'' of length at least ''n'' over an alphabet of size ''k'' we clearly have
:
the bounds being achieved by the constant word and a disjunctive word,[Bugeaud (2012) p.91] for example, the Champernowne word respectively.[Cassaigne & Nicolas (2010) p.165] For infinite words ''u'', we have ''p''''u''(''n'') bounded if ''u'' is ultimately periodic (a finite, possibly empty, sequence followed by a finite cycle). Conversely, if ''p''''u''(''n'') ≤ ''n'' for some ''n'', then ''u'' is ultimately periodic.[Allouche & Shallit (2003) p.302]
An aperiodic sequence is one which is not ultimately periodic. An aperiodic sequence has strictly increasing complexity function (this is the Morse–Hedlund theorem),[Cassaigne & Nicolas (2010) p.166] so ''p''(''n'') is at least ''n''+1.[Lothaire (2011) p.22]
A set ''S'' of finite binary words is ''balanced'' if for each ''n'' the subset ''S''''n'' of words of length ''n'' has the property that the Hamming weight
The Hamming weight of a string is the number of symbols that are different from the zero-symbol of the alphabet used. It is thus equivalent to the Hamming distance from the all-zero string of the same length. For the most typical case, a string o ...
of the words in ''S''''n'' takes at most two distinct values. A balanced sequence is one for which the set of factors is balanced.[Allouche & Shallit (2003) p.313] A balanced sequence has complexity function at most ''n''+1.[Lothaire (2011) p.48]
A Sturmian word over a binary alphabet is one with complexity function ''n'' + 1.[Pytheas Fogg (2002) p.6] A sequence is Sturmian if and only if it is balanced and aperiodic.[Lothaire (2011) p.46][Allouche & Shallit (2003) p.318] An example is the Fibonacci word
A Fibonacci word is a specific sequence of binary digits (or symbols from any two-letter alphabet). The Fibonacci word is formed by repeated concatenation in the same way that the Fibonacci numbers are formed by repeated addition.
It is a parad ...
. More generally, a Sturmian word over an alphabet of size ''k'' is one with complexity ''n''+''k''−1. An Arnoux-Rauzy word over a ternary alphabet has complexity 2''n'' + 1:[ an example is the ]Tribonacci word
In mathematics, the Rauzy fractal is a fractal set associated with the Tribonacci substitution
: s(1)=12,\ s(2)=13,\ s(3)=1 \,.
It was studied in 1981 by Gérard Rauzy, with the idea of generalizing the dynamic properties of the Fibonacci mor ...
.[Pytheas Fogg (2002) p.368]
For recurrent words, those in which each factor appears infinitely often, the complexity function almost characterises the set of factors: if ''s'' is a recurrent word with the same complexity function as ''t'' are then ''s'' has the same set of factors as ''t'' or δ''t'' where δ denotes the letter doubling morphism ''a'' → ''aa''.[Berstel et al (2009) p.84]
Complexity function of a language
Let ''L'' be a language over an alphabet and define the function ''p''''L''(''n'') of a positive integer ''n'' to be the number of different words of length ''n'' in ''L''[Berthé & Rigo (2010) p.166] The complexity function of a word is thus the complexity function of the language consisting of the factors of that word.
The complexity function of a language is less constrained than that of a word. For example, it may be bounded but not eventually constant: the complexity function of the regular language
In theoretical computer science and formal language theory, a regular language (also called a rational language) is a formal language that can be defined by a regular expression, in the strict sense in theoretical computer science (as opposed to ...
takes values 3 and 4 on odd and even ''n''≥2 respectively. There is an analogue of the Morse–Hedlund theorem: if the complexity of ''L'' satisfies ''p''''L''(''n'') ≤ ''n'' for some ''n'', then ''p''''L'' is bounded and there is a finite language ''F'' such that[
:
A polynomial or ]sparse language In computational complexity theory, a sparse language is a formal language (a set of strings) such that the complexity function, counting the number of strings of length ''n'' in the language, is bounded by a polynomial function of ''n''. They are ...
is one for which the complexity function ''p''(''n'') is bounded by a fixed power of ''n''. A regular language
In theoretical computer science and formal language theory, a regular language (also called a rational language) is a formal language that can be defined by a regular expression, in the strict sense in theoretical computer science (as opposed to ...
which is not polynomial is ''exponential'': there are infinitely many ''n'' for which ''p''(''n'') is greater than ''k''''n'' for some fixed ''k'' > 1.[Berthé & Rigo (2010) p.136]
Related concepts
The '' topological entropy'' of an infinite sequence ''u'' is defined by
:
The limit exists as the logarithm of the complexity function is subadditive 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. ...
.[Pytheas Fogg (2002) p.4][Allouche & Shallit (2003) p.303] Every real number between 0 and 1 occurs as the topological entropy of some sequence is applicable,[Cassaigne & Nicolas (2010) p.169] which may be taken to be uniformly recurrent[Berthé & Rigo (2010) p.391] or even uniquely ergodic.[Berthé & Rigo (2010) p.169]
For ''x'' a real number and ''b'' an integer ≥ 2 then the complexity function of ''x'' in base ''b'' is the complexity function ''p''(''x'',''b'',''n'') of the sequence of digits of ''x'' written in base ''b''.
If ''x'' is an irrational number
In mathematics, the irrational numbers (from in- prefix assimilated to ir- (negative prefix, privative) + rational) are all the real numbers that are not rational numbers. That is, irrational numbers cannot be expressed as the ratio of two inte ...
then ''p''(''x'',''b'',''n'') ≥ ''n''+1; if ''x'' is rational
Rationality is the quality of being guided by or based on reasons. In this regard, a person acts rationally if they have a good reason for what they do or a belief is rational if it is based on strong evidence. This quality can apply to an abil ...
then ''p''(''x'',''b'',''n'') ≤ ''C'' for some constant ''C'' depending on ''x'' and ''b''.[Bugeaud (2012) p.91] It is conjectured that for algebraic irrational ''x'' the complexity is ''b''''n'' (which would follow if all such numbers were normal) but all that is known in this case is that ''p'' grows faster than any linear function of ''n''.[Berthé & Rigo (2010) p.414]
The abelian complexity function ''p''ab(''n'') similarly counts the number of occurrences of distinct factors of given length ''n'', where now we identify factors that differ only by a permutation of the positions. Clearly ''p''ab(''n'') ≤ ''p''(''n''). The abelian complexity of a Sturmian sequence satisfies ''p''ab(''n'') = 2.
References
*
*
*
*
*
*
* {{cite book , last=Pytheas Fogg , first=N. , editor1=Berthé, Valérie, editor1-link=Valérie Berthé, editor2=Ferenczi, Sébastien, editor3=Mauduit, Christian, editor4=Siegel, A. , title=Substitutions in dynamics, arithmetics and combinatorics , series=Lecture Notes in Mathematics , volume=1794 , location=Berlin , publisher=Springer-Verlag
Springer Science+Business Media, commonly known as Springer, is a German multinational publishing company of books, e-books and peer-reviewed journals in science, humanities, technical and medical (STM) publishing.
Originally founded in 1842 ...
, year=2002 , isbn=3-540-44141-7 , zbl=1014.11015
Theoretical computer science