New techniques for linear arithmetic: cubes and equalities

We present several new techniques for linear arithmetic constraint solving. They are all based on the linear cube transformation, a method presented here, which allows us to efficiently determine whether a system of linear arithmetic constraints contains a hypercube of a given edge length. Our first findings based on this transformation are two sound tests that find integer solutions for linear arithmetic constraints. While many complete methods search along the problem surface for a solution, these tests use cubes to explore the interior of the problems. The tests are especially efficient for constraints with a large number of integer solutions, e.g., those with infinite lattice width. Inside the SMT-LIB benchmarks, we have found almost one thousand problem instances with infinite lattice width. Experimental results confirm that our tests are superior on these instances compared to several state-of-the-art SMT solvers. We also discovered that the linear cube transformation can be used to investigate the equalities implied by a system of linear arithmetic constraints. For this purpose, we developed a method that computes a basis for all implied equalities, i.e., a finite representation of all equalities implied by the linear arithmetic constraints. The equality basis has several applications. For instance, it allows us to verify whether a system of linear arithmetic constraints implies a given equality. This is valuable in the context of Nelson–Oppen style combinations of theories.


Introduction
Polyhedra and the systems of linear arithmetic constraints Ax ≤ b defining them have a vast number of theoretical and real-world applications [5,19].It is, therefore, no surprise that the theory of linear arithmetic is one of the most popular and best investigated theories for satisfiability modulo theories (SMT) solving [14][15][16].
This paper serves as a collection of our results based on the linear cube transformation.On its own, the linear cube transformation allows us to efficiently determine whether a system of linear arithmetic constraints contains a hypercube of a given edge length.We were able to develop several techniques based on this transformation that allow us to investigate linear arithmetic constraints in various ways.Here, we present our previous results [7,8] on the linear cube transformation in more detail as well as some new applications (e.g., quantifier elimination).
Finding an integer solution for a polyhedron that is defined by a system of linear inequalities Ax ≤ b is a well-known NP-complete problem [25].This problem has been investigated in different research areas, e.g., in optimization via (mixed) integer linear programming (MILP) [19] and in constraint solving via satisfiability modulo theories (SMT) [4,6,11,16].For commercial MILP implementations, it is standard to integrate preprocessing techniques, heuristics, and specialized tests [19].Although these techniques are not complete, they are much more efficient on their designated target systems of linear inequalities than a complete algorithm alone.
The SMT community is still in the process of developing a variety of specialized tests.A big challenge is to adopt the tests from the MILP community so that they still fit the requirements of SMT solving.SMT theory solvers have to solve a large number of incrementally connected, small systems of linear inequalities.Exploiting this incremental connection is key for making SMT theory solvers efficient [15].In contrast, MILP solvers typically target one large system.The same holds for their specialized tests, which are not well suited to exploit incremental connections.
Based on the linear cube transformation, we present two tests tailored for SMT solvers: the largest cube test and the unit cube test [8].The largest cube test finds a hypercube with maximum edge length contained in the input polyhedron, determines its rational valued center, and rounds it to a potential integer solution.The unit cube test determines if a polyhedron contains a hypercube with edge length one, which is the minimal edge length that guarantees an integer solution.Due to computational complexity, we restrict ourselves to those hypercubes that are parallel to the coordinate axes.
Most SMT linear integer arithmetic theory solvers are based on a branch-and-bound algorithm on top of the simplex algorithm.They search for a solution at the surface of a polyhedron.In contrast, our tests search in the interior of the polyhedron.This gives them an advantage on polyhedra with a large number of integer solutions, e.g., polyhedra with infinite lattice width [20].
SMT theory solvers are designed to efficiently exchange bounds [14].This efficient exchange is the main reason why SMT theory solvers exploit the incremental connection between the different polyhedra so well.Our unit cube test also requires only an exchange of bounds.After applying the test, we can easily recover the original polyhedron by reverting to the original bounds.In doing so, the unit cube test conserves the incremental connection between the different original polyhedra.We make a similar observation about the largest cube test.
Equalities are a special instance of linear arithmetic constraints.They are useful in simplifying systems of arithmetic constraints [16], and they are essential for the Nelson-Oppen style combinations of theories [9].However, they are also an obstacle for our fast cube tests.If a system of linear arithmetic constraints implies an equality, then it has only a surface and no interior; so our cube tests cannot explore an interior and will certainly fail.In order to expand the applicability of our cube tests, we have to develop methods that find, isolate, and eliminate implied equalities from systems of linear arithmetic constraints [7].
We can detect the existence of an implied equality by searching for a hypercube in our polyhedron.If the maximal edge length of such a hypercube is zero, there exists an implied equality.This test can be further simplified.By turning all inequalities into strict ones, the interior of the original polyhedron remains while the surface disappears.If the strict system is unsatisfiable, the original system has no interior and implies an equality.Based on an explanation of unsatisfiability for the strict system, the method generates an implied equality as an explanation.
We are also able to extend the above method into an algorithm that computes an equality basis, i.e., a finite representation of all equalities implied by a satisfiable system of linear arithmetic constraints.For this purpose, the algorithm repeatedly applies the above method to find, collect, and eliminate equalities from our system of constraints.When the system contains no more equalities, then the collected equalities represent an equality basis, i.e., any implied equality can be obtained by a linear combination of the equalities in the basis.The equality basis has many applications.If transformed into a substitution, it eliminates all equalities implied by our system of constraints, which results in a system of constraints with an interior and, therefore, improves the applicability of our cube tests.The equality basis also allows us to test whether a system of linear arithmetic constraints implies a given equality.We even extend this test into an efficient method that computes all pairs of equivalent variables inside a system of constraints.These pairs are necessary for the Nelson-Oppen style combination of theories.
While Hillier [17] was aware of the unit cube test, he applied it only to cones (a special class of polyhedra) as a subroutine in a new heuristic.His work never mentioned applications beyond cones, nor did he prove any structural properties connected to hypercubes.Hillier's heuristic tailored for MILP optimization lost popularity as soon as interior point methods [21] became efficient in practice.Nonetheless, our cube tests remain relevant for SMT theory solvers because there are no competitive incremental interior point methods known.Also, Bobot et al. [4] discuss relations between hypercubes and polyhedra including infinite lattice width and positive linear combinations between inequalities.Our largest cube test can also detect these relations because it is, with some minor changes, the dual of the linear optimization problem of Bobot et al.In contrast to the linear optimization problem of Bobot et al., our tests are closer to the original polyhedron and, therefore, easier to construct.Our cube tests also produce sample points and find solutions for polyhedra with finite lattice width.
Another method that provides a sufficient condition for the existence of an integer solution is the dark shadow of the omega test [26].The dark shadow is based on Fourier-Motzkin elimination and its worst case runtime is double exponential.Although not practically advantageous, formulating the unit cube test through Fourier-Motzkin elimination allows us to put the sufficient conditions of the two methods in relation.Fourier-Motzkin elimination eliminates the variable x from a problem by combining each pair of inequalities ax ≤ p and q ≤ bx (with a, b > 0) into a new inequality aq − bp ≤ 0. The dark shadow creates a stronger version (aq − bp ≤ a + b − ab) of the combined inequality to guarantee the existence of an integer solution for x.Formulating the unit cube test through Fourier-Motzkin elimination makes the combined inequality even stronger (aq − bp ≤ −ab).This means that the sufficient condition of the dark shadow subsumes the condition of the unit cube test.
Still, our unit cube test is definable as a linear program and it is, therefore, computable in polynomial time.So the better condition of the dark shadow comes at the cost of being much harder to compute.
There also already exist several methods that find, isolate, and eliminate implied equalities [3,27,31,32].Hentenryck and Graf [32] define unique normal forms for systems of linear constraints with non-negative variables.To compute a normal form, they first eliminate all implied equalities from the system.To this end, they determine the lower bound for each inequality by solving one linear optimization problem.Similarly, Refalo [27] describes several incremental methods that use optimization to turn a satisfiable system of linear constraints in "revised solved form" into a system without any implied equalities.Rueß and Shankar also use this optimization scheme to determine a basis of implied equalities [28].Additionally, they present a necessary but not sufficient condition for an inequality to be part of an equality explanation.During preprocessing, all inequalities not fulfilling this condition are eliminated, thus, reducing the number of optimization problems their method has to compute.However, this preprocessing step might be in itself expensive because it relies on a non-trivial fixed-point scheme.The method presented by Telgen [31] does not require optimization.He presents criteria to detect implied equalities based on the tableau used in the simplex algorithm, but he was not able to formulate an algorithm that efficiently computes these criteria.In the worst case, he has to pivot the simplex tableau until he has computed all possible tableaux for the given system of constraints.Another method that detects implied equalities was presented by Bjørner [3].He uses Fourier Motzkin variable elimination to compute linear combinations that result in implied equalities.
Our methods that detect implied equalities do not require optimization, which is advantageous because SMT solvers are usually not fine-tuned for optimization.Moreover, we defined our methods for a rather general formulation of linear constraints, which allows us to convert our results into other representations, e.g., the tableau-and-bound representation used in Dutertre and de Moura's version of the simplex algorithm (see Sect. 7), while preserving efficiency.Finally, our method efficiently searches for implied equalities.We neither have to check each inequality independently nor do we have to blindly pivot the simplex tableau.This also makes potentially expensive preprocessing techniques obsolete.
The paper is organized as follows: we define in Sect. 3 the linear cube transformation (Proposition 3) that allows us to efficiently compute whether a polyhedron contains a hypercube of a given edge length by solely changing the bounds of the inequalities.Based on this transformation, we develop in Sect. 4 two tests: the largest cube test and the unit cube test.Both tests find integer solutions for linear arithmetic constraints.For polyhedra with infinite lattice width, both tests always succeed (Lemma 4).Inside the SMT-LIB benchmarks, there are almost one thousand problem instances with infinite lattice width, and we show the advantage of our cube tests on these instances by comparing our implementation of the cube test with several state-of-the-art SMT solvers in Sect. 5.In Sect.6, we show how to investigate equalities with the linear cube transformation.First, we introduce an efficient method for testing whether a system of linear arithmetic constraints implies a given equality (Sect.6.1).Then, we extend the method so that it computes an equality basis for our system of constraints (Sect.6.2).In Sect.7 we start with an implementation of our methods as an extension of Dutertre and de Moura's version of the simplex algorithm [14], which is integrated in many SMT solvers.The implementation generates justifications and preserves incrementality.The efficient computation of an equality basis can then be used in identifying equivalent variables for the Nelson-Oppen combination of theories.Section 8 concludes the paper including a further application of the linear cube transformation to quantifier elimination.

