On Presburger arithmetic extended with non-unary counting quantifiers

We consider a first-order logic for the integers with addition. This logic extends classical first-order logic by modulo-counting, threshold-counting and exact-counting quantifiers, all applied to tuples of variables (here, residues are given as terms while moduli and thresholds are given explicitly). Our main result shows that satisfaction for this logic is decidable in two-fold exponential space. If only threshold- and exact-counting quantifiers are allowed, we prove an upper bound of alternating two-fold exponential time with linearly many alternations. This latter result almost matches Berman's exact complexity of first-order logic without counting quantifiers. To obtain these results, we first translate threshold- and exact-counting quantifiers into classical first-order logic in polynomial time (which already proves the second result). To handle the remaining modulo-counting quantifiers for tuples, we first reduce them in doubly exponential time to modulo-counting quantifiers for single elements. For these quantifiers, we provide a quantifier elimination procedure similar to Reddy and Loveland's procedure for first-order logic and analyse the growth of coefficients, constants, and moduli appearing in this process. The bounds obtained this way allow to restrict quantification in the original formula to integers of bounded size which then implies the first result mentioned above. Our logic is incomparable with the logic considered by Chistikov et al. in 2022. They allow more general counting operations in quantifiers, but only unary quantifiers. The move from unary to non-unary quantifiers is non-trivial, since, e.g., the non-unary version of the H\"artig quantifier results in an undecidable theory.


Introduction
Presburger arithmetic is the first-order theory of the structure Z, i.e., the integers with addition, comparison, binary relations ≡ k (standing for equality modulo k) for all k ⩾ 2, and all constants c ∈ Z. Presburger [Pre30] developed a quantifier elimination procedure for • The FO[∃ (t,p) x, ∃ ⩾c x, ∃ =c x]-theory of the integers is decidable in doubly exponential space (here, t stands for a term, p and c for natural numbers, and x for a tuple of variables). • The FO[∃ ⩾c x, ∃ =c x]-theory of the integers can be decided by an alternating Turing machine using doubly exponential time and linearly many alternations. As opposed to the above mentioned result on the unary versions of these quantifiers, we cannot prove that the number of alternations is bounded by the depth of the formula.
Despite the similarity of results, we cannot follow the route of proof used by Chistikov et al. since they start from their handling of the unary Härtig quantifier which cannot be extended to its non-unary version. Differently, we proceed as follows.
(1) In polynomial time, we compute from a formula in the full logic FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x an equivalent formula in the fragment FO ∃ (t,p) x], that is, non-unary threshold-and exact-counting quantifiers can be eliminated in polynomial time. This procedure does not introduce new modulo-counting quantifiers; consequently, from a formula from FO[∃ ⩾c x, ∃ =c x], it computes an equivalent formula from classical first-order logic FO. Since the "block depth" (a notion defined later, it is bounded by the length of the formula) of the resulting formula is linear in the size of the original one, we obtain that the satisfaction relation for FO[∃ ⩾c x, ∃ =c x] is decidable in two-fold exponential alternating time with O(n) many alternations. Note that this is very close to Berman's optimal result for FO where only n alternations are necessary [Ber80]. (2) We provide a quantifier elimination procedure for the logic FO ∃ (t,p) x] and therefore, by the first result, for the full logic FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x . It follows that this full logic agrees in expressive power with classical first-order logic FO. (3) Analysing the size of constants, coefficients, and moduli appearing in this procedure, we can restrict quantification to integers of bounded size. As a result, we get a decision procedure in two-fold exponential space for the full logic FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x . Note Atomic formulas. Expressions of the form s < t (also written t > s) and s ≡ k t for terms s and t and a natural number k ⩾ 1 are called atomic formulas. We extend an assignment f to a function (also denoted f ) that maps atomic formulas to the truth values tt and ff: f (s < t) = tt iff f (s) < f (t) and f (s ≡ k t) = tt iff k divides f (s) − f (t) = f (s − t). Two atomic formulas α and β are equivalent if f (α) = f (β) holds for all assignments f ; we write α ⇔ β for this fact. Let x be a variable. An atomic formula φ is x-separated if there are an x-free term t and a non-negative integer a ∈ N such that φ is of the form ax < t, t < ax, or ax ≡ k t. If t is an x-free term, then, e.g., the formula 0x ≡ k t is x-separated. Since 0 is the normal form of 0x, also the formulas 0 ≡ k t, 0 < t, and t < 0 are considered to be x-separated (despite the fact that it does not mention x at all). It follows that, for any atomic formula α and any variable x, there exists an equivalent x-separated atomic formula.
An atomic formula is constant separated if it is of the form c < s, s < c, or s ≡ k c where s is a constant-free term and c ∈ Z a constant. Again, for any atomic formula α, there exists an equivalent constant separated atomic formula. Formulas. Formulas of classical first-order logic are built from atomic formulas using the quantifier ∃ (applied to single variables) and the Boolean combinators negation, conjunction, implication, and equivalence. We extend this classical logic by quantifiers that allow threshold-(∃ ≥c ) and exact-counting (∃ =c ) as well as modulo counting (∃ (t,p) ), all applied to tuples of variables.
Definition 2.1. Formulas of the logic FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x are defined by induction: (1) Any atomic formula is a formula.
(3) If φ is a formula and y a variable, then ∃y : φ is a formula.
For certain fragments of the logic FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x we use the following naming scheme.
We can further extend an assignment f in the standard way to a function (also denoted f ) that maps formulas to the truth values tt and ff.
Before we define the semantics of quantified formulas, we need the following definitions. For ℓ ⩾ 1, y = (y 1 , . . . , y ℓ ) an ℓ-tuple of distinct variables, and a = (a 1 , . . . , a ℓ ) ∈ Z ℓ , we let f y/a be the assignment that maps the variable y i to the value a i (for all 1 ⩽ i ⩽ ℓ) and, apart from this, coincides with the assignment f . In other words, f y/a (y i ) = a i for all 1 ⩽ i ⩽ ℓ and f y/a (x) = f (x) for all variables x / ∈ {y 1 , . . . , y ℓ }. To define the semantics of the quantifiers, let φ be a formula, t a term, y 1 , . . . , y ℓ distinct variables, p ⩾ 2, and c ⩾ 1. With y = (y 1 , . . . , y ℓ ), we then define the following: • f ∃y 1 : φ = tt iff there exists a ∈ Z such that f y 1 /a (φ) = tt.
• f ∃ (t,p) y : φ = tt iff the set {a ∈ Z ℓ | f y/a (φ) = tt} is finite and In other words, the formula ∃ (t,p) y : φ expresses that the number of witnessing tuples y for φ is (modulo p) congruent to the value of the term t.
In other words, the formula ∃ ⩾c y : φ expresses that the number of witnessing tuples y for φ is at least c (and possibly infinite). With ℓ = 1, ∃ ⩾1 is the usual existential quantifier ∃. This easy observation allows us to consider ∃ as an abbreviation and therefore to skip item (3) in the definition of fragments of the full logic FO Two formulas α and β are equivalent if f (α) = f (β) holds for all assignments f ; we write α ⇔ β for this fact.
Clearly, the formula ∃ =c y : φ is equivalent to ∃ ⩾c y : φ∧¬∃ ⩾c+1 y : φ, i.e., we can eliminate any occurrence of ∃ =c without changing the semantics of a formula. But this elimination may increase the size of the formula exponentially.
Note that f (s < t ∨ s > t) = tt iff f (s) ̸ = f (t) since < is a strict linear order on the set Z. Therefore, we will write s = t as abbreviation of the formula ¬(s < t ∨ s > t). Similarly, s ⩽ t stands for ¬s > t and sequences of comparisons like s 1 ⩽ s 2 ⩽ s 3 denote the conjunction s 1 ⩽ s 2 ∧ s 2 ⩽ s 3 . Similarly, we write ∀x φ as abbreviation for ¬∃x ¬φ.
Note that the quantifier depth depends on the length of tuples of variables that follow a quantifier, i.e., it increases by ℓ whenever we prepend a quantifier ∃ ... (y 1 , . . . , y ℓ ) to a formula. The overall goal of this paper is to obtain an elementary decision procedure for the full logic FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x . As a first step, we will transform a formula α from FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x into an equivalent formula β from FO ∃ (q,p) x], that will later be transformed into an equivalent quantifier-free formula γ. To control the form of the resulting formulas β and γ, we define the following sets.
Then Coeff(φ) ⊆ Z is the set of integers 0, ±1, ±2 and ±a where a is a coefficient in the term s 1 − s 2 for some atomic formula s 1 < s 2 from φ. Similarly, Const(φ) ⊆ Z is the set of integers 0, ±1, ±2, and ±c where c is the constant term in s 1 − s 2 for some atomic formula s 1 < s 2 from φ.

