Keywords

1 Introduction

In a recent paper [11], Haase and Różycki considered definability problems in k-Büchi arithmetic, an extension of Presburger arithmetic with a relation \(V_{k}\) such that \(V_{k}(x,y)\) if and only if x is the largest power of k that divides y. They proved that there are relations which are definable in k-Büchi arithmetic (k-definable) and not definable by any existential formula of the corresponding language. By a slight modification of a theorem of Villemaire [24, Corollary 2.4], they show that every k-definable relation can actually be expressed via some \(\exists \forall \)-formula, whereas Villemaire constructs a \(\exists \forall \exists \)-formula.

Büchi arithmetic of base \(k\ge 2\) can be considered as a first-order characterization of the languages, recognizable by finite-state automata over the alphabet \(\left\{ 0,1,...,k-1\right\} ^{n}\) (called k-FA-recognizable). Interpreting the words of this language as tuples \((x_{1},...,x_{n})\) of natural numbers in base k encoding, we obtain the Büchi-Bruyère theorem [3, 5], which states that every relation \(R\subseteq \mathbb {N}^n\) is k-FA-recognizable if and only if it is k-definable. A second-order version of this theorem (which was proved independently by Büchi [5], Elgot [9], and Trakhtenbrot [22]) says that every relation is 2-FA-recognizable iff it is weak monadic second-order (WMSO-)definable in the structure \(\left\langle \mathbb {N};S\right\rangle \), where S is a unary function symbol for the successor function over the natural numbers. The WMSO-theory of \(\left\langle \mathbb {N};S\right\rangle \) is usually denoted by WS1S.

Coming back to the Villemaire’s result, we see that his encoding of k-FA via \(\exists \forall \exists \)-formulas of the language of k-Büchi arithmetic uses a unique bounded universal quantifier. A similar construction often appears in logical descriptions of abstract machines. For example, Klaedtke and Rueß considered in [16] various definability and decidability properties for WMSO-formulas with successor S and cardinality constraints of the form \(|X_{1}|+...+|X_{r}|<|Y_{1}|+...+|Y_{s}|\); the corresponding WMSO-theory of \(\mathbb {N}\) was denoted by WS1S\(^{\text {card}}\). They introduced Parikh automata, an extension of finite automata, and obtained an analogue of Büchi’s Theorem, namely every relation recognizable by a Parikh automaton over the alphabet \(\left\{ 0,1\right\} ^{n}\) is existentially WMSO-definable in \(\mathbb {N}\) with S and cardinality constraints, and vice versa. Here, only second-order variables are existentially quantified, while the formula, which describes a computation of a given Parikh automaton, still contains a universally quantified first-order variable (see [16, Theorem 10], where the universal quantifier \(\forall x\) can be bounded by the maximal element of the existentially quantified second-order variable U).

Note that while WS1S is decidable, WS1S\(^{\text {card}}\) is already undecidable, and its decidable fragments [16, Theorem 16] were obtained as a consequence of decidability of the emptiness problem for Parikh automata. Translating these undecidability results into first-order context, Bès showed [2, Proposition 3.8] in particular that the graph of multiplication function is definable in the structure \(\left\langle \mathbb {N};0,1,+,V_{2}, EqNonZeroBits ,=\right\rangle \), where \( EqNonZeroBits (x,y)\) is true iff x and y have the same number of non-zero bits in their binary representations. This implies undecidability of the first-order theory of this structure, but it is not known, for example, whether the existential first-order theory is decidable. In the concluding section [2], Bès remarks that “it would be interesting to study the expressive power of fragments of FO arithmetic which include predicates like \( EqNonZeroBits \)”. We will further shorten the name of this predicate to \( EqNZB \).

The Davis-Putnam-Robinson theorem (DPR-theorem) [8] was a milestone in the undecidability proof of the Hilbert’s Tenth Problem. This theorem states that every relation \(R\subseteq \mathbb {N}^{n}\) is recursively enumerable (r.e.) if and only if it is existentially first-order definable in the structure \(\left\langle \mathbb {N};0,1,+,\cdot ,exp,=\right\rangle \) (these relations are also called exponential diophantine). As the starting point, the proof uses the result of Davis [7], which states that every r.e. set is \(\exists \forall \exists \)-definable in the structure \(\left\langle \mathbb {N};0,1,+,\cdot ,=\right\rangle \) with one bounded universal quantifier. It is important for us that elimination of this quantifier in the proof of DPR-theorem involves multiplication, factorial, binomial coefficients, and does not seem useful when we try to eliminate bounded universal quantifier in weaker structures. However in 1976, Matiyasevich presented an alternative proof of DPR-theorem [19] by purely existential encoding of computations of Turing machines, which thus gives us another approach for eliminating bounded universal quantifier [20, Section 6.1].

It is easy to modify the final steps of Matiyasevich’s proof in order to obtain an existential formula of the language with 0, 1, addition, bitwise minimum &, and concatenation \(\smallfrown \), where \(t=x\smallfrown y\rightleftharpoons t = x + 2^{l(x)}y\) and l(x) is the bit-length of x. Kummer’s lemma [18] then plays a crucial role, since it gives an exponential diophantine representation of bitwise minimum (see also an exponential diophantine representation of masking relation \(\preccurlyeq \) in [14]). Note that it is not difficult to define & in the structure \(\left\langle \mathbb {N};0,1,+,V_{2},=\right\rangle \) by a formula with one bounded universal quantifier, whereas there is an existential formula that defines \(V_{2}\) in . This suggests the question whether every 2-FA-recognizable relation is existentially first-order definable in .

In Theorem 1, we show that every relation is actually k-FA-recognizable if and only if it is existentially definable in the structure , where corresponds to the binary bitwise minimum operation of base k. The same approach is applied in Theorem 2 to obtain an existential first-order characterization of the languages, recognizable by Parikh automata over the alphabet \(\left\{ 0,1,...,k-1\right\} ^{n}\). In this case, the structure must be extended by the binary predicate \( EqNZB _{k}\), which is true for those pairs of natural numbers (xy) such that x and y have the same number of non-zero bits of base k.

Applying essentially the same ideas as in Theorem 1, we are able to show in Theorem 3 that every relation \(R\subseteq \mathbb {N}^{n}\) is recognizable by multi-counter machines over the alphabet \(\left\{ 0,1,...,k-1\right\} ^{n}\) if and only if it is existentially definable in the structure , where \(z=x\smallfrown _{k} y\rightleftharpoons z = x + k^{l_{k}(x)}y\) and \(l_{k}(x)\) is the bit-length of x in base k. Since such machines recognize exactly r.e. sets, this provides yet another [14, 19, 20] proof of DPR-theorem by purely existential arithmetization of abstract machines.

2 Definitions and the main example

This section recalls some basic definitions from logic and automata theory, which will be used in the sequel. Then we illustrate the main idea of the existential characterisations constructed in Sections 3 and 4.

2.1 Definability and automata

First-order definability. The domain of all the structures considered in this paper will be the set of natural numbers \(\mathbb {N}=\{0,1,2,...\}\), and we will consider existential definability in some extensions of \(\left\langle \mathbb {N};0,1,+,=\right\rangle \).

Denote by \(L_{\sigma }\) the first-order language of some signature \(\sigma \). An \(L_{\sigma }\)-formula \(\varphi \) is existential if it has the form \(\exists \overline{x}\psi (\overline{x},\overline{y})\), where \(\psi (\overline{x},\overline{y})\) is a quantifier-free \(L_{\sigma }\)-formula. Here, \(\overline{x}\) denotes a list of variables \(x_{1},...,x_{n}\). We say that an n-ary relation R over \(\mathbb {N}\) is first-order (FO-)definable in the structure \(\left\langle \mathbb {N}; \sigma \right\rangle \) if there exists an \(L_{\sigma }\)-formula \(\varphi (\overline{x})\) such that for every \(\overline{a}\in \mathbb {N}^{n}\) we have \(R(\overline{a})\) if and only if \(\varphi (\overline{a})\). When the formula \(\varphi (\overline{x})\) is existential, the corresponding relation is called existentially first-order (\(\exists \)FO-)definable, and similarly for the case of quantifier-free formulas, universal formulas and other quantifier prefixes. We will subsequently write the prefix “FO” in the cases where we also discuss second-order definability, and in general it will be omitted.

