Quantiﬁer elimination for counting extensions of Presburger arithmetic

. We give a new quantiﬁer elimination procedure for Presburger arithmetic extended with a unary counting quantiﬁer ∃ = x y Φ that binds to the variable x the number of diﬀerent y satisfying Φ. While our procedure runs in non-elementary time in general, we show that it yields nearly optimal elementary complexity results for expressive counting extensions of Presburger arithmetic, such as the threshold counting quantiﬁer ∃ ≥ c y Φ that requires that the number of diﬀerent y satisfying Φ be at least c ∈ N , where c can succinctly be deﬁned by a Presburger formula. Our results are cast in terms of what we call the monadically-guarded fragment of Presburger arithmetic with unary counting quantiﬁers, for which we develop a 2ExpSpace decision procedure. .


Introduction
Counting the number of solutions to an equation, or the number of elements in a set subject to constraints, is a fundamental and often computationally challenging problem studied in logic, mathematics and computer science. In discrete geometry, counting the number of integral points in a polyhedron is a canonical #P-complete problem. Barvinok's celebrated algorithm solves this problem in polynomial time when the dimension is fixed [2]. In this paper, we investigate a generalization of this problem and study algorithmic aspects of counting the number of models of formulae of Presburger arithmetic, the first-order theory of the integers with addition and order, and more generally, extensions of this logic with counting quantifiers.
Counting quantifiers such as the Härtig quantifier, which allows to assert equal-cardinality constraints on the sets of satisfying assignments of two given first-order formulae, have long been studied in first-order logic [6]. In first-order theories of integer arithmetic, it is compelling to consider variants of counting quantifiers that bind the number of satisfying assignments of a formula to a first-order variable. Apelt [1] and Schweikardt [10] studied the decidability of Presburger arithmetic enriched with the unary counting quantifier ∃ =x y with the following semantics: given an assignment of integers to the first-order variables x, z 1 , . . . , z n , a formula ∃ =x y Φ(x, y, z 1 , . . . , z n ) evaluates to true whenever the number of different y satisfying Φ(x, y, z 1 , . . . , z n ) is exactly x. In both [1] and [10], decidability is shown by developing a quantifier elimination procedure for this extension of Presburger arithmetic which eliminates a counting quantifier by translating it into an equivalent quantified formula of Presburger arithmetic, i.e., one that only uses standard first-order quantifiers. This immediately gives decidability of Presburger arithmetic extended with the unary counting quantifier ∃ =x y since Presburger arithmetic is decidable in 2ExpSpace [9,3,12]. Unfortunately, the quantifier elimination procedures in [1,10] do not yield a similar elementary upper bound for the extended theory, as the elimination of a single quantifier ∃ =x y results in an exponential blow-up of the formula size and introduces nested first-order quantifiers. It is a widely open problem whether there is a decision procedure for Presburger arithmetic extended with the counting quantifier ∃ =x y with elementary running time, or whether this theory admits a significantly stronger lower bound than standard Presburger arithmetic.
To shed more light on the complexity of Presburger arithmetic extended with the aforementioned unary counting quantifier, Habermehl and Kuske gave a quantifier elimination procedure for Presburger arithmetic extended with a unary modulo counting quantifier ∃ (r,q) y, where r and q are positive natural numbers [4]. Here, ∃ (r,q) y Ψ(y, z 1 , . . . , z n ) holds whenever the number of different y satisfying Ψ(y, z 1 , . . . , z n ) is congruent to r modulo q. An analysis of the growth of the constants and coefficients occurring in their procedure then enables them to derive a 2ExpSpace upper bound for the logic, matching the complexity of Presburger arithmetic on deterministic machines. This noteworthy result shows that there is still room to extend Presburger arithmetic with non-trivial counting quantifiers without increasing the computational cost of deciding the logic.
Note that in order to keep the logic decidable, the counting quantifiers considered in the literature must be unary. Indeed, consider a binary counting quantifier ∃ =x (y 1 , y 2 ) counting the number of different y 1 and y 2 satisfying a formula. Then, Φ(x, z) = ∃ =x (y 1 , y 2 )(0 ≤ y 1 , y 2 < z) holds for x = z 2 , which in turn allows defining multiplication, leading to undecidability of the resulting theory.
Our contribution. Following the lines of [4] while trying to avoid the limitations of the procedures in [1,10], our goal is to study decision procedures for Presburger arithmetic enriched with variants of counting quantifiers that do not increase the complexity of the Presburger arithmetic. To begin with, we develop a new quantifier elimination procedure for Presburger arithmetic with unary counting quantifiers ∃ =x y that, in contrast to [1,10], does not require the introduction of first-order quantifiers. While the procedure still runs in non-elementary time, avoiding first-order quantification allows us not only to derive exponentially better bounds on the size of the formula obtained after eliminating a single ∃ =x y, but also to identify the sources of non-elementary growth. We exploit those observations to extend the range of counting quantifiers that can be added to Presburger arithmetic without increasing the complexity of the resulting logic.
The first type of counting quantifiers we consider is a threshold counting quantifier ∃ ≥c y for some integer c. A formula ∃ ≥c y Ψ(y, z 1 , . . . , z n ) evaluates to true whenever there are at least c different values of y satisfying Ψ(y, z 1 , . . . , z n ). We show that Presburger arithmetic enriched with threshold counting quantifiers can be decided in 2ExpSpace, even when the threshold c itself is succinctly given as the unique solution of a Presburger arithmetic formula. This is surprising since in Presburger arithmetic one can define numbers that are triply exponential in the size of the formula used to encode them [7, pp. 151-152]. Furthermore, we show that if we restrict c to be at most doubly exponential in the size of its encoding then Presburger arithmetic with threshold counting quantifiers is decidable in STA( * , 2 2 n O (1) , O(n)), matching the complexity of Presburger arithmetic [3]. Here, STA(s(n), t(n), a(n)) is the class of all decision problems in which inputs of length n can be decided by an alternating Turing machine in space s(n) and time t(n) using a(n) alternations, where " * " stands for unbounded availability of a certain resource.
Our results on the quantifier ∃ ≥c x arise from studying a more general extension of Presburger arithmetic that relies on the notion of monadic decomposition put forward by Veanes et al. in [11] and studied by Hague et al. [5] in the context of integer linear arithmetic. Briefly, a formula Φ(x, y 1 , . . . , y n ) is said to be monadically decomposable on the variable x whenever it is equivalent to a formula of the form i∈I ∆ i (x) ∧ Ψ i (y 1 , . . . , y n ), i.e., a formula where the satisfaction of constraints on x does not depend on the values of y 1 , . . . , y n . Based on this definition, we extend Presburger arithmetic by allowing the general unary counting quantifiers ∃ =x y to appear with guards of the form ∃ x(Ψ ∧ ∃ =x y Φ), where Ψ is monadically decomposable on the variable x. The resulting logic is very powerful, as it not only generalizes the quantifiers ∃ ≥c x but also the modulo counting quantifiers ∃ (r,q) y from [4]. We establish two further results for this monadically-guarded fragment of Presburger arithmetic with counting quantifiers. First, we develop a 3ExpTime quantifier elimination procedure for the logic, matching the complexity of the best possible quantifier elimination procedures for Presburger arithmetic. Second, we exploit this procedure to obtain a quantifier relativization argument showing that the logic is decidable in 2ExpSpace.
Basic syntax. Let X = {x, y, z, . . . } be a countable set of first-order variables. Linear terms, usually denoted by t, t 1 , t 2 , etc., are expressions of the form a 1 x 1 + · · · + a d x d + c where x 1 , . . . , x d ∈ X, a 1 , . . . , a d , c ∈ Z. The integer a i is the coefficient of the variable x i . Variables not appearing in the linear term are tacitly assumed to have a 0 coefficient. A term t is said to be x-free if the coefficient of the variable x in t is 0. The integer c is the constant of the linear term. Linear terms with constant 0 are said to be homogeneous.
Given a term t, the lexeme t < 0 is understood as a linear inequality, and t ≡ q 0 is a modulo constraint. Syntactically, Presburger arithmetic (PA) is the closure of linear inequalities and modulo constraints under the Boolean connectives ∧ and ¬ (i.e., conjunction and negation, respectively) and the first-order quantifier ∃y. Presburger arithmetic with counting quantifiers (PAC) extends PA with the (unary) counting quantifier ∃ =x y, where x and y are two syntactically distinct variables from X. Formulae of PAC are denoted by Φ, Ψ, Γ, etc.
We write vars(Φ) and fv(Φ) for the set of variables and free variables of Φ, respectively, with fv( A sentence is a formula Φ with fv(Φ) = ∅. We sometimes write Φ(x 1 , . . . , x k ) or Φ(x), with x = (x 1 , . . . , x k ) a tuple of variables, for a formula Φ with fv(Φ) = {x 1 , . . . , x k }. We say that Φ is z-free if z ∈ X does not occur in Φ. Given terms t and t , Φ[t /t] stands for the formula obtained from Φ by syntactically replacing every occurrence of t by t . Given Φ(x 1 , . . . , x k ) and terms t 1 , . .
Semantics. An assignment is a function ν : X → Z assigning an integer value to every variable. As usual, we extend ν in the standard way to a function that maps every term to an element of Z. For instance, ν(x+3x+2) = ν(x)+3ν(y)+2. Given a variable x and an integer n, we write ν[n/x] for the assignment obtained form ν by updating the value of x to n, i.e. ν[n/x](x) = n, and for all variables y distinct from x, ν[n/x](y) = ν(y). Given a formula Φ of PAC and an assignment ν, the satisfaction relation ν |= Φ is defined as usual for linear inequalities, modulo constraints, Boolean connectives and the existential quantifier ranging over Z. For the counting quantifier, we define ν |= ∃ =x y Φ if and only if #{n ∈ Z | ν[n/y] |= Φ} = ν(x).
Syntactic abbreviations. We define ⊥ def = 0 < 0 and def = ¬⊥. The Boolean connectives ∨, → and ↔ and the universal first-order quantifier ∀ are derived as usual, and so are the (in)equalities <, ≤, =, ≥, and >, between terms. For instance, t 1 < t 2 corresponds to t 1 − t 2 < 0, where we tacitly manipulate t 1 − t 2 with standard operations of linear arithmetic to obtain an equivalent term. Similarly, t 1 ≡ q t 2 is short for t 1 − t 2 ≡ q 0, whereas |t 1 | + t 2 < 0 is short for . For a variable x ∈ X and r ∈ [q], we call x ≡ q r a simple modulo constraint. All modulo constraints introduced by our quantifier elimination procedure given in Section 3 are simple.
The counting quantifier ∃ ≥x y. Historically [1,10], the quantifier ∃ =x y has been the unary counting quantifier of choice when it comes to PAC. However, a priori one could define PAC as the extension of PA featuring counting quantifiers ∃ ≥x y, where ν |= ∃ ≥x y Φ holds for an assignment ν whenever there are at least ν(x) values n ∈ Z for y such that ν[n/y] |= Φ. Notice that the counting quantifier ∃ =y can be expressed using ∃ ≥y , and vice versa: Two comments are in order: first, translating a PAC formula by swapping the type of counting quantifiers using the equivalences above has the unpleasant effect of increasing the size of the formula, exponentially if the nesting depth of quantifiers is unbounded. Second, the subformula ∀z ∃y : |z| ≤ |y| ∧ Φ used in the last equivalence states that there are infinitely many values for y that make the formula Φ true. This formula highlights the main difference between ∃ =x y and ∃ ≥x y quantifiers: the latter is true in the presence of infinitely many values for y, whereas the former is false. Throughout the paper, we focus on the quantifier ∃ =x y, as done in [1,10], but use this observation to argue that our results can be readily adapted to the counting quantifier ∃ ≥x y. Full details of this adaptation are given in the full version of the paper.
Parameters of formulae. To analyze quantifier-elimination procedures, following [8,12], we introduce a number of parameters for formulae of PAC: -|Φ| denotes the length of the formula Φ, i.e., the number of symbols to write down ϕ, with numbers encoded in binary. We always assume |Φ| ≥ 2; qr(Φ) (resp. nr(Φ)) denotes the quantifier (resp. negation) rank of the formula Φ, i.e., the depth of nesting of the quantifiers (resp. negations) of Φ; fd(Φ) denotes the overall depth of Φ, i.e., the depth of nesting of all constructors (i.e. ∧, ¬, ∃x and ∃ =x y) in the formula Φ; lin(Φ) is the set containing the term 0 plus all the terms t that appear in linear inequalities t < 0 of Φ (recall that t 1 < t 2 is short for t 1 − t 2 < 0); hom(Φ) is the set of homogeneous linear terms obtained from all terms in lin(Φ) by setting their constants to 0; const(Φ) is the set of all constants appearing in linear terms of lin(Φ); and mod(Φ) is the set of all moduli q ∈ N appearing in modulo constraints t 1 ≡ q t 2 of Φ. We postulate 1 ∈ mod(Φ), even if Φ has no modulo constraints.
Similarly, for a linear term t, we write ||t|| for the maximum absolute value of a coefficient or constant appearing in t. Given a finite set of vectors or a finite set of terms A, we define ||A|| = max{||a|| : a ∈ A}. Given a matrix A ∈ Z n×d , its infinity norm is the maximal infinity norm of its column vectors. Notice that ||lin(Φ)|| = ||hom(Φ) ∪ const(Φ)||. For a formula Φ, Complexity remarks. The proposition below characterizes the complexity of PA.

Proposition 1 ([3]). Presburger arithmetic is
To be more precise, the number of alternations required to decide the validity or satisfiability of a formula Φ from Presburger arithmetic is linear in nr(Φ).

A quantifier elimination procedure for PAC
In this section, we develop a new quantifier elimination procedure (QE procedure) for the counting quantifier ∃ =x y: Let Φ be quantifier-free. Then ∃ =x y Φ is equivalent to a Boolean combination of linear inequalities and simple modulo constraints.
We quantify the growth of parameters in the formula in Section 4. Upper bounds on this growth are at the core of our results. Without any bounds (as stated), Proposition 2 is known and can be obtained by chaining the quantifier elimination procedure developed by Schweikardt [10] together with the standard quantifier elimination procedure for Presburger arithmetic. An advantage of our QE procedure for the quantifier ∃ =x y is that it avoids the introduction of additional ∃-and ∀-quantifiers when eliminating a counting quantifier on which Schweikardt's procedure relies. More precisely, given a formula ∃ =x y Φ where Φ is quantifier-free (q.f. in short), the QE procedure in [10] requires a full transformation of Φ into disjunctive normal form, and eliminates the quantifier ∃ =x y by introducing first-order quantifiers, producing an equivalent formula Ψ of Presburger arithmetic. This strategy comes at a cost: the size of the q.f. formula obtained after removing the quantifiers from Ψ is doubly exponential in the size of ∃ =x y Φ. By avoiding the introduction of first-order quantifiers, our QE procedure already exponentially improves upon Schweikardt's procedure.
Our QE procedure performs a series of formula manipulations, divided into five steps. At the end of the i-th step, the procedure produces a formula Φ i equivalent to the original formula ∃ =x y Φ. Ultimately, Φ 5 is a Boolean combination of inequalities and simple modulo constraints allowing us to establish Proposition 2. In this section, we present the procedure and briefly discuss its correctness, leaving the computational analysis of parameters lin(Φ 5 ), hom(Φ 5 ), const(Φ 5 ) and mod(Φ 5 ) to subsequent sections.
Step I: Normalise the coefficients of y. Given the input formula Φ 0 = ∃ =x y Φ, with Φ q.f., the first step of the procedure is a standard step for QE procedures for Presburger arithmetic. It produces an equivalent formula Φ 1 in which all nonzero coefficients of y appearing in a linear term are normalized to 1 or −1. For simplicity, we first translate every modulo constraint in Φ into simple modulo constraints, by relying on the lemma below. Lemma 1. Every constraint t ≡ q 0 is equivalent to a Boolean combination Ψ of simple modulo constraints such that vars(Ψ) ⊆ vars(t ≡ q 0) and mod(Ψ) = {q}.
The first step of our QE procedure is as follows: 1 Translate every modulo constraint in Φ into simple modulo constraints (Lemma 1). 2 Let k be the lcm of the absolute values of all coefficients of y appearing in hom(Φ). 3 Let Φ be the formula obtained from Φ by applying the following three rewrite rules to each linear inequality and simple modulo constraint in which y appears: Claim 1. Φ 0 ⇔ Φ 1 , and in Φ 1 , all non-zero coefficients of y are either 1 or −1.
Step II: Subdivide the formula according to term orderings and residue classes.
We define an ordering for a set of linear terms T to be a formula of the form where There is an algorithm that, given a set T of n linear terms over d variables, computes in time The second step of our QE procedure is as follows: 5 Let T be the set of all y-free terms t such that t, y − t or −y + t belongs to lin(Φ1). 6 Using Lemma 2, build a set {O1, . . . , Oo} of orderings for the terms T . 7 Let Z def = vars(Φ) and m def = lcm(mod(Φ1)). 8 For every i ∈ [1, o] and every r : In Steps III to V of the procedure, we focus on each disjunct of Φ 2 separately, iterating over all i ∈ [1, o], hence over all orderings, and all r : Z → [m], i.e., functions assigning residue classes modulo m to the variables in Z.
Step III: Split the range of y into segments. Recall that Φ 1 = ∃ =x y Ψ, where Ψ is some Boolean combination of inequalities and modulo constraints with variables from vars(Φ) in which the non-zero coefficients of y are either 1 or −1. Let T | Oi def = (t 1 , · · · , t ) be the tuple of all the terms in T that the formula O i asserts pairwise non-equal, taken in the ascending order. In other words, we obtain t 1 , . . . , t by removing from the sequence t 1 , . . . , t n in Equation (1) all terms t j+1 for which j is =. Let seg(y, O i ) be the set of formulae We have #seg(y, O i ) = 2 + 1. Given κ ∈ seg(y, O i ), the formula O i ∧ κ imparts a linear ordering on the terms T ∪ {y}. This enables us to "almost evaluate" Ψ: Our QE procedure manipulates Φ 2 as follows: 10 For every i ∈ [1, o] and every r : Z → [m] : 11 Let seg(y, Oi) = {κ0, . . . , κ 2 }. 12 For every j ∈ [0, 2 ], consider the formula Ψ i,r κ j from Lemma 3. 13 Let Step IV: Compute the number of solutions for each segment. We next aim at eliminating the counting quantifiers introduced in Step III in the sub-formulae ∃ =xj y(κ j ∧Ψ i,r κj ). We go over each κ ∈ seg(y, O i ), and consider three cases depending on whether it specifies (syntactically) an infinite interval, a finite segment, or a single value for y.
Notice that r is in fact an assignment to variables, so r(t) ∈ Z is well-defined for every term t with free variables Z. Let u j = (r(t j−1 ) mod m). 20 Let uj be the smallest integer congruent to r(t j ) modulo m and greater than u j . 21 Let r j ∈ [0, m] be the number of y ∈ [u j + 1, uj − 1] satisfying Ψ i,r κ (y). 22 Let rj ∈ [−m 2 , m 2 ] be such that rj = −pj · (uj − u j ) + m · r j . Lemma 4. Given a formula Ψ i,r κ and m, u j , u j , the numbers p j and r j can be computed in #P, or by a deterministic algorithm with running time O(m·|Ψ i,r κ |). The numbers c j , p j , r j determine, for each κ ∈ seg(y, O i ), how many assignments to the variable y satisfy the formula Ψ i,r κ in the conjunction Γ i,r ∧ κ ∧ Ψ i,r κ . Intuitively, this is c j for κ of the form y = t j , and (p j (t j − t j−1 ) + r j )/m for κ of the form t j−1 < y ∧ y < t j . We say "intuitively" here, because in the latter case the expression above depends on other variables so is not, strictly speaking, a number. The following claims formalize this intuition: Claim 4. Let κ ∈ {y < t 1 , t < y}. If Ψ i,r κ (y) is satisfiable, then Φ i,r 3 ⇔ ⊥. Claim 5. Let j ∈ [1, ], κ = (y = t j ), z ∈ X. Then, ∃ =z y (κ ∧ Ψ i,r κ ) ⇔ z = c j . Claim 6. Let κ = (t j−1 < y ∧ y < t j ) for some j ∈ [2, ] and let z be a fresh variable. Then, Γ i,r ∧ ∃ =z y (κ ∧ Ψ i,r κ ) ⇔ Γ i,r ∧ mz = p j (t j − t j−1 ) + r j . The procedure manipulates the formula Φ 3 as follows: If Ψ i,r κ (y) is satisfiable for some κ ∈ {y < t 1 , t < y}, then let Φ i,r Step V: Sum up the solutions. It remains to get rid of the variables x i introduced earlier. For each disjunct Γ i,r ∧ Φ i,r 4 of Φ 4 , we use the notation from Step IV.
The procedure outputs Φ 5 . The following claim implies Proposition 2.

Discussion, summary of results and roadmap
The QE procedure for a single counting quantifier ∃ =x y from Section 3 forms the basis of our results. In this section we discuss its use and lay out its applications.
Analysis of the procedure. The next lemma establishes the growth of the formulae and their parameters in our quantifier elimination procedure.
Lemma 5. Let Φ 5 be obtained from applying the QE procedure of Section 3 to a formula ∃ =y x Φ, where Φ is quantifier-free and #vars(Φ) = d. Then:

Remark 1.
With minor changes to our procedure, one can obtain a QE procedure for the quantifier ∃ ≥x y. In particular, since ∃ ≥x y Φ is true if there are infinitely many values for y that satisfy Φ, Claim 4 needs to be updated so that Φ i,r 3 ⇔ is deduced, instead of Φ i,r 3 ⇔ ⊥. Other minor adaptations are required, e.g. equalities "x = . . . " and counting quantifiers ∃ =xj y appearing in Line 13 must be updated to "x ≤ . . . " and ∃ ≥xj y. The resulting QE procedure for ∃ ≥x y still adheres to the bounds in Lemma 5.
A consequence of Lemma 5 is that our QE procedure gives an algorithm for deciding a formula Φ from PAC featuring multiple counting quantifiers ∃ =x y in time 2 . . . 2 , where the height of the tower is linear in the quantifier rank of Φ. Indeed, in view of the upper bounds and equations given by Lemma 5 for #hom(Φ 5 ), N , m, and k, we observe that the upper bound for #hom(Φ 5 ) is exponential in #hom(Φ). This means that more fine-grained bounds are necessary for decision procedures with elementary complexity, i.e., with a running time bounded from above by a k-fold exponential in the size of the input formula.
Elementary decision procedures. In view of this growth of the parameters, it is natural to ask ourselves whether our QE procedure is perhaps naïvely disregarding important properties of the underlying arithmetic theory that could lead to better bounds. A good test in this direction is to check whether improved bounds can be achieved when the procedure runs on restricted forms of counting quantifiers. In the remainder of the paper we show that this is the case, and explain how the growth of parameters can be countered for restricted quantifiers, obtaining 3ExpTime quantifier elimination procedures as well as 2ExpSpace decision procedures for extensions of PA with a variety of counting quantifiers.
As an example, let us consider Presburger arithmetic enriched with threshold quantifiers ∃ ≥c y Φ, where c ∈ N is written in binary. These are satisfied whenever there are at least c distinct values for the variable y that make the formula Φ true. Notice that the threshold counting quantifiers ∃ ≥c y are a syntactic generalization of the first-order quantifiers, as ∃ ≥1 y Φ ⇔ ∃y Φ. Interestingly enough, one can translate threshold quantifiers into standard Presburger arithmetic with just a polynomial increase in the size of the formula. For simplicity, assume that the threshold c is a power of 2. Then, the quantifier ∃ ≥c y can be internalized in PA by relying on the equivalence ∃ ≥2g y Φ(y, z) ⇔ ∃u ∀v ∃ ≥g y : (v = 0 ↔ y < u) ∧ Φ(y, z) as well as ∃ ≥1 y Φ ⇔ ∃y Φ. However, in terms of decision procedures, this is an inadequate solution, as it comes at the cost of introducing 2 log 2 c many quantifier alternations. Building upon the QE procedure from Section 3, we show how to directly eliminate threshold quantifiers. This proves that the increase in alternation depth that depends on the threshold c is unnecessary. , O(fd(Φ))).
This result matches the complexity of deciding standard PA in the case of unbounded alternation depth. Thus, PA can be enriched with threshold quantifiers with almost no computational overhead. Note that a slight increase in number of alternations is still required, and goes from O(nr(Φ)) for PA to O(fd(Φ)) for PA with threshold counting quantifiers.
We further strengthen Theorem 1, extending it to the case where the threshold c is encoded even more succinctly, as the unique solution of a PA formula Φ(x) as long as this solution is bounded doubly-exponentially in |Φ|. An example of such a formula is Φ(x) = ∃z : and the only solution is given by x = 2 2 n [7, Lecture 23], whilst |Φ| = O(n). The crux of our results lies in the identification of a fragment of PAC that we call monadically-guarded, for which the following theorem can be established.
In the next section, we introduce the monadically-guarded fragment of PAC and discuss extensions of PA that can be captured by this fragment. In Section 6, by adding post-processing to the procedure from Section 3, we show how to deal with any monadically-guarded counting quantifiers in 3ExpTime. In Section 7 we establish Theorem 2 by designing a quantifier relativization argument, continuing the direction of research due to [12]. In Section 8 we prove Theorem 1.

