<p>The answer to (1) is yes (regardless of the properties D.W. asked for in the comments), depending on how $R$ is given: First, note that since $R$ is finite, the abelian group $(R,+)$ is of the form $\mathbb{Z}_{p_1^{k_1}} \oplus \dotsb \oplus \mathbb{Z}_{p_\ell^{k_\ell}}$, where $\ell \leq \log_2|R|$. Now, if $R$ is only given to you by generators and relations, even finding this decomposition is as hard as factoring (but given a factoring oracle, it can then be done easily). But if $R$ is fixed for all time (not part of the input), then this can be done as a once-and-for-all off-line precomputation, or if $R$ is part of the input, this can be done in $O(|R|)$ steps (even when given generators and relations).</p>

<p>So depending on your assumptions, the preceding step is either hard or easy. But let's suppose it's done. Now we'll use two viewpoints on the elements of $R$ to reduce to linear algebra over abelian groups.</p>

<p>Viewpoint 1: We may consider elements of $R$ as "vectors" with $\ell$ integer coordinates, where we consider the $i$-th coordinate modulo $p_i^{k_i}$. </p>

<p>Viewpoint 2: This requires a little setup. Let $Hom(\mathbb{Z}_{p_j^{k_j}}, \mathbb{Z}_{p_i^{k_i}})$ denote the set of ring homomorphisms between these two rings. In particular, when $p_i \neq p_j$, this is zero; when $p_i = p_j$ if $k_i &lt; k_j$ then this involves taking element of $\mathbb{Z}_{p_j^{k_j}}$ modulo $p_i^{k_i}$, and possibly multiplying it by an element of $\mathbb{Z}_{p_i^{k_i}}$ (which we may represent by an integer, treated modulo $p_i^{k_i}$); if $k_i &gt; k_j$ it involves possibly multiplying by an element of $\mathbb{Z}_{p_j^{k_j}}$ (represented by an integer), and then applying the unique embedding of $\mathbb{Z}_{p_j^{k_j}}$ into $\mathbb{Z}_{p_i^{k_i}}$ (as the multiples of $p_i^{k_i-k_j}$, modulo $p_i^{k_i}$)</p>

<p>Now, consider the left multiplicative action of any $r \in R$ on $R$. Then we may associate to $r$ an $\ell \times \ell$ matrix, where the $(i,j)$ entry is an element of $Hom(\mathbb{Z}_{p_j^{k_j}}, \mathbb{Z}_{p_i^{k_i}})$, which can be represented by an integer, following the conventions above.</p>

<p>Now, replace each entry of $A$ by the associated $\ell \times \ell$ matrix as in viewpoint 2, replace each entry of $b$ by the associated vector as in viewpoint $1$, and replace each entry of $x$ with a vector of length $\ell$ (as in viewpoint 1).</p>

<p>Now the original problem has been reduced to linear algebra over abelian groups, which can be solved in polynomial time (see, e.g., Mikael Goldmann and Alexander Russell. The complexity of solving equations over finite groups. Inf. Comput., 178(1):253–262, 2002).</p>

CC BY-SA 3.0
2016-09-02T17:09:35.957Z
Beautiful.  This shows that the problem is at most as hard as factoring.  Can we prove it is at least as hard as factoring?  Can we find a reduction from factoring, i.e., given $n$ can we find an explicit example of a problem instance where the solution to that problem instance reveals the factorization of $n$?
D.W.
CC BY-SA 3.0
2016-09-02T04:28:31.070Z
2016-09-02T04:28:31.070Z
Joshua Grochow
<p>Let $R$ be a finite ring with operations $(+,\cdot)$. Let $A \in R^{m\times n}$ and 
$b\in R^{m}$.</p>

<p>Questions: </p>

<ol>
<li>What is the complexity of counting the number of solutions to the system of equations $Ax = b$? Can it be done in polynomial time? </li>
<li>More generally, let $R$ is a finite set and $(+,\cdot)$ be binary opeartions such that $(R,+)$ and $(R,\cdot)$ are (not necessarily commutative) semigroups. What is the complexity of counting the number of solutions to a system of linear equations $Ax=b$? </li>
</ol>

<p>Note that it is well known that the answer to Question 1 is affirmative if the the ring $R$ is a finite field. </p>

