Algorithm for solving systems of linear equations mod 2 over non-square matrix

65 Views Asked by At

I am trying to write an algorithm that finds a solution to a system of linear xor equations $A x = b$ where A is a $n \times m$ boolean matrix with (possibly) more columns than rows $(n < m)$. I have implemented a variant of Gaussian elimination along the lines of this post. However, since there are more variables than equations, I am still left with a (simplified) system of equations that needs to be solved after $A$ has been reduced.

I was looking up on computing the pseudo-inverse for $A$ with singular value decomposition implementations but I feel like this is overkill for this case of linear boolean equations. Is there a more clever way? Also I have checked out several C++ libraries, however none of them supports non square boolean matrices and corresponding XOR operations. Also I used SageMath's .solve_right() to check and it does yield solutions for the examples I have tried out - so for my particular test cases there indeed seem to be solutions for the system of equations.

As example consider the matrix $A$ (which is already reduced):

$A = \left(\begin{array}{rrr} 1 &0 &0 &1 &0 &1 &1 \\ 0 &1 &0 &1 &1 &0 &1 \\ 0 &0 &1 &0 &1 &1 &1\\ \end{array}\right)$

and

$b = (0, 1, 0)$

How can I algorithmically solve the system now to obtain the solution (computed with SageMath) $x = (0, 1, 0, 0, 0, 0, 0)$?

Thanks a lot in advance.