Preliminaries
While the difference between matrices, vectors, and their components is always clear in context, we generally use upper case letters for matrices (e.g., A), lower case letters for vectors (e.g., x), and lower case letters with an index i or j (e.g., b i , x j ) as components of the associated vector at position i or j, respectively.The only exceptions are the row vectors a T i = (a i1 , . . ., a in ) of a matrix A = (a 1 , . . ., a m ) T , which already contain an index i that indicates the row's position inside A. In order to save space, we write vectors only implicitly as columns via the transpose operator ( ) T , which turns all rows (b 1 , . . ., b m ) into columns (b 1 , . . ., b m ) T and vice versa.We also abbreviate the n-dimensional origin (0, . . ., 0) T as 0 n .Likewise, we abbreviate (1, . . ., 1) T as 1 n .
In the context of SMT solvers, we have to deal with strict inequalities a T i x < b i and non-strict inequalities a T i x ≤ b i as our constraints, where a i ∈ Q n and b i ∈ Q.A system of constraints is, therefore, just a set of inequalities and the rational solutions of this system are exactly those points x ∈ Q n that satisfy all inequalities in this set.The rational solutions of this system also define a polyhedron in the Q n , where each rational solution is equivalent to a point in the polyhedron.For this reason, we treat polyhedra and their definitions through a system of inequalities as interchangeable.In the case that our system contains only non-strict inequalities, the polyhedron is even closed convex, which entails two very useful properties: firstly, the closed convex polyhedron has a surface if it is neither empty nor encompasses the whole Q n ; secondly, any supremum h max = sup{h T x : x ∈ Q n satisfies Ax ≤ b} is either h max = −∞ because there exists no point satisfying our constraints, h max = ∞ because the supremum is unbounded, or there exists an actual maximum, i.e., there exists an x ∈ Q n that satisfies the constraints and its cost h T x is equivalent to our supremum h max .
If we also consider strict inequalities, then our polyhedron is no longer necessarily a closed convex set.This means we lose the above properties, which poses a problem when we want to adapt algorithms that originally deal only with non-strict inequalities so they can also deal with strict inequalities.For instance, the classical dual simplex algorithm [29] returns only rational solutions on the surface of the polyhedron defined by Ax ≤ b.It is, therefore, not trivial to adapt the classical dual simplex algorithm to also handle strict inequalities.
To avoid these problems, we instead model strict inequalities as non-strict inequalities by generalizing the field Q for our inequality bounds b i and variables x i to Q δ [14].
As a result of this observation, δ is expressed symbolically as an infinitesimal parameter.This leads to the ordered vector space Q δ that has pairs of rationals as elements ( p, q) ∈ Q × Q, representing p + qδ, with the following operations: where a ∈ Q [14].Now we can represent a T i x < b i by a T i x ≤ b i − δ, where a i ∈ Q n and b i ∈ Q.Since we also let the assignments for our variables range over Q δ , the solutions of our inequalities describe a closed convex polyhedron in the Q n δ and methods like the classical simplex algorithm are again complete.It is also easy to extract a purely rational solution v ∈ Q n from a δ-rational solution v ∈ Q n δ of Ax ≤ b.We just have to choose a small enough value δ ∈ Q and replace the parameter δ with this value (Lemma 1).Therefore, we call a δ-rational solution just a rational solution.Representing our strict inequalities as non-strict inequalities also allows us to use the second property listed above for closed convex polyhedra: any supremum h max = sup{h T x : x ∈ Q n δ satisfies Ax ≤ b} is either h max = −∞, h max = ∞, or there exists an actual maximum and not just a limit.This property is especially useful on techniques based on optimization like the largest cube test (see Sect. 4.1).
With the δ-rationals, we are now able to formally define a system of constraints as Ax ≤ b.Ax ≤ b is just an abbreviation for the set of inequalities {a T 1 x ≤ b 1 , . . ., a T m x ≤ b m }.The row coefficients are given by A = (a 1 , . . ., a m ) T ∈ Q m×n , the variables are given by x = (x 1 , . . ., x n ) T , and the inequality bounds are given by b = (b 1 , . . ., b m ) T ∈ Q m δ .Moreover, we assume that any constant rows a i = 0 n were eliminated from our system during an implicit preprocessing step.This is a trivial task and eliminates some unnecessarily complicated corner cases.The δ-coefficients q i in the bounds b i = p i + q i δ can take on any value in Q δ .In case q i = 0, the inequality a T i x ≤ b i is equivalent to the non-strict inequality a T i x ≤ p i .In case q i < 0, the inequality a T i x ≤ b i is equivalent to the strict inequality a T i x < p i .In case q i > 0, we have no clear interpretation over the actual rationals (compare also Lemma 1).For instance, the two inequalities x ≤ δ and −x ≤ −δ describe a satisfiable system of constraints in Q δ , but there is no clear way of interpreting x ≤ δ in Q. Beware also that our linear cube transformation can introduce positive δ-coefficients in the bounds.But since we derive the transformation via a semantically clear construction, the semantic interpretation over the rationals is still discernible if the original system has only non-positive δ-coefficients in its inequality bounds before the transformation.
For the remainder of the paper, we abbreviate with b δ i the strict version of a given bound b i ∈ Q δ .If the bound b i is non-strict, i.e., b i = ( p i , 0), then the strict version is b δ i := ( p i , −1).Otherwise, the bound b i is already strict, i.e., b i = ( p i , q i ) with q i < 0, and we just standardize the δ-coefficient to −1, i.e, b δ i := ( p i , −1).Since Ax ≤ b and A x ≤ b are just sets, we can write their combination as (Ax ≤ b) ∪ (A x ≤ b ).A special system of inequalities is a system of equations Dx = c, which is equivalent to the combined system of inequalities (Dx ≤ c) ∪ (−Dx ≤ −c).For such a system of equalities, the row coefficients are given by D = (d 1 , . . ., d m ) T ∈ Q m×n , the variables are given by x = (x 1 , . . ., x n ) T , and the equality bounds are given by c We denote by P A b = {x ∈ Q n δ : Ax ≤ b} the set of δ-rational solutions to the system of inequalities Ax ≤ b and, therefore, the points inside the polyhedron.Similarly, we denote by 2 the set of points contained in the ndimensional hypercube that is parallel to the coordinate axes, has edge length e ∈ Q δ (with e ≥ 0), and has center z ∈ Q n δ .For the remainder of this paper, we consider only hypercubes that are parallel to the coordinate axes.For simplicity, we call these restricted hypercubes cubes.
Besides cubes and polyhedra, we use two norms in this paper.The first norm we use is the maximum norm.It is defined by: x ∞ = max {|x 1 |, . . ., |x n |}, and we use it because it is closely related to our definition of cubes C e (z), i.e., the condition in the definition of C e (z) can also be expressed with the maximum norm: The second norm we use is the 1-norm, which is defined by: x 1 = (|x 1 | + . . .+ |x n |).We use it in Sect. 3 to define the linear cube transformation.
Using the maximum norm, we define a closest integer to x as a point x ∈ Z n with minimal distance x − x ∞ .We also define the operators x j and x such that they describe a closest integer to x j and x, respectively.Formally, this means that x = ( x 1 , . . ., x n ) T and This definition of x is also known as simple rounding.
x is a closest integer to x, or formally: We say that a polyhedron implies an inequality h T x ≤ g, where h ∈ Q n , h = 0 n , and g ∈ Q δ , if h T x ≤ g holds for all x ∈ P A b .In the same manner, a polyhedron implies an equality h T x = g, where h ∈ Q n , h = 0 n , and g ∈ Q, if h T x = g holds for all x ∈ P A b .An equality implied by Ax ≤ b is explicit if the inequalities h T x ≤ g and −h T x ≤ −g appear in Ax ≤ b.Otherwise, the equality is implicit.Polyhedra implying equalities have only surface points and, therefore, neither an interior nor a center.Thus, all cubes that fit into a polyhedron implying an equality d T x = c with d = 0 n have edge length zero.
In Sect.6, we present a method that detects whether a polyhedron implies an equality at all and returns one such equality.To prove the correctness of this method, we use Farkas' Lemma [5].But first we have to proof that Farkas' Lemma works with δ-rationals: Lemma 2 Ax ≤ b is unsatisfiable iff there exists a y ∈ Q m with y ≥ 0 m and y T A = 0 n so that y T b < 0, i.e., there exists a non-negative linear combination of inequalities in Ax ≤ b that results in an inequality y T Ax ≤ y T b that is constant and unsatisfiable.
Proof Let us first consider the case where Ax ≤ b is unsatisfiable.Dutertre and de Moura's version of the dual simplex algorithm is a complete and correct algorithm for determining the satisfiability of a linear arithmetic problem over the δ-rationals [14].In case the problem is unsatisfiable, the algorithm returns a conflict explanation, which can be turned, together with the final simplex tableau, into the non-negative linear combination y ∈ Q m we are looking for.Let us now consider the case where x ∈ Q n δ is a solution for Ax ≤ b.If x is a solution to the inequalities in Ax ≤ b, then it is also a solution to any non-negative linear combination of inequalities in Ax ≤ b.
Our method that detects implied equalities transforms our original polyhedron Ax ≤ b into a second polyhedron A x ≤ b that is unsatisfiable if Ax ≤ b implies an equality.We also show how to extract an equality implied by Ax ≤ b from a minimal set C of unsatisfiable inequalities in A x ≤ b .We call an unsatisfiable set C of inequalities minimal if every proper subset C ⊂ C is satisfiable.If a polyhedron Ax ≤ b is unsatisfiable, there exists a minimal set C of unsatisfiable inequalities so that every inequality in C appears also in Ax ≤ b [14].We call such a minimal set C an explanation for Ax ≤ b's unsatisfiability.In case we are investigating a minimal set of unsatisfiable inequalities, we can refine Farkas' Lemma: Then it holds for every y ∈ Q m with y ≥ 0 n , y T A = 0 n , and y T b < 0 that y i > 0 for all i ∈ {1, . . ., m}.

