Profinite word

In mathematics, more precisely in formal language theory, the profinite words are a generalization of the notion of finite words into a complete topological space. This notion allows the use of topology to study languages and finite semigroups. For example, profinite words are used to give an alternative characterization of the algebraic notion of a variety of finite semigroups.
Definition.
Let "A" an alphabet. The set of profinite words over "A" consists of the completion of a metric space whose domain is the set formula_1 of words over "A". The distance used to define the metric is given using a notion of separation of words. Those notions are now defined.
Separation.
Let "M" and "N" be monoids, and let "p" and "q" be elements of the monoid "M". Let "φ" be a morphism of monoids from "M" to "N". It is said that the morphism "φ" separates "p" and "q" if formula_2. For example, the morphism formula_3 sending a word to the parity of its length separates the words "ababa" and "abaa". Indeed formula_4. 
It is said that "N" separates "p" and "q" if there exists a morphism of monoids "φ" from "M" to "N" that separates "p" and "q". Using the previous example, formula_5 separates "ababa" and "abaa". More generally, formula_6 separates any words whose size are not congruent modulo "n". In general, any two distinct words can be separated, using the monoid whose elements are the factors of "p" plus a fresh element 0. The morphism sends prefixes of "p" to themselves and everything else to 0.
Distance.
The distance between two distinct words "p" and "q" is defined as the inverse of the size of the smallest monoid "N" separating "p" and "q". Thus, the distance of "ababa" and "abaa" is formula_7. The distance of "p" and itself is defined as 0.
This distance "d" is an ultrametric, that is, formula_8. Furthermore it satisfies formula_9 and formula_10.
Since any word "p" can be separated from any other word using a monoid with "|p|+1" elements, where "|p|" is the length of "p", it follows that the distance between "p" and any other word is at least formula_11. Thus the topology defined by this metric is discrete.
Profinite topology.
The profinite completion of formula_1, denoted formula_13, is the completion of the set of finite words under the distance defined above. The completion preserves the monoid structure.
The topology on formula_13 is .
Any monoid morphism formula_15, with "M" finite can be extended uniquely into a morphism formula_16, and this morphism is . Furthermore, formula_13 is the least topological space with this property.
Profinite word.
A profinite word is an element of formula_13. And a profinite language is a set of profinite words. Every finite word is a profinite word. A few examples of profinite words that are not finite are now given.
For "m" any word, let formula_19 denote formula_20. Note that formula_21 is a Cauchy sequence. Intuitively, to separate formula_21 and formula_23, a monoid should count at least up to formula_24, hence requires at least formula_24 elements. Since formula_21 is a Cauchy sequence, formula_19 is indeed a profinite word.
Furthermore, the word formula_19 is idempotent. This is due to the fact that, for any morphism formula_29 with "N" finite, formula_30. Since "N" is finite, for "i" great enough, formula_31 is idempotent, and the sequence is constant. 
Similarly, formula_32 and formula_33 are defined as formula_34 and formula_35 respectively.
Profinite languages.
The notion of profinite languages allow to relate notions of semigroup theory to notions of topology. More precisely, given "P" a profinite language, the following statements are equivalent:
Similar statements also holds for languages "P" of finite words. The following conditions are equivalent.
Those characterisations are due to the more general fact that, taking the closure of a language of finite words, and restricting a profinite language to finite words are inverse operations, when they are applied to recognisable languages.