I am fairly new here and with Mathematica too. I have a question regarding Boolean matrices but before this I did a random search and got this Defining an arbitrary binary relation
But I am unable to modify the code to get the desired results.
I am hoping to generate 3 × 3 Boolean matrices, there are 2^9 of them, and I need to know how many of those 2 ^ 9 Boolean matrices are transitive.
Can someone please put me in the right direction?
Thanks
Edit:
Let A=(a_ij)∈M_n(B) be a non-zero matrix. If for any i,j,k in I_n, where I_n={1,2,⋯,n}, when a_ij=a_jk=1 ,we have a_ik=1, then A is said to be transitive.
Futhermore
A is transitive if and only if A^2≤A.
We can set a check on the validity by using the following
T[n_] :=
n*(n - 1)^3 + 1/6*n*(n - 1)^4*(n - 2) +
1/6*n*(n - 1)*(n - 2)*(4*n - 1)
This works for only those boolean matrices which has 3 nonzero elements. For example in 3x3 there are 43 transitive matrices, for 4x4 there are 276 having only 3 nonzero elements.
Edit 2.
I got quick and very positive responses here, which I really appreciate. I have tried to adopt the answers but due to my lack of basic understanding of Mathematica, I am unable to get the desired results. here is what I am looking for
- How to manange a code which can easily work for higher orders such is 3X3, 4X4, 5X5, 6X6?
- I would like to incorporate all the matrices which satisfies the above two definitions more specificly A^2<=A
- I would like to see the complete list of the transitive matrices that I can verify them manually If I had to.
- It would be more helpful if the code includes verfication test as I have mentioned above.
I know I am asking for too much but this work if done manually is beyond my abilities.
Looking forward to your kind replies!
ArrayReshape[#, {3, 3}] & /@ Tuples[{0, 1}, 9];
. $\endgroup$trQ[k_?MatrixQ] := Unitize@MatrixPower[k, 2] == k
and(res = Select[ArrayReshape[#, {3, 3}] & /@ Tuples[{0, 1}, 9], trQ]) // Length
gives me123
. Am I wrong in usingMatrixPower
instead ofDot
? $\endgroup$