The monadically-guarded fragment of PAC
Fix a logic L. A formula Φ(x, z) from L, where z is a tuple of variables not including x, is said to be monadically decomposable on the variable x whenever where ∆ i and Γ i are formulae from L. In this case, Ψ is said to be a monadic decomposition of Φ on the variable x.
The notion of monadic decomposition has been put forward by Veanes et al. in [11], as a general simplification technique that improves the performance of solvers. Here, our interest lies in studying whether the notion of monadic decomposability can bring complexity advantages for Presburger arithmetic with counting quantifiers. With this in mind, we consider formulae of PAC that we call monadically-guarded : those in which the quantifiers ∃ =x y only appear in subformulae of the form ∃x (Ψ ∧ ∃ =x y Φ), where Φ and Ψ are themselves from the monadically-guarded fragment of PAC, x does not occur in Φ, and Ψ is monadically decomposable on the variable x. The monadically-guarded fragment of PAC is understood as the set of all formulae from PAC that are monadicallyguarded. This fragment captures several interesting extensions of PA: -It can express that the number of different y satisfying Φ(y, z) lies in an arithmetic progression b, b + p, b + 2 · p, b + i · p, . . . , with b, p ∈ N. That is, y Φ(y, z)).
This type of monadically-guarded formulae extends the modulo counting quantifiers studied by Habermehl and Kuske [4]. Modulo counting quantifiers are written as ∃ (r,q) y Φ and hold whenever the number of different y satisfying Φ is congruent to r modulo q. Hence, ∃ (r,q) y Φ ⇔ ∃x (x ≡ p r ∧ ∃ =x yΦ).
Moreover, in the monadically-guarded fragment, we can replace the integer r with an arbitrary linear term t with variables from z, since the modulo constraint x ≡ p t can be monadically decomposed into r∈[p] (x ≡ p r ∧ t ≡ p r). -As we recalled in the previous section with the formula Ψ n (x, z), it is known that PA allows one to succinctly encode numbers that are doubly or triply exponentially large with respect to the size of the formula. For instance, one can define a formula L n (x), again of size polynomial in n, that is true whenever x is the product of all primes in the interval [2, 2 2 n ] (see [7,Lecture 24]). In this case, x ≥ 2 c2 2 n for some fixed c > 0. The monadically-guarded fragment of PAC allows one to use these succinct representations as guards of counting quantifiers. For instance, ∃x(L n (x)∧∃ =x y Ψ(y, z)) is true whenever the number of y satisfying Ψ(y, z) is the product of all primes in [2, 2 2 n ].
Hague et al. [5] proved that constructing the monadic decomposition of a quantifier-free formula can be done in exponential time. More precisely, given a q.f. formula Φ(x, y) from PA that is monadically decomposable on x, in [5] it is shown that there is a natural number B of magnitude exponential in |Φ| that makes the following formula Ψ B (x, y) a monadic decomposition of Φ on x: where m = lcm(mod(Φ)). We study the arguments presented in [5] and refine the bound B, tracking dependencies on several formula parameters separately. We find that B is polynomial in ||Φ||; it is only exponential in #mod(Φ) and in the number of variables of the tuple y. Let m = lcm(mod(Φ)) and B = 2 48d 2 (m · ||lin(Φ)||) 6d + 1. If Φ is monadically decomposable on x, then the formula Ψ B is such a decomposition.
Together with our QE procedure, Proposition 3 shows that it is decidable to check whether a formula of PAC is monadically decomposable (on a certain variable). Due to Theorem 2, this problem is in 2ExpSpace for formulae of the monadically-guarded fragment of PAC. Besides, notice that all formulae having one free variable are monadic decompositions of themselves.
Our QE procedure for the monadically-guarded fragment of PAC, outlined below, makes use of the sharper bound obtained in Proposition 3.