2.
1. An excursion into Presburger arithmetic. Berman proved in [Ber80] that Presburger arithmetic is complete for the class STA( * , 2 2 O(n) , n) of all problems that can be solved by an alternating Turing machine in doubly exponential time with n alternations. Here, we are mainly interested in the proof of the upper bound. He presents this proof in a very sketchy way essentially saying that Ferrante and Rackoff have shown in [FR79] that quantification can be reduced to integers of at most triply exponential size (which can be represented in doubly exponential space). It should be noted that this latter result holds for any formula, no matter whether it is in prenex normal form or it contains the Boolean connective ↔. Berman's result actually means that the algorithm by Ferrante and Rackoff can be implemented on an alternating Turing machine with the above time and alternation bound. Looking into the algorithm from [FR79], one sees that the formula is first transformed into prenex normal form and that then, the alternation of the Turing machine equals the quantifier alternation depth of the resulting formula. Note that turning a formula into prenex normal form is possible in polynomial time whenever the Boolean connectives are restricted to ¬, ∨, ∧, and →. Differently here, we also allow the connective ↔ which gives a convenient way to write certain formulas succinctly. But in the presence of this connective, we do not know how to compute equivalent formulas in prenex normal form in polynomial time.
For later reference, we now sketch a proof that, also in the presence of ↔, Berman's upper bound holds. Since the computation of prenex normal forms is too costly, we need another bound for the alternation. To this aim, we define the block depth of a formula. Intuitively, the block depth bd FO (α) of the formula α ∈ FO bounds the number of blocks of existential quantifiers along any path in the syntax tree of α.
• BD FO 0 is the set of atomic formulas. • For n ⩾ 1, the set BD FO n contains the formulas of the form ∃x 1 ∃x 2 . . . ∃x m : β where m ⩾ 0 and β is a Boolean combination (possibly using ¬, ∧, ∨, →, and ↔) of formulas from BD FO n−1 . • The block depth bd FO (α) of a formula α ∈ FO is the minimal natural number n with α ∈ BD FO n . Note that the block depth of any formula is at most half of its depth (which is the maximal length of a branch in the syntax tree) and therefore half of its length.
With this definition in place, we can now formulate Berman's upper bound for first-order logic in presence of the Boolean connective ↔.
Theorem 2.6. There is an alternating Turing machine that, on input of a closed formula φ ∈ FO, decides in time doubly exponential in |φ| with 2 bd FO (φ) ⩽ |φ| alternations whether φ holds or not.
Proof sketch. The alternating algorithm runs as follows: • If φ is atomic, then validity of the closed formula φ is checked deterministically.

