## Abstract

We develop an algebraic theory for languages of data words. We prove that, under certain conditions, a language of data words is definable in first-order logic if and only if its syntactic monoid is aperiodic.

### Keywords

Monoids Nominal sets Data words## 1 Introduction

This paper is an attempt to combine two fields.

For instance, the language “words where there exists a position with labelA regular language of finite words is definable in first-order logic if and only if its syntactic monoid is aperiodic.

*a*” is defined by the first-order logic formula (this example does not even use the order on positions <, which is also allowed in general) The syntactic monoid of this language is isomorphic to {0,1} with multiplication, where 0 corresponds to the words that satisfy the formula, and 1 to the words that do not. Clearly, this monoid does not contain any non-trivial group. There are many results similar to the theorem above, each one providing a connection between seemingly unrelated concepts of logic and algebra, see e.g. the book [13].

The motivation of this paper is to combine the two fields, and prove a theorem that is analogous to the Schützenberger-McNaughton-Papert characterization theorem, but talks about languages of data words. If we want an analogue, we need to choose the notion of regular language for data words, the definition of first-order logic for data words, and then find the property corresponding to aperiodicity.

For the sake of simplicity, we assume that the alphabet is of the form \(A = \varSigma\times\mathbb{D}\), where *Σ* is a finite set, whose elements are called *labels*, and where \(\mathbb{D}\) is the infinite set of data values. Later, we will study a more general and abstract definition of an alphabet, which will cover other cases, e.g. the set of unordered pairs of data values.

*x*<

*y*for order on positions, and

*x*∼

*y*for having the same data value. Also, for each label

*a*∈

*Σ*we have a unary predicate

*a*(

*x*) that selects positions with label

*a*. An example of a formula of first-order logic is the formula which defines the language

*L*

_{dd}in the running example.

As for the notion of regular language, we use the monoid approach. For languages of data words, we use the syntactic monoid, defined in the same way as it is for words over finite alphabets. That is, elements of the syntactic monoid are equivalence classes of the two-sided Myhill-Nerode congruence. When the alphabet is infinite, the syntactic monoid is infinite for almost every language of data words. For instance, in the case of the running example language *L*_{dd}, two words *w*,*w*′∈*D*^{∗} are equivalent if and only if: either both belong to *L*_{dd}, or both have the same first and last letters. Since there are infinitely many letters, there are infinitely many equivalence classes.

*orbit-finite*monoids. Intuitively speaking, two elements of a syntactic monoid are considered to be in the same orbit if there is a renaming of data values that maps one element to the other.

^{1}For instance, in the running example

*L*

_{dd}, the elements of the syntactic monoid that correspond to the words 1⋅7 and 2⋅3⋅4⋅8 are not equal, but they are in the same orbit, because the renaming

*i*↦

*i*+1 maps 1⋅7 to 2⋅8, which corresponds to the same element of the syntactic monoid as 2⋅3⋅4⋅8. It is not difficult to see that the syntactic monoid of

*L*

_{dd}has four orbits: one for the empty word, one for words outside

*L*

_{dd}where the first and last letters are not equal, and for words outside

*L*

_{dd}where the first and last letters are equal, and one for words inside

*L*

_{dd}. The monoid is illustrated in Fig. 1.

The contribution of this paper is a study of orbit-finite monoids. We develop the algebraic theory of orbit-finite monoids, and show that it resembles the theory of finite monoids. The main result of the paper is Theorem 9.1, which shows that the Schützenberger-McNaughton-Papert characterization also holds for languages of data words with orbit-finite syntactic monoids.

### Nominal Sets

The key idea of using permutations of data values to act on the syntactic monoid of a language, or more generally, to act on any monoid, goes back to nominal sets. The theory of nominal sets originates from the work of Frankel in 1922, further developed by Mostowski in the 1930s. At that time, nominal sets were used to prove independence of the axiom of choice, and other axioms. In Computer Science, they have been rediscovered by Gabbay and Pitts in [7], as an elegant formalism for modeling name binding. Since then, nominal sets have become a lively topic in semantics. They were also independently rediscovered by the concurrency community, as a basis for syntax-free models of name-passing process calculi, see [11, 12].

The definition of monoid used in this paper is the same thing as a monoid in the category of nominal sets. That is why we call it a *nominal monoid*. The restriction on orbit-finiteness is what corresponds to finiteness in the category of nominal sets (more precisely, a nominal set is orbit-finite if and only if it is a finitely presentable object). In other words, the theory of syntactic monoids for languages of data words turns out to be the same theory as the theory of finite monoids in the category of nominal sets.

### Other Related Work

The idea to present effective characterizations of logics on data words was proposed by Benedikt, Ley and Puppis. In [1], they show that definability in first-order logic is undecidable if the input is a nondeterministic register automaton. Also, they provide some decidable characterizations, including a characterization of first-order logic with local data comparisons within the class of languages recognized by deterministic register automata. This result is incomparable to the one in this paper, because we characterize a different logic (data comparisons are not necessarily local), and inside a weaker class of recognizers (nominal monoids have less expressive power than deterministic register automata).

There are two papers on algebra for languages over infinite alphabets. One approach is described by Bouyer, Petit and Thérien [5]. Their monoids are different from ours in the following ways: the definition of a monoid explicitly talks about registers, there is no syntactic monoid, monoids have undecidable emptiness (not mention questions such as aperiodicity or first-order definability). Our setting is closer to the approach of Francez and Kaminski from [6], but the latter talks about automata and not monoids, and does not study the connection with logics.

### Progress Beyond the Conference Version

This article is a journal version of a conference paper [2]. The main difference is that the conference version was written without examining the connection to nominal sets; this shortcoming is fixed here. The paper is written entirely using the language of nominal sets; and theorems from the nominal literature are cited instead of reproved.

Using the abstract language of nominal sets requires more abstract and general definitions. An important example is our abstract notion of first-order logic and MSO logic for words in nominal sets. In the special case of data words with alphabets of the form \(\varSigma\times \mathbb{D}\), the abstract logic coincides with the standard notion of logic for data words.

Unlike the conference version, we use the more general notion of nominal sets, from [3], which allows more structure on data values, such as order instead of equality only.

## 2 Nominal Sets

In this section we describe nominal sets. The definition is based on [3], with slight modifications.

### Group Action

*G*on a set

*X*is a function subject to axioms

*x*∈

*X*and

*π*,

*σ*∈

*G*, where 1 is the neutral element of

*G*. A set equipped with such an action is called a

*G*-

*set*. The point of the axioms is to make unambiguous an expression like

*xπσ*.

### Nominal Symmetry

*set of data values*, and a group

*G*of bijections on \(\mathbb{D}\). The group

*G*need not contain all bijections of \(\mathbb{D}\). The idea is that \(\mathbb{D}\) might have some structure, and

*G*contains the structure-preserving bijections (i.e. automorphisms). The pair \((\mathbb{D} ,G)\) is called a

*data symmetry*. In this paper, we will use the following symmetries as the examples:

The set \(\mathbb{D}\) is empty, and

*G*has only the identity element. We call this the*classical symmetry*.The set \(\mathbb{D}\) is a countable set, say the natural numbers. The group

*G*consists of all bijections on \(\mathbb{D}\). We call this the*equality symmetry*.The set \(\mathbb{D}=\mathbb{Q}\) is the set of rational numbers, and

*G*is the set of monotone bijections. We call this*total order symmetry*.

### Nominal Set

*C*is a set of data values, we denote by

*G*

_{C}the subgroup If

*X*is a

*G*-set, then a set

*C*is called a

*support*of

*x*∈

*X*if

*x*=

*xπ*for all

*π*∈

*G*

_{C}. In other words, the orbit of

*x*under the action of

