8

Consider m by n matrices M, all of whose entries are 0 or 1. For a given M, the question is whether there exists a non zero vector v, all of whose entries are -1, 0 or 1 for which Mv = 0. For example,

      [0 1 1 1]
M_1 = [1 0 1 1]
      [1 1 0 1]

In this example, there is no such vector v.

      [1 0 0 0]
M_2 = [0 1 0 0]
      [0 0 1 0]

In this example, the vector (0,0,0,1) gives M_2v = 0.

Given an m and n, I would like to find if there exists such an M so that there is no non-zero v such that Mv = 0.

If m = 3 and n = 4 then the answer is yes as we can see above.

I am currently solving this problem by trying all different M and v which is very expensive.

However, is it possible to express the problem as an integer programming problem or constraint programming problem so I can use an existing software package, such as SCIP instead which might be more efficient.

Simd
  • 19,447
  • 42
  • 136
  • 271
  • 1
    Isn't the answer always `yes` ? If I understood the question properly, any matrix with a column having elements set to zero will fit the answer. And this is valid for any `m` and `n`. – rpsml Jul 10 '15 at 07:55
  • 1
    @rpsml No, the matrix `M` might be square and regular, and the problem demands for a vector with _nonzero_ entries. It is necessary to check whether `M` has a nontrivial Kernel which contains a nonzero vector having entries from `{0,1,-1}`. – Codor Jul 10 '15 at 08:01
  • 1
    @rpsml I think you might have misread the question. I would like to find if there exists such an M so that there is **no** non-zero v such that Mv = 0. – Simd Jul 10 '15 at 09:38
  • @Codor and @user2179021: I think I still do not get the question. If the question is: "is there a pair `M` (size `m x n`) and `v` (size `n`) so that `M v = 0` if `v` is not `0` (and I am adding and if `M` is not `0 ` either) ? For this question the answer is yes. Basically the example in the question can be generalized to any size `m x n`: take any matrix `M` and set its last column to `0` (all other elements can be random `0's` and `1's`). Take a vector `v^t = ( 0 0 0 0 ... 1 )`. This vector is non-zero and its product with `M` is a null vector. What is the flaw in my construction ? – rpsml Jul 10 '15 at 11:54
  • @rpsml Sorry for the confusion. The question is, is there an M such that there **does not exist a non-zero v** such that Mv = 0. Is there some way we can chat live on stackoverflow? – Simd Jul 10 '15 at 11:56
  • @rpsml to be a little clear. The question *is not* the one you stated. – Simd Jul 10 '15 at 12:07
  • 1
    @dorothy I stand corrected. Thanks for the clarification. – rpsml Jul 10 '15 at 12:14
  • @dorothy To answer the question in part: If `m = n`, if `M` is the unit matrix of dimension `m` times `m`, `Mv=0` is true if and only if `v` is the zero vector, which means that the answer to the problem is *yes* for the case `m = n`. – Codor Jul 10 '15 at 12:39
  • @Codor Thank you. You are right the identity matrix solves it for a square matrix with a yes. It's trickier when `m < n` however . – Simd Jul 10 '15 at 12:40
  • @dorothy I believe that for the case `m < n` (where `M` cannot have full rank and hence a kernel of nonzero dimension), one could use Gaussian elimination or elementary row operations to transform `M` into an upper diagonal matrix, chose `v` in such a way that it is zero except for a position of the missing step in the transformed `M` and apply to `v` the inverses of the elementary row operations. If I'm not mistaken, one would arrive at a `v'` with all zeros and a single entry `1` or `-1`; the `-1` would be okay since `-v` would also be contained in the kernel of `M`. – Codor Jul 10 '15 at 12:53
  • @Codor M_1 in the question must be a counter example to this if what you are saying is that the answer is always no. – Simd Jul 10 '15 at 12:54
  • @user2179021 No, my idea is wrong. `M_1` has rank `3` which means that the kernel has dimension `1`. Applying gaussian elimination yields that `{(1,1,1,-2)}` is a basis of the kernel, however the vector `(1,1,1,-2)` is apparently linearly independent from any vector with entries in `{0,1,-1}`. – Codor Jul 10 '15 at 13:26
  • For `n = m+1` and `m >= 3`, the matrix `M_1` nicely generalizes: the matrix with all `1` except on the diagonal is such a matrix. The kernel of that matrix is the 1-dimensional space of multiples of `(1,1,1,...,1,1-m)`, which does not contain any vector made of just `{0,1,-1}`. – Daniel Martin Jul 13 '15 at 21:28
  • Also, if the answer is "yes" for `(m,n)`, then it is "yes" for `(m+k,n)` for any positive integer `k`: just repeat any of the rows of the `M` that works for `(m,n)`. As a consequence, you're really searching, for each `n`, what is the minimal `m` such that the answer for `(m,n)` is "yes". Also, in the exhaustive search, you can skip any matrix with two equal rows since if that worked that would mean the answer was "yes" for an even smaller `m`. Since you can shuffle the rows as well, you can then assume that the rows are strictly increasing. – Daniel Martin Jul 14 '15 at 07:03

3 Answers3

6

This question is probably more mathematical than progamming. I haven't found the final answer yet, but at least some ideas are here:

We can re-state the problem in the following way.

Problem A: Fix positive integers m and n. Let S be the set of n-dimensional vectors whose entries are 0 or 1. Does there exist any m by n matrix M whose entries are 0 or 1, such that, for any two different vectors v_1 and v_2 in S, the vectors Mv_1 and Mv_2 are different. (Or, you may say that, the matrix M, considered as an application from n-dimensional vectors to m-dimensional vectors, is injective on the set S.)

In brief: given the pair (m, n), does there exist such an injective M?

Problem A is equivalent to the original problem. Indeed, if Mv_1 = Mv_2 for two different v_1 and v_2 in S, then we have M(v_1 - v_2) = 0, and the vector v_1 - v_2 will have only 0, 1, - 1 as entries. The inverse is obviously also true.

Another reinterpretation is:

Problem B: Let m, n be a positive integer and S be the set of n-dimensional vectors whose entries are 0 and 1. Can we find m vectors r_1, ..., r_m in S, such that, for any pair of different vectors v_1 and v_2 in S, there exists an r_i, which satisfies <v_1, r_i> != <v_2, r_i>? Here <x, y> is the usual inner product.

In brief: can we choose m vectors in S to distinguish everyone in S by taking inner product with the chosen ones?

Problem B is equivalent to Problem A, because you can identify the matrix M with m vectors in S.

In the following, I will use both descriptions of the problem freely.

Let's call the pair (m, n) a "good pair" if the answer to Problem A (or B) is yes.

With the description of Problem B, it is clear that, for a given n, there is a minimal m such that (m, n) is a good pair. Let us write m(n) for this minimal m associated to n.

Similarly, for a given m, there is a maximal n such that (m, n) is good. This is because, if (m, n) is good, i.e. there is an injective M as stated in Problem A, then for any n' <= n, erasing any n - n' columns of M will give an injective M'. Let us write n(m) for this maximal n associated to m.

So the task becomes to calculate the functions m(n) and/or n(m).

We first prove several lemmas:

Lemma 1: We have m(n + k) <= m(n) + m(k).

Proof: If M is an m(n) by n injective matrix for the pair (m(n), n) and K is an m(k) by k injective matrix for the pair (m(k), k), then the (m(n) + n(k)) by (n + k) matrix

[M 0]
[0 K]

works for the pair (m(n) + 1, n + 1). To see this, let v_1 and v_2 be any pair of different (n + k)-dimensional vectors. We may cut both of them into two pieces: the first n entries, and the last k entries. If the first pieces of them are not equal, then they can be distinguished by one of the first m(n) rows of the above matrix; if the first pieces of them are equal, then the second pieces of them must be different, hence they can be distinguished by one of the last m(k) rows of the above matrix.

Remark: The sequence m(n) is thus a subadditive sequence.

A simple corollary:

Corollary 2: We have m(n + 1) <= m(n) + 1, hence m(n) <= n.

Proof: Take k = 1 in Lemma 1.

Note that, from other known values of m(n) you can get better upper bounds. For example, since we know that m(4) <= 3, we have m(4n) <= 3n. Anyway, these always give you O(n) upper bounds.

The next lemma gives you a lower bound.

Lemma 3: m(n) >= n / log2(n + 1).

Proof: Let T be the set of m(n)-dimensional vectors whose entries lie in {0, 1, ..., n}. Any m(n) by n matrix M gives a map from S to T, sending v to Mv.

Since there exists an M such that the above map is injective, then necessarily the size of the set T is at least the size of the set S. The size of T is (n + 1)^m, and the size of S is 2^n, thus we have:

(n + 1)^m(n) >= 2^n

or equivalently, m(n) >= n / log2(n + 1).

Back to programming

I have to say that I haven't figured out a good algorithm. You might restate the problem as a Set Cover Problem, as follows:

Let U be the set of n dimensional vectors with entries 1, 0 or - 1, and let S be as above. Every vector w in S gives a subset C_w of U: C_w = {v in U: <w, v> != 0}. The question is then: can we find m vectors w such that the union of the subsets C_w is equal to U.

The general Set Cover Problem is NP complete, but in the above Wiki link there is an integer linear program formulation.

Anyway, this cannot take you much further than n = 10, I guess.

I'll keep editting this answer if I have further results.

WhatsUp
  • 1,618
  • 11
  • 21
  • A set cover reduction is potentially interesting how large would an instance be? – Simd Jul 16 '15 at 14:37
  • As I explained, you will have a set `U` of size `3^n`, and `2^n` subsets of `U`. The task is to find a covering of `U` with minimal number of subsets. But the time cost is still expensive. What are the values of `(m, n)` that you are interested in? – WhatsUp Jul 16 '15 at 14:42
  • Ah.. An instance of set cover of size 3^n is not good. n = 50 and m = 25 is an interesting set of parameters. – Simd Jul 16 '15 at 14:43
  • 1
    Well ... yes, as I said it's not very helpful. I will think about your particular pair `(25, 50)` later. Perhaps this case is attackable with some ugly optimizations. – WhatsUp Jul 16 '15 at 14:49
3

i think using Boolean matrix multiplication will allow you to solve the Mv=0 problem with only 1's & 0's more efficiently. Using this method you should be able to solve without worrying about rank deficiencies due to the RHS equaling zero. Here is a link to documentation on some algorithms for using BMM:

http://theory.stanford.edu/~virgi/cs367/lecture2.pdf

bern
  • 366
  • 1
  • 10
  • 1
    I am not sure how this addresses the question. The problem is this: Given an m and n, I would like to find if there exists such an M so that there is no non-zero v such that Mv = 0. How does your answer solves this problem? – Simd Jul 14 '15 at 06:42
  • while it does not give you the exact code to solve your problem it shows how to take advantage of the Boolean nature of your data to perform the Ax=0 problem that you have. Without constraining the problem to this set, the solution becomes poorly conditioned since in order to solve for x, A must be divided by zeros. Using boolean matrix algebra seems like a good way around this issue – bern Jul 14 '15 at 14:52
0

If I understand the question, you are asking for a given m,n if there exists a Matrix M, (Linear Transformation), with a trivial kernal, that is Ker(M)={0}.

Recall that this is the same as the Nullspace of M being zero 0, Null(M)=0.

For the system Mv=0 the nullspace is {0} if the rank of the matrix M is equal to the dimension of v. So your question comes down to asking about the existence of a mxn matrix with rank dim(v)=m. The problem in this form has been discussed here

Generate "random" matrix of certain rank over a fixed set of elements

You can also frame this question in terms of determinants because if M has determinant=0 then the nullspace is nontrivial. So you can think about this question in terms of constucting a matrix with entries in {-1,0,1} with a desired determinant.

I hope this helps.

Community
  • 1
  • 1
mdh1665
  • 46
  • 1
  • No that's not quite it. The kernel isn't allowed to contain any non-zero vectors whose elements are -1, 0, 1. It could contain other vectors and in fact is guaranteed to if the elements are allowed to vary over the reals the matrix is non-square. – Simd Jul 16 '15 at 13:00
  • Ah, I misread the problem. I thought entries in both the matrix and the vector v were from {0,1,-1}, and hence you were working over the vector space over {0,1,-1}. My apologies. – mdh1665 Jul 16 '15 at 14:34
  • Besides, there's no such a thing as "vector space over {0, 1, - 1}"... the set is not a field. – WhatsUp Jul 16 '15 at 14:55
  • @whatUip, You are absolutely right, I am an idiot. For some reason I was thinking of F_3 and did not check to see if what was thinking made sense. But clearly it is not a group with respect to +. I will bow out in shame. – mdh1665 Jul 16 '15 at 15:14