  
  [1X3 [33X[0;0YFunctions[133X[101X
  
  
  [1X3.1 [33X[0;0YConverting polynomials into different formats[133X[101X
  
  [1X3.1-1 GP2NP[101X
  
  [33X[1;0Y[29X[2XGP2NP[102X( [3Xgp[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YIf  [3Xgp[103X  is an element of a free algebra, then the polynomial in NP
            format  (see Section [14X2.1[114X) corresponding to [3Xgp[103X; if [3Xgp[103X is an element
            of  a free module, then the vector in NPM format (see Section [14X2.2[114X)
            corresponding to [3Xgp[103X.[133X
  
  [33X[0;0YThis  function  will convert an element of a free algebra to a polynomial in
  NP format and an element of a free right module to a vector in NPM format.[133X
  
  [33X[0;0Y[13XExample:[113X  Let  [10XA[110X be the free associative algebra with one over the rationals
  on the generators [10Xa[110X and [10Xb[110X. Let [10Xe[110X be the one of the algebra.[133X
  
  [4X[32X[104X
    [4Xgap> A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");;[104X
    [4Xgap> a:=A.a;;[104X
    [4Xgap> b:=A.b;;[104X
    [4Xgap> e:=One(A);;[104X
    [4Xgap> z:=Zero(A);;[104X
  [4X[32X[104X
  
  [33X[0;0YNow let [10Xgp[110X be the polynomial [22Xba-ab-e[122X.[133X
  
  [4X[32X[104X
    [4Xgap> gp:=b*a-a*b-e;[104X
    [4X(-1)*<identity ...>+(-1)*a*b+(1)*b*a[104X
  [4X[32X[104X
  
  [33X[0;0YThe  polynomial  in  NP format, corresponding to [10Xgp[110X can now be obtained with
  GP2NP:[133X
  
  [4X[32X[104X
    [4Xgap> GP2NP(gp);[104X
    [4X[ [ [ 2, 1 ], [ 1, 2 ], [  ] ], [ 1, -1, -1 ] ][104X
  [4X[32X[104X
  
  [33X[0;0YLet [10XD[110X be the free associative algebra over [10XA[110X of rank 2.[133X
  
  [4X[32X[104X
    [4Xgap> D := A^2;;[104X
  [4X[32X[104X
  
  [33X[0;0YTake the following list [10XR[110X of two elements of [10XD[110X.[133X
  
  [4X[32X[104X
    [4Xgap> R := [ [b-e, z], [e+a*(e+a+b), -e-a*(e+a+b)] ];;[104X
  [4X[32X[104X
  
  [33X[0;0YConvert the list [10XR[110X to a list of vectors in NPM format.[133X
  
  [4X[32X[104X
    [4Xgap> List(R,GP2NP);[104X
    [4X[ [ [ [ -1, 2 ], [ -1 ] ], [ 1, -1 ] ], [104X
    [4X  [ [ [ -1, 1, 2 ], [ -1, 1, 1 ], [ -2, 1, 2 ], [ -2, 1, 1 ], [ -1, 1 ], [104X
    [4X          [ -2, 1 ], [ -1 ], [ -2 ] ], [ 1, 1, -1, -1, 1, -1, 1, -1 ] ] ][104X
  [4X[32X[104X
  
  [1X3.1-2 GP2NPList[101X
  
  [33X[1;0Y[29X[2XGP2NPList[102X( [3XLgp[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe  list  of  polynomials  in  NP  or NPM format corresponding to
            elements of a free algebra or module occurring in the list [3XLgp[103X.[133X
  
  [33X[0;0YThis function has the same effect as [10XList(Lgp,GBNP)[110X.[133X
  
  [33X[0;0Y[13XExample:[113X  Let  [10XA[110X be the free associative algebra with one over the rationals
  on the generators [10Xa[110X and [10Xb[110X. Let [10Xe[110X be the one of the algebra.[133X
  
  [4X[32X[104X
    [4Xgap> A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");;[104X
    [4Xgap> a:=A.a;;[104X
    [4Xgap> b:=A.b;;[104X
    [4Xgap> e:=One(A);;[104X
  [4X[32X[104X
  
  [33X[0;0YLet [10XLgp[110X be the list of polynomials [22X[a^2-e,b^2-e,ba-ab-e][122X.[133X
  
  [4X[32X[104X
    [4Xgap> Lgp:=[a^2-e,b^2-e,b*a-a*b-e];[104X
    [4X[ (-1)*<identity ...>+(1)*a^2, (-1)*<identity ...>+(1)*b^2, [104X
    [4X  (-1)*<identity ...>+(-1)*a*b+(1)*b*a ][104X
  [4X[32X[104X
  
  [33X[0;0YThe polynomial in NP format corresponding to [10Xgp[110X can be obtained with GP2NP:[133X
  
  [4X[32X[104X
    [4Xgap> GP2NPList(Lgp);[104X
    [4X[ [ [ [ 1, 1 ], [  ] ], [ 1, -1 ] ], [ [ [ 2, 2 ], [  ] ], [ 1, -1 ] ], [104X
    [4X  [ [ [ 2, 1 ], [ 1, 2 ], [  ] ], [ 1, -1, -1 ] ] ][104X
  [4X[32X[104X
  
  [33X[0;0YThe  same  result  is  obtained by a simple application of the standard List
  function in GAP:[133X
  
  [4X[32X[104X
    [4Xgap> List(Lgp,GP2NP) = GP2NPList(Lgp);[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  [1X3.1-3 NP2GP[101X
  
  [33X[1;0Y[29X[2XNP2GP[102X( [3Xnp[103X, [3XA[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe GAP format of the polynomial [3Xnp[103X in NP format.[133X
  
  [33X[0;0YThis  function will convert a polynomial in NP format to a GAP polynomial in
  the free associative algebra [3XA[103X and a vector in NPM format to a GAP vector in
  the  free module [3XA[103X. In case of the NP format, the number of variables should
  not  exceed  the  rank of the free algebra [3XA[103X. In case of the NPM format, the
  absolute  of  the  negative  numbers  should not exceed the rank of the free
  module [3XA[103X.[133X
  
  [33X[0;0Y[13XExample:[113X  Let  [10XA[110X be the free associative algebra with one over the rationals
  on the generators [10Xa[110X and [10Xb[110X.[133X
  
  [4X[32X[104X
    [4Xgap> A:=FreeAssociativeAlgebraWithOne(GF(3),"a","b");;[104X
  [4X[32X[104X
  
  [33X[0;0YLet [10Xnp[110X be a polynomial in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> np:=[ [ [ 2, 1 ], [ 1, 2 ], [  ] ], [ Z(3)^0, Z(3), Z(3) ] ];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe  polynomial  can  be  converted  to  the corresponding element of [3XA[103X with
  NP2GP:[133X
  
  [4X[32X[104X
    [4Xgap> NP2GP(np,A);[104X
    [4X(Z(3)^0)*b*a+(Z(3))*a*b+(Z(3))*<identity ...>[104X
  [4X[32X[104X
  
  [33X[0;0YNote that some information of the coefficient field of a polynomial [10Xnp[110X in NP
  format can be obtained from the second list of [10Xnp[110X.[133X
  
  [4X[32X[104X
    [4Xgap> One(np[2][1]);[104X
    [4XZ(3)^0[104X
  [4X[32X[104X
  
  [33X[0;0YNow  let [10XM[110X be the module [10XA^2[110X and let [10Xnpm[110X be a polynomial over that module in
  NPM form.[133X
  
  [4X[32X[104X
    [4Xgap> M:=A^2;;[104X
    [4Xgap> npm:=[ [ [ -1, 1 ], [ -2, 2 ] ], [ Z(3)^0, Z(3)^0 ] ];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe element of [3XM[103X corresponding to [10Xnpm[110X is[133X
  
  [4X[32X[104X
    [4Xgap> NP2GP(npm,M);[104X
    [4X[ (Z(3)^0)*a, (Z(3)^0)*b ][104X
  [4X[32X[104X
  
  [33X[0;0YIf  [10XM[110X is a module of dimension 2 over [10XA[110X and [10XLnp[110X a list of polynomials in NPM
  format,   then  the  polynomials  can  be  converted  to  the  corresponding
  polynomials of [10XM[110X as follows:[133X
  
  [4X[32X[104X
    [4Xgap> M:=A^2;;[104X
    [4Xgap> Lnp:=[ [ [ [ -2, 1, 1 ], [ -2, 1 ] ], [ 1, -1 ] ],[104X
    [4X>   [ [ [ -1, 2, 2], [-2, 1 ] ], [ 1, -1 ]*Z(3)^0 ] ];;[104X
    [4Xgap> List(Lnp, m -> NP2GP(m,M));[104X
    [4X[ [ <zero> of ..., (Z(3))*a+(Z(3)^0)*a^2 ], [ (Z(3)^0)*b^2, (Z(3))*a ] ][104X
  [4X[32X[104X
  
  [1X3.1-4 NP2GPList[101X
  
  [33X[1;0Y[29X[2XNP2GPList[102X( [3XLnp[103X, [3XA[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe list of polynomials corresponding to [3XLnp[103X in GAP format.[133X
  
  [33X[0;0YThis  function  will  convert  the list [3XLnp[103X of polynomials in NP format to a
  list of GAP polynomials in the free associative algebra [3XA[103X.[133X
  
  [33X[0;0Y[13XExample:[113X  Let  [10XA[110X be the free associative algebra with one over the rationals
  on the generators [10Xa[110X and [10Xb[110X.[133X
  
  [4X[32X[104X
    [4Xgap> A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");;[104X
  [4X[32X[104X
  
  [33X[0;0YLet  [10XLnp[110X be a list of polynomials in NP format. Then [10XLnp[110X can be converted to
  a list of polynomials of [10XA[110X with NP2GPList:[133X
  
  [4X[32X[104X
    [4Xgap> Lnp:=[ [ [ [ 1, 1, 1 ], [ 1 ] ], [ 1, -1 ] ],[104X
    [4X>   [ [ [ 2, 2 ], [ ] ], [ 1, -1 ] ] ];;[104X
    [4Xgap> NP2GPList(Lnp,A);[104X
    [4X[ (1)*a^3+(-1)*a, (1)*b^2+(-1)*<identity ...> ][104X
  [4X[32X[104X
  
  [33X[0;0YIt has the same effect as the function [10XList[110X applied as follows.[133X
  
  [4X[32X[104X
    [4Xgap> List(Lnp, p -> NP2GP(p,A));[104X
    [4X[ (1)*a^3+(-1)*a, (1)*b^2+(-1)*<identity ...> ][104X
  [4X[32X[104X
  
  [33X[0;0YNow let [10XM[110X be a module of dimension 2 over [10XA[110X and [10XLnp[110X a list of vectors in NPM
  format.  Then  polynomials [10XLnp[110X can be converted to the corresponding vectors
  of [10XM[110X with NP2GPList:[133X
  
  [4X[32X[104X
    [4Xgap> M:=A^2;;[104X
    [4Xgap> Lnp:=[ [ [ [ -2, 1, 1 ], [ -2, 1 ] ], [ 1, -1 ] ],[104X
    [4X>   [ [ [ -1, 1 ], [ -2 ] ], [ 1, -1 ] ] ];;[104X
    [4Xgap> NP2GPList(Lnp,M);[104X
    [4X[ [ <zero> of ..., (-1)*a+(1)*a^2 ], [ (1)*a, (-1)*<identity ...> ] ][104X
  [4X[32X[104X
  
  [33X[0;0YThe  same  result  can  be  obtained  by  application  of  the standard List
  function:[133X
  
  [4X[32X[104X
    [4Xgap> List(Lnp, m -> NP2GP(m,M)) = NP2GPList(Lnp,M) ;[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  
  [1X3.2 [33X[0;0YPrinting polynomials in NP format[133X[101X
  
  [1X3.2-1 PrintNP[101X
  
  [33X[1;0Y[29X[2XPrintNP[102X( [3Xnp[103X ) [32X function[133X
  
  [33X[0;0YThis  function  prints a polynomial [3Xnp[103X in NP format, using the letters [10Xa[110X, [10Xb[110X,
  [10Xc[110X,  [22X...[122X  for  [22Xx_1[122X, [22Xx_2[122X, [22Xx_3[122X, [22X...[122X, except that everything beyond [22Xl[122X (the 12-th
  letter) is printed as [22Xx[122X.[133X
  
  [33X[0;0YThis  function  prints  a  polynomial  [3Xnp[103X  in NP format as configured by the
  function [2XGBNP.ConfigPrint[102X ([14X3.2-2[114X).[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following polynomial in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p := [[[1,1,2],[1,2,2],[]],[1,-2,3]];;[104X
  [4X[32X[104X
  
  [33X[0;0YIt  can  be  printed in the guise of a polynomial in [10Xa[110X and [10Xb[110X by the function
  [10XPrintNP[110X:[133X
  
  [4X[32X[104X
    [4Xgap> PrintNP(p);[104X
    [4X a^2b - 2ab^2 + 3 [104X
  [4X[32X[104X
  
  [1X3.2-2 GBNP.ConfigPrint[101X
  
  [33X[1;0Y[29X[2XGBNP.ConfigPrint[102X( [3Xarg[103X ) [32X function[133X
  
  [33X[0;0YBy  default  the  generators  of  the  algebra  are printed as [10Xa[110X, ..., [10Xl[110X and
  everything  after  the  twelfth generator as [10Xx[110X. By calling [10XConfigPrint[110X it is
  possible  to  alter  this  printing  convention.  The argument(s) will be an
  algebra  or  arguments  used  for naming algebras in GAP upon creation. More
  specifically, we have the following choices.[133X
  
  [8X[13Xno arguments[113X[108X
        [33X[0;6YWhen  the  function is invoked without arguments the printing is reset
        to the default (see above).[133X
  
  [8Xalgebra[108X
        [33X[0;6YWhen  the  function is invoked with an algebra as argument, generators
        will be printed as they would be in the algebra.[133X
  
  [8Xalgebra,integer[108X
        [33X[0;6YWhen  the  function  is  invoked  with  an algebra and an integer [3Xn[103X as
        arguments,  generators will be printed as they would be in the algebra
        and seperated over the [3Xn[103X dimensions.[133X
  
  [8Xleftmodule[108X
        [33X[0;6YWhen  the function is invoked with an leftmodule [22XA^n[122X of an associative
        algebra  as  argument,  generators will be printed as they would be in
        the algebra, seperated over the [3Xn[103X dimensions.[133X
  
  [8Xstring[108X
        [33X[0;6YWhen  the  function  is  invoked  with a string as its argument, it is
        assumed  that  there is only 1 generator and that this should be named
        as indicated by the string.[133X
  
  [8Xinteger[108X
        [33X[0;6YWhen the function is invoked with an integer as its argument, the [3Xn[103X-th
        generator will be printed as [10Xx.<n>[110X.[133X
  
  [8Xinteger, string[108X
        [33X[0;6YWhen  the function is invoked with a non-negative integer and a string
        as  its arguments, generators will be printed as [10X<s>.<n>[110X, where [10X<s>[110X is
        the  string  given  as  argument  and [10X<n>[110X the number of the generator.
        There  is  no  checking whether the number given as argument is really
        the  dimension.  So  it  is possible that higher numbers return in the
        output.  This  way  of  input  is  useful  however,  because  it  is a
        distinction  from the one-dimensional case and compatible with the way
        a free algebra is created.[133X
  
  [8Xstring, string, ..., string[108X
        [33X[0;6YWhen  the  function  is  invoked  with  a  sequence  of  strings, then
        generators  will  be printed with the corresponding string or [10Xx[110X if the
        sequence is not long enough.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThey can be printed by the function [10XPrintNP[110X.[133X
  
  [4X[32X[104X
    [4Xgap> PrintNP(p1);[104X
    [4X a^2b - 1 [104X
    [4Xgap> PrintNP(p2);[104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YWe  can  let the variables be printed as [10Xx[110X and [10Xy[110X instead of [10Xa[110X and [10Xb[110X by means
  of [2XGBNP.ConfigPrint[102X.[133X
  
  [4X[32X[104X
    [4Xgap> GBNP.ConfigPrint("x","y");[104X
    [4Xgap> PrintNP(p1);[104X
    [4X x^2y - 1 [104X
    [4Xgap> PrintNP(p2);[104X
    [4X xy^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YWe  can  also let the variables be printed as [10Xx.1[110X and [10Xx.2[110X instead of [10Xa[110X and [10Xb[110X
  by means of [2XGBNP.ConfigPrint[102X.[133X
  
  [4X[32X[104X
    [4Xgap> GBNP.ConfigPrint(2,"x");[104X
    [4Xgap> PrintNP(p1);[104X
    [4X x.1^2x.2 - 1 [104X
    [4Xgap> PrintNP(p2);[104X
    [4X x.1x.2^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YWe can even assign strings to the variables to be printed like [10Xalice[110X and [10Xbob[110X
  instead of [10Xa[110X and [10Xb[110X by means of [2XGBNP.ConfigPrint[102X.[133X
  
  [4X[32X[104X
    [4Xgap> GBNP.ConfigPrint("alice","bob");[104X
    [4Xgap> PrintNP(p1);[104X
    [4X alice^2bob - 1 [104X
    [4Xgap> PrintNP(p2);[104X
    [4X alicebob^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YAlternatively,  we can introduce the free algebra [3XA[103X with two generators, and
  print the polynomials as members of [3XA[103X:[133X
  
  [4X[32X[104X
    [4Xgap> A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");;[104X
    [4Xgap> GBNP.ConfigPrint(A);[104X
    [4Xgap> PrintNP(p1);[104X
    [4X a^2b - 1 [104X
    [4Xgap> PrintNP(p2);[104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  [1X3.2-3 PrintNPList[101X
  
  [33X[1;0Y[29X[2XPrintNPList[102X( [3XLnp[103X ) [32X function[133X
  
  [33X[0;0YThis  function  prints  a  list  [3XLnp[103X  of polynomials in NP format, using the
  function [10XPrintNP[110X.[133X
  
  [33X[0;0Y[13XExample:[113X We put two polynomials in NP format into the list [10XLnp[110X.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
    [4Xgap> Lnp := [p1,p2];;[104X
  [4X[32X[104X
  
  [33X[0;0YWe can print the list with [2XPrintNPList[102X.[133X
  
  [4X[32X[104X
    [4Xgap> PrintNPList(Lnp);[104X
    [4X a^2b - 1 [104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YAlternatively, using the function [2XGBNP.ConfigPrint[102X ([14X3.2-2[114X), we can introduce
  the  free  algebra  [3XA[103X  with two generators, and print the polynomials of the
  list as members of [3XA[103X:[133X
  
  [4X[32X[104X
    [4Xgap> A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");;[104X
    [4Xgap> GBNP.ConfigPrint(A);[104X
    [4Xgap> PrintNPList(Lnp);[104X
    [4X a^2b - 1 [104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  
  [1X3.3 [33X[0;0YCalculating with polynomials in NP format[133X[101X
  
  [1X3.3-1 NumAlgGensNP[101X
  
  [33X[1;0Y[29X[2XNumAlgGensNP[102X( [3Xnp[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe  minimum  number [10Xt[110X so that [3Xnp[103X belongs to the free algebra on [10Xt[110X
            generators.[133X
  
  [33X[0;0YWhen  called  with  an  NP  polynomial [3Xnp[103X, this function returns the minimum
  number of generators needed for the corresponding algebra to contain the [3Xnp[103X.
  If  [3Xnp[103X  is  a  polynomial without generators, that is, equivalent to [22X0[122X or [22X1[122X,
  then [10X0[110X is returned.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following polynomial in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> np := [[[2,2,2,1,1,1],[4],[3,2,3]],[1,-3,2]];;[104X
    [4Xgap> PrintNP(np);[104X
    [4X b^3a^3 - 3d + 2cbc [104X
    [4Xgap> NumAlgGensNP(np);[104X
    [4X4[104X
  [4X[32X[104X
  
  [1X3.3-2 NumAlgGensNPList[101X
  
  [33X[1;0Y[29X[2XNumAlgGensNPList[102X( [3XLnp[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe minimum number [10Xt[110X so that each polynomial in [3XLnp[103X belongs to the
            free algebra on [10Xt[110X generators.[133X
  
  [33X[0;0YWhen  called  with  a  list of NP polynomials [3XLnp[103X, this function returns the
  minimum number of generators needed for the corresponding algebra to contain
  the  NP  polynomials  in  [3XLnp[103X.  If  [3XLnp[103X  only  contains  polynomials without
  generators, that is equivalent to [22X0[122X and [22X1[122X, then [10X0[110X is returned.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2,3,1],[2],[1]],[1,-2,1]];;[104X
    [4Xgap> p2 := [[[2,2,1,4,3],[]],[1,-1]];;[104X
    [4Xgap> PrintNPList([p1,p2]);[104X
    [4X a^2bca - 2b + a [104X
    [4X b^2adc - 1 [104X
    [4Xgap> NumAlgGensNPList([p1,p2]);[104X
    [4X4[104X
  [4X[32X[104X
  
  [1X3.3-3 NumModGensNP[101X
  
  [33X[1;0Y[29X[2XNumModGensNP[102X( [3Xnpm[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe minimum number [10Xmt[110X so that [3Xnpm[103X belongs to the free module on [10Xmt[110X
            generators.[133X
  
  [33X[0;0YWhen  called  with a polynomial [3Xnpm[103X in NPM format, this function returns the
  minimum  number of module generators needed for the corresponding algebra to
  contain  [3Xnpm[103X.  If  [3Xnpm[103X  is  an  NP  polynomial  that does not contain module
  generators, then [10X0[110X is returned.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following polynomial in NPM format.[133X
  
  [4X[32X[104X
    [4Xgap> np := [[[-1,1,2,3,1],[-2],[-1]],[1,-2,1]];;[104X
    [4Xgap> PrintNP(np);[104X
    [4X[ abca + 1 , - 2 ][104X
    [4Xgap> NumModGensNP(np);[104X
    [4X2[104X
  [4X[32X[104X
  
  [1X3.3-4 NumModGensNPList[101X
  
  [33X[1;0Y[29X[2XNumModGensNPList[102X( [3XLnpm[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe  minimum  number  [10Xmt[110X so that each member of [3Xnpm[103X belongs to the
            free module on [10Xmt[110X generators.[133X
  
  [33X[0;0YWhen  called  with  a  list of polynomials [3XLnpm[103X in NPM format, this function
  returns  the  minimum  number  of  module  generators  needed to contain the
  polynomials  in  [3XLnpm[103X.  If  there are only polynomials in [3XLnpm[103X in NP format,
  then [10X0[110X is returned.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NPM format.[133X
  
  [4X[32X[104X
    [4Xgap> v1 := [[[-1,1,2,3,1],[-2],[-1]],[1,-2,1]];;[104X
    [4Xgap> v2 := [[[-2,2,1,4,3],[-3]],[1,-1]];;[104X
    [4Xgap> PrintNPList([v1,v2]);[104X
    [4X[ abca + 1 , - 2 ][104X
    [4X[ 0, badc , - 1 ][104X
    [4Xgap> NumModGensNPList([v1,v2]);[104X
    [4X3[104X
  [4X[32X[104X
  
  [1X3.3-5 AddNP[101X
  
  [33X[1;0Y[29X[2XAddNP[102X( [3Xu[103X, [3Xv[103X, [3Xc[103X, [3Xd[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[3Xc[103X[22X*[122X[3Xu[103X[22X+[122X[3Xd[103X[22X*[122X[3Xv[103X[133X
  
  [33X[0;0YComputes  [3Xc[103X[22X*[122X[3Xu[103X[22X+[122X[3Xd[103X[22X*[122X[3Xv[103X where [3Xu[103X and [3Xv[103X are polynomials in NP format and [3Xc[103X and [3Xd[103X are
  scalars.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-3]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-4]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe second can be subtracted from the first by the function [10XAddNP[110X.[133X
  
  [4X[32X[104X
    [4Xgap> PrintNP(AddNP(p1,p2,1,-1));[104X
    [4X - ab^2 + a^2b + 1 [104X
  [4X[32X[104X
  
  [1X3.3-6 BimulNP[101X
  
  [33X[1;0Y[29X[2XBimulNP[102X( [3Xga[103X, [3Xnp[103X, [3Xdr[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Ythe polynomial [3Xga[103X[22X*[122X[3Xnp[103X[22X*[122X[3Xdr[103X in NP format[133X
  
  [33X[0;0YWhen called with a polynomial [3Xnp[103X and two monomials [3Xga[103X, [3Xdr[103X, the function will
  return  [3Xga[103X[22X*[122X[3Xnp[103X[22X*[122X[3Xdr[103X.  Recall from Section [14X2.1[114X that monomials are represented as
  lists.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-3]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-4]];;[104X
  [4X[32X[104X
  
  [33X[0;0YMultiplying  [10Xp1[110X from the right by [10Xb[110X and multiplying [10Xp2[110X from the left by [10Xa[110X is
  possible with the function [10XBimulNP[110X:[133X
  
  [4X[32X[104X
    [4Xgap> PrintNP(BimulNP([],p1,[2]));[104X
    [4X a^2b^2 - 3b [104X
    [4Xgap> PrintNP(BimulNP([1],p2,[]));[104X
    [4X a^2b^2 - 4a [104X
  [4X[32X[104X
  
  [1X3.3-7 CleanNP[101X
  
  [33X[1;0Y[29X[2XCleanNP[102X( [3Xu[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe cleaned up version of [3Xu[103X[133X
  
  [33X[0;0YGiven  a  polynomial  in  NP  format, this function collects terms with same
  monomial,  removes trivial monomials, and orders the monomials, with biggest
  one first.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following polynomial in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p := [[[1,1,2],[],[1,1,2],[]],[1,-3,-2,3]];;[104X
    [4Xgap> PrintNP(p);[104X
    [4X a^2b - 3 - 2a^2b + 3 [104X
  [4X[32X[104X
  
  [33X[0;0YThe  monomials  [10X[1,1,2][110X  and  [10X[][110X  occur  twice each. For many functions this
  representation  of  a polynomial in NP format is not allowed. It needs to be
  cleaned, as by [2XCleanNP[102X:[133X
  
  [4X[32X[104X
    [4Xgap> PrintNP(CleanNP(p));[104X
    [4X - a^2b [104X
  [4X[32X[104X
  
  [33X[0;0YIn  order  to  define  a  polynomial over [22XGF(2)[122X, the coefficients need to be
  defined  over this field. Such a list of coefficients can be obtained in GAP
  from  a  list  of  integers  by multiplying with the identity element of the
  field.  The  resulting  polynomial  need not be clean, and so should be made
  clean again with [10XCleanNP[110X.[133X
  
  [4X[32X[104X
    [4Xgap> p := [[[1,1,2],[]],One(GF(2))*[1,-2]];;[104X
    [4Xgap> CleanNP(p);[104X
    [4X[ [ [ 1, 1, 2 ] ], [ Z(2)^0 ] ][104X
  [4X[32X[104X
  
  [1X3.3-8 GtNP[101X
  
  [33X[1;0Y[29X[2XGtNP[102X( [3Xu[103X, [3Xv[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[10Xtrue[110X if [22Xu > v[122X and [10Xfalse[110X if [22Xu ≤ v[122X[133X
  
  [33X[0;0YGreater  than  function for monomials [3Xu[103X and [3Xv[103X represented as in Section [14X2.1[114X.
  It   tests   whether   [3Xu[103X[22X>[122X[3Xv[103X.   The  ordering  is  done  by  degree  and  then
  lexicographically.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two monomials.[133X
  
  [4X[32X[104X
    [4Xgap> u := [1,1,2];[104X
    [4X[ 1, 1, 2 ][104X
    [4Xgap> v := [2,2,1];[104X
    [4X[ 2, 2, 1 ][104X
  [4X[32X[104X
  
  [33X[0;0YWe test whether [10Xu[110X is greater than [10Xv[110X.[133X
  
  [4X[32X[104X
    [4Xgap> GtNP(u,v);[104X
    [4Xfalse[104X
  [4X[32X[104X
  
  [1X3.3-9 LtNP[101X
  
  [33X[1;0Y[29X[2XLtNP[102X( [3Xu[103X, [3Xv[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[10Xtrue[110X if [22Xu < v[122X and [10Xfalse[110X if [22Xu ≥ v[122X[133X
  
  [33X[0;0YLess than function for NP monomials, tests whether [3Xu[103X[22X<[122X[3Xv[103X. The ordering is done
  by degree and then lexicographically.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two monomials.[133X
  
  [4X[32X[104X
    [4Xgap> u := [1,1,2];[104X
    [4X[ 1, 1, 2 ][104X
    [4Xgap> v := [2,2,1];[104X
    [4X[ 2, 2, 1 ][104X
  [4X[32X[104X
  
  [33X[0;0YWe test whether [10Xu[110X is less than [10Xv[110X.[133X
  
  [4X[32X[104X
    [4Xgap> LtNP(u,v);[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  [1X3.3-10 LMonsNP[101X
  
  [33X[1;0Y[29X[2XLMonsNP[102X( [3XLnp[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA list of leading monomials[133X
  
  [33X[0;0YThis  function returns the leading monomials of a list [3XLnp[103X of polynomials in
  NP  format.  The  polynomials  of  [3XLnp[103X are required to be clean; see Section
  [14X3.3-7[114X.[133X
  
  [33X[0;0Y[13XExample:[113X We put two polynomials in NP format into the list [10XLnp[110X.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
    [4Xgap> Lnp := [p1,p2];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe list of leading monomials is computed by [10XLMonsNP[110X:[133X
  
  [4X[32X[104X
    [4Xgap> LMonsNP(Lnp);[104X
    [4X[ [ 1, 1, 2 ], [ 1, 2, 2 ] ][104X
  [4X[32X[104X
  
  [33X[0;0YFor  a nicer printing, the monomials can be converted into polynomials in NP
  format, and then submitted to PrintNPList:[133X
  
  [4X[32X[104X
    [4Xgap> PrintNPList(List(LMonsNP(Lnp), q -> [[q],[1]]));[104X
    [4X a^2b [104X
    [4X ab^2 [104X
  [4X[32X[104X
  
  [1X3.3-11 MkMonicNP[101X
  
  [33X[1;0Y[29X[2XMkMonicNP[102X( [3Xnp[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[3Xnp[103X made monic[133X
  
  [33X[0;0YThis  function  returns  the scalar multiple of a polynomial [3Xnp[103X in NP format
  that is monic, i.e., has leading coefficient equal to 1.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following polynomial in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p := [[[1,1,2],[]],[2,-1]];;[104X
    [4Xgap> PrintNP(p);[104X
    [4X 2a^2b - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YThe  coefficient of the leading term is [22X2[122X. The function [10XMkMonicNP[110X finds this
  coefficient and divides all terms by it:[133X
  
  [4X[32X[104X
    [4Xgap> PrintNP(MkMonicNP(p));[104X
    [4X a^2b - 1/2 [104X
  [4X[32X[104X
  
  [1X3.3-12 MulNP[101X
  
  [33X[1;0Y[29X[2XMulNP[102X( [3Xnp1[103X, [3Xnp2[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[3Xnp1[103X[22X*[122X[3Xnp2[103X[133X
  
  [33X[0;0YWhen  invoked  with  two polynomials [3Xnp1[103X and [3Xnp2[103X in NP format, this function
  will return the product [3Xnp1[103X[22X*[122X[3Xnp2[103X.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe function [10XMulNP[110X multiplies the two polynomials.[133X
  
  [4X[32X[104X
    [4Xgap> PrintNP(MulNP(p1,p2));[104X
    [4X a^2bab^2 - ab^2 - a^2b + 1 [104X
  [4X[32X[104X
  
  [33X[0;0YThe  fact  that this multiplication is not commutative is illustrated by the
  following comparison, using [10XMulNP[110X twice and [10XAddNP[110X once.[133X
  
  [4X[32X[104X
    [4Xgap> PrintNP(AddNP(MulNP(p1,p2),MulNP(p2,p1),1,-1));[104X
    [4X - ab^2a^2b + a^2bab^2 [104X
  [4X[32X[104X
  
  
  [1X3.4 [33X[0;0YGröbner functions, standard variant[133X[101X
  
  [1X3.4-1 Grobner[101X
  
  [33X[1;0Y[29X[2XGrobner[102X( [3XLnp[103X[, [3XD[103X][, [3Xmax[103X] ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YIf the algorithm terminates, a Gröbner Basis or a record if [3Xmax[103X is
            specified (see description).[133X
  
  [33X[0;0YFor  a  list  [3XLnp[103X  of  polynomials  in  NP  format  this  function  will use
  Buchberger's  algorithm  with  normal  form  to  find  a  Gröbner  Basis (if
  possible, the general problem is unsolvable).[133X
  
  [33X[0;0YWhen  called  with  the  optional  argument  [3Xmax[103X, which should be a positive
  integer,  the  calculation will be interrupted if it has not ended after [3Xmax[103X
  iterations. The return value will be a record containing lists [10XG[110X and [10Xtodo[110X of
  polynomials  in  NP  format, a boolean [10Xcompleted[110X, and an integer [10Xiterations[110X.
  Here  [10XG[110X  and [10Xtodo[110X form a Gröbner pair (see [Coh07]). The number of performed
  iterations  will  be  placed in [10Xiterations[110X. If the algorithm has terminated,
  then [10Xtodo[110X will be the empty list and [10Xcompleted[110X will be equal to [10Xtrue[110X. If the
  algorithm  has  not  terminated,  then  [10Xtodo[110X  will  be  a  non-empty list of
  polynomials in NP format and [10Xcompleted[110X will be [10Xfalse[110X.[133X
  
  [33X[0;0YBy  use  of  the  optional argument [3XD[103X, it is possible to resume a previously
  interrupted calculation.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
    [4Xgap> PrintNPList([p1,p2]);[104X
    [4X a^2b - 1 [104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YTheir Gröbner basis can be computed by the function [10XGrobner[110X.[133X
  
  [4X[32X[104X
    [4Xgap> G := Grobner([p1,p2]);;[104X
    [4Xgap> PrintNPList(G);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YOne iteration of the Gröbner computations is invoked by use of the parameter
  [10Xmax[110X:[133X
  
  [4X[32X[104X
    [4Xgap> R := Grobner([p1,p2],1);;[104X
    [4Xgap> PrintNPList(R.G);[104X
    [4X b - a [104X
    [4Xgap> PrintNPList(R.todo);[104X
    [4X a^3 - 1 [104X
    [4Xgap> R.iterations;[104X
    [4X1[104X
    [4Xgap> R.completed;[104X
    [4Xfalse[104X
  [4X[32X[104X
  
  [33X[0;0YThe  above  list [10XR.todo[110X can be used to resume the computation of the Gröbner
  basis computation with the Gröbner pair [10XR.G[110X, [10XR.todo[110X:[133X
  
  [4X[32X[104X
    [4Xgap> PrintNPList(Grobner(R.G,R.todo));[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YIn order to perform the Gröbner basis computation with polynomials in a free
  algebra over the field [22XGF(2)[122X, the coefficients of the polynomials need to be
  defined over that field.[133X
  
  [4X[32X[104X
    [4Xgap> PrintNPList(Grobner([[p1[1],One(GF(2))*p1[2]],[p2[1],One(GF(2))*p1[2]]]));[104X
    [4X b + a [104X
    [4X a^3 + Z(2)^0 [104X
  [4X[32X[104X
  
  [1X3.4-2 SGrobner[101X
  
  [33X[1;0Y[29X[2XSGrobner[102X( [3XLnp[103X[, [3Xtodo[103X][, [3Xmax[103X] ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YIf the algorithm terminates, a Gröbner Basis or a record if [3Xmax[103X is
            specified (see description).[133X
  
  [33X[0;0YFor  a  list  [3XLnp[103X  of  polynomials  in  NP  format  this  function  will use
  Buchberger's  algorithm  with  strong  normal  form  (see [Coh07]) to find a
  Gröbner Basis (if possible, the general problem is unsolvable).[133X
  
  [33X[0;0YWhen  called  with  the  optional  argument  [3Xmax[103X, which should be a positive
  integer,  the  calculation will be interrupted if it has not ended after [3Xmax[103X
  iterations. The return value will be a record containing lists [10XG[110X and [10Xtodo[110X of
  polynomials  in  NP  format, a boolean [10Xcompleted[110X, and an integer [10Xiterations[110X.
  Here  [10XG[110X  and [10Xtodo[110X form a Gröbner pair (see [Coh07]). The number of performed
  iterations  will  be  placed in [10Xiterations[110X. If the algorithm has terminated,
  then [10Xtodo[110X will be the empty list and [10Xcompleted[110X will be equal to [10Xtrue[110X. If the
  algorithm  has  not  terminated,  then  [10Xtodo[110X  will  be  a  non-empty list of
  polynomials in NP format and [10Xcompleted[110X will be [10Xfalse[110X.[133X
  
  [33X[0;0YBy  use  of  the  optional argument [3XD[103X, it is possible to resume a previously
  interrupted calculation.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
    [4Xgap> PrintNPList([p1,p2]);[104X
    [4X a^2b - 1 [104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YTheir Gröbner basis can be computed by the function [10XGrobner[110X.[133X
  
  [4X[32X[104X
    [4Xgap> G := SGrobner([p1,p2]);;[104X
    [4Xgap> PrintNPList(G);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YOne iteration of the Gröbner computations is invoked by use of the parameter
  [10Xmax[110X:[133X
  
  [4X[32X[104X
    [4Xgap> R := SGrobner([p1,p2],1);;[104X
    [4Xgap> PrintNPList(R.G);[104X
    [4X b - a [104X
    [4Xgap> PrintNPList(R.todo);[104X
    [4X a^3 - 1 [104X
    [4Xgap> R.iterations;[104X
    [4X1[104X
    [4Xgap> R.completed;[104X
    [4Xfalse[104X
  [4X[32X[104X
  
  [33X[0;0YThe  above  list [10XR.todo[110X can be used to resume the computation of the Gröbner
  basis computation with the Gröbner pair [10XR.G[110X, [10XR.todo[110X:[133X
  
  [4X[32X[104X
    [4Xgap> PrintNPList(SGrobner(R.G,R.todo));[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
  [4X[32X[104X
  
  [1X3.4-3 IsGrobnerBasis[101X
  
  [33X[1;0Y[29X[2XIsGrobnerBasis[102X( [3XG[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[10Xtrue[110X if [3XG[103X is a Gröbner basis and [10Xfalse[110X otherwise[133X
  
  [33X[0;0YWhen  invoked  with  a list [3XG[103X of polynomials in NP format (see Section [14X2.1[114X),
  this  function  will check whether the list is a Gröbner basis. The check is
  based on Theorem 1.4 from [Coh07].[133X
  
  [33X[0;0YPolynomials representing zero are allowed in [3XG[103X.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following list of two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> Lnp := [[[[1,1,2],[]],[1,-1]], [[[1,2,2],[]],[1,-1]]];;[104X
    [4Xgap> PrintNPList(Lnp);[104X
    [4X a^2b - 1 [104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YThe function [10XIsGrobner[110X checks whether the list is a Gröbner basis.[133X
  
  [4X[32X[104X
    [4Xgap> IsGrobnerBasis(Lnp);[104X
    [4Xfalse[104X
  [4X[32X[104X
  
  [33X[0;0YSo the answer should be [10Xtrue[110X for the result of a Gröbner computation:[133X
  
  [4X[32X[104X
    [4Xgap> IsGrobnerBasis(Grobner(Lnp));[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  [1X3.4-4 IsStrongGrobnerBasis[101X
  
  [33X[1;0Y[29X[2XIsStrongGrobnerBasis[102X( [3XG[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[10Xtrue[110X if [3XG[103X is a strong Gröbner basis and [10Xfalse[110X otherwise[133X
  
  [33X[0;0YWhen  invoked  with  a list [3XG[103X of polynomials in NP format (see Section [14X2.1[114X),
  this  function will check whether the polynomials in this list form a strong
  Gröbner basis (see [Coh07]).[133X
  
  [33X[0;0YPolynomials representing zero are allowed in [3XG[103X.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following list of two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> Lnp := [[[[1,1,2],[]],[1,-1]], [[[1,2,2],[]],[1,-1]]];;[104X
    [4Xgap> PrintNPList(Lnp);[104X
    [4X a^2b - 1 [104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YThe  function  [10XIsStrongGrobner[110X  checks  whether the list is a strong Gröbner
  basis.[133X
  
  [4X[32X[104X
    [4Xgap> IsStrongGrobnerBasis(Lnp);[104X
    [4Xfalse[104X
  [4X[32X[104X
  
  [33X[0;0YBut  the  answer  should  be  [10Xtrue[110X  for  the  result  of  a  strong  Gröbner
  computation:[133X
  
  [4X[32X[104X
    [4Xgap> IsStrongGrobnerBasis(SGrobner(Lnp));[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  [33X[0;0YA Gröbner basis that is not a strong Gröbner basis:[133X
  
  [4X[32X[104X
    [4Xgap> B := SGrobner(Lnp);;[104X
    [4Xgap> Add(B,AddNP(Lnp[1],B[1],1,-1));;[104X
    [4Xgap> PrintNPList(B);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
    [4X a^2b - b + a - 1 [104X
    [4Xgap> IsGrobnerBasis(B);[104X
    [4Xtrue[104X
    [4Xgap> IsStrongGrobnerBasis(B);[104X
    [4Xfalse[104X
  [4X[32X[104X
  
  [1X3.4-5 IsGrobnerPair[101X
  
  [33X[1;0Y[29X[2XIsGrobnerPair[102X( [3XG[103X, [3XD[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  boolean,  which has the value [10Xtrue[110X if the input forms a Gröbner
            pair[133X
  
  [33X[0;0YWhen  called  with  two  lists  of  polynomials  in NP format, this function
  returns  true  if they form a Gröbner pair. Testing whether [3XD[103X is a basic set
  for  [3XG[103X  might involve computing the Gröbner basis. Instead of this only some
  simple  computations  are done to see if it can easily be proven that [3XD[103X is a
  basic  set  for  [3XG[103X. If this cannot be proven easily, then [10Xfalse[110X is returned,
  even though [22XG, D[122X might still be a Gröbner pair.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following four polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
    [4Xgap> q1 := [[[2],[1]],[1,-1]];;[104X
    [4Xgap> q2 := [[[1,1,1],[]],[1,-1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe  function  [10XIsGrobnerPair[110X  is  used to check whether some combinations of
  these polynomials in two lists provide Gröbner pairs.[133X
  
  [4X[32X[104X
    [4Xgap> IsGrobnerPair([p1,p2,q1],[q2]);[104X
    [4Xtrue[104X
    [4Xgap> IsGrobnerPair([q1,q2],[p1,p2]);[104X
    [4Xfalse[104X
  [4X[32X[104X
  
  [33X[0;0YThe  function [10XIsGrobnerPair[110X applied with an empty list as second argument is
  a check whether the first argument is a Gröbner basis.[133X
  
  [4X[32X[104X
    [4Xgap> IsGrobnerPair([p1,p2],[]) = IsGrobnerBasis([p1,p2]);[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  [1X3.4-6 MakeGrobnerPair[101X
  
  [33X[1;0Y[29X[2XMakeGrobnerPair[102X( [3XG[103X, [3XD[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA record containing a new Grobner pair[133X
  
  [33X[0;0YWhen  called with as arguments a pair [22XG, D[122X, this function cleans [3XG[103X and [3XD[103X and
  adds some obstructions to [3XD[103X till it is easily provable that [3XD[103X is a basic set
  for [3XG[103X (see [Coh07]). The result is a record containing the fields [10XG[110X and [10Xtodo[110X
  representing the Gröbner pair.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe  function [10XMakeGrobnerPair[110X turns the list with these two polynomials into
  a  Gröbner  pair,  once  the  empty  list is added as a second argument. The
  result is a record whose fields [10XG[110X and [10Xtodo[110X[133X
  
  [4X[32X[104X
    [4Xgap> GP := MakeGrobnerPair([p1,p2],[]);;[104X
    [4Xgap> PrintNPList(GP.G);[104X
    [4X a^2b - 1 [104X
    [4X ab^2 - 1 [104X
    [4Xgap> PrintNPList(GP.todo);[104X
    [4X b - a [104X
  [4X[32X[104X
  
  [33X[0;0YThese fields are ready for use in [10XGrobner[110X[133X
  
  [4X[32X[104X
    [4Xgap> GB := Grobner(GP.G,GP.todo);;[104X
    [4Xgap> PrintNPList(GB);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
  [4X[32X[104X
  
  
  [1X3.5 [33X[0;0YFinite-dimensional quotient algebras[133X[101X
  
  [1X3.5-1 BaseQA[101X
  
  [33X[1;0Y[29X[2XBaseQA[102X( [3XG[103X, [3Xt[103X, [3Xmaxno[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  list  of  terms  forming a basis of the quotient algebra of the
            (non-commutative) polynomial algebra in [3Xt[103X variables by the 2-sided
            ideal generated by [3XG[103X[133X
  
  [33X[0;0YWhen  called  with  a  Gröbner  basis  [3XG[103X,  the number [3Xt[103X of generators of the
  algebra, and a maximum number of terms to be found [3Xmaxno[103X, BaseQA will return
  a  (partial)  base of the quotient algebra. If this function is invoked with
  [3Xmaxno[103X  equal to 0, then a full basis will be given. If the dimension of this
  quotient  algebra  is  infinite  and  [3Xmaxno[103X  is set to 0, then the algorithm
  behind this function will not terminate.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following Gröbner basis.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
    [4Xgap> G := Grobner([p1,p2]);;[104X
    [4Xgap> PrintNPList(G);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YThe  function  [10XBaseQA[110X  computes a basis for the quotient algebra of the free
  algebra  over  the  rationals with generators [22Xa[122X and [22Xb[122X by the two-sided ideal
  generated by [10XG[110X.[133X
  
  [4X[32X[104X
    [4Xgap> PrintNPList(G);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
    [4Xgap> BaseQA(G,2,0);[104X
    [4X[ [ [ [  ] ], [ 1 ] ], [ [ [ 1 ] ], [ 1 ] ], [ [ [ 1, 1 ] ], [ 1 ] ] ][104X
    [4Xgap> PrintNPList(BaseQA(G,2,0));[104X
    [4X 1 [104X
    [4X a [104X
    [4X a^2 [104X
  [4X[32X[104X
  
  [33X[0;0YIt  is  necessary  for a correct result that the first argument be a Gröbner
  basis, as will be clear from the following invocation of [10XBaseQA[110X.[133X
  
  [4X[32X[104X
    [4Xgap> PrintNPList(BaseQA([p1,p2],2,10));[104X
    [4X 1 [104X
    [4X a [104X
    [4X b [104X
    [4X a^2 [104X
    [4X ab [104X
    [4X ba [104X
    [4X b^2 [104X
    [4X a^3 [104X
    [4X aba [104X
    [4X ba^2 [104X
    [4X bab [104X
    [4X b^2a [104X
    [4X b^3 [104X
  [4X[32X[104X
  
  [1X3.5-2 DimQA[101X
  
  [33X[1;0Y[29X[2XDimQA[102X( [3XG[103X, [3Xt[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe dimension of the quotient algebra[133X
  
  [33X[0;0YWhen called with a Gröbner basis [3XG[103X and a number of variables [3Xt[103X, the function
  [10XDimQA[110X  will return the dimension of the quotient algebra of the free algebra
  generated  by  [3Xt[103X  variables  by the ideal generated by [3XG[103X if it is finite. It
  will not terminate if the dimension is infinite.[133X
  
  [33X[0;0YIf  [3Xt[103X=0,  the  function  will  compute  the minimal value of [10Xt[110X such that the
  polynomials in [3XG[103X belong to the free algebra on [10Xt[110X generators.[133X
  
  [33X[0;0YTo  check  whether  the  dimension  of the quotient algebra is finite and to
  determine  the  type  of  growth  if  it is infinite, see also the functions
  [2XFinCheckQA[102X ([14X3.6-2[114X) and [2XDetermineGrowthQA[102X ([14X3.6-1[114X) in Section [14X3.6[114X.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following Gröbner basis.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-2]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-2]];;[104X
    [4Xgap> G := Grobner([p1,p2]);;[104X
    [4Xgap> PrintNPList(G);[104X
    [4X b - a [104X
    [4X a^3 - 2 [104X
  [4X[32X[104X
  
  [33X[0;0YThe  function  [10XDimQA[110X  computes  the dimension of the quotient algebra of the
  free  algebra  over  the  rationals with generators [22Xa[122X and [22Xb[122X by the two-sided
  ideal generated by [10XG[110X.[133X
  
  [4X[32X[104X
    [4Xgap> DimQA(G,2);[104X
    [4X3[104X
  [4X[32X[104X
  
  [1X3.5-3 MatrixQA[101X
  
  [33X[1;0Y[29X[2XMatrixQA[102X( [3Xi[103X, [3XB[103X, [3XGB[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe  matrix  representation  for the [3Xi[103X-th generator of the algebra
            for right multiplication in the quotient algebra[133X
  
  [33X[0;0YGiven  a basis [3XB[103X of the quotient algebra, a Gröbner basis (record) [3XGB[103X, and a
  natural number [3Xi[103X, this function creates a matrix representation for the [3Xi[103X-th
  generator of the algebra for right multiplication.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2,1],[]],[1,-1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe  matrix  of  right  multiplication  by  the first indeterminate [22Xa[122X on the
  quotient  algebra  with  respect  to  the  ideal  generated  by [10Xp1[110X and [10Xp2[110X is
  obtained by applying [10XMatrixQA[110X to the Gröbner basis of these generators and a
  basis of the quotient algebra as found in [2XBaseQA[102X ([14X3.5-1[114X):[133X
  
  [4X[32X[104X
    [4Xgap> GB := Grobner([p1,p2]);;[104X
    [4Xgap> B := BaseQA(GB,2,0);;[104X
    [4Xgap> PrintNPList(B);[104X
    [4X 1 [104X
    [4X a [104X
    [4X b [104X
    [4X a^2 [104X
    [4X ab [104X
    [4X a^3 [104X
    [4X a^2b [104X
    [4X a^4 [104X
    [4Xgap> Display(MatrixQA(1, B,GB));[104X
    [4X[ [  0,  1,  0,  0,  0,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  1,  0,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  0,  1,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  0,  0,  1,  0,  0 ],[104X
    [4X  [  0,  0,  0,  0,  0,  0,  1,  0 ],[104X
    [4X  [  0,  0,  0,  0,  0,  0,  0,  1 ],[104X
    [4X  [  1,  0,  0,  0,  0,  0,  0,  0 ],[104X
    [4X  [  0,  0,  1,  0,  0,  0,  0,  0 ] ][104X
  [4X[32X[104X
  
  [33X[0;0YThe  function  is  also  applicable  to  Gröbner  basis records for modules.
  Consider the following two vectors.[133X
  
  [4X[32X[104X
    [4Xgap> v1 := [[[-1,1,2],[-1]],[1,-1]];;[104X
    [4Xgap> v2 := [[[-2,2,2],[-2]],[1,-2]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe  Gröbner  basis  record for this data is found by [2XSGrobnerModule[102X ([14X3.9-1[114X)
  and a quotient module basis by [2XBaseQM[102X ([14X3.9-2[114X):[133X
  
  [4X[32X[104X
    [4Xgap> GBR := SGrobnerModule([v1,v2],[p1,p2]);;[104X
    [4Xgap> B := BaseQM(GBR,2,2,0);;[104X
  [4X[32X[104X
  
  [33X[0;0YThe  matrix  of  right  multiplication by [22Xa[122X, the first generator of the free
  algebra, is[133X
  
  [4X[32X[104X
    [4Xgap> Display(MatrixQA(1,B,GBR));[104X
    [4X[ [  0,  1 ],[104X
    [4X  [  1,  0 ] ][104X
  [4X[32X[104X
  
  [1X3.5-4 MatricesQA[101X
  
  [33X[1;0Y[29X[2XMatricesQA[102X( [3Xt[103X, [3XB[103X, [3XGB[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe  matrix representation for the [3Xt[103X generators of the algebra for
            right multiplication in the quotient algebra[133X
  
  [33X[0;0YGiven  a basis [3XB[103X of the quotient algebra, a Gröbner basis (record) [3XGB[103X, and a
  natural  number  [3Xt[103X,  this function creates a list of [3Xt[103X matrices representing
  the  linear  transformations  of  the  generators  of  the  algebra by right
  multiplication on the quotient algebra.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2,1],[]],[1,-1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe function [10XMatricesQA[110X gives the list of matrices found by [2XMatrixQA[102X ([14X3.5-3[114X)
  when the first argument takes the integer values between 1 and the number of
  all algebra generators.[133X
  
  [4X[32X[104X
    [4Xgap> GB := Grobner([p1,p2]);;[104X
    [4Xgap> B := BaseQA(GB,2,0);;[104X
    [4Xgap> mats := MatricesQA(2,B,GB);;[104X
    [4Xgap> for mat in mats do Display(mat); Print("\n"); od;[104X
    [4X[ [  0,  1,  0,  0,  0,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  1,  0,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  0,  1,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  0,  0,  1,  0,  0 ],[104X
    [4X  [  0,  0,  0,  0,  0,  0,  1,  0 ],[104X
    [4X  [  0,  0,  0,  0,  0,  0,  0,  1 ],[104X
    [4X  [  1,  0,  0,  0,  0,  0,  0,  0 ],[104X
    [4X  [  0,  0,  1,  0,  0,  0,  0,  0 ] ][104X
    [4X[104X
    [4X[ [  0,  0,  1,  0,  0,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  0,  1,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  1,  0,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  0,  0,  0,  1,  0 ],[104X
    [4X  [  0,  0,  0,  0,  0,  1,  0,  0 ],[104X
    [4X  [  1,  0,  0,  0,  0,  0,  0,  0 ],[104X
    [4X  [  0,  0,  0,  0,  0,  0,  0,  1 ],[104X
    [4X  [  0,  1,  0,  0,  0,  0,  0,  0 ] ][104X
    [4X[104X
  [4X[32X[104X
  
  [33X[0;0YThe result is also obtainable by use of the List function:[133X
  
  [4X[32X[104X
    [4Xgap> MatricesQA(2,B,GB) = List([1,2], q -> MatrixQA(q,B,GB));[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  [1X3.5-5 MulQA[101X
  
  [33X[1;0Y[29X[2XMulQA[102X( [3Xp1[103X, [3Xp2[103X, [3XG[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe strong normal form of the product [3Xp1[103X[22X*[122X[3Xp2[103X with respect to [3XG[103X[133X
  
  [33X[0;0YWhen  called with two polynomials in NP form, [3Xp1[103X and [3Xp2[103X, and a Gröbner basis
  [3XG[103X, this function will return the product in the quotient algebra.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following Gröbner basis.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
    [4Xgap> G := Grobner([p1,p2]);;[104X
    [4Xgap> PrintNPList(G);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YPrint  the product in the quotient algebra of the polynomials [22Xa-2[122X and [22Xb-3[122X by
  use of [10XMulQA[110X:[133X
  
  [4X[32X[104X
    [4Xgap> s1 := [[[1],[]],[1,-2]];;[104X
    [4Xgap> s2 := [[[2],[]],[1,-3]];;[104X
    [4Xgap> PrintNP(MulQA(s1,s2,G));[104X
    [4X a^2 - 5a + 6 [104X
  [4X[32X[104X
  
  [33X[0;0YThe  result  should be equal to the strong normal form of the product of [22Xa-2[122X
  and [22Xb-3[122X with respect to [10XG[110X:[133X
  
  [4X[32X[104X
    [4Xgap> MulQA(s1,s2,G) = StrongNormalFormNP(MulNP(s1,s2),G);[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  [1X3.5-6 StrongNormalFormNP[101X
  
  [33X[1;0Y[29X[2XStrongNormalFormNP[102X( [3Xf[103X, [3XG[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe strong normal form of a polynomial with respect to [3XG[103X[133X
  
  [33X[0;0YWhen  invoked  with a polynomial in NP format (see Section [14X2.1[114X) and a finite
  set [3XG[103X of polynomials in NP format, this function will return a strong normal
  form  (that  is, a polynomial that is equal to [3Xf[103X modulo [3XG[103X, every monomial of
  which is a multiple of no leading monomial of an element of [3XG[103X).[133X
  
  [33X[0;0YNote  that  the StrongNormalForm with respect to a Gröbner basis is uniquely
  determined,  but  that for an arbitrary input [3XG[103X the result may depend on the
  order in which the individual reduction steps are implemented.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe strong normal form of the polynomial[133X
  
  [4X[32X[104X
    [4Xgap> p := [[[1,1,1,2],[2,1],[]],[1,-1,3]];;[104X
  [4X[32X[104X
  
  [33X[0;0Ywith  respect  to  the  list  [10X[p1,p2][110X  is  computed  by  use of the function
  [10XStrongNormalFormNP[110X:[133X
  
  [4X[32X[104X
    [4Xgap> PrintNP(StrongNormalFormNP(p,[p1,p2]));[104X
    [4X - ba + a + 3 [104X
  [4X[32X[104X
  
  
  [1X3.6 [33X[0;0YFiniteness and Hilbert series[133X[101X
  
  [1X3.6-1 DetermineGrowthQA[101X
  
  [33X[1;0Y[29X[2XDetermineGrowthQA[102X( [3XLm[103X, [3Xt[103X, [3Xexact[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YIf  the quotient algebra is finite dimensional, then the integer [10X0[110X
            is returned. If the growth is polynomial and the algorithm found a
            precise  degree [10Xd[110X of the growth polynomial, then [10Xd[110X is returned. If
            the  growth  is  polynomial  and  no  precise  answer is found, an
            interval  [10X[d1,d2][110X  is returned in which the dimension lies. If the
            growth   is   exponential,  the  string  [10X"exponential  growth"[110X  is
            returned.[133X
  
  [33X[0;0YGiven leading monomials [3XLm[103X of some Gröbner basis (these can be obtained with
  the  function  [2XLMonsNP[102X  ([14X3.3-10[114X)),  the  number  [3Xt[103X  of  generators of a free
  algebra,  say  [22XA[122X,  in  which  the  monomials  lie, and a boolean [3Xexact[103X, this
  function  checks whether the quotient algebra of [22XA[122X by the ideal generated by
  [3XLm[103X  is finite dimensional. In doing so it constructs a graph of normal words
  which  helps  with  the  computations.  It  also  checks  for exponential or
  polynomial growth in the infinite case.[133X
  
  [33X[0;0YIf  the  precise degree is needed in the polynomial case, the argument [3Xexact[103X
  should be set to [10Xtrue[110X.[133X
  
  [33X[0;0YThe  function [10XDetermineGrowthQA[110X allows preprocessing, which may speed up the
  computations.  This  can  be  done  with  the  function [2XPreprocessAnalysisQA[102X
  ([14X3.6-4[114X).[133X
  
  [33X[0;0Y[13XExample:[113X For the list of monomials consisting of a single variable in a free
  algebra  generated  by  two  variables  the  growth is clearly polynomial of
  degree  1.  This  is  verified  by invoking [10XDetermineGrowthQA[110X with arguments
  [10X[[1]][110X  (the  list  of the single monomial consisting of the first variable),
  the  number  of generators of the free algebra to which the monomials belong
  (which  is  2  here), and the boolean [10Xtrue[110X indicating that we wish a precise
  degree in case of polynomial growth.[133X
  
  [4X[32X[104X
    [4Xgap> DetermineGrowthQA([[1]],2,true);[104X
    [4X1[104X
  [4X[32X[104X
  
  [33X[0;0YHere is an example of polynomial growth of degree 2:[133X
  
  [4X[32X[104X
    [4Xgap> L := [[1,2,1],[2,2,1]];[104X
    [4X[ [ 1, 2, 1 ], [ 2, 2, 1 ] ][104X
    [4Xgap> DetermineGrowthQA(L,2,true);[104X
    [4X2[104X
  [4X[32X[104X
  
  [33X[0;0YIn  order  to  show  how  to  apply  the  function to arbitrary polynomials,
  consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> F := GF(256);[104X
    [4XGF(2^8)[104X
    [4Xgap> z := GeneratorsOfField(F)[1];[104X
    [4XZ(2^8)[104X
    [4Xgap> p1 := [[[1,1,1,2],[]],[z,1]];;[104X
    [4Xgap> p2 := [[[2,2,2,1],[]],[1,z]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe  polynomials [10Xp1[110X and [10Xp2[110X have coefficients in the field [10XF[110X of order 256. In
  order  to study the growth of the quotient algebra we first compute the list
  of   leading  monomials  of  the  Gröbner  basis  elements  and  next  apply
  [10XDetermineGrowthQA[110X.[133X
  
  [4X[32X[104X
    [4Xgap> GB := Grobner([p1,p2]);;[104X
    [4Xgap> L := LMonsNP(GB);;[104X
    [4Xgap> for lm  in L  do PrintNP( [ [ lm ], [ 1 ] ] ); od;[104X
    [4X a^3b [104X
    [4X b^2 [104X
    [4X ba [104X
    [4X a^5 [104X
    [4Xgap> DetermineGrowthQA(L,2,true);[104X
    [4X0[104X
  [4X[32X[104X
  
  [1X3.6-2 FinCheckQA[101X
  
  [33X[1;0Y[29X[2XFinCheckQA[102X( [3XLm[103X, [3Xt[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10Y[10Xtrue[110X,  if  the  quotient  algebra  is finite dimensional and[10X false[110X
            otherwise[133X
  
  [33X[0;0YGiven  a  list  [3XLm[103X  of  leading  monomials  such  that none of these divides
  another,  and the number [3Xt[103X of generators of a free algebra in which they are
  embedded,  this  function  checks  whether  the quotient algebra of the free
  algebra by the ideal generated by [3XLm[103X is finite dimensional.[133X
  
  [33X[0;0YWhen  given  a Gröbner basis [22XG[122X, the dimension of the quotient algebra of the
  free algebra by the ideal generated by [22XG[122X coincides with the the dimension of
  the  quotient  algebra  of  the  free  algebra by the ideal generated by the
  leading  terms  of  elements  of  [22XG[122X.  These  can be obtained from [22XG[122X with the
  function [2XLMonsNP[102X ([14X3.3-10[114X).[133X
  
  [33X[0;0YThe   function   [10XFinCheckQA[110X  allows  for  preprocessing  with  the  function
  [2XPreprocessAnalysisQA[102X ([14X3.6-4[114X). This may speed up the computation.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following list [10XL[110X of two monomials.[133X
  
  [4X[32X[104X
    [4Xgap> L := [[1,2,1],[2,2,1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YFiniteness  of  the dimension of the quotient algebra of the free algebra by
  the  ideal  generated  by  these  two  monomials  can be decided by means of
  [10XFinCheckQA[110X.  Its  arguments  are  [10XL[110X and the number of generators of the free
  algebra in which the monomials reside.[133X
  
  [4X[32X[104X
    [4Xgap> FinCheckQA(L,2);[104X
    [4Xfalse[104X
  [4X[32X[104X
  
  [33X[0;0YThis   example   turns   out   to   be   infinite  dimensional.  Here  is  a
  finite-dimensional example.[133X
  
  [4X[32X[104X
    [4Xgap> FinCheckQA([[1],[2,2]],2);[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  [1X3.6-3 HilbertSeriesQA[101X
  
  [33X[1;0Y[29X[2XHilbertSeriesQA[102X( [3XLm[103X, [3Xt[103X, [3Xd[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA list of coefficients of the Hilbert series up to degree [3Xd[103X[133X
  
  [33X[0;0YGiven a set of monomials [3XLm[103X, none of which divides another, and the number [3Xn[103X
  of  generators  of  the  free  algebra  in  which  they occur, this function
  computes the Hilbert series up to a given degree [3Xd[103X.[133X
  
  [33X[0;0YInternally,  it  builds (part of) the graph of standard words. This function
  will remove zeroes from the end of the list of coefficients.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following list [10XL[110X of two monomials.[133X
  
  [4X[32X[104X
    [4Xgap> L := [[1,2,1],[2,2,1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YFiniteness  of  the dimension of the quotient algebra of the free algebra by
  the  ideal  generated  by  these  two  monomials  can be decided by means of
  [10XFinCheckQA[110X.  Its  arguments  are  [10XL[110X and the number of generators of the free
  algebra in which the monomials reside.[133X
  
  [4X[32X[104X
    [4Xgap> HilbertSeriesQA(L,2,10);[104X
    [4X[ 1, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20 ][104X
  [4X[32X[104X
  
  [33X[0;0YThis  indicates that the growth may be polynomial. [2XDetermineGrowthQA[102X ([14X3.6-1[114X)
  can be used to check this.[133X
  
  [1X3.6-4 PreprocessAnalysisQA[101X
  
  [33X[1;0Y[29X[2XPreprocessAnalysisQA[102X( [3XLm[103X, [3Xt[103X, [3Xiterations[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe  left-reduced  list  of  `obstructions',  obtained by applying
            left-reduction recursively[133X
  
  [33X[0;0YThis  preprocessing of the list [3XLm[103X of monomials can be applied to the set of
  leading  terms  of  a  Gröbner basis before calling the functions [2XFinCheckQA[102X
  ([14X3.6-2[114X)  or  [2XDetermineGrowthQA[102X  ([14X3.6-1[114X),  in  order to speed up calculations
  using  these  functions.  As  the name suggests, [3Xt[103X should be the size of the
  alphabet.  The  parameter  [3Xiterations[103X  gives the maximum number of recursion
  steps  in  the  preprocessing ([3X0[103X means no restriction). For more information
  about this function see [Kro03].[133X
  
  [33X[0;0Y[13XExample:[113X  Consider  the  following  two  polynomials in NP format of which a
  Gröbner basis is computed.[133X
  
  [4X[32X[104X
    [4XF := GF(256);[104X
    [4Xz := GeneratorsOfField(F)[1];[104X
    [4Xgap> p1 := [[[1,1,1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2,1,1,1],[]],[1,-1]];;[104X
    [4Xgap> GB := Grobner([p1,p2]);;[104X
    [4Xgap> PrintNPList(GB);[104X
    [4X a^4b - 1 [104X
    [4X ba - ab [104X
    [4X b^2 - a [104X
    [4X a^5 - b [104X
  [4X[32X[104X
  
  [33X[0;0YApplication  of  [10XPreprocessAnalysisQA[110X is carried out on the leading terms of
  [10XGB[110X, with 2, 4, 8, recursions, respectively.[133X
  
  [4X[32X[104X
    [4Xgap> L := LMonsNP(GB);[104X
    [4X[ [ 1, 1, 1, 1, 2 ], [ 2, 1 ], [ 2, 2 ], [ 1, 1, 1, 1, 1 ] ][104X
    [4Xgap> L1 := PreprocessAnalysisQA(L,2,2);[104X
    [4X[ [ 1, 1, 1 ], [ 2, 1 ], [ 1, 1, 2 ], [ 2, 2 ] ][104X
    [4Xgap> L2 := PreprocessAnalysisQA(L1,2,4);[104X
    [4X[ [ 1 ], [ 2 ] ][104X
  [4X[32X[104X
  
  
  [1X3.7 [33X[0;0YFunctions of the trace variant[133X[101X
  
  [1X3.7-1 EvalTrace[101X
  
  [33X[1;0Y[29X[2XEvalTrace[102X( [3Xp[103X, [3XLnp[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe trace evaluated to a polynomial in NP format.[133X
  
  [33X[0;0YFor  a  traced polynomial [3Xp[103X and a list [3XLnp[103X of polynomials in NP format, this
  program  evaluates  the trace by substituting the polynomials of [3XLnp[103X back in
  the  expression  [10Xp.trace[110X  and computing the resulting polynomial. The result
  should have the same value as [10Xp.pol[110X.[133X
  
  [33X[0;0Y[13XExample:[113X  First  we  compute  the  traced  Gröbner  basis of the list of the
  following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,1],[]],[1,-1]];;[104X
    [4Xgap> Lnp := [p1,p2];;[104X
    [4Xgap> GBT := SGrobnerTrace(Lnp);;[104X
  [4X[32X[104X
  
  [33X[0;0YIn  order to check that the polynomials in [10XGBT[110X belong to the ideal generated
  by  [10Xp1[110X  and  [10Xp2[110X, we evaluate the trace. For each traced polynomial [10Xp[110X in [10XGBT[110X,
  the  polynomial  [10Xp.pol[110X  is  equated  to the evaluated expression [10Xp.trace[110X, in
  which each occurrence of [10XG(i)[110X is replaced by [10XLnp[i][110X by use of [2XEvalTrace[102X.[133X
  
  [4X[32X[104X
    [4Xgap> ForAll(GBT,q -> EvalTrace(q,Lnp) = q.pol);[104X
    [4Xtrue[104X
  [4X[32X[104X
  
  [1X3.7-2 PrintTraceList[101X
  
  [33X[1;0Y[29X[2XPrintTraceList[102X( [3XG[103X ) [32X function[133X
  
  [33X[0;0YWhen  invoked  with a list [3XG[103X of traced polynomials, this function prints the
  traces of that list.[133X
  
  [33X[0;0Y[13XExample:[113X  First  we  compute  the  traced  Gröbner  basis of the list of two
  polynomials in NP format and next we print it by use of [10XPrintTraceList[110X.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,1],[]],[1,-1]];;[104X
    [4Xgap> GBT := SGrobnerTrace([p1,p2]);;[104X
    [4Xgap> PrintTraceList(GBT);[104X
    [4X aG(1) - bG(1) - G(1)ba^2b + a^2G(2)ab [104X
    [4X[104X
    [4X G(1)ba^2 + bG(1)ba + G(2) - a^2G(2)a - ba^2G(2) [104X
  [4X[32X[104X
  
  [1X3.7-3 PrintTracePol[101X
  
  [33X[1;0Y[29X[2XPrintTracePol[102X( [3Xp[103X ) [32X function[133X
  
  [33X[0;0YThis function prints the trace of an NP polynomial [3Xp[103X.[133X
  
  [33X[0;0Y[13XExample:[113X  First  we  compute  the  traced  Gröbner  basis of the list of two
  polynomials  in NP format. Next we print the trace polynomial of the members
  of the list by use of [10XPrintTracePol[110X.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,1],[]],[1,-1]];;[104X
    [4Xgap> GBT := SGrobnerTrace([p1,p2]);;[104X
    [4Xgap> for np in GBT do PrintTracePol(np); Print("\n"); od;[104X
    [4X aG(1) - bG(1) - G(1)ba^2b + a^2G(2)ab [104X
    [4X[104X
    [4X G(1)ba^2 + bG(1)ba + G(2) - a^2G(2)a - ba^2G(2) [104X
    [4X[104X
  [4X[32X[104X
  
  [1X3.7-4 PrintNPListTrace[101X
  
  [33X[1;0Y[29X[2XPrintNPListTrace[102X( [3XG[103X ) [32X function[133X
  
  [33X[0;0YWhen  invoked  with  a  set  of  traced  non-commutative polynomials [3XG[103X, this
  function prints the list of the traced polynomials, without the trace.[133X
  
  [33X[0;0Y[13XExample:[113X  First  we  compute  the  traced  Gröbner  basis of the list of two
  polynomials  in  NP  format.  Next  we print the polynomials found by use of
  [10XPrintNPListTrace[110X.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,1],[]],[1,-1]];;[104X
    [4Xgap> GBT := SGrobnerTrace([p1,p2]);;[104X
    [4Xgap> PrintNPListTrace(GBT);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
  [4X[32X[104X
  
  [1X3.7-5 SGrobnerTrace[101X
  
  [33X[1;0Y[29X[2XSGrobnerTrace[102X( [3XLnp[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YGröbner Basis, traceable[133X
  
  [33X[0;0YFor  a  list  of  noncommutative  polynomials  [3XLnp[103X  this  function  will use
  Buchberger's algorithm with strong normal form to find a Gröbner Basis [10XG[110X (if
  possible; the general problem is unsolvable).[133X
  
  [33X[0;0YThe  results  will  be traceable. Functions that can print the Gröbner basis
  are  [2XPrintTraceList[102X  ([14X3.7-2[114X)  (with  the trace) and [2XPrintNPListTrace[102X ([14X3.7-4[114X)
  (without the trace).[133X
  
  [33X[0;0Y[13XExample:[113X  For  the  list  of  the  following two polynomials in NP format, a
  traced Gröbner basis is computed.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,1],[]],[1,-1]];;[104X
    [4Xgap> GBT := SGrobnerTrace([p1,p2]);[104X
    [4X[ rec( pol := [ [ [ 2 ], [ 1 ] ], [ 1, -1 ] ], [104X
    [4X      trace := [ [ [  ], 1, [ 2, 1, 1, 2 ], -1 ], [ [ 2 ], 1, [  ], -1 ], [104X
    [4X          [ [ 1 ], 1, [  ], 1 ], [ [ 1, 1 ], 2, [ 1, 2 ], 1 ] ] ), [104X
    [4X  rec( pol := [ [ [ 1, 1, 1 ], [  ] ], [ 1, -1 ] ], [104X
    [4X      trace := [ [ [ 2 ], 1, [ 2, 1 ], 1 ], [ [  ], 1, [ 2, 1, 1 ], 1 ], [104X
    [4X          [ [  ], 2, [  ], 1 ], [ [ 2, 1, 1 ], 2, [  ], -1 ], [104X
    [4X          [ [ 1, 1 ], 2, [ 1 ], -1 ] ] ) ][104X
  [4X[32X[104X
  
  [1X3.7-6 StrongNormalFormTraceDiff[101X
  
  [33X[1;0Y[29X[2XStrongNormalFormTraceDiff[102X( [3Xnp[103X, [3XGBT[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe  traced  polynomial  for  the  difference of [3Xf[103X with the strong
            normal form of [3Xnp[103X with respect to [3XGBT[103X[133X
  
  [33X[0;0YWhen  invoked with a polynomial [3Xnp[103X in NP format as its first argument, and a
  traced  Gröbner  basis  [3XGBT[103X  as  generated  by  [2XSGrobnerTrace[102X  ([14X3.7-5[114X), this
  function returns the difference of [3Xnp[103X with the strong normal form of [3Xnp[103X with
  respect  to  [3XGBT[103X.  This difference [10Xd[110X is returned as a traced polynomial. The
  trace  information  [10Xd.trace[110X gives an expression of [10Xd.pol[110X as a combination of
  polynomials from the list of polynomials to which the trace parts of [3XGBT[103X are
  referring.  Typically,  this  is  the  set of relations used as input to the
  computation of [3XGBT[103X.[133X
  
  [33X[0;0YNote  that the difference of the polynomials [3Xnp[103X and [10Xd.pol[110X is the same as the
  StrongNormalForm of [3Xnp[103X.[133X
  
  [33X[0;0Y[13XExample:[113X  First  we  compute  the  traced  Gröbner  basis of the list of the
  following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,1],[]],[1,-1]];;[104X
    [4Xgap> GBT := SGrobnerTrace([p1,p2]);;[104X
  [4X[32X[104X
  
  [33X[0;0YOf  the  polynomial  [22Xa^6[122X we compute its difference with the normal form. The
  result is printed by used of [2XPrintNP[102X ([14X3.2-1[114X) and [2XPrintTraceList[102X ([14X3.7-2[114X).[133X
  
  [4X[32X[104X
    [4Xgap> f := [[[1,1,1,1,1,1]],[1]];;[104X
    [4Xgap> sf := StrongNormalFormTraceDiff(f,GBT);;[104X
    [4Xgap> PrintNP(sf.pol);[104X
    [4X a^6 - 1 [104X
    [4Xgap> PrintTraceList([sf]);[104X
    [4X G(1)ba^2 + bG(1)ba + G(1)ba^5 + bG(1)ba^4 + G(2) + G(2)a^3 - a^2G([104X
    [4X2)a - ba^2G(2) - a^2G(2)a^4 - ba^2G(2)a^3 [104X
  [4X[32X[104X
  
  
  [1X3.8 [33X[0;0YFunctions of the truncated variant[133X[101X
  
  
  [1X3.8-1 [33X[0;0YExamples[133X[101X
  
  [33X[0;0YMore about these functions can be found in [14XA.4[114X[133X
  
  [1X3.8-2 SGrobnerTrunc[101X
  
  [33X[1;0Y[29X[2XSGrobnerTrunc[102X( [3XLnp[103X, [3Xdeg[103X, [3Xwtv[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  list of homogeneous NP polynomials if the first argument of the
            input  is  a  list  of homogeneous NP polynomials, and the boolean
            [10Xfalse[110X otherwise.[133X
  
  [33X[0;0YThis  functions  should  be  invoked  with  a  list [3XLnp[103X of polynomials in NP
  format,  a  natural number [3Xdeg[103X, and a weight vector [3Xwtv[103X of length the number
  of generators of the free algebra [22XA[122X containing the elements of [3XLnp[103X, and with
  positive  integers  for  entries.  If the polynomials of [3XLnp[103X are homogeneous
  with  respect  to  [3Xwtv[103X,  the  function  will  return  a Gröbner basis of [3XLnp[103X
  truncated  above [3Xdeg[103X. If the list of polynomials [3XLnp[103X is not homogeneous with
  respect  to  [3Xwtv[103X, it returns [10Xfalse[110X. The homogeneity check can be carried out
  by [2XCheckHomogeneousNPs[102X ([14X3.8-3[114X).[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2],[1,1]],[1,-1]];;[104X
    [4Xgap> PrintNPList([p1,p2]);[104X
    [4X ab^2a - ba^2b [104X
    [4X b^3 - a^2 [104X
  [4X[32X[104X
  
  [33X[0;0YThese  are homogeneous with respect to weights [22X[3,2][122X. The degrees are [22X10[122X and
  [22X6[122X,  respectively.  The  Gröbner  basis truncated above degree 12 of the list
  [10X[p1,p2][110X is computed and subsequently printed as follows.[133X
  
  [4X[32X[104X
    [4Xgap> PrintNPList(SGrobnerTrunc([p1,p2],12,[3,2]));[104X
    [4X ba^2 - a^2b [104X
    [4X b^3 - a^2 [104X
    [4X ab^2a - a^2b^2 [104X
  [4X[32X[104X
  
  [1X3.8-3 CheckHomogeneousNPs[101X
  
  [33X[1;0Y[29X[2XCheckHomogeneousNPs[102X( [3XLnp[103X, [3Xwtv[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  list  of  weighted  degrees  of  the  polynomials  if these are
            homogeneous with respect to [3Xwtv[103X, and [10Xfalse[110X otherwise.[133X
  
  [33X[0;0YWhen  invoked  with  a  list  of  NP polynomials [3XLnp[103X and a weight vector [3Xwtv[103X
  (whose  entries should be positive integers), this function returns the list
  of  weighted  degrees of the polynomials in [3XLnp[103X if these are all homogeneous
  and   nonzero,  and  [10Xfalse[110X  otherwise.  Here,  a  polynomial  is  (weighted)
  homogeneous  with  respect  to a weight vector [22Xw[122X if there is constant [22Xd[122X such
  that,  for  each  monomial  [22X[t_1,...,t_r][122X  of  the polynomial the sum of all
  [22Xw[t_i][122X  for  [22Xi[122X  in [22X[1..r][122X is equal to [22Xd[122X. The natural number [22Xd[122X is then called
  the weighted degree of the polynomial.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2],[1,1]],[1,-1]];;[104X
    [4Xgap> PrintNPList([p1,p2]);[104X
    [4X ab^2a - ba^2b [104X
    [4X b^3 - a^2 [104X
  [4X[32X[104X
  
  [33X[0;0YThese  are homogeneous with respect to weights [22X[3,2][122X. The degrees are [22X10[122X and
  [22X6[122X, respectively. This is checked as follows.[133X
  
  [4X[32X[104X
    [4Xgap> CheckHomogeneousNPs([p1,p2],[3,2]);[104X
    [4X[ 10, 6 ][104X
  [4X[32X[104X
  
  [1X3.8-4 BaseQATrunc[101X
  
  [33X[1;0Y[29X[2XBaseQATrunc[102X( [3XLnp[103X, [3Xdeg[103X, [3Xwtv[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  list  of monomials if the first argument of the input is a list
            of homogeneous NP polynomials or [10Xfalse[110X.[133X
  
  [33X[0;0YWhen  invoked  with  a  list of polynomials [3XLnp[103X, a natural number [3Xdeg[103X, and a
  weight  vector  [3Xwtv[103X  of  length  the  number  of variables and with positive
  integers  for entries, such that the polynomials of [3XLnp[103X are homogeneous with
  respect  to  [3Xwtv[103X, it returns a list whose [22Xi[122X-th entry is a basis of monomials
  of  the  homogeneous  part  of  degree  [22Xi-1[122X the quotient algebra of the free
  noncommutative  algebra  by  the weighted homogeneous ideal generated by [3XLnp[103X
  truncated  above  [3Xdeg[103X. If the list of polynomials [3XLnp[103X is not homogeneous, it
  returns [10Xfalse[110X.[133X
  
  [33X[0;0Y[13XExample:[113X   Consider  the  truncated  Gröbner  basis  of  the  following  two
  polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2],[1,1]],[1,-1]];;[104X
    [4Xgap> wtv := [3,2];;[104X
    [4Xgap> GB := SGrobnerTrunc([p1,p2],12,wtv);;[104X
    [4Xgap> GBNP.ConfigPrint("a","b");[104X
    [4Xgap> PrintNPList(GB);[104X
    [4X ba^2 - a^2b [104X
    [4X b^3 - a^2 [104X
    [4X ab^2a - a^2b^2 [104X
  [4X[32X[104X
  
  [33X[0;0YA basis of standard monomials is found and printed as follows.[133X
  
  [4X[32X[104X
    [4Xgap> BT := BaseQATrunc(GB,12,wtv);;[104X
    [4Xgap> for degpart in BT do [104X
    [4X>   for mon in degpart do PrintNP([[mon],[1]]); od;[104X
    [4X> od;[104X
    [4X 1 [104X
    [4X b [104X
    [4X a [104X
    [4X b^2 [104X
    [4X ba [104X
    [4X ab [104X
    [4X a^2 [104X
    [4X b^3 [104X
    [4X b^2a [104X
    [4X bab [104X
    [4X ab^2 [104X
    [4X aba [104X
    [4X a^2b [104X
    [4X b^4 [104X
    [4X a^3 [104X
    [4X b^3a [104X
    [4X b^2ab [104X
    [4X bab^2 [104X
    [4X ab^3 [104X
    [4X baba [104X
    [4X abab [104X
    [4X a^2b^2 [104X
    [4X b^5 [104X
    [4X a^2ba [104X
    [4X b^4a [104X
    [4X a^3b [104X
    [4X b^3ab [104X
    [4X b^2ab^2 [104X
    [4X bab^3 [104X
    [4X ab^4 [104X
    [4X a^4 [104X
    [4X b^2aba [104X
    [4X ab^3a [104X
    [4X babab [104X
    [4X abab^2 [104X
    [4X a^2b^3 [104X
    [4X b^6 [104X
  [4X[32X[104X
  
  [1X3.8-5 DimsQATrunc[101X
  
  [33X[1;0Y[29X[2XDimsQATrunc[102X( [3XLnp[103X, [3Xdeg[103X, [3Xwtv[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  list  of monomials if the first argument of the input is a list
            of homogeneous NP polynomials or [10Xfalse[110X.[133X
  
  [33X[0;0YWhen  invoked  with  a  list of polynomials [3XLnp[103X, a natural number [3Xdeg[103X, and a
  weight  vector  [3Xwtv[103X  of  length  the  number  of variables and with positive
  integers  for entries, such that the polynomials of [3XLnp[103X are homogeneous with
  respect  to [3Xwtv[103X, it returns a list of dimensions of the homogeneous parts of
  the  quotient  algebra  of  the  free  noncommutative  algebra  by the ideal
  generated  by  [3XLnp[103X truncated above [3Xdeg[103X. The [22Xi[122X-th entry of the list gives the
  dimension  of the homogeneous part of degree [22Xi-1[122X of the quotient algebra. If
  the list of polynomials [3XLnp[103X is not homogeneous, it returns [10Xfalse[110X.[133X
  
  [33X[0;0Y[13XExample:[113X   Consider  the  truncated  Gröbner  basis  of  the  following  two
  polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2],[1,1]],[1,-1]];;[104X
    [4Xgap> wtv := [3,2];;[104X
    [4Xgap> GB := SGrobnerTrunc([p1,p2],12,wtv);;[104X
  [4X[32X[104X
  
  [33X[0;0YInformation  on  the  dimensions  of  the  homogeneous parts of the quotient
  algebra is found as follows,[133X
  
  [4X[32X[104X
    [4Xgap> DimsQATrunc(GB,12,wtv);[104X
    [4X[ 1, 0, 1, 1, 1, 2, 2, 3, 3, 5, 4, 7, 7 ][104X
  [4X[32X[104X
  
  [1X3.8-6 FreqsQATrunc[101X
  
  [33X[1;0Y[29X[2XFreqsQATrunc[102X( [3XLnp[103X, [3Xdeg[103X, [3Xwtv[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  list of multiplicities of frequencies of monomials if the first
            argument  of  the input is a list of homogeneous polynomials in NP
            format, and [10Xfalse[110X otherwise.[133X
  
  [33X[0;0YThe  frequency  of  a  monomial  is  the list of numbers of occurrences of a
  variable  in the monomial for each variable; the multiplicity of a frequency
  is the number of monomials in the standard basis for a quotient algebra with
  this  frequency.  When  invoked  with a list [3XLnp[103X of polynomials in NP format
  representing a (truncated) Gröbner basis, a natural number [3Xdeg[103X, and a weight
  vector  [3Xwtv[103X of length the number of variables and with positive integers for
  entries,  such  that  the polynomials of [3XLnp[103X are homogeneous with respect to
  [3Xwtv[103X,  it  returns  a list of frequencies occurring with their multiplicities
  for  the  quotient  algebra  of the free noncommutative algebra by the ideal
  generated  by  [3XLnp[103X truncated above [3Xdeg[103X. The [22Xi[122X-th entry of the list gives the
  frequencies  of the weight [22X(i-1)[122X basis monomials of the quotient algebra. If
  the  list  of  polynomials  [3XLnp[103X  is  not homogeneous with respect to [3Xwtv[103X, it
  returns [10Xfalse[110X.[133X
  
  [33X[0;0Y[13XExample:[113X   Consider  the  truncated  Gröbner  basis  of  the  following  two
  polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2],[1,1]],[1,-1]];;[104X
    [4Xgap> wtv := [3,2];;[104X
    [4Xgap> GB := SGrobnerTrunc([p1,p2],12,wtv);;[104X
    [4Xgap> PrintNPList(GB);[104X
    [4X ba^2 - a^2b [104X
    [4X b^3 - a^2 [104X
    [4X ab^2a - a^2b^2 [104X
  [4X[32X[104X
  
  [33X[0;0YThe multiplicities of the frequencies of of monomials in a standard basis of
  the  quotient  algebra with respect to the ideal generated by [10XGB[110X is found as
  follows, for weights up to and including 8.[133X
  
  [4X[32X[104X
    [4Xgap> F := FreqsQATrunc(GB,8,wtv);[104X
    [4X[ [ [ [  ], 1 ] ], [ [ [ 0, 1 ], 1 ] ], [ [ [ 1, 0 ], 1 ] ], [104X
    [4X  [ [ [ 0, 2 ], 1 ] ], [ [ [ 1, 1 ], 2 ] ], [104X
    [4X  [ [ [ 2, 0 ], 1 ], [ [ 0, 3 ], 1 ] ], [ [ [ 1, 2 ], 3 ] ], [104X
    [4X  [ [ [ 2, 1 ], 2 ], [ [ 0, 4 ], 1 ] ] ][104X
  [4X[32X[104X
  
  [33X[0;0YThe interpretation of this data is given by the following lines of code.[133X
  
  [4X[32X[104X
    [4Xgap> for f in F do[104X
    [4X>   if f[1][1] <> [] then[104X
    [4X>     Print("At level ", wtv * (f[1][1]), " the multiplicities are\n");[104X
    [4X>     for x in f do[104X
    [4X>       Print("  for ",x[1],": ",x[2],"\n");[104X
    [4X>     od;[104X
    [4X>   else[104X
    [4X>     Print("At level ", 0 , " the multiplicity of [] is ",f[1][2],"\n");[104X
    [4X>   fi;[104X
    [4X>   Print("\n");[104X
    [4X> od;[104X
    [4XAt level 0 the multiplicity of [] is 1[104X
    [4X[104X
    [4XAt level 2 the multiplicities are[104X
    [4X  for [ 0, 1 ]: 1[104X
    [4X[104X
    [4XAt level 3 the multiplicities are[104X
    [4X  for [ 1, 0 ]: 1[104X
    [4X[104X
    [4XAt level 4 the multiplicities are[104X
    [4X  for [ 0, 2 ]: 1[104X
    [4X[104X
    [4XAt level 5 the multiplicities are[104X
    [4X  for [ 1, 1 ]: 2[104X
    [4X[104X
    [4XAt level 6 the multiplicities are[104X
    [4X  for [ 2, 0 ]: 1[104X
    [4X  for [ 0, 3 ]: 1[104X
    [4X[104X
    [4XAt level 7 the multiplicities are[104X
    [4X  for [ 1, 2 ]: 3[104X
    [4X[104X
    [4XAt level 8 the multiplicities are[104X
    [4X  for [ 2, 1 ]: 2[104X
    [4X  for [ 0, 4 ]: 1[104X
    [4X[104X
  [4X[32X[104X
  
  
  [1X3.9 [33X[0;0YFunctions of the module variant[133X[101X
  
  [1X3.9-1 SGrobnerModule[101X
  
  [33X[1;0Y[29X[2XSGrobnerModule[102X( [3XLnpm[103X, [3XLnp[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  record  [10XGBR[110X  containing a Gröbner basis (if found...the general
            problem  is unsolvable) for modules; [10XGBR.p[110X will contain the prefix
            rules and [10XGBR.ts[110X will contain the two-sided rules, and [10XGBR.pg[110X will
            be  the  smallest  rank  of  the  free  module to which all prefix
            relations belong[133X
  
  [33X[0;0YFor  a  list [3XLnpm[103X of vectors in NPM format (see Section [14X2.1[114X), and a list [3XLnp[103X
  of  polynomials  in NP format, this function will use Buchberger's algorithm
  with  strong  normal  form  applied  to  the  union of [3XLnpm[103X, [3XLnp[103X, the set of
  polynomials  [22Xx*e-x[122X  and  [22Xx*m[i][122X  for  [22Xx[122X  a  standard indeterminate, a module
  generator [22Xm[j][122X or the dummy indeterminate [22Xe[122X, and the set of all [22Xe*x -x[122X for [22Xx[122X
  a  standard  indeterminate, to find a Gröbner Basis record [10XGBR[110X (if possible;
  the  general  problem  is unsolvable). This record will have a Gröbner Basis
  [10XGBR.ts[110X for the two-sided ideal generated by [3XLnp[103X and an intersection with the
  module [10XGBR.p[110X representing the module relations needed to find representative
  vectors  in the module uniquely by means of a strong normal form computation
  modding out [10XGBR.p[110X and, for the scalars, [10XGBR.ts[110X.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-2]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-3]];;[104X
  [4X[32X[104X
  
  [33X[0;0YConsider also the following two vectors in NPM format.[133X
  
  [4X[32X[104X
    [4Xgap> v1 := [[[-1,1,2],[-1]],[1,-1]];;[104X
    [4Xgap> v2 := [[[-2,2,2],[-2]],[1,-2]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe Gröbner basis record for this data is found by [2XSGrobnerModule[102X:[133X
  
  [4X[32X[104X
    [4Xgap> GBR := SGrobnerModule([v1,v2],[p1,p2]);;[104X
  [4X[32X[104X
  
  [33X[0;0YThe  record  [10XGBR[110X  has  two  fields,  [10Xp[110X  for prefix relations (vectors in the
  module) and [10Xts[110X for two-sided relations (polynomials in the algebra):[133X
  
  [4X[32X[104X
    [4Xgap> PrintNPList(GBR.p);[104X
    [4X[ 0, 1 ][104X
    [4X[ 1 , 0][104X
    [4Xgap> PrintNPList(GBR.ts);[104X
    [4X b - 3/2a [104X
    [4X a^3 - 4/3 [104X
  [4X[32X[104X
  
  [1X3.9-2 BaseQM[101X
  
  [33X[1;0Y[29X[2XBaseQM[102X( [3XGBR[103X, [3Xt[103X, [3Xmt[103X, [3Xmaxno[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YA  basis  of  the  module obtained from the free module of rank [3Xmt[103X
            over  the  free  algebra  on  [3Xt[103X  generators  by  factoring out the
            submodule generated by the elements of [3XGBR[103X[133X
  
  [33X[0;0YWhen called with a Gröbner basis record [3XGBR[103X (see Section [14X2.8[114X), the number of
  variables  [3Xt[103X,  the  number  of module generators [3Xmt[103X, and a maximum number of
  terms  to  be found, [3Xmaxno[103X, the function [10XBaseQM[110X will return a (partial) base
  of the quotient module of [22XA^mt[122X over the free algebra on [22XA[122X on [10Xt[110X generators by
  the  right  sub  [22XA[122X-module  generated  by  the elements of [3XGBR[103X. Note that the
  record  [3XGBR[103X  consists of two fields: the list [3XGBR.p[103X of vectors in NPM format
  representing  elements  of  the  free  module  [22XA^mt[122X,  and the list [3XGBR.ts[103X of
  polynomials in NP format representing elements of [22XA[122X. The submodule generated
  by  [3XGBR[103X  is  considered to be the right submodule of [22XA^mt[122X generated by [3XGBR.p[103X
  and  all  elements  of  the  form  [22Xv⋅ np[122X with [22Xnp[122X in the two-sided ideal of [22XA[122X
  generated  by  [3XGBR.ts[103X  and [22Xv[122X in [22XA^mt[122X. If this function is invoked with [3Xmaxno[103X
  equal to 0, then a full basis will be given.[133X
  
  [33X[0;0YIf [3Xt[103X[22X=0[122X, then [10Xt[110X will be set to the minimal value such that all polynomials of
  [3XGBR.ts[103X and all polynomials occurring in [3XGBR.p[103X have at most [10Xt[110X variables.[133X
  
  [33X[0;0YIf  [3Xmt[103X[22X=0[122X,  then [10Xmt[110X will be set to the minimal value such that all vectors of
  [3XGBR.p[103X belong to [22XA^mt[122X.[133X
  
  [33X[0;0YIf the module is cyclic (that is, has a single generator), it is possible to
  use  the  Gröbner  basis  of the ideal in the algebra instead of the Gröbner
  basis  record.  This  can  be done by entering 0 for the number [3Xmt[103X of module
  generators.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2,1],[]],[1,-1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YConsider also the following two vectors in NPM format.[133X
  
  [4X[32X[104X
    [4Xgap> v1 := [[[-1,1,2],[-1]],[1,-1]];;[104X
    [4Xgap> v2 := [[[-2,2,2],[-2]],[1,-2]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe Gröbner basis record for this data is found by [2XSGrobnerModule[102X ([14X3.9-1[114X):[133X
  
  [4X[32X[104X
    [4Xgap> GBR := SGrobnerModule([v1,v2],[p1,p2]);;[104X
    [4Xgap> PrintNPList(GBR.ts);[104X
    [4X ba - ab [104X
    [4X b^2 - a^2 [104X
    [4X a^3b - 1 [104X
    [4X a^5 - b [104X
    [4Xgap> PrintNPList(GBR.p);[104X
    [4X[ 0, 1 ][104X
    [4X[ b - a , 0][104X
    [4X[ a^2 - 1 , 0][104X
    [4X[ ab - 1 , 0][104X
  [4X[32X[104X
  
  [33X[0;0YThe function [10XBaseQM[110X computes a basis.[133X
  
  [4X[32X[104X
    [4Xgap> B := BaseQM(GBR,2,2,0);;[104X
    [4Xgap> PrintNPList(B);[104X
    [4X[ 1 , 0][104X
    [4X[ a , 0][104X
  [4X[32X[104X
  
  [33X[0;0YThe  function [10XBaseQM[110X with arguments so as to let the number of dimensions of
  the module and the number of variables be chosen minimal.[133X
  
  [4X[32X[104X
    [4Xgap> B := BaseQM(GBR,0,0,0);;[104X
    [4Xgap> PrintNPList(B);[104X
    [4X[ 1 , 0][104X
    [4X[ a , 0][104X
  [4X[32X[104X
  
  [33X[0;0YThe function [10XBaseQM[110X can also be used to ompute the first three elements of a
  basis.[133X
  
  [4X[32X[104X
    [4Xgap> B := BaseQM(GBR,2,2,3);;[104X
    [4Xgap> PrintNPList(B);[104X
    [4X[ 1 , 0][104X
    [4X[ a , 0][104X
  [4X[32X[104X
  
  [1X3.9-3 DimQM[101X
  
  [33X[1;0Y[29X[2XDimQM[102X( [3XGBR[103X, [3Xt[103X, [3Xmt[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe dimension of the quotient module[133X
  
  [33X[0;0YWhen  called  with a Gröbner basis record [3XGBR[103X (see Section [14X2.8[114X), a number of
  variables  [3Xt[103X  at  least  equal  to  the number of generators involved in the
  polynomials  of  [3XGBR.p[103X  and  [3XGBR.ts[103X, and a number of generators [3Xmt[103X of a free
  module  containing  the  prefix  relations in [3XGBR.p[103X, the function [10XDimQM[110X will
  return  the  dimension  over the coefficient field of the quotient module of
  the  free  right  module  [22XA^mt[122X  of  rank  [3Xmt[103X  over  the  free algebra [22XA[122X on [10Xt[110X
  generators  by  the  right sub [22XA[122X-module generated by the elements of [3XGBR[103X, if
  this dimension is finite. Otherwise, the computation invoked by the function
  will not terminate.[133X
  
  [33X[0;0YIf [3Xt[103X[22X=0[122X, then [10Xt[110X will be set to the minimal value such that all polynomials of
  [3XGBR.ts[103X and all polynomials occurring in [3XGBR.p[103X belong to [22XA^mt[122X.[133X
  
  [33X[0;0YIf  [3Xmt[103X[22X=0[122X,  then [10Xmt[110X will be set to the minimal value such that all vectors of
  [3XGBR.p[103X  belong to [22XA^mt[122X. [13XExample:[113X Consider the following two polynomials in NP
  format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[2,2,2,1],[]],[1,-1]];;[104X
  [4X[32X[104X
  
  [33X[0;0YConsider also the following two vectors in NPM format.[133X
  
  [4X[32X[104X
    [4Xgap> v1 := [[[-1,1,2],[-2]],[1,-1]];;[104X
    [4Xgap> v2 := [[[-2,2,2],[-1]],[1,-2]];;[104X
  [4X[32X[104X
  
  [33X[0;0YThe Gröbner basis record for this data is found by [2XSGrobnerModule[102X ([14X3.9-1[114X):[133X
  
  [4X[32X[104X
    [4Xgap> GBR := SGrobnerModule([v1,v2],[p1,p2]);;[104X
  [4X[32X[104X
  
  [33X[0;0YThe function [10XDimQM[110X computes the dimension over the rationals of the quotient
  of  the free module over the free algebra on two generators by the submodule
  generated  by the vectors [10Xv1[110X, [10Xv2[110X, [22X[p,q][122X, where [22Xp[122X and [22Xq[122X run over all elements
  of the two-sided ideal in the free algebra generated by [10Xp1[110X and [10Xp2[110X.[133X
  
  [4X[32X[104X
    [4Xgap> SetInfoLevel(InfoGBNP,2);[104X
    [4Xgap> DimQM(GBR,2,2);[104X
    [4X0[104X
  [4X[32X[104X
  
  [33X[0;0YThe answer should be equal to the size of [10XBaseQM(GBR,t,mt,0)[110X.[133X
  
  [4X[32X[104X
    [4Xgap> DimQM(GBR,2,2) = Length(BaseQM(GBR,2,2,0));[104X
    [4Xtrue[104X
    [4Xgap> SetInfoLevel(InfoGBNP,0);[104X
  [4X[32X[104X
  
  [1X3.9-4 MulQM[101X
  
  [33X[1;0Y[29X[2XMulQM[102X( [3Xp1[103X, [3Xp2[103X, [3XGBR[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe strong normal form of the product [3Xp1[103X[22X*[122X[3Xp2[103X with respect to [3XGBR[103X[133X
  
  [33X[0;0YWhen  called  with  three  arguments,  the  first  of which, [3Xp1[103X, is a module
  element in NPM format, the second of which, [3Xp2[103X, is a polynomial in NP format
  representing an element of the quotient algebra, and the third of which is a
  Gröbner basis record [3XGBR[103X, this function will return the product [10Xp1*p2[110X in the
  module.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
    [4Xgap> PrintNPList([p1,p2]);[104X
    [4X a^2b - 1 [104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YConsider also the following two vectors in NPM format.[133X
  
  [4X[32X[104X
    [4Xgap> v1 := [[[-1,1,2],[-1]],[1,-1]];;[104X
    [4Xgap> v2 := [[[-2,2,2],[-2]],[1,-2]];;[104X
    [4Xgap> PrintNPList([v1,v2]);[104X
    [4X[ ab - 1 , 0][104X
    [4X[ 0, b^2 - 2 ][104X
  [4X[32X[104X
  
  [33X[0;0YThe Gröbner basis record for this data is found by [2XSGrobnerModule[102X ([14X3.9-1[114X):[133X
  
  [4X[32X[104X
    [4Xgap> GBR := SGrobnerModule([v1,v2],[p1,p2]);;[104X
    [4Xgap> PrintNPList(GBR.ts);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
    [4Xgap> PrintNPList(GBR.p);[104X
    [4X[ 0, 1 ][104X
    [4X[ a - 1 , 0][104X
  [4X[32X[104X
  
  [33X[0;0YThe  function [10XMulQM[110X computes the product of the vector [10Xw[110X with the polynomial
  [10Xq[110X.[133X
  
  [4X[32X[104X
    [4Xgap> w := [[[-1,2],[-2,1]],[1,-4]];;[104X
    [4Xgap> PrintNP(w);[104X
    [4X[ b , - 4a ][104X
    [4Xgap> q := [[[2,2,1],[1]],[2,3]];;[104X
    [4Xgap> PrintNP(q);[104X
    [4X 2b^2a + 3a [104X
    [4Xgap> wq := MulQM(w,q,GBR);;[104X
    [4Xgap> PrintNP(wq);[104X
    [4X[ 5 , 0][104X
  [4X[32X[104X
  
  [1X3.9-5 StrongNormalFormNPM[101X
  
  [33X[1;0Y[29X[2XStrongNormalFormNPM[102X( [3Xf[103X, [3XGBR[103X ) [32X function[133X
  [6XReturns:[106X  [33X[0;10YThe  strong  normal form of a polynomial in NP format with respect
            to [3XGBR[103X[133X
  
  [33X[0;0YWhen  invoked with a polynomial in NP format (see Section [14X2.1[114X) and a Gröbner
  basis  record  [3XGBR[103X  (see  Section [14X2.8[114X), this function will return the strong
  normal form (the polynomial reduced by the prefix and two-sided relations of
  the Gröbner basis combination).[133X
  
  [33X[0;0YThis  function  assumes that [3XGBR.p[103X and [3XGBR.ts[103X are ordered (with the ordering
  [2XLtNP[102X  ([14X3.3-9[114X)),  that  the  polynomials  in  [3XGBR.ts[103X are monic and clean (see
  [2XMkMonicNP[102X ([14X3.3-11[114X) and [2XCleanNP[102X ([14X3.3-7[114X)), and that the polynomial [3Xf[103X is clean.
  Note   that   a  Gröbner  basis  record  as  returned  by  a  function  like
  [2XSGrobnerModule[102X ([14X3.9-1[114X) is in the required form.[133X
  
  [33X[0;0Y[13XExample:[113X Consider the following two polynomials in NP format.[133X
  
  [4X[32X[104X
    [4Xgap> p1 := [[[1,1,2],[]],[1,-1]];;[104X
    [4Xgap> p2 := [[[1,2,2],[]],[1,-1]];;[104X
    [4Xgap> PrintNPList([p1,p2]);[104X
    [4X a^2b - 1 [104X
    [4X ab^2 - 1 [104X
  [4X[32X[104X
  
  [33X[0;0YConsider also the following two vectors in NPM format.[133X
  
  [4X[32X[104X
    [4Xgap> v1 := [[[-1,1,2],[-1]],[1,-1]];;[104X
    [4Xgap> v2 := [[[-2,2,2],[-2]],[1,-2]];;[104X
    [4Xgap> PrintNPList([v1,v2]);[104X
    [4X[ ab - 1 , 0][104X
    [4X[ 0, b^2 - 2 ][104X
  [4X[32X[104X
  
  [33X[0;0YThe Gröbner basis record for this data is found by [2XSGrobnerModule[102X ([14X3.9-1[114X):[133X
  
  [4X[32X[104X
    [4Xgap> GBR := SGrobnerModule([v1,v2],[p1,p2]);;[104X
    [4Xgap> PrintNPList(GBR.ts);[104X
    [4X b - a [104X
    [4X a^3 - 1 [104X
    [4Xgap> PrintNPList(GBR.p);[104X
    [4X[ 0, 1 ][104X
    [4X[ a - 1 , 0][104X
  [4X[32X[104X
  
  [33X[0;0YThe vector [10Xw[110X is brought into strong normal form with respect to [10XGBR[110X:[133X
  
  [4X[32X[104X
    [4Xgap> w := [[[-1,2],[-2,1]],[1,-4]];;[104X
    [4Xgap> PrintNP(w);[104X
    [4X[ b , - 4a ][104X
    [4Xgap> v := StrongNormalFormNPM(w,GBR);;[104X
    [4Xgap> PrintNP(v);[104X
    [4X[ 1 , 0][104X
  [4X[32X[104X
  
