Twovariable first order logic with modular predicates over words
S TA C S '
Twovariable rst order logic with modular predicates over words?
Luc Dartois 0
Charles Paperman 0
0 LIAFA, Universite ParisDiderot and CNRS , Case 7014, 75205 Paris Cedex 13 , France
We consider rst order formulae over the signature consisting of the symbols of the alphabet, the symbol < (interpreted as a linear order) and the set MOD of modular numerical predicates. We study the expressive power of FO2[<, MOD], the twovariable rst order logic over this signature, interpreted over nite words. We give an algebraic characterization of the corresponding regular languages in terms of their syntactic morphisms and we also give simple unambiguous regular expressions for them. It follows that one can decide whether a given regular language is captured by FO2[<, MOD]. Our proofs rely on a combination of arguments from semigroup theory (stamps), model theory (EhrenfeuchtFrasse games) and combinatorics.
and phrases First order logic; automata theory; semigroup; modular predicates

[<, MOD]
?1
Decidable
[12, 21]
Decidable
[4]
B?1
Decidable
[17, 21]
Decidable
[4]
FO2
Decidable
[20]
Decidable
New result
FO
Decidable
[11, 15]
Decidable
[18, 2]
We also give an algebraic characterization of FO2[<, MOD] (Theorem 6), a description
of the corresponding languages as unambiguous regular expressions (Proposition 31) and
an equivalent de nition in terms of a suitable variant of temporal logic (Proposition 30).
Our algebraic characterization QDA = FO2[<, MOD] can be viewed as an extension of
two known results (a) QA = FO[<, MOD] proved in [2, 18] and (b) DA = FO2[<] proved
in [5, 20]. However, it is not easy to extend the proofs of these equalities to our case. For
instance, the proof of (a) makes use of the successor relation, which is not expressible in
FO2[<]. Therefore our proof is closer to the proof of (b) but some technical di culties still
have to be worked out (See Section 5).
1
1.1
Preliminaries
Words and logic
Let A be a nite alphabet. We denote by A? the set of all nite words over A and 1 the
empty word. Given a word u = a0 ? ? ? an?1 of length n, we denote by ?(u) the set of letters
of A occurring in u. We associate to u the relational structure Mu = {[0, n ? 1], ?}, where
[i, j] is the set of integers between i and j and ? is the truth table of the predicates over u.
Basic examples of predicates are the binary predicate <, which is the usual order on integers,
and (a)a?A that are disjoint monadic predicates marking the positions of the letters over
the structure. For instance, if u = aabbab, then a = {0, 1, 4} and b = {2, 3, 5}. We also
consider the modular predicate M ODid, which holds at all positions equal to i modulo d,
and the 0ary predicate Did which is true if the word has length equals to i modulo d. For
u = aabbab, we have M OD02 = {0, 2, 4}, and D13 is false whereas D03 is true. We denote by
MOD the set of these modular predicates.
First order formulae are interpreted on words in the usual way (see [18]). For instance
the formula ?x ?y ?z a(x) ? b(y) ? a(z) ? x < y ? y < z de nes the language A?aA?bA?aA?.
In this article, we focus on the rst order formulae containing only two di erent
variables. The subsequent logic is denoted by FO2[<]. For instance the twovariable formula
?x ?y a(x) ? b(y) ? x < y ? (?x ? a(x) ? y < x) also de nes the language A?aA?bA?aA? of
the previous example. The rst order logic with the order predicate can be enriched with
modular predicates. We denote by FO[<, MOD] (resp. FO2[<, MOD]) the logic built with
the same atomic propositions that FO[<] (resp. FO2[<]) except that we allow the modular
predicates. For instance the formula ?x ?y ?z a(x) ? M OD02(x) ? b(y) ? a(z) ? x < y ? y < z
de nes the language (A2)?aA?bA?aA?.
Note that if required by context, we will specify the alphabet, denoting it between
parentheses. For instance FO[<](B?) denotes the set of the languages of B? de nable by a
formula of FO[<].
1.2
Algebraic notions
We recall in this section the algebraic notions used in this paper.
1.2.1
Semigroups and recognizable languages
We refer to [13] for the standard de nitions of semigroup theory. A semigroup is a set
equipped with a binary associative operation, which we will denote multiplicatively. A
monoid is a semigroup with a neutral element 1. Given a semigroup S, we denote by S1
either S if S is already a monoid or the monoid obtained by adding a neutral element 1 to
S otherwise. Recall that a monoid M divides another monoid N if M is a quotient of a
submonoid of N . This de nes a partial order on nite monoids.
A stamp is a surjective monoid morphism from A? onto a nite monoid. A language
L is recognized by a nite monoid M if there exists a stamp ? : A? ? M and a subset
P of M such that L = ??1(P ). A language is recognizable if it is recognized by a nite
monoid. Kleene's theorem states that the set of recognizable languages is exactly the set of
rational (or regular) languages. The syntactic congruence of a regular language L of A? is
the equivalence relation ?L de ned as follow:
u ?L v if and only if for all w, w0 ? A?, wuw0 ? L ? wvw0 ? L.
The monoid A?/?L is the syntactic monoid of L and the morphism ? : A? ? A?/?L is the
syntactic stamp.
1.2.2
Stability index, stable semigroup, stable automaton
For a stamp ? : A? ? M , the set ?(A) is an element of the powerset monoid of M .
As such it has an idempotent power. The stability index of a stamp is the least positive
integer s such that ?(As) = ?(A2s). This set is therefore a semigroup called the stable
semigroup of ?. Stable semigroups are strongly related to stable automata, de ned as follows.
Let A = (Q, A, ?) be a deterministic automaton and let k be a positive integer. The
kautomaton of A is the deterministic automaton Ak = (Q, Ak, ?k) where q ?k (a1a2 ? ? ? ak) =
(? ? ? (q ? a1) ? a2) ? ? ? ) ? ak). Note that if M is the transition monoid of A, and Mk the transition
monoid of Ak, then Mk is the submonoid of M generated by the image elements of words
of length k in M .
I De nition 1. Let A = (Q, B, ?) be a deterministic automaton. We say that A is stable if
for any twoletter word, there exists a letter that has the same action over the set Q, and
conversely for any letter of B, there exists a word of B2 that has the same action over Q.
As shown in the next proposition, this de nition is a compatible translation of the stable
semigroup for an automaton.
I Proposition 2. Let A be a deterministic automaton. Then, there is an integer k such that
the associated kautomaton is stable.
The least k which satis es this proposition is called the stability index of the automaton.
It is equal to the stability index of the associated stamp.
1.2.3
Stamps and varieties
A (pseudo) variety of ( nite) monoids is a class of monoids closed under division and nite
products. According to Eilenberg [
6
], a variety of languages V is a class of languages closed
under nite union, intersection and complementation, and closed under inverse of monoid
morphism. This means that, for any monoid morphism ? : A? ? B?, X ? V(B?) implies
??1(X) ? V(A?). Furthermore Eilenberg [
6
] proved that there is a onetoone
correspondence between varieties of monoids and varieties of languages.
The class of languages FO2[<, MOD] is not closed under inverse morphisms, and the
Eilenberg's varieties theory does not apply. Still, this class is closed under inverse of
lengthmultiplying morphisms (shortened as lmmorphisms), and an algebraic characterization can
be obtained by considering a more general framework : the theory of Cvarieties
independently introduced by Esik and Ito [7] and Straubing [19] and developed by Pin and
Straubing [14].
Let us now recall the notion of variety of stamps. A morphism ? : A? ? B? is
lengthmultiplying if there exists an integer n such that for any letter a of A, ?(a) is a word of
Bn. Given two stamps ? : A? ? M and ? : A? ? N , the product stamp is the stamp
? : A? ? M ? N de ned by ?(a) = (?(a), ?(a)). A stamp ? : A? ? M lmdivides another
stamp ? : B? ? N if and only if there exists a pair (?, ?) such that ? is a lmmorphism
from A? to B?, ? : N ? M is a partial onto monoid morphism and ? = ? ? ? ? ?. The
couple (?, ?) is called an lmdivision.
Then a lmvariety of stamps is a class of stamps containing the trivial stamp and closed
under lmdivision and nite product. Note that if V is a variety of monoids, then the class
of all stamps whose image is a monoid in V forms a lmvariety of stamps, also denoted V.
Moreover, given a lmvariety of stamps V, the class V of all languages recognized by a stamp
in V is a lmvariety of languages. The correspondence V ? V is onetoone and onto [19].
These notions are very useful to decide membership problems for regular languages. Let us
recall a few examples.
I Example 3. A monoid M is aperiodic if there exists an integer n such that for any x ? M ,
xn = xn+1. It has been proved by Schutzenberger [15] and McNaughton and Papert [11]
that the class of aperiodic monoids forms a variety called A and the corresponding variety of
languages is exactly the rstorder de nable languages, with the order and letter predicates.
I Example 4. Let DA be the variety of monoids satisfying the equation
(xy)? = (xy)?x(xy)? where ? is the idempotent power of the monoid. Alternatively DA is
the variety of monoids whose regular Dclasses are aperiodic semigroups. The corresponding
variety of languages DA is the class of FO2[<]de nable languages [20] or equivalently the
unambiguous starfree languages [16].
I Example 5. Given a variety V, the set of all stamps whose stable semigroup is in V forms
a lmvariety of stamps denoted by QV. A language L has its syntactic stamp in QV if
and only if there is an automaton A recognizing L and a positive integer k such that the
kautomaton of A has its transition monoid in V. Straubing proved in [18] that a language
is de nable in FO[<, MOD] if and only if its syntactic stamp belongs to the lmvariety of
stamps QA. We always denote by QV the lmvariety of languages associated to QV.
2
Main result
Our main result extends the algebraic characterization of FO2[<]de nable languages by
Therien and Wilke [20] to FO2[<, MOD]de nable languages. The next theorem states that
the languages de nable in FO2[<, MOD] are exactly the languages whose syntactic stamp
is in QDA.
I Theorem 6. FO2[<, MOD] = QDA
Given a regular language (given by a regular expression or by some nite automaton), one
can e ectively compute the stable semigroup of its syntactic stamp. Since membership in
DA is decidable we get the following corollary.
I Corollary 7. Given a regular language L, one can decide whether L is FO2[<, MOD]
de nable.
In Section 3 we will give intuition of the power of the modular predicates. The rst
inclusion FO2[<, MOD] ? QDA will be proved in Section 4, using general arguments on
automata and logic. The second inclusion is proved in Section 5, using EhrenfeuchtFrasse
games and algebraic tools. We will extend our main result to several other characterizations
in Section 6.
3
FO2[<] over an enriched alphabet
Given an integer d > 1, let us denote by FO2[<, MODd] the fragment of FO2[<, MOD]
restricted to congruences modulo d. For a given language, this restriction does not lead to
any loss of generality.
I Lemma 8. Let L be a language of FO2[<, MOD]. Then there exists an integer d such that L is in FO2[<, MODd].
We now
x a positive integer d.
I De nition 9 (Enriched alphabet). Let A be an alphabet. We call the set Ad = A ? (Z/dZ)
the enriched alphabet of A, and we denote by ? : A?d ? A? the projection de ned by
?(a, i) = a for each (a, i) ? Ad.
For example, the word (a, 2)(b, 1)(b, 2)(a, 0) is an enriched word of abba for d = 3. We
say that abba is the underlying word of (a, 2)(b, 1)(b, 2)(a, 0).
I De nition 10 (Wellformed words). A word (a0, i0)(a1, i1) ? ? ? (an, in) of Ad is wellformed
if for 0 6 j 6 n, ij ? j mod d. We denote by K the set of all wellformed words of A?.
d
I De nition 11. For a word u = a0a1 ? ? ? an ? A?, the word u = (a0, 0)(a1, 1) ? ? ? (ai, i mod
d) ? ? ? (an, n mod d) is called the wellformed word attached to u.
I Remark. On wellformed structures, the projection ? is a onetoone application.
The enriched word (a, 0)(b, 1)(b, 2)(a, 0) is a wellformed word for d = 3. Thanks to the
previous remark, it is the unique wellformed word having the word abba as underlying word.
I Remark. The operation u ? u is not a morphism. Indeed, if u 6? 0 mod d then uv 6= u v.
Thus we de ne the kshift operation, denoted by uk, which maps the word u = u0 ? ? ? un
to the enriched word (u0, k mod d)(u1, k + 1 mod d) ? ? ? (un, n + k mod d). Note that, if
u ? k mod d, then uv = u vk.
I Proposition 12. Let d be a positive integer. Then
FO2[<, MODd](A?) = ?(FO2[<](A?d) ? K).
The proof relies on a syntactic transformation of the formulae. We replace M ODid by a
conjunction of enriched letters predicates. This can be done in the opposite direction as
well, as we consider only wellformed words.
We recall (see [10]) that two words are separated by a formula of FO2[<] with quanti er
depth n if and only if Spoiler wins the n rounds EhrenfeuchtFrasse game with two coloured
pebbles. Thus one can state, in light of Proposition 12, the following assertion:
I Proposition 13. Let u, v be words of A?. Then there exists a formula of FO2[<, MODd] of
quanti er depth n that separates them if, and only if, Spoiler wins the n rounds
Ehrenfeucht
Frasse game for FO2[<] over the wellformed pair (u, v).
4
The inclusion FO2[<, MOD] ? QDA
In this section, we prove one direction of the main theorem, using the enriched alphabet and
the wellformed words. Let us rst study the language K of wellformed words.
(a,i)
i 6= 3
(a,3)
1
3
Consider the semigroup Bd = (Z/dZ ? Z/dZ) ? {?} where ? is a zero of Bd and for all (i, j)
and (k, `) in Z/dZ ? Z/dZ,
(i, j)(k, `) =
((i, `)
?
if j = k
otherwise.
The monoid Bd1 is the transition monoid of the minimal automaton of K for d > 2. Let us
denote by J1 the variety of idempotent and commutative monoids.
I Proposition 14. The set of all wellformed words is recognized by a stamp in QJ1.
I Lemma 15. Let L be a language of DA(A?d). Then the language L ? K is in QDA(A?d).
Proof. This comes from the fact that L ? DA(A?d) ? QDA(A?d), and K ? QJ 1(A?d) ?
QDA(A?d). J
Now, we can use the previous result on wellformed words over modular predicates and
prove the inclusion FO2[<, MOD] ? QDA.
I Theorem 16. The syntactic stamp of a FO2[<, MOD]de nable language belongs to QDA.
As suggested by one the referees, this result can be proved by using EhrenfeuchtFrasse
games. The proof given below relies on nite automata and could easily be modi ed to
recover the inclusion FO[<, MOD] ? QA [18] and similar results for other fragments of
logic.
Proof. Let L be a regular language de nable in FO2[<, MOD](A?). Then by Lemma 8,
there exists an integer d such that L is de ned in FO2[<, MODd](A?). By Proposition 12,
there exists a formula ? in FO2[<](A?d) such that, L = ?(L0) with L0 = L(?) ? K. Since
FO2[<] = DA (see [20]), and thanks to Lemma 15, the language L0 is in QDA(A?d). Let
A0 = (Q, Ad, ?, i, F ) be its minimal trim deterministic automaton. Since ? is onetoone,
the automaton ?(A0), obtained by dropping the integer component on the transitions of A0,
recognizes L. As A0 is trim and recognizes only wellformed words, the labels of all the
outgoing edges from a given state have the same second component. For 0 6 i < d, let
Qi = {q ? Q  there exists a ? A such that q ? (a, i) is de ned }
and let QE be the set of all states of fanout 0. Then Q is a disjoint union of the sets Qi
(0 6 i < d) and QE. Observing that a word of length k can only send a state of Qi to
a state of Qi+k mod d ? QE, the transition function of the dautomaton A0d is a subset of
S Qi ? Add ? (Qi ? QE) . Then each set Qi induces a monoid Mi, which is a submonoid
06i<d
of the transition monoid of A0d. Now, going back to the projected dautomaton ?(A0)d,
one can see that the action of a word u ? Ad on the set Qi is the action of the word
(u0, i) ? ? ? (ud, i ? 1) on Qi in the automaton A0d, described in Mi.
A0
A0d
Q0 . . . Qi . . . Qd?1
(a, 0)... Q...1 .?.. ?... ?... ?...
(a, i)... ?... ?... Qi...+1 .?.. ?...
(a, d ? 1) ? ? ? ? Q0
dAutomaton
Q0 . . . Qi . . . Qd?1
u... Q...0 .?.. ?... ?... ?...
ui... ?... ?... Q...i .?.. ?...
ud?1 ? ? ? ? Qd?1
The inclusion QDA ? FO2[<, MOD]
We now come to the second part of the proof of Theorem 6. We rst enrich the congruences
de ned in [20] to take the modular predicates into account.
5.1
Congruence and syntactic operations over FO2[<, MOD]
I De nition 17. Let u ? A? be a word, and let a ? A be a letter of u. We call left
adecomposition of u the unique triple (u0, a, u1) such that u = u0au1 and u0 does not contain
any a. We de ne the right decomposition in a symmetrical way.
We recall the de nition of the congruence ?n on A? from [20].
I De nition 18. [20] Let u, v ? A? be words. Then we have u ?0 v.
Moreover, u ?n v if and only if the following conditions hold:
1. ?(u) = ?(v), the two words have the same alphabet,
2. For each a occurring in u, if (u0, a, u1) is the left adecomposition of u and (v0, a, v1)
that of v, then u0 ?n v0 and u1 ?n?1 v1,
3. For each a occurring in u, if (u0, a, u1) is the right adecomposition of u and (v0, a, v1)
that of v, then u0 ?n?1 v0 and u1 ?n v1.
The termination of these inductive de nitions has to be veri ed. Let suppose that u ?n v
for some words u and v and some positive integer n. Then, thanks to the rst condition, the
parameter n + ?(u) is equal to n + ?(v)j. For any left or right decomposition we decompose
the words in two parts for which the parameter strictly decreases.
I Proposition 19. [20] The relation ?nis a congruence.
This de nition can be extended to the enriched alphabet and wellformed words as
follows. We say that u ?dn v if and only if u ?n v.
I Lemma 20. Let n, d be two positive integers, and u and v two words such that u ?dn v.
Then the following statements hold:
1. if u is the empty word, then so is v,
2. u ? v mod d,
3. if u = u0au1, v = v0bv1 with u0a ? v0b mod d and u1 < d, v1 < d, then a = b,
u1 = v1 and u0 ?dn?1 v0,
4. if u = u0au1, v = v0bv1 with u0 < d, v0 < d and au1 ? bv1 mod d, then a = b,
u0 = v0 and u1 ?dn?1 v1,
5. for any word w, uw ?dn vw and wu ?dn wv.
I Corollary 21. The relation ?dn is a congruence on A?.
We will now connect our congruence to the logic FO2[<, MODd] through the
EhrenfeuchtFrasse games for FO2[<](A?d) (cf. Proposition 13).
I Theorem 22. Let u, v ? A? be words. If u 6?dn v then there is a formula of FO2[<, MODd]
of quanti er depth at most n + ?(u) that separates u from v.
The proof makes use of EhrenfeuchtFrasse games following the arguments of [20].
5.2
Congruence and algebraic operations over QDA
We now de ne a slightly modi ed version of the Green's preorders adapted to the stable
semigroup. Let h : A? ? M be a stamp and let S be its stable semigroup. For any elements
x and y in M let us write:
x 6Rst y if and only if xM ? S ? yM ? S
x 6Lst y if and only if M x ? S ? M y ? S
x 6Hst y if and only if x 6Rst y and x 6Lst y.
We also extend our de nitions to modi ed versions of the Green's relations.
x Rst y if and only if x 6Rst y and y 6Rst x
x Lst y if and only if x 6Lst y and y 6Lst x
x Hst y if and only if x 6Hst y and y 6Hst x
We say that the stamp h is length faithful if h?1(S1) = (Ad)?. This notion is shown to
be necessary in the next lemma and does not involve a loss of generality, as shown in the
proof of Corollary 29.
I Lemma 23. Let h : A? ? M be a stamp and let S be its stable semigroup. If h is length
faithful, then the restriction of 6Rst (resp. 6Lst ) to S is the usual Green relation 6R (resp.
6L) over S.
Proof. Let x be an element of S, and y an element of M such that xy is in S. Then, since
h is length faithful, h?1(xy) is contained in (Ad)?. Moreover, as x belongs to S, we also
have h?1(x) ? (Ad)?. Thus for any word u such that h(u) = x, and any word v such that
h(v) = y, we have u ? uv ? 0 mod d, so v ? 0 mod d. Therefore y is an element of S.
This proves that for any x in S, xM ? S = xS, and consequently for any x, y in S, x 6Rst y
if and only if x 6R y in the Green relation over S.
The result for the 6Lst relation is obtained with a symmetric proof. J
I Corollary 24. Let h : A? ? M be a length faithful stamp of QDA. Then, the restriction
of the Hstclasses to S are trivial.
We also de ne the Rstdecomposition :
I De nition 25. Let u be a word and let h : A? ? M be a stamp. We call the
Rstdecomposition of u the tuple (u0, a1, u1, . . . , as, us) such that u = u0a1u1 ? ? ? asus and:
1. u0a1u1 ? ? ? aiui ? 0 mod d for all 0 6 i < s
2. h(u0a1u1 ? ? ? ui?1ai) >Rst h(u0 ? ? ? uiai+1)
3. For every pre x v of ui of length multiple of d, h(u0 ? ? ? ui?1ai) Rst h(u0 ? ? ? aiv)
4. For every pre x v and v0 of u0 of length multiple of d, h(v) Rst h(v0)
The positions occurring in the Rstdecomposition are the rst positions multiple of d
after falling in the 6Rst order. The two next lemmas will link our congruence ?dn to the
Rstdecomposition of the lmmorphisms of QDA.
I Lemma 26. Let h : A? ? M be a length faithful stamp in QDA, let S be its stable
semigroup. Let u ? S and a, x ? M . If ax ? S, then uax Rst u implies uaxa Rst u.
Proof. The elements u and uax are Rstequivalent and h is length faithful. So thanks
to Lemma 23 there is an element t of S such that u = uaxt. By iteration, we obtain
u = u(axt)?. But S belongs to DA, hence it satis es the equation (xy)?x(xy)? = (xy)?.
Thus, (axt)?ax(axt)? = (axt)?, then u = u(axt)?ax(axt)?. Shall we rewrite this last
equation, we nally get u = uaxa(xt(axt)??1). And nally u ? uaxaM ? S, proving that
u Rst uaxa. J
I Corollary 27. Let h : A? ? M be a length faithful stamp in QDA and let u be a word.
Then if (u0, a1, u1, . . . , as, us) is the Rstdecomposition of u then (ai+1, 0) 6? ?(aiui) for
i < s.
Proof. Let (u0, a1, u1, . . . , as, us) be the Rstdecomposition of u. Suppose now that there
exists i such that (ai+1, 0) ? ?(aiui) for i < s. Then, thanks to the preceding Lemma,
h(aiuiai+1) Rst h(aiui) which is in contradiction with the de nition of the Rstdecomposition
of u. J
We now have all the tools to prove the following theorem.
I Theorem 28. Let h : A? ? M be a length faithful stamp of QDA and let d be its stability
index. Then there exists an integer n such that for every words u and v, u ?dn v implies
h(u) = h(v).
Proof. Thanks to Lemma 20, if two words are equivalent for the congruence ?dn+1, then
their su xes of length smaller than d are equal and the associated pre xes are equivalent for
d
the congruence ?n. Therefore it is su cient to prove the result for words of length multiple
of d.
Let u and v be two words of length multiple of d, and an integer n > ?(u)S such that
u ?dn v. Let us prove by induction on ?(u) that h(u) = h(v). If ?(u) = 0, then u = v = 1.
Consider the result to be true up to the rank k ? 1 and let u be such that ?(u) = k.
We write (u0, a1, u1, . . . , a`, u`) the Rstdecomposition of u. One can remark that ` 6 S,
as each ai makes the word go down in the Rstclasses, whose number is bounded by the
size of S. Using the preceding corollary, (ui, ai+1, ui+1 ? ? ? u`) is a left decomposition of
xi = ui ? ? ? u` for i < `. As u ?dn v, there also exists a decomposition (v0, a1, . . . , a`, v`) of
d
v such that aiui ?n?i aivi where (ai+1, 0) 6? ?(aiui) and hence ?(aiui) 6 ?(u) ? 1. As
i < `, we have n ? i > (k ? 1)S > ?(aiui)S. Using the induction hypothesis, for i < `,
h(aiui) = h(aivi). And hence h(u) Rst h(u1 ? ? ? a`) = h(v1 ? ? ? a`) >Rst h(v). Symmetrically,
we obtain that h(v) >Rst h(u) and thus h(u) Rst h(v). Using the left/right symmetry, we
also get that h(v) Lst h(u) and hence h(v) Hst h(u). By Corollary 24, the Hstclasses are
trivial in QDA over words of length multiple of d and hence h(u) = h(v). J
I Corollary 29. QDA ? FO2[<, MOD]
Proof. Let ? : A? ? M be the syntactic stamp of L and S be the stable semigroup of ?.
Assume that ? is in QDA. We claim that the morphism h : A? ? M ? Z/dZ de ned, for
all words u, by h(u) = (?(u), u mod d) is length faithful. Indeed, the stable semigroup of
h is equal to S ? {0} and h?1(S ? {0}) = (Ad)?.
By Theorem 28, there exists an integer n such that the congruence ?dn is thinner than
the congruence induced by h which is itself thinner than the syntactic congruence of L.
Therefore L is a nite union of ?dn classes, each of them being, according to Theorem 22,
de nable by a formula of FO2[<, MODd] of quanti erdepth at most n + Ad. J
6
Other characterizations
Several other characterizations of DA are known (see [5] for a survey). For example, consider
the fragment TL[Xa, Ya] of the linear temporal logic de ned inductively as follow:
? ? >  ? ? ?  ? ? ?  ??  Xa?  Ya?.
The unary operator Xa stands for neXt a, and Ya stands for Yesterday a. For a word u and
one of its positions x, we have (u, x) = Xa? if ? is true at the next a after x. We say that the
word u satis es Xa? if (u, ?1) = Xa?. Symmetrically, we say that u satis es Ya? if (u, u) =
Ya?. It is a well known fact that the fragment TL[Xa, Ya] has the same expressiveness power
as the variety DA. Therefore, it is natural to look at TL[Xar mod d, Yar mod d], where each
predicate Xar mod d is de ned as follows. For a word u and one of its position x, we have
(u, x) = Xar mod d? if ? is true at the next a whose position is equal to r modulo d. As in
Proposition 12 we can transfer a modular information from the predicates to the letters by
changing the size of the alphabet.
I Proposition 30. Let d be a nonzero integer. Then,
TL[Xar mod d, Yar mod d](A?) = ?(TL[X(a,r mod d), Y(a,r mod d)](A?d) ? K).
In [16], Schutzenberger de ned the monomials as the set of languages of the form
B0?a1B1? ? ? ? anBn?, with ai ? A and Bi ? A. A monomial L is said to be unambiguous if for
every word u in L, there exists only one decomposition u = u0a1u1 ? ? ? anun with ?(ui) ? Bi.
Finally, Schutzenberger proved in [16] that a language is in DA if and only if it is a disjoint
union of unambiguous monomials. We now give a similar de nition adapted to the modular
predicates. We de ne the modular monomials as the languages of the form
Proof. We know by Theorem 6 and Proposition 12 that a language L is in QDA(A?) if
and only if there exists an integer d such that L is the projection of a set of wellformed
words of a language L0 in DA(A?d). Then L0 is a disjoint union of unambiguous
monomials. As the projection over wellformed words preserves disjoint union, it su ces to show
that each unambiguous monomial projects into a disjoint union of modular monomials. Let
B0?b1B1? ? ? ? bnBn? be an enriched unambiguous monomial with bi = (ai, ri). Then the
projection of its wellformed words is the rational expression
(A00 ? ? ? Ad?1)?A00 ? ? ? Ar01 a1(Ai1+1 ? ? ? Ai1)?Ai1+1 ? ? ? Ar12 a2 ? ? ?
0
with Aij = {a  (a, j) ? Bi}, which can be rewritten as a disjoint union of unambiguous
modular monomials. J
7
Conclusion
Our main results can now be summarized in a single statement, a consequence of Propositions
12, 30, 31 and Theorem 6.
I Theorem 32. Let L be a regular language. Then, the following assertions are equivalent:
L has its syntactic stamp in QDA,
L is de nable in FO2[<, MOD],
L is de nable in TL[Xar mod d, Yar mod d],
L is a disjoint union of unambiguous modular monomials.
Our results are an instance of a more general problem: given a fragment F of FO, what is
the expressive power of F[<, MOD]. In particular, if F[<] has an algebraic characterization,
is there also a natural algebraic description of F[<, MOD]? Further if F[<] is decidable,
does it imply that F[<, MOD] is also decidable?
These questions are related to nontrivial questions of semigroup theory [1]. There is some
hope that, for some su ciently wellbehaved fragment, F[<] corresponds to some variety of
monoids V and that F[<, MOD] corresponds to the semidirect product V ? MOD where
MOD denotes the variety of all stamps onto a cyclic group. This is the case for instance
for the fragment ?1 and B?1, as shown in [4]. The decidability of V ? MOD (given that
of V) leads to another series of problems. When V ? MOD is equal to QV the decidability
follows immediately but this is not always the case. For instance, B?1[<] corresponds to
the variety J but B?1[<, MOD] does not correspond to QJ and more sophisticated tools
using derived categories have to be used [22]. Another possible route would be to follow a
model theoretic approach as in [8, 9].
Acknowledgements We would like to thank the anonymous referees for very useful
suggestions and Olivier Carton and JeanEric Pin for their helpful advice.
J. Almeida , Hyperdecidable pseudovarieties and the calculation of semidirect products , Internat. J. Algebra Comput. 9 , 3  4 ( 1999 ), 241 { 261 .
D. A. M. Barrington , K. Compton , H. Straubing and D. Therien , Regular languages in NC1, J. Comput. System Sci. 44 , 3 ( 1992 ), 478 { 499 .
J. R. Bu chi, Weak secondorder arithmetic and nite automata , Z. Math. Logik Grundlagen Math. 6 ( 1960 ), 66 { 92 .
L. Chaubard , J.E. Pin and H. Straubing , First order formulas with modular predicates , in 21st Annual IEEE Symposium on Logic in Computer Science (LICS 2006 ), pp. 211 { 220 , IEEE, 2006 .
V. Diekert , P. Gastin and M. Kufleitner , A survey on small fragments of rstorder logic over nite words , Internat. J. Found. Comput. Sci. 19 , 3 ( 2008 ), 513 { 548 .
S. Eilenberg , Automata, languages, and machines . Vol. B, Academic Press [Harcourt Brace Jovanovich Publishers], New York, 1976 . With two chapters by Bret Tilson , Pure and Applied Mathematics , Vol. 59 .
Z. Esik and M. Ito , Temporal logic with cyclic counting and the degree of aperiodicity of nite automata , Acta Cybernet . 16 , 1 ( 2003 ), 1 { 28 .
Comb. 6 , 4 ( 2001 ), 437 { 452 . 2nd Workshop on Descriptional Complexity of Automata, Grammars and Related Structures (London, ON, 2000 ).
C. Glasser , H. Schmitz and V. Selivanov , E cient algorithms for membership in Boolean hierarchies of regular languages , in STACS 2008 , pp. 337 { 348 , LIPIcs . Leibniz Int. Proc. Inform . vol. 1 , Schloss Dagstuhl . LeibnizZent. Inform., Wadern , 2008 .
N. Immerman , Upper and lower bounds for rst order expressibility , J. Comput. System Sci. 25 , 1 ( 1982 ), 76 { 98 .
R. McNaughton and S. Papert , Counterfree automata, The M.I.T . Press, Cambridge, Mass.London, 1971 .
J.E. Pin , Syntactic semigroups , in Handbook of formal languages , Vol. 1 , pp. 679 { 746 , Springer, Berlin, 1997 .
J.E. Pin and H. Straubing , Some results on Cvarieties , Theor. Inform. Appl . 39 , 1 ( 2005 ), 239 { 262 .
M. P. Schu tzenberger, On nite monoids having only trivial subgroups , Information and Control 8 ( 1965 ), 190 { 194 .
M. P. Schu tzenberger, Sur le produit de concatenation non ambigu , Semigroup Forum 13 , 1 ( 1976 /77), 47 { 75 .
I. Simon , Piecewise testable events, in Automata theory and formal languages (Second GI Conf ., Kaiserslautern , 1975 ), pp. 214 { 222 ., Lect. Notes Comp. Sci. vol. 33 , Springer, Berlin, 1975 .
H. Straubing , Finite automata, formal logic, and circuit complexity, Birkhauser Boston Inc ., Boston, MA, 1994 .
H. Straubing , On logical descriptions of regular languages , in LATIN 2002 : Theoretical informatics , pp. 528 { 538 , Lect. Notes Comp. Sci. vol. 2286 , Springer, Berlin, 2002 .
D. Therien and T. Wilke , Over words, two variables are as powerful as one quanti er alternation , in STOC ' 98 (Dallas, TX), pp. 234 { 240 , ACM , New York, 1999 .
W. Thomas , Classifying regular events in symbolic logic , J. Comput. System Sci. 25 , 3 ( 1982 ), 360 { 376 .
Pure Appl. Algebra 48 , 1  2 ( 1987 ), 83 { 198 .