Existential and unary modulo-counting quantifiers suffice
In this section, we will transform a formula from FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x into an equivalent one from FO ∃ (q,p) x]. Note that the logic FO ∃ (t,p) x] is an intermediate logic between these two logics: • In the logic FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x , we can use the non-unary threshold-and exactcounting quantifiers ∃ ⩾c (x 1 , . . . , x ℓ ) and ∃ =c (x 1 , . . . , x ℓ ) while FO ∃ (t,p) x] does not allow threshold-and exact-counting quantification. • FO ∃ (t,p) x] allows non-unary modulo-counting quantifiers ∃ (t,p) (x 1 , . . . , x ℓ ) with t an arbitrary term while FO ∃ (q,p) x] allows only unary modulo-counting quantification of the form ∃ (q,p) x with q ∈ N. We will transform a formula from FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x first into an equivalent formula from FO ∃ (t,p) x], i.e., we will eliminate threshold counting quantifiers. In a second step, the resulting formula from FO ∃ (t,p) x] will be translated into an equivalent one from FO ∃ (q,p) x], i.e., we will eliminate non-unary modulo-counting quantifiers as well as terms as residue. Both these transformations will leave the sets of coefficients, constants, and moduli unchanged; the first transformation will be done in polynomial time while the second one uses doubly exponential time.
3.1. Elimination of threshold-and exact-counting quantifiers. Here, we give the transformation from FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x to FO ∃ (t,p) x]. We will provide a polynomialtime transformation that does not change the sets Coeff, Const, and Mod. In addition, this transformation will not introduce new modulo-counting quantifiers so that formulas from FO[∃ ⩾c x, ∃ =c x] get translated into equivalent formulas φ from first-order logic 2 whose validity can then be checked using Theorem 2.6.
We now come to the translation, i.e., to the elimination of threshold-and exact-counting quantifiers for tuples. First note that the formulas ∃ =c y : φ and ∃ ⩾c y : φ ∧ ¬∃ ⩾c+1 y : φ are clearly equivalent, i.e., semantically, there is no need for the exact-counting quantifier ∃ =c . But applying this replacement to all exact-counting quantifiers in a formula increases the size of the formula exponentially. Similarly, ∃ ⩾c y : φ is equivalent to ∃y 1 ∃y 2 . . . ∃y c : (where (y 1 , y 2 , . . . , y ℓ ) = (y 1 i , . . . , y ℓ i ) abbreviates 1⩽j⩽ℓ y j = y j i ). Since the constant c is written in binary, already the prefix of existential quantifiers is of exponential length, i.e., also this transformation incurs an exponential blow-up in formula size. Finally note that the non-unary quantifiers ∃y and ∀y are equivalent to ∃y 1 ∃y 2 · · · ∃y ℓ and ∀y 1 ∀y 2 · · · ∀y ℓ , respectively.
Thus, we saw that any formula from FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x can be transformed into an equivalent one from FO ∃ (t,p) x] (and similarly for FO[∃ ⩾c x, ∃ =c x] and FO), but at the cost of an exponential size increase. Our first result shows that this size increase can be avoided.
The crucial part in this construction is the elimination of a threshold-or exact-counting quantifier in front of a formula from FO ∃ (t,p) x] or from FO, respectively. This construction adapts a binary search strategy. For instance, the formula ∃ =2c y : y 0 ⩽ y < y 1 ∧ φ(y) expresses that the interval 3 [y 0 , y 1 ) contains precisely 2c many numbers y satisfying φ. This is equivalent to saying that there exists some number y 1 2 in the said interval such that both intervals [y 0 , y 1 2 ) and [y 1 2 , y 1 ) contain precisely c numbers satisfying φ. The constructed formula then contains the conjunction of the two formulas ∃ =c y : y 0 ⩽ y < y 1 2 ∧ φ(y) and ∃ =c y : y 1 2 ⩽ y < y 1 ∧ φ(y) . Therefore, using this binary-search idea alone does not prevent an exponential blow-up. The solution is to replace the conjunction of these two formulas by an expression of the form ∀a, b : (a, b) ∈ {(y 0 , y 1 2 ), (y 1 2 , y 1 )} → ∃ =c y : a ⩽ y < b ∧ φ(y) .
This idea (known as Fischer-Rabin-trick) goes back to [FR74] where it is attributed to earlier work by Fischer and Meyer as well as by Strassen without specifying concrete publications.
A similar idea transforms the formula ∃ =2c+1 y : y 0 ⩽ y < y 1 ∧ φ(y) into ∃y 1 2 : Note that this results in an exponential increase in formula size since the formula φ is mentioned twice. To avoid this size increase, we "postpone" the evaluation of the formula φ(y 1 2 ). Slightly more precisely, the above construction proceeds recursively since in both cases, we have the subformula ∃ =c y : a ⩽ y < b ∧ φ(y) . Along this recursion, we collect in 3 All intervals in this paper are considered as sets of integers or of tuples of integers. some set V all the variables y 1 2 seen in between that are required to satisfy φ. At the very end of the recursion, we write down the formula expressing all the "postponed" requirements at once.
The above idea is based on the linear order on the integers. If we consider the non-unary quantifier ∃ =c y, the role of this linear order ⩽ is played by the lexicographic order on tuples y.
The proof of the following lemma formalises the above ideas. The crucial requirement is that the formula and its block depth shall grow only by a small summand (the latter makes sense only in case the formula φ does not contain any modulo-counting quantifiers, i.e., belongs to FO).
where ℓ is the length of the tuple of variables y and the formula ψ can be computed from α in time |φ| + O(ℓ · log c).
If φ belongs to FO, then also ψ ∈ FO and the block depth of ψ is at most bd FO (φ) + 2⌈log(c)⌉ + 2.
We fix fresh ℓ-tuples of variables z left , z middle , z right , z 1 , z 2 , and z 3 that have no variable in common.
By induction on n ⩾ 0, we will now construct for any finite set V of ℓ-tuples of variables a formula ψ n,V with the following property: Let f be an assignment such that In other words, the interval f (z left ), f (z right ) ⊆ (Z ℓ , ⩽ ℓ lex ) is not empty, but contains none of the values f (v) for v ∈ V . Our construction of the formula ψ n,V will ensure that it holds under such an assignment f , i.e., f (ψ n, In this construction, it will be convenient to write w ∈ V for v∈V v = w, i.e., for the semantical property that f (w) is one of the tuples of integers We start with n = 0 and n = 1: For the induction step, we now construct ψ 2n,V and ψ 2n+1,V with n ⩾ 1. The former is the simpler case: into two subintervals f (z 1 ), f (z 2 ) and f (z 2 ), f (z 3 ) and to verify that both these intervals satisfy the formula ψ n,V , i.e., contain in particular precisely n witnesses for φ.
To also construct ψ 2n+1,V , we need another ℓ-tuple z 2 ′ of fresh variables and set Here, the idea is to divide the interval and to verify that both these intervals satisfy the formula ψ n,V ∪{z 2 ′ } , i.e., contain in particular precisely n witnesses for φ, and that f (z 2 ′ ) satisfies φ. Since I is the disjoint union of the intervals I 1 , {f (z 2 ′ )}, and I 2 , this ensures that the interval I contains precisely 2n + 1 witnesses for φ. Then the formula ∃z left , z right : (z left < ℓ lex z right ∧ ψ c,∅ is equivalent to ∃ ⩾c x : φ since it expresses that some interval contains precisely c witnesses for φ. Furthermore, the formula ∅ is equivalent to ∃ =c x : φ since it expresses that for some interval, any superinterval contains precisely c witnesses for φ.
It remains to analyse the size of the resulting formula as well as the block depth in case φ ∈ FO.
To estimate the size of ψ c,∅ , note the following: • The size of the formulas ψ 0,V and ψ 1,V is of the form |φ| + O ℓ · log(c) since we allow the Boolean connective ↔ in our formulas and since the size of V is bounded by ⌈log(c)⌉ (the formula size doubles if we consider ↔ as abbreviation). • The size increase when moving from ψ n,V to ψ 2n,V is bounded by a summand of size O(ℓ) and the same applies to the construction of ψ 2n+1,V from ψ n,V ∪{z 2 ′ } .
It follows that |ψ c,∅ | ⩽ |φ| + κ · ℓ · log(c) for some constant κ. One sees easily that the same holds for the formula ψ and that it can be constructed in time |φ| + O ℓ · log(c) . Now suppose φ ∈ FO. Since in the construction, we only introduce classical existential quantifiers, we obtain ψ c,∅ ∈ FO. We want to analyse the block depth of ψ c,∅ . First note that In the final step, the block depth increases by at most 2. Hence we obtain bd FO The above lemma can be applied iteratively to all threshold-and exact-counting quantifiers. Hence, from a formula from FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x , we obtain an equivalent formula in FO ∃ (t,p) x], and from a formula from FO[∃ ⩾c x, ∃ =c x], we obtain a formula from FO. In order to bound the block depth of this formula from FO, we extend its definition to formulas from FO[∃ ⩾c x, ∃ =c x] as follows: • BD 0 is the set of atomic formulas.
• For n ⩾ 1, the set BD n contains the formulas of the following forms: -∃x 1 ∃x 2 . . . ∃x m : β where m ⩾ 0 and β is a Boolean combination (possibly using ¬, ∧, ∨, →, and ↔) of formulas from BD n−1 -∃ ⩾c x : β or ∃ =c x : β where β is a Boolean combination of formulas from BD n−2⌈log 2 c⌉−2 • The block depth bd(α) of a formula α ∈ FO[∃ ⩾c x, ∃ =c x] is the minimal natural number n with α ∈ BD n .
Note that the block depth of a formula from FO[∃ ⩾c x, ∃ =c x] is at most twice the length of the formula (since the constants c in ∃ ⩾c and ∃ =c are written in binary). Furthermore, if α ∈ FO, then bd FO (α) = bd(α).
In addition, we have , then the resulting formula ψ belongs to FO and the block depth bd(ψ) of ψ equals that of φ.
Then the formula φ n belongs to FO. Furthermore, when moving from φ i to φ i+1 , the block depth does not increase. From Berman's upper bound for Presburger arithmetic, we get immediately the following for the logic FO[∃ ⩾c x, ∃ =c x], i.e., the fragment of FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x without modulocounting quantifiers.
Corollary 3.4. Satisfaction of a closed formula φ ∈ FO[∃ ⩾c x, ∃ =c x] can be decided in doubly exponential alternating time with linearly many alternations.
Proof. The transformation of φ into an equivalent closed formula ψ from FO increases the size of the formula only polynomially and the resulting block depth belongs to O(|φ|). Hence the claim follows from Berman's Theorem 2.6.
Somewhat surprisingly, the above result says that adding the quantifiers ∃ ⩾c x and ∃ =c x does not increase the complexity of the decision procedure; for the unary version of the above logic, i.e., for FO[∃ ⩾c x, ∃ =c x], this was already observed in [CHM22].
3.2. Elimination of non-unary modulo-counting quantifiers. Here, we give the transformation from FO ∃ (t,p) x] to FO ∃ (q,p) x]. We will provide a transformation that can be computed in doubly exponential time and does not change the sets Coeff, Const, and Mod, nor the quantifier depth.
The crucial task in this section is to express a non-unary quantification ∃ (t,p) (y 1 , . . . , y ℓ ) (where the remainder is given as a term t) using only unary modulo-counting quantifications where the remainder is given as a constant. The first step is obvious: Using a case distinction, we replace ∃ (t,p) y : φ by the disjunction of all formulas t ≡ p r ∧ ∃ (r,p) y : φ for 0 ⩽ r < p. As a second step, one has to eliminate the quantification over a tuple y. We explain the basic idea using the formula ∃ (0,2) (y 1 , y 2 ) : ρ(y 1 , y 2 ) where ρ is some formula and R is the set of pairs of integers satisfying ρ. We have to express that R is finite and its number of elements is even.
Assuming R to be finite, its size is even iff the number of elements y 1 with y 2 (y 1 , y 2 ) ∈ R odd is even. This can be expressed by the formula Further, R is finite iff its number of elements is even or odd. But this would not eliminate the non-unary quantification. Alternatively, R is finite iff it is bounded, i.e., if ∃z ∀y 1 ∀y 2 ρ(y 1 , y 2 ) → |y 1 |, |y 2 | ⩽ z holds. Although being a simple formula, its quantifier rank is larger than that of the formula we started with. Yet another characterisation of finiteness of R is "only finitely many elements can be extended to a tuple from R and no element can be extended in infinitely many ways". The following formula expresses precisely this: ∃ (0,2) y 1 ∃y 2 : ρ(y 1 , y 2 ) ∨ ∃ (1,2) y 1 ∃y 2 : ρ(y 1 , y 2 ) ∧∀y 1 ∃ (0,2) y 2 : ρ(y 1 , y 2 ) ∨ ∃ (1,2) y 2 : ρ(y 1 , y 2 ) 4:14

