Notes on $\{a,b,c\}$-Modular Matrices

Let $A \in \mathbb{Z}^{m \times n}$ be an integral matrix and $a$, $b$, $c \in \mathbb{Z}$ satisfy $a \geq b \geq c \geq 0$. The question is to recognize whether $A$ is $\{a,b,c\}$-modular, i.e., whether the set of $n \times n$ subdeterminants of $A$ in absolute value is $\{a,b,c\}$. We will succeed in solving this problem in polynomial time unless $A$ possesses a duplicative relation, that is, $A$ has nonzero $n \times n$ subdeterminants $k_1$ and $k_2$ satisfying $2 \cdot |k_1| = |k_2|$. This is an extension of the well-known recognition algorithm for totally unimodular matrices. As a consequence of our analysis, we present a polynomial time algorithm to solve integer programs in standard form over $\{a,b,c\}$-modular constraint matrices for any constants $a$, $b$ and $c$.


Introduction
A matrix is called totally unimodular (TU) if all of its subdeterminants are equal to 0, 1, or −1. Within the past 60 years the community has established a deep and beautiful theory about TU matrices. A landmark result in the understanding of such matrices is Seymour's decomposition theorem [19]. It shows that TU matrices arise from network matrices and two special matrices using row, column, transposition, pivoting, and so-called k-sum operations. As a consequence of this theorem it is possible to recognize in polynomial time whether a given matrix is TU [18,22]. An implementation of the algorithm in [22] by Walter and Truemper [25] returns a certificate if A is not TU: For an input matrix with entries in {0, ±1}, the algorithm finds a submatrixÃ which is minimal in the sense that | det(Ã)| = 2 and every proper submatrix ofÃ is TU. We refer to Schrijver [18] for a textbook exposition of Seymour's decomposition theorem, a recognition algorithm arising therefrom and further material on TU matrices.
There is a well-established relationship between totally unimodular and unimodular matrices, i.e., matrices whose n × n subdeterminants are equal to 0, 1 or −1. In analogy to this we define for A ∈ Z m×n and m ≥ n,  [1] can be applied to calculate D(A) given that max{k : k ∈ D(A)} is constant (cf. Lemma 1). Nonetheless, with the exception of these results we are not aware of other instances for which it is known how to determine D(A) in polynomial time.
The main motivation for the study of matrices with bounded subdeterminants comes from integer optimization problems (IPs). It is a well-known fact that IPs of the form max{c T x : Ax ≤ b, x ∈ Z n } for A ∈ Z m×n of full column rank, b ∈ Z m and c ∈ Z n can be solved efficiently if D(A) ⊆ {1, 0}, i.e., if A is unimodular. This naturally leads to the question whether these problems remain efficiently solvable when the assumptions on D(A) are further relaxed. Quite recently in [2] it was shown that when D(A) ⊆ {2, 1, 0} and rank(A) = n, integer optimization problems can be solved in strongly polynomial time. Recent results have also led to understand IPs when A is nondegenerate, i.e., if 0 ∈ D(A). The foundation to study the nondegenerate case was laid by Veselov and Chirkov [23]. They describe a polynomial time algorithm to solve IPs if D(A) ⊆ {2, 1}. In [1] the authors showed that IPs over nondegenerate constraint matrices are solvable in polynomial time if the largest n×n subdeterminant of the constraint matrix is bounded by a constant.
The role of bounded subdeterminants in complexity questions and in the structure of IPs and LPs has also been studied in [8,10,12,17], as well as in the context of combinatorial problems in [5,6,16]. The sizes of subdeterminants also play an important role when it comes to the investigation of the diameter of polyhedra, see [7] and [3].