Fitting cubes into polyhedra
We say that a cube C e (z) fits into a polyhedron defined by Ax ≤ b if all points inside the cube C e (z) are solutions of Ax ≤ b, or formally: C e (z) ⊆ P A b .In order to compute this, we transform the polyhedron Ax ≤ b into another polyhedron Ax ≤ b .For this new polyhedron, we merely have to test whether the cube's center point z is a solution (z ∈ P A b ) in order to also determine whether the cube C e (z) fits into the original polyhedron.This is a simple test that requires only evaluation.We call this entire transformation the linear cube transformation.
We start explaining the linear cube transformation by looking at the case where the polyhedron is defined by a single inequality We can think of a T i x as an objective function that we want to maximize and see b i as a guard for the maximum objective of any solution in the cube.Thus, we can express the universal quantifier in the above equation as an optimization problem (see Fig. 1a): max{a T i x : x ∈ C e (z)} ≤ b i .This also means that all points in x ∈ C e (z) satisfy the inequality } for the objective function a T i x satisfies the inequality a T i x * ≤ b i .Since every cube is a bounded polyhedron, one of the points with maximum objective value is a vertex x v ∈ C e (z).A vertex x v of the cube C e (z) is one of the points with maximum distance to the center z (see Fig. 1b), or formally: T .If we insert the above equation into the objective function a T i x, we get: j=1 ±a i j , which in turn is maximal if we choose x v such that ±a i j is always positive: Hence, we transform the inequality Proposition 2 Let C e (z) be a cube and a T i x ≤ b i be an inequality.
Next, we look at the case where multiple inequalities  Until now, we have discussed how to use the linear cube transformation to determine if one cube C e (z) with fixed center point z fits into a polyhedron.A generalization of this problem determines whether a polyhedron Ax ≤ b contains a cube of edge length e at all.Actually, a closer look at the transformed polyhedron Ax ≤ b reveals that the linear cube transformation (b i = b i − e 2 a i 1 ) is dependent only on the edge length e of the cube.Therefore, the solutions P A b of the transformed polyhedron Ax ≤ b are exactly all center points of cubes with edge length e that fit into the original polyhedron Ax ≤ b (see Fig. 1c).By determining the satisfiability of the transformed polyhedron Ax ≤ b , we can now also determine whether a polyhedron Ax ≤ b contains a cube of edge length e at all.If we choose a suitable algorithm, e.g., the simplex algorithm, then we even get the center point z of a cube C e (z) that fits into Ax ≤ b.This observation is the foundation for the cube tests that we present in Sect. 4.

A polyhedron Ax ≤ b has an integer solution if and only if P
, if the set of rational solutions contains an integer point.In this section, we show how to use the linear cube transformation to find such an integer solution.In contrast to arbitrary polyhedra, determining whether a cube C e (z) contains an integer point is easy.Because of the cubes symmetry, it is enough to test whether it contains a closest integer point z to the center z.

Proposition 4 A cube C e (z) contains an integer point if and only if it contains a closest integer point z to the center z.
Note that every point z ∈ Q n δ is also a cube C 0 (z) of edge length 0. In order to be efficient, our tests look only at cubes with special properties.In the case of the largest cube test, we check for an integer solution in one of the largest cubes fitting into the polyhedron Ax ≤ b.In the case of the unit cube test, we look for a cube of edge length one, which always guarantees an integer solution.Due to these restrictions, both tests are not complete but very fast to compute.

Largest cube test
A well-known test, implemented in most ILP solvers, is simple rounding.For simple rounding, the ILP solver computes a rational solution x for a set of inequalities, rounds it to a closest integer x , and determines whether this point is an integer solution.Not all types of rational solutions are good candidates for this test to be successful.Especially surface points, such as vertices, the usual output of the simplex algorithm, are not good candidates for rounding.For many polyhedra, center and interior points z are a better choice because all integer points adjacent to z are solutions, including a closest integer point z .
We now use the linear cube transformation (Sect.3) to calculate a rational center point with the simplex algorithm.The center point we calculate is the center point of a largest cube that fits into the polyhedron Ax ≤ b (see Fig. 2a).We determine the center z of this largest cube and the associated edge length e with the following linear program (LP): maximize x e subject to Ax + a x e 2 ≤ b, where a i = a i 1 x e ≥ 0 .This linear program employs the linear cube transformation from Sect. 3. The only generalization is a variable x e for the edge length instead of a constant value e.Additionally, this linear program maximizes the edge length as an optimization goal.If the resulting maximum edge length is unbounded, the original polyhedron contains cubes of arbitrary edge length (see Fig. 2b) and, thus, infinitely many integer solutions.Since the linear program contains all solutions of the original polyhedron (see x e = 0), the original polyhedron is empty if and only if the above linear program is infeasible.If the maximum edge length is a finite value e, we use the resulting assignment z for the variables x as a center point and C e (z) is a largest cube that fits into the polyhedron.From the center point, we round to a closest integer point z and determine if it fits into the original polyhedron.If this is the case, we are done because we have found an integer solution for Ax ≤ b.Otherwise, the largest cube test does not know whether or not Ax ≤ b has an integer solution.An example for the latter case, are the following inequalities: 3x 1 − x 2 ≤ 0, −2x 1 − x 2 ≤ −2, and −2x 1 + x 2 ≤ 1.These inequalities have exactly one integer solution (1, 3) T , but the largest cube contained by the inequalities has edge length e = 3  17 and center point ( 3 17 , 3  2 ) T , which rounds to (0, 2) T .
The largest cube test also upholds the incremental advantages of Dutertre and de Moura's version of the dual simplex algorithm [14].The only difference is the extra column a x e 2 , which the theory solver can internally create while it is notified of all potential arithmetic literals.Adding this column from the start does not influence the correctness of the solution because x e ≥ 0 guarantees that the largest cube test is satisfiable exactly when the original inequalities Ax ≤ b are satisfiable.Even for explanations of unsatisfiability, it suffices to remove the bound x e ≥ 0 to obtain an explanation for the original inequalities Ax ≤ b.The only disadvantage is the additional variable x e , which only shrinks the search space when it is increased.Therefore, increasing x e can never resolve any conflicts during the satisfiability search.The simplex solver recognizes this with at least one additional pivot that sets x e to 0. Hence, adding the extra column a x e 2 from the beginning has only constant influence on the theory solver's run-time, and is therefore negligible.

