The Groebner Package

by Frederic Chyzak, Algorithms Project, INRIA, France

Frederic.Chyzak@inria.fr

The Groebner package extends the functionality of the grobner package into several directions, namely:

calculations over more complicated ground fields are now possible with a single package;

new term orders are available, in view of new applications and improved efficiency;

calculations of common invariants of ideals and varieties are available;

facilities for change of orderings are available.

> with(Groebner);

[Maple Math]
[Maple Math]
[Maple Math]

Some syntactical differences exist between the grobner and the Groebner packages. These differences are motivated by the extension of functionality, particularly in the number of term orderings. Specifically, a call

grobner[gbasis](G,[x,y],plex);

becomes

Groebner[gbasis](G,plex(x,y));

while the call

grobner[gbasis](G,{x,y});

with [Maple Math] being the standard has no counterpart in Groebner. For instance,

> grobner[gbasis]([x^2-2*x*z+5,x*y^2+y*z^3,3*y^2-8*z^3],[y,x,z],plex);

[Maple Math]
[Maple Math]

becomes

> Groebner[gbasis]([x^2-2*x*z+5,x*y^2+y*z^3,3*y^2-8*z^3],plex(y,x,z));

[Maple Math]
[Maple Math]

Moreover, for complicated calculations, the Groebner package requires data structures that are created by the Ore_algebra package.

> with(Ore_algebra);

[Maple Math]
[Maple Math]
[Maple Math]

Ground fields

The Groebner package supports transcendental and algebraic extensions of the field of rational numbers and finite fields. This includes algebraic number fields. Here is a sample computation with complex numbers in [Maple Math] .

> G:=[x^2+y^2-I,sqrt(2)*y+sqrt(2)*(x-sqrt(2))-1];

[Maple Math]

> GB:=gbasis(G,tdeg(x,y));

[Maple Math]

For computations with modular integers, one has to declare the corresponding algebra of polynomials. This is dealt with by the Ore_algebra package. (Ore polynomials extend commutative polynomials, and the general mechanism to deal with general algebras is in this package.)

> A:=poly_algebra(x,y,z,characteristic=5);

[Maple Math]

> G:=[x^2-2*x*z+5,x*y^2+y*z^3,3*y^2-8*z^3]:

> A[normalizer](G);

[Maple Math]

> T:=termorder(A,plex(x,y,z)):

> gbasis(G,T);

[Maple Math]

Term orderings

The grobner package allows two types of term orderings:

[Maple Math] , for "efficient" normal forms,

[Maple Math] , for "slow" triangularizations (system solving).

There was a need for specialized orderings for the purpose of efficient elimination and for term orderings defined by a matrix for the purpose of generality. The Groebner package implements both orderings, the [Maple Math] and [Maple Math] types respectively, together with a more practical [Maple Math] for weighted orderings. User-defined orderings are also available.

As an example, here is a calculation that is performed far faster using [Maple Math] than using [Maple Math] . Assume we want to find the optima of

> phi:=x^3+2*x*y*z-z^2;

[Maple Math]

on the sphere

> const:=x^2+y^2+z^2-1;

[Maple Math]

By Lagrange method, we compute

> G:={seq(diff(phi,v)-diff(const,v)*t,v=[x,y,z]),const};

[Maple Math]

and we eliminate [Maple Math] by the use of an appropriate term order

> GB:=gbasis(G,lexdeg([t],[x,y,z]));

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> remove(has,GB,t);

[Maple Math]
[Maple Math]
[Maple Math]

In the general case, we would have to compute numerical estimates and substitute into [Maple Math] . Here, we can go further and compute all the possible values for [Maple Math] , by elimination of [Maple Math] and [Maple Math] .

> GB2:=gbasis(%,lexdeg([x,y],[z]));

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

> op(remove(has,GB2,{x,y}));

[Maple Math]

> sol_z:=solve(%,z);

[Maple Math]

Substituting into the system yields the possible tuples where the optima take place.

> map(op,[seq(map(`union`,[solve(convert(subs(z=i,GB2),set),{x,y})],{z=i}),i=sol_z)]);

[Maple Math]
[Maple Math]
[Maple Math]

Finally, we get the minimum and maximum values.

> min(op(map(subs,%,phi))),max(op(map(subs,%,phi)));

[Maple Math]

Similar calculations using [Maple Math] need more than an hour.

As another example, the Groebner package allows for the computation of standard bases. We define the leading term of a polynomial as its minimum term instead of its maximum term by using a [Maple Math] term order rather than a [Maple Math] term order:

> L:=1+x+y+z+x^2+y^2+z^2;

[Maple Math]

> leadterm(L,plex(x,y,z));

[Maple Math]

> leadterm(L,plex_min(x,y,z));

[Maple Math]

Then Groebner bases can be computed for homogeneous ideals. Here is an example in [Maple Math] .