*G*

_{C}is a singleton.

### Definition 2.1

Consider a data symmetry \((\mathbb{D},G)\), and a finite set \(C \subseteq \mathbb{D}\) of data values. A nominal set with support *C* is a *G*_{C}-set where every element has some finite support.

*X*and

*Y*be two nominal sets, with support

*C*and

*D*, respectively. A function

*f*:

*X*→

*Y*is called a

*nominal function*if it commutes with the action of

*G*

_{E}for some finite set

*E*. More precisely, there must be a finite set

*E*⊇

*C*∪

*D*such that the following diagram commutes for every

*π*∈

*G*

_{E}

Nominal sets and nominal functions form a category, which is parametrized by the data symmetry \((\mathbb{D},G)\). We say a nominal set is *equivariant* if it has empty support. A nominal function is called equivariant if the set *E* in the definition is empty. In an equivariant function, the domain and codomain must be equivariant sets.

Observe that nominal sets in the classical symmetry are simply sets (equipped with the only possible action), and nominal functions are simply functions. Therefore the classical symmetry corresponds to classical set theory, without data values.

### Nominal Subsets

*X*be a nominal set with support

*C*. A subset

*Y*⊆

*X*is called a

*nominal subset*if there is some finite set of data values

*D*⊇

*C*such that In other words,

*Y*is a nominal set with support

*D*, when the set

*X*is restricted to

*Y*and the action is restricted to

*G*

_{D}.

### Orbit Finite Sets

Let *X* be a nominal set with support *C*. We say that *X* is *orbit-finite with respect to**C* if it has finitely many orbits under the action of *G*_{C}.

### Assumptions on the Data Symmetry

*Least supports*. Every element of a nominal set has a finite support that is least with respect to inclusion. This assumption is very useful in proofs. Intuitively it says that an element of a nominal set can be canonically represented by identifying its least support.*Cartesian products*. Orbit-finite sets are preserved under Cartesian products. The usefulness of this assumption should be clear: it is very difficult to get any work done without pairs and other tuples.*Orbit refinement*. Let*C*⊆*D*be supports of a nominal set*X*. If*X*is orbit-finite with respect to*C*, then it is also orbit-finite with respect to*D*. The reason for this assumption is that it establishes a robust notion of “finite” set, namely the notion of an orbit-finite set, see Lemma 2.2 below.

These assumptions are satisfied by the classical, equality and total order symmetries. This was shown in [3] for least supports and Cartesian products, and in [4] for orbit refinement. For other examples of data symmetries that satisfy these properties, see [3, 4].

An example of a data symmetry that violates all three assumptions is when the data values are integers \(\mathbb{Z}\), and the group consists of translations *x*↦*x*+*y*. The set \(\mathbb{Z}\) of data values itself is a counter-example to all three assumptions. It does not have least supports, since \(0 \in\mathbb{Z}\), or any other number, is supported by every singleton, but not by the empty set. The set \(\mathbb{Z}\) is orbit-finite, since it has just one orbit, but \(\mathbb{Z}\times \mathbb{Z}\) has infinitely many orbits, which are diagonals of the form \(\{(x,y+x) : y \in\mathbb{Z}\}\). Finally, \(\mathbb{Z}\) is orbit-finite with respect to the empty set of data values, but it shatters into singleton orbits with respect to any nonempty set of data values.

As mentioned above, a corollary of orbit refinement is we can simply say that a set is orbit-finite, without saying that it is finite with respect to some *C*, as stated by the following lemma.

### Lemma 2.2

*Let**C*,*D**be supports of a nominal set**X*. *Then**X**is orbit*-*finite with respect to**C**if and only if it is orbit*-*finite with respect to**D*.

### Proof

Suppose that *X* is orbit-finite with respect to *C*. By orbit refinement, it is orbit-finite with respect to *C*∪*D*⊇*C*. Because the group *G*_{C∪D} is a subgroup of *G*_{D}, then orbit-equivalence with respect to *G*_{C∪D} refines orbit-equivalence with respect to *G*_{D}. It follows that *X* is also orbit-finite with respect to *D*. □

### Background

The definition of nominal sets presented above is based on, but not identical to, the one from [3]. The definition used in this paper is slightly more relaxed than the one in [3]; in [3] the category of nominal sets used only equivariant sets and equivariant objects. The difference between the nominal sets from [3] and this paper, and the nominal sets of Gabbay and Pitts [7], is that here and in [3] there is the additional parameter of a data symmetry, while in [7] the data symmetry is always assumed to be the same, namely \(\mathbb{D}\) is the natural numbers and *G* is the set of all permutations of natural numbers.

## 3 Nominal Monoids

Fix a data symmetry \((\mathbb{D},G)\). When talking about nominal sets and functions below, we mean nominal under this symmetry. In the category of nominal sets, there is a natural definition of a monoid:

### Definition 3.1

A *nominal monoid* is a monoid, where the carrier is a nominal set, and the concatenation operation is nominal. If *M*,*N* are nominal monoids, then a nominal monoid morphism *α*:*M*→*N* is a function that is both a nominal function and a monoid morphism.

### Example

*L*

_{dd}, which is in the equality symmetry. We now describe the syntactic monoid of this language, which is illustrated in Fig. 1. The carrier of the monoid is the set The 0 and 1 are not atoms, but the traditional zero and identity elements of a monoid: anything multiplied by 0 is 0, and anything multiplied by 1 is itself. This carrier has empty support. The action of

*G*is natural: it does nothing to the elements 0 and 1, and it renames the coordinates of the pairs in \(\mathbb{D}^{2}\). The carrier has four orbits: two singleton orbits {0} and {1}, an orbit for the diagonal \(\{(d,d) : d \in \mathbb{D}\}\), and an orbit for the co-diagonal \(\{(d,e) : d \neq e \in\mathbb{D}\}\). It is easy to see that every element of the carrier has finite support: the elements 0 and 1 have empty supports, while an element (

*d*,

*e*) has support {

*d*,

*e*}. Finally, multiplication for elements that are not 0 or 1 is defined by This operation is clearly nominal, it has empty support. The language

*L*

_{dd}from the running example is recognized by the monoid morphism defined by The accepting set is {1}. This particular accepting set is simply finite, but for the complement of

*L*

_{dd}we have an orbit-finite, but not finite, accepting set.

The rest of this section is devoted to showing that the properties of monoids as language recognizers work just as well in the nominal setting, including the free monoid and the syntactic monoid.

### 3.1 Free Monoid

*A*be any nominal set, with support

*C*. Define

*A*

^{∗}to be the set of words over

*A*, with support

*C*and the action defined coordinatewise: It is easy to see that

*A*

^{∗}is a nominal set, because the word

*a*

_{1}⋯

*a*

_{n}is supported by the union of supports of its letters

*a*

_{1},…,

*a*

_{n}. (Observe that this would fail for infinite words.) The following lemma shows that

*A*

^{∗}deserves to be called free.

### Lemma 3.2

*Let**M**be a nominal monoid and**A**a nominal set*. *Every nominal function**α*:*A*→*M**can be uniquely extended to a nominal monoid morphism* [*α*]:*A*^{∗}→*M*.

### Proof

*C*is a set of constants that includes all the constants in

*A*,

*α*and

*M*. If the extension [

*α*] is to be a nominal monoid morphism, it needs to satisfy Therefore, if [

*α*] exists, then it is unique. Since every word

*w*∈

*A*

^{∗}has a unique decomposition

*w*=

*a*

_{1}⋯

*a*

_{n}, the above can be seen as the definition of [

*α*]. It remains to check that [

*α*] is a nominal function, that is By definition of the function [

*α*], the left side of the equality becomes: Since the concatenation in

*M*commutes with