In this paragraph, we focus on definability in the structure \(\left\langle \mathbb {N};0,1,+,V_{k},=\right\rangle \), where \(k\ge 2\) is an integer, and \(V_{k}\) is a binary relation such that \(V_{k}(x,y)\) if and only if x is the largest power of k dividing y. Büchi arithmetic of base k is the first-order theory of this structure. The relations definable in this structure are called k-definable. Recall that for every multiplicatively independent integer \(l\ge 2\) (i.e., \(k^{a}\ne l^{b}\) for every positive integers ab), \(V_{l}\) is not definable in \(\left\langle \mathbb {N};0,1,+,V_{k},=\right\rangle \) [23, 24] (see also a generalization of this result by Bès [1]). In the following, we consider some fixed base k. Let be the binary bitwise minimum operation of base k, where we assume that the natural number of smaller bit-length is supplemented with a sufficient number of leading zeros. For example, we have . It is not difficult to prove the following lemma.

Lemma 1

Every relation is k-definable if and only if it is definable in the structure .

Proof

In order to define bitwise minimum, for every \(j\in [0..k-1]\) we use the relation \(X_{k,j}(x,y)\), which is defined as “x is a power of k and the coefficient of this power of k in the representation of y in base k equals j”. There is a simple existential formula for this relation in [4, 11, 24]:

$$ X_{k,j}(x,y)\rightleftharpoons V_{k}(x,x)\wedge \exists z\exists t\exists u(y = z + jx + t\wedge z< x \wedge (t=0 \vee (V_{k}(u,t)\wedge x < u))), $$

where \(x < y\rightleftharpoons \exists z(y=x+z+1)\). Therefore, the graph of bitwise minimum can be expressed by a formula with a universal quantifier

figure k

For the converse, by using monus \(z=x-y\rightleftharpoons (z=0\wedge x < y)\vee (x=z+y)\), define the set of powers of k by the formula . Finally, we have .   \(\square \)

We see that \(X_{k,j}(x,y)\) can be defined in by the quantifier-free formula . Let \(\lambda _{k}(x)\) be the greatest power of k less or equal to x when \(x>0\), and \(\lambda _{k}(0)=1\). Formally, we have the definition \(y=\lambda _{k}(x)\Leftrightarrow (x=0\wedge y=1)\vee (P_k(y)\wedge y\le x\wedge x<y)\). Now an analogue of bitwise negation can be defined as follows: . Here, \(\sim _{k} (y,x)\) has the same bit-length as y, and we assume that has a higher precedence than \(+\) or monus. For our purposes, it is useful to include in the signature a binary function symbol for bitwise maximum

figure r

We will write \(\frac{x}{k^n}\) with some fixed natural number n for the function whose graph is quantifier-free definable by the formula \(y=\frac{x}{k^n}\Leftrightarrow k^ny\le x\wedge x<k^n(y+1)\). The function \({\textbf {1}}_{k}(y)\) gives a natural number of the same bit-length with y, but with all k-ary digits equal to one: \(x={\textbf {1}}_{k}(y)\Leftrightarrow (k-1)x=k\lambda _{k}(y)-1\). For notational convenience, let us introduce a binary predicate symbol \(\preccurlyeq _{k}\) such that . The following lemma summarizes these definability results and will be implicitly used in the next sections.

Lemma 2

The predicates \(P_{k}\), \(V_{k}\), \(X_{k,j}\), <, \(\le \) and the graphs of functions −, \(\lambda _{k}\), \(\sim _{k}\), \({\textbf {1}}_{k}\), \(|_{k}\), and \(\frac{\cdot }{k^n}\) for every fixed \(n\ge 1\) are \(\exists \)-definable in the structure .

The existential encoding of k-automata in Subsection 2.2 uses a \(\exists \)-definable function, which echoes a construction that was applied by Matiyasevich [19] in his arithmetization of Turing machines. For every \(a\in [1..k-1]\) the function \(\varTheta _{k,a}(x)\) substitutes 1 for every digit of x equal to a, and 0 otherwise. Then, the graph of this function is defined as follows:

(1)

Note that each digit in the k-ary representation of every quantified variable in (1) is either 0 or 1. Moreover, if we denote then the sum \(x_{1}+...+x_{k-1}\) is exactly \(\bar{{\textbf {1}}}_{k}(x)\). In the case of digit zero, the function \(\varTheta _{k,0}\) has an extra parameter that specifies the number of leading zeros, which must be replaced by ones:

$$\begin{aligned} y=\varTheta _{k,0}(t,x)\Leftrightarrow y={\textbf {1}}_{k}(t)-\bar{{\textbf {1}}}_{k}(x). \end{aligned}$$
(2)

In particular, when \(\lambda _{k}(t) < \lambda _{k}(x)\), we always have \(\varTheta _{k,0}(t,x)=0\) and otherwise we obtain, for example, \(\varTheta _{3,0}(100000, 1020)=110101\).

Remark 1

In Subsection 2.2 and Section 3 it is convenient to write \(\varTheta _{k,a}(t,x)\) instead of \(\varTheta _{k,a}(x)\) when \(a\in \{1,...,k-1\}\). In Section 4 there is no need to consider auxiliary zeros, and we use \(\varTheta _{k,a}\) with a single parameter assuming that \(\varTheta _{k,0}(x)\rightleftharpoons \varTheta _{k,0}(x,x)\).

We conclude this paragraph by defining a set of natural numbers \(\bar{{\textbf {1}}}_{k}(\mathbb {N})=\left\{ \bar{{\textbf {1}}}_{k}(x)\mid x\in \mathbb {N}\right\} \). This definition will be useful in the next paragraph.

Second-order definability. Similarly to Bès [2], let us denote by \(\mathcal {F}\) the set of finite subsets of \(\mathbb {N}\) and also define a function \(cod_{k}:\mathcal {F}^{n}\rightarrow \mathbb {N}^{n}\) which maps every tuple \((X_{1},...,X_{n})\in \mathcal {F}^{n}\) to the tuple of non-negative integers \(cod_{k}(\overline{X})=(\underset{i\in X_{1}}{\sum \limits }k^{i},...,\underset{i\in X_{n}}{\sum \limits }k^{i})\). We see that the image of \(cod_{k}\) is \(\bar{{\textbf {1}}}_{k}(\mathbb {N})\). This function establishes a connection between first-order definability and weak monadic second-order (WMSO-)definability in \(\left\langle \mathbb {N};S\right\rangle \) in the following way.

Recall that WMSO-language \(L_{\sigma }^{ WMSO }\) allows to quantify over finite subsets of the domain, and its signature \(\sigma \) has auxiliary binary predicate symbol \(\in \) for the membership relation \(x\in X\). Again, let the domain of our structures be the set of natural numbers \(\mathbb {N}\). Then a relation \(R\subseteq \mathcal {F}^{n}\) is WMSO-definable in the structure \(\left\langle \mathbb {N};\sigma \right\rangle \) if there exists a \(L_{\sigma }^{ WMSO }\)-formula \(\varphi (X_{1},...,X_{n})\) such that \(R(\overline{A})\Leftrightarrow \varphi (\overline{A})\) for every \(\overline{A}\in \mathcal {F}^{n}\). As was explicitly shown by Villemaire [23, Theorem 3.3], every relation \(R\subseteq \mathcal {F}^{n}\) is WMSO-definable in the structure \(\left\langle \mathbb {N};S\right\rangle \) if and only if \(cod_{2}(R)\) is FO-definable in \(\left\langle \mathbb {N};0,1,+,V_{2},=\right\rangle \).