P. Habermehl and D. Kuske
Vol. 19:3 The proof of the following lemma formalises this idea (and extends it to other moduli and remainder given as terms). In other words, it shows how to eliminate a single non-unary modulo-counting quantifier.
Note that the modulus p is given in binary. Hence the time bound is doubly exponential in the size of the formula α.
Proof. First suppose ℓ = 1 and consider the formula which is clearly equivalent to α and has all the properties required by the claim of the lemma.
It remains to bound the time needed to construct the formula ψ. First, η 0 can be constructed in time O(ℓ·p·|α|) since the formula η n+1 appears only once in η n . Next, any of the formulas δ d ℓ−1 can be constructed in time O(|α|). We now consider the construction of δ d n from the formulas δ i n+1 . Note that the tuple (d 1 , . . . , d p−2 ) together with equation (3.1) completely determines the value of d p−1 ∈ {0, . . . , p − 1}. Hence the disjunction ( * ) extends over at most p p−2 tuples. Consequently, the formula δ d n contains at most p p−2 · (p − 1) ⩽ p p−1 many subformulas δ i n+1 . By induction, we obtain that δ r 0 can be constructed in time O p (p−1)·ℓ ·|α| . Since the construction of ψ requires this to be done for all r ∈ {0, 1, . . . , p−1} and furthermore r ≡ p t has to be added, the formula ψ can be constructed in time O p · log(p) · p (p−1)·ℓ · |α| which is in O p p·ℓ · |α| as ℓ > 1.
The above lemma allows to reduce the number of non-unary modulo-counting quantifiers by one, hence an inductive application eliminates all of them. The algorithmic cost and the form of the resulting formula is analysed in the following proof.
Proof. Let P be the maximal value such that some modulo-counting quantifier ∃ (t,P ) appears in the formula φ and let L be the maximal arity of any modulo-counting quantifier in φ. Finally, let n be the number of non-unary modulo-counting quantifiers in φ. Let φ 0 = φ. To inductively construct φ i+1 from φ i , we chose some subformula ∃ (t,p) (y 1 , . . . , y ℓ ) : α with ℓ > 1 and α ∈ FO ∃ (q,p) x]. This subformula is replaced by an equivalent formula from FO ∃ (q,p) x] that we obtain from Lemma 3.5. This reduces the number of non-unary modulo-counting quantifiers by one so that γ := φ n is a formula from FO ∃ (q,p) x].
Also from Lemma 3.5, we get that φ i+1 can be constructed from φ i in time O(P P ·L · |φ i |) and is therefore of size at most O(P P ·L · |φ i |). Consequently, γ can be constructed from φ 0 in time O( P P ·L n · |φ|). Since the binary encoding of P appears in φ, we get P ⩽ 2 |φ| . Furthermore, L, n ⩽ |φ|. Consequently, the construction of γ from φ can be carried out in doubly exponential time.
The above two Propositions 3.3 and 3.6 imply the following.
In addition, the quantifier depth qd(γ) is polynomial in the size of φ.
Proof. Using Proposition 3.3, one first constructs in polynomial time an equivalent formula ψ from FO ∃ (t,p) x]. This formula is then, using Proposition 3.6, translated into an equivalent formula γ from FO ∃ (q,p) x].
Since |ψ| is polynomial in the size of φ, its quantifier depth is also polynomial in |φ|. Hence, the same holds for the quantifier depth of γ.