Unit cube test
Most SMT solvers implement a simplex algorithm that is specialized towards feasibility and not towards optimization [1,14,16,24].Therefore, a test based on optimization, such as the largest cube test, does not fit well with existing implementations.As an alternative, we have developed a second test based on cubes that does not need optimization.
We avoid optimization by fixing the edge length e to the value 1 for all the cubes C e (z) we consider (see Fig. 2c).We do so because cubes C 1 (z) of edge length 1 are the smallest cubes to always guarantee an integer solution, independent of the center point z.A cube with edge length 1 is also called a unit cube.To prove this guarantee, we first fix e = 1 in the definition of cubes, , and look at the following property for the rounding operator .: We see that any unit cube contains a closest integer z to its center point z.Furthermore, 1 is the smallest edge length that guarantees an integer solution for a cube with center point z = (. . ., 1  2 , . ..)T .Thus, 1 is the smallest value that we can fix as an edge length to guarantee an integer solution for all cubes C 1 (z).
Our second test tries to find a unit cube that fits into the polyhedron Ax ≤ b and, thereby, a guarantee for an integer solution for Ax ≤ b.Again, we employ the linear cube transformation from Sect. 3 and obtain the linear program: In addition to being a linear program without an optimization objective, we only have to change the row bounds b i of the original inequalities.In Dutertre and de Moura's version of the dual simplex algorithm [14], which is implemented in many SMT solvers [1,14,16,24], such a change of bounds is already part of the framework so that integrating the unit cube test into theory solvers is possible with only minor adjustments to the existing implementation.Since our unit cube test requires only an exchange of bounds, we can easily return to the original polyhedron by reverting the bounds.In doing so, the unit cube test upholds the incremental connection between the different original polyhedra.

Mixed linear integer and rational arithmetic
We can also extend our cube tests to the theory of mixed linear integer and rational arithmetic.In this theory, we partition our variables x = (x 1 , . . ., x n ) T into two vectors: the integer variables x Z = (x Z 1 , . . ., x Z k ) T and the rational variables Based on this partitioning, we also split the coefficient matrix A into two matrices A = (S, R), where S = (s 1 , . . ., s m ) T ∈ Q m×k defines the coefficients for the integer variables and R = (r 1 , . . ., r m ) T ∈ Q m×t defines the coefficients for the rational variables.The system has a solution if there exists an integer assignment for the variables x Z and a rational assignment for the variables x Q that satisfies our system of inequalities s T i x Z +r T i x Q ≤ b i (for i = 1, . . ., m).Because only integer variables need to be assigned to integer values, tests like simple rounding should be restricted to integer variables.For instance, if z is a rational solution for the overall polyhedron, then simple rounding applies .only to the components z Z of z that correspond to integer variables.The same holds for our fast cube tests.Instead of looking for hypercubes of the same dimension n as the number of total variables, we are looking for hypercubes of dimension k that expand in the directions that correspond to integer variables, but are flat in the directions that correspond to rational variables.Such a hypercube of dimension n1 with center point z is defined as the set: We can also modify the linear cube transformation so that we can compute whether a polyhedron Sx Z + Rx Q ≤ b contains a hypercube F e (z) that is less than full dimensional:

Proposition 5 Let F e (z) be a flat cube of dimension k and Sx
Since the hypercube F e (z) only expands in the directions that correspond to integer variables, the inequality bounds b of the modified linear cube transformation are only influenced by the coefficients of the integer variables.Using Proposition 5, we can now modify our fast cube tests so that they work for mixed linear integer and rational arithmetic.For the largest cube test, we compute the center point of a largest cube F e (z) that is flat in the directions that correspond to rational variables and fits into the polyhedron Sx Z + Rx Q ≤ b.We determine the center z of this largest cube and the associated edge length e with the following LP: maximize x e subject to Sx Z + Rx Q + s x e 2 ≤ b, where From the resulting center point z we receive a candidate mixed integer rational solution by applying the rounding operator .to the components z Z of z that correspond to integer variables.For the unit cube test, we search for a cube F 1 (z) that is flat in the directions that correspond to rational variables, has edge length 1, and fits into the polyhedron Sx Z + Rx Q ≤ b.A linear program that accomplishes this task is: Again, 1 is the smallest value that we can fix as an edge length to guarantee a mixed rational integer solution for all cubes F 1 (z).

Experiments
While our tests are useful for many types of polyhedra, the motivation for our tests stems from a special type of polyhedron, a so-called infinite lattice width polyhedron [20].A polyhedron Ax ≤ b has infinite lattice width if for every objective c ∈ Q n \ {0 n }, either its maximum or minimum objective value is unbounded: Polyhedra with infinite lattice width seem trivial at first glance because their interior expands arbitrarily far in all directions (see Fig. 2b).Therefore, a polyhedron with infinite lattice width contains an infinite number of integer solutions [20].Nonetheless, many SMT solvers are inefficient on those polyhedra because they use a branch-and-bound approach with an underlying simplex solver [14].Although such an approach terminates inside finite a priori bounds [25], it does not explore the infinite interior, but rather directs the search along the solutions suggested by the simplex solver: the vertices of the polyhedron.Thus, the SMT solvers concentrate their search on a bounded part of the polyhedron.This bounded part contains only a finite number of integer solutions, whereas the complete interior contains infinitely many integer solutions.The advantage of our cube tests is that they actually exploit the infinite interior because polyhedra with infinite lattice width contain cubes for every edge length (see Fig. 2b).Our tests are, therefore, always successful on polyhedra with infinite lattice width and usually need only a small number of pivoting steps before finding a solution.

