Let $n$, $m$, and $q$ be positive integers (with $m > n$), and $A$ be a matrix over $\mathbb{Z}_q^{n \times m}$. Using Mathematica, I want to find the shortest non-zero vectors $x \in \mathbb{Z}_q^m$ such that:
$$Ax=0 \pmod q$$
Note: By "shortest," I mean the vector with the smallest Euclidean norm. I'm not sure if this vector is unique. If it's not, I want a list of vectors with smallest Euclidean norm.
Example:
Let: $n=2, m=3, q=7, A = \left(\begin{matrix} 2 & 1 & 6\\ 1 & 3 & 1 \end{matrix} \right)$. Then, the following vectors are solutions to
{1,1,3} $\quad$ Norm = $\sqrt{11}$
{3,3,2} $\quad$ Norm = $\sqrt{22}$
{2,2,6} $\quad$ Norm = $\sqrt{44}$
{5,5,1} $\quad$ Norm = $\sqrt{51}$
{4,4,5} $\quad$ Norm = $\sqrt{57}$
{6,6,4} $\quad$ Norm = $\sqrt{88}$
Therefore, the vector {1,1,3} is the shortest solution.
PS: I used an exhaustive search to find the above solutions. My approach takes a long time for even small choices of $n$ and $m$, say $n=2, m=8$. Please offer an approach which can at least find solutions for such small parameters.
Edit: As Michael suggested in a comment, I demonstrate the "exhaustive search" code I used. I'm not proud of it at all, as I just wrote the code to find an example for this question.
A = RandomInteger[6, {2, 3}];
x = {a, b, c};
Table[
If[Mod[A.x, 7] == {0, 0}, Print[{x, x // Norm}]],
{a, 0, 6}, {b, 0, 6}, {c, 0, 6}]
Solve
orFindMin
. It's nothing more than an exhaustive search, and that's why it takes a long time to find a solution for even relatively small parameters. $\endgroup$mat = {{2, 3, 2}, {2, 6, 1}}
. Then it turns out that{4,3,2}
is the null vector of interest (though see (1) above-- I do not know why it is of interest). It appeas in the following lattice reduction.In[35]:= LatticeReduce[ Join[NullSpace[A], 7*IdentityMatrix[Length[A[[1]]]]]] Out[35]= {{-2, 2, -1}, {1, -1, -3}, {4, 3, 2}}
$\endgroup$LatticeReduce
is guaranteed to find a vector that is "short" (in Euclidean norm) in a particular sense. But it is not guaranteed to be shortest. In practice, it tends to be close. $\endgroup$