Quantifier elimination
This section provides a quantifier elimination procedure for the logic FO ∃ (q,p) x] where, differently from the full logic FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x , only unary quantifications ∃y and ∃ (q,p) y with q ∈ N are allowed.
As usual with quantifier elimination procedures, we first demonstrate how to eliminate a single quantifier in front of a Boolean combination of atomic formulas. Since the classical existential quantifier and the modulo-counting quantifier behave rather differently, we handle them in separate Lemmas 4.2 and 4.3. The main point in both these lemmas is (a) properties of the form ∃/∃ (q,p) x : β where β is quantifier-free can be expressed without quantification and (b) the sets of coefficients, constants, and moduli vary in this process, but these sets can be controlled. Our quantifier elimination is effective, but we do not concentrate on this fact. We do, in particular, not aim at a fast elimination algorithm nor at small resulting formulas. All we need for our later decision procedure is a bound on the size of the coefficients, constants, and moduli appearing in the resulting formula.
For this bound, suppose β is a quantifier-free formula and E is a quantifier ∃ or ∃ (q,p) . We will prove that Ex : β is equivalent to some quantifier-free formula γ whose sets of coefficients etc. are contained in the following sets (with p = 1 in case E = ∃): a 1 a 2 − a 3 a 4 a 1 , a 2 , a 3 , a 4 ∈ Coeff(β) Mod p (β) = a 1 a 2 k 1 k 2 a 1 a 2 ∈ Coeff(β), k 1 , k 2 ∈ Mod(β) ∪ {p} Note that the first set does not depend on the number p and that Const p (β) ⊆ Const p 1 (β) for all 1 ⩽ p < p 1 . Using these sets, we formulate the following condition on the triple (β, γ, p) where β and γ are formulas and p ⩾ 1 is a positive integer: Let β be a quantifier-free formula and x = t an equation (with t an x-free term). Write β ′ for the formula obtained from β by replacing all occurrences of x by t so that β ′ is a Boolean combination of x-free atomic formulas. Then the formulas x = t ∧ β and x = t ∧ β ′ are equivalent. The following lemma, whose statement will be used repeatedly, demonstrates the analogous fact for equations of the form ax = t (with a ̸ = 0), i.e., constructs an x-free quantifier-free formula β ′ so that ax = t ∧ β and ax = t ∧ β ′ are equivalent. The main point here is that, under a specific condition on a, t, and c, the triple (β, β ′ , p) satisfies the above Condition (4.1).
Lemma 4.1. Let β be a Boolean combination of x-separated atomic formulas, ax < t or t < ax some atomic formula from β with a > 0, p ⩾ 1 a positive integer, and c ∈ Z with |c| ⩽ a · p · lcm Mod(β). There exists a Boolean combination β a,t+c of x-free atomic formulas such that the triple (β, β a,t+c , p) satisfies Condition (4.1) and, for all assignments f ,