Eliminating monadically-guarded counting quantifiers
Consider a formula Φ 0 = ∃x(Ψ ∧ ∃ =x y Φ), where Φ and Ψ are quantifier-free formulae, x does not occur in Φ, and Ψ is monadically decomposable on x. By relying on the QE procedure introduced in Section 3, we show how to obtain a quantifier-free formula equivalent to Φ 0 . W.l.o.g., we assume that all free variables distinct from x and y and occurring in Φ and Ψ come from the tuple of variables z.
Below, let Ψ = k∈K ∆ k (x) ∧ Ψ k (z) be the monadic decomposition of Ψ on the variable x computed according to Proposition 3. Recall that this means that each ∆ k is a formula having one among the following three forms: and B is a fixed natural number. Let us also consider the formula Φ 5 obtained from performing the QE procedure for the ∃ =x y counting quantifier on ∃ =x y Φ, so that Φ 0 ⇔ ∃x(Ψ ∧ Φ 5 ). In particular, recall that Φ 5 where Z is the set of variables appearing in z, m = lcm(mod(Φ)) and Γ i,r = O i ∧ ( w∈Z w ≡ m r(w)) is a conjunction of an ordering O i and simple modulo constraints with variables from Z. Hence, Γ i,r is x-free. Moreover, Φ i,r 5 is either ⊥ or a formula of the form where the terms t 1 , . . . , t are from T (where T is defined as in Step II of Section 3), and hence x-free. Therefore, the following property holds.
Claim 9. In Φ 5 , x only appears on the left-hand side of equalities of the form (2).
This inconspicuous claim, together with the shape of ∆ k , is at the heart of our QE procedure eliminating x from the formula ∃x(Ψ ∧ Φ 5 ). Indeed, after distributing the existential quantifier ∃x and all conjunctions over disjunctions of Ψ ∧ Φ 5 , we end up with a disjunction of formulae of the form ∃x : , and let us consider one such disjunct with ∆ k (x) = (x ≥ B ∧ x ≡ q c) and Φ i,r 5 as in Equation (2). The variable x can be eliminated with a simple substitution, rewriting ∆ k (x) ∧ Φ i,r 5 as the new formula t ≥ m · B ∧ t ≡ m·q m · c, where t is the right-hand side of Equation (2). The correctness of this rewrite step follows simply from the equivalences x ≥ B ⇔ m · x ≥ m · B and x ≡ q c ⇔ m · x ≡ m·q m · c, with m ≥ 1. In a similar way, we can treat all possible cases for the different forms of ∆ k (x) and Φ i,r 5 . We obtain a formula The number of homogeneous terms across all such disjuncts is still prohibitive as it was in Φ 5 . Now comes the key simplification step; we deal with the inequality t ≥ m · B and with the modulo constraint t ≡ m·q m · c.
Consider the former first. By definition, all the coefficients p j of Equation (2) are non-negative, and thanks to the ordering O i appearing in Γ i,r , in every valuation ν satisfying the formula in Equation (3) we have ν(t j − t j−1 ) ≥ 0. Therefore, the inequality t ≥ m · B can be translated into a formula of the form g∈G j=2 t j − t j−1 ≥ d g,j , where each d g,j is non-negative and, for every g ∈ G, the sum j=2 p j d g,j is at least e def = m(B − j=1 c j ) − j=2 r j . To compute this formula efficiently, we appeal to Lemma 2, with respect to the set of terms A similar simplification can be done for the modulo constraint t ≡ m·q m · c: we guess residue classes of variables in t modulo m · q, rewriting t ≡ m·q m · c into s : Z→[m·q] ( t ≡ m·q m · c ∧ z∈Z z ≡ m·q s(z)) and then replace, in each disjunct, t ≡ m·q m · c by or ⊥, according to the satisfaction of s( t) ≡ m·q m · c.
The steps just discussed forms the post-processing phase of our QE procedure for the monadically-guarded fragment of PAC. Thanks to Lemma 6, we can show that the set of homogeneous terms of the resulting quantifier free formula Φ , equivalent to Φ 0 , is the set of homogeneous terms in the monadic decomposition Ψ , together with terms of the form t − t with t and t belong to the set T defined in Line 5. But #hom(Ψ ) = O(#hom(Φ 0 )), and thus: Running time. Lemma 7 is the key to obtaining an elementary QE procedure.
In particular, this improvement over the exponential dependence of #hom(Φ 5 ) on #hom(Φ) from our "baseline" Lemma 5 leads to the following bounds on the elimination of an arbitrary number of monadically-guarded quantifiers.