Lemma 4 ([8]
) Let Ax ≤ b be a polyhedron.Let a ∈ Q m be a vector such that its components are a i = a i 1 .Then Ax ≤ b contains a cube C e (z) for every non-negative e ∈ Q δ if and only if Ax ≤ b has infinite lattice width.
We have found instances of polyhedra with the infinite lattice width property in some classes of the SMT-LIB benchmarks.These instances are 229 of the 233 dillig benchmarks designed by Dillig et al. [11], 503 of the 591 CAV-2009 benchmarks also by Dillig et al. [11], 229 of the 233 slacks benchmarks which are the dillig benchmarks extended with slack variables [18], and 19 of the 37 prime-cone benchmarks, that is, "a group of crafted benchmarks encoding a tight n-dimensional cone around the point whose coordinates are the first n prime numbers" [18].The remaining problems (4 from dillig, 88 from CAV-2009, 4 from slacks, and 18 from prime-cone) do not have infinite lattice width because they are either tightly bounded or unsatisfiable.For our experiments, we look only at the instances of those benchmark classes that actually fulfill the infinite lattice width property.
Using these benchmark instances, we have confirmed our theoretical assumptions (Lemma 4) in practice.We integrated the unit cube test into our own branch-and-bound solver SPASS-IQ (http://www.spass-prover.org/spass-iq) and ran it on the infinite lattice width instances; once with the unit cube test turned on (SPASS-IQ-0.1+uc)and once with the test turned off (SPASS-IQ-0.1).For every problem, SPASS-IQ-0.1+uc applies the unit cube test exactly once.This application happens before we start the branch-and-bound approach.We also compared our solver with state-of-the-art SMT solvers for linear integer arithmetic: cvc4-1.4[1], mathsat5-3.13[10], yices2.5.1 [13], and z3-4.4.1 [24].All these solvers employ a branch-and-bound approach with an underlying dual simplex solver [14].The only exception is mathsat5, which, subsequent to our first publication on the unit cube test [8], now also performs the unit cube test in advance.That is why we also test mathsat5 once with the unit cube test turned on (mathsat5-3.13+uc)and once with the test turned off (mathsat5-3.13).
The solvers had to solve each problem in under 10 min.For the experiments, we used a Debian Linux server with 32 Intel Xeon E5-4640 (2.4 GHz) processors and 512 GB RAM.Table 1 lists the results of the different solvers (column one) on the different benchmark classes (row one).Row two lists the number of benchmark instances we considered for our experiments.For each combination of benchmark class and solver, we have listed the number of instances the solver could solve in the given time as well as the total time (in seconds) of the instances solved (columns labelled with "solved" and "time", respectively).
Our solver that employs the unit cube test solves all instances with the application of the unit cube test and is 25 times faster than our solver without the test.The SMT theory The bold entries represent the best results for the given benchmark class solvers in their standard setting were not able to solve all instances within the allotted time.Moreover, our unit cube test was over 100 times faster than any state-of-the-art SMT solver without the unit cube test.The results for mathsat5 further support the superiority of the test.
We also compared our test with the ctrl-ergo solver, which includes a subroutine that is essentially the dual to our largest cube test [4].As expected, both approaches are comparable for infinite lattice width polyhedra.In order to also compare the two approaches on benchmarks without infinite lattice width, we created the rotate benchmarks by adding the same four inequalities to all infinite width instances of the dillig benchmarks.These four inequalities essentially describe a square bounding the variables x 0 and x 1 in an interval [−u, u].For a large enough choice of u (e.g., u = 2 10 ), the square is so large that the benchmarks are still satisfiable and not absolutely trivial for branch-and-bound solvers.To add a challenge, we rotated the square by a small factor 1/r , which resulted in the following four inequalities: These changes have nearly no influence on SPASS-IQ, and two SMT solvers even benefit from the proposed changes.For ctrl-ergo the rotate benchmarks are very hard because its subroutine detects only infinite lattice width.Without infinite lattice width, ctrl-ergo starts its search from the boundaries of the polyhedron instead of looking at the polyhedron's interior.We can even control the number of iterations (r 2 ) ctrl-ergo spends on the parts of the boundary without any integer solutions if we choose r accordingly (e.g., r = 2 10 ).In contrast, we use our cube tests to also extract interior points for rounding.This difference makes our tests much more stable under small changes to the polyhedron.
There exist alternative methods for solving linear integer constraints that do not rely on a branch-and-bound approach [6,18].These have not yet matured enough to be competitive with our tests or state-of-the-art SMT theory solvers.
Most problems in the linear integer arithmetic SMT-LIB benchmarks with finite lattice width can be solved without using any actual integer arithmetic techniques.A standard simplex solver for the rationals typically finds a rational solution for such a problem that is also an integer solution.Applying the unit cube test on these trivial problem classes is a waste of time.In the worst case, it doubles the eventual solution time.For these examples it is beneficial to first compute a general rational solution and to check it for integer satisfiability applying the unit cube test.This has the additional benefit that rational unsatisfiable problems are filtered out before applying the unit cube test.The unit cube test is also guaranteed to fail on problems containing boolean variables, i.e., variables that are either 0 or 1, unless they are absolutely trivial and describe a unit cube themselves.Whenever the problem contains a boolean variable, it is beneficial to skip the unit cube test.This is also the reason why we provide no experimental results for the theory of mixed linear integer and rational arithmetic, i.e., the few mixed benchmarks available in the SMT-LIB all contain boolean variables.

From cubes to equalities
If a polyhedron implies an equality, then it has only surface points and neither an interior nor a center.There is no way such a polyhedron contains a unit cube and a largest cube has edge length zero and is just a point in the original polyhedron.Equalities are, therefore, a challenge for the applicability of our cube tests.
There even exist systems of inequalities that imply infinitely many equalities.For instance, the system consisting of the inequalities −2x 1 + x 2 ≤ −2, x 1 + 3x 2 ≤ 8, and x 1 − 2x 2 ≤ −2 has only one rational solution: the point (x 1 , x 2 ) = (2, 2).Therefore, it implies the equalities −2x 1 + x 2 = −2 and x 1 + 3x 2 = 8, and all linear combinations of those two equalities, i.e., λ 1 The above example also points us to another fact about equalities: there exists a finite representation of all equalities implied by a system of inequalities-even if the system implies infinitely many equalities.
One such finite representation is the equality basis for a satisfiable system of inequalities Ax ≤ b.An equality basis is a system of equalities D x = c such that all (explicit and implicit equalities) implied by Ax ≤ b are linear combinations of equalities from D x = c .We prefer to represent each equality basis D x = c as an equivalent system of equalities y − Dz = c such that y = (y 1 , . . ., y n y ) T and z = (z 1 , . . ., z n z ) T are a partition of the variables in x, D ∈ Q n y ×n z , and c ∈ Q n y .The existence of such an equivalent system of equalities is guaranteed by Gaussian elimination.Moreover, each variable y i appears exactly once in the system y − Dz = c, that is to say, y i appears only in the row y i − d T i z i = c i .We choose to represent our equality bases in this manner because this form also correlates to a distinct substitution σ D,c y,z that replaces variable y i with c i + d T i z: The substitution σ D,c y,z is important because it allows us to eliminate all equalities from Ax ≤ b.We simply apply the substitution σ D,c y,z to Ax ≤ b and receive a new system A z ≤ b that neither contains the variables y nor implies any equalities. 1 And the substitution σ D,c y,z for the equality basis y − Dz = c has even further applications.For instance, we can directly check whether an equality h T x = g is a linear combination of y − Dz = c and, therefore, implied by both Ax ≤ b and y − Dz = c.We simply apply σ D,c y,z to h T x = g and see if it simplifies to 0 = 0. We even use σ D,c y,z for the Nelson-Oppen style combination of theories (see Sect. 7).

Finding equalities
The first step in an equality basis for a polyhedron Ax ≤ is to detect whether the system contains any equalities.We have already stated a criterion that detects this: Lemma 5 ([8]) Let Ax ≤ b be a polyhedron.Then exactly one of the following statements is true: (1) Ax ≤ b implies an equality h T x = g with h = 0 n , or (2) Ax ≤ b contains a cube with edge length e > 0.
A cube with positive edge length is enough to prove that there exists no implied equality.The actual edge length e of this cube is not relevant.Therefore, we can assume that the edge length e is arbitrarily small.We can even assume that our edge length is so small that we can ignore the different multiples a i 1 and any infinitesimals introduced by strict inequalities.We just have to turn all of our inequalities into strict inequalities.

Lemma 6
Let Ax ≤ b be a polyhedron, where a i = 0 n , b i = ( p i , q i ), q i ≤ 0, and b δ i = ( p i , −1) be the strict versions of the bounds b i for all i ∈ {1, . . ., m}.Then the following statements are equivalent: (1) Ax ≤ b contains a cube with edge length e > 0, and (2) Ax ≤ b δ is satisfiable.
In case Ax ≤ b δ is unsatisfiable, Ax ≤ b contains no cube with positive edge length and, therefore by Lemma 5, an equality.In case Ax ≤ b δ is unsatisfiable, the algorithm returns an explanation, i.e., a minimal set C of unsatisfiable constraints a T i x ≤ b δ i from Ax ≤ b δ .If Ax ≤ b itself is satisfiable, we can extract equalities from this explanation: for every a T i x ≤ b δ i ∈ C, Ax ≤ b implies the equality a T i x = b i .Lemma 7 Let Ax ≤ b be a satisfiable polyhedron, where a i = 0 n , b i = ( p i , q i ), q i ≤ 0, and b δ i = ( p i , −1) for all i ∈ {1, . . ., m}.Let Ax ≤ b δ be unsatisfiable.Let C be a minimal set of unsatisfiable constraints a T i x ≤ b δ i from Ax ≤ b δ .Then it holds for every a T i x ≤ b δ i ∈ C that a T i x = b i is an equality implied by Ax ≤ b.Proof Because of transitivity of the subset and implies relationships, we can assume that Ax ≤ b and Ax ≤ b δ contain only the inequalities associated with the explanation C.
By Lemma 2 and Ax ≤ b δ being unsatisfiable, we know that there exists a y ∈ Q m with y ≥ 0, y T A = 0 n , and y T b δ < 0. By Lemma 2 and Ax ≤ b being satisfiable, we know that y T b ≥ 0 is also true.By Lemma 3, we know that y k > 0 for every k ∈ {1, . . ., m}.Now, we use y T b δ < 0, y T b ≥ 0, and the definitions of < and ≤ for Q δ to prove that y T b = 0 and b = p.Since y T b δ < 0, we get that y T p ≤ 0. Since y T b ≥ 0, we get that y T p ≥ 0. If we combine y T p ≤ 0 and y T p ≥ 0, we get that y T p = 0. From y T p = 0 and y T b ≥ 0, we get y T q ≥ 0. Since y > 0 and q i ≤ 0, we get that y T q = 0 and q i = 0. Since Next, we multiply y T A = 0 with an x ∈ P A b to get y T Ax = 0. y k > 0 for every k ∈ {1, . . ., m}, we can solve y T Ax = 0 for every a T k x and get: Likewise, we solve y T b = 0 for every b k to get: Lemma 7 justifies simplifications on Ax ≤ b δ .We can eliminate all inequalities in Ax ≤ b δ that cannot appear in the explanation of unsatisfiability, i.e., all inequalities a T i x ≤ b δ i that cannot form an equality a T i x = b i that is implied by Ax ≤ b.For example, if we have an assignment v ∈ Q n δ such that Av ≤ b is true, then we can eliminate every inequality According to this argument, we can also eliminate all inequalities a T i x ≤ b δ i that were already strict inequalities in Ax ≤ b.

Computing an equality basis
We now present the algorithm EqBasis(A x ≤ b ) (Fig. 3) that computes an equality basis for a polyhedron A x ≤ b .In a nutshell, EqBasis iteratively detects and removes equalities from our system of inequalities and collects them in a system of equalities until it has a complete equality basis.To this end, EqBasis computes in each Let C be an explanation for Az ≤ b δ being unsatisfiable Select a variable z k such that a ik = 0. ).This has the following effects: (1) the new system of inequalities A z ≤ b implies no longer the equality a T i z = b i ; and (2) it no longer contains the variable z k .Next, we apply σ to our system of equalities (line 10) and concatenate the equality z k + n j=1, j =k a i j a ik z j = b i a ik to the end of (y− Dz = c)σ .This has the following effects: (1) the new system of equalities y − D z = c implies a T i z = b i ; and (2) the variable z k appears exactly once in y − D z = c .This means that we can now re-partition our variables so that z := (z 1 , . . ., z k−1 , z k+1 , . . ., z n ) T and y l := z k to get two new systems Az ≤ b and y − Dz = c that are equivalent to our original polyhedron (line 11).Finally, we remove all rows 0 ≤ 0 from Az ≤ b because those rows are trivially satisfied but would obstruct the detection of equalities with Lemma 6.
To prove the correctness of the algorithm, we first need to prove that moving the equality from our system of inequalities to our system of equalities preserves equivalence, i.e, the systems