Note that in particular
Proof. The formula β a,t+c is obtained from β by the following replacements (where s is some x-free term, a ′ ⩾ 0, and k ⩾ 2): a ′ x < s is replaced by a ′ t + a ′ c < as s < a ′ x is replaced by as < a ′ t + a ′ c a ′ x ≡ k s is replaced by a ′ t + a ′ c ≡ ak as Let f be some assignment with f (ax) = f (t + c). Then we have and similarly f (s < a ′ x) = f (as < a ′ t + a ′ c) as well as This completes the proof that f (ax) = f (t + c) implies f (β) = f (β a,t+c ). It remains to verify Condition (4.1). First note that a ∈ Coeff(β) since ax < t or ax > t appears in β and since t is x-free.
Then there exists some atomic formula a ′ x < s or s < a ′ x in β such that b is some coefficient in the term as − a ′ (t + c). Consequently, there exists a variable y with coefficient a 2 in s and with coefficient a 4 in t such that b = aa 2 − a ′ a 4 . Since a ′ x < s or s < a ′ x is an atomic formula in β and since s is x-free, we have a ′ ∈ Coeff(β). Hence, also in this case, b ∈ Coeff p (β).
Next let d ∈ Const(β a,t+c ). If d ∈ Const(β), we have d = 1d − 0(0 + c) ∈ Const p (β). So suppose d / ∈ Const(β). Then, as above, there exists some atomic formula a ′ x < s or s < a ′ x in β such that ±d is the constant term in as − a ′ (t + c). Consequently, ±d = ac 1 − a ′ (c 2 + c) where c 1 and c 2 are the constant terms of s and t, resp. Since a, a ′ ∈ Coeff(β) (see above) and since |c| ⩽ a · p · lcm Mod(β), we get d ∈ Const p (β).
We now come to the elimination of the classical existential quantifier. Neither the result nor its proof are new, we present them here to be able to also verify Condition (4.1).
Lemma 4.2. Let x be a variable and β a Boolean combination of x-separated atomic formulas. Then there exists a Boolean combination γ of x-free atomic formulas such that the triple (β, γ, 1) satisfies Condition (4.1) and (∃x : β) ⇐⇒ γ.
Proof. Let T be the set of all pairs (a, t) such that β contains an atomic formula of the form ax < t or t < ax with a > 0. We first assume that this set T is not empty. Let furthermore N = lcm Mod(β) . In particular, N is a multiple of every integer k such that the atomic formula ax ≡ k t appears in β for some term t and some a ∈ Z. Then we set where the disjunction extends over all triples (a, t, c) with (a, t) ∈ T and −aN ⩽ c ⩽ aN (since T ̸ = ∅, this disjunction is not empty). We prove (∃x : β) ⇐⇒ γ. So let f be an assignment with f (∃x : β) = tt. Then there is we get tt = g(β) = g(β a,t ) = f (β a,t ) and, since f (t) a = b ∈ Z, also f (0 ≡ a t) = tt. Hence, using the triple (a, t, 0), we have f (γ) = tt.
Next consider the second case. There exists k ∈ N with 0 < Since N is a multiple of all moduli appearing in β, we get f x/b−kN (β) = tt from f x/b (β) = tt and the choice of (a, t) and of k. triple (a, t, c), we obtain f (γ) = tt also in the second case.
The third case is symmetric to the second, i.e., we showed f (∃x : β) = tt =⇒ f (γ) = tt. For the converse implication, suppose f (γ) = tt. Then there is a triple (a, t, c) with (a, t) ∈ T and −aN ⩽ c ⩽ aN such that f (β a,t+c ∧ 0 Hence, by Lemma 4.1, we have g(β) = g(β a,t+c ) = f (β a,t+c ) = tt. Since g = f x/b , this implies f (∃x : β) = tt and therefore the remaining implication.
Thus, we proved the lemma in case T ̸ = ∅. Now assume T = ∅. Note that the formulas β and β ∧ (x < 0 ∨ ¬x < 0) are equivalent, agree on the sets of coefficients etc., and that the latter contains some atomic formula of the form ax < t. Thus, by the above arguments, we find the Boolean combination γ with the desired properties also in this case.
Having shown how to eliminate a single existential quantifier, we now come to the analogous result for modulo-counting quantifiers.
Lemma 4.3. Let x be a variable, β a Boolean combination of x-separated atomic formulas, and 0 ⩽ q < p natural numbers. Then there exists a Boolean combination of x-free atomic formulas γ such that the triple (β, γ, p) satisfies Condition (4.1) and (∃ (q,p) x : β) ⇐⇒ γ.
The proof of this lemma requires several claims and definitions that we demonstrate first, the actual proof of Lemma 4.3 can be found on page 23. Its idea is to split the integers into finitely many intervals (depending on the set of terms that appear in β) and to express the number (modulo p) of witnesses for β in any such interval by a quantifier-free formula. The claims below consider different types of such intervals.
Let N = lcm Mod(β) . Let T be the set of all pairs (a, t) such that β contains an atomic formula of the form ax < t or t < ax with a > 0 (if no such formula exists, set T = (1, 0) ).
Proof. Let f be an assignment that is consistent with (S, ≺). Let b ∈ Z with a 1 b < f (s 1 ). For all (a, t) ∈ T , we have b < f (s 1 ) a 1 ⩽ f (t) a and therefore a(b − N ) < ab < f (t). Consequently, b and b − N satisfy the same inequalities from β. Since N is a multiple of all moduli appearing in β, the same holds for all modulo constraints. Hence we obtain Consequently, there are infinitely many b ∈ Z satisfying f x/b (a 1 x < s 1 ∧ β) = tt or none. For r ̸ = 0, we can therefore set γ ≺ 0,r = (0 < 0) ensuring Condition (4.1) for the triple (β, γ ≺ 0,r , p). It remains to consider the case r = 0. Note that a 1 satisfy f x/b (β) = tt. Let α be the formula obtained by Lemma 4.2 from the formula ∃x : (a 1 x < s 1 ∧ β) and set γ ≺ 0,0 = ¬α. Since a 1 x < s 1 or s 1 < a 1 x is an atomic formula from β, we get Coeff(β) = Coeff(a 1 x < s 1 ∧ β) and similarly for Const and Mod. Hence the triple (β, α, p) and therefore (β, γ ≺ 0,0 , p) satisfies Condition (4.1).
Symmetrically, we also get the following: Claim 4.5. Let 0 ⩽ r < p. There exists a Boolean combination γ ≺ n,r of x-free atomic formulas such that the triple (β, γ ≺ n,r , p) satisfies Condition (4.1) and f (β n,r ) = f (γ ≺ n,r ) for all assignments f that are consistent with (S, ≺). We next want to eliminate the initial quantifier ∃ (r,p) from β i,r for 1 ⩽ i < n, i.e., we . To get the idea of the rather long proof, consider the formula ∃ (0,2) x : y < x < z ∧ x ≡ 3 y + z and assume that the assignment f satisfies f (y) < f (z). Then the witnesses for φ := (x ≡ 3 y + z) in the interval f (y), f (z) are 3-periodic. Consequently, any subinterval of length 6 = 3 · 2 contains an even number of witnesses for φ. It follows that we only need to count the number of witnesses of φ in the interval f (y), f (y) + b where 1 ⩽ b ⩽ 6 is the unique number satisfying 6 | f (z) − b (since then the length of the interval f (y) + b, f (z) is a multiple of 6).
The main additional difficulty in the following proof is based on the occurrence of subformulas of the form ax < t for a > 0.
Claim 4.6. Let 1 ⩽ i < n and 0 ⩽ r < p. There exists a Boolean combination γ ≺ i,r of x-free atomic formulas such that the triple (β, γ ≺ i,r , p) satisfies Condition (4.1) and f (β i,r ) = f (γ ≺ i,r ) for all assignments f consistent with (S, ≺).
Proof. Let f be any assignment that is consistent with (S, ≺) and let W ⊆ Z be the set of witnesses for β, i.e., . Our task is to express, by a quantifier-free formula and irrespective of the concrete (S, ≺)-consistent assignment f , that |I ∩ W | ≡ p r holds.
We first split the interval I into an initial segment of length ⩽ pN and subsequent subintervals of length pN each. To this aim, let b be the unique integer from the set Since N is the least common multiple of Mod(β), this is equivalent to requiring that the formula − a i+1 f (s i ) and therefore K ∈ N. Now we define the following intervals: a i a i+1 + (k + 1) · pN for 0 ⩽ k < K Note that these intervals form a partition of the interval I.
Let c ∈ Z with f (s i ) a i < c < c + N < f (s i+1 ) a i+1 , i.e., c, c + N ∈ I. Since f is consistent with (S, ≺), for any (a, t) ∈ T , we have Hence c and c + N satisfy the same inequalities from β. Since N is a multiple of all moduli appearing in β, it follows that c and c + N also satisfy the same modulo constraints from β.
Hence we get It follows that the set W of witnesses for β within the interval I is N -periodic. Since the interval J k ⊆ I is of length pN , it follows that |J k ∩W | ≡ p 0 for all 0 ⩽ k < K. Consequently, It remains to construct a formula expressing that the interval I 0 has, modulo p, r witnesses for β.
To characterise the elements of I 0 , let e ∈ Z be arbitrary. By the definition of I 0 , we have e ∈ I 0 iff a i+1 f (s i ) < a i a i+1 e < a i+1 f (s i ) + b. This is clearly equivalent to 0 < a i e − f (s i ) < b a i+1 . Equivalently, there exists an integer d with . Then we showed Hence, by Lemma 4.1, we get where the last equality holds since β a i ,s i +d is x-free. It follows that e ∈ W iff f (β a i ,s i +d ) = tt. Hence we showed that I 0 ∩ W is the set of fractions f (s i +d) a i for d ∈ M with f (s i + d) ≡ a i 0 and f (β a i ,s i +d ) = tt. We consequently get It follows that |I 0 ∩ W | ≡ p r iff the following formula γ ≺ i,r holds under the assignment f : We finally verify Condition (4.1) for the triple (β, γ ≺ i,r , p). Note that any element of Coeff(γ ≺ i,r ) or Const(γ ≺ i,r ) appears in a subformula of the form β a i ,s i +d for some integer d ∈ M and therefore 1 ⩽ d ⩽ b−1 a i+1 < a i pN . Hence Coeff(γ ≺ i,r ) ⊆ Coeff p (β) and Const(γ ≺ i,r ) ⊆ Const p (β) follow from Lemma 4.1. Now let p 1 ∈ Mod(γ ≺ i,r ). There are three cases to be considered: • p 1 = a i a i+1 pm for some m ∈ Mod(β). Then p 1 ∈ Mod p (β).
Then, by Lemma 4.1, p 1 ∈ Mod p (β). Thus, indeed, Mod(γ ≺ i,r ) ⊆ Mod p (β) which finishes the proof of Claim 4.6. Claim 4.7. Let 1 ⩽ j ⩽ n and 0 ⩽ r < p. There exists a Boolean combination δ ≺ j,r of x-free atomic formulas such that (β, δ ≺ j,r , p) satisfies Condition (4.1) and, for all assignments f (even those that are not consistent with (S, ≺)), f (β ′ j,r ) = f (δ ≺ j,r ). Proof. Since the term s j is x-free, there can be at most one witness for the formula a j x = s j ∧ β (which is the quantifier-free part of the formula β ′ j,r ). For r > 1, we therefore set δ ≺ j,r = (0 < 0). For the same reason, we obtain Hence, we obtain the formula δ ≺ j,1 from Lemma 4.2. Since precisely one of the formulas δ ≺ j,r must hold, we can set δ ≺ j,0 = 0<r<p ¬δ ≺ j,r (which is equivalent to ¬δ ≺ j,1 ). Having shown all these claims, we can now use them to finally prove Lemma 4.3.
Next consider the formula Then, for any assignment f , we have f (α ≺ ) = tt if and only if f is consistent with (S, ≺).
Since α ≺ is a Boolean combination of formulas of the form a ′ s < at 5 with (a, s), (a ′ , t) ∈ T , the triple (β, α ≺ , p) satisfies Condition (4.1). Finally, let where the disjunction ( * ) extends over all strict linear orders ≺ on some non-empty subset of T .
Lemmas 4.2 and 4.3 above show how to eliminate a quantifier in front of a quantifier-free formula and analyses the sets of coefficients, constants, and moduli appearing in this process. The following proposition summarises these results and provides bounds on the maximal coefficients etc. Recall that P(φ) = Coeff(φ) ∪ Mod(φ).
Proposition 4.8. Let x be a variable and α a Boolean combination of atomic formulas. Let furthermore E = ∃ or E = ∃ (q,p) for some 0 ⩽ q < p and 2 ⩽ p. Then there exists a Boolean combination γ of x-free atomic formulas such that (Ex : α) ⇐⇒ γ. Furthermore, we have the following: Proof. If E = ∃, set p = 1. Without changing the sets of coefficients etc., we can transform α into an equivalent Boolean combination β of x-separated atomic formulas. By Lemma 4.2 or 4.3, there exists a Boolean combination γ of x-free atomic formulas with (Ex : α) ⇐⇒ γ such that the triple (α, γ, p) satisfies Condition (4.1).
Now, by induction on the quantifier depth we can obtain the following theorem.
Theorem 4.9. Let φ ∈ FO ∃ (q,p) x] be a formula of quantifier-depth d. There exists an equivalent Boolean combination γ of atomic formulas with Proof. The proof proceeds by induction on d. For d = 0, the claim is trivial since then, we can set γ = φ. Now suppose the theorem has been shown for formulas of quantifier-depth < d. So let φ = Ex : ψ where E = ∃ or E = ∃ (q,p) for some 0 ⩽ q < p and the formula ψ has quantifier-rank < d. If E = ∃, set p = 1. Then, by the induction hypothesis, there exists a Boolean combination α of atomic formulas such that ψ ⇐⇒ α, max P(α) ⩽ (max P(ψ)) 4 d−1 and max Const(α) ⩽ 2 (max P(ψ)) 4 d−1 · max Const(ψ) .
By Prop. 4.8, we find a Boolean combination γ of atomic formulas such that the following hold: Note that max P(Ex : α) is the maximum of p ⩽ p 4 d−1 and max P(α) ⩽ max P(ψ) 4 d−1 . Similarly, the maximum of p and max P(ψ) is equal to max P(Ex : ψ). Therefore we get max P(Ex : α) ⩽ max P(Ex : ψ) 4 d−1 . Hence max P(γ) ⩽ max P(Ex : α) 4 ⩽ (max P(Ex : ψ) 4 d−1 ) 4 = max P(φ) 4 d . Before we prove the desired upper bound for max Const(γ), note the following for all n ⩾ 2 and d ⩾ 1: With n = max P(φ), we therefore obtain max Const(γ) ⩽ 16 max P(Ex : α) · max Const(Ex : α) Using Proposition 3.6, the extension of the above result to the larger logic FO ∃ (t,p) x] follows immediately.
If we allow the threshold counting quantifiers ∃ ⩾c and ∃ =c , the result gets a bit weaker since we have to replace the exponent d in the above bounds by a polynomial in the size of φ. To see this, let φ ∈ FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x . Then, by Proposition 3.3, it can be transformed in polynomial time into an equivalent formula φ ′ from FO ∃ (t,p) x]. The quantifier depth d ′ of φ ′ is bounded by the size of φ ′ and therefore polynomial in the size of φ. Now we can resort to the above corollary and obtain Corollary 4.11. Let φ ∈ FO ∃ (t,p) x, ∃ ⩾c x, ∃ =c x be a formula. There exists an equivalent Boolean combination γ of atomic formulas with max P(γ) ⩽ max P(φ) 4 poly(|φ|) and max Const(γ) ⩽ 2 (max P(φ)) 4 poly(|φ|) · max Const(φ) .