Our Results
A matrix A ∈ Z m×n , m ≥ n, is called {a, b, c}-modular if D(A) = {a, b, c}, where a ≥ b ≥ c ≥ 0. 1 The paper presents three main results. First, we prove the following structural result for a subclass of {a, b, 0}-modular matrices.
Theorem 1 (Decomposition Property) Let a ≥ b > 0, gcd({a, b}) = 1 and assume that (a, b) = (2, 1). Using row permutations, multiplications of rows by −1, and elementary column operations, any {a, b, 0}-modular matrix A ∈ Z m×n can be brought into a block structure of the form in time polynomial in n, m, and log ||A|| ∞ , where L ∈ Z m 1 ×n 1 and R ∈ Z m 2 ×n 2 are TU, n 1 + n 2 = n − 1, and m 1 + m 2 = m. In the representation above the rightmost column has entries in {0, a} and {0, b}, respectively. The matrix L 0 0 R contains the (n − 1)-dimensional unit matrix as a submatrix.
The first n − 1 columns of (1) are TU since they form a 1-sum of two TU matrices (see [18,Chapter 19.4]). This structural property lies at the core of the following recognition algorithm. We say that a matrix A possesses a duplicative relation if it has nonzero n × n subdeterminants k 1 and k 2 satisfying 2 · |k 1 | = |k 2 |.
Theorem 2 (Recognition Algorithm) There exists an algorithm that solves the following recognition problem in time polynomial in n, m, and log ||A|| ∞ : Either, calculate D(A), or give a certificate that |D(A)| ≥ 4, or return a duplicative relation.
For instance, Theorem 2 cannot be applied to check whether a matrix is {4, 2, 0}modular, but it can be applied to check whether a matrix is {3, 1, 0}-or {6, 4, 0}modular. More specifically, Theorem 2 recognizes {a, b, c}-modular matrices unless (a, b, c) = (2·k, k, 0), k ∈ Z ≥1 . In particular, this paper does not give a contribution as to whether so-called bimodular matrices (the case k = 1) can be recognized efficiently. This is because Theorem 1 excludes the case (a, b) = (2, 1).
The decomposition property established in Theorem 1 is a major ingredient for the following optimization algorithm to solve standard form IPs over {a, b, c}modular constraint matrices for any constant a ≥ b ≥ c ≥ 0.

Theorem 3 (Optimization Algorithm) Consider a standard form integer program of the form
for b ∈ Z m , c ∈ Z n , and B ∈ Z m×n of full row rank, where D(B T ) is constant, i.e., max{k : k ∈ D(B T )} is constant. 2 Then, in time polynomial in n, m, and the encoding size of the input data, one can solve (2) or output that |D(B T )| ≥ 4.
Notably, in Theorem 3, the assumption that D(B T ) is constant can be dropped if B is degenerate, i.e., if 0 ∈ D(B T ).

Three Examples of {a, b, c}-Modular Matrices
Generalized network flow. Let G = (V, E) be a directed graph whose vertices can be partitioned as V = S ∪ {v} ∪ T such that no arc runs between S and T , and no arc runs from v to S. Consider a generalized network flow problem in G, where s ∈ S and t ∈ T , with capacities u : E → Z >0 and gains if e runs from S to v, 1 otherwise, where a, b ∈ Z >0 . Then, the natural formulation of finding a maximal s-t flow in G with respect to u and γ is an integer optimization problem whose constraint matrix A satisfies D(A T ) ⊆ {a, b, 0} after multiplying the constraint corresponding to v by b.
Perfect d-matching. Let G = (V, E) be an undirected graph with edge capacities u : E → Z >0 ∪ {∞}, weights c : E → R, and numbers d : V → Z >0 . Then, the perfect d-matching problem is the problem of finding a function f : E → Z ≥0 of maximal cost e∈E f (e) · c(e) which satisfies f (e) ≤ u(e) for all e ∈ E and [14,15].
Consider the following variation of this problem: Let G 1 = (V 1 , E 1 ) and G 2 = (V 2 , E 2 ) be two bipartite graphs with edge capacities u : Fix edges e 1 ∈ E 1 and e 2 ∈ E 2 . Then, the natural formulation of finding an optimal, perfect d-matching f in (V 1 ∪ V 2 , E 1 ∪ E 2 ) w.r.t. u, c, and d and under the additional constraint that is an integer optimization problem whose constraint matrix A satisfies D(A T ) ⊆ {a, b, 0}. The signs of a and b can be different.
Edge-weighted vertex cover. Given an undirected graph G = (V, E) and weights w : E → Z ≥0 , an edge-weighted vertex cover is a function f : V → Z ≥0 such that for each e = {u, v} ∈ E, f (u) + f (v) ≥ w(e).
Consider the following variation of this problem: Let G 1 = (V 1 , E 1 ) and G 2 = (V 2 , E 2 ) be two bipartite graphs with weights w : E 1 ∪ E 2 → Z ≥0 and costs c : V 1 ∪ V 2 → R ≥0 . Let a, b ∈ Z >0 . Then, the natural formulation of finding a minimal edge-weighted vertex cover f in G 1 ∪G 2 w.r.t. c, where the constraints are replaced by is an integer optimization problem whose constraint matrix is {a, b}-or {a, b, 0}modular. 3 Note in particular that the signs of the two constraints can be different.

