# How to make Sage know that a set is an ideal

I have constructed the following ideal

```
J = {0, x*y*z - x*y - x*z + y*z - x + y - z, x*z - y*z - x + y - 1, x*y*z + x*y + x*z + y*z - z - 1, x*y + x*z + x - y + z, -x*y*z - x*y + x*z - y*z - x - y - z, ....}
```

in the ring

$$ R = F[X,Y,Z]/(X^2-1,Y^2-1,Z^2-1) $$

where $F=GF(3)$ and $x$ (resp; $y$, $z$) is the residue class of $X$ (resp. $Y$, $Z$) modulo the ideal $(X^2-1, Y^2-1, Z^2-1)$. By its construction, the set $J$ is indeed an ideal, containing 2187 elements, so it is hard to write or copy all its elements. I want to find a Groebner basis of $J$, by writing

```
B = J.groebner_basis(),
```

but Sage returns

```
TypeError: R must be a commutative ring.
```

This error seems to mean that Sage doesn' t remember that $J$ is the above set anymore and consider $J$ as an inappropriate new objet of a new ring $R$!

I must first construct the ideal

```
H = ideal(0, x*y*z - x*y - x*z + y*z - x + y - z, x*z - y*z - x + y - 1, x*y*z + x*y + x*z + y*z - z - 1, x*y + x*z + x - y + z, -x*y*z - x*y + x*z - y*z - x - y - z, ....)
```

and then compute

```
B = H.groebner_basis().
```

That works, but, as I previously said, it is not easy to construct the ideal $H$ because that needs copy and paste 2187 elements!

Therefore I'd like to know whether there is another way to the task, without copying and pasting all of the elements of $J$, and declaring the ideal of these elements, is there a way to convert a set of elements in a ring (which is already an ideal) to the underlying ideal?

I have updatet the question because it contained some syntax errors

The computation

B=H.groebner_basis()

answers my preeceding question "Does sage allow computation of a groebner basis of an ideal J in the quotient ring Z/pZ[X_1,...X_r]/I?". The answer is "YES".

Please provide enough code for anyone to reproduce in a fresh Sage session. For instance what is

`F`

?If the question is not self-contained, at least provide an explicit reference to a previous question where things are defined.

From your previous questions it would seem this is the context.

Construct a finite field, a multivariate polynomial ring over it, and the quotient by the ideal generated by three polynomials:

Check what we have so far:

Now how do you construct the ideal

`J`

?Thank for your remarks, the set $F$ is the finite field $GF(3)$ as you knew. The ideal $J$ is a "multicyclic code" of dimension $3$, and is equal the set of polynomials of $R$ which vanishes on a finite subset of $F^3$. Here is the code :

def code(POLS,ZER):

In my case, POLS is the set of polynomials of $R$ ( of degree $\leqslant (1,1)$, using the lexicographical order) and ZER a subset of $F^3$ consisting of a unique element. More time is needed to provide the codes for constructing POLS, I will provide these latter on.