I'm writing Buchberger's Criterion in a program in Macaulay2 to check whether or not the set of polynomials I have form a Grobner basis for the ideal it generates. However, I have not been able to find a method that gives me the remainder when a polynomial, say $f$, is divided by a set of polynomials $G=\{g_1, g_2, ..., g_t\}$ in some order. Would anyone know if such a method exists and, if yes, what is its name?
Although that's not all I have, here is the part of the program where I try to implement the Buchberger's Criterion:
n=0;
for i to #polynomials-2 do
(
for j from i+1 to #polynomials-1 do
(
Spoly := lcm(leadTerm(polynomials#i),leadTerm(polynomials#j))/leadTerm(polynomials#i)*polynomials#i-lcm(leadTerm(polynomials#i),leadTerm(polynomials#j))/leadTerm(polynomials#j)*polynomials#j;
remainder := Spoly%polynomials;
if remainder == 0 then n=n+1;
);
);
if n == binomial(#polynomials, 2) then print "The polynomials form a Grobner basis for the ideal it generates." else print "The polynomials don't form a Grobner basis for the ideal it generates."
On the codes above, I use % as the method I'm looking for - but it doesn't work for a polynomial being divided by a list of polynomials.