*π*, the above becomes Because

*α*is a nominal function, it commutes with

*π*, and therefore the above becomes By definition of [

*α*], the above becomes Finally, by definition of the concatenation operation in

*A*

^{∗}, the above becomes which is what we wanted to prove. □

### Recognition

*α*:

*A*

^{∗}→

*M*is said to

*recognize*a nominal language

*L*⊆

*A*

^{∗}if there is a nominal subset

*F*⊆

*M*such that In this paper, we are mainly interested in the case when

*M*is orbit-finite.

### 3.2 Syntactic Monoid

A *nominal alphabet* is any nominal orbit-finite set.

### Examples of Alphabets

The set \(\mathbb{D}\) of data values.

- The product \(\varSigma\times\mathbb{D}\), where
*Σ*is a finite set and the action is defined by Pairs of data values: \(\mathbb{D}^{2}\).

Unordered pairs of data values: \(\{\{d,e\} : d \neq e \in \mathbb{D}\}\).

Recall that in the definition of a nominal set, Definition 2.1, a nominal set comes with a support

*C*. In the examples above, the support was empty. An example of a set with nonempty support {*d*} is the set of data values with some chosen value*d*being excluded: \(\mathbb{D}- \{d\}\).

*d*}.

### Nominal Language

Consider a nominal alphabet *A*. A *nominal language over**A* is a nominal subset of *A*^{∗}. It is easy to see that any language recognized by a nominal monoid morphism is a nominal language. Using the syntactic morphism, we will also prove the converse in Lemma 3.3.

### Two-Sided Myhill-Nerode Congruence

*L*⊆

*A*

^{∗}, one can define the two-sided Myhill-Nerode equivalence relation ≡

_{L}on

*A*

^{∗}by The

*syntactic monoid*of

*L*is defined to be the set of equivalence classes of

*A*

^{∗}under ≡

_{L}, with concatenation defined by where

*wv*denotes concatenation of words in

*A*

^{∗}. As is well known, the above is a proper definition (it does not depend on the choice of

*w*and

*v*), the resulting concatenation operation is associative, its neutral element is the equivalence class of the empty word, and the function \(w \mapsto[w]_{\equiv_{L}}\) is a monoid morphism, which is denoted by

*α*

_{L}and called the

*syntactic morphism.*The syntactic morphism recognizes

*L*.

### Lemma 3.3

*If**L*⊆*A*^{∗}*is a nominal language*, *then its syntactic monoid is a nominal monoid*, *and the syntactic morphism is a nominal monoid morphism*.

### Proof

The assumption in the lemma is that for some support *D* that contains the support of the alphabet, *L*=*Lπ* holds for all *π*∈*G*_{D}.

*G*

_{D}on the syntactic monoid, which consists of equivalence classes under ≡

_{L}. The action is defined by We first show that this is a correct definition, i.e. it does not depend on the choice of

*w*in the equivalence class. Suppose then that

*w*≡

_{L}

*w*′. We need to show that

*wπ*≡

_{L}

*w*′

*π*. This follows immediately from the definition of ≡

_{L}and the assumption that

*Lπ*=

*L*. It is easy to see that every element of the syntactic monoid has finite support, namely \([w]_{\equiv_{L}}\) is supported by whatever supports

*w*. This shows that the syntactic monoid is a nominal set.

Because the syntactic morphism is \(w \mapsto[w]_{\equiv_{L}}\), the very definition of the action in the syntactic monoid proves that the syntactic morphism is a nominal function. □

The following lemma shows that the syntactic morphism is the “best morphism” for recognizing a language.

### Lemma 3.4

*Consider a nominal language**L*⊆*A*^{∗}. *For every surjective nominal monoid morphism**α*:*A*^{∗}→*M**that recognizes**L*, *there is a unique**β**such that**β*∘*α**is the syntactic morphism*.

### Proof

*α*:

*A*

^{∗}→

*M*is a surjective morphism that recognizes

*L*. Let

*w*,

*w*′∈

*A*

^{∗}be such that

*α*(

*w*)=

*α*(

*w*′). Then for all words

*u*,

*v*∈

*A*

^{∗}, we have and therefore, because membership in

*L*depends only on the image under

*α*, it follows that

*uwv*∈

*L*if and only if

*uw*′

*v*∈

*L*. We have just shown that if

*α*(

*w*)=

*α*(

*w*′), then

*w*≡

_{L}

*w*′. Therefore, it makes sense to define a function which shows that

*α*extends to the syntactic morphism. □

## 4 Logic

In this section, we give a definition of MSO and first-order logics for words in any data symmetry. The definition is abstract, but in the special case of the equality symmetry it specializes to the well known MSO and first-order logics, which access data values via a binary data equality predicate.

Let *A* be an orbit-finite alphabet. Define a relational vocabulary *τ*_{A}, which has one binary relation symbol <, and one *n*-ary relation symbol *R* for every *n*-ary nominal subset *R*⊆*A*^{n}. The vocabulary is infinite.

*w*=

*a*

_{1}⋯

*a*

_{k}∈

*A*

^{∗}can be treated as relational structure \(\underline{w}\) over the vocabulary

*τ*

_{A}. The carrier of the structure is the set {1,…,

*k*} of positions. There relation < is interpreted as the linear order on positions. Finally, a relation

*R*⊆

*A*

^{n}is interpreted in \(\underline{w}\) as the set

When talking about *nominal first-order logic for words over**A*, we refer to first-order logic over the vocabulary *τ*_{A}. A sentence is said to be true in a word *w* if it is true in the structure \(\underline{w}\). Likewise for MSO.

### Example 1

*Σ*is finite. The standard definition of first-order logic for data words has a predicate < for order, a predicate ∼ for equality on the data value, and a unary predicate

*a*(

*x*) for every

*a*∈

*Σ*. We also add a unary predicate

*d*(

*x*) for every \(d \in \mathbb{D}\), which selects positions that carry

*d*as their data value. Call this

*standard first-order logic for words over*

*A*. We show that the predicates of the standard logic are available in the nominal logic. The order < is built in. For the predicate ∼, it comes from the relation

*R*

_{∼}⊆

*A*×

*A*defined by which is nominal. The label predicate

*a*(

*x*) comes from the relation

*R*

_{a}⊆

*A*defined by which is also nominal. It follows that the nominal logic is at least as powerful as the standard logic. We will show in Theorem 4.1 that it actually has the same expressive power, in the case of alphabets of the form \(\varSigma\times\mathbb{D}\).

### Example 2

*A*. A typical language we might study is the set of words where the first letter and the last letter have nonempty intersection: This can be done in our nominal first-order logic for words over

*A*, using the predicate

*R*⊆

*A*×

*A*, which is a nominal subset of

*A*

^{2}.

*L*. A nominal monoid morphism which recognises this language maps a nonempty word to its first last letter: For the empty word we need a special value, call it 1. The nominal monoid in the target of this morphism is therefore

*A*

^{2}∪{1}, with 1 as the identity and the monoid operation defined by It is not difficult to see that we have actually described the syntactic nominal monoid. Indeed, if two words

*w*,

*w*′ disagree on their first or last letter, then one can choose words

*x*,

*y*∈

*A*

^{∗}such that exactly one of the words

*xwy*and

*xw*′

*y*is in the language.

### 4.1 Nominal vs Standard Logic

We now prove the result that was announced in Example 1, namely that nominal and standard first-order logics coincide in the special case of the equality symmetry and alphabets of the form \(\varSigma\times\mathbb{D}\).

### Theorem 4.1

*Consider the equality symmetry*, *and an alphabet*\(A = \varSigma\times \mathbb{D}\), *with**Σ**a finite set*. *Then the standard and nominal first*-*order logics for words over**A**have the same expressive power*.

