Manuscript Offprint
arXiv:2610.19200A Simple Algorithm for Counting Solutions to Integer Programs
Abstract
We consider the problem of counting solutions to integer linear programming problems of the form where and . We present an algorithm that counts solutions with arithmetic operations. This simplifies the algorithm of Gribanov and Malyshev, who considered the problem for the more general setting in which is -modular.
Acknowledgements We thank the organizers of the workshop Phase Transitions in Combinatorics, Algorithms and Probability held at the CWI, Amsterdam in May 2026 for providing a fruitful research environment in which this work was initiated.
Centrum Wiskunde & Informatica (CWI), Amsterdam, The Netherlands, dadush@cwi.nl.
ETH Zürich, Zürich, Switzerland, anita.duerr@inf.ethz.ch.
Eindhoven University of Technology, Eindhoven, The Netherlands, t.l.s.hamm@tue.nl.
Bocconi University, Milan, Italy, jonas.schmidt2@phd.unibocconi.it.
Max Planck Institute for Informatics, Saarbrücken, Germany, kwegrzyc@mpi-inf.mpg.de. Supported by the Deutsche Forschungsgemeinschaft (DFG, German Research Foundation) grant number 559177164.
1 Introduction
Integer linear programming is a fundamental problem in discrete optimization and theoretical computer science. In this paper, we study the problem of computing the cardinality of
where and .
The corresponding feasibility problem asks whether is nonempty. Building on the seminal work of Lenstra and Kannan [13, 15], Reis and Rothvoss [17] gave a randomized algorithm deciding feasibility in time , where denotes the input size. Note, however, that these algorithms only determine whether a solution exists and do not compute the number of solutions. For the counting problem, the best known general-purpose method is Barvinok's algorithm [2, 3], which computes in time (see [6]).
These algorithms are exponential when is large. Gribanov and Malyshev [10] considered the regime in which is -modular, i.e., , where, using to denote the restriction of to a subset of its rows and a subset of its columns,
Gribanov and Malyshev [10] presented an algorithm computing using arithmetic operations, where is the maximum possible number of vertices in the polytope defined by as varies (see [10, Definition 2]). Since and , their bound simplifies to arithmetic operations. More recently, Gribanov, Shumilov, Malyshev, and Zolotykh [9] (see also [8]) gave an improved bound of arithmetic operations, where is the polytope dimension. Since , the same estimates for and give
in the parameters used here. In this work, we give a simpler algorithm with improved dependence on n, m, and .
Theorem 1.1. There exists an algorithm that computes with arithmetic operations .
Notice that in the packing case (i.e., when every entry of is non-negative), after handling zero columns separately, the value can be computed using arithmetic operations by dynamic programming, but even in this special case it is not clear how to avoid polynomial dependence on . For general , the feasibility problem under this parameterization was first studied by Papadimitriou [16]. Eisenbrand and Weismantel [7] proposed an -time algorithm. Jansen and Rohwedder [11] later improved this to a bound of . All of these methods rely on proximity results guaranteeing the existence of an integral solution close to the LP relaxation. This approach is challenging to apply in the counting setting.
Organization and Exposition. Our paper follows a slightly non-standard structure. We start by presenting the simpler packing case of Theorem 1.1 in Section 2. The algorithm is presented in the language that we discovered it in, namely using a generating function of and polynomial multiplications
To simplify the presentation, we bound the running time always in the number of arithmetic operations. In the standard word RAM model, the running time equals the stated bound increased by a factor of (see the discussion in Section 3).
and manipulations of polynomials. This language turns out to be convenient for expressing the operations that our algorithm performs. We find this surprising, since our algorithm does not rely on any specific deeper theory used in other counting algorithms such as Barvinok's algorithm [2,3]. (In fact, our algorithm even works with a different generating function.)
While allowing for an efficient presentation and interesting perspective, we find it less intuitive to grasp which operations the algorithm in Section 2 is actually performing and therefore harder to generalize (e.g., to the non-packing case). Thus, we believe that it adds value to present the generalized algorithm and full proof of Theorem 1.1 in a more traditional, dynamic-programming-based way in Section 3.
Based on this difference, readers may choose whether to read Section 2 or Section 3, as the main ideas are identical. The main difference is the need for the Steinitz lemma (see, [7]).
Lemma 2.1 (Fast Fourier Transform, [5, Chapter 30]). There is an algorithm that, given two m-variate polynomials and with degree at most per variable and represented by their monomials, computes the monomials of using operations.
The goal of this section is to prove the following statement.
Lemma 2.2. There exists an algorithm that computes with arithmetic operations when .
In this case, we use the characteristic function approach which was already used to simplify algorithms for the related Subset Sum problem [12].
Proof of Lemma 2.2. If some coordinate of is negative, then clearly . If contains any zero columns, we delete them and return if the algorithm detects at least one solution. Hence, for the remainder of the proof, we may assume that every column of is nonzero and .
The reader is invited to assume on the first read. For arbitrary , we use to denote variables . Let be a generating function of , more precisely:
where . Our goal is to compute the coefficient of in denoted by . Towards this goal, let be the -th column of , and define the polynomial
Let be an upper bound on the degree of each variable in . We observe the following.
Claim 2.3.
Proof. By the definition of and considering that is a solution to we have:
Next, we use the following identity that follows by the uniqueness of the binary expansion:
This means that can be represented in the following form
By taking out one factor of from this product, the final equality immediately follows:
From the above claim, we see that the coefficients of are functions of the coefficients of . In particular, contains all the information about .
We now present our recursive algorithm for computing coefficients of . Due to the nature of the recursive subproblems, the algorithm solves the more general problem of computing a target coefficient of the product of with another polynomial , where the original problem corresponds to . The input to the algorithm is the target coefficient , and the list of coefficients of and (recalling that represents implicitly).
Algorithm 1: Procedure COEFF: recursive coefficient extraction for Claim 2.4
Input: Polynomials and , and a vector
Output: The coefficient
1 if then
2 | return
3 Compute the monomials of via FFT (Lemma 2.1)
4 Group the monomials of by parity of exponents to compute the decomposition
5
6 return COEFF()
Claim 2.4. Let be an -variate polynomial where each variable has degree at most . Then, given and the monomials of and , we can compute:
with arithmetic operations.
Proof. By grouping monomials of we can represent it by uniquely determined polynomials as follows:
As is a polynomial of degree at most per variable, each polynomial for has degree at most per variable. Next, we use Claim 2.3 to notice that:
Let be such that for all . Then:
(Only even contribute)
Observe that is an m-variate polynomial where each variable has degree at most . So, we can compute the representation in (1) of using arithmetic operations with FFT (Lemma 2.1) and recursively compute .
We summarize the procedure in Algorithm 1. In each step of the recursion halves, so the depth of the recursion is . In the base case, we conclude that for we have . Indeed, since is non-negative and has no zero column, implies .
Now notice that we can compute the monomials of as follows.
Claim 2.5. The monomials of can be computed in arithmetic operations.
Proof. We recursively split the set of columns into two halves, compute the product of the terms in each half, and then multiply the two resulting polynomials.
This yields a binary tree of multiplications with depth . For each level of the tree, the degree per variable of the resulting polynomials is at most , and the number of polynomials at level is at most . Using FFT (Lemma 2.1), each multiplication takes operations. Summing over all levels, the total cost is bounded by
Hence, to compute , we first compute using Claim 2.5 and apply Claim 2.4 with . In total the number of arithmetic operations is
Notice that we used the assumption that is non-negative only in the base case of the recursion, where we trivially have . This is not necessarily 1 (or even finite!) in the case when has negative entries. In the next section, we show how to handle this using the Steinitz lemma.
3 Proof of Theorem 1.1
We will require the following bound on the size of solutions to an integer program. At a high level, the bound will be used to prove that a feasible integer program always has short solutions, and that long solutions only exist if there are infinitely many solutions.
Lemma 3.1. Let such that there is a solution to with
Then, the following holds:
-
There is a nonzero solution to with .
-
There is a nonzero with with .
The bound can be derived from standard results in integer programming, in particular using Graver bases and conformal decompositions. To make the paper more self-contained, we give a direct proof using the Steinitz lemma, which was introduced as tool for proving related size bounds by Eisenbrand and Weismantel [7, Section 2]. Intuitively, it states that a sequence of vectors that sum to a target b can be rearranged so that their partial sums remain in a tube of radius around the line segment between 0 and b.
Lemma 3.2 (Steinitz lemma, tube version [7, Section 2]). Let such that for all and . Then there exists a permutation such that for all partial sums :
Proof of Lemma 3.1. Examine the sequence of vectors derived by repeating the columns of the number of times they appear in . By the Steinitz lemma (Lemma 3.2), we can construct a rearranged sequence that sums to and whose prefix sums never leave the tube (2) around the line segment from to . Since the box contains the tube and has integer points, the number of integer points in the tube is at most .
Given that , by pigeon-hole we can find two distinct prefixes of the Steinitz sequence with equal partial sums and . The difference of their partial sums then satisfies , where and .
To prove property 1, examine . By construction, is a non-negative integer solution to with strictly smaller -norm than . Applying this procedure iteratively, replacing with the shorter at each step, we may continue until .
To prove property 2, we invoke property 1 of the Lemma when applied against the initial non-zero y found in the second paragraph of the proof.
To prove Theorem 1.1, we use a dynamic program that should be thought of as mostly equivalent to the polynomial approach in Section 2, except running for more iterations. Rohwedder and Węgrzycki [18] apply a similar dynamic programming technique for optimizing an ILP where variables are bounded. Their algorithm relies on proximity, which we avoid by using Lemma 3.1 directly.
Unlike in the packing case in Lemma 2.2, we need to be slightly more careful about checking if the answer is finite: It requires us to check feasibility and the existence of a cycle, that is, property 2 of Lemma 3.1. Both of these problems have standard solutions: A cycle can be found in polynomial time by solving an LP over the reals, and there are fast algorithms for checking feasibility [7]. To achieve a precise value of m in the exponent, we take a different route and do both of these checks with our dynamic programming techniques for counting (see Claim 3.3).
Proof of Theorem 1.1. Assume without loss of generality ; the case is either covered by the packing case (Lemma 2.2) or . Moreover, if and only if the greatest common divisor of the values of divides the right-hand side, which we simply check in the beginning.
In the following, we represent a multiset by storing the distinct set elements along with the number of their occurrences in binary.
Consider the following multiset for and
We observe that to compute , it suffices to compute the multisets and , where and is as defined in Lemma 3.1. In particular, is a positive integer and .
Claim 3.3. The following properties hold:
-
If , then .
-
If and occurs at least twice in , then .
-
In all other cases, occurs times in .
Proof. By Lemma 3.1, if then there must be a solution with . This must be counted in , proving property 1.
For property 2, notice that always occurs in because . Thus, a second occurrence of yields a nonzero vector with . If then there exists with , and thus contains infinitely many vectors of the form .
To prove property 3, suppose there is a solution such that is not represented in . This means that
and by Lemma 3.1 there must be a nonzero with and . Hence, both and are contained in , i.e., occurs at least twice in . So the assumptions of property 2 are satisfied, a contradiction.
The goal of the algorithm is therefore to compute the multisets and . Note that for any . We show how to efficiently compute from . Define the following multiset
We establish the following recurrence.
Claim 3.4.
Proof. The right-hand side clearly enforces the residue condition and is hence included in the left-hand side. For the other inclusion, consider with . Clearly, . Furthermore, define
Since , we have . Moreover
and since , we have . This shows that .
Additionally, observe that this mapping also defines a bijection, hence the number of occurrences of each element in the multisets match as well.
Algorithm 2: Our dynamic programming counting algorithm for Theorem 1.1
Input: A matrix and a vector
Output: The count
1 Compute
2 for do
3 Initialize
4 for do
5 Compute the multiset
6 if then
7 return 0
8 else if and occurs at least twice in then
9 return
10 else
11 return the number of occurrences of in
Our algorithm works as follows. First, compute and initialize . Then, iteratively compute and for using the previously computed transition (Claim 3.4). Using Claim 3.3 and the number of occurrences of in and of in , we can now deduce the correct value of , including whether it is infinite (see also Algorithm 2, the case is omitted there since it only influences log factors).
Finally, we prove the bound on the number of operations.
Claim 3.5. B can be computed using operations. Given and , can also be computed using operations.
Proof. The computation of proceeds similarly to Claim 2.5. Notice that any sum of at most column vectors of stays in the set . We use recursion to compute : Divide the set of columns into two roughly equal-sized parts and recursively compute including the counts for each vector for restricted to both parts. Finally, combine the two parts with (Lemma 2.1) to obtain the whole set . On recursion level , there are at most FFT instances with vectors in each. Since we assume , the cost per recursion level decreases geometrically, and we can bound the total number of operations by
To compute , we use Claim 3.4. Consider the box
Notice that , , and are all contained in . Moreover, contains only with , while and only contain with . Hence, all three sets are contained in a set of size , and we can compute using FFT. The number of operations is .
A well-known observation is that this operation is equivalent to multiplying two polynomials by treating the vector coordinates as exponents and the multiplicities as factors in front of the corresponding monomials. Hence, Lemma 2.1 applies.
In total, the algorithm requires one computation of and iterations. By Claim 3.5, each iteration requires operations. When , running the algorithm from Lemma 2.2 requires operations. This last term also bounds the total number of operations, since
Note that one factor only shows up in the case that , where our problem immediately reduces to Counting Unbounded Subset Sum with only positive elements.
Running Time Bound. We now argue how to transform the bound on the number of arithmetic operations as in Theorem 1.1 into a bound on the running time in, say, the word RAM model. To do so, it is sufficient to bound the size of the integers used in (intermediate) operations in the algorithm. Clearly, any vector handled by the algorithm is bounded by
Therefore, any intermediate matrix-vector-product Ax is still bounded by
The number of occurrences of any such vector in is bounded by . The number of occurrences in doubles at most in each iteration. Therefore, the counts handled in the algorithm are bounded by and the number of bits required to represent these number is
In total, this yields a running time of .
4 Conclusion
The dependence on is essentially tight, even in the packing case (Lemma 2.2): Knop, Pilipczuk and Wrochna [14] showed that even when , the existence of an algorithm running in time that decides whether would contradict the Exponential Time Hypothesis. Notice that the dependence on is also tight in the packing case. Namely, for every constant and , there is no algorithm running in time , assuming the Strong Exponential Time Hypothesis (see [4]). This was also observed by Jansen and Rohwedder [11] in the general case of .
AI Disclosure. AI tools (Codex with ChatGPT 5.6) were used for proofreading and suggesting improvements to the exposition. The authors assume full responsibility.
References
[1] A. Abboud, K. Bringmann, D. Hermelin, and D. Shabtay. SETH-based Lower Bounds for Subset Sum and Bicriteria Path. ACM Transactions on Algorithms, 18(1):6:1–6:22, 2022.
Bringmann et al. [4] actually showed that for every , m-dimensional Subset Sum is equivalent to Subset Sum, which by [1] yields SETH-hardness. Both of these results can be adapted to work for Unbounded Subset Sum variants.
[2] A. Barvinok and K. Woods. Short rational generating functions for lattice point problems. Journal of the American Mathematical Society, 16(4):957–979, 2003.
[3] A. I. Barvinok. A polynomial time algorithm for counting integral points in polyhedra when the dimension is fixed. Mathematics of Operations Research, 19(4):769–779, 1994.
[4] K. Bringmann, A. Dürr, and K. Wegrzycki. Tight (S)ETH-based lower bounds for pseudopolynomial algorithms for bin packing and multi-machine scheduling. In Proceedings of the 58th Annual ACM Symposium on Theory of Computing, STOC 2026, pages 2094–2105. ACM, 2026.
[5] T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein. Introduction to Algorithms, 3rd Edition. MIT Press, 2009.
[6] M. Dyer and R. Kannan. On Barvinok's algorithm for counting lattice points in fixed dimension. Mathematics of Operations Research, 22(3):545–549, 1997.
[7] F. Eisenbrand and R. Weismantel. Proximity results and faster algorithms for integer programming using the Steinitz lemma. ACM Transactions on Algorithms, 16(1):1–14, 2019.
[8] D. Gribanov, D. Malyshev, P. M. Pardalos, and S. Zolotykh. A new and faster representation for counting integer points in parametric polyhedra. Computational Optimization and Applications, 92(3):811–861, 2025.
[9] D. Gribanov, I. Shumilov, D. Malyshev, and N. Zolotykh. Faster algorithms for sparse ilp and hypergraph multi-packing/multi-cover problems. Journal of Global Optimization, 89(4):1033–1067, 2024.
[10] D. V. Gribanov and D. S. Malyshev. A faster algorithm for counting the integer points number in -modular polyhedra. Siberian Electronic Mathematical Reports, 19(2):613–626, 2022. Corrected version available as arXiv:2110.01732.
[11] K. Jansen and L. Rohwedder. On integer programming, discrepancy, and convolution. Mathematics of Operations Research, 48(3):1481–1495, 2023. Announced in ITCS 2019.
[12] C. Jin and H. Wu. A simple near-linear pseudopolynomial time randomized algorithm for Subset Sum. In 2nd Symposium on Simplicity in Algorithms, page 17, 2019.
[13] R. Kannan. Improved algorithms for integer programming and related lattice problems. In Proceedings of the fifteenth annual ACM symposium on Theory of computing, pages 193–206, 1983.
[14] D. Knop, M. Pilipczuk, and M. Wrochna. Tight complexity lower bounds for integer linear programming with few constraints. ACM Transactions on Computation Theory, 12(3):1–19, 2020.
[15] H. W. Lenstra Jr. Integer programming with a fixed number of variables. Mathematics of operations research, 8(4):538–548, 1983.
[16] C. H. Papadimitriou. On the complexity of integer programming. Journal of the ACM (JACM), 28(4):765–768, 1981.
[17] V. Reis and T. Rothvoss. The subspace flatness conjecture and faster integer programming. In 2023 IEEE 64th Annual Symposium on Foundations of Computer Science (FOCS), pages 974–988. IEEE, 2023.
[18] L. Rohwedder and K. Wegrzycki. Fine-grained equivalence for problems related to integer linear programming. In 16th Innovations in Theoretical Computer Science Conference (ITCS 2025), pages 83–1. Schloss Dagstuhl–Leibniz-Zentrum für Informatik, 2025.