Lemma 8 Let Az ≤ b be a system of inequalities. Let y − Dz = c be a system of equalities. Let h T z = g be an equality implied by Az ≤ b with h
h k z j } be a substitution based on this equality.Let y := (y 1 , . . ., y l , z k ) T and z := (z 1 , . . ., that is equivalent to σ except that it directly assigns the variables z i to their values v i .Let us now assume that either simplify to the same expressions and if one combined system is true, so is the other. The algorithm EqBasis(A x ≤ b ) decomposes the original system of inequalities A x ≤ b into a reduced system Az ≤ b that implies no equalities, and an equality basis y − Dz = c.The algorithm is guaranteed to terminate because the variable vector z decreases by one variable in each iteration.Note that EqBasis(A x ≤ b ) constructs y − Dz = c in such a way that the substitution σ D,c y,z is the concatenation of all substitutions σ from every previous iteration.Therefore, we also know that σ D,c y,z applied to A x ≤ b results in the system of inequalities Az ≤ b that implies no equalities.We exploit this fact to prove the correctness of EqBasis(A x ≤ b ), but first we need two more auxiliary lemmas.
y,z and n y recursive applications of Lemma 8, the four systems of constraints is also true.The latter contradicts our initial assumptions.Now we can also prove what we have already explained at the beginning of this section.The equality h T x = g is implied by Ax ≤ b if and only if y − Dz = c is an equality basis and (h T x = g)σ D,c  y,z simplifies to 0 = 0.An equality basis is already defined as a set of equalities y − Dz = c that implies exactly those equalities implied by Ax ≤ b.So we only need to prove that h T x = g is implied by y,z simplifies to 0 = 0.
Lemma 10 Let y − Dz = c be a satisfiable system of equalities.Let h T x = g be an equality.
Proof First, let us look at the case where h T x = g is an explicit equality y,z must be equivalent (see Lemma 9).As we stated at the beginning of this proof, (y i − d T i z = c i )σ D,c y,z simplifies to 0 = 0.An equality h T c = g that simplifies to 0 = 0 is true for all v ∈ Q n z δ .Moreover, only equalities that simplify to 0 = 0 are true for all v ∈ Q is satisfiable for all assignments and, therefore, (h T z = g)σ D,c  y,z must simplify to 0 = 0. Finally, let us look at the case where h T x = g is not an equality implied by y − Dz = c.Suppose to the contrary that y,z is satisfiable for all assignments.We know based on Lemma 8 and transitivity of equivalence that (y − Dz = c) ∪ (h T z = g) and (y − Dz = c) ∪ ∅ are equivalent.Therefore, h T z = g is implied by y − Dz = c, which contradicts our initial assumption.
With Lemma 10, we have now all auxiliary lemmas needed to prove that the algorithm EqBasis is correct: Let us now suppose to the contrary of our initial assumptions that A x ≤ b implies an equality h T x = g that y − Dz c does not imply.Since h T x = g is not implied by y − = c, the output of (h T x = g )σ D,c y,z is an equality h T z = g, where h = 0 n z .This also implies that y,z .By Lemma 9, Az ≤ b and (Az ≤ b) ∪ (h T z = g) are equivalent.Therefore, Az ≤ b implies the equality h T z = g, which contradicts the condition in line 3 of EqBasis and, therefore, our initial assumptions.

Implementation and application
It is not straight forward how to efficiently integrate our method that finds an equality basis into an SMT solver.Therefore, we now explain how to implement our method as an extension of Dutertre and de Moura's version [14] of the dual simplex algorithm [2,22].We choose to specialize this version of the dual simplex algorithm because it is implemented in most SMT solvers and has all properties necessary for an efficient theory solver: it produces minimal conflict explanations, handles backtracking efficiently, and is highly incremental.Whenever we refer to the simplex algorithm in this section, we refer to the specific version of the dual simplex algorithm presented by Dutertre and de Moura [14].
We defined the theory for the equality basis by representing our input constraints through inequalities Ax ≤ b because inequalities represent the set of solutions more intuitively.In the simplex algorithm, the input constraints are represented instead by a so-called tableau Ax = 0 m and two bounds l i ≤ x i ≤ u i for every variable x i in the tableau.Therefore, it might seem difficult to efficiently integrate our method in the simplex algorithm.The truth, however, is that the tableau-and-bound representation grants us several advantages for the implementation of our equality basis method.For example, we do not have to explicitly eliminate variables via substitution, but we do so automatically via pivoting.
Later in this section, we also explain how the integration of our methods in the simplex algorithm can be used for the combination of theories with the Nelson-Oppen Method.For the Nelson-Oppen style combination of theories inside an SMT solver [9], each theory solver has to return all valid equations between variables in its theory.Linear arithmetic theory solvers sometimes guess these equations based on one satisfying assignment.Then the equations are transferred according to the Nelson-Oppen method without verification.This leads to a backtrack of the combination procedure in case the guess was wrong and eventually led to a conflict.With the availability of an equality basis, the guesses can be verified directly and efficiently.Therefore, the method helps the theory solver in avoiding any conflicts due to wrong guesses together with the overhead of backtracking.This comes at the price of computing the equality basis, which should be negligible because the integration we propose is incremental and includes justified simplifications.

The dual simplex algorithm
The input of the simplex algorithm (Fig. 4) is a set of equalities Ax = 0 m and a set of bounds for the variables l j ≤ x j ≤ u j (for j = 1, . . ., n).If there is no lower bound l j ∈ Q δ for variable x j , then we simply set l j = −∞.Similarly, if there is no upper bound u j ∈ Q δ for variable x j , then we simply set u j = ∞.
We can easily transform a system of inequalities Ax ≤ b into the above format if we introduce a so-called slack variable s i for every inequality in our system.Our system is then defined by the equalities Ax − s = 0 m , and the bounds −∞ ≤ x j ≤ ∞ for every original variable x j and the bounds −∞ ≤ s i ≤ b i for every slack variable introduced for Algorithm 2: pivot(x i , x j ) Input : A basic variable x i and a non-basic variable x so that a ij is non-zero Effect : Transforms the tableau so x i non-basic and x j basic 1 Let x i = k∈N a ik x k be the row defining the basic variable x i 2 We rewrite this row as

v)
Input : A non-basic variable x j and a value v ∈ Q δ Effect : Sets the value β(x j ) of x j to v and updates the values of all basic variables

v)
Input : A basic variable x i , a non-basic variable x j , and a value v ∈ Q δ Effect : Pivots variables x i and x j and updates the value β(x i ) of Algorithm 5: Check() Output : Returns true iff there exists a satisfiable assignment for the tableau and the bounds u and l; otherwise, it returns (false,x i ), where x i is the conflicting basic variable 1 while true do 2 select the smallest basic variable x i such that β(x i ) < l i or β(x i ) > u i 3 if there is no such x i then return true; 4 if β(x i ) < l i then 5 select the smallest non-basic variable x j such that 6 (a ij > 0 and β(x j ) < u j ) or (a ij < 0 and β(x j ) > l j ) 7 if there is no such x j then return (false,x i ) ; select the smallest non-basic variable x j such that 12 (a ij < 0 and β(x j ) < u j ) or (a ij > 0 and β(x j ) > l j ) 13 if there is no such x j then return (false,x i ) ; 14 pivotAndUpdate(x i , x j , u i ) 15 end 16 end Fig. 4 The functions of the dual simplex algorithm by Dutertre and de Moura [14] 123 the inequality a T i x ≤ b i .We can even reduce the number of slack variables if we transform rows of the form a i j • x j ≤ c j directly into bounds for x j .Moreover, we can use the same slack variable for multiple inequalities as long the left side of the inequality is similar enough.For example, the inequalities a T i x ≤ b i and −a T i x ≤ c i can be transformed into the equality a T i x − s i = 0 and the bounds −c i ≤ s i ≤ b i .SMT solvers typically assign the slack variables during a preprocessing step with a normalization procedure based on a variable ordering.After the normalization, all terms are represented in one directed acyclic graph (DAG) so that all equivalent terms are assigned to the same node and, thereby, to the same slack variable.For more details on these simplifications we refer to [14].
The simplex algorithm also partitions the variables into two sets: the set of non-basic variables N and the set of basic variables B. Initially, our original variables are the non-basic variables and the slack variables are the basic variables.The non-basic variables N define the basic variables over a tableau derived from our system of equalities.Each row in this tableau represents one basic variable x i ∈ B: x i = x j ∈N a i j x j .The simplex algorithm exchanges variables from x i ∈ B and x j ∈ N with the pivot algorithm.To do so, we also have to change the tableau via substitution.All tableaux constructed in this way are equivalent to the original system of equalities Ax = 0 m .
The goal of the simplex algorithm is to find an assignment β that maps every variable x i to a value β(x i ) ∈ Q δ that satisfies our constraint system, i.e., A(β(x)) = 0 m and l i ≤ β(x i ) ≤ u i for every variable x i .The algorithm starts with an assignment β that fulfills A(β(x)) = 0 m and l j ≤ β(x j ) ≤ u j for every non-basic variable x j ∈ N .Initially, we get such an assignment through our tableau.We simply choose a value l j ≤ β(x j ) ≤ u j for every non-basic variable x j ∈ N and define the value of every basic variable x i ∈ B over the tableau: β(x i ) := x j ∈N a i j β(x j ).As an invariant, the simplex algorithm continues to fulfill A(β(x)) = 0 m and l j ≤ β(x j ) ≤ u j for every non-basic variable x j ∈ N and every intermediate assignment β.
The simplex algorithm finds a satisfiable assignment or an explanation of unsatisfiability through the Check() algorithm.Since all non-basic variables fulfill their bounds and the tableau guarantees that Ax = 0 m , Check() only looks for a basic variable that violates one of its bounds.If all basic variables x i satisfy their bounds, then β is a satisfiable assignment and Check() returns true.If Check() finds a basic variable x i that violates one of its bounds, then it looks for a non-basic variable x j fulfilling the conditions in lines 6 or 12 of Check().If it finds a non-basic variable x j fulfilling the conditions, then we pivot x i with x j and update our β assignment so β(x i ) is set to the previously violated bound value, which satisfies our invariant once more.If it finds no non-basic variable fulfilling the conditions, then the row of x i and all non-basic variables x j with a i j = 0 build an unresolvable conflict.Hence, Check() has found a row that explains the conflict and it can return unsatisfiable.The algorithm terminates due to a variable selection strategy called Bland's rule.Bland's rule is based on a predetermined variable order and always selects the smallest variables fulfilling the conditions for pivoting.