*R*is definable in standard first-order logic. Toward this end, we use the following lemma.

### Lemma 4.2

*R*

*is a finite boolean combination of relations of the form*:

*Furthermore*,

*the relations of the last type are used only for data values*

*d*

*in the least support of*

*R*.

### Proof

*D*be the least support of the alphabet. Let \(C \subseteq\mathbb{D}\) be the least support of

*R*, this set includes

*D*. By definition of support of a set,

*R*is a union of orbits under the action of the group

*G*

_{C}, i.e. Because orbit-finite sets are closed under Cartesian products, then also

*A*

^{n}is orbit-finite. By the orbit-refinement property,

*A*

^{n}has finitely many orbits under the action of any group with fixed support, in particular under the action of

*G*

_{C}. It follows that

*R*can be described as a finite union To prove the lemma, it is enough to show that for every tuple \(\bar{a} \in A^{n}\) and every finite set of data values

*C*, the set \(\bar{a} G_{C}\) is a finite boolean combination of languages as in the statement of the lemma. Let us inspect the coordinates of the tuple \(\bar{a}\) It is not difficult to show that a tuple belongs to \(\bar{a} G_{C}\) if and only if

For every

*i*∈{1,…,*n*}, the label*b*_{i}is*a*_{i}.For every

*i*∈{1,…,*n*}, if*d*_{i}∈*C*, then*e*_{i}=*d*_{i}.For every

*i*∈{1,…,*n*}, if*d*_{i}∉*C*, then*e*_{i}∉*C*.For every

*i*,*j*∈{1,…,*n*} if*d*_{i}=*d*_{j}then*e*_{i}=*e*_{j}.

Theorem 4.1 follows immediately from the lemma above, because the relations in standard first-order logic for data words can capture the predicates corresponding to the relations in the statement of Lemma 4.2. Observe also that, thanks to the “furthermore” clause in the lemma, if a formula of nominal first-order logic uses only equivariant predicates, then its corresponding formula in standard first-order logic does not need to use the predicates *d*(*x*) for \(d \in\mathbb{D}\).

The same proof as for Theorem 4.1 would work in other symmetries, such as the total order symmetry, except that ∼ would need to be replaced by the ordering on the data values.

## 5 Local Finiteness

A monoid is called *locally finite* if every finitely generated submonoid of *M* is finite. For example, the monoid \(\mathbb{N}\) with addition is not locally finite, because the submonoid generated by {1} is the whole infinite set \(\mathbb{N}\). Below is an example of an infinite but locally finite monoid.

### Example 3

Let *X* be an infinite set. Consider the monoid where elements are subsets of *X*, and the monoid operation is set union. This monoid is infinite. However, any finite set of *n* generators will generate a submonoid of at most 2^{n} elements, hence the monoid is locally finite.

In this section we show that every orbit-finite nominal monoid is locally finite. As we shall see, this implies that most of Green’s theory can be used in orbit-finite monoids.

### Theorem 5.1

*Every orbit*-*finite nominal monoid is locally finite*.

In the proof, we use the following lemma.

### Lemma 5.2

*Let**X**be an orbit*-*finite nominal set*, *and**C**a finite set of data values*. *There are finitely many elements in**X**that are supported by**C*.

### Proof

We assume without loss of generality that *X* has one orbit. Let *D* be the least support of the set *X* itself.

If an element *x*∈*X* is supported by *C*, then its least support (which exists by the least support assumption) is a subset *E*⊆*C*, which must satisfy *D*⊆*E*. There are finitely many subsets of *C*. Therefore, the lemma will follow once we show that for every *E*⊇*D* there are finitely many elements *x*∈*X* whose least support is *E*.

*Y*⊆

*X*of elements with least support

*E*. Because the set

*X*has a single orbit, we know that for every

*x*,

*y*∈

*X*there is some

*π*

_{xy}∈

*G*

_{D}such that

*y*=

*xπ*

_{xy}. In [3] it is shown that and therefore for every

*x*,

*y*∈

*Y*, the function

*π*

_{xy}, when restricted to

*E*, is a permutation of

*E*. Toward a contradiction, suppose that

*Y*is infinite. Because there are finitely many permutations of

*E*, the pigeon-hole principle says that for every

*x*∈

*Y*there must be different elements

*y*≠

*z*∈

*Y*such that

*π*

_{xy}and

*π*

_{xz}induce the same permutation on

*E*. It follows that Therefore, by assumption that

*E*supports

*x*, we get which contradicts our assumption on

*y*,

*z*being different: □

### Proof of Theorem 5.1

*M*be an orbit-finite monoid. Suppose that

*X*⊆

*M*is a finite set of generators, and let

*N*be the submonoid of

*M*generated by

*X*. It is easy to see that if a set of data values

*C*supports

*m*,

*n*∈

*M*and the monoid operation, then it also supports

*mn*: Let

*C*be a finite set that supports every element from

*X*, and which also supports the monoid. By the observation above, the set supports every element of

*N*. The result follows by Lemma 5.2. □

### Aperiodic Monoid

*M*is called

*aperiodic*if We say that a monoid

*M*

*contains a group*if there is some subset

*G*⊆

*M*, such that

*M*restricted to

*G*with the same operation is a group, possibly with the group identity not being the same as the monoid identity. The following lemma shows that for locally finite monoids, containing a non-trivial group is the same as violating aperiodicity.

### Lemma 5.3

*For a locally finite monoid*,

*the following conditions are equivalent*

*M**does not contain a nontrivial subgroup*.*M**is aperiodic*.

### Proof

Suppose first that *M* is aperiodic. We show that there can be no subgroup. For the sake of contradiction, suppose that *G* is a subgroup. Let *g*∈*G* be an element different than the group identity. By aperiodicity, there must be some \(i\in\mathbb{N}\) such that *g*^{i}=*g*^{i+1}, and by multiplying both sides by *g*^{−i}, we get that 1=*g*, where 1 is the identity of *G*.

*M*is not aperiodic, i.e. there is some

*a*such that

*a*

^{i}≠

*a*

^{i+1}holds for all

*i*. By local finiteness, the set \(\{ a^{i}\}_{i \in\mathbb{N}}\) is a finite. It follows that there must be some

*j*such that

*a*

^{i+j}=

*a*

^{i}. In this case the set forms a cyclic group. □

Observe that the two conditions in Lemma 5.3 are not equivalent in all monoids. For instance, the group of integers with addition is aperiodic.

## 6 Local Finiteness for MSO

As an added bonus, we prove a much stronger result than Theorem 5.1. This section is independent from the rest of the paper, and may be skipped by the reader who is only interested in the main result, Theorem 9.1

### Theorem 6.1

*Let**A**be an orbit*-*finite alphabet*, *and let**L*⊆*A*^{∗}*be a language definable in nominal MSO*. *Then the syntactic monoid of**L**is locally finite*.

Theorem 6.1 was stated in the conference paper but not proved. This theorem may come useful in future work. For instance, we might want to develop an algebraic theory of languages recognized by deterministic, or even nondeterministic, finite nominal automata, as defined in [3]. These automata can be simulated in MSO, and therefore Theorem 6.1 says that Green’s theory can be used for them. The rest of this section is devoted to the proof of Theorem 6.1.

### Fiber Bounded Morphism

*f*:

*A*

^{∗}→

*B*

^{∗}is called

*fiber bounded*if for every

*w*∈

*B*

^{∗}, the preimage

*f*

^{−1}(

*w*) is finite. Examples of nominal morphisms that are not fiber bounded include any morphism which maps some letter to the empty word, or the morphism that maps all letters to their first coordinate.

### Language Characterization of MSO

When proving Theorem 6.1, we want to avoid formulas of logic, so that we do not have to talk about free variables and other nuisances. That is why we state below a characterization of MSO that is purely in terms of languages.

### Lemma 6.2

*Languages definable in nominal MSO are included*^{2}*in the smallest class of languages that contains languages recognized by orbit*-*finite nominal monoids*, *is closed under boolean combinations and images under fiber bounded morphisms*.

### Proof of Lemma 6.2

*X*⊆

*Y*for set variables, and replacing every

*k*-ary predicate

*R*by a set version The resulting logic has the same expressive power, and it does not use first-order variables. Next, we show how a formula with free variables can be treated as a language. For a word

*w*∈

*A*

^{∗}and a set of

*X*of positions in

*w*, define

*w*⊗

*X*∈(

*A*×2)

^{∗}by extending the label of each position with a bit, which says if the position belongs to

*X*. The language of a formula

*φ*(

*X*

_{1},…,

*X*

_{n}) is defined as Under this interpretation, we see that the existential set quantifiers (boolean combinations, respectively) on the side of formulas correspond to morphic images (boolean combinations, respectively) on the side of languages. The morphisms are fiber bounded, because they simply remove one 2 component from the alphabet (i.e. the alphabet is halved).

*R*′ of a predicate

*R*. When

*R*is the order predicate on positions, then the monoid is simply finite. When

*R*is obtained from a nominal relation

*R*⊆

*A*

^{k}, we use the following monoid

*M*

_{R}to recognize the language that corresponds to the relation

*R*′. Elements of the monoid are partial functions plus an additional zero element 0. The zero element is used for words where the sets \(X_{i_{1}},\ldots,X_{i_{n}}\) are not singletons. The monoid operation is defined by The monoid identity is the completely undefined partial function. It is easy to see that the monoid is orbit-finite. We now give a monoid morphism which recognizes the predicate

*R*. A word is mapped by

*α*

_{R}to 0 if one of the sets

*X*

_{1},…,

*X*

_{n}contains at least two positions. Otherwise, the word is mapped to the partial function □

### Example 4

*L*as distinct elements, and a special zero element for all other words. The monoid is locally finite, because it satisfies the following property: In particular, for a given set

*X*of generators, the number of elements in the monoid generated by

*X*is bounded by the number of words over

*X*that use each letter at most once.

Consider now the morphism \(f : \mathbb{D}^{*} \to a^{*}\) which replaces all letters by *a*. This morphism is not fiber bounded, because the inverse image of *a* is \(\mathbb{D}\). The image of *L* under *f* is the set of words of prime length. The syntactic monoid of that language is not locally finite, because it is finitely generated by {*a*} and infinite.

We now prove Theorem 6.1. By Lemma 6.2, it is enough to prove that the syntactic monoids of the class of languages in the lemma are locally finite. We first show two operations on monoids that correspond to boolean combinations and fiber bounded morphisms, respectively.

### Monoid Operations

*M*×

*N*. It is easy to see that the Cartesian product of two nominal monoids is also monoid. The second operation is the finite powerset construction, which defines a monoid P

_{fin}(

*M*) based on a monoid

*M*. Elements of P

_{fin}(

*M*) are finite subsets of

*M*. The monoid operation is defined pointwise, by It is easy to see that P

_{fin}(

*M*) is nominal if and only if

*M*is nominal. The following straightforward lemma, which is given without proof, shows that the monoid operations above capture the language operations from Lemma 6.2.

### Lemma 6.3

*Let*

*L*,

*K*

*be languages*,

*recognized by monoids*

*M*,

*N*

*respectively*.

*Any boolean combination of**L**and**K**is recognized by the product**M*×*N*.*Any fiber bounded projection of**L**is recognized by*P_{fin}(*M*).

A corollary of Lemmas 6.2 and 6.3 is that every language definable in MSO is recognized by a monoid from the least class of monoids that contains orbit-finite monoids and is closed under Cartesian products and finite powersets. By Theorem 5.1, all orbit-finite nominal monoids are locally finite. In Lemmas 6.4 and 6.5 below, we show that locally finite monoids are closed under Cartesian products and finite powersets, respectively. It follows that every language definable in MSO is recognized by a locally finite monoid. Finally, by Lemma 6.6 below, and Lemma 3.4, it follows that the syntactic monoid of every language definable in MSO is locally finite.

### Lemma 6.4

*If monoids**M*_{1},*M*_{2}*are locally finite*, *then so is**M*_{1}×*M*_{2}.

### Proof

Let *X* be a finite subset of *M*_{1}×*M*_{2}. For *i*∈{1,2} let *N*_{i} be the submonoid of *M*_{i} generated by the projection of *X* to the *i*-th coordinate. By assumption on *M*_{1},*M*_{2} being locally finite, the submonoids *N*_{1},*N*_{2} are finite. The submonoid generated by *X* in *M*_{1}×*M*_{2} is a subset of *N*_{1}×*N*_{2}, and therefore it is also finite. □

### Lemma 6.5

*If monoid**M**is locally finite*, *then so is*P_{fin}(*M*).

### Proof

Let \(\mathcal{X}\) be a finite set of elements in P_{fin}(*M*). Let *X* be the union \(\bigcup\mathcal{X}\), which is a finite set, because it is a finite union of finite sets. Let *N* be the submonoid of *M* that is generated by *X*. By local finiteness of *M*, the monoid *N* is finite. Let \(\mathcal{N}\) be the submonoid of P_{fin}(*M*) generated by \(\mathcal{X}\). By induction one shows that every element of \(\mathcal{N}\) is a subset of *N*. By finiteness of *N*, there are finitely many elements in \(\mathcal{N}\). □

### Lemma 6.6

*Let**α*:*M*→*N**be a surjective monoid morphism*. *If**M**is locally finite*, *then so is**N*.

### Proof

Let *X* be a finite subset of *N*. Using surjectivity, choose a finite subset *Y* of *M* such that *α*(*Y*)=*X*. By local finiteness of *M*, the monoid generated by *Y* in *M* is finite; and therefore so is its image in *N*, which is the same as the monoid generated by *X* in *N*. □

## 7 Green’s Relations for Nominal Monoids

*M*is a nominal monoid. Using the underlying monoid, one can define Green’s relations on elements

*m*,

*n*∈

*M*.

\(m \le_{\mathcal{L}}n\) if

*Mm*⊆*Mn*\(m \le_{\mathcal{R}}n\) if

*mM*⊆*nM*\(m \le_{\mathcal{J}}n\) if

*MmM*⊆*MnM*

*n*is a

*suffix*of

*m*instead of writing \(m \le_{\mathcal{L}}n\). Likewise for

*prefix*and

*infix*, and the relations \(\le_{\mathcal{R}}\) and \(\le_{\mathcal{J}}\). Finally, we use the name

*extension*for the converse of infix. Like in any monoid, these relations are transitive and reflexive, so one can talk about their induced equivalence relations, which are denoted by \(\mathcal{L}\), \(\mathcal{R}\) and \(\mathcal{J}\). Equivalence classes of these relations are called \(\mathcal{L}\)-classes, \(\mathcal {R}\)-classes and \(\mathcal{J}\)-classes. An \(\mathcal{H}\)-class is defined to be the intersection of an \(\mathcal{L}\)-class and an \(\mathcal{R}\)-class.

It is easy to see that Green’s relations are nominal relations, with their support being the support of the monoid. The following lemma^{3} shows that two key properties of Green’s relations work in all locally finite monoids, which covers the case of orbit-finite nominal monoids thanks to Theorem 5.1.

### Lemma 7.1

*The following properties hold in every locally finite monoid*

*M*.