Lemma 8.
Let Ω be a formula from the monadically-guarded fragment of PAC, with quantifier rank d. There is an equivalent quantifier-free formula Υ such that -#hom(Υ) ≤ |Ω| Proof idea. In a nutshell, the bounds of Lemma 8 are obtained by first iterating Lemma 7 across all quantifier elimination rounds. This results in the doubly exponential bound |Ω| on the cardinality of the set of homogeneous terms throughout the entire procedure. With this bound in hand, exponentiation on the right-hand side of the inequalities of Section 3 does not blow the parameters above triple exponential.
Subsequent analysis leads to the following result.
Theorem 3. There is a 3ExpTime quantifier elimination procedure for the monadically-guarded fragment of PAC.
Theorem 3 follows by combining Lemma 8 with upper bounds on the running time of a single quantifier elimination round. These upper bounds are all subsumed by the size of the obtained formulae, except possibly for the subdivision procedure of Step II (Lemma 2), the model counting procedure of Step IV (Lemma 4), and the further subdivision performed by Lemma 6. For Lemmas 2 and 6, the running time is only exponential in the size of the original formula, and thus polynomial time in the size of the obtained formula, as long as the latter has at least exponential size. For Lemma 4, observe that m ≤ ||mod(Υ)||, where Υ is the quantifier-free formula of Lemma 8. Therefore, the bounds of Lemma 8 suffice for a triply exponential time overall.
Remark 2. Only small updates are necessary to treat monadically-guarded formulae of the form ∃x(Ψ(x, z) ∧ ∃ ≥x yΦ(y, z)). Again, these updates deal with the fact that, contrary to ∃ =x yΦ, the formula ∃ ≥x yΦ is true whenever there are infinitely many y satisfying Φ, or alternatively when x corresponds to a non-positive number. Then, Lemma 8 can be established for formulae of PAC containing both monadically-guarded quantifiers ∃ =x and ∃ ≥x .
7 The monadically-guarded fragment is in doubly exponential space In this section, we prove Theorem 2. Theorem 3 shows that our QE procedure has the same asymptotic running time as the standard QE procedures for PA. Historically, bounds obtained from the latter lead to computationally optimal decision procedures based on quantifier relativisation [12,4]. More precisely, given a formula Φ from PA, the QE procedures allow us to conclude that there is a bound C, of bitsize at most doubly exponential in |Φ|, such that ∃x Φ ⇔ ∃x : −C ≤ x ≤ C ∧Φ holds (a small-model property). Then, a quantifier relativisation procedure follows the semantics of the formula and naïvely tries all the possible assignments to x in [−C, C] whenever a quantifier ∃x is encountered. With some bookkeeping, this procedure runs in 2ExpSpace. In this section, we show that this is also the case for our QE procedure, leading to a 2ExpSpace relativisation procedure for the monadically-guarded fragment of PAC, proving Theorem 2.
First of all, we need to recall a folklore result regarding the existence of infinitely many solutions of a quantifier-free Presburger formula.
Together with Lemma 8, this result leads to the relativisation of first-order quantifiers in the context of PAC.