Notation and Preliminaries
For k ∈ Z ≥1 , [k] := {1, . . . , k}. I n is the n-dimensional unit matrix, where we leave out the subscript if the dimension is clear from the context. For a matrix A ∈ Z m×n , we denote by A i,· the i-th row of A. For a subset I of [m], A I,· is the submatrix formed by selecting all rows with indices in I, in increasing order. An analogous notation is used for the columns of A. For k ∈ Z, we write I k := {i ∈ [m] : A i,n = k}, the indices of the rows whose n-th entry is equal to k. Set ||A|| ∞ := max i∈[m],j∈[n] |A i,j |. For simplicity, we assume throughout the document that the input matrix A to any recognition algorithm satisfies m ≥ n and rank(A) = n as rank(A) < n implies that D(A) = {0}. Left-out entries in figures and illustrations are equal to zero. D(A) is preserved under elementary column operations, permutations of rows and multiplications of rows by −1. By a series of elementary column operations on A, any nonsingular n × n submatrix B of A can be transformed to its Hermite normal form (HNF), in which B becomes a lower-triangular, nonnegative submatrix with the property that each of its rows has a unique maximum entry on its main diagonal [18]. This can be done in time polynomial in n, m, and log ||A|| ∞ [21].
At various occasions we will make use of the following simple adaptation of the HNF described in [1,Section 3]. Begin by choosing a nonsingular n × n submatrix B of A: Either, the choice of B will be clear from the context or otherwise, choose B to be any nonsingular n × n submatrix of A. Permute the rows of A such that A [n],· = B. Apply elementary column operations to A such that B is in HNF. After additional row and column permutations and multiplications of rows by −1, . . . * · · · · · · · · · * δ l * · · · · · · · · · · · · * A n,n A n+1,1 · · · · · · · · · · · · A n+1,n−1 A n+1,n . . . A m,1 · · · · · · · · · · · · A m,n−1 A m,n where A ·,n ≥ 0, | det(B)| = ( l i=1 δ i ) · A n,n , all entries marked by * are numbers between 0 and the corresponding entry on the main diagonal minus one, and δ i ≥ 2 for all i ∈ [l]. In particular, the rows of A [n],· whose entries on the main diagonal are strictly larger than one are at positions n − l, . . . , n.
We note that it is not difficult to efficiently recognize nondegenerate matrices given a constant upper bound on |D(A)|. This will allow us to exclude the nondegenerate case in all subsequent algorithms. We wish to emphasize that the results in [1] can be applied to solve this task given that max{k : k ∈ D(A)} is constant. Proof We first prove that for n ≥ 2, any nondegenerate matrix A ∈ Z m×n with |D(A)| ≤ d has at most (n − 1) + d · (2 · d + 1) rows. Given such a matrix A, transform it to (3). We introduce the following family of 2 × 2 subdeterminants: Any such subdeterminant can be extended to an n × n subdeterminant Θ i,j of A by appending rows 1, . . . , n − 2 and columns 1, . . . , n − 2 to θ i,j . Applying Laplace expansion yields Θ i,j = ( l−1 k=1 δ k ) · θ i,j . Starting with row n, partition the rows of A into submatrices (bins) A[1], . . . , A[s] such that the rows with the same entry in the n-th column are in the same bin. Thus, s is the number of different entries in the n-th column, starting from the n-th row. Denote by In what follows, we first derive a bound on s and subsequently bound the number of rows in each bin.
Regarding the former, as A n−1,n = 0, it holds that θ n−1,j = δ l · A j,n for any j ≥ n. This implies that A j,n = 0 for any j ≥ n as otherwise, Θ n−1,j = 0, contradicting the nondegeneracy of A. As we have assumed that A ·,n ≥ 0, it follows that A ·,n > 0. Therefore, θ n−1,j > 0 and Θ n−1,j > 0 for any j ≥ n. Varying j among different bins induces pairwise different and nonnegative subdeterminants Θ n−1,j , i.e., s ≤ d.
Next, we derive a bound on the number of rows of each bin. Choose an arbitrary bin k ∈ [s]. Let i be the smallest element of I[k] and let j 1 , In other words, every element of I[k] \ {i} yields a different n × n subdeterminant. Since those n × n subdeterminants are not necessarily different in absolute value, |I[k] \ {i}| ≤ 2 · d and |I[k]| ≤ 2 · d + 1. Combining this bound with our bound on the number of bins, we obtain m ≤ (n − 1) + d · (2 · d + 1).
From the result above we straightforwardly deduce the following simple recognition algorithm: Let A be the input matrix. If n = 1 perform an exhaustive search. If m ≤ (n−1)+d·(2·d+1), enumerate all (n−1)+d·(2·d+1) n n×n subdeterminants. Otherwise, we find at least d + 1 elements of D(A) or an n × n subdeterminant equal to zero as described above.

Proof of Theorem 1
Transform A to (3), thus A ·,n ≥ 0. As a first step we show that we may assume that A n,n > 1 without loss of generality. For this purpose, assume that A n,n = 1, i.e., that l = 0. This implies that A [n],· = I n . Consequently, any nonsingular submatrix B of A can be extended to an n × n submatrix with the same determinant in absolute value by (a) appending unit vectors from the topmost n rows of A to B and (b) for each unit vector appended in step (a), by appending the column to B in which this unit vector has its nonzero entry. By Laplace expansion, the n × n submatrix we obtain admits the same determinant in absolute value. Therefore, if we identify any submatrix of A with determinant larger than one in absolute value, we can transform A once more to (3) with respect to its corresponding n × n submatrix which yields A n,n > 1 as desired. To find a subdeterminant of A of absolute value larger than one, if present, test A for total unimodularity. If the test fails, it returns a desired subdeterminant. If the test returns that A is TU, then a = b = 1 and A is already of the form L 0 /1 for L TU.
The n-th column is not divisible by any integer larger than one as otherwise, all n × n subdeterminants of A would be divisible by this integer, contradicting gcd({a, b}) = 1. In particular, since A n,n > 1, A ·,n is not divisible by A n,n . This implies that there exists an entry A k,n = 0 such that A k,n = A n,n . Thus, there exist two n × n subdeterminants, det(A [n],· ) and det(A [n−1]∪k,· ), of different absolute value. This allows us to draw two conclusions: First, the precondition A n,n > 1 which we have established in the previous paragraph implies a > b. We may therefore assume for the rest of the proof that a ≥ 3 as {a, b} = {2, 1}. Secondly, it follows that l = 0: For the purpose of contradiction assume that l ≥ 1. Then the aforementioned two subdeterminants det(A [n],· ) and det(A [n−1]∪k,· ) are both divisible by l i=1 δ i > 1. Since one of those subdeterminants must be equal to ±a and the other must be equal to ±b, this contradicts our assumption of gcd({a, b}) = 1.
As a consequence of l = 0, the topmost n − 1 rows of A form unit vectors. Thus, any subdeterminant of rows n, . . . , m of A which includes elements of the n-th column can be extended to an n × n subdeterminant of the same absolute value by appending an appropriate subset of these unit vectors. To further analyze the structure of A we will study the 2 × 2 subdeterminants where i, j ≥ n, i = j, and h ≤ n − 1. It holds that |θ h i,j | ∈ {a, b, 0}.

Claim 1 There exists a sequence of elementary column operations and row permutations which turn A into the form
are submatrices consisting of rows whose first n−1 entries lie in {0, ±1}, and whose n-th entry is equal to a, b, or 0, respectively.
Proof (Proof of Claim 1) We start by analyzing the n-th column of A. To this end, In addition, by what we have observed two paragraphs earlier, at least one entry of A ·,n must be equal to a and at least one entry must be equal to b. Sort the rows of A by their respective entry in the n-th column as in (5).
In the remaining proof we show that after column operations, A ·,[n−1] ∈ {0, ±1} m×(n−1) . To this end, let h ∈ [n − 1] be an arbitrary column index. Recall that I k := {i ∈ [m] : A i,n = k}. We begin by noting a few properties which will be used to prove the claim. For i ∈ I a and j ∈ I b , it holds that These are Diophantine equations which are solved by Furthermore, for any i 1 , Since this quantity is a multiple of a and since θ h i 1 ,i 2 ∈ {±a, ±b, 0}, it follows that We now perform a column operation on A ·,h : Let us fix arbitrary indices p ∈ I a and q ∈ I b . The pair (A p,h , A q,h ) solves one of the three Diophantine equations for a fixed k.
We claim that as a consequence of this column operation, A ·,h ∈ {0, ±1} m . We begin by showing that A I a ,h and A I b ,h have entries in {0, ±1}. First, assume for the purpose of contradiction that there exists j ∈ I b such that |A j,h | > 1. This implies that the pair (A p,h , A j,h ) satisfies (6) for |k| ≥ 1. As a ≥ 3, this contradicts that A p,h ∈ {0, ±1}. Secondly, assume for the purpose of contradiction that there is i ∈ I a such that |A i,h | > 1. 4 As |A p,h | ≤ 1, it follows from (7) that |A i,h | = 2 and that |A p,h | = 1. Therefore, as either A p,h or A q,h must be equal to zero, A q,h = 0. This implies that |θ h i,q | = 2 · b which is a contradiction to θ h i,q ∈ {±a, ±b, 0} as A has no duplicative relation, i.e., 2 · b = a.
It remains to prove that A I 0 ,h has entries in {0, ±1}. For the purpose of contradiction, assume that there exists i ∈ I 0 , i ≥ n, such that |A i,h | ≥ 2. Choose any s ∈ I a . Then, which is larger than a in absolute value, a contradiction.

⊓ ⊔
In the next claim, we establish the desired block structure (1). We will show afterwards that the blocks L and R are TU.
Claim 2 There exists a sequence of row and column permutations which turn A into (1) for matrices L and R with entries in {0, ±1}.

Proof (Proof of Claim 2)
For reasons of simplicity, we assume that A has no rows of the form 0 · · · 0 a or 0 · · · 0 b as such rows can be appended to A while preserving the properties stated in this claim. We construct an auxiliary graph G = (V, E), where we introduce a vertex for each nonzero entry of A ·,[n−1] and connect two vertices if they share the same row or column index. Formally, set Let K 1 , . . . , K k ⊆ V be the vertex sets corresponding to the connected components in G. For each l ∈ [k], set . Furthermore, by construction, it holds that I p ∩ I q = ∅ and J p ∩ J q = ∅ for all p = q. The entries A i,j for which (i, j) / ∈ l∈[k] (I l × J l ) are equal to zero. Therefore, sorting the rows and columns of A ·,[n−1] with respect to the partition formed by I l , resp. J l , l ∈ [k], yields In what follows we show that for all l ∈ [k], it holds that either I l ∩ I a = ∅ or that I l ∩ I b = ∅. From this property the claim readily follows: We obtain the form (1) from (8) by permuting the rows and columns such that the blocks which come first are those which correspond to the connected components K l with I l ∩ I a = ∅. For the purpose of contradiction, assume that there exists l ∈ [k] such that I l ∩ I a = ∅ and I l ∩ I b = ∅. Set K a l := {(i, j) ∈ K l : i ∈ I a } and K b l := {(i, j) ∈ K l : i ∈ I b }. Among all paths in the connected component induced by K l which connect the sets K a l and K b l , let P := {(i (1) , j (1) ), . . . , (i (t) , j (t) )} be a shortest one. By construction, (i (1) , j (1) ) is the only vertex of P which lies in K a l and (i (t) , j (t) ) is the only vertex of P which lies in K b l . This implies that P starts and ends with a change in the first component, i.e., i (1) = i (2) and i (t−1) = i (t) . Furthermore, since P has minimal length, it follows from the construction of the edges that it alternates between changing first and second components, i.e., for all s = 1, . . . , t − 2, i (s) = i (s+1) ⇔ j (s+1) = j (s+2) and j (s) = j (s+1) ⇔ i (s+1) = i (s+2) .
Define B := A {i (1) ,...,i (t) },{j (1) ,...,j (t) ,n} . B is a square matrix with t+2 2 rows and columns for the following reason: P starts with a change of rows, after which the remaining path of length t − 2 starts with a change of columns, ends with a change of rows and alternates between row and column changes in between. Thus, t − 2 is even and in total P changes rows 1 + t−2 2 times and columns t−2 2 times. It follows that B has 1+ t−2 2 +1 rows and t−2 2 +1 columns excluding the column with entries of A ·,n . Permute the rows and columns of B such that they are ordered with respect to the order i (1) , . . . , i (t) and j (1) , . . . , j (t) , n. We claim that B is of the form To see this, first observe that the entries on the main diagonal and the diagonal below are equal to ±1 and that the entries B 1, t+2 2 and B t+2 2 , t+2 2 are equal to a or b, respectively, by construction. As we have observed above, (i (1) , j (1) ) is the only vertex of P which lies in K a l and (i (t) , j (t) ) is the only vertex of P which lies in K b l , implying that all other entries of the rightmost column, B 2, t+2 2 , . . . , B t+2 2 −1, t+2 2 , are equal to zero. For the purpose of contradiction, assume that any other entry of B, say B v,w , is nonzero. Let us consider the case that w > v, i.e., that B v,w lies above the main diagonal of B. Among all vertices of P whose corresponding entries lie in the same row as B v,w , let (i (s) , j (s) ) be the vertex with minimal s. Among all vertices of P whose corresponding entries lie in the same column as B v,w , let (i (s ′ ) , j (s ′ ) ) be the vertex with maximal s ′ . Then, consider the following path: Connect (i (1) , j (1) ) with (i (s) , j (s) ) along P ; then take the edge to the vertex corresponding to B v,w ; take the edge to (i (s ′ ) , j (s ′ ) ); then connect (i (s ′ ) , j (s ′ ) ) with (i (t) , j (t) ) along P . This path is shorter than P , a contradiction. An analogous argument yields a contradiction if w < v−1, i.e., if B v,w lies in the lower-triangular part of B. Thus, B is of the form stated above. By Laplace expansion applied to the last column of B, det(B) = ±a ± b / ∈ {±a, ±b, 0} as 2 · b = a. Since B can be extended to an n × n submatrix of A of the same determinant in absolute value, this is a contradiction.
Regarding the computational running time of this operation, note that G can be created and its connected components can be calculated in time polynomial in n and m. A subsequent permutation of the rows and columns as noted above yields the desired form.
⊓ ⊔ It remains to show that L and R are TU. We will prove the former, the proof of the latter property is analogous. Assume for the purpose of contradiction that L is not TU. As the entries of L are all ±1 or 0, it contains a submatrixÃ of determinant ±2 [18,Theorem 19.3]. ExtendÃ by appending the corresponding entries of A ·,n and by appending an arbitrary row of A I b ,· . We obtain a submatrix of the form Ã 0 /a 0 b , whose determinant in absolute value is 2·b, a contradiction as A has no duplicative relations. Similarly, one obtains a submatrix of determinant ±2 · a if R is not TU. ⊓ ⊔

Proof of Theorem 2
In this section, the following recognition problem will be of central importance: For numbers a ≥ b ≥ c ≥ 0, we say that an algorithm tests for {a, b, c}-modularity if, given an input matrix A ∈ Z m×n (m ≥ n), it checks whether D(A) = {a, b, c}.
As a first step we state the following lemma which allows us to reduce the gcd in all subsequent recognition algorithms. The proof uses a similar technique as was used in [11,Remark 5]. Proof Calculate the transformation matrices which transform A to its Smith normal form: Find P ∈ Z m×m and Q ∈ Z n×n unimodular such that where S ∈ Z n×n is a diagonal matrix satisfying n i=1 S i,i = gcd(D(A)), cf. [18]. The matrices P and Q can be calculated in time polynomial in n, m and log ||A|| ∞ , see [20]. It must hold that n i=1 S i,i = γ, otherwise gcd(D(A)) = gcd({a, b}), i.e., we have found a certificate that A is not {a, b, 0}-modular. Since S and P are invertible, we obtain that As P is unimodular, P −1 is integral, i.e., AQS −1 is integral. Since Q is unimodular, AQ corresponds to performing elementary column operations on A, i.e., Multiplying A by S −1 from the right corresponds to performing these divisions. We conclude that D(AQS −1 ) = Thus, assume that a > b. Since gcd({a, b}) = 1, 2 · b = a ⇔ {a, b} = {2, 1}. Therefore, the numbers a and b fulfill the prerequisites of Theorem 1. Follow the proof of Theorem 1 to transform A to (1). If the matrix is {a, b, 0}-modular, we will arrive at a representation of the form (1). Otherwise, the proof of Theorem 1 (as it is constructive) exhibits a certificate of the following form: An element of D(A) \ {a, b, 0}, gcd(D(A)) = gcd({a, b}), or a set D ′ {a, b, 0} such that D(A) = D ′ . Without loss of generality, we may further assume that at least one n × n subdeterminant of A is equal to ±a and that at least one n × n subdeterminant of A is equal to ±b, i.e., that {a, b, 0} ⊆ D(A).
Next, we show that i) holds if and only if both ii) and iii) hold, where i) every nonsingular n × n submatrix of A has determinant ±a or ±b, ii) every nonsingular n × n submatrix of A I a ∪I 0 ,· has determinant ±a, iii) every nonsingular n × n submatrix of A I b ∪I 0 ,· has determinant ±b.
A I 0 ,· contains the first n − 1 unit vectors and hence, A I a ∪I 0 ,· and A I b ∪I 0 ,· admit full column rank.
We first show that ii) and iii) follow from i). Let us start with iii). For the purpose of contradiction, assume that i) holds but not iii). By construction, the n-th column of A I b ∪I 0 ,· is divisible by b. Denote by A ′ the matrix which we obtain by dividing the last column of A I b ∪I 0 ,· by b. The entries of A ′ are all equal to ±1 or 0. As we have assumed that iii) is invalid, there exists a nonsingular n × n submatrix of A ′ whose determinant is not equal to ±1. In particular, A ′ is not TU. By [18,Theorem 19.3], as the entries of A ′ are all ±1 or 0 but it is not TU, it contains a submatrix of determinant ±2. Since A ′ ·,[n−1] is TU, this submatrix must involve entries of the n-th column of A ′ . Thus, it corresponds to a submatrix of Append a subset of the first n − 1 unit vectors to extend this submatrix to an n × n submatrix. This n × n submatrix is also an n × n submatrix of A. Its determinant is ±2 · b, which is not contained in {±a, ±b, 0} because 2 · b = a, a contradiction to i). For ii), the same argument yields an n × n subdeterminant of ±2 · a, which is also a contradiction to i).
Next, we prove that i) holds if both ii) and iii) hold. This follows from the 1-sum structure of A. Let B be any nonsingular n × n submatrix of A. B is of the form where C ∈ Z m 1 ×n 1 , D ∈ Z m 2 ×n 2 for n 1 , n 2 , m 1 , and m 2 satisfying n 1 + n 2 + 1 = n = m 1 + m 2 . As B is nonsingular, n i ≤ m i and m i ≤ n i + 1, i ∈ {1, 2}. Thus, n i ≤ m i ≤ n i + 1, i ∈ {1, 2}, and we identify two possible cases which are symmetric: m 1 = n 1 + 1, m 2 = n 2 and m 1 = n 1 , m 2 = n 2 + 1. We start with the analysis of the former. By Laplace expansion applied to the last column, The latter determinant is zero as m 1 = n 1 + 1. As the former matrix is blockdiagonal, | det B| = | det[C | 0 /a]| · | det D|. B is nonsingular and D is TU, therefore | det D| = 1. [C | 0 /a] is a submatrix of A I a ∪I 0 ,· which can be extended to an n × n submatrix of the same determinant in absolute value by appending a subset of the n − 1 unit vectors contained in A I a ∪I 0 ,· . Therefore by ii), | det B| = | det[C | 0 /a]| = a. In the case m 1 = n 1 , m 2 = n 2 + 1 a symmetric analysis leads to To test for ii), let A ′ be the matrix which we obtain by dividing the n-th column of A I a ∪I 0 ,· by a. Then, ii) holds if and only if every nonsingular n × n submatrix of A ′ has determinant ±1. Transform A ′ to (3). The topmost n rows of A ′ must form a unit matrix. Therefore, ii) is equivalent to A ′ being TU, which can be tested efficiently. Testing for iii) can be done analogously.

⊓ ⊔
We now have all the necessary ingredients to prove Theorem 2. In essence, what remains is a technique to find sample values a, b, and c for which we test whether A is {a, b, c}-modular using our previously established algorithms. To do so, we first apply a technique from the proof of Lemma 2. This technique allows us to reduce finding k 2 ∈ D(A)\{k 1 , 0} to finding k 2 ∈ D(A ′ )\{ k 1 gcd(D(A)) , 0} for a matrix A ′ ∈ Z m×n which satisfies gcd(D(A ′ )) = 1: Calculate the Smith normal form of A, i.e., calculate P ∈ Z m×m and Q ∈ Z n×n unimodular such that ). This can be done in time polynomial in n, m, and log ||A|| ∞ , see [20]. Then, the matrix A ′ := AQS −1 is integral, satisfies D(A ′ ) = This implies that A ′ [n],· = I n , and in particular that every nonsingular submatrix of A ′ can be extended to an n × n submatrix of the same determinant in absolute value. Test A ′ for total unimodularity. Since we know that |D(A ′ )| = |D(A)| ≥ 3, A ′ is not TU, i.e., the algorithm returns a submatrix of determinant at least 2 in absolute value. The absolute value of this subdeterminant and det(I n ) = 1 are two nonzero elements of D(A ′ ), one of which cannot be equal to One ingredient to the proof of Theorem 3 is the following result by Gribanov, Malyshev, and Pardalos [11] which reduces the standard form IP (2) to an IP in inequality form in dimension n−m such that the subdeterminants of the constraint matrices are in relation.
Lemma 4 ([11, Corollary 1.1, Remark 5, Theorem 3] 5 ) In time polynomial in n, m, and log ||B|| ∞ , (2) can be reduced to the inequality form IP max{h T y : Cy ≤ g, y ∈ Z n−m }, where h ∈ Z n−m , g ∈ Z n , and C ∈ Z n×(n−m) , with D(C) = To prove this reduction, the authors apply a theorem by Shevchenko and Veselov [24] which was originally published in Russian. For completeness of presentation, we will provide an alternative but similar proof of Lemma 4 which uses the following well-known determinant identity instead of the aforementioned result. Proof (Alternative proof of Lemma 4) We closely follow the proof of [11]. First, we reformulate (2) in such a way that the gcd of the full rank subdeterminants of the constraint matrix becomes 1. To this end, calculate the Smith normal form of B, i.e., find P ∈ Z m×m and Q ∈ Z n×n unimodular and nonsingular such that B = P [S | 0]Q, where S ∈ Z m×m is a diagonal matrix satisfying m i=1 S i,i = gcd(D(B T )). This can be done in time polynomial in m, n, and log ||B|| ∞ , see [20]. (2) is infeasible. Thus, assume that b ′ ∈ Z m . Summarizing, solving (2) is equivalent to solving Secondly, we reduce (10) to an IP in inequality form. Since Q is unimodular, substituting z := Qx yields Plugging this identity into (10) yields i.e., the claim follows.

