We study the difficulty of counting points in parametric sets of the form
Here are the parameters, are the free variables, and are the quantified variables, all ranging over ; are the quantifiers; and is a Boolean combination, in disjunctive normal form, of linear inequalities in with coefficients in . That is,
where each is a matrix, each is a length
column vector, all with entries in, and the concatenation of the and variables is treated as a row vector.111By a simple trick, we do not need to worry about negations of basic inequalities, since these are equivalent to strict inequalities “,” which in turn are equivalent to non-strict inequalities “” since we are working over the integers. If there are parameters , we say that the family of sets is a -parametric Presburger family. A general expression of the type
with as in (1) is called a formula in -parametric Presburger Arithmetic (often abbreviated as -parametric PA). Classic Presburger arithmetic corresponds to .
Given a -parametric Presburger family defined by , under what conditions on the formula is the counting function a “nice” function of ?
Of course, “nice” is a vague qualifier, so let’s start with some nice examples. We will assume that the parameters are nonnegative in the following examples, which simplifies the number of cases:
If we define then
The set consists of the integer points on a line segment with endpoints and , and so
If , then the equality forces (which is only valid if ) and substituting into the inequality shows that
We’re seeing many types of “nice” functions in these examples, and the question is now how to generalize. In fact, Example 1.5 generalizes to any family in 1-parametic Presburger arithmetic , as described in the next section.
1.1. -parametric Presburger arithmetic
In the case of a single parameter , our perspective means studying families of subsets of of the form
where is exactly as in (2) except that the entries of the ’s and the ’s come from the univariate polynomial ring . The study of such 1-parametric PA families was proposed by Woods in . These families were further analyzed in , in which the main result is that they exhibit quasi-polynomial behavior:
A function is a quasi-polynomial if there exists a period and polynomials such that
A function is an eventual quasi-polynomial, abbreviated EQP, if it agrees with a quasi-polynomial for sufficiently large .
Example 1.5 is a family where is an EQP.
 Let be a 1-parametric PA family. There exists an EQP such that, if has finite cardinality, then . The set of such that has finite cardinality is eventually periodic.