> G:=[y*w^2-z^3,x*w^3-z^4];

[Maple Math]

Compare the usual Groebner basis

> gbasis(G,plex(w,x,y,z));

[Maple Math]

which allows for divisions by decreasing powers:

> reduce(w^5*x^3*y^2*z,%,plex(w,x,y,z));

[Maple Math]

and the standard basis

> gbasis(G,plex_min(w,x,y,z));

[Maple Math]

which allows for divisions by increasing powers:

> reduce(w^5*x^3*y^2*z,%,plex_min(w,x,y,z));

[Maple Math]

Ideal invariants

The dimension of a variety (zero for isolated points, one for lines, two for planes) is the Hilbert dimension of the corresponding annihilating ideal. The Groebner package allows one to compute this Hilbert dimension, together with the Hilbert polynomial and Hilbert series.

As a first example, here is a zero-dimensional ideal, corresponding to finitely many points in the variety.

> G:=[3*y^2-8*z^3,x^2-2*z*x+5,3*y^3+8*x*y^2]:

> hilbertdim(G,tdeg(y,x,z));

[Maple Math]

> hilbertseries(G,tdeg(y,x,z),s);

[Maple Math]

> subs(s=1,%);

[Maple Math]

> hilbertpoly(G,tdeg(y,x,z),s);

[Maple Math]

As another example, here is an ideal of positive dimension.

> G:=[x^3*y^2+3*x^2*y^2+y^3+1]:

> hilbertdim(G,tdeg(x,y));

[Maple Math]

> hilbertseries(G,tdeg(x,y),s);

[Maple Math]

> series(%,s,10);

[Maple Math]

> hilbertpoly(G,tdeg(y,x),s);

[Maple Math]

FGLM algorithm

The FGLM algorithm was introduced to perform changes of orderings for zero-dimensional ideals.

> G:=[x+y+z,x*y+y*z+z*x,x*y*z-1]:

> GB:=gbasis(G,tdeg(x,y,z));

[Maple Math]

> hilbertdim(GB,tdeg(x,y,z));

[Maple Math]

The implementation is a fully user-customizable generalization:

1. choice of the normal form:

> NFproc:=proc(t,NF,T) local r,s; global GB;
r:=reduce(t,GB,tdeg(x,y,z),s);
NF[t]:=r/s
end:

2. computation of dependencies between those normal forms:

> FDproc:=proc(M,NF)
local ind_lst,t,eta,sol,zero,sys,rel;
ind_lst:=map(op,[indices(NF)]);
for t in M do
ind_lst:=remove(divide,ind_lst,t)
od;
zero:=expand(numer(normal(add(eta[t]*NF[t],
t=ind_lst))));
sys:={coeffs(zero,{x,y,z})};
sol:=[readlib(`solve/linear`)(sys,
{seq(eta[t],t=ind_lst)})];
rel:=subs(sol[1],add(eta[t]*t,t=ind_lst));
`if`(rel=0,FAIL,
collect(primpart(numer(subs(map(n->n=1,
map2(op,1,select(evalb,sol[1]))),
rel)),{x,y,z}),{x,y,z},
distributed,factor))
end:

3. choice of the termination condition:

> TMproc:=proc(border,monoideal,TOrd)
border<>[]
end:

> A:=poly_algebra(x,y,z):

> T:=termorder(A,plex(z,y,x)):

> FGLM:=[fglm(NFproc,FDproc,TMproc,T)]:

> GB2:=map(op,[entries(FGLM[2])]);

[Maple Math]

Groebner bases for skew algebras

The functionality of the Groebner package is also available for skew polynomial inputs. Whereas in the commutative case the ideals are two-sided, in the skew case we focus on left-sided ideal. This corresponds to skew polynomials acting on functions on the left.

As a first application, we derive a proof that Legendre polynomials satisfy

> Sum(orthopoly[P](n,z)*u^n,n=0..infinity)=1/sqrt(1-2*z*u+u^2);

[Maple Math]

Legendre polynomials [Maple Math] are defined by the following set of operators in the Ore algebra [Maple Math] built over a differential operator [Maple Math] and a shift operator [Maple Math] .

> G:={(1-z^2)*Dz^2-2*z*Dz+n*(n+1),
(n+2)*Sn^2-(2*n+3)*z*Sn+(n+1),
(1-z^2)*Dz*Sn+(n+1)*z*Sn-(n+1)};

[Maple Math]
[Maple Math]

It follows that the summand [Maple Math] in the identity we want to prove satisfies

> G:=map(numer@normal,subs(Sn=Sn/u,G)) union {u*Du-n};

[Maple Math]
[Maple Math]

in the new algebra [Maple Math] . (Since the index of summation is [Maple Math] , we consider polynomials in this variable to allow for its elimination.)

