# All the solutions of a polynomial system over a finite ring

Let $E$ be a finite list of polynomial equations with variables $t_0, \dots, t_r$ over the finite ring of integers modulo $n$ (for some $n$). We can compute the Groebner basis as follows:

```
ZN=Integers(n)
R=PolynomialRing(ZN,r,"t")
R.inject_variables()
Id=R.ideal(E)
G=Id.groebner_basis()
```

Usually, over a field and if `Id.dimension()=0`

then we can get all the solutions by `Id.variety()`

. But here the dimension is not necessarily $0$ and moreover it is not over a field but a ring, the finite ring of integers modulo $n$. By finiteness of the ring, there still have finitely many solutions. How to get them all?

*Example*: $n=248832$, $r=10$ and:

```
sage: G
[t4*t7, t7*t8, t7*t9, t0, t1, t2, t3 + 248831*t4, 2*t4, t5 + 248783*t7, t6 + 11*t7, 9*t7, 4*t8 + 248828*t9, 16*t9]
```

In your example, all non-linear polynomials (like

`t4*t7`

) are reducible and furthermore are products of linear factors. So, it's enough to iterate over their factors, making them equal to divisors of zero, to obtain a number of systems of linear equations, which can be solved via integer lattices like explained in https://ask.sagemath.org/question/625...@Max Alekseyev Is it working as well for the finite ring of integers modulo $n$?

The standard approach to modeling "modulo $n$" is by adding a term $n\cdot z_i$ to the $i$-th equation (where $z_i$ are new integer variables) and considering the resulting system over the integers.