In , the parameter takes values in instead of . However, one can see that the same proofs and conclusions also hold when ranges over .
There are several other forms of quasi-polynomial behavior that 1-parametric PA families exhibit (such as possessing EQP Skolem functions; see ). Here we focus on the cardinality, . We hope the reader agrees that EQPs are relatively “nice” functions.
1.2. -parametric Presburger arithmetic
Let us restate our main definition:
A -parametric PA family is a collection of subsets of of the form
where now is a Boolean combination of linear inequalities with coefficients in .
A -parametric PA formula is an expression “” as above, or any logically equivalent first-order formula in the language with a function symbols for , unary function symbols for multiplication by each polynomial , constant symbols for and , and a relation symbol for .
Abusing the notation, we also denote the parametric family just by when the dimension is clear.
Examples 1.2, 1.3, and 1.4 show that -parametric PA families, with , can have nice counting functions, . Will they always? We despair of defining “nice” precisely, but we can at least provide a necessary condition: for a fixed family , if is to qualify as a nice function, there must at least be a polynomial-time algorithm that takes as input and outputs .
Given a -parametric Presburger family defined by , under what conditions on the (fixed) formula is the counting function polynomial-time computable, taking as input the values of the parameters ?
Note that we define polynomial-time computation in the usual computer-science sense: the number of steps of the algorithm must be polynomial in the input size of (that is, the number of bits to encode into binary), which is . For example, the Euclidean algorithm is polynomial-time: it computes in number of arithmetic operations bounded by a degree 1 polynomial in .
The functions from Examples 1.2 through 1.5 are all polynomial-time computable. From Theorem 1.7 and the observation that EQPs are polynomial-time computable, we immediately obtain an answer to Question 1.11 in the case of a single parameter :
Let be any fixed 1-parametric PA family. Then there are polynomial time algorithms to: i) check if , ii) compute if .
The main goal of this paper is to construct a fixed 2-parametric PA family for which there is no polynomial-time algorithm computing (assuming ). Therefore, while we cannot say with precision what a nice function should be like, we can say that this particular counting function is not nice. Furthermore, this implies that certain classes of functions (polynomials, gcds, floor functions, modular reductions,…) are not expressive enough to capture , even for a very simple-looking . This contrasts with the 1-parameter case, where is always an EQP and hence polynomial-time computable.
Definition 1.9 is a generalization of classical Presburger arithmetic (PA), in which a formula is given only with explicit integer coefficients and constants ( and ) without any parameters . PA is decidable, meaning there is an algorithm to decide the truth of any given well-formed sentence in it. Moreover, PA has full quantifier elimination in an expanded language with predicates for divisibility by each fixed integer. This important logical fact permits an algorithm to actually count the cardinality of any set definable by a PA formula with an arbitrary number of quantifiers and inequalities, although with an unpractical triply exponential complexity in the length of (see ). The complexity of PA is itself a fundamental topic in the study of decidable logical theories and their complexities (see [6, 8]).
Returning to -parametric PA, for a fixed formula , given any value for , we can substitute it into to get a formula in PA. By the above paragraph, the parametric counting problem for (1) is always computable. Moreover, the form of the resulting formula , especially its number of quantifiers and inequalities, stays the same for different values a of . So we can hope that the complexity of computing (for a fixed family ) is much lower than that of counting solutions to a general PA formula (when the formula is not fixed, but instead given as input to the algorithm). To reiterate, it is critical in our analysis that the formula be fixed throughout, and we look for an efficient algorithm with as the only input.
1.3. Summary of results
Our main result is that if (technically, we only need the weaker assumption that ), then there exists a -parametric PA family such that is not polynomial-time computable; in fact, such a family exists with limited alternation of quantifiers. First we recall the and hierarchies of first-order formulas based on the number of quantifier alternations.
A -parametric PA formula is in (respectively, ) if it is logically equivalent to one of the form
in which every quantifier is (respectively, every is ), and is a Boolean combination of linear inequalities with coefficients in .
Inductively, a -parametric PA formula is in (respectively, ) if it is equivalent to one of the form
in which every is (respectively, ) and is a formula in (respectively, ).
Assume . There exists a -parametric PA family for which is always finite but cannot be expressed as a polynomial time evaluable function in and .
Two corollaries are:
There is a -parametric family such that the set of for which is positive cannot be described using polynomial-time relations in .
Any extension of -parametric PA with only polynomial-time computable predicates cannot have full quantifier elimination.
1.4. Structure of the rest of the paper
We will present what amount to two different proofs of Theorem 1.14 in the following two sections. In each case, we leverage the main result of Nguyen and Pak  which yields a -parametric PA formula, and then show how this can be reduced to a -parametric PA formula whose points are equally “hard” to count (modulo polynomial-time reductions). The first reduction we present, in Section 2, uses a trick due to Glivický and Pudlák  to encode multiplication by three different integers using multiplication by only two integers, and this reduction has the advantage of not increasing the number of free variables in the formula. Next, in Section 3 we present a more general counting-reduction technique which is less ad hoc and reduces any -parametric PA formula to a -parametric PA formula with the same number of quantifier alternations; the idea here is a little more transparent than in Section 2, but it has the disadvantage of introducing many more new free and quantified variables to the formula, so we consider that it is interesting to present both reductions.
In Section 4 we consider a variant of Question 1.11 in which there is no order relation in our language; that is, we can only express linear equations but not linear inequalities. Quantifier-free formulas in this language define finite unions of lattice translates. This setting was studied in detail from a model-theoretic perspective by van den Dries and Holly , and we apply their results to show that, in contrast to Theorem 1.14, the counting functions in the unordered setting can be computed in polynomial time, regardless of the number of parameters and of quantifier alternations. Indeed, these functions can be expressed using gcd and related functions.
Finally, in Section 5 we discuss the optimality of Theorem 1.14 by explaining what happens when we weaken or modify some of the hypotheses.
2. Proof of Theorem 1.14 and its corollaries
In what follows, it will be convenient to allow -parametric PA formulas in which the quantifiers are not necessarily outside the scope of all Boolean operations, but these are always logically equivalent to expressions as in (5); for instance,
is equivalent to
In , certain subclasses of classical PA formulas, called short PA formulas
, were investigated. The PA formulas in each such subclass are allowed to have only a bounded number of variables, quantifiers and inequalities (atomic formulas). The main problem was to classify the complexity (of counting and decision) for those short PA subclasses. It was proved that a simple subclass with onlyvariables, quantifier alternations and inequalities is NP-complete to decide, and also -complete to count. Combined with the positive results in [1, 2], this settled the last open subcase of classical PA complexity problems. The main reduction in  started with the following NP-complete problem:
AP-COVER: Given an interval222All intervals in the paper are over , so with should be understood as . and arithmetic progressions
with , , , decide if there exists some .
In other words, the problem asks whether there is some element in the interval not covered by the given arithmetic progressions. The problem is clearly invariant under a translation of both and the ’s, so we can assume . Also without affecting the complexity, we can assume that , i.e., . The main argument in  uses continued fractions to construct an integer and a rational number such that the best approximations of , in the terminology of continued fractions, encode modulo . The main point is that should satisfy , so that , and the formula
satisfies the property
Thus, the original AP-COVER instance is not satisfied if and only if . We emphasize that can be computed in polynomial time from . The meaning behind this formula can be explained as follows.
In Figure 1, the line divides the positive orthant into two parts. The integer hull of the points strictly below this line and above the horizontal axis form a polyhedron, whose boundary is the (bold) convex polygonal curve , starting at and ending at . Denote by the -th edge of above the (dotted) horizontal line . Then for every we have , and thus
In (6), we express as for some with and .333The curve includes in , but not here. This small difference is not very significant as one can easily check. By a basic property of continued fractions (see e.g. ), the condition is equivalent to saying that , and there is no other integer point with such that approximates better than . This last condition is expressed by the clause in .
A hardness result for 3-parameter PA immediately follows.
Assume . There exists a -parametric PA family such that is always finite but cannot be expressed as a polynomial-time evaluable function in , , and .
We can clear the integer denominators in (6) by cross multiplications. The condition
can be expressed with existential quantifiers. Thus we obtain a 3-parametric PA formula , which defines a family . The set of satisfying values is finite by . Now assume is a polynomial-time evaluable function . Then given any AP-COVER instance, we can compute in polynomial time from the ’s, and then evaluate in polynomial time to check whether . This contradicts . ∎
It remains to reduce the three parameters to two. To do this, we will adapt a trick of Glivický and Pudlák . Their context is slightly different from ours in that they use nonstandard integers rather than parameters that range over , and that their results involve computability rather than complexity. However their key idea and its proof apply in our context. The two parameters that will be involved are
For convenience, we will assume for the rest of Section that all the parameters in our formulas ( and ) only take nonnegative integer values. Although in other parts of this paper the parameters are assumed to range over , this restriction does not affect the hardness results we are proving here.
[7, §3.2] For , the three multiplications can be defined by using just two multiplications and .
By definition, we have for all , so it remains to define the multiplications by and for . By the division algorithm, for every we can uniquely write
If , then and we can then solve to obtain . Thus for , the formula
is satisfied by the triple . Furthermore, for such this formula cannot be satisfied by any other values of the second and third arguments. ∎
We now prove some additional capabilities of the parameters , that will be required in order to transform the entire formula (6) into a formula in and alone.
The congruence relation modulo is definable using just the multiplications by and .
Let be the formula
Since , the condition is expressed as:
The constant is definable using just the multiplications by and .
Since , is the smallest positive integer such that . Since , we can express that a pair of variables satisfy by the formula
which we denote by .
Suppose , , and are positive integers such that . If and then .
First, we have
so . On the other hand, since we have:
This means , and thus . ∎
In order to apply Proposition 2.3, we must first multiply by every inequality in (6) that involves multiplication by or . This works because multiplications by , , and appear separately in (6). After doing so and clearing some denominators, we obtain the equivalent formula
(9) (10) (11) (12) (13)
It only remains to show that and are equivalent. We have:
This follows by rounding down both equations to the nearest integer and applying Lemma 2.6.
This is Lemma 2.4.
or in another form
So and are all equivalent. This finishes the proof of Theorem 1.14. ∎
The formula is satisfied only by those (see (7)). This formula defines a 2-parametric family . So the condition , which is equivalent to AP-COVER, cannot be expressed using polynomial-time relations in and . Similarly, any expansion of parametric PA with polynomial-time predicates cannot have full quantifier elimination. For otherwise we can apply it to the sentence and get an equivalent Boolean combination of polynomial-time relations in . ∎
3. Counting-universality of -parametric Presburger formulas
Consider a -parametric PA formula:
Here are the scalar parameters, are the free variables, are the quantified variables, are the quantifiers, and is a Boolean combination of linear inequalities in with coefficients and constants from . This formula defines a parametric family .
We say that a -parametric family counting-reduces to an -parametric family if there exists with such that for every we have:
Every -parametric PA family counting-reduces to another -parametric PA family with the same number of alternations. In other words, -parametric PA families are counting-universal.
First we prove the following lemma.
For every formula of the form (14), there exist such that for every value we have:
if and only if:
If then for every :
Here is the – norm. So stands for and stands for . Each restricted quantifier means exits/for all in the interval .444Here we understand that have positive values for all .
Consider a usual, non-parametric PA formula:
which defines some set . Recall Cooper’s quantifier elimination procedure for Presburger arithmetic (see ). Applying it to , we obtain an equivalent quantifier free formula , which may contain some extra divisibility predicates. By Theorem 2 of , after eliminating all quantifiers from , we obtain the following bounds:
is the number of distinct integers that appeared as coefficients or divisors in ,
is the largest absolute value of all integers that appeared in (coefficients + divisors + constants),
is the total number of atomic formulas in (inequalities + divisibilities),
and are the corresponding quantities for . Now assume and are fixed. Then we have:
where is fixed. So in this case has at most a fixed number of coefficients and divisors.
Denote by the common multiple of all divisors in . We have . Let be the lattice of consisting of whose coordinates are all divisible by . Fix some particular coset of and restrict to . Then in , all divisor predicates have fixed values (either true or false) as varies over . So over , the formula is just a Boolean combination of linear inequalities in , which represents a disjoint union of some rational polyhedra in . Each such polyhedron can be described by a system of fixed length, because there are only at most different coefficients for the variables. The integers in the system are also bounded by . We consider . By the fundamental theorem of Integer Programming555We are rescaling to before applying this bound. (see [12, Th. 16.4 and Th. 7.1]), we have: