Zero-sum squares in $\{-1, 1\}$-matrices with low discrepancy

Given a matrix $M = (a_{i,j})$ a square is a $2 \times 2$ submatrix with entries $a_{i,j}$, $a_{i, j+s}$, $a_{i+s, j}$, $a_{i+s, j +s}$ for some $s \geq 1$, and a zero-sum square is a square where the entries sum to $0$. Recently, Ar\'evalo, Montejano and Rold\'an-Pensado proved that all large $n \times n$ $\{-1,1\}$-matrices $M$ with discrepancy $|\sum a_{i,j}| \leq n$ contain a zero-sum square unless they are split. We improve this bound by showing that all large $n \times n$ $\{-1,1\}$-matrices $M$ with discrepancy at most $n^2/4$ are either split or contain a zero-sum square. Since zero-sum square free matrices with discrepancy at most $n^2/2$ are already known, this bound is asymptotically optimal.


Introduction
A square S in a matrix M = (a i,j ) is a 2 × 2 submatrix of the form S = a i,j a i,j+s a i+s,j a i+s,j+s .
In 1996 Erickson [11] asked for the largest n such that there exists an n × n binary matrix M with no squares which have constant entries. An upper bound was first given by Axenovich and Manske [2] before the answer, 14, was determined by Bacher and Eliahou in [3].
Recently, Arévalo, Montejano and Roldán-Pensado [1] initiated the study of a zero-sum variant of Erickson's problem. Here we wish to avoid zero-sum squares, squares with entries that sum to 0.
Zero-sum problems have been well-studied since the Erdős-Ginsburg-Ziv Theorem in 1961 [10], which says that any set of 2n−1 integers must contain a set of n integers which sum to 0 modulo n. Much of the research has been on zero-sum problems in finite abelian groups (see the survey [12] for details), but problems have also been studied in other settings such as on graphs (see e.g. [5,6,7,9]). Of particular relevance is the work of Balister, Caro, Rousseau and Yuster in [4] on submatrices of integer valued matrices where the rows and columns sum to 0 mod p, and the work of Caro, Hansberg and Montejano on zero-sum subsequences in bounded sum {−1, 1}-sequences [8].
Given an n × m matrix M = (a i,j ) define the discrepancy of M as the sum of the entries, that is, We say a square S is a zero-sum square if disc(S) = 0, or equivalently, a i,j + a i,j+s + a i+s,j + a i+s,j+s = 0.
We will be interested in {−1, 1}-matrices M which do not contain any zerosum squares. Clearly, matrices with at most one −1 cannot contain a zerosum square and, in general, there are many such matrices when the number of −1s is low. But what happens if there are a similar number of 1s and −1s? In particular, what happens if the matrix M is itself zero-sum?
An n × m {−1, 1}-matrix M = (a i,j ) is said to be t-split for some 0 ≤ t ≤ n + m − 1 if Note that when t = 0 the matrix consists entirely of −1 entries, and when t = n + m − 1 the matrix consists entirely of +1 entries. We say a matrix M is split if there is some t such that a t-split matrix N can be obtained from M by applying vertical and horizontal reflections. Split matrices are of particular interest since they can have low absolute discrepancy, yet they never contain a zero-sum square. However, it is not hard to check that an n × n split matrix cannot have discrepancy 0, and it may still be the case that a zero-sum matrix M must contain a zero-sum square.
This was confirmed by Arévalo, Montejano and Roldán-Pensado in [1]. In fact, they proved that, except when n ≤ 4, every n × n non-split {−1, 1}matrix M with | disc(M)| ≤ n has a zero-sum square. They remark that it should be possible to extend their proof to give a bound of 2n, and they conjecture that the bound Cn should hold for any C > 0 when n is large enough relative to C.
Conjecture 1 (Conjecture 5 in [1]). For every C > 0 there is an integer N such that whenever n ≥ N the following holds: every n × n non-split Let f (n) be the absolute value of the minimum discrepancy of a non-split {−1, 1}-matrix with no zero-sum squares. Arévalo, Montejano and Roldán-Pensado proved that f (n) ≥ n + 1 for all n ≥ 5, and the conjecture would imply that f (n) = ω(n). We improve the lower bound on f to ⌊n 2 /4⌋ + 1 (for all n ≥ 5), showing that f = Ω(n 2 ).
The best known construction for a non-split matrix with no zero-sum squares has discrepancy close to n 2 /2, about twice the lower bound given here, and our computer experiments suggest that this construction is in fact optimal. Although the lower bound now only differs from the upper bound by a constant factor, closing the gap between the upper and lower bounds remains a very interesting problem and we discuss it further in Section 3.
To show that every zero-sum n × n {−1, 1}-matrix (where n ≥ 5) contains a zero-sum square (for n ≥ 5), Arévalo, Montejano and Roldán-Pensado prove that a small t ′ -split submatrix M ′ determines many entries of the matrix M, and their proof leads to the following lemma. An example application is shown in Figure 1.
and suppose t ≤ n.

The submatrix
Furthermore, both a i,j = 1 and a j,i = 1 whenever T < j ≤ T + t − 2 and one of the following holds: Note that we can apply this lemma even when it is a reflection of M ′ which is t-split; we just need to suitably reflect M and potentially multiply by −1, and then undo these operations at the end. The matrix N will always contain at least one of a 1,1 , a 1,n , a n,1 and a n,n , and if N contains two, then M is split.
We will also make use of the following observation. This will be used in conjunction with the above lemma to guarantee the existence of some additional 1s, which allows us to show a particular submatrix has positive discrepancy.
Observation 4. Let M be an n×n {−1, 1}-matrix with no zero-sum squares, and suppose that a i,i = 1 for every i ∈ [n]. Then at least one of a i,j and a j,i is 1. In particular, Figure 1: The entries known from applying Lemma 3. The yellow squares represent −1s and the blue squares represent 1s. The submatrix M ′ is shown in a darker shade. The final lemma we will use to prove Theorem 2 is a variation on Claim 11 from [1]. The main difference between Lemma 5 and the result used by Arévalo, Montejano and Roldán-Pensado is that we will always find a square submatrix, which simplifies the proof of Theorem 2.
Proof. We only prove this in the case n is odd as the case n is even is similar, although simpler. Partition the matrix M into 9 regions as follows. Let the four (n − 1)/2 × (n − 1)/2 submatrices containing a 1,1 , a 1,n , a n,n and a n,1 be A 1 , . . . , A 4 respectively. Let the (n − 1)/2 × 1 submatrix between A 1 and A 2 be B 1 and define B 2 , B 3 and B 4 similarly. Finally, let the central entry be B 5 . The partition is shown in Figure 2a.
As these partition the matrix M, we have Let the overlapping (n + 1)/2 × (n + 1)/2 submatrices containing a 1,1 , a 1,n , a n,n and a n,1 be A ′ 1 , . . . , A ′ 4 (as indicated in Figure 2b). The submatrices B 1 , . . . , B 4 each appear twice in the A ′ i and B 5 appears four times and, by subtracting these overlapping regions, we obtain a second equation for disc(M): respectively, we are done, so we may assume that this is not the case. First, suppose that disc(A i ) > (n − 1) 2 /16 and disc(A ′ i ) > (n + 1) 2 /16 for all i = 1, 2, 3, 4. Since n − 1 is even and disc(A i ) ∈ Z, we must have disc(A i ) ≥ (n − 1) 2 /16 + 1/4, and similarly, disc(A ′ i ) ≥ (n + 1) 2 /16 + 1/4. Adding the equations (1) and (2) we get the bound which reduces to disc(B 5 ) ≥ 5/4. This gives a contradiction since B 5 is a single square. Similarly we get a contradiction if, for every i, both disc(A i ) < −(n − 1) 2 /16 and disc(A ′ i ) < −(n + 1) 2 /16. This only leaves the case where two of the 8 submatrices have different signs. If A ′ i > (n + 1) 2 /16, then, for n ≥ 8, and either | disc(A i )| ≤ (n − 1) 2 /16, a contradiction, or disc(A i ) > 0. By repeating the argument when disc(A ′ i ) is negative, it follows that A i and A ′ i have the same sign for every i. In particular, two of the A ′ i must have different signs, and we can apply an interpolation argument as in [1].
Armed with the above results, we are now ready to prove our main result, but let us first give a sketch of the proof which avoids the calculations in the main proof.
Sketch proof of Theorem 2. Assume we have an n×n {−1, 1}-matrix M with no zero-sum squares and which has | disc(M)| ≤ n 2 /4. We will prove the result by induction, so we assume that the result is true for 5 ≤ n ′ < n.
Applying Lemma 5 gives a submatrix M ′ with low discrepancy. Since M ′ also contains no zero-sum squares, we know that it is split by the induction hypothesis. Applying Lemma 3 then gives a lot of entries M and, in particular, a submatrix N with high discrepancy. Since we are assuming that M has low discrepancy, the remainder M \ N of M not in N must either have low discrepancy or negative discrepancy. In both cases we will find B, a submatrix of M with low discrepancy. When the discrepancy of M \ N is low, we use an argument similar to the proof of Lemma 5, and when the discrepancy of M \ N is negative, we find a positive submatrix using Observation 4 and then use an interpolation argument.
By the induction hypothesis, B must also be split and we can apply Lemma 3 to find many entries of M. By looking at specific a i,j , we will show that the two applications of Lemma 3 contradict each other.
We now give the full proof of Theorem 2, complete with all the calculations. To start the induction, we must check the cases n < 30 which is done using a computer. The problem is encoded as a SAT problem using PySAT [13] and checked for satisfiability with the CaDiCaL solver. The code to do this is attached to the arXiv submission.
Proof of Theorem 2. We will use induction on n. A computer search gives the result for all n < 30, so we can assume that n ≥ 30 and that the result holds for all 5 ≤ n ′ < n.
Suppose, towards a contradiction, that M is an n×n matrix with no zerosum squares and | disc(M)| ≤ n 2 /4 . By Lemma 5, we can find an n ′ × n ′ submatrix M ′ = M[p : p+n ′ −1, q : q +n ′ −1] with (n−1)/2 ≤ n ′ ≤ (n+1)/2 and | disc(M ′ )| ≤ (n ′ ) 2 /4. By the induction hypothesis and our assumption that M doesn't contain a zero-sum square, the matrix M ′ must be split. By reflecting M and switching −1 and 1 as necessary, we can assume that the submatrix M ′ is t ′ -split for some t ′ , and that t := t ′ + p + q − 2 ≤ n.
We will want to apply Lemma 3, for which we need to check If t + ⌊t/2⌋ ≥ n, the matrix M is t-split and we are done, so we can assume that this is not the case, and that t ≤ 2n/3. We will also need the following bound on 2t + ⌊t/2⌋ − 2, which follows almost immediately from (3).
Proof. Substituting n ′ ≥ (n − 1)/2 into (3) gives the following bound on t: We now lower bound ⌊t/2⌋ by (t − 1)/2 to find 2t + ⌊t/2⌋ − 2 ≥ 2t + t − 5 2 The right hand side grows like √ 75 8 n asymptotically, which is faster than n, so the claim is certainly true for large enough n. In fact, the equation 5   Let k = ⌈5n/6⌉ and let N = M[1 : k, 1 : k] be the k × k sub-matrix in the top left corner which contains a 1,1 . We will apply Lemma 3 and Observation 4 to guarantee lots of 1s in N, and therefore ensure N has large discrepancy. This will mean that the rest of M which is not in N must have low discrepancy, and we can find another split submatrix B.

Proof.
Consider the 11 (n − k) × (n − k) disjoint submatrices B 1 , . . . , B 11 of M given by and shown in Figure 3. The submatrix B 1 contains a n,n and sits in the bottom right of M, while the others lie along the bottom and right-hand edges of M. If one of the B i satisfies | disc(B i )| ≤ (n − k) 2 /4, we are done by taking this submatrix as B, so suppose this is not the case.
As disc(B 1 ) > 0, if disc(B i ) < 0 for any i = 1, we can use an interpolation argument as in Lemma 5 to find the claimed matrix. The argument only requires which is true for (n − k) > 4.
We must now be in the case where disc(B i ) > (n − k) 2 /4 for every i. The bulk of the work in this case will be bounding the discrepancy of the matrix N, and then the discrepancy of M. There are 2n(n − k) − 12(n − k) 2 ≤ 10(n − k) entries of M in the gaps between the B i , or in other words, there are at most 10(n − k) entries a i,j which are not contained in either N or one of the B i . In particular, we have disc(M) ≥ disc(N) + disc(B 1 ) + · · · + disc(B 11 ) − 10(n − k) > disc(N) + 11(n − k) 2 /4 − 10(n − k).
Let s = min {k, t + ⌊t/2⌋} so that M[1 : s, 1 : s] is t split, and let r = k −s be the number of remaining rows in N. Let a 1 , . . . , a 4 be the number of 1s in N guaranteed by Lemma 3, and let a 5 be the number of additional 1s guaranteed by also applying Observation 4. This guarantees that at least one of a i,j and a j,i is 1 for all s + 1 ≤ i, j ≤ k, and a 5 ≥ r(r − 1)/2.
We have the following bounds.
Let us first consider the case where s = k, so that N is t-split. In this case a 2 = · · · = a 5 = 0, and we can easily write down the discrepancy of N as k 2 − t(t + 1). Since k ≥ 5n/6, we get the bound disc(N) ≥ 25n 2 36 − t(t + 1).
Substituting this into (4) and using the bounds (n − 5)/6 ≤ n − k ≤ n/6 we get For n ≥ 4, the righthand side is greater than n 2 /4 whenever Since we have assumed t ≤ 2n/3, we get a contradiction for all sufficiently large n. In fact, we get a contradiction for all n ≥ 40. The remaining cases need to be checked using exact values for the floor and ceiling functions which we do with the help of a computer. Now we consider the case where s = t + ⌊t/2⌋ which is very similar, although more complicated. To be in this case, we must have t + ⌊t/2⌋ ≤ k which implies and t ≤ (5n + 8)/9 ≈ 0.556n.
We have the bounds and so, for n ≥ 44, disc(M) > n 2 /4. This again leaves a few cases which we check with the help of a computer.
Given a submatrix B as in the above claim we apply the induction hypothesis, noting that (n−k) ≥ 5 since n ≥ 30, to find that B is split. Let C be the split submatrix obtained from applying Lemma 4 to B, and let C be ℓ-split up to rotation. Note that ℓ ≥ 3 as (n − k) ≥ 5 and | disc(B)| ≤ (n − k) 2 /4, and we can assume ℓ ≤ 2n/3 as M is not split.
Hence, C contains exactly one of a 1,1 , a 1,n , a n,1 and a n,n , and we will split into cases based on which one C contains. We will also sometimes need to consider cases for whether the entry is 1 or −1, but in all cases we will find a contradiction.
From Lemma 3 applied to M ′ and Claim 1, we already know some of the entries and we highlight some important entries in the following claim.
Suppose the submatrix C contains a 1,1 so sits in the top-left corner. Since M[1 : t + ⌊t/2⌋ , 1 : t + ⌊t/2⌋] is t-split, C must also be t-split. As C was found by applying Lemma 3 to B, it must contain a −1 from B. Hence, t ≥ 5n/6 which is a contradiction as we assumed that t ≤ 2n/3.
Some illustrative examples of these three cases are shown in Figure 4.
The case where C contains a n,1 is done in the same way with the rows and columns swapped.
This leaves the case where C contains a n,n . Since ℓ ≥ 3, if the entry a n,n equals −1, so does the entry a n−1,n−1 , and this contradicts Claim 3. If instead a n,n = 1, we consider the entry a i,i where i = n + 1 − ⌈(ℓ + 2)/2⌉, which must be −1. However, since ℓ ≤ 2n/3, Figure 4: The three cases when C contains a 1,n and a 1,n = 1. The yellow squares represent some of the a i,j which are known to be −1 from Claim 3 and the blue squares those which are 1. The square which gives the contradiction is marked with a cross. Figure 5: The case where C contains a n,n and a n,n = 1. The square marked with a cross gives a contradiction. and a i,i = 1 by Claim 3. This final contradiction is shown in Figure 5.
We remark that it should be possible to improve the bound n 2 /4 using a similar proof provided one can check a large enough base case. Indeed, we believe that all the steps in the above proof hold when the bound is increased to n 2 /3, but only when n is large enough. For example, Claim 1 fails for n = 127 and our proof of Claim 2 fails for n = 67. Checking base cases this large is far beyond the reach of our computer check, and some new ideas would be needed here.

Open problems
The main open problem is to determine the correct lower bound for the (absolute value of the) discrepancy of a non-split {−1, 1}-matrix with no zero-sum squares. We have improved the lower bound to ⌊n 2 /4⌋ + 1, but this does not appear to be optimal.
The best known construction is the following example by Arévalo, Mon-tejano and Roldán-Pensado [1]. Let M = (a i,j ) be given by a i,j = −1 i and j are odd, 1 otherwise.
This has discrepancy n 2 /2 when n is even and (n − 1) 2 /2 − 1 when n is odd.
With the help of a computer we have verified that this construction is best possible when 9 ≤ n ≤ 32, and we conjecture that this holds true for all n ≥ 9. In fact, our computer search shows that the above example is the unique non-split matrix avoiding zero-sum squares with minimum (in magnitude) discrepancy, up to reflections and multiplying by −1. An example when n = 9 is given in Figure 6. We note that the condition n ≥ 9 is necessary, as shown by the 8 × 8 matrix with discrepancy 30 given in Figure 7. Arévalo, Montejano and Roldán-Pensado prove their result for both n × n and n × (n + 1) matrices, and computational experiments suggest that Theorem 2 holds for n × (n + 1) matrices as well. More generally, what is the best lower bound for a general n × m matrix when n and m are large?