⊓ ⊔
As a second ingredient to the proof of Theorem 3, we will make use of some results for bimodular integer programs (BIPs). BIPs are IPs of the form where c ∈ Z n , b ∈ Z m , and A ∈ Z m×n is bimodular, i.e., rank(A) = n and D(A) ⊆ {2, 1, 0}. As mentioned earlier, [2] proved that BIPs can be solved in strongly polynomial time. Their algorithm uses the following structural result for BIPs by [23] which will also be useful to us.
Theorem 4 ([23, Theorem 2], as formulated in [2, Theorem 2.1]) Assume that the linear relaxation max{c T x : Ax ≤ b, x ∈ R n } of a BIP is feasible, bounded and has a unique optimal vertex solution v. Denote by I ⊆ [m] the indices of the constraints which are tight at v, i.e., A I,· v = b I . Then, an optimal solution x * of max{c T x : A I,· x ≤ b I , x ∈ Z n } is also optimal for the BIP.
Proof (Proof of Theorem 3) Using Lemma 4, we reduce the standard form IP (2) to (9). Note that gcd(D(C)) = 1. Let us denote (9) with objective vector h ∈ Z n−m by IP ≤ (h) and its natural linear relaxation by LP ≤ (h). We apply Theorem 2 to C and perform a case-by-case analysis depending on the output.
i) The algorithm calculates and returns D(C). If 0 / ∈ D(C), C is nondegenerate and IP ≤ (h) can be solved using the algorithm in [1]. Thus, assume that 0 ∈ D(C). C has no duplicative relations. As gcd(D(C)) = 1, this implies that C is {a, b, 0}-modular for a ≥ b > 0, where gcd({a, b}) = 1 and (a, b) = (2, 1). Thus, C satisfies the assumptions of Theorem 1. As a consequence of Theorem 1, there exist elementary column operations which transform C such that its first n − m − 1 columns are TU, i.e., there is U ∈ Z (n−m)×(n−m) unimodular such that CU = [T | d], where T is TU and d ∈ Z n . Substituting z := U −1 y yields the equivalent problem where we have used that y = U z ∈ Z n−m ⇔ z ∈ Z n−m as U preserves integrality. Let z * be an optimal solution to the mixed-integer linear program which can be found in polynomial time [18,Chapter 18.4]. If no such solution exists, (11) is infeasible. Fixing z n−m := z * n−m in (12) induces an LP in dimension n − m − 1. Letz be a vertex solution to this LP, which can be found efficiently (see, for example, [13]). 6 Since T is TU,z ∈ Z n−m−1 . The solution [z | z * n ] has the same objective value as z * and is optimal for (11) since it is integral and (12) is a relaxation of (11).
This case is more involved because we do not have any information as to which other elements might be contained in D(C). Assume w.l.o.g. that LP ≤ (h) is feasible and that LP ≤ (h) is bounded. We postpone the unbounded case to the end of the proof. Calculate an optimal vertex solution v to LP ≤ (h). If v ∈ Z n−m , then v is also optimal for IP ≤ (h). Thus, assume that v ∈ Z n−m and let I ⊆ [n] be the indices of tight constraints at v, i.e., C I,· v = g I . In what follows, we prove that we may assume w.l.o.g. that (a) 0 ∈ D(C), (b) k = 1, and (c) every nonzero (n − m) × (n − m) subdeterminant of C I,· is equal to ±2. 7 (a) From Lemma 1 applied to C for d = 3 we obtain three possible results: |D(C)| ≥ 4, 0 / ∈ D(C) or 0 ∈ D(C). In the first case we are done and in the second case, C is nondegenerate and IP ≤ (h) can be solved using the algorithm in [1]. Therefore, w.l.o.g., 0 ∈ D(C).
Let IP cone ≤ (h) := max{h T y : C I,· y ≤ g I , y ∈ Z n−m }. As C I,· is bimodular, this is a BIP. By possibly perturbing the vector h (e.g. by adding 1 M · i∈I C i,· for a sufficiently large M > 0), we can assume that v is the unique optimal solution to LP ≤ (h), which will allow us to apply Theorem 4. Solve IP cone ≤ (h) using the algorithm by [2]. If IP cone ≤ (h) is infeasible, so is IP ≤ (h). Let y ∈ Z n−m be an optimal solution for IP cone ≤ (h). It follows that either, y is also optimal for IP ≤ (h) or that |D(C)| ≥ 4: If y is feasible for IP ≤ (h), it is also optimal since IP cone ≤ (h) is a relaxation of IP ≤ (h). If C is bimodular, Theorem 4 states that y is feasible for IP ≤ (h), i.e., it is optimal for IP ≤ (h). Thus, if y is not feasible for IP ≤ (h), D(C) contains an element which is neither 0 nor 1 nor 2. As {2, 1, 0} ⊆ D(C) by (a) and (b), this implies that |D(C)| ≥ 4.
It remains to explain why we may assume that LP ≤ (h) is bounded. If not, IP ≤ (h) is either infeasible or unbounded. More precisely, IP ≤ (h) is unbounded if and only if {y ∈ Z n−m : Cy ≤ g} is feasible. We reduce the feasibility test of this set to a bounded IP of the same form as above: Set s := C 1,· . By construction, LP ≤ (s) is bounded. Solve IP ≤ (s) using our algorithm above. Either, we determine a feasible point of {y ∈ Z n−m : Cy ≤ g} in which case IP ≤ (h) is unbounded, we find that this set is infeasible, or we find that |D(C)| ≥ 4.