Lemma 10.
There is a constant c with the following property. Let ν be an assignment, Φ(y, z) be a monadically-guarded formula of PAC, where z has d variables, and let C def = 2 |Ψ| 2 c·d · max{1, |ν(z)| : z is in z}. Then, ν |= ∃y Φ if and only if ν[n/y] |= Φ holds for some n ∈ Z with |n| ≤ 3 · C.
We want to derive a similar lemma for monadically guarded counting quantifiers. First of all, we consider a formula Φ = ∃ =x y Ψ(y, z) where Ψ is a monadically guarded formula. Recall that Φ is satisfied by an assignment ν whenever the number of distinct values n ∈ Z such that ν[n/y] |= Ψ is finite and equal to ν(x). By relying on Lemmas 8 and 9, we show the following lemma. Lemma 11. There is a constant c with the following property. Let ν be an assignment, and consider a formula Φ = ∃ =x y Ψ(y, z) such that Ψ is a monadically guarded formula of quantifier rank d. Let C def = 2 |Ψ| 2 c·d · max{1, |ν(z)| : z is in z}. Then, ν |= Φ iff (i ) ν[n/y] |= Ψ, for every n ∈ Z with C < |n| ≤ 3 · C; and (ii ) #{n ∈ Z : |n| ≤ C and ν[n/y] |= Ψ} = ν(x).
We now consider the outermost quantifier x of a monadically-guarded formula Θ = ∃x (Ψ(x, z) ∧ ∃ =x y Φ(y, z)), and aim at finding relativisation bounds for the variable x. Notice that the subformula Ψ(x, z) ∧ ∃ =x y Φ(y, z) is not, strictly speaking, in the monadically-guarded fragment of PAC. However, we can first apply Lemma 8 and obtain quantifier-free formulae Ψ and Φ equivalent to Ψ and Φ, respectively. Then, we apply the QE procedure of Section 3 on input ∃ =x y Φ , producing an equivalent quantifier-free formula Φ. We have Θ ⇔ ∃x ( Ψ ∧ Φ), where Ψ ∧ Φ is quantifier-free. Similarly to Lemma 10, we can now obtain relativisation bounds from ∃x ( Ψ ∧ Φ) by relying on Lemma 9: There is a constant c with the following property. Let ν be an assignment, and let Θ = ∃x (Ψ(x, z) ∧ ∃ =x y Φ(y, z)) be a monadically-guarded formula of quantifier rank d. Define C def = 2 |Θ| 2 c·d · max{1, |ν(z)| : z is in z}. Then, ν |= Θ if and only if there is n ∈ N s.t. n ≤ C and ν[n/x] |= Ψ ∧ ∃ =x y Φ.
Lemmas 10 to 12 allow to evaluate the truth of a sentence of the monadicallyguarded fragment of PAC by recursively evaluating the truth of its subformulae, and iterating over a finite set of values when considering first-order and counting quantifiers. As all the considered values admit a binary encoding that is doubly exponential in the size of the input formula, this proves Theorem 2.