An efficient decision procedure
Let φ(x) be a Boolean combination of formulas with a single free variable. To determine validity of the formula ∃x : φ, one has to check, for all integers n ∈ Z, whether φ(n) holds.
The following lemma reduces this infinite search space to a finite one that is exponential in the coefficients and moduli as well as linear in the constants from φ.
Lemma 5.1. Let A ⩾ 6 and B ⩾ 0. Let x be a variable and γ a Boolean combination of atomic formulas of the form ax > b, ax < b, and cx ≡ h d with a, b, c, d ∈ Z, h ⩾ 2, |a|, h < A, and |b| < B. Then ∃x : γ is equivalent to ∃x : |x| ⩽ A A 5 · B ∧ γ .
Proof. Since h < A, we can assume that 0 ⩽ c, d < A for all formulas of the form cx ≡ h d.
We can also assume that γ is in negation normal form, i.e., only atomic formulas are negated. We make the following replacements: As a result, γ is equivalent to a formula in disjunctive normal form, without negations, and with atomic formulas of the form ax < b and cx ≡ h d with 0 ⩽ c, d, |a|, h < A and |b| ⩽ B. Hence γ ⇐⇒ 1⩽i⩽n δ i where each of the formulas δ i is a conjunction of atomic formulas of the allowed form. Consequently, ∃x : γ is equivalent to 1⩽i⩽n ∃x : δ i .
Consider one such conjunction δ i . Note that it contains at most A 3 many atomic formulas of the form cx ≡ h d since 0 ⩽ c, d, h < A. For any such atomic formula, introduce a new variable y and replace cx ≡ h d by cx − hy = d. Then δ i is equivalent to ∃y : δ ′ i where δ ′ i is a conjunction of formulas of the form cx − hy = d and ax < b with 0 ⩽ c, h, d, |a| < A and |b| ⩽ B and y is a sequence of at most A 3 variables. Let M be the maximal absolute value of the determinant of an (m × m)-matrix with m ⩽ A 3 + 2, where the first m − 1 columns contain entries of absolute value at most A and the entries in the last column have absolute value at most B. Then it is not hard to determine that Now the main theorem of [VS78] implies that the formula ∃x, y : δ ′ is equivalent to the existence of a solution (x, y) of δ ′ where the absolute value of every entry is at most In summary, we get where all disjunctions extend over 1 ⩽ i ⩽ n.
The core of the above lemma is the reduction of the search space for closed formulas of the form ∃x : φ(x) with φ quantifier-free. The following corollary provides an analogous reduction for arbitrary formulas φ(x). In addition, we allow the formula φ to have further free variables y 1 , . . . , y ℓ that are handled as parameters.
In the following, we want to prove a similar result for the modulo-counting quantifier. Recall that ∃ (q,p) x : φ(x) can only be true if φ has only finitely many witnesses, i.e., if the formula ∃y∀x : φ(x) → |x| ⩽ y is true. Applying the above corollary, one finds a finite interval such that φ has infinitely many witnesses iff it has at least one witness in this interval. In case φ has only finitely many witnesses, then all of them are of bounded absolute value. More precisely, we get the following.
Now the claim follows since the formula (5.1) and therefore this formula holds.
Hence, in this case, ∃ (q,p) x : φ is equivalent to statement (b). Since (a ′ ) is true in this case, we have the equivalence.
By induction, we obtain that all recursive calls of the evaluation procedure use integers of size at most where c is some constant. To store any such integer, one needs space 4 d log D. When evaluating a closed formula of quantifier depth d, one has to store at most d variables at once. Therefore we get the following.
Proposition 5.5. Satisfaction of a closed formula φ ∈ FO ∃ (q,p) x] of quantifier-depth d can be decided in space O(4 d · log D) with D given by Equation (5.2).
Let φ ∈ FO ∃ (q,p) x]. Then the quantifier depth d is at most |φ|. Since coefficients etc. are written in binary, max P(φ) and max Const(φ) are bounded by 2 |φ| . Consequently, the proposition shows that satisfaction of closed formulas φ ∈ FO ∃ (q,p) x] can be decided in space doubly exponential in |φ|.
Recall that for formulas from FO ∃ (q,p) x] we require modulo-counting quantifiers of the form ∃ (t,p) (y 1 , . . . , y ℓ ) to satisfy t ∈ N and ℓ = 1. We now show that also without this restriction, the doubly exponential space bound remains true.