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.
For the construction of the POLS, I used the following program :
def vect2pol(c,Vars):
where : c is a tuple of an element from a finite field
Vars a list of monomials with the same length as c
for example
list2pol((1, 2, 1, 2, 0, 0, 1, 1),[1, z, y, yz, x, xz, xy, xy*z])
produces
xyz + xy - yz + y - z + 1.
In my case, POLS is the list of elements of $R$. I first construct the cartesian product $F3^8$ :
S=Set(list(cartesian_product([F3]*8))).
Then I apply the function vect2pol to the elements of S, with Vars =[1, z, y, yz, x, xz, xy, xy*z]:
POLS={vect2pol(c,Vars) for c in S ...(more)
The set $J$ is then those of the polynomials of $R$ which vanishes on ${(1,2,1)}$ (It may be not be equal to the initial $J$ in my question), but that doesn't matter, it also contains 2187 elements). Using the command nbruin gave below, I entered
J1=ideal(*J);J1
B=J1.groebner_basis();B
and Sage returned
[x - 1, y + 1, z - 1].
The problem is solved : $J1$ is the ideal whose elements are the same as those of $J$ and no copy and paste were needeed!
Strangely, when I write the Sage programs in the text editor of Asksage, the line containing "def" (for example def vect2pol(c,Vars in the preceeding code) is outside of the box containing the remaining part of the program. Can you explain how to correct it ?