15

I am trying to construct all inequivalent $8\times 8$ matrices (or $n\times n$ if you wish) with elements 0 or 1. The operation that gives equivalent matrices is the simultaneous exchange of the i and j row AND the i and j column. eg. for $1\leftrightarrow2$ \begin{equation} \left( \begin{array}{ccc} 0 & 0 & 0 \\ 0 & 1 & 1 \\ 1 & 0 & 0 \end{array} \right) \sim \left( \begin{array}{ccc} 1 & 0 & 1 \\ 0 & 0 & 0 \\ 0 & 1 & 0 \end{array} \right) \end{equation}

Eventually, I will also need to count how many equivalent matrices there are within each class but I think Polya's counting theorem can do that. For now I just need an algoritmic way of constructing one matrix in each inequivalence class. Any ideas?

Raphael
  • 72,336
  • 29
  • 179
  • 389
Heterotic
  • 391
  • 1
  • 2
  • 12
  • 2
    There are at least $2^{64}/8! \geq 2^{48}$ of these. That's a really large number. – Yuval Filmus Dec 25 '13 at 01:05
  • @Yuval : These are indeed large numbers and for my calculation it really makes a difference if it's $2^{48}$ or $2^{52}$. It could take weeks more to run! This is the reason I am trying to use all the symmetries of the problem at hand. As an aside, this problem originates from model building in String Theory! :) – Heterotic Dec 27 '13 at 10:07
  • What do you intend to do with all these matrices? Where are you going to store them? What's the application? – Yuval Filmus Dec 27 '13 at 12:24
  • Do you know of any way to choose a canonical representative of each equivalence class, such that there is an efficient way to test whether a given $8 \times 8$ matrix is in canonical form? (i.e., such that there is a small circuit $C$ such that $C(M)=1$ if $M$ is in canonical form and $C(M)=0$ otherwise) If you do, then one possible approach might be to use a #SAT solver (applied to the circuit $C$). – D.W. Dec 30 '13 at 00:50
  • @D.W. : There is a natural ordering of these matrices, for example we can consider them as binary numbers of length 64. We could then choose the canonical representative to be the smallest (or biggest) matrix in each equivalence class, but it looks like you need to "findMin" in each class so I don't think this is efficient at all. – Heterotic Dec 30 '13 at 11:04
  • Your definition of equivalence isn't an equivalence because it isn't transitive (take matrix $A$, swap rows 1 and 2 to get $B$, then swap rows 3 and 4 of $B$ to get $C$: $A\sim B$ and $B\sim C$ but, in general, $A\not\sim C$). Do you mean to say that two matrices are equivalent if applying some permutation (not necessarily just a swap of two rows and columns) simultaneously to the rows and columns of $A$ gives $B$? – David Richerby Jul 02 '14 at 14:51
  • 1
    idea: isnt this very similar to graph isomorphism problem? where matrices are graph edge matrices? except those are symmetric... maybe can be leveraged somehow, there is tons of theory on that... – vzn Aug 31 '14 at 15:13
  • 2
    http://math.stackexchange.com/questions/924745/how-to-encode-matrices-uniquely?noredirect=1#924769 – orezvani Sep 09 '14 at 12:35
  • There are not that many 8x8 matrices that are canonically different. Using the nice code given here you can calculate that the number of binary 8x8 matrices is 14685630688. Still a lot and still a challenge to create, however. – smichr May 18 '22 at 05:01

1 Answers1

1

I have made some progress towards answering this question. I am posting here in case anyone else is interested and also because this construction might have some usefulness for (directed) graphs.

Count the number of 1s in each row. Let $a_0$ be the number of rows with zero 1s, $a_1$ the number of rows with one 1 and so on up to $a_8$ which is the number of rows that have eight 1s. Obviously $\sum a_i=8$. The proposed parametrization that I have come to after trial and error is: $$(a_1,\cdots, a_8; T, S)$$ where T is the trace of the matrix and S is $1$ if the matrix is symmetric and $0$ otherwise. T runs from $0$ to $\sum_{i=1}^8 a_i=8-a_0$.

From my trials and errors it looks like that if two matrices are different in this parametrization then they belong to different equivalence classes, so to construct a representative in each class we just scan through the space of parameters as described above.

(Update) It turns out that this parametrization works fine for n=2 but not for n=3 as it can be seen by a brute force calculation. I still think it provides some insight on the structure of the answer and I invite people to try and modify/extend it to cover the most general case.

Heterotic
  • 391
  • 1
  • 2
  • 12
  • 2
    It would be surprising and interesting if this worked. I don't see any obvious reason why this should be sufficient (i.e., why we're guaranteed that if two matrices have the same parameters, then they will be in the same equivalence class). Without some proof, I am skeptical. As a starting point, you could try verifying this conjecture on smaller matrices ($1 \times 1$, $2\times 2$, ..., $7 \times 7$) exhaustively. A better test would be to try using a SAT solver to look for counterexamples to your conjecture. – D.W. Dec 30 '13 at 00:47
  • @D.W. : Indeed it is the proof that this condition is sufficient that troubles me and the one I would like some help with. I'll try verifying it exhaustively for the smaller cases and see what happens. Thanks for the advice! Unfortunately, I have no idea how to use a SAT solver to look for counterexamples. If the conjecture, holds for the smaller matrices, I might start learning about it... – Heterotic Dec 30 '13 at 11:06
  • Makes sense, Heterotic! Actually, I take back my statement about using a SAT solver. I don't know how to use a SAT solver to look for counterexamples, either (it's harder than I thought at first) -- so please ignore that part of my comment. Sorry about that! – D.W. Dec 31 '13 at 06:03
  • The statement in your answer "if two matrices are different in this parametrization then they belong to different equivalence classes" is trivial to prove (just verify that a single exchange operation does not change the parameters). However, in order to use this representation to find all representatives, you'd need the inverse statement. – FrankW Jan 28 '14 at 23:00
  • 2
    There are unequivalent matrices with the same parametrization. Note that by changing the $a_i$ to count the 1's in the columns you also get a parametrization that is invariant under the equivalence operation. From this we can conclude that the matrices with 1's in $(1,4)$ and $(2,3)$ resp. in $(1,4)$ and $(2,4)$ (all remaining entries 0 for both) are not equivalent but have the same parametrization. (Of course this immediately leads to an improved parametrization that also takes the columns into account.) – FrankW Jan 28 '14 at 23:38
  • @FrankW : Thanks for the counterexample. I also noticed myself (but forgot to post it here) that my parametrization works for 2x2 but not for nxn matrices with n>2, by constructing all the inequivalent 3x3. I now believe that taking the columns into account will not be sufficient either. As an aside, the number of inequivalent nxn matrices that can be constructed is series http://oeis.org/A000595 . – Heterotic Jan 29 '14 at 10:23
  • 1
    Heterotic, now that you know your answer doesn't work, I'd suggest deleting your answer so it doesn't confuse others... – D.W. Jan 31 '14 at 04:15