*If*\(n \ \mathcal{J}\ m\)*and*\(m \le_{\mathcal{R}}n\),*then*\(m\ \mathcal{R}\ n\).*Likewise for*\(\mathcal{L}\).*If**M**is aperiodic*,*then*\(m\ \mathcal{L}\ n\)*and*\(m\ \mathcal {R}\ n\)*imply**m*=*n*.

### Proof

It is well known that the properties above hold in finite monoids.

*x*,

*y*,

*z*∈

*M*such that Consider the submonoid

*N*⊆

*M*that is generated by {

*n*,

*m*,

*x*,

*y*,

*z*}. This monoid is finite by the local finiteness assumption. In the submonoid

*N*, the assumptions \(n\ \mathcal{J}\ m\) and \(m \le_{\mathcal{R}}n\) are also satisfied, and therefore so is the conclusion \(m\ \mathcal{R}\ n\). This means there is some

*x*′∈

*N*with

*n*=

*mx*′. Because

*x*′ belongs also to

*M*, it follows that \(n\ \mathcal{R}\ m\) holds in

*M*.

The same argument works for the second property. □

## 8 First-Order Definable Functions

*A*and

*B*are nominal orbit-finite sets. We will use first-order definable functions as a technical tool in the proof of our characterization of first-order logic. Before defining the notion, we present some examples of functions that will turn out to be first-order definable.

### Example 5

*B*=2 and *f* says if some data value appears twice. More generally, the characteristic function of any first-order definable language is a first-order definable function, see Lemma 8.1.

### Example 6

*B*=*A* and *f* returns the first letter. This is a partial function, because *f* is undefined on the empty word. Unlike in Example 5, the output set is infinite, and therefore *f* cannot be described just by using sentences of first-order logic.

### Example 7

*B* is the family of two element subsets of *A*, and *f* returns the unordered set containing the first and last letters. Again, *f* is a partial function.

In the classical setting, where orbit-finite alphabets are simply finite, the notion of first-order definable function is just syntactic sugar on top of first-order definable languages. This is because a function *f*:*A*^{∗}→*B* can be described as finite set of sentences {*φ*_{b}}_{b∈B}, such that *φ*_{b} defines the language *f*^{−1}(*b*). However, when orbit-finite sets are actually infinite, the ability to return letters and data values becomes important. In Sect. 8.1, we come back to the idea of representing a function as a set {*φ*_{b}}_{b∈B}.

### Definition of First-Order Definable Functions

*Boolean properties*. Suppose that*φ*is a first-order sentence. Then the characteristic function*f*:*A*^{∗}→2 is a first-order definable function.*Letter selection*. Suppose that*φ*(*x*) is a first-order formula with one free variable. Then the function*f*:*A*^{∗}→*A*, which maps a word*w*to the label of the first position selected by*φ*(*x*), is first-order definable. The function*f*is partial, because in some words no position is selected by*φ*(*x*).*Product and case*. If functions*f*:*A*^{∗}→*B*and*f*:*A*^{∗}→*C*are first-order definable, then so are their product and sum The product (*f*,*g*) is defined whenever both*f*and*g*are defined.*Information loss*. If the function*f*:*A*^{∗}→*B*is first-order definable, and*g*:*B*→*C*is any nominal function, then the composition*f*;*g*:*A*^{∗}→*C*is also first-order definable.

It is easy to see that all the examples from the beginning of this section are first-order definable. Consider the function from Example 7. We use the product of two letter selectors to define a function *h*:*A*^{∗}→*A*^{2}, which maps a word to the ordered pair of its first and last letters. Then, we use information loss to forget the order in the pair.

### Lemma 8.1

*A language**L*⊆*A*^{∗}*is first*-*order definable if and only if its characteristic function**f*_{L}:*A*^{∗}→2 *is first*-*order definable*.

### Proof

The left-to-right implication is by definition of first-order definable functions. The right-to-left implication is by substituting formulas of first-order logic. □

### 8.1 Formulas as a Nominal Set

In this section we conjecture that first-order definable functions have a more elegant description than the one presented in the previous section.

Recall that the predicates in nominal first-order logic are obtained from nominal subsets *R*⊆*A*^{n} (except for the order relation). Suppose that the alphabet *A* has support *C*, i.e. one can use *G*_{C} to act on elements of *A*. Extending this action coordinatewise to *A*^{n}, and then pointwise to subsets of *A*^{n}, we can apply any permutation *π*∈*G*_{C} to a nominal relation *R*⊆*A*^{n}, and get a new nominal relation *Rπ*⊆*A*^{n}. We can then extend this action of *G*_{C}, by simple structural induction, to all formulas of nominal first-order logic, so that a permutation *π*∈*G*_{C} maps one formula *φ* to another formula *φπ*. It is easy to see that the set of formulas of nominal first-order logic is also a nominal set, with support *C*. Call this set FO_{A}.

*f*:

*A*

^{∗}→

*B*is first-order definable if and only if there is a set of sentences {

*φ*

_{b}}

_{b∈B}, such that

For every

*b*, the sentence*φ*_{b}defines the language*f*^{−1}(*b*); andThe correspondence

*b*↦*φ*_{b}is a nominal function from*B*to FO_{A}.

## 9 First-Order Logic

In this section we prove the main result of the paper, Theorem 9.1, which is an effective characterization of first-order logic in terms of aperiodic monoids. In the theorem, we talk about the \(\mathcal{J}\)-order, which is the relation \(\le_{\mathcal{J}}\) lifted to \(\mathcal{J}\)-classes.

### Theorem 9.1

*Let**L**be a nominal language*, *and let**M*_{L}*be its syntactic monoid*. *Assume that**M*_{L}*is orbit*-*finite and has a well*-*founded*\(\mathcal{J}\)-*order*. *Then**L**is definable in first*-*order logic if and only if**M*_{L}*is aperiodic*.

Lemma 9.2 shows that the easier implication holds even without the assumptions on orbit-finiteness and well-foundedness.

### Lemma 9.2

*If**L**is definable in first*-*order logic*, *then**M*_{L}*is aperiodic*.

### Proof

This proof is the same as in the classical case, without data values.

*L*is defined by a sentence

*φ*of first-order logic. Let

*i*be a number which is sufficiently large with respect to the quantifier rank of

*φ*. Using an Ehrenfeucht-Fraïssé game, one shows that for every all

*u*,

*w*,

*v*∈

*A*

^{∗},

*w*∈

*A*

^{∗}and sufficiently large

*i*, the words

*w*

^{i}and

*w*

^{i+1}are equivalent under the two-sided Myhill-Nerode equivalence relation. Since the syntactic monoid consists of these equivalence classes, it is aperiodic. □

In Sect. 9.1, we show the more difficult implication: if *M*_{L} is aperiodic then *L* is first-order definable. First, we give examples which illustrate the assumptions in the theorem. Both examples show syntactic monoids where the \(\mathcal {J}\)-order is not well-founded. It could be the case that if a syntactic monoid is aperiodic and has a well-founded \(\mathcal{J}\)-order, then it is orbit-finite. In particular, in Theorem 9.1, it could be that the assumption on orbit-finiteness is not necessary.^{4}

### Example 8

*M*

_{L}of this language is where 0 stands for words outside

*L*, 1 stands for the empty word,

*d*stands for a single-letter word, and (

*d*,

*e*,

*i*) stands for a word that begins with

*d*, ends with

*e*, and its length modulo 2 is

*i*. This monoid is orbit-finite. However, the monoid fails the assumption on the \(\mathcal{J}\)-ordering being well-founded, as witnessed by the following infinite decreasing sequence That is why the implication in the theorem fails: the monoid is aperiodic, but the language

*L*is not definable in first-order logic.

### Example 9