A complexity characterisation
By Theorem 2, for deterministic machines, the monadically-guarded fragment of PAC is no harder than standard Presburger arithmetic, and the same is true when considering monadically-guarded quantifiers ∃ ≥x y (Remark 2). However, by Proposition 1, PA is not complete for 2ExpSpace, but rather for the complexity class STA( * , 2 2 n O (1) , O(n)). This leads to the natural question on whether the monadically-guarded fragment of PAC is also complete for the same STA class. While we leave this question open, in this section we show a completeness result in the restricted case where all monadically-guarded quantifiers appear in the form ∃x(Ψ(x) ∧ ∃ ≥x y Φ), where Ψ(x) is any formula from PAC having all models bounded by 2 2 |Ψ| , in absolute value. For brevity, let us denote this fragment by F. As F extends PA, proving the following upper bound suffices. Turing machine with runtime 2 2 |Φ| O (1) and performing O(fd(Φ)) alternations.
With Lemma 13 at hand, designing an algorithm that can be implemented as an alternating Turing machine with resources bounded as in Theorem 4 is simple. The function check(·, ·) given in Figure 1 provides such an algorithm. When Φ is a sentence, i.e. fv(Φ) = ∅, this lemma implies that Φ is valid if and only if check({ν}, Φ) = , where ν is an arbitrary assignment. Then, Theorem 4 follows by establishing that check(·, ·) can be implemented with an alternating Turing machine that, on input ({ν}, Φ) where Φ is a sentence in F, runs in time (1) and performs O(fd(Φ)) many alternations. We see the existential quantifications on V 1 , V 2 , ν and (W ν ) ν∈V in Lines 2, 4 and 5 as guesses done by the alternating Turing machine. The computation in Line 1 is done deterministically in time polynomial in the encoding of V and t < 0. In Line 2, the alternating Turing machine decides which branch among check(V 1 ,Φ 1 ) and check(V 2 ,Φ 2 ) must be evaluated, at the cost of one alternation. In this way, alternations occur only in the case of check(V ,Φ 1 ∨ Φ 2 ) and check(V ,¬Ψ), as the latter returns the negation of the assertion "∃ν ∈ V : check({ν}, Ψ) = ". This leads to O(fd(Φ)) many alternations overall. Let us now discuss the runtime of check(·, ·), again on alternating Turing machines. Assume that, after a certain number of recursive calls including at most r ≤ qr(Φ) calls to Line 5, the algorithm evaluates the input (V , Ψ). Then, the number of assignments in V is bounded by 2 r·2 |Φ| (this correspond to the case where each W ν in Line 7 contains the maximum amount of assignments, according to k (ν) ), and following the bounds on the numbers n (ν) and n (ν) i in Lines 10 and 11 and by Lemma 13, all these assignments map each variable to an integer that is, in absolute value, bounded by 2 r·|Φ| 2 c·d , where c is the constant of Lemma 13 and d is the number of variables in Φ. So, as the number of recursive calls to check(·, ·) is bounded by |Φ|, no more than |Φ| · 2 qr(Φ)·2 |Φ| · log 2 (2 qr(Φ)·|Φ| 2 c·d ) ≤ 2 2 (c+3)|Φ| space is required to represent all possible sets of assignments that are generated throughout the evaluation of check(·, ·). All the assignments are guessed by the alternating Turing machine and thus, when also accounting for the computation done in Line 1, we conclude that check({ν}, Φ) runs in time 2 2 |Φ| O(1) .

Conclusion
We developed a new quantifier elimination procedure for Presburger arithmetic extended with the unary counting quantifiers (PAC), and adapted it for its monadically-guarded fragment. While the existence of an algorithm for PAC running in elementary time is wide open, our procedure runs in 3ExpTime on the monadically-guarded fragment and leads to the small-model property and relativisation argument, which show that this logic is decidable in 2ExpSpace.
When it comes to deterministic algorithms, this matches the complexity of deciding standard Presburger arithmetic. However, fully settling the complexity of the monadically-guarded fragment of Presburger arithmetic seems to require a generalisation of the STA complexity framework to capture counting mechanisms, which we leave as an avenue for further investigation. In this direction, we have shown that Presburger arithmetic is still STA( * , 2 2 n O(1) , O(n))-complete when enriched with threshold quantifiers ∃ ≥c y, for the case of c written in binary but also even for the case of c represented succinctly as a solution of a Presburger formula Φ, characterising a number that may be doubly exponential in |Φ|.
With respect to our QE procedure for (general) unary counting quantifiers ∃ =x , we have pinpointed precisely where the non-elementary growth occurs. It remains to be seen whether our procedure can be further improved, or if, possibly based on insights obtained from it, a non-elementary lower bound for Presburger arithmetic extended with the ∃ =x y quantifier can be established.