> A:=skew_algebra(diff=[Dz,z],diff=[Du,u],shift=[Sn,n],polynom=n):

> T:=termorder(A,lexdeg([n],[Dz,Du,Sn])):

> GB:=gbasis(G,T);

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

The previous equations are satisfied by the summand. Setting [Maple Math] in them yields equations satisfied by the sum. A final Groebner basis calculation returns these equations

> GB:=gbasis(subs(Sn=1,remove(has,GB,n)),T):

> collect(GB,{Dz,Du},distributed,factor);

[Maple Math]

Solving this simple system of PDE's yields the announced closed form.

The same method applies to perform definite integration. Here, we show that the integral

> Int((1+x*y+2*y^2)*exp(x^2*y^2/(1+2*y^2))/y^n/y/(1+2*y^2)^(2/3),
y=-infinity..infinity);

[Maple Math]

satisfies a recurrence of order 6. With a more refined method also based on Groebner basis calculations, one could obtain a second order recurrence so as to get a proof that the integral is an integral representation for Hermite polynomials. These polynomials are known to Maple as [Maple Math] .

They satisfy the system

> G:={Sn*y-1,
3*(1+x*y+2*y^2)*(1+2*y^2)^2*y*Dy+24*n*y^6+8*y^6+12*n*x*y^5+16*x*y^5
-12*x^2*y^4+20*y^4+36*n*y^4+12*n*x*y^3+8*x*y^3-6*x^3*y^3+14*y^2
-6*x^2*y^2+18*n*y^2+3*n*x*y+3+3*n};

[Maple Math]
[Maple Math]
[Maple Math]

in the Ore algebra [Maple Math]

> A:=skew_algebra(diff=[Dy,y],shift=[Sn,n],comm=x,polynom=y):

built on a differential operator [Maple Math] and a shift operator [Maple Math] . (Since the variable of integration is [Maple Math] , we consider polynomials in this variable to allow for its elimination.)

The elimination is obtained by using a suitable term order.

> T:=termorder(A,lexdeg([y],[Dy,Sn])):

> GB:=gbasis(G,T);

[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]
[Maple Math]

The above equations are also satisfied by the integrand. Setting [Maple Math] in them yields an equation satisfied by the integral.

> collect(primpart(subs(Dy=0,op(remove(has,GB,y))),Sn),Sn,factor);

[Maple Math]
[Maple Math]

The order is easily reduced by 1 to get the announced 6 order equation.

> collect(subs(n=n-1,%/Sn),Sn,factor);

[Maple Math]
[Maple Math]

Groebner bases for modules

Groebner bases for modules are available in the case of K[x[1],...,x[p]]-modules of the form K[x[1],...,x[p],s[1],...,s[q]], where the [Maple Math] 's and the [Maple Math] 's need not commute. Those module structures are obtained by disallowing the multiplications by the [Maple Math] 's along all calculations.

As an example of a Groebner basis for the [Maple Math] -module [Maple Math] , we simulaneously compute a Groebner basis [Maple Math] for an ideal generated by [Maple Math] , and we compute each polynomial in [Maple Math] as a combination of the initial polynomials.

The initial basis [Maple Math] is:

> G:=[x+y+z,x*y+y*z+z*x,x*y*z-1];

[Maple Math]

Let us introduce the module generated by

> MG:=[seq(s^(i-1)+G[i]*s^nops(G),i=1..nops(G))];

[Maple Math]

in the polynomial algebra

> A:=poly_algebra(x,y,z,s):

To refrain from any multiplication by [Maple Math] in the calculations, we use a third argument in the call to termorder.

> T:=termorder(A,lexdeg([s],[x,y,z]),[s]):

> MGB:=collect(gbasis(MG,T),s);

[Maple Math]
[Maple Math]
[Maple Math]

Up to 0's, the Groebner basis [Maple Math] for [Maple Math] is

> GB:=map(coeff,MGB,s,3);

[Maple Math]

as checked by

> gbasis(G,tdeg(x,y,z));

[Maple Math]

Furthermore, we get the following relations between the elements of [Maple Math] :

> seq(coeff(MGB[i],s,3)=subs(dummy='G',add(coeff(MGB[i],s,j)*dummy[j+1],j=0..2)),i=1..3);

[Maple Math]
[Maple Math]

And we get the Groebner basis for [Maple Math] in terms of the elements of [Maple Math] :

> seq(coeff(MGB[i],s,3)=subs(dummy='G',add(coeff(MGB[i],s,j)*dummy[j+1],j=0..2)),i=4..6);

[Maple Math]

or, in matrix notation:

> matrix(3,1,[seq(coeff(MGB[i],s,3),i=4..6)])=
matrix(3,3,[seq(subsop(seq(j+1=coeff(MGB[i],s,j),j=0..2),[0,0,0]),
i=4..6)])&*matrix(3,1,G);

[Maple Math]