Implementation details
In case of the tableau-and-bound representation, an equality basis simplifies to the tableau Ax = 0 m and a set of tightly bounded variables, i.e., a set of variables x j such that β(x j ) := l j or β(x j ) := u j for all satisfiable assignments β.Therefore, one way of determining an equality basis is to find all tightly bounded variables.
To find all tightly bounded variables, we present a new extension of the simplex algorithm called FindTBnds() (Fig. 5).This extension uses our Lemmas 6 and 7 to iteratively find all bounds l j ≤ x j (x j ≤ u j ) that hold tightly for all satisfiable assignments β, and then turns them into explicit equalities by setting u j := l j (l j := u j ).But first of all, FindTBnds() determines if our constraint system is actually satisfiable with a call of Check().If the system is unsatisfiable, then it has no solutions and implies all equalities.In this case, FindTBnds() returns false.
Otherwise, we get a satisfiable assignment β from Check() and we use this assignment in Initialize() (Fig. 5) to eliminate all bounds that do not hold tightly under β (i.e., β(x i ) > l i or β(x i ) < u i ).We know that we can eliminate these bounds without losing any tightly bounded variables because we only need the bounds that can be part of an equality explanation, i.e., only bounds that hold tightly for all satisfiable assignments (see Lemma 7).For the same reason, Initialize() eliminates all originally strict bounds, i.e., bounds with a non-zero delta part.
Next, Initialize() tries to turn as many variables x i with l i = u i into non-basic variables.We do so because x i is guaranteed to stay a non-basic variable if l i = u i (see lines 6 and 12 of Check).Pivoting like this essentially eliminates the tightly bounded nonbasic variable x i and replaces it with the constant value l i .There only exists one case when Initialize() cannot turn the variable x i with l i = u i into a non-basic variable.This case occurs whenever all non-basic variables x j with non-zero coefficient a i j also have tight bounds l j = u j .In this case, the complete row x i = x j ∈N a i j x j simplifies to x i = l i , so it never produces a conflict and we can also ignore this row.
As its last action, Initialize() turns the bounds of all variables x j with l j < u j into strict bounds.Since Initialize() transformed these bounds into strict bounds, the condition of the while loop in line 3 of FindTBnds() checks whether the system contains another tightly bounded variable (see also Lemma 6).If Check returns (false, x i ), then the row x i represents an equality explanation and all variables x j with a non-zero coefficient in the row hold tightly (see Lemma 7).FindTBnds() uses FixEqs(x i ) (Fig. 5) to turn these tightly bounded variables x j into explicit equalities by setting l j = u j .After FixEqs(x i ) is done, we go back to the beginning of the loop in FindTBnds() and do another call to Check.
If Check returns true, then the original system of inequalities implies no further tightly bounded variables (Lemma 6).We exit the loop and revert the bounds of the remaining variables x j with l j < u j to their original values.As a result, we have also reverted to a linear system equivalent to our original constraint system.The only difference is that now all tightly bounded variables x i are explicit equalities because l i = u i .Moreover, the tableau Ax = 0 m and the non-basic variables that are tightly bounded represent an equality basis for our original constraint system.The simplex algorithm even represents the current tableau and the tightly bounded non-basic variables in such a way that they also describe a substitution σ for the elimination of equalities: the rows of the tableau map each basic variable x i to their row definition x j ∈N a i j x j and the tightly bounded non-basic variables x j , i.e., all variables x j with j ∈ N and l j = u j , are mapped to their tight bound l j .
After applying FindTBnds(), we can efficiently find all valid equations between variables as needed for the Nelson-Oppen style combination of theories.For each variable x i , we use the substitution σ that we get from the tableau and the tightly bounded variables to get a normalized term that represents each variable.If the variable x i is non-basic and tightly bounded (i.e., l i = u i ), then the normalized term is the constant value l i .If the variable x i is non-basic and not tightly bounded (i.e., l i = u i ), then the normalized term is the variable x i itself.If the variable x i is basic, then the normalized term is x j ∈N ,l j =u j a i j x j + x j ∈N ,l j =u j a i j l j , where all basic mathematical operations between constant values are replaced by the results of those operations.
We know from Lemma 10 that x i σ = x k σ simplifies to 0 = 0 if σ is the substitution we get from an equality basis and x i = x k is implied by our constraints.Therefore, both x i σ and x k σ must be represented by the same normalized term if x i and x k are equivalent.So the equality basis together with a normalization procedure has turned semantic equivalence into syntactic equivalence.It is very easy to find variables x i represented by the same normalized term if we store these terms in a DAG, which most SMT solvers already provide for assigning slack variables.

Incrementality, explanations, and justifications
Note that asserting additional bounds to our system can increase the number of tightly bounded variables.In this case, we have to apply FindTBnds() again to find all tightly bounded variables and to complete the new equality basis.We already mentioned that Check() never pivots a non-basic variable x j into a basic one if l j = u j because of the conditions in the lines 6 and 12 of Check().So even if the SMT solver asserts additional bounds for the variables and applies Check() again, the tightly bounded non-basic variables we have computed in the last call to FindTBnds() stay non-basic.Hence, our next application of FindTBnds() does not perform any computations for the tightly bounded variables that were detected by earlier applications of FindTBnds().This means that our algorithm to compute the equality basis is highly incremental.
Another important feature of an efficient SMT theory solver is that it produces goodmaybe even minimal-conflict explanations.In a typical SMT solver, a SAT solver based on CDCL (conflict-driven clause learning) selects and asserts a set of theory literals that satisfy the boolean model.Then the theory solvers verify that the asserted literals that belong to their theory are consistently satisfiable.If the theory solver finds a conflict between the asserted literals, then it returns a conflict explanation.The SAT solver uses the conflict explanation to start a conflict analysis that determines a good point for back jumping so it can select a new set of theory literals.Naturally, a good conflict explanation greatly enhances the conflict analysis and, therefore, the remaining search.
The literals asserted in our simplex based theory solver are bounds for our variables.2Our algorithm FindTBnds() asserts bounds independently of the SAT solver.This leads to problems in the conflict analysis because the conflict explanation is no longer comprehensible for the SAT solver.Hence, we have to extend FindTBnds() so it produces justifications (for the bounds it asserts in FixEqs(x i )) that the SAT solver can comprehend and reproduce.
We only need to justify bounds asserted by FixEqs(x i ) because all other bounds asserted by FindTBnds() are reverted to their original bounds x k ≥ l k and x k ≤ u k .And even in FixEqs(x i ), we only have to justify the bounds x k ≤ l k (x k ≥ u k ) that make the tight bounds x k ≥ l k (x k ≤ u k ) explicit.We also see that the bounds asserted by FixEqs(x i ) are just linear combinations of existing bounds if we look again at the proof of Lemma 7. The proof also shows that we can derive this linear combination from the conflict explanation C of the strict system.For instance, if the call to Check() from line 3 of FindTBnds() exits in line 7 with (false, x i ), then the conflict explanation is C = {x i > l i } ∪ {x j < u j : j ∈ N and a i j > 0} ∪ {x j > l j : j ∈ N and a i j < 0}. [14] If the call to Check() exits instead in line 13 with (false, x i ), then the conflict explanation is C = {x i < u i } ∪ {x j > l j : j ∈ N and a i j > 0} ∪ {x j < u j : j ∈ N and a i j < 0}. [14] We receive the set of tightly propagating bounds that we found with the last call to Check() if we turn all bounds in C into non-strict bounds: FixEqs(x i ) asserts now for every bound (x k ≥ l k ) ∈ C the bound x k ≤ l k .From the proof of Lemma 7, we see that the bound x k ≤ l k is a linear combination of the bounds justifies the asserted bound x k ≤ l k .Together with the slack variable definitions stored in the simplex tableau, this clause is a tautology and the SAT solver can learn it without restrictions.Moreover, all literals in this clause except for x k ≤ l k are asserted as unsatisfiable in the current model of our SAT solver.Therefore, the SAT solver can assert the literal x k ≤ l k on its own through unit propagation.Symmetrically, FixEqs(x i ) asserts for every bound (x k ≤ u k ) ∈ C the bound x k ≥ u k and the justification for this bound is the clause: But FindTBnds() is not our only method that asserts literals independently of the SAT solver.If we use the equality basis computed by FindTBnds() for a Nelson-Oppen style combination of theories, then we also assert equalities x i = x k for all pairs of equivalent variables x i , x k .Hence, we also have to justify these assertions to the SAT solver.
We get these justifications by looking at the normalized representations of the variables x i and x k that are equivalent.The current set of non-basic variables defines a basis and, therefore, already on its own a normalized representation for all variables.Since this normalized representation only depends on the current tableau Ax = 0 m , it is also independent of any of the asserted bounds.The normalized representation we use for the Nelson-Oppen style combination is only an extension of this representation by the tight bounds x j = c j of all tightly bounded non-basic variables.Therefore, the equality x i = x k is implied by those tight bounds x j = c j that were actively used to compute this representation.
For instance, if x i and x k are both non-basic, both variables must be tightly bounded so that x i = x k = v.Otherwise, they cannot have the same normalized representation.Therefore, x i = v and x k = v imply x i = x k , or as a clause: Next, we look at the case where two basic variables x i and x k are equivalent.But before we give the complete formal justification, let us look at an example.Let the variables x 1 , x 2 , x 3 , x 4 , x 5 be non-basic and the variables x 6 and x 7 be basic.In this example, the basic variables are defined by the non-basic variables as follows: x 6 = 2x 1 −x 2 +3x 4 and x 7 = 2x 1 −x 2 +x 5 .
Moreover, let the variables x 2 , x 3 , x 4 , and x 5 be tightly bounded such that x 2 = 1, x 3 = 0, x 4 = 1, and x 5 = 3.If we now replace the tightly non-basic variables, in the definitions of x 6 and x 7 we get that both of their normalized representations are 2x 1 and we have actively used the tight bounds x 2 = 1, x 4 = 1, x 5 = 3 to compute this normalization.Hence, x 6 = x 7 is implied by the tight bounds x 2 = 1, x 4 = 1, and x 5 = 3.The variables x 6 and x 7 are also equivalent if we had not asserted that x 2 = 1 because the normalized representation of both variables without x 2 = 1 is 2x 1 − x 2 .Hence, x 2 = 1 is redundant for the justification and x 6 = x 7 is also implied by just the tight bounds x 4 = 1 and x 5 = 3.
To find which tightly bounded variables are redundant, we can just look at the coefficients.If a i j and a k j are the same, then any tight bound x j = c j is redundant in the justification.This gives us the following clause as a general justification: ⎛ ⎝ j∈N ,l j =u j ,a i j =a k j ,(a k j ,a i j ) =(0,0) From this clause, we also get the justification for the mixed case, i.e., the case where x i is basic and x k non-basic.We simply treat x k as if it were defined as a basic variable by itself (x k = 1 • x k ), so a kk = 1 and all other a k j = 0.If we simplify these restrictions in the clause justification (1) for the case with two basic variables, then we receive the following general justification for the mixed case: ⎛ ⎝ j∈N ,l j =u j ,a i j =0,( j,a i j ) =(k,1) All literals in the above clauses except for x i = x k are asserted as unsatisfiable in the current model of our SAT solver.This holds because these literals contain only tightly bounded variables.Hence, the SAT solver can assert the literal x i = x k on its own through unit propagation.Note also that all justifications we defined are in some sense minimal: each of the above clauses is a tautology and, if we remove one literal from the clause, then it is no longer a tautology.This fact is another property that enhances any potential conflict analysis.