Let *A* be an infinite but orbit-finite alphabet, e.g. \(\mathbb{D}\) in the equality symmetry. Consider the set of words where the number of distinct letters is even. The syntactic monoid of this language is the family of finite subsets of *A*, with union as the monoid operation. The monoid is aperiodic (and therefore a language that talks about parity can have an aperiodic syntactic monoid). However, the monoid is not orbit-finite, because subsets of different sizes are in different orbits. Also, the \(\mathcal{J}\)-order is not well-founded (because the \(\mathcal{J} \)-order is the superset relation, which is not well-founded).^{5}

Observe that in Example 8 we used the total order symmetry, and not the simpler equality symmetry. Indeed, it is impossible to provide an example that uses the equality symmetry, as shown by the following lemma.

### Lemma 9.3

*In the equality symmetry*, *the*\(\mathcal{J}\)-*order is well*-*founded in every orbit*-*finite monoid*.

### Proof

*M*. Suppose that there is an infinite decreasing chain Let

*C*be a support of

*M*. Because the monoid is orbit-finite, there must be some

*i*<

*j*such that

*m*

_{i}is in the same orbit as

*j*, with respect to

*G*

_{C}. We will show that

*m*

_{i}and

*m*

_{j}are in the same \(\mathcal{J}\)-class, contradicting the assumption on the decreasing chain.

*m*

_{j}comes later in the chain than

*m*

_{i}, there must be elements

*x*,

*y*∈

*M*such that Because

*m*

_{i}and

*m*

_{j}are in the same orbit, there must be some

*π*∈

*G*

_{C}such that

*m*

_{i}=

*m*

_{j}

*π*. Choose

*π*so that, as a permutations on data values, it is the identity on all but a finite set of data values. This can be done in the equality symmetry, but not in other symmetries, such as the total order symmetry. By the assumption that the monoid operation is nominal, we see that Apply the above equation to itself

*k*times, yielding Because the permutation

*π*is the identity on almost all data values, then

*π*

^{k}is the identity for some

*k*>0. It follows that which means that

*m*

_{j}=

*xm*

_{i}

*y*is an infix of

*m*

_{i}, and therefore

*m*

_{i}is \(\mathcal{J}\)-equivalent to

*m*

_{j}.

Observe that we have proved a slightly stronger result: if a permutation from *G*_{C} can map one \(\mathcal{J}\)-class to another, then the \(\mathcal{J} \)-classes are either equal or incomparable in the \(\mathcal{J}\)-ordering. □

### 9.1 From Aperiodic to First-Order Definable

In this section we finish the proof of Theorem 9.1, by showing the more difficult implication: if *M*_{L} is aperiodic then *L* is first-order definable. The proof is an induction, which needs a more detailed statement, as presented below.

### Proposition 9.4

*Consider a nominal monoid morphism**α*:*A*^{∗}→*M**into a nominal monoid**M**that is orbit*-*finite and aperiodic*. *Let**X*⊆*M**be a nominal subset that is upward closed under*\(\le_{\mathcal{J}}\). *Then the partial function**α*_{X}, *which is**α**with domain restricted to**X*, *is first*-*order definable*.

Let *C* be a set that supports both *M* and *X*. The proof is by induction on the number of orbits in *X*, under the action of the group *G*_{C}. The base of the induction is when there are zero orbits, in which case the function *α*_{X} is easy to define.

*X*is upward closed under \(\le_{\mathcal{J}}\), then it is a union of \(\mathcal{J}\)-classes. Choose a \(\mathcal{J}\)-class

*J*⊆

*X*that is minimal under the \(\mathcal{J} \)-order, which is possible by the assumption that the \(\mathcal {J}\)-order is well founded. Let

*Y*be the closure of

*J*under the action of

*G*

_{C}, i.e. Because

*X*is supported by

*C*, it follows that

*Y*⊆

*X*. Consider the set

*Z*=

*X*−

*Y*, which is also supported by

*C*. The sets

*X*,

*Y*,

*Z*are illustrated in Fig. 2.

### Lemma 9.5

*The set**Z**is upward closed under*\(\le_{\mathcal{J}}\).

### Proof

*n*∈

*Z*and \(n \le_{\mathcal{J}}m\). Because

*X*is upward closed, it follows that

*m*∈

*X*. Suppose, for the sake of contradiction, that

*m*∉

*Z*. Then

*m*∈

*Y*, and by definition of

*Y*, there must be some

*π*∈

*G*

_{C}such that

*mπ*∈

*J*. Because the order \(\le_{\mathcal{J}}\) has support

*C*, we can multiply both sides of \(n \le_{\mathcal{J}}m\) by

*π*, yielding Because

*n*belongs to

*Z*, and

*Z*is supported by

*C*, it follows that

*nπ*belongs to

*Z*, and therefore

*nπ*cannot belong to

*J*, which is included in

*Y*. This contradicts the assumption that

*mπ*belongs to a minimal \(\mathcal{J}\)-class in

*X*. □

Thanks to Lemma 9.5, we can apply the induction assumption to *Z*, yielding a function *α*_{Z} that is first-order definable. The rest of this section is devoted to extending the function from *Z* to *X*=*Y*∪*Z*

For a word *w*∈*A*^{∗}, we use the name *type of**w* for *α*(*w*). Define *R*_{w} to be the \(\mathcal{R}\)-class of the shortest prefix of *w* with type outside *Z*. Likewise, define *L*_{w} to be the \(\mathcal{L}\)-class of the shortest suffix of *w* whose type is outside *Z*. Both *R*_{w} and *L*_{w} might be undefined, if the appropriate prefixes or suffixes do not exist.

### Lemma 9.6

*The partial function*

*is first*-

*order definable*.

*Its domain is the set of words with type outside*

*Z*.

### Proof

Suppose that a word *w* has type in *Z*. Because the \(\mathcal {J}\)-class of an infix decreases as the infix grows, and because *Z* is upward closed under the \(\mathcal{J}\)-ordering, it follows that all infixes of *w* have type in *Z*. Therefore, *g* is undefined on *w*.

Consider now a word *w* with type outside *Z*. Let *u*_{1} be the longest prefix of *w* with type in *Z*. Let *a*_{1} be the next letter after *u*_{1} in *w*. By choice of *a*_{1}, we have that *R*_{w} is the \(\mathcal{R} \)-class of *u*_{1}*a*_{1}. Likewise, let *u*_{2} be the shortest suffix of *w* with type in *Z*, and let *a*_{2} be the letter that precedes *u*_{2} in *w*. Again, *L*_{w} is the \(\mathcal{L}\)-class of *a*_{2}*u*_{2}.

*w*is outside

*Z*). By composing the function with the monoid operation, and the nominal functions we conclude that the function

*g*itself is first-order definable. □

*R*

_{w}is an \(\mathcal{R}\)-class, and

*L*

_{w}is an \(\mathcal {L}\)-class, and because the monoid

*M*is aperiodic, it follows from the second item of Lemma 7.1 that the intersection

*R*

_{w}∩

*L*

_{w}contains at most one element. This is the only place where we use the assumption that

*M*is aperiodic. Consider the following partial function

*f*:

*A*

^{∗}→

*M*. The partial function

*f*is first-order definable, because first-order definable functions allow a case distinction.

### Lemma 9.7

*If**w**has type in**X*, *then that type is**f*(*w*).

### Proof

Because *X* is partitioned into *Y* and *Z*, we consider two cases.

If *w* has type in *Z*, then the result follows from the definition of *f*.

*w*has type in

*Y*. In this case,

*R*

_{w}and

*L*

_{w}are defined. Let

*u*be the shortest prefix of

*w*with type outside

*Z*, this is the word whose \(\mathcal{R}\)-class is

*R*

_{w}. Because

*u*is a prefix of

*w*, we have Because the type of

*u*is not in

*Z*, then it must be in