Note that \(cod_{k}\) is bijective only in the case \(k=2\) when we have \(\bar{{\textbf {1}}}_{2}(\mathbb {N})=\mathbb {N}\). In the case when \(k>2\), we can transfer FO-definability results for extensions of k-Büchi arithmetic to their WMSO-definability analogues using the function \(\overline{cod}_{k}:\mathbb {N}\rightarrow \mathcal {F}^{k-1}\) which maps every \(x\in \mathbb {N}\) to the tuple \(\overline{cod}_{k}(x)=(cod_{k}^{-1}(\varTheta _{k,1}(x)),...,cod_{k}^{-1}(\varTheta _{k,k-1}(x)))\). This function can obviously be extended such that \(\overline{cod}_{k}:\mathbb {N}^{n}\rightarrow \left( \mathcal {F}^{k-1}\right) ^{n}\). We use \(\overline{cod}_{k}\) to establish a relationship between \(\exists \)FO-definability in and \(\exists \)WMSO-definability in \(\left\langle \mathbb {N};S\right\rangle \) extended with cardinality constraints of the form \(|X_{1}|+...+|X_{r}|<|Y_{1}|+...+|Y_{s}|\). Section 3 focuses on the existential definability in these structures and recognizability by Parikh automata [16]. We say that \(R\subseteq \mathcal {F}^{n}\) is existentially (\(\exists \))WMSO-definable in the structure \(\left\langle \mathbb {N};\sigma \right\rangle \) if there exists an \(L_{\sigma }^{ WMSO }\)-formula \(\exists \overline{Y}\varphi (\overline{X},\overline{Y})\), where \(\varphi (\overline{X},\overline{Y})\) may include arbitrary first-order quantifiers, such that for every \(\overline{A}\in \mathcal {F}^{n}\) we have \(R(\overline{A})\) if and only if \(\exists \overline{Y}\varphi (\overline{A},\overline{Y})\).

The following lemma shows that it is sufficient to extend \(\left\langle \mathbb {N};S\right\rangle \) with the relation \( EqCard (X,Y)\rightleftharpoons |X|=|Y|\) to reason about \(\exists \)WMSO-definability in \(\mathbb {N}\) with successor S and cardinality constraints.

Lemma 3

Every cardinality constraint \(|X_{1}|+...+|X_{r}|<|Y_{1}|+...+|Y_{s}|\) is existentially WMSO-definable in the structure \(\left\langle \mathbb {N};S, EqCard \right\rangle \).

Proof

Let us first define the graph of \(\cap \) using a formula with one universal first-order quantifier \(\forall x(x\in Z\Leftrightarrow x\in X\wedge x\in Y)\) (and analogously, the graphs of union \(Z=X\cup Y\) and difference \(Z=X\setminus Y\)) and the empty set \(X=\emptyset \Leftrightarrow \forall x(\lnot x\in X)\).

Now it is not difficult to see that

$$\begin{aligned} \begin{aligned} |X_{1}|+...+|X_{r}|<|Y_{1}|+...&+|Y_{s}|\Leftrightarrow \exists U\exists V\exists X'_{1}...\exists X'_{r}\exists Y'_{1}...\exists Y'_{s}\Big (\Big . \\ \underset{1\le i<j\le r}{\bigwedge }\ X'_{i}\cap X'_{j}=\emptyset&\wedge \underset{1\le i\le r}{\bigwedge } EqCard (X_{i},X'_{i})\wedge \\ \underset{1\le i<j\le s}{\bigwedge }\ Y'_{i}\cap Y'_{j}=\emptyset&\wedge \underset{1\le i\le s}{\bigwedge } EqCard (Y_{i},Y'_{i})\;\wedge \\ \underset{1\le i\le r}{\bigcup }X'_{i}=U&\wedge \underset{1\le i\le s}{\bigcup }Y'_{i}=V\wedge U\cap V = U\wedge \lnot (V\setminus U=\emptyset )\Big .\Big ). \end{aligned} \end{aligned}$$
(3)

   \(\square \)

The following fact is an analogue of Villemaire’s theorem [23]. Note that when \(k=2\) the function \(\overline{cod}_{2}\) is exactly \(cod_{2}^{-1}\).

Proposition 1

  1. (i)

    If a relation \(R\subseteq \mathcal {F}^{n}\) is existentially WMSO-definable in the structure \(\left\langle \mathbb {N};S, EqCard \right\rangle \) then \(cod_{k}(R)\) is existentially FO-definable in .

  2. (ii)

    If a relation \(R\subseteq \mathbb {N}^{n}\) is \(\exists \)FO-definable in then \(\overline{cod}_{k}(R)\) is \(\exists \)WMSO-definable in \(\left\langle \mathbb {N};S, EqCard \right\rangle \).

The proof of this proposition is rather straightforward and follows along similar lines as the proof of Villemaire’s theorem. Only notice that in order to deal with universal FO-quantifiers in (i), we apply Corollary 1 from Subsection 2.2.

Klaedtke and Rueß show in [16] that every relation \(R\subseteq \mathcal {F}^{n}\) is existentially WMSO-definable in the structure \(\left\langle \mathbb {N};S, EqCard \right\rangle \) if and only if it is recognizable by some Parikh automaton over the alphabet \(\{0,1\}\). By reduction to the emptiness problem for Parikh automata, they show that satisfiability of existential WMSO-formulas in the structure \(\left\langle \mathbb {N};S, EqCard \right\rangle \) is decidable. The next paragraph gives the necessary definitions.

Automata languages. Büchi-Bruyère’s theorem [4, 5] states that every relation is first-order definable in the structure \(\left\langle \mathbb {N};0,1,+,V_{k},=\right\rangle \) if and only if it is recognizable by a finite k -automaton. Haase and Różycki [11] prove that this statement is however not true if we consider existential first-order definability in \(\left\langle \mathbb {N};0,1,+,V_{k},=\right\rangle \). We first recall some automata-theoretic definitions and then show that substituting for \(V_{k}\) yields the desired existential description of k-recognizable sets.