Conclusions
We have presented the linear cube transformation (Proposition 3), which allows us to efficiently determine whether a polyhedron contains a cube of a given edge length.Based on this transformation we have created two tests for linear integer arithmetic: the largest cube test and the unit cube test.Our tests can be integrated into SMT theory solvers without sacrificing the advantages that SMT solvers gain from the incremental structure of subsequent subproblems.Furthermore, our experiments have shown that these tests increase efficiency on certain polyhedra such that previously hard sets of constraints become trivial.
One obstacle for our cube tests are equalities.Resolving these obstacles led to an additional application of the linear cube transformation: investigating equalities.Through Lemmas 6 and 7, we have presented a method that efficiently checks whether a system of linear arithmetic constraints implies an equality at all.We use this method in the algorithm EqBasis(Ax ≤ b) to compute an equality basis y − Dz = c, which is a finite representation of all equalities implied by the inequalities Ax ≤ b.
We also presented various applications for the equality basis y − Dz = c.(1) We can use the equality basis to eliminate all equalities from Ax ≤ b.It is, therefore, useful as a preprocessing step for our cube tests.(2) We can use the equality basis to directly check whether an equality h T x = g is implied by Ax ≤ b. (3) In Sect.7, we also use the equality basis to efficiently compute all pairs of equivalent variables in Ax ≤ b.These pairs are necessary for a backjump-free Nelson-Oppen style combination of theories.
The results presented in this paper have further applications.For instance, our methods for detecting implied equalities are also useful for quantifier elimination.In general, a quantifier elimination (QE) procedure takes a formula ∃y.φ(y),where φ(y) itself is quantifier-free but may contain extra variables x called parameters, and returns an equivalent formula φ that is quantifier-free.Linear virtual substitution is a complete QE procedure for the theory of linear rational arithmetic [23].It eliminates the variable y by creating a case distinction exploiting the following fact: a linear real arithmetic formula φ(y) is satisfiable if and only if φ(l) is satisfiable, where l is the strictest lower bound (or upper bound) of y, i.e., the smallest value for y in any solution to the problem.This value is either represented by one of the inequalities in φ(y) containing y or −∞ (+∞).There are only finitely many inequalities in φ(y), so by a case distinction over all inequalities containing y satisfiability can be preserved: This case distinction is the source of the worst-case doubly exponential complexity of the procedure in case of quantifier alternations.At the same time, there are also instances that we can resolve without case distinctions.For instance, if the formula φ(y) implies an equality h y • y + h T x = g where h y = 0, then we already know one guaranteed definition for the strictest lower bound of y: g h y − h T x h y .
A quantifier-free formula that is equivalent to the original one is simply: This technique is well-known and integrated in many QE implementations [12,23,30].Even so, we are unaware of any implementation that makes use of non-explicit equalities for this purpose.This is where our methods that find implicit equalities come into play.Our methods are applicable because QE procedures typically keep φ in a disjunctive form and the respective disjuncts contain often only conjuncts of inequalities.This allows us to efficiently search for an equality.
For future research, we plan to implement the methods around the equality basis and investigate their performance for the above mentioned applications.Moreover, we want to work out even more applications for the linear cube transformation.

2 a i 1 .
We can express this by m optimization problems: ∀i ∈ {1, . . ., m}. max{a T i x : x ∈ C e (z)} ≤ b i and, after applying Proposition 2, by the following m inequalities: ∀i ∈ {1, . . ., m}. a T i z ≤ b i − e Hence, the linear cube transformation transforms the polyhedron Ax ≤ b into the polyhedron Ax ≤ b , where b i = b i − e 2 a i 1 , and C e (z) fits into Ax ≤ b if Az ≤ b .

Fig. 1 a
Fig. 1 a A square (two-dimensional cube) fitting into an inequality a T i x ≤ b i and the cube's maximum a T i x * for the objective a T i x. b The vertices of an arbitrary square parallel to the coordinate axes (two-dimensional cube with edge length e and center z).c The transformed polyhedron Ax ≤ b for edge length 1 together with the original polyhedron Ax ≤ b

Fig. 2 a
Fig. 2 a The largest cube inside a polyhedron, its center point, and a closest integer point to the center.b An infinite lattice width polyhedron, containing cubes for every edge length e > 0. c A unit cube inside a polyhedron, its center point, and a closest integer point to the center

Algorithm 1 :
iteration one system of inequalities Az ≤ b and one system of equalities y − Dz = c such that A x ≤ b is equivalent to (y − Dz = c) ∪ (Az ≤ b).While the variables z are completely defined by the EqBasis(Ax ≤ b) Input : A satisfiable system of inequalities Ax ≤ b, where A ∈ Q m×n and b ∈ Q m δ Output : An equality basis z − Dy = c for Ax ≤ b 1 l := 1, nz := n, (z 1 , . . ., zn z ) := (x 1 , . . ., xn), y := () T , and (y − Dz = c) := ∅ 2 Remove all rows a T i i z ≤ b from Az ≤ b with a i = 0 n and b i = 0 3 while Az ≤ b δ is unsatisfiable (i.e., Az ≤ b contains an equality) do 4

Lemma 9
Let y − Dz = c be a satisfiable system of equalities.Let Ax ≤ b and A * x b * be two systems of inequalities, both implying the equalities in y − = c.Let A z ≤ b := (Ax ≤ b)σ D,c y,z and A * * z ≤ b * * c y,z simplifies to 0 = 0 because σ D,c y,z maps y i to d T i z + c i and the variables z j are not affected by σ D,c y,z .Next, let us look at the case where h T x = g is an implicit equality in y − Dz = c.Since both y − Dz = c and (y − Dz = c) ∪ (h T z = g) imply h T z = g and the equalities in y − Dz = c, both (y − Dz = c)σ D,c y,z and ((y

Lemma 11
Let A x ≤ b be a satisfiable system of inequalities.Let y − Dz = c be the output of EqBasis(A x ≤ b ).Then y − Dz = c is an equality basis of A x ≤ b .Proof Let Az ≤ b be the result of applying σ D,c y,z to A x ≤ b .Since y − Dz = c is the output of EqBasis(A x ≤ b ), the condition in line 3 of EqBasis guarantees us that Az ≤ b implies no equalities.