*Y*. By the first item of Lemma 7.1, it follows that and therefore the \(\mathcal{R}\)-class of

*w*is

*R*

_{w}. In the same way, we show that the \(\mathcal{L}\)-class of

*w*is

*L*

_{w}. It follows that the intersection

*R*

_{w}∩

*L*

_{w}is nonempty, as it contains the type of

*w*, and therefore

*R*

_{w}∩

*L*

_{w}={

*α*(

*w*)}. □

### Lemma 9.8

*The set of words with type in**Y**is first*-*order definable*.

### Proof

*Y*is

*X*−

*Z*, and we already have a formula for words with type in

*Z*, it suffices to define words with type in

*X*. We will define the complement of

*X*, i.e. the words that have type outside

*X*. Consider the following set

*K*of words Because it is defined in terms of the function

*f*, the set

*K*is a first-order definable language. We claim that a word

*w*has type outside

*X*if and only if it has an infix from

*K*, the latter being a first-order definable property.

For the right-to-left implication, observe that all words in *K* have type outside *X*, and therefore also all words that contain an infix from *K*.

For the left-to-right implication, observe that the complement of *X* is downward closed in the \(\mathcal{J}\)-order, by assumption on *X* being upward closed. Therefore, a word has type outside *X* if and only if it has an infix outside *X*. If we choose the infix to have minimal length, then removing the first or last letter of the infix gives a word in with type in *X*, for which we can use Lemma 9.7. This infix is the word *u* in the definition of *K*. □

We now conclude the proof of the induction step in Proposition 9.4. We need to define the function *α*_{X}. This is the disjoint union of the functions *α*_{Y} and *α*_{Z}. The latter function is defined by induction assumption. The former function is the restriction of *f* to the set of words with type in *Y*, by Lemma 9.7. By Lemma 9.8, this restriction can be done in first-order logic.

## 10 Further Work

### Characterize Other Logics

It is natural to extend the characterization of first-order logic to other logics. Candidates that come to mind include first-order logic with two variables, or various logics inspired by XPath, or piecewise testable languages. Also, it would be interesting to see the expressive power of languages recognized by orbit-finite nominal monoids. This class of languages is incomparable in expressive power to first-order logic, e.g. the first-order definable language “some data value appears twice” is not recognized by an orbit-finite nominal monoid. It would be nice to see a logic, maybe a variant of monadic second-order logic, with the same expressive power as orbit-finite nominal monoids.

### Use Mechanisms More Powerful than Monoids

As language recognizers, orbit-finite nominal monoids are very weak. In most data symmetries, such as the equality and total order symmetries, orbit-finite nominal monoids are strictly less expressive than orbit-finite deterministic automata.^{6} For example, the language “the first letter in the word appears also on some other position”, is recognized by an orbit-finite deterministic automaton, but has a syntactic monoid with infinitely many orbits. Therefore, one can ask: is it decidable if an orbit-finite automaton recognizes a language that can be defined in first-order logic? We conjecture that this problem is decidable, and even that a necessary and sufficient condition is aperiodicity of the syntactic monoid (which need not be orbit-finite).

## Footnotes

- 1.
This is related to Proposition 3 in [9].

- 2.
The inclusion is strict. Consider the language described in Sect. III.A of an unpublished manuscript, http://www.mimuw.edu.pl/~bojan/papers/atomturing.pdf. This is an example of a language that is not definable in nominal MSO (because it is not even recognised by a deterministic Turing machine with atoms, and the machines are more powerful than nominal MSO), but which is an image, under a fiber bounded morphism, of a language definable in nominal MSO (because having an even number of conflicts, as defined in the manuscript, is definable in nominal MSO).

- 3.
As pointed out by one of the anonymous referees, every locally finite monoid is group bound, which implies Lemma 7.1. See e.g. [8].

- 4.
I would like to thank an anonymous reviewer for pointing this out.

- 5.
A previous version of this paper claimed that the monoid has a well-founded \(\mathcal{J}\)-order. This error was pointed out by the anonymous referee. I am not aware of a syntactic monoid that is aperiodic, not orbit-finite, but has a well-founded \(\mathcal{J}\)-order.

- 6.

## Notes

### Acknowledgements

I would like to thank Clemens Ley for introducing me to the subject. I would like to thank Sławomir Lasota and Bartek Klin for many stimulating discussions. Finally, I would also like to thank Michael Kaminski and the anonymous referees for their many helpful comments.

### References

- 1.Benedikt, M., Ley, C., Puppis, G.: Automata vs. logics on data words. In: Dawar, A., Veith, H. (eds.) CSL. Lecture Notes in Computer Science, vol. 6247, pp. 110–124. Springer, Berlin (2010) Google Scholar
- 2.Bojańczyk, M.: Data monoids. In: Schwentick, T., Dürr, C. (eds.) STACS. LIPIcs, vol. 9, pp. 105–116. Schloss Dagstuhl, Leibniz-Zentrum für Informatik, Saarbrücken (2011) Google Scholar
- 3.Bojańczyk, M., Klin, B., Lasota, S.: Automata with group actions. In: LICS, pp. 355–364. IEEE Computer Society, Los Alamitos (2011) Google Scholar
- 4.Bojańczyk, M., Braud, L., Klin, B., Lasota, S.: Towards nominal computation. In: Field, J., Hicks, M. (eds.) POPL, pp. 401–412. ACM, New York (2012) Google Scholar
- 5.Bouyer, P., Petit, A., Thérien, D.: An algebraic approach to data languages and timed languages. Inf. Comput.
**182**(2), 137–162 (2003) MATHCrossRefGoogle Scholar - 6.Francez, N., Kaminski, M.: An algebraic characterization of deterministic regular languages over infinite alphabets. Theor. Comput. Sci.
**306**(1–3), 155–175 (2003) MathSciNetMATHCrossRefGoogle Scholar - 7.Gabbay, M., Pitts, A.M.: A new approach to abstract syntax with variable binding. Form. Asp. Comput.
**13**(3–5), 341–363 (2002) MATHCrossRefGoogle Scholar - 8.Higgins, P.M.: Techniques of Semigroup Theory. Oxford University Press, London (1992) MATHGoogle Scholar
- 9.Kaminski, M., Francez, N.: Finite-memory automata. Theor. Comput. Sci.
**134**(2), 329–363 (1994) MathSciNetMATHCrossRefGoogle Scholar - 10.Luc, S.: Automata and logics for words and trees over an infinite alphabet. In: Ésik, Z. (ed.) CSL. Lecture Notes in Computer Science, vol. 4207, pp. 41–57. Springer, Berlin (2006) Google Scholar
- 11.Montanari, U., Pistore, M.: Finite state verification for the asynchronous pi-calculus. In: Cleaveland, R. (ed.) TACAS. Lecture Notes in Computer Science, vol. 1579, pp. 255–269. Springer, Berlin (1999) Google Scholar
- 12.Montanari, U., Pistore, M.: History-dependent automata: an introduction. In: Bernardo, M., Bogliolo, A. (eds.) SFM. Lecture Notes in Computer Science, vol. 3465, pp. 1–28. Springer, Berlin (2005) Google Scholar
- 13.Straubing, H.: Finite Automata, Formal Languages, and Circuit Complexity. Birkhäuser, Boston (1994) CrossRefGoogle Scholar
- 14.Thomas, W.: Languages, automata, and logic. In: Rozenberg, G., Salomaa, A. (eds.) Handbook of Formal Language Theory, vol. III, pp. 389–455. Springer, Berlin (1997) CrossRefGoogle Scholar

## Copyright information

**Open Access** This article is distributed under the terms of the Creative Commons Attribution License which permits any use, distribution, and reproduction in any medium, provided the original author(s) and the source are credited.