Let \(\varSigma \) be some alphabet and \(\varSigma ^{*}\) denote the set of words of finite length over \(\varSigma \) with a unique empty word \(\epsilon \) of length 0. Then a (non-deterministic) finite \(\varSigma \)-automaton (\(\varSigma \)-FA) is a 4-tuple \(\mathcal {A}=(Q,q_{0},F,\delta )\), where \(Q = \{q_{0},...,q_{s}\}\) is a finite set of states with initial state \(q_{0}\) and the set \(F\subseteq Q\) of finial states; \(\delta :Q\times \varSigma \rightarrow 2^{Q}\) is the transition function, where \(2^{Q}\) is the power set of Q. A configuration of \(\mathcal {A}\) is a pair (qx), where \(q\in Q\) is a current state and \(x\in \varSigma ^{*}\) is an unused part of an input word. A transition relation \(\rightarrow \) over configurations of \(\mathcal {A}\) is defined such that \((q,ax)\rightarrow (q',x)\) if and only if \(q'\in \delta (q,a)\). A sequence of transitions between configurations is called a computation of \(\mathcal {A}\). We say that \(x = x_{0}x_{1}\cdots x_{t}\in \varSigma ^{t+1}\) is accepted by a given \(\varSigma \)-FA \(\mathcal {A}\) if there is an accepting computation of \(\mathcal {A}\) for x, that is, a sequence \((q_{0},x_{0}x_{1}...x_{t})\rightarrow (q',x_{1}...x_{t})\rightarrow \cdots \rightarrow (q'',x_{t})\rightarrow (q_{f},\epsilon )\) for some \(q_{f}\in F\). The set of all words \(x\in \varSigma ^{*}\) accepted by \(\varSigma \)-FA \(\mathcal {A}\) defines the language recognizable by this automaton. This language is denoted by \(L(\mathcal {A})\).

A finite k-automaton (k-FA) is defined as a \(\varSigma _{k}^{n}\)-FA, where every letter from \(\varSigma _{k}^{n}\) is an n-tuple of digits from \(\varSigma _{k} = \{0,1,...,k-1\}\). To each language \(L\subseteq (\varSigma _{k}^{n})^{*}\) there corresponds a relation \(R_{L}\) over \(\mathbb {N}^{n}\) in the following way: \(R_{L} = \{\sum _{i=0}^{t}x_{i}k^{i}\,\mid \,x_{0}\cdots x_{t}\in L\}\). An n-ary relation R over \(\mathbb {N}\) is called k -FA-recognizable if there exists a k-FA \(\mathcal {A}\) such that for every \(\overline{a}\in \mathbb {N}^{n}\) we have \(R(\overline{a})\Leftrightarrow R_{L(\mathcal {A})}(\overline{a})\). For technical convenience, the notion of k-recognizability is commonly defined [4, 23, 24] for deterministic k-FA (k-DFA), where for every state q and letter \(a\in \varSigma _{k}^{n}\) it holds that \(|\delta (q,a)|\le 1\). Since \(\varSigma \)-FA and \(\varSigma \)-DFA recognize the same class of languages [17], i.e. the class of regular languages over the alphabet \(\varSigma \), this restriction does not change the class of recognizable relations. In our logical characterization of k-FA-recognizable relations we will not benefit from such restrictions on the transition function.

The definition of \(\varSigma \)-FA can be extended by adjoining to every letter of \(\varSigma \) a vector \(v\in D\), where D is a finite subset of \(\mathbb {N}^{m}\), and imposing certain restrictions on the accepting sequences of transitions to obtain Parikh finite automata (\(\varSigma \)-PFA). That is, for some \(m>0\) and a finite set \(D\subseteq \mathbb {N}^{m}\), a \(\varSigma \)-PFA is a pair \((\mathcal {A},\varphi )\), denoted by \(\mathcal {A}_{\varphi }\), where \(\mathcal {A}\) is a \((\varSigma \times D)\)-FA and \(\varphi (x_{1},...,x_{m})\) is an existential \(L_{\left\langle 0,1,+,=\right\rangle }\)-formula. It is convenient to think of a configuration of \(\varSigma \)-PFA as an \((m+2)\)-tuple \((q,x,y_{1},...,y_{m})\) where the pair (qx) is the same as in the definition of configurations of \(\varSigma \)-FA, and \((y_{1},...,y_{m})\) is a vector from \(\mathbb {N}^m\). A transition relation between two configurations of \(\varSigma \)-PFA \(\mathcal {A}_{\varphi }\) is now defined as follows: \((q,ax,y_{1},...,y_{m})\rightarrow (q',x,y_{1}+d_{1},...,y_{m}+d_{m})\) if and only if \(q'\in \delta (q,a,d_{1},...,d_{m})\). A word \(x = x_{0}x_{1}\cdots x_{t}\in \varSigma ^{t+1}\) is accepted by \(\mathcal {A}_{\varphi }\) if there is a computation \((q_{0},x_{0}x_{1}\cdots x_{t},0,...,0) \rightarrow (q',x_{1}\cdots x_{t},y'_{1},...,y'_{m})\rightarrow \cdots \rightarrow (q'',x_{t},y''_{1},...,y''_{m}) \rightarrow (q_{f},\epsilon ,y_{1},...,y_{m})\) for some \(q_{f}\in F\) and the formula \(\varphi (y_{1},...,y_{m})\) is true. We denote by \(L(\mathcal {A}_{\varphi })\) the language recognizable by \(\varSigma \)-PFA \(\mathcal {A}_{\varphi }\).

In order to deal with definability over the natural numbers, we again consider \(\varSigma _{k}^{n}\)-PFA, which we call a k-Parikh finite automata (k-PFA). The k-PFA-recognizable relations \(R\in \mathbb {N}^{n}\) are defined analogously. The prefixes \(\varSigma \)- and k- will be sometimes omitted when the exact alphabet \(\varSigma \) or value of k is not significant.

The original definition of Parikh automata [16] uses semi-linear sets \(C\subseteq \mathbb {N}^{t}\) instead of existential formulas of Presburger arithmetic, but it is well-known [10] that these definitions of PFA are equivalent. The main result by Klaedtke and Rueß [15, Theorems 12 and 15] states that every relation \(R\subseteq \mathcal {F}^{n}\) is \(\exists \)WMSO-definable in the structure \(\left\langle \mathbb {N};S, EqCard \right\rangle \) if and only if the relation \(cod_{2}^{-1}(R)\) is 2-PFA-recognizable. The “only if” part of this WMSO-characterization follows from the fact that the class of languages recognizable by PFA is closed under union, intersection, left and right quotients [15, Property 4] and that \( EqCard \) with its negation are recognizable by 2-PFA. Since it is easy to construct k-PFA for the predicate \( EqNZB _{k}\) and for its negation, the following proposition can be proved in a similar way.

Proposition 2

If some relation \(R\subseteq \mathbb {N}^{n}\) is existentially FO-definable in the structure then it is k-PFA-recognizable.

Based on Parikh’s theorem [21], Klaedtke and Rueß proved decidability of the emptiness problem for PFA, and thus decidability of the existential WMSO-theory of \(\left\langle \mathbb {N};S, EqCard \right\rangle \). They also proved that the universality problem for Parikh automata is undecidable. In contrast to finite automata, deterministic Parikh automata, where for every \((q,a)\in Q\times \varSigma _{k}^{n}\) there exists at most one pair \((q',\overline{d})\in Q\times D\) such that \(q'\in \delta (q,(a,\overline{d}))\), are less powerful than PFA. The paper by Cadilhac, Finkel and McKenzie [6] provides some explicit examples of languages recognizable by PFA but not by any deterministic PFA. These authors continued the study of other properties of PFA and, in particular, proved undecidability of the regularity property for PFA. This result will be used in Section 3.

2.2 Existential characterization of k-FA-recognizable languages

In this section we illustrate the main idea of the existential characterisation from Section 3. Our aim now is to prove the following theorem.

Theorem 1

For an integer \(k\ge 2\) every relation is k-FA-recognizable if and only if it is existentially definable in the structure .

Proof

Let \(\mathcal {A}=(Q,q_{0},F,\delta )\) be a k-FA. We are going to prove existential definability of the relation \(R_{L(\mathcal {A})}\) in the structure by encoding the existence of an accepting computation of \(\mathcal {A}\) when the input word is the k-ary representation of \(\overline{x}=x_{1},...,x_{n}\). To this end, let us first introduce new variables \(\overline{q}=q_{0},...,q_{s}\) for every state \(q_{i}\in Q\); for a state \(p\in Q\), we denote by \(\nu (p)\) its number from [0..s]. The following restriction on \(\overline{q}\) expresses the fact that at each step of a computation the automaton \(\mathcal {A}\) has a unique state from Q:

(4)

Here t will be another existentially quantified variable that will be a power of k. This variable corresponds to a configuration \((p,\epsilon )\) for some \(p\in F\), and formula (4) also requires that the computation starts in the state \(q_{0}\). It is obvious that t must be greater than \(x_{i}\) for every \(i\in [1..n]\); this restriction will appear in the resulting formula below.

In order to express the fact that each step of a computation is performed in accordance with the transition function \(\delta :Q\times \varSigma _{k}^{n}\rightarrow 2^{Q}\), we introduce a predicate \(\varDelta _{(p,\overline{a})}\). For every pair \((p,\overline{a})\in Q\times \varSigma _{k}^{n}\), we have

(5)

where, by definition, \(\underset{y\in \emptyset }{|_{k}}\,y\,= 0\). From this formula we see that at each step of an accepting computation there are either no configurations with the state p and a word starting with the letter \(\overline{a} = (a_{1},...,a_{n})\), or in the next configuration the state will be from \(\delta (p,\overline{a})\). By combining formulas (4) and (5), we conclude that

$$\begin{aligned} R_{L(\mathcal {A})}(\overline{x})\Leftrightarrow \exists t\exists \overline{q}\Big (P_{k}(t)\wedge \underset{i\in [1..n]}{\bigwedge }\ x_{i} < t\wedge K_{k}(t,\overline{q})\wedge \underset{(p,\overline{a})\in Q\times \varSigma _{k}^{n}}{\bigwedge }\varDelta _{(p,\overline{a})}(t,\overline{q},\overline{x})\Big ). \end{aligned}$$
(6)

It remains to use formulas (1) and (2), Büchi-Bruyère’s theorem and Lemmas 1 and 2.   \(\square \)

Corollary 1

If a relation is definable in the structure then it is existentially definable in this structure.

This result for \(k=2\) can be transferred to the second-order case similarly to Proposition 1. Thus, we obtain a corollary, which was essentially proved by Elgot [9, Theorem 5.3 (b)].

Corollary 2

If a relation \(R\in \mathcal {F}^{n}\) is WMSO-definable in the structure \(\left\langle \mathbb {N};S\right\rangle \) then it is existentially WMSO-definable in this structure.

3 First-order characterization of Parikh automata

The aim of this section is to prove the converse statement to Proposition 2 and thus obtain an existential first-order characterization of Parikh automata languages. Parikh map over the natural numbers can be defined as a function \(\Phi _{k}:\mathbb {N}\rightarrow \mathbb {N}^{k}\) such that \(\Phi _{k}(x)=(\#_{k,0}(x),...,\#_{k,k-1}(x))\), where every function \(\#_{k,i}\) counts the number of occurrences of the digit i in k-ary representation of x. For such counting functions we have the following lemma.

Lemma 4

Let \(R(x_{1},...,x_{n})\) be a relation that is existentially definable in the structure \(\left\langle \mathbb {N};0,1,+,=\right\rangle \), and let \(\overline{a}\) be some vector from \(\{0,...,k-1\}^n\). Then the relation \(R(\#_{k,a_{1}}(x_{1}),...,\#_{k,a_{n}}(x_{n}))\) is \(\exists \)-definable in .

Proof

It is sufficient to define the relations \(\#_{k,a}(x)=d\) for integers \(d\ge 0\) and \(\#_{k,a}(x)+\#_{k,b}(y)=\#_{k,c}(z)\) by some existential formulas. For the first relation we have the formula \( EqNZB _{k}(\varTheta _{k,a}(x), k^{d}-1)\), and for the second one there is the following first-order analogue to formula (3):

figure ae

It remains to use existential definability of the graph of \(\varTheta _{k,i}\) in the structure .

Note that every function \(\#_{k,i}\) can be represented in terms of Subsection 2.1 as \(\#_{k,i}(x)=|cod_{k}^{-1}(\varTheta _{k,i}(x))|\), and thus this lemma can also be proved using Lemma 3 and the first part of Proposition 1.    \(\square \)

Let D be some finite subset of \(\mathbb {N}^{m}\), and let M(D) be the maximum integer occurring in D. The same as Klaedtke and Rueß [16], we encode vectors from D of a given k-Parikh automaton by introducing \(M(D)+1\) new variables \(y_{i,0}\),...,\(y_{i,M(D)}\) for each coordinate \(y_{i}\). For every \(i\in [1..m]\), these variables will be pairwise disjoint (i.e. for \(j_{1}\ne j_{2}\)) and their representation in base k will contain only zeros and ones. For this reason, we use only \(\#_{k,1}\) in our encoding and denote \(\#_{k}\rightleftharpoons \#_{k,1}\).

Theorem 2

For every integer \(k\ge 2\) a relation \(R\subseteq \mathbb {N}^{n}\) is k-PFA-recognizable if and only if it is \(\exists \)-definable in the structure .

Proof

The “if” direction of this theorem is Proposition 2. In the proof of the “only if” direction, suppose we are given a k-Parikh automaton \(\mathcal {A}_{\varphi }\) for some finite set \(D\in \mathbb {N}^{m}\), where \(\mathcal {A}=(Q,q_{0},F,\delta )\) is a FA over the language \(\varSigma _{k}^{n}\times D\) and \(\varphi \) is an existential \(L_{\left\langle 0,1,+,=\right\rangle }\)-formula. We are going to construct an existential -formula \(\psi \) such that \(R_{L(\mathcal {A}_{\varphi })}(\overline{a})\) if and only if \(\psi (\overline{a})\) for every \(\overline{a}\in \mathbb {N}^{n}\). Again, \(\psi (\overline{x})\) will encode the existence of an accepting computation of \(\mathcal {A}_{\varphi }\) when the input word is the k-ary representation of \(\overline{x}\).

The sequence of states from an accepting computation of \(\mathcal {A}\) can be encoded using the predicate \(K_{k}(t,\overline{q})\), defined by the existential -formula (4).

We modify formula (5) so that it works with the alphabet \(\varSigma _{k}^{n}\times D\). To this end, let us introduce \(m(M(D)+1)\) variables \(\overline{y}=y_{1,0}\),...,\(y_{1,M(D)}\),...,\(y_{m,0}\),...,\(y_{m,M(D)}\) such that for every \(i\in [1..m]\) it holds that \(\theta _{k}(t,y_{i,0},...,y_{i,M(D)})\), where

figure ak

Now for every \((p,\overline{a},\overline{d})\in Q\times \varSigma _{k}^{n}\times D\) we have:

figure al

Recall that the expression with bitwise maximums \(|_{k}\) evaluates to zero when \(\delta (p,\overline{a},\overline{d})=\emptyset \).

By combining all the parts of the existential definition of \(R_{L(\mathcal {A}_{\varphi })}\), we get the following analogue to formula (6):

$$\begin{aligned} R_{L(\mathcal {A}_{\varphi })}(\overline{x})\Leftrightarrow \exists t\exists \overline{q}\exists \overline{y}\bigg (P_{k}(t)\wedge \underset{i\in [1..n]}{\bigwedge }\ x_{i} < t&\wedge K_{k}(t,\overline{q})\wedge \\ \underset{i\in [1..m]}{\bigwedge }\theta _{k}(t,y_{i,0},...,y_{i,M(D)})&\wedge \underset{(p,\overline{a},\overline{d})\in Q\times \varSigma _{k}^{n}\times D}{\bigwedge }\varDelta _{(p,\overline{a},\overline{d})}(t,\overline{q},\overline{x},\overline{y})\wedge \\ \varphi \Big (\underset{c\in [1..M(D)]}{\sum }\ {}&c\#_{k}(y_{1,c}),...,\underset{c\in [1..M(D)]}{\sum }c\#_{k}(y_{m,c})\Big )\bigg ). \end{aligned}$$

It remains to apply Lemma 4 to obtain the desired existential formula.    \(\square \)

This result gives us the following statement concerning decidability of fragments of the first-order theory of the structure .

Corollary 3

The existential theory of is decidable and the \(\forall \exists \)-theory of this structure is undecidable.

Proof

The first part of the corollary is just a variation on the automata-theoretic techniques that were formalized by Hodgson [12]. It follows from the decidability of the emptiness problem for PFA. Undecidability of the universality problem, combined with Theorem 2, imply undecidability already for the problem of deciding \(\forall \exists \)-formulas with a single universal quantifier.   \(\square \)

Haase and Różycki [11, Conclusion] ask whether the property of \(\exists \)-definability is decidable for the relations definable in the structure \(\left\langle \mathbb {N};0,1,+,V_{k},=\right\rangle \). Using Theorem 1, this problem can be reformulated so that we consider only existentially definable sets, but now the signatures are different. Namely, the question is whether we can decide if a set \(\exists \)-definable in the structure is \(\exists \)-definable in \(\left\langle \mathbb {N};0,1,+,V_{k},=\right\rangle \). A similar question can be answered in the negative for the structure with and \( EqNZB _{k}\).

Proposition 3

The problem of deciding whether a set existentially definable in the structure is \(\exists \)-definable in is undecidable.

This follows from Theorems 1 and 2, and from undecidability of the regularity property for Parikh automata, which was proved by Cadilhac, Finkel and McKenzie [6, Proposition 7].

Parikh automata are closely related to multi-counter machines (MCM): they recognize exactly the same languages as reversal-bounded MCM [15, Section A.3] (see also [6, Subsection 3.3]). Recall that a MCM is reversal-bounded (the notion was introduced by Ibarra [13]) if there exists a pair of integers (rs) such that in every accepting computation the value of each counter increases and decreases at most r times and the input head reverses at most s times. Theorem 2 now gives an existential first-order characterization of this restricted version of MCM. It is clear that the model of PFA is more suitable for our logical descriptions. However, as we will see in the next section, the behaviour of MCM can be described in a similar way when the structure is extended with concatenation.

4 Multi-counter machines and DPR-theorem

4.1 Two-way multi-counter machines

Same as Ibarra [13], we define a two-way multi-counter machine \(\mathcal {M}\) over an alphabet \(\varSigma \) (\(\varSigma \)-MCM) with two special symbols \(\vdash ,\dashv \) as a tuple \((m,Q,q_{0},F,\delta )\). Here, \(m\ge 0\) is the number of the counters of \(\mathcal {M}\), the triple \((Q,q_{0},F)\) has its standard meaning, and \(\delta \) is a function from \(Q\times \left( \varSigma \cup \{\vdash ,\dashv \}\right) \times \{0,1\}^{m}\) to \(2^{Q\times \{-1,0,1\}^{m+1}}\). Every computation of \(\mathcal {M}\) starts with an input \(x\in \varSigma ^{*}\) written on the tape between the delimiters: \(\vdash x\dashv \), and the input head of \(\mathcal {M}\) reading the left delimiter \(\vdash \). A configuration of \(\mathcal {M}\) on an input \(\vdash x\dashv \) is given by an \((m+3)\)-tuple \((q,\vdash x\dashv ,i,y_{1},...,y_{m})\) denoting the fact that \(\mathcal {M}\) is in state q, the read-only input head scans the i-th symbol of the input, and \(y_{1}\),...,\(y_{m}\) are some non-negative integer values of the counters. The relation \(\rightarrow \) over configurations is defined such that \((q,\vdash x\dashv ,i, y_{1},...,y_{m})\rightarrow (q',\vdash x\dashv ,i+\varDelta , y_{1}+d_{1},...,y_{m}+d_{m})\) if and only if \((q',\varDelta , d_{1},...,d_{m})\in \delta (q,a,[y_{1}>0],...,[y_{m}>0])\), where a is the i-th symbol of the input and \([y > 0]\) returns 1 if \(y > 0\), and 0 otherwise. A natural restriction on \(\delta \) prevents the cases when: (1) \([y_{j}>0]=0\) and \(d_{j} = -1\); (2) \(i=0\) and \(\varDelta = -1\); (3) the i-th symbol of the input is \(\dashv \) and \(\varDelta = 1\).

We say that \(x\in \varSigma ^{*}\) is accepted by a given \(\varSigma \)-MCM if for the input word \(\vdash x\dashv \) there is a computation \((q_{0},\vdash x\dashv ,0,0,...,0)\rightarrow ...\rightarrow (q_{f},\vdash x\dashv ,0,0,...,0)\) for some \(q_{f}\in F\). The set of all the words \( x\in \varSigma ^{*}\) accepted by a \(\varSigma \)-MCM \(\mathcal {M}\) defines the language recognized by this machine, which we denote by \(L(\mathcal {M})\). In order to properly relate \(\varSigma \)-MCM with definability over \(\mathbb {N}\), we again assume that \(\varSigma = \varSigma _{k}^{n}\) for \(k\ge 2\). Every \(x\in \varSigma ^{*}\) is now an element of \(\mathbb {N}^{n}\) in the inverse base k representation. An n-ary relation R over \(\mathbb {N}\) is called k-MCM-recognizable if there exists a \(\varSigma _{k}^{n}\)-MCM \(\mathcal {M}\) such that for every \(\overline{a}\in \mathbb {N}^{n}\) we have \(R(\overline{a})\Leftrightarrow R_{L(\mathcal {M})}(\overline{a})\).

Two-way multi-counter machines can simulate Turing machines (see e.g. [17]), and thus every relation R over \(\mathbb {N}^{n}\) is r.e. iff it is k-MCM-recognizable. The aim of this section is to use the same arguments as in the cases of k-FA and k-PFA in order to obtain an existential characterization of r.e. relations, and Theorem 3 gives us the desired result. The proof will be in some sense intermediate between the arithmetization of Turing machines by Matiyasevich [19] and the encoding of register machines by Jones and Matiyasevich in [14], but here we emphasize the role of concatenation in existential characterizations of multi-counter languages.

4.2 The role of concatenation in DPR-theorem

Matiyasevich’s proof [19] implicitly gives us a description of every r.e. set via \(\exists \)-formulas of the first-order language with 0, 1, addition, bitwise multiplication , concatenation \(\smallfrown _{2}\), and equality. Here, \(t=x\smallfrown _{k} y\rightleftharpoons t = x + k^{l_{k}(x)}y = x + k\lambda _{k}(x)y\), where \(l_{k}(x)\) is the length of x in k-ary notation. This section aims to prove this theorem using the ideas from Subsection 2.2. Informally speaking, the main difference between the case of k-MCM and k-FA is that we now consider bytewise multiplication instead of bitwise from Theorem 1. Suppose a given k-MCM accepts \(\overline{x}\in \varSigma _{k}^{n}\) and let M be the maximum value of all the counters of some accepting computation for \(\overline{x}\). If u is a power of k which is greater than the maximum of \(k^{M}\) and all the \(x_{i}\), then \(l_{k}(u)\) will be the size of the byte in our encoding. Every non-negative integer can be represented as a sequence of bytes of size \(l_{k}(u)\), which will be called u-bytes.

First, we introduce some auxiliary devices, which are required in our construction. Define the predicate \(\varDelta _{k}(u, t, x)\), which is true when u is a power of k greater than \(k^{2}\), the variable x has the same u-byte-length as t and has the following form

$$ x=1\underset{l_{k}(u)}{\underbrace{000...0**}}...\underset{l_{k}(u)}{\underbrace{0..010..0}}...\underset{l_{k}(u)}{\underbrace{000...001}}, $$

where \(*\,*\) is either 10 or 01, and for every two consecutive u-bytes \(b_{1}, b_{2}\) in x the only 1 in \(b_{2}\) is either in the same place or one bit left/right of its position in \(b_{1}\). Moreover, the two most significant bits in every u-byte are equal to zero. We will use this predicate to describe a position of the input head and values of the counters in configurations of a given k-MCM. Before we proceed with the existential definition of this relation, we need to introduce some auxiliary functions. The first one performs the right shift by \(l_{k}(z)\) bits and can be defined via the formula \(y=\frac{x}{z}\Leftrightarrow \exists v\exists u(\lambda _{k}(z)=u\wedge \lambda _{k}(v)\le u\wedge x = u\smallfrown _{k}y-u+v)\). The second function is \( Copy _{k}(u,t,x)\) which maps to zero when \(\lambda _{k}(u)<\lambda _{k}(x)\), and otherwise gives us the sequence of u-bytes of the same u-byte-length as t such that each u-byte is equal to x. The following lemma gives the desired definition, and then we immediately prove existential definability of \(\varDelta _{k}(u, t, x)\).

Lemma 5

The function \( Copy _{k}\) is \(\exists \)-definable in .

Proof

We start with the predicate \( Cpy _{k}(x,y)\) which is true whenever y has the form \(x\smallfrown _{k}...\smallfrown _{k}x\). Its definition is rather standard:

$$ Cpy _{k}(x,y)\Leftrightarrow y=x\vee \exists z(y=x\smallfrown _{k}z\wedge y=z\smallfrown _{k}x). $$

The predicate \(I_{k}(u,x)\Leftrightarrow x = 1\vee \exists y( Cpy _{k}(\lambda _{k}(u), y)\wedge x=ky+1)\) is an another special case of \( Copy _{k}\) which is true when x is a sequence of u-bytes, each of which is equal to 1. Then, the minimum power of k of the same u-byte-length as x can be expressed as \(y=\Lambda _{k}(u,x)\Leftrightarrow \exists v\left( I_{k}(u,v)\wedge v\le x\wedge v\smallfrown _{k}u > x\wedge y=\lambda _{k}(v)\right) \).

It is now clear that

$$\begin{aligned} y= Copy _{k}(u,t,x)\Leftrightarrow \lambda _{k}(u)<\,\lambda _{k}(x)&\wedge y =0\vee \Lambda _{k}(u,y)=\Lambda _{k}(u,t)\;\,\wedge \\ \Big (\lambda _{k}(u)=\,\lambda _{k}(x)&\wedge Cpy _{k}(x,y)\vee \lambda _{k}(u)>\lambda _{k}(x)\wedge \exists y'\exists y''\big ( \\ Cpy _{k}(x+\lambda _{k}(u),y')\wedge Cpy _{k}(\lambda _{k}&(u),y'')\wedge \,\lambda _{k}(y')=\lambda _{k}(y'')\wedge y=y'-y''\big )\Big ). \end{aligned}$$

In this formula, the variables \(y'\) and \(y''\) are introduced in order to supplement every u-byte with a sufficient number of leading zeros.   \(\square \)

Lemma 6

The relation \(\varDelta _{k}\) is \(\exists \)-definable in .

Proof

We are going to prove the correctness of the following definition:

(7)
(8)
(9)
(10)

Conjunction (7) expresses that x is a sequence of the same number of u-bytes as t that starts and ends with the u-byte 000...01, and in every u-byte there can only be zeros and ones. Condition (10) specifies that the two most significant bits in every u-byte of x are equal to zero. Next, the variables \(x_{1},x_{2},x_{3}\) correspond to the right shifts of x one u-byte plus \(D\in \{-1,0,+1\}\). Let us prove that in every u-byte there is a unique 1 and that it has the same position plus \(D\in \{-1,0,+1\}\) compared to the previous u-byte.

From (8), we see that in every u-byte of x there is at least one 1. Indeed, if \(x\ne u\) then the first u-byte of \(x_{1}\), or \(x_{2}\), or \(x_{3}\) must contain 1 (the least significant bit); thus, the second u-byte of x is also non-zero, etc. This 1 in every u-byte is in the desired position since the values , , describe the three cases in which the position in the next u-byte is the same plus \(-1\), 0, \(+1\), respectively.

Now we prove that there are no other non-zero bits in every u-byte of x. Assume for a contradiction that there is a u-byte in x with more than one 1. Then, there are two consecutive u-bytes (which are depicted on the next page) such that the left u-byte has the only 1, and the right one has at least two 1. This pair exists because the most significant u-byte of x equals 1. From the representation of x in (8), we see that the bits a, b, f, g are all equal to zero. Next, since by (9) \(x_{1}\), \(x_{2}\) and \(x_{3}\) are pairwise disjoint, among c, d and e there is only one 1. This contradicts our assumption.

figure ay

It remains to prove that for every u and x such that \(\varDelta _{k}(u, t, x)\) there exist non-negative integers from the definition above. This is obvious for \(z_{1}\) and \(z_{2}\); the existence of \(x_{1}\), \(x_{2}\), \(x_{3}\) follows from the fact that there are at least two zeros between every pair of 1 in x.   \(\square \)

In our proof we check whether or not the u-bytewise minimum of two natural numbers equals zero. In order to express this property, let us introduce a function \(U_{k}\) which modifies x as follows. If x can be split into consecutive u-bytes where the most significant bit is equal to zero, then \(U_{k}(u,x)\) replaces every non-zero u-byte by 1. Otherwise, this function maps to zero. For example, when \(x=10\,000\,011\,000\,010\) we have \(U_{2}(100, x) = 1\,000\,001\,000\,001\) and \(U_{2}(1000, x)=0\).

Lemma 7

The function \(U_{k}\) is \(\exists \)-definable in .

Proof

Let us first define a predicate \(\overline{U_{k}}\), which (in comparison with the function \(U_{k}\)) is also true for the cases when y has u-bytes equal 1 while the corresponding u-bytes of x are equal to zero. In \(\overline{U_{k}}\) there are also no restrictions on the most significant bits of u-bytes. We have the definition

figure ba

The k-ary representation of v is a sequence of u-bytes which are either zero or equal to \(ku-1\); moreover, for every unit in x there is \((k-1)\) in v. Then we select the desired 1 in y via a bitwise multiplication of v by a sequence of u-bytes of the same u-byte-length as x, where all bytes are equal to 1.

In order to exclude extra non-zero u-bytes from y, we consider the difference \(kx-y\). Recall that the definition of \(U_{k}\) requires zeroness of the most significant bit in every u-byte. Thus, we have

(11)

Consider the case when the most significant bits in u-bytes of x are all zero. The least significant bit in every u-byte of kx now equals 0, and the fact that there is a unique y that satisfies the definition can be illustrated as follows:

$$\begin{aligned}&...\underset{l_{k}(u)}{\underbrace{*...*1\qquad \,\,0\,...\qquad \,\,0\qquad \;0\,}}...\underset{l_{k}(u)}{\underbrace{*...*\qquad \,\,0\,}}\quad \,\,\overline{0}\quad \,\;\underset{l_{k}(u)}{\underbrace{\,\,\qquad 0\,...\qquad \,\,0\qquad \,\,0\,}}... \\&...\underset{l_{k}(u)}{\underbrace{0\,...\,0\,0\qquad \,\,0\,...\qquad \,\,0\qquad \;1\,}}...\underset{l_{k}(u)}{\underbrace{0\,...\,0\qquad \,\,1\,}}\quad \,\,\overline{0}\quad \,\;\underset{l_{k}(u)}{\underbrace{\,\,\qquad 0\,...\qquad \,\,0\qquad \,\,1\,}}... \\&...\underset{l_{k}(u)}{\underbrace{*...*0(k-1)...(k-1)(k-1)}}...\underset{l_{k}(u)}{\underbrace{*...*(k-2)}}\,\overline{(k-1)}\,\underset{l_{k}(u)}{\underbrace{(k-1)...(k-1)(k-1)}}... \end{aligned}$$

These three lines represent the numbers kx, y, and \((kx-y)\), respectively. The left column demonstrates the general “correct” case. The middle and the right columns show why the existence of an extra non-zero u-byte in y contradicts definition (11).   \(\square \)

We are now able to prove the main result of this section.

Theorem 3

For every integer \(k\ge 2\) a relation is k-MCM-recognizable if and only if it is \(\exists \)-definable in the structure . Therefore, every relation \(R\subseteq \mathbb {N}^n\) is r.e. iff it is \(\exists \)-definable in this structure.

Proof

For a given k-MCM \(\mathcal {M}=(m,Q,q_{0},F,\delta )\) and an input vector \(\overline{x}\in \mathbb {N}^{n}\) in k-ary notation, we are going to encode the existence of an accepting sequence of transitions between configurations of \(\mathcal {M}\). First choose a variable u such that \(P_{k}(u)\wedge \underset{i\in [1..n]}{\bigwedge }k^{4}x_{i}\le u\); this choice specifies the size of bytes in our encoding. We multiply by \(k^{4}\) since in u-byte there must be two bits for delimiters \(\vdash ,\dashv \) and at least two auxiliary zeros from the definition of \(\varDelta _{k}\).

A sequence of states is encoded similarly to formula (4), that is,

figure bc

where \(\overline{q}=q_{0},...,q_{s}\) and t corresponds to the number of steps of an accepting computation of \(\mathcal {M}\). Here we also require \(q_{0}\) to be the initial state and the most significant u-byte of t corresponds to a final configuration.

We now define a predicate \(C_{\mathcal {M}}\) that encodes a sequence of configurations of \(\mathcal {M}\). Similar to Matiyasevich [19], in this definition for every \(x_{i}\in \overline{x}\) a sequence of copies of \(x_{i}\) is decomposed into disjoint variables \(\theta _{i,0}\),...,\(\theta _{i,k-1}\) such that every u-byte of \(\theta _{i,a}\) equals \(\varTheta _{k,a}(x_{i})\). Let \(\overline{\theta }\) denote the list of variables \(\theta _{1,0},...,\theta _{1,k-1},\theta _{2,0},...,\theta _{n,k-1},\theta _{\vdash },\theta _{\dashv }\), where the extra variables \(\theta _{\vdash }\), \(\theta _{\dashv }\) encode the positions of the delimiters. The variable h stores the positions of the input head of \(\mathcal {M}\), and the list of variables \(\overline{y}=y_{1},...,y_{m}\) corresponds to the values of the counters at each step of computation.

It is convenient to introduce a function \(b_{k}\), which gives the smallest power of k greater than every \(x_{i}\in \overline{x}\). The graph of this function can be defined as

$$ y=b_{k}(\overline{x})\Leftrightarrow \underset{i\in [1..n]}{\bigvee }y=k\lambda _{k}(x_{i})\wedge \underset{i\in [1..n]}{\bigwedge }y\ge k\lambda _{k}(x_{i}). $$

This function will be applied to encode the positions of the right delimiter \(\dashv \). The following formula describes a sequence of configurations of \(\mathcal {M}\).

$$\begin{aligned} C_{\mathcal {M}}(u,t,\overline{q},\overline{x},\overline{\theta },h,\overline{y})\rightleftharpoons P_{k}(&u)\wedge \underset{i\in [1..n]}{\bigwedge }k^{4}x_{i}\le u\wedge u\le t\wedge K_{k}(u,t,\overline{q})\wedge \\ \theta _{\vdash }=\, Copy _{k}(u,t,&1)\wedge \underset{i\in [1..n]}{\bigwedge }\Big (\,\;\theta _{i,0}=\, Copy _{k}(u,t,k\varTheta _{k,0}(x_{i}+b_{k}(\overline{x}))\wedge \\ \underset{a\in [1..k-1]}{\bigwedge }\theta _{i,a}= Copy _{k}(u,t,&k\varTheta _{k,a}(x_{i}))\Big )\wedge \theta _{\dashv }= Copy _{k}(u,t,kb_{k}(\overline{x}))\wedge \\&\qquad \qquad \qquad \varDelta _{k}(u,t,h)\wedge \underset{i\in [1..m]}{\bigwedge }\varDelta _{k}(u,t,y_{i}). \end{aligned}$$

It is easy to see that \(\theta _{\vdash }\), \(\theta _{\dashv }\) are disjoint with the other variables from \(\overline{\theta }\). For notational convenience, we subsequently assume that \(\theta _{i,\vdash }\rightleftharpoons \theta _{\vdash }\) and \(\theta _{i,\dashv }\rightleftharpoons \theta _{\dashv }\) for every \(i\in [1..n]\), and the letters for the delimiters be the vectors \((\vdash ,...,\vdash )\) and \((\dashv ,...,\dashv )\) of length n.

We now proceed to the encoding of the fact that a given sequence of configurations is actually a sequence of transitions in \(\mathcal {M}\). For a letter \((a_{1},...,a_{n})\in \varSigma _{k}^{n}\cup \{\vdash ,\dashv \}\), a state \(p\in Q\), and a tuple \(\overline{c}\in \{0,1\}^{m}\) such that the values of the counters from \(Y_{\overline{c}}=\{i\in [1..m]\,\mid \,c_{i}=0\}\) are equal to zero and from \([1..m]\setminus Y_{\overline{c}}\) are non-zero, the following formula is an analogue to definition (5):

figure bd

The key difference with (5) is that now in order to compare two consecutive configurations we shift by one u-byte instead of one bit. It is obvious that the predicate \(\varDelta _{(p,\overline{a},\overline{c})}\) makes sense when it is complemented with \(C_{\mathcal {M}}\). In this case, for example, highlights the configurations for which in the following configuration the position of the input head shifts by d. Indeed, we obtain a sequence of u-bytes, each of which is equal to one if and only if the position of the unique 1 in the next u-byte is the same plus d, otherwise this u-byte is equal to zero.

It remains to define the relation \(R_{L(\mathcal {M})}\) that corresponds to the language recognizable by \(\mathcal {M}\). To this end, we have to consider every tuple \((p,\overline{a},\overline{c})\) in \(Q\times \left( \varSigma _{k}^{n}\cup \{\vdash ,\dashv \}\right) \times \{0,1\}^{m}\) and apply already defined predicates \(C_{\mathcal {M}}\) and \(\varDelta _{(p,\overline{a},\overline{c})}\).

$$\begin{aligned} R_{L(\mathcal {M})}(\overline{x})\Leftrightarrow \exists u\exists t\exists \overline{q}\exists \overline{\theta }\exists h\exists \overline{y}\Big (&C_{\mathcal {M}}(u,t,\overline{q},\overline{x},\overline{\theta },h,\overline{y})\,\wedge \\&\underset{(p,\overline{a},\overline{c})\in Q\times (\varSigma _{k}^{n}\cup \{\vdash ,\dashv \})\times \{0,1\}^{m}}{\bigwedge }\varDelta _{(p,\overline{a},\overline{c})}(u,t,\overline{q},\overline{\theta },h,\overline{y})\Big ). \end{aligned}$$

This completes the proof.   \(\square \)

Since by [14, 19] the bitwise minimum operation is existentially definable in \(\left\langle \mathbb {N};0,1,+,\cdot ,exp,=\right\rangle \), we obtain DPR-theorem as a corollary.

Corollary 4 (DPR-theorem)

Every relation \(R\subseteq \mathbb {N}^n\) is r.e. if and only if it is \(\exists \)-definable in the structure \(\left\langle \mathbb {N};0,1,+,\cdot ,exp,=\right\rangle \).

Let us fix \(k=2\) and omit mentioning k in \(\smallfrown _{k}\) and \( EqNZB _{k}\). Since we have (see [14]), bitwise minimum is \(\exists \)-definable in \(\left\langle \mathbb {N};0,1,+,\preccurlyeq ,\smallfrown ,=\right\rangle \). Next, exponential diophantiness of \(\preccurlyeq \) follows from the fact that \(x\preccurlyeq y\) iff \(\left( \frac{y}{x}\right) \equiv 1(\text {mod}~2)\), where \(\left( \frac{y}{x}\right) \) is a binomial coefficient. Factorial representation of binomial coefficients and Legendre’s formula imply that

$$ x\preccurlyeq y\Leftrightarrow s_{2}(y)=s_{2}(x)+s_{2}(y-x), $$

where \(s_{2}(x)\) is the number of 1’s in base 2 expansion of x. Therefore, the masking relation is definable by the formula \(x\preccurlyeq y\Leftrightarrow EqNZB (y, x\smallfrown (y-x))\) and we have the following result.

Corollary 5

Every relation \(R\subseteq \mathbb {N}^n\) is r.e. if and only if it is \(\exists \)-definable in the structure \(\left\langle \mathbb {N};0,1,+, EqNZB ,\smallfrown ,=\right\rangle \).

5 Conclusion

The purpose of this paper is to emphasize similarities in existential first-order characterizations of the languages recognizable by various abstract machines. Such descriptions in Sections 3 and 4 allowed us (in some sense) to answer the question of Bès [2, Open Problems] concerning the expressive power of fragments of FO-arithmetic with the predicate \( EqNZB \).

Let us mention one natural question which is related to Theorems 1 and 3. Villemaire proves [23, 24] that multiplication is definable in \(\left\langle \mathbb {N};0,1,+,V_{k},V_{l},=\right\rangle \) when k and l are multiplicatively independent. Bès strengthens this result [1] by showing that the same is true when \(V_{l}\) is replaced by any l-recognizable relation \(R_{l}\) that is not definable in \(\left\langle \mathbb {N};0,1,+,=\right\rangle \). It would be interesting to see whether multiplication is existentially definable in , and more generally, to study \(\exists \)-definability in the structures .