CC BY-SA 3.0
2016-09-01T15:13:13.247Z
Perhaps [Smith normal form](https://en.wikipedia.org/wiki/Smith_normal_form) can help in some cases.
Yuval Filmus
CC BY-SA 3.0
2016-09-01T23:01:47.340Z
You might want to narrow this down by specifying what type of ring you are talking about.  Are we guaranteed that the ring has a multiplicative identity?  Commutative ring?  Principle Ideal Domain?  Division ring?  Or do you want to know for the general case, where the ring need not be commutative?  I suggest you take a look at http://math.stackexchange.com/q/414385/14578.  Also consider the case of the ring of integers modulo $N$ where $N=pq$ is a product of two different prime numbers, chosen large enough that $N$ is hard to factor, to see one hard case.
D.W.
<reference-request><linear-algebra><complexity>
Number of solutions for a system of linear equations over a finite ring
Mateus de Oliveira Oliveira
# Number of solutions for a system of linear equations over a finite ring

(Asked by: username_0 on 2016-09-01)

Let $R$ be a finite ring with operations $(+,\cdot)$. Let $A \in R^{m\times n}$ and
$b\in R^{m}$.

Questions:

1. What is the complexity of counting the number of solutions to the system of equations $Ax = b$? Can it be done in polynomial time?
2. More generally, let $R$ is a finite set and $(+,\cdot)$ be binary opeartions such that $(R,+)$ and $(R,\cdot)$ are (not necessarily commutative) semigroups. What is the complexity of counting the number of solutions to a system of linear equations $Ax=b$?

Note that it is well known that the answer to Question 1 is affirmative if the the ring $R$ is a finite field.

**Tags:** reference-request, linear-algebra, complexity

> **Comments:**
> **username_1**: Perhaps [Smith normal form](https://en.wikipedia.org/wiki/Smith_normal_form) can help in some cases.  
> **username_2**: You might want to narrow this down by specifying what type of ring you are talking about.  Are we guaranteed that the ring has a multiplicative identity?  Commutative ring?  Principle Ideal Domain?  Division ring?  Or do you want to know for the general case, where the ring need not be commutative?  I suggest you take a look at http://math.stackexchange.com/q/414385/14578.  Also consider the case of the ring of integers modulo $N$ where $N=pq$ is a product of two different prime numbers, chosen large enough that $N$ is hard to factor, to see one hard case.  

---

## 1 answers

### Answer by username_3 on 2016-09-02. Score: 7

The answer to (1) is yes (regardless of the properties username_2 asked for in the comments), depending on how $R$ is given: First, note that since $R$ is finite, the abelian group $(R,+)$ is of the form $\mathbb{Z}\_{p\_1^{k\_1}} \oplus \dotsb \oplus \mathbb{Z}\_{p\_\ell^{k\_\ell}}$, where $\ell \leq \log\_2|R|$. Now, if $R$ is only given to you by generators and relations, even finding this decomposition is as hard as factoring (but given a factoring oracle, it can then be done easily). But if $R$ is fixed for all time (not part of the input), then this can be done as a once-and-for-all off-line precomputation, or if $R$ is part of the input, this can be done in $O(|R|)$ steps (even when given generators and relations).

So depending on your assumptions, the preceding step is either hard or easy. But let's suppose it's done. Now we'll use two viewpoints on the elements of $R$ to reduce to linear algebra over abelian groups.

Viewpoint 1: We may consider elements of $R$ as "vectors" with $\ell$ integer coordinates, where we consider the $i$-th coordinate modulo $p\_i^{k\_i}$.

Viewpoint 2: This requires a little setup. Let $Hom(\mathbb{Z}\_{p\_j^{k\_j}}, \mathbb{Z}\_{p\_i^{k\_i}})$ denote the set of ring homomorphisms between these two rings. In particular, when $p\_i \neq p\_j$, this is zero; when $p\_i = p\_j$ if $k\_i < k\_j$ then this involves taking element of $\mathbb{Z}\_{p\_j^{k\_j}}$ modulo $p\_i^{k\_i}$, and possibly multiplying it by an element of $\mathbb{Z}\_{p\_i^{k\_i}}$ (which we may represent by an integer, treated modulo $p\_i^{k\_i}$); if $k\_i > k\_j$ it involves possibly multiplying by an element of $\mathbb{Z}\_{p\_j^{k\_j}}$ (represented by an integer), and then applying the unique embedding of $\mathbb{Z}\_{p\_j^{k\_j}}$ into $\mathbb{Z}\_{p\_i^{k\_i}}$ (as the multiples of $p\_i^{k\_i-k\_j}$, modulo $p\_i^{k\_i}$)

Now, consider the left multiplicative action of any $r \in R$ on $R$. Then we may associate to $r$ an $\ell \times \ell$ matrix, where the $(i,j)$ entry is an element of $Hom(\mathbb{Z}\_{p\_j^{k\_j}}, \mathbb{Z}\_{p\_i^{k\_i}})$, which can be represented by an integer, following the conventions above.

Now, replace each entry of $A$ by the associated $\ell \times \ell$ matrix as in viewpoint 2, replace each entry of $b$ by the associated vector as in viewpoint $1$, and replace each entry of $x$ with a vector of length $\ell$ (as in viewpoint 1).

Now the original problem has been reduced to linear algebra over abelian groups, which can be solved in polynomial time (see, e.g., Mikael Goldmann and Alexander Russell. The complexity of solving equations over finite groups. Inf. Comput., 178(1):253–262, 2002).

> **Comments:**
> **username_2**: Beautiful.  This shows that the problem is at most as hard as factoring.  Can we prove it is at least as hard as factoring?  Can we find a reduction from factoring, i.e., given $n$ can we find an explicit example of a problem instance where the solution to that problem instance reveals the factorization of $n$?  

---

