From ba0cc48672e72e2130518076af9c73744717253a Mon Sep 17 00:00:00 2001 From: Chris Wensley Date: Mon, 25 Sep 2023 15:37:54 +0100 Subject: [PATCH 1/4] Nmo tst (#30) * added four NMO tests * renamed tst/testfunctions.tst * added UnpatchGBNP() commands to nmo.tst --- tst/{test-functions.tst => functions.tst} | 4 +- tst/nmo.tst | 217 +++ tst/test-functions.g | 1591 --------------------- 3 files changed, 219 insertions(+), 1593 deletions(-) rename tst/{test-functions.tst => functions.tst} (99%) create mode 100644 tst/nmo.tst delete mode 100644 tst/test-functions.g diff --git a/tst/test-functions.tst b/tst/functions.tst similarity index 99% rename from tst/test-functions.tst rename to tst/functions.tst index beb3572..a71e06f 100644 --- a/tst/test-functions.tst +++ b/tst/functions.tst @@ -1,4 +1,4 @@ -gap> START_TEST("GBNP test-functions"); +gap> START_TEST("GBNP functions"); gap> ######################### BEGIN COPYRIGHT MESSAGE ######################### gap> # GBNP - computing Gröbner bases of noncommutative polynomials gap> # Copyright 2001-2010 by Arjeh M. Cohen, Dié A.H. Gijsbers, Jan Willem @@ -1948,4 +1948,4 @@ gap> NumModGensNPList([v1,v2]); gap> # gap> # <#/GAPDoc> gap> -gap> STOP_TEST("test-functions.g",10000); +gap> STOP_TEST("GBNP functions",10000); diff --git a/tst/nmo.tst b/tst/nmo.tst new file mode 100644 index 0000000..1c1260e --- /dev/null +++ b/tst/nmo.tst @@ -0,0 +1,217 @@ +gap> START_TEST("NMO functions"); +gap> ######################### BEGIN COPYRIGHT MESSAGE ######################### +gap> # GBNP - computing Gröbner bases of noncommutative polynomials +gap> # Copyright 2001-2010 by Arjeh M. Cohen, Dié A.H. Gijsbers, Jan Willem +gap> # Knopper, Chris Krook. Address: Discrete Algebra and Geometry (DAM) group +gap> # at the Department of Mathematics and Computer Science of Eindhoven +gap> # University of Technology. +gap> # +gap> # For acknowledgements see the manual. The manual can be found in several +gap> # formats in the doc subdirectory of the GBNP distribution. The +gap> # acknowledgements formatted as text can be found in the file chap0.txt. +gap> # +gap> # GBNP is free software; you can redistribute it and/or modify it under +gap> # the terms of the Lesser GNU General Public License as published by the +gap> # Free Software Foundation (FSF); either version 2.1 of the License, or +gap> # (at your option) any later version. For details, see the file 'LGPL' in +gap> # the doc subdirectory of the GBNP distribution or see the FSF's own site: +gap> # https://www.gnu.org/licenses/lgpl.html +gap> ########################## END COPYRIGHT MESSAGE ########################## +gap> +gap> # First load the gap package (before the example) +gap> +gap> LoadPackage("gbnp", false); +true +gap> +gap> # NMO Example 1 is taken from Dr. Edward Green's paper +gap> # Noncommutative Gröbner Bases, and Projective Resolutions, +gap> # and is referenced as Example 2.7 there; +gap> # please see for more information. +gap> # +gap> # remove any previous orderings +gap> UnpatchGBNP(); +LtNP restored. +GtNP restored. +gap> # Create a noncommutative free algebra on 4 gens over the Rationals +gap> A := FreeAssociativeAlgebraWithOne(Rationals,"a","b","c","d"); + +gap> # Label the generators of the algebra: +gap> a := A.a; b := A.b; c := A.c; d := A.d; +(1)*a +(1)*b +(1)*c +(1)*d +gap> # Set up our polynomials, and convert them to NP format: +gap> polys := [ c*d*a*b-c*b, b*c-d*a ]; +[ (-1)*c*b+(1)*c*d*a*b, (1)*b*c+(-1)*d*a ] +gap> reps := GP2NPList( polys ); +[ [ [ [ 3, 4, 1, 2 ], [ 3, 2 ] ], [ 1, -1 ] ], + [ [ [ 4, 1 ], [ 2, 3 ] ], [ -1, 1 ] ] ] +gap> # Compute the Gröbner basis via GBNP using its default +gap> # (length left-lexicographic) ordering; that is, +gap> # without patching GBNP with an NMO ordering: +gap> gbreps := Grobner( reps );; +gap> gb := NP2GPList( gbreps, A ); +[ (1)*d*a+(-1)*b*c, (1)*(c*b)^2+(-1)*c*b ] +gap> +gap> # Create a length left-lexicographic ordering, +gap> # with generators ordered: a < b < c < d. +gap> # Note: this is the default ordering of generators by NMO, +gap> # if none is provided: +gap> ml := NCMonomialLeftLengthLexOrdering( A ); +NCMonomialLeftLengthLexicographicOrdering([ (1)*a, (1)*b, (1)*c, (1)*d ]) +gap> +gap> # Patch GBNP with the ordering ml, and then run the same example. +gap> # We should get the same answer as above: +gap> PatchGBNP( ml ); +LtNP patched. +GtNP patched. +gap> gbreps := Grobner( reps );; +gap> gb := NP2GPList( gbreps, A ); +[ (1)*d*a+(-1)*b*c, (1)*(c*b)^2+(-1)*c*b ] +gap> +gap> # Now create a Length-Lexicographic ordering on the generators +gap> # such that d < c < b < a +gap> ml2 := NCMonomialLeftLengthLexOrdering( A, [4,3,2,1] ); +NCMonomialLeftLengthLexicographicOrdering([ (1)*d, (1)*c, (1)*b, (1)*a ]) +gap> +gap> # Compute the Gröbner basis w.r.t this new ordering on the same algebra: +gap> PatchGBNP( ml2 ); +LtNP patched. +GtNP patched. +gap> gbreps2 := SGrobner( reps );; +gap> gb2 := NP2GPList( gbreps2, A ); +[ (1)*b*c+(-1)*d*a, (1)*c*d*a*b+(-1)*c*b, (1)*(d*a)^2*b+(-1)*d*a*b, + (1)*c*(d*a)^2+(-1)*c*d*a, (1)*(d*a)^3+(-1)*(d*a)^2 ] +gap> +gap> +gap> # NMO Example 2 is the same as Example 1 above, except that the length +gap> # and left-lexicographic orderings are created independently and then +gap> # chained to form the usual length left-lexicographic ordering. +gap> # Hence, all results should be the same. +gap> +gap> # remove any previous orderings +gap> UnpatchGBNP(); +LtNP restored. +GtNP restored. +gap> # Create a noncommutative free algebra on 4 generators over the +gap> # Rationals, label, and set up the example: +gap> A := FreeAssociativeAlgebraWithOne(Rationals,"a","b","c","d");; +gap> a := A.a;; b := A.b;; c := A.c;; d := A.d;; +gap> polys := [ c*d*a*b-c*b, b*c-d*a ];; +gap> reps := GP2NPList( polys );; +gap> # Create left-lexicographic ordering with a < b < c < d: +gap> lexord := NCMonomialLeftLexicographicOrdering( A ); +NCMonomialLeftLexicographicOrdering([ (1)*a, (1)*b, (1)*c, (1)*d ]) +gap> # Create a length ordering on monomials in A, +gap> # with ties broken by the lexicographic order lexord: +gap> lenlex := NCMonomialLengthOrdering( A, lexord ); +NCMonomialLengthOrdering([ (1)*a, (1)*b, (1)*c, (1)*d ]) +gap> +gap> # Patch GBNP and proceed with our example: +gap> PatchGBNP( lenlex );; +LtNP patched. +GtNP patched. +gap> gbreps := Grobner( reps );; +gap> gb := NP2GPList( gbreps, A ); +[ (1)*d*a+(-1)*b*c, (1)*(c*b)^2+(-1)*c*b ] +gap> +gap> # Now, proceed similarly, with the lexicographic order +gap> # such that d < c < b < a: +gap> lexord2 := NCMonomialLeftLexicographicOrdering( A, [4,3,2,1] ); +NCMonomialLeftLexicographicOrdering([ (1)*d, (1)*c, (1)*b, (1)*a ]) +gap> lenlex2 := NCMonomialLengthOrdering( A, lexord2 ); +NCMonomialLengthOrdering([ (1)*a, (1)*b, (1)*c, (1)*d ]) +gap> PatchGBNP( lenlex2 );; +LtNP patched. +GtNP patched. +gap> gbreps2 := Grobner( reps );; +gap> gb2 := NP2GPList( gbreps2, A ); +[ (1)*b*c+(-1)*d*a, (1)*c*d*a*b+(-1)*c*b, (1)*(d*a)^2*b+(-1)*d*a*b, + (1)*c*(d*a)^2+(-1)*c*d*a, (1)*(d*a)^3+(-1)*(d*a)^2 ] +gap> # An important point can be made here. Notice that when the lenlex2 +gap> # length ordering is created, a lexicographic (generator) ordering +gap> # table is assigned internally to the ordering since one was not +gap> # provided to it. +gap> # This is justa convenience for lexicographically-dependent orderings, +gap> # and in the case of the length order, it is not used. +gap> # Only the lex table for lexord2 is ever used. +gap> # Some clarification may be provided in examining: +gap> HasNextOrdering( lenlex2 ); +true +gap> NextOrdering( lenlex2 ); +NCMonomialLeftLexicographicOrdering([ (1)*d, (1)*c, (1)*b, (1)*a ]) +gap> LexicographicTable( NextOrdering( lenlex2 ) ); +[ (1)*d, (1)*c, (1)*b, (1)*a ] +gap> +gap> +gap> # NMO Example 3 is taken from the book +gap> # 'Ideals, Varieties, and Algorithms', (, +gap> # Example 2, p. 93-94); it is a commutative example. +gap> # First, set up the problem and find a Gröbner basis w.r.t. the length +gap> # left-lexicographic ordering implicitly assumed in GBNP: +gap> # remove any previous orderings +gap> UnpatchGBNP(); +LtNP restored. +GtNP restored. +gap> A3 := FreeAssociativeAlgebraWithOne( Rationals, "x", "y", "z" );; +gap> x := A3.x;; y := A3.y;; z := A3.z;; id := One(A3);; +gap> polys3 := [ x^2 + y^2 + z^2 - id, x^2 + z^2 - y, x-z, +> x*y-y*x, x*z-z*x, y*z-z*y];; +gap> reps3 := GP2NPList( polys3 );; +gap> gb3 := Grobner( reps3 );; +gap> NP2GPList( gb3, A3 ); +[ (1)*z+(-1)*x, (1)*x^2+(-1/2)*y, (1)*y*x+(-1)*x*y, + (1)*y^2+(2)*x^2+(-1)* ] +gap> +gap> # The example, as presented in the book, uses a left-lexicographic +gap> # ordering with z < y < x. We create the ordering in NMO, +gap> # patch GBNP,and get the result expected: +gap> ml3 := NCMonomialLeftLexicographicOrdering( A3, [3,2,1] ); +NCMonomialLeftLexicographicOrdering([ (1)*z, (1)*y, (1)*x ]) +gap> PatchGBNP( ml3 ); +LtNP patched. +GtNP patched. +gap> gb3 := Grobner( reps3 );; +gap> NP2GPList( gb3, A3 ); +[ (1)*z^4+(1/2)*z^2+(-1/4)*, (1)*y+(-2)*z^2, (1)*x+(-1\ +)*z ] +gap> +gap> +gap> # NMO Example 4 was taken from page 339 of the book +gap> # 'Some Tapas of Computer Algebra' by A.M. Cohen, H. Cuypers, H. Sterk, +gap> # ; +gap> # it also appears as Example 6 in the GBNP example set. +gap> # A noncommutative free algebra on 6 generators over the Rationals +gap> # is created in GAP, and the generators are labeled: +gap> # remove any previous orderings +gap> UnpatchGBNP(); +LtNP restored. +GtNP restored. +gap> A4 := FreeAssociativeAlgebraWithOne(Rationals,"a","b","c","d","e","f");; +gap> a := A4.a;; b := A4.b;; c := A4.c;; d := A4.d;; e := A4.e;; f := A4.f;; +gap> # Set up list of noncommutative polynomials: +gap> polys4 := [ e*a, a^3 + f*a, a^9 + c*a^3, a^81 + c*a^9 + d*a^3, +> a^27 + d*a^81 + e*a^9 + f*a^3, b + c*a^27 + e*a^81 + f*a^9, +> c*b + d*a^27 + f*a^81, a + d*b + e*a^27, c*a + e*b + f*a^27, +> d*a + f*b, b^3 - b, a*b - b*a, a*c - c*a, a*d - d*a, +> a*e - e*a, a*f - f*a, b*c - c*b, b*d - d*b, b*e - e*b, +> b*f - f*b, c*d - d*c, c*e - e*c, c*f - f*c, d*e - e*d, +> d*f - f*d, e*f - f*e ];; +gap> reps4 := GP2NPList( polys4 );; +gap> # Create a length left-lex ordering with the following (default) +gap> # ordering on the generators: a < b < c < d < e < f: +gap> ml4 := NCMonomialLeftLengthLexOrdering( A4 ); +NCMonomialLeftLengthLexicographicOrdering([ (1)*a, (1)*b, (1)*c, (1)*d, + (1)*e, (1)*f ]) +gap> # Patch GBNP and compute the Gröbner basis w.r.t the ordering ml4: +gap> PatchGBNP( ml4 ); +LtNP patched. +GtNP patched. +gap> gb4 := Grobner( reps4 );; +gap> NP2GPList( gb4, A4 ); +[ (1)*a, (1)*b, (1)*d*c+(-1)*c*d, (1)*e*c+(-1)*c*e, + (1)*e*d+(-1)*d*e, (1)*f*c+(-1)*c*f, + (1)*f*d+(-1)*d*f, (1)*f*e+(-1)*e*f ] +gap> +gap> STOP_TEST("NMO functions",10000); diff --git a/tst/test-functions.g b/tst/test-functions.g deleted file mode 100644 index 1d19a73..0000000 --- a/tst/test-functions.g +++ /dev/null @@ -1,1591 +0,0 @@ -######################### BEGIN COPYRIGHT MESSAGE ######################### -# GBNP - computing Gröbner bases of noncommutative polynomials -# Copyright 2001-2010 by Arjeh M. Cohen, Dié A.H. Gijsbers, Jan Willem -# Knopper, Chris Krook. Address: Discrete Algebra and Geometry (DAM) group -# at the Department of Mathematics and Computer Science of Eindhoven -# University of Technology. -# -# For acknowledgements see the manual. The manual can be found in several -# formats in the doc subdirectory of the GBNP distribution. The -# acknowledgements formatted as text can be found in the file chap0.txt. -# -# GBNP is free software; you can redistribute it and/or modify it under -# the terms of the Lesser GNU General Public License as published by the -# Free Software Foundation (FSF); either version 2.1 of the License, or -# (at your option) any later version. For details, see the file 'LGPL' in -# the doc subdirectory of the GBNP distribution or see the FSF's own site: -# https://www.gnu.org/licenses/lgpl.html -########################## END COPYRIGHT MESSAGE ########################## - -# First load the gap package (before the example) - -LoadPackage("gbnp", false); - -# <#GAPDoc Label="example-GP2NP"> - -# Example: -# Let A be the free associative algebra with one over the rationals on the -# generators a and b. Let e be the one of the algebra. - -# -A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");; -a:=A.a;; -b:=A.b;; -e:=One(A);; -z:=Zero(A);; -# - -# Now let gp be the polynomial ba-ab-e. - -# -gp:=b*a-a*b-e; -# - -# The polynomial in NP format, corresponding to gp can now be obtained -# with GP2NP: - -# -GP2NP(gp); -# - - - -# Let D be the free associative algebra over A -# of rank 2. - -# -D := A^2;; -# - -# Take the following list R of two elements of D. - -# -R := [ [b-e, z], [e+a*(e+a+b), -e-a*(e+a+b)] ];; -# - -# Convert the list R to a list of vectors in NPM format. - -# -List(R,GP2NP); -# - -# <#/GAPDoc> - -# <#GAPDoc Label="example-GP2NPList"> - -# Example: -# Let A be the free associative algebra with one over the rationals on the -# generators a and b. Let e be the one of the algebra. - -# -A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");; -a:=A.a;; -b:=A.b;; -e:=One(A);; -# - -# Let Lgp be the list of polynomials [a^2-e,b^2-e,ba-ab-e]. - -# -Lgp:=[a^2-e,b^2-e,b*a-a*b-e]; -# - -# The polynomial in NP format corresponding to gp can be obtained -# with GP2NP: - -# -GP2NPList(Lgp); -# - -# The same result is obtained by a simple application of the standard List -# function in GAP: - -# -List(Lgp,GP2NP) = GP2NPList(Lgp); -# - - -# <#/GAPDoc> - -# <#GAPDoc Label="example-NP2GP"> - -# Example: -# Let A be the free associative algebra with one over the rationals on -# the generators a and b. - -# -A:=FreeAssociativeAlgebraWithOne(GF(3),"a","b");; -# - -# Let np be a polynomial in NP format. - -# -np:=[ [ [ 2, 1 ], [ 1, 2 ], [ ] ], [ Z(3)^0, Z(3), Z(3) ] ];; -# - -# The polynomial can be converted to the corresponding element of A -# with NP2GP: - -# -NP2GP(np,A); -# - -# Note that some information of the coefficient field of -# a polynomial -# np in NP format can be obtained from the second list of np. - -# -One(np[2][1]); -# - - -# Now let M be the module A^2 and let npm be a polynomial -# over that module in NPM form. - -# -M:=A^2;; -npm:=[ [ [ -1, 1 ], [ -2, 2 ] ], [ Z(3)^0, Z(3)^0 ] ];; -# - - - -# The element of M corresponding to npm is - -# -NP2GP(npm,M); -# - - -# If M is a module of dimension 2 over A and Lnp a list -# of polynomials in NPM format, then the polynomials can be converted to the -# corresponding polynomials of M as follows: - -# -M:=A^2;; -Lnp:=[ [ [ [ -2, 1, 1 ], [ -2, 1 ] ], [ 1, -1 ] ], - [ [ [ -1, 2, 2], [-2, 1 ] ], [ 1, -1 ]*Z(3)^0 ] ];; -List(Lnp, m -> NP2GP(m,M)); -# - - - - - -# <#/GAPDoc> - -# <#GAPDoc Label="example-NP2GPList"> - -# Example: -# Let A be the free associative algebra with one over the rationals on -# the generators a and b. - -# -A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");; -# - -# Let Lnp be a list of polynomials in NP format. -# Then Lnp can be converted to a list of polynomials of A -# with NP2GPList: - -# -Lnp:=[ [ [ [ 1, 1, 1 ], [ 1 ] ], [ 1, -1 ] ], - [ [ [ 2, 2 ], [ ] ], [ 1, -1 ] ] ];; -NP2GPList(Lnp,A); -# - - -# It has the same effect as the function List applied as follows. - -# -List(Lnp, p -> NP2GP(p,A)); -# - -# Now let M be a module of dimension 2 over A and Lnp -# a list of vectors in NPM format. Then polynomials Lnp -# can be converted to the -# corresponding vectors of M with NP2GPList: - -# -M:=A^2;; -Lnp:=[ [ [ [ -2, 1, 1 ], [ -2, 1 ] ], [ 1, -1 ] ], - [ [ [ -1, 1 ], [ -2 ] ], [ 1, -1 ] ] ];; -NP2GPList(Lnp,M); -# - -# The same result can be obtained by application of the standard -# List function: - -# -List(Lnp, m -> NP2GP(m,M)) = NP2GPList(Lnp,M) ; -# - - -# <#/GAPDoc> - - - - -# <#GAPDoc Label="example-PrintNP"> -# Example: -# Consider the following polynomial in NP format. -# -p := [[[1,1,2],[1,2,2],[]],[1,-2,3]];; -# - - -# It can be printed in the guise of a polynomial in a and b -# by the function PrintNP: -# -PrintNP(p); -# - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-ConfigPrint"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -# - - -# They can be printed by the function PrintNP. -# -PrintNP(p1); -PrintNP(p2); -# - -# We can let the variables be printed as x and y -# instead of a and b by means of -# . -# -GBNP.ConfigPrint("x","y"); -PrintNP(p1); -PrintNP(p2); -# - - -# We can also let the variables be printed as x.1 and x.2 -# instead of a and b by means of -# . -# -GBNP.ConfigPrint(2,"x"); -PrintNP(p1); -PrintNP(p2); -# - - -# We can even assign strings to the variables to -# be printed like alice and bob -# instead of a and b by means of -# . -# -GBNP.ConfigPrint("alice","bob"); -PrintNP(p1); -PrintNP(p2); -# - - -# Alternatively, we can introduce the free algebra A -# with two generators, -# and print the polynomials as members of A: - -# -A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");; -GBNP.ConfigPrint(A); -PrintNP(p1); -PrintNP(p2); -# - - -# <#/GAPDoc> - - - - -# <#GAPDoc Label="example-PrintNPList"> -# Example: -# We put two polynomials in NP format into the list Lnp. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -Lnp := [p1,p2];; -# - -# We can print the list with -# . -# -PrintNPList(Lnp); -# - -# Alternatively, using the function -# , -# we can introduce the free algebra A -# with two generators, -# and print the polynomials of the list as members of A: - -# -A:=FreeAssociativeAlgebraWithOne(Rationals,"a","b");; -GBNP.ConfigPrint(A); -PrintNPList(Lnp); -# - - -# <#/GAPDoc> - - - - -# <#GAPDoc Label="example-AddNP"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-3]];; -p2 := [[[1,2,2],[]],[1,-4]];; -# - - -# The second can be subtracted from the first by the function AddNP. -# -PrintNP(AddNP(p1,p2,1,-1)); -# - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-BimulNP"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-3]];; -p2 := [[[1,2,2],[]],[1,-4]];; -# - -# Multiplying p1 from the right by b and -# multiplying p2 from the left by a -# is possible with the function BimulNP: -# -PrintNP(BimulNP([],p1,[2])); -PrintNP(BimulNP([1],p2,[])); -# - -# <#/GAPDoc> - - - - -# <#GAPDoc Label="example-CleanNP"> -# Example: -# Consider the following polynomial in NP format. -# -p := [[[1,1,2],[],[1,1,2],[]],[1,-3,-2,3]];; -PrintNP(p); -# - -# The monomials [1,1,2] and [] occur twice each. -# For many functions this representation of a polynomial in NP format -# is not allowed. It needs to be cleaned, as by : -# -PrintNP(CleanNP(p)); -# - - -# In order to define a polynomial over GF(2), -# 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 CleanNP. -# -p := [[[1,1,2],[]],One(GF(2))*[1,-2]];; -CleanNP(p); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-GtNP"> -# Example: -# Consider the following two monomials. -# -u := [1,1,2]; -v := [2,2,1]; -# - -# We test whether u is greater than v. - -# -GtNP(u,v); -# - -# <#/GAPDoc> - - - - -# <#GAPDoc Label="example-LtNP"> -# Example: -# Consider the following two monomials. -# -u := [1,1,2]; -v := [2,2,1]; -# - -# We test whether u is less than v. - -# -LtNP(u,v); -# - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-LMonsNP"> -# Example: -# We put two polynomials in NP format into the list Lnp. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -Lnp := [p1,p2];; -# - -# The list of leading monomials is computed by LMonsNP: - -# -LMonsNP(Lnp); -# - - -# For a nicer printing, the monomials can be converted into polynomials in NP format, -# and then submitted to PrintNPList: - -# -PrintNPList(List(LMonsNP(Lnp), q -> [[q],[1]])); -# - -# <#/GAPDoc> - -# <#GAPDoc Label="example-MkMonicNP"> -# Example: -# Consider the following polynomial in NP format. -# -p := [[[1,1,2],[]],[2,-1]];; -PrintNP(p); -# - -# The coefficient of the leading term is 2. The function MkMonicNP finds -# this coefficient and divides all terms by it: - -# -PrintNP(MkMonicNP(p)); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-MulNP"> -# Example: - -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -# - -# The function MulNP multiplies the two polynomials. -# -PrintNP(MulNP(p1,p2)); -# - - -# The fact that this multiplication is not commutative is illustrated by -# the following comparison, using MulNP twice and AddNP once. -# -PrintNP(AddNP(MulNP(p1,p2),MulNP(p2,p1),1,-1)); -# - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-StrongNormalFormNP"> -# Example: - -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -# -# The strong normal form of the polynomial -# -p := [[[1,1,1,2],[2,1],[]],[1,-1,3]];; -# -# with respect to the list [p1,p2] -# is computed by use of the function StrongNormalFormNP: -# -PrintNP(StrongNormalFormNP(p,[p1,p2])); -# -# <#/GAPDoc> - - -# <#GAPDoc Label="example-Grobner"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -PrintNPList([p1,p2]); -# - - -# Their Gröbner basis can be computed by the function Grobner. -# -G := Grobner([p1,p2]);; -PrintNPList(G); -# - -# One iteration of the Gröbner computations is invoked by use of the parameter -# max: -# -R := Grobner([p1,p2],1);; -PrintNPList(R.G); -PrintNPList(R.todo); -R.iterations; -R.completed; -# - -# The above list R.todo can be used to resume the computation -# of the Gröbner basis computation with the Gröbner pair -# R.G, R.todo: -# -PrintNPList(Grobner(R.G,R.todo)); -# - -# In order to perform -# the Gröbner basis computation with polynomials in -# a free algebra over the field GF(2), the coefficients -# of the polynomials need to be defined over that field. - -# -PrintNPList(Grobner([[p1[1],One(GF(2))*p1[2]],[p2[1],One(GF(2))*p1[2]]])); -# - - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-SGrobner"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -PrintNPList([p1,p2]); -# - - -# Their Gröbner basis can be computed by the function Grobner. -# -G := SGrobner([p1,p2]);; -PrintNPList(G); -# - -# One iteration of the Gröbner computations is invoked by use of the parameter -# max: -# -R := SGrobner([p1,p2],1);; -PrintNPList(R.G); -PrintNPList(R.todo); -R.iterations; -R.completed; -# - -# The above list R.todo can be used to resume the computation -# of the Gröbner basis computation with the Gröbner pair -# R.G, R.todo: -# -PrintNPList(SGrobner(R.G,R.todo)); -# -# <#/GAPDoc> - - -# <#GAPDoc Label="example-BaseQA"> -# Example: -# Consider the following Gröbner basis. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -G := Grobner([p1,p2]);; -PrintNPList(G); -# -# The function BaseQA computes a basis for the -# quotient algebra of the free algebra over the rationals -# with generators a and b -# by the two-sided ideal generated by G. -# -PrintNPList(G); -BaseQA(G,2,0); -PrintNPList(BaseQA(G,2,0)); -# - -# It is necessary for a correct result that the first argument -# be a Gröbner basis, as will be clear from the following invocation -# of BaseQA. -# -PrintNPList(BaseQA([p1,p2],2,10)); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-DimQA"> -# Example: -# Consider the following Gröbner basis. -# -p1 := [[[1,1,2],[]],[1,-2]];; -p2 := [[[1,2,2],[]],[1,-2]];; -G := Grobner([p1,p2]);; -PrintNPList(G); -# -# The function DimQA computes the dimension of the -# quotient algebra of the free algebra over the rationals -# with generators a and b -# by the two-sided ideal generated by G. -# -DimQA(G,2); -# -# <#/GAPDoc> - - -# <#GAPDoc Label="example-MulQA"> -# Example: -# Consider the following Gröbner basis. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -G := Grobner([p1,p2]);; -PrintNPList(G); -# - -# Print the product in the quotient algebra of the polynomials -# a-2 and b-3 by use of MulQA: -# -s1 := [[[1],[]],[1,-2]];; -s2 := [[[2],[]],[1,-3]];; -PrintNP(MulQA(s1,s2,G)); -# - -# The result should be equal to the strong normal form of -# the product of a-2 and b-3 with respect to -# G: -# -MulQA(s1,s2,G) = StrongNormalFormNP(MulNP(s1,s2),G); -# - - -# <#/GAPDoc> - -# <#GAPDoc Label="example-IsStrongGrobnerBasis"> -# Example: -# Consider the following list of two polynomials in NP format. -# -Lnp := [[[[1,1,2],[]],[1,-1]], [[[1,2,2],[]],[1,-1]]];; -PrintNPList(Lnp); -# -# The function IsStrongGrobner checks whether the list is a -# strong Gröbner basis. -# -IsStrongGrobnerBasis(Lnp); -# - -# But the answer should be true for the result of a -# strong Gröbner computation: -# -IsStrongGrobnerBasis(SGrobner(Lnp)); -# - -# A Gröbner basis that is not a strong Gröbner basis: -# -B := SGrobner(Lnp);; -Add(B,AddNP(Lnp[1],B[1],1,-1));; -PrintNPList(B); -IsGrobnerBasis(B); -IsStrongGrobnerBasis(B); -# -# <#/GAPDoc> - - -# <#GAPDoc Label="example-IsGrobnerBasis"> -# Example: -# Consider the following list of two polynomials in NP format. -# -Lnp := [[[[1,1,2],[]],[1,-1]], [[[1,2,2],[]],[1,-1]]];; -PrintNPList(Lnp); -# -# The function IsGrobner checks whether the list is a -# Gröbner basis. -# -IsGrobnerBasis(Lnp); -# - -# So the answer should be true for the result of a -# Gröbner computation: -# -IsGrobnerBasis(Grobner(Lnp)); -# - -# <#/GAPDoc> - -# <#GAPDoc Label="example-IsGrobnerPair"> -# Example: -# Consider the following four polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -q1 := [[[2],[1]],[1,-1]];; -q2 := [[[1,1,1],[]],[1,-1]];; -# -# The function IsGrobnerPair is used to check whether -# some combinations of these polynomials in two lists provide -# Gröbner pairs. -# -IsGrobnerPair([p1,p2,q1],[q2]); -IsGrobnerPair([q1,q2],[p1,p2]); -# - -# The function IsGrobnerPair applied with an empty list -# as second argument is a check whether the first argument is a -# Gröbner basis. -# -IsGrobnerPair([p1,p2],[]) = IsGrobnerBasis([p1,p2]); -# - -# <#/GAPDoc> - -# <#GAPDoc Label="example-MakeGrobnerPair"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -# - -# The function MakeGrobnerPair 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 G and todo -# -GP := MakeGrobnerPair([p1,p2],[]);; -PrintNPList(GP.G); -PrintNPList(GP.todo); -# - -# These fields are ready for use in Grobner -# -GB := Grobner(GP.G,GP.todo);; -PrintNPList(GB); -# - - - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-StrongNormalFormNPM"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -PrintNPList([p1,p2]); -# - -# Consider also the following two vectors in NPM format. -# -v1 := [[[-1,1,2],[-1]],[1,-1]];; -v2 := [[[-2,2,2],[-2]],[1,-2]];; -PrintNPList([v1,v2]); -# - -# The Gröbner basis record for this data is found by -# : -# -GBR := SGrobnerModule([v1,v2],[p1,p2]);; -PrintNPList(GBR.ts); -PrintNPList(GBR.p); -# - -# The vector w is brought into strong normal form -# with respect to GBR: -# -w := [[[-1,2],[-2,1]],[1,-4]];; -PrintNP(w); -v := StrongNormalFormNPM(w,GBR);; -PrintNP(v); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-SGrobnerModule"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-2]];; -p2 := [[[1,2,2],[]],[1,-3]];; -# - -# Consider also the following two vectors in NPM format. -# -v1 := [[[-1,1,2],[-1]],[1,-1]];; -v2 := [[[-2,2,2],[-2]],[1,-2]];; -# - -# The Gröbner basis record for this data is found by -# : -# -GBR := SGrobnerModule([v1,v2],[p1,p2]);; -# - -# The record GBR has two fields, p for prefix relations (vectors -# in the module) -# and ts for two-sided relations (polynomials in the algebra): -# -PrintNPList(GBR.p); -PrintNPList(GBR.ts); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-MulQM"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[1,2,2],[]],[1,-1]];; -PrintNPList([p1,p2]); -# - -# Consider also the following two vectors in NPM format. -# -v1 := [[[-1,1,2],[-1]],[1,-1]];; -v2 := [[[-2,2,2],[-2]],[1,-2]];; -PrintNPList([v1,v2]); -# - -# The Gröbner basis record for this data is found by -# : -# -GBR := SGrobnerModule([v1,v2],[p1,p2]);; -PrintNPList(GBR.ts); -PrintNPList(GBR.p); -# - - -# The function MulQM computes the product of the -# vector w with the polynomial q. -# -w := [[[-1,2],[-2,1]],[1,-4]];; -PrintNP(w); -q := [[[2,2,1],[1]],[2,3]];; -PrintNP(q); -wq := MulQM(w,q,GBR);; -PrintNP(wq); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-BaseQM"> -# Example: -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,1,2],[]],[1,-1]];; -p2 := [[[2,2,2,1],[]],[1,-1]];; -# - - - -# Consider also the following two vectors in NPM format. -# -v1 := [[[-1,1,2],[-1]],[1,-1]];; -v2 := [[[-2,2,2],[-2]],[1,-2]];; -# - -# The Gröbner basis record for this data is found by -# : -# -GBR := SGrobnerModule([v1,v2],[p1,p2]);; -PrintNPList(GBR.ts); -PrintNPList(GBR.p); -# - - - -# The function BaseQM computes a basis. -# -B := BaseQM(GBR,2,2,0);; -PrintNPList(B); -# - -# The function BaseQM with arguments so as to let the -# number of dimensions of the module and the number of variables be chosen minimal. -# -B := BaseQM(GBR,0,0,0);; -PrintNPList(B); -# - -# The function BaseQM can also be used to ompute the first three elements of a basis. -# -B := BaseQM(GBR,2,2,3);; -PrintNPList(B); -# - - -# <#/GAPDoc> - -# <#GAPDoc Label="example-DimQM"> -# Example: - - -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,1,2],[]],[1,-1]];; -p2 := [[[2,2,2,1],[]],[1,-1]];; -# - - - -# Consider also the following two vectors in NPM format. -# -v1 := [[[-1,1,2],[-2]],[1,-1]];; -v2 := [[[-2,2,2],[-1]],[1,-2]];; -# - -# The Gröbner basis record for this data is found by -# : -# -GBR := SGrobnerModule([v1,v2],[p1,p2]);; -# - - -# The function DimQM 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 v1, v2, -# [p,q], where p and q run over all elements of -# the two-sided ideal in the free algebra generated by p1 and p2. -# -SetInfoLevel(InfoGBNP,2); -DimQM(GBR,2,2); -# - -# The answer should be equal to the size of BaseQM(GBR,t,mt,0). - -# -DimQM(GBR,2,2) = Length(BaseQM(GBR,2,2,0)); -SetInfoLevel(InfoGBNP,0); -# -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-MatrixQA"> -# Example: - -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,1,2],[]],[1,-1]];; -p2 := [[[2,2,2,1],[]],[1,-1]];; -# - -# The matrix of right multiplication by the first indeterminate a -# on the quotient algebra with respect to the ideal generated by -# p1 and p2 is obtained by applying MatrixQA -# to the Gröbner basis of these generators and a basis of the quotient -# algebra as found in -# : -# -GB := Grobner([p1,p2]);; -B := BaseQA(GB,2,0);; -PrintNPList(B); -Display(MatrixQA(1, B,GB)); -# - -# The function is also applicable to Gröbner basis records for -# modules. Consider the following two vectors. -# -v1 := [[[-1,1,2],[-1]],[1,-1]];; -v2 := [[[-2,2,2],[-2]],[1,-2]];; -# - -# The Gröbner basis record for this data is found by -# and a quotient module basis -# by : -# -GBR := SGrobnerModule([v1,v2],[p1,p2]);; -B := BaseQM(GBR,2,2,0);; -# - -# The matrix of right multiplication by a, the first generator -# of the free algebra, is -# -Display(MatrixQA(1,B,GBR)); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-MatricesQA"> -# Example: - -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,1,2],[]],[1,-1]];; -p2 := [[[2,2,2,1],[]],[1,-1]];; -# - -# The function MatricesQA gives the list of matrices -# found by -# when the first argument takes the integer values -# between 1 and the number of all algebra generators. - -# -GB := Grobner([p1,p2]);; -B := BaseQA(GB,2,0);; -mats := MatricesQA(2,B,GB);; -for mat in mats do Display(mat); Print("\n"); od; -# - -# The result is also obtainable by use of the List function: -# -MatricesQA(2,B,GB) = List([1,2], q -> MatrixQA(q,B,GB)); -# - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-MatrixQAC"> -# Example: - -# Consider the following two polynomials in NP format. -# -F := GF(256); -z := GeneratorsOfField(F)[1]; -p1 := [[[1,1,1,2],[]],[z,1]];; -p2 := [[[2,2,2,1],[]],[1,z]];; -# - -# The polynomials p1 and p2 have coefficients in -# the field F of order 256. -# The matrix of right multiplication by the first indeterminate a -# on the quotient algebra is obtained by applying MatrixQAC -# just like . The difference is -# that the result is in another format. -# -GB := Grobner([p1,p2]); -B := BaseQA(GB,2,0); -MatrixQAC(1, B,GB); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-MatricesQAC"> -# Example: - -# Consider the following two polynomials in NP format. -# -F := GF(256); -z := GeneratorsOfField(F)[1]; -p1 := [[[1,1,1,2],[]],[z,1]];; -p2 := [[[2,2,2,1],[]],[1,z]];; -# - -# The polynomials p1 and p2 have coefficients in -# the field F of order 256. -# The matrices of right multiplication by the indeterminates -# on the quotient algebra are just like for -# except for the format of the result. -# -GB := Grobner([p1,p2]); -B := BaseQA(GB,2,0); -MatricesQAC(2,B,GB); -# - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-PreprocessAnalysisQA"> -# Example: - -# Consider the following two polynomials in NP format of which a Gröbner -# basis is computed. -# -# F := GF(256); -# z := GeneratorsOfField(F)[1]; -p1 := [[[1,1,1,1,2],[]],[1,-1]];; -p2 := [[[2,2,2,1,1,1],[]],[1,-1]];; -GB := Grobner([p1,p2]);; -PrintNPList(GB); -# - -# Application of PreprocessAnalysisQA is carried out on the leading terms of -# GB, with 2, 4, 8, recursions, respectively. -# -L := LMonsNP(GB); -L1 := PreprocessAnalysisQA(L,2,2); -L2 := PreprocessAnalysisQA(L1,2,4); -# - -# <#/GAPDoc> - - - - -# <#GAPDoc Label="example-EvalTrace"> -# Example: - - -# First we compute the -# traced Gröbner basis -# of the list of the -# following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[2,2,1],[]],[1,-1]];; -Lnp := [p1,p2];; -GBT := SGrobnerTrace(Lnp);; -# - -# In order to check that the polynomials in GBT belong to the ideal -# generated by p1 and p2, we evaluate the trace. -# For each traced polynomial p in GBT, -# the polynomial p.pol is equated to the evaluated expression -# p.trace, -# in which each occurrence of G(i) is replaced by Lnp[i] -# by use of . - -# -ForAll(GBT,q -> EvalTrace(q,Lnp) = q.pol); -# - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-SGrobnerTrace"> -# Example: - -# For the list of the -# following two polynomials in NP format, a traced Gröbner -# basis is computed. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[2,2,1],[]],[1,-1]];; -GBT := SGrobnerTrace([p1,p2]); -# - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-StrongNormalFormTraceDiff"> -# Example: - -# First we compute the -# traced Gröbner basis -# of the list of the -# following two polynomials in NP format. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[2,2,1],[]],[1,-1]];; -GBT := SGrobnerTrace([p1,p2]);; -# - - -# Of the polynomial a^6 we compute its -# difference with the normal form. -# The result is printed by used of -# and . -# -f := [[[1,1,1,1,1,1]],[1]];; -sf := StrongNormalFormTraceDiff(f,GBT);; -PrintNP(sf.pol); -PrintTraceList([sf]); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-SGrobnerTrunc"> -# Example: - -# Consider the -# following two polynomials in NP format. -# -p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];; -p2 := [[[2,2,2],[1,1]],[1,-1]];; -PrintNPList([p1,p2]); -# - - -# These are homogeneous with respect to weights [3,2]. -# The degrees are 10 and 6, respectively. -# The Gröbner basis truncated above degree 12 of the list [p1,p2] -# is computed and subsequently printed as follows. - -# -PrintNPList(SGrobnerTrunc([p1,p2],12,[3,2])); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-CheckHomogeneousNPs"> -# Example: - -# Consider the -# following two polynomials in NP format. -# -p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];; -p2 := [[[2,2,2],[1,1]],[1,-1]];; -PrintNPList([p1,p2]); -# - - -# These are homogeneous with respect to weights [3,2]. -# The degrees are 10 and 6, respectively. -# This is checked as follows. - -# -CheckHomogeneousNPs([p1,p2],[3,2]); -# - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-BaseQATrunc"> -# Example: - -# Consider the truncated Gröbner basis -# of the following two polynomials in NP format. -# -p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];; -p2 := [[[2,2,2],[1,1]],[1,-1]];; -wtv := [3,2];; -GB := SGrobnerTrunc([p1,p2],12,wtv);; -GBNP.ConfigPrint("a","b"); -PrintNPList(GB); -# - - -# A basis of standard monomials is found and printed as follows. - -# -BT := BaseQATrunc(GB,12,wtv);; -for degpart in BT do - for mon in degpart do PrintNP([[mon],[1]]); od; -od; -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-DimsQATrunc"> -# Example: - -# Consider the truncated Gröbner basis -# of the following two polynomials in NP format. -# -p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];; -p2 := [[[2,2,2],[1,1]],[1,-1]];; -wtv := [3,2];; -GB := SGrobnerTrunc([p1,p2],12,wtv);; -# - - -# Information on the dimensions of the homogeneous parts -# of the quotient algebra is found as follows, - -# -DimsQATrunc(GB,12,wtv); -# - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-FreqsQATrunc"> -# Example: - -# Consider the truncated Gröbner basis -# of the following two polynomials in NP format. -# -p1 := [[[1,2,2,1],[2,1,1,2]],[1,-1]];; -p2 := [[[2,2,2],[1,1]],[1,-1]];; -wtv := [3,2];; -GB := SGrobnerTrunc([p1,p2],12,wtv);; -PrintNPList(GB); -# - - -# The multiplicities of the frequencies of -# of monomials in a standard basis -# of the quotient algebra with respect to the ideal generated by -# GB is found as follows, for weights up to and including 8. - -# -F := FreqsQATrunc(GB,8,wtv); -# - -# The interpretation of this data is given by the following lines of code. - -# -for f in F do - if f[1][1] <> [] then - Print("At level ", wtv * (f[1][1]), " the multiplicities are\n"); - for x in f do - Print(" for ",x[1],": ",x[2],"\n"); - od; - else - Print("At level ", 0 , " the multiplicity of [] is ",f[1][2],"\n"); - fi; - Print("\n"); -od; -# - - -# <#/GAPDoc> - - - - -# <#GAPDoc Label="example-PrintTraceList"> -# Example: - -# 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 PrintTraceList. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[2,2,1],[]],[1,-1]];; -GBT := SGrobnerTrace([p1,p2]);; -PrintTraceList(GBT); -# -# <#/GAPDoc> - - - - - -# <#GAPDoc Label="example-PrintTracePol"> -# Example: - -# 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 PrintTracePol. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[2,2,1],[]],[1,-1]];; -GBT := SGrobnerTrace([p1,p2]);; -for np in GBT do PrintTracePol(np); Print("\n"); od; -# -# <#/GAPDoc> - - -# <#GAPDoc Label="example-PrintNPListTrace"> -# Example: - -# 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 PrintNPListTrace. -# -p1 := [[[1,1,2],[]],[1,-1]];; -p2 := [[[2,2,1],[]],[1,-1]];; -GBT := SGrobnerTrace([p1,p2]);; -PrintNPListTrace(GBT); -# -# <#/GAPDoc> - - - - - -# <#GAPDoc Label="example-DetermineGrowthQA"> -# Example: - -# 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 DetermineGrowthQA with arguments -# [[1]] -# (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 true indicating that we wish a precise degree -# in case of polynomial growth. - - -# -DetermineGrowthQA([[1]],2,true); -# - -# Here is an example of polynomial growth of degree 2: - - -# -L := [[1,2,1],[2,2,1]]; -DetermineGrowthQA(L,2,true); -# - - -# In order to show how to apply the function -# to arbitrary polynomials, consider -# the following two polynomials in NP format. - -# -F := GF(256); -z := GeneratorsOfField(F)[1]; -p1 := [[[1,1,1,2],[]],[z,1]];; -p2 := [[[2,2,2,1],[]],[1,z]];; -# - -# The polynomials p1 and p2 have coefficients in -# the field F 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 -# DetermineGrowthQA. - -# -GB := Grobner([p1,p2]);; -L := LMonsNP(GB);; -for lm in L do PrintNP( [ [ lm ], [ 1 ] ] ); od; -DetermineGrowthQA(L,2,true); -# - - -# <#/GAPDoc> - - - -# <#GAPDoc Label="example-FinCheckQA"> -# Example: - -# Consider the following list L of two monomials. -# -L := [[1,2,1],[2,2,1]];; -# - -# Finiteness 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 FinCheckQA. -# Its arguments are L and the number of generators of the free algebra -# in which the monomials reside. - -# -FinCheckQA(L,2); -# - -# This example turns out to be infinite dimensional. -# Here is a finite-dimensional example. - -# -FinCheckQA([[1],[2,2]],2); -# - - - -# <#/GAPDoc> - - -# <#GAPDoc Label="example-HilbertSeriesQA"> -# Example: - -# Consider the following list L of two monomials. -# -L := [[1,2,1],[2,2,1]];; -# - -# Finiteness 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 FinCheckQA. -# Its arguments are L and the number of generators of the free algebra -# in which the monomials reside. - -# -HilbertSeriesQA(L,2,10); -# - - -# This indicates that the growth may be polynomial. -# can be used to check this. - -# <#/GAPDoc> - -# reset printing; note not inside a GAPDoc part here -# -GBNP.ConfigPrint(); -# - -# <#GAPDoc Label="example-NumAlgGensNP"> -# Example: - -# Consider the following polynomial in NP format. -# -np := [[[2,2,2,1,1,1],[4],[3,2,3]],[1,-3,2]];; -PrintNP(np); -NumAlgGensNP(np); -# -# <#/GAPDoc> - -# <#GAPDoc Label="example-NumAlgGensNPList"> -# Example: - -# Consider the following two polynomials in NP format. -# -p1 := [[[1,1,2,3,1],[2],[1]],[1,-2,1]];; -p2 := [[[2,2,1,4,3],[]],[1,-1]];; -PrintNPList([p1,p2]); -NumAlgGensNPList([p1,p2]); -# -# <#/GAPDoc> - - -# <#GAPDoc Label="example-NumModGensNP"> -# Example: - -# Consider the following polynomial in NPM format. -# -np := [[[-1,1,2,3,1],[-2],[-1]],[1,-2,1]];; -PrintNP(np); -NumModGensNP(np); -# -# <#/GAPDoc> - - -# <#GAPDoc Label="example-NumModGensNPList"> -# Example: - -# Consider the following two polynomials in NPM format. -# -v1 := [[[-1,1,2,3,1],[-2],[-1]],[1,-2,1]];; -v2 := [[[-2,2,1,4,3],[-3]],[1,-1]];; -PrintNPList([v1,v2]); -NumModGensNPList([v1,v2]); -# -# <#/GAPDoc> From 935491b5b4de5a09d1278f25beca6d06ecefcce6 Mon Sep 17 00:00:00 2001 From: Chris Wensley Date: Mon, 25 Sep 2023 15:45:23 +0100 Subject: [PATCH 2/4] Add GBNP.Config commands to tests so they can be run in any order (#31) --- tst/test02.tst | 2 ++ tst/test06.tst | 2 ++ tst/test10.tst | 2 ++ tst/test12.tst | 2 ++ tst/test16.tst | 2 ++ tst/test24.tst | 2 ++ tst/test25.tst | 2 ++ 7 files changed, 14 insertions(+) diff --git a/tst/test02.tst b/tst/test02.tst index 20bd562..4b3f705 100644 --- a/tst/test02.tst +++ b/tst/test02.tst @@ -85,6 +85,8 @@ gap> gap> I := Concatenation([s1,s2],MkTrLst(n));; gap> # gap> +gap> # add the next command in case other tests have changed the alphabet: +gap> GBNP.ConfigPrint("a","b","c"); gap> # To give an impression, we print the first 20 entries of this list: gap> # gap> PrintNPList(I{[1..20]}); diff --git a/tst/test06.tst b/tst/test06.tst index 3e66be2..2216253 100644 --- a/tst/test06.tst +++ b/tst/test06.tst @@ -110,6 +110,8 @@ gap> for i in [1..5] do > od; gap> # gap> +gap> # add the next command in case other tests have changed the alphabet: +gap> GBNP.ConfigPrint("a","b","c","d","e","f"); gap> # The relations can be shown with : gap> gap> # diff --git a/tst/test10.tst b/tst/test10.tst index e8477fa..e9cad36 100644 --- a/tst/test10.tst +++ b/tst/test10.tst @@ -101,6 +101,8 @@ gap> GB := SGrobner(KI);; #I End of phase II #I End of phase III #I End of phase IV +gap> # add the next command in case other tests have changed the alphabet: +gap> GBNP.ConfigPrint("a","b","c","d","e","f","g"); gap> PrintNPList(GB); a b diff --git a/tst/test12.tst b/tst/test12.tst index 243980a..2199805 100644 --- a/tst/test12.tst +++ b/tst/test12.tst @@ -59,6 +59,8 @@ gap> # function and can be subsequently gap> # displayed with . gap> gap> # +gap> # add the next command in case other tests have changed the alphabet: +gap> GBNP.ConfigPrint("a","b","c"); gap> uerelsNP:=GP2NPList(uerels);; gap> PrintNPList(uerelsNP); ba - ab + c diff --git a/tst/test16.tst b/tst/test16.tst index 78d9e58..7df4657 100644 --- a/tst/test16.tst +++ b/tst/test16.tst @@ -107,6 +107,8 @@ gap> # gap> gap> # The relations can be shown with : gap> +gap> # add the next command in case other tests have changed the alphabet: +gap> GBNP.ConfigPrint("a","b","c","d","e","f"); gap> # gap> PrintNPList(KI); ea diff --git a/tst/test24.tst b/tst/test24.tst index 030c835..e6397b0 100644 --- a/tst/test24.tst +++ b/tst/test24.tst @@ -53,6 +53,8 @@ gap> KI := [ [[[2,1],[1,1,2]],[1,-1]], > [[[3,6], []],[1,-1]], > [[[6,3], []],[1,-1]], > ];; +gap> # add the next command in case other tests have changed the alphabet: +gap> GBNP.ConfigPrint("a","b","c","d","e","f"); gap> PrintNPList(KI); ba - a^2b cb - b^2c diff --git a/tst/test25.tst b/tst/test25.tst index f2f933a..db7d6d4 100644 --- a/tst/test25.tst +++ b/tst/test25.tst @@ -103,6 +103,8 @@ gap> # using gap> # and determine the minimal polynomial of the sum of the three matrices. gap> gap> # +gap> # add the next command in case other tests have changed the alphabet: +gap> GBNP.ConfigPrint("x"); gap> B := BaseQA(GB,3,0);; gap> M := MatricesQA(3,B,GB);; gap> f := MinimalPolynomial(Rationals,M[1]+M[2]+M[3]); From 8f4dc7a91521846f2bee3a632bc1af277d8dd7d0 Mon Sep 17 00:00:00 2001 From: Chris Wensley Date: Mon, 2 Oct 2023 10:46:16 +0100 Subject: [PATCH 3/4] the NMO manual is now chapter 5 in the GBNP manual (#33) --- doc/gbnp_doc.bib | 19 +++ doc/{nmo/nmo_doc.xml => nmo.xml} | 226 +++++++++++++++++-------------- doc/nmo/nmo_doc.bib | 18 --- lib/occurtree.gi | 2 +- makedoc.g | 4 +- tst/nmo.g | 202 +++++++++++++++++++++++++++ 6 files changed, 352 insertions(+), 119 deletions(-) rename doc/{nmo/nmo_doc.xml => nmo.xml} (75%) delete mode 100644 doc/nmo/nmo_doc.bib create mode 100644 tst/nmo.g diff --git a/doc/gbnp_doc.bib b/doc/gbnp_doc.bib index e153753..de17510 100644 --- a/doc/gbnp_doc.bib +++ b/doc/gbnp_doc.bib @@ -235,3 +235,22 @@ @book{MR1954121 MRCLASS = {20E08 (05C05 20E06 20G25)}, MRNUMBER = {MR1954121 (2003m:20032)}, } + +@Book{CLO97, + AUTHOR = {Cox, David and Little, John and O'Shea, Donal}, + TITLE = {Ideals, varieties, and algorithms}, + SERIES = {Undergraduate Texts in Mathematics}, + EDITION = {Second}, + NOTE = {An introduction to computational algebraic geometry and + commutative algebra}, + PUBLISHER = {Springer-Verlag}, + ADDRESS = {New York}, + YEAR = {1997} +} + +@book{gN02, +author = "Gonzalo Navarro and Mathieu Raffinot", +title = "Flexible Pattern Matching in Strings", +publisher = "Cambridge University Press", +year = "2002" +} diff --git a/doc/nmo/nmo_doc.xml b/doc/nmo.xml similarity index 75% rename from doc/nmo/nmo_doc.xml rename to doc/nmo.xml index 6df3675..4001d8d 100644 --- a/doc/nmo/nmo_doc.xml +++ b/doc/nmo.xml @@ -1,26 +1,35 @@ - - - Documentation on the <Package>NMO</Package> package - Version 1.0 - Randall E. Cone rcone@math.vt.edu - 7 January 2010 -
Virginia Tech
- Blacksburg, VA, 24060, USA
- - - Our immense gratitude to the authors of GBNP for allowing us to make a small contribution. - Equal gratitude to Dr. Ed Green for his help as mentor and advisor, - in both this project and many others. - - -
- - - - - -NMO -
Introduction + + + + + + + + + + + + + + + + + + + + + + +NMO Manual + +
+Introduction + +Up until September 2023 the NMO manual was provided by +GBNP as a separate manual.pdf. +The NMO manual now forms this chapter +in the GBNP manual. +

What follows is a description of the largely experimental project of providing arbitrary monomial orderings to the GBNP package. @@ -72,7 +81,20 @@ are related to attributes of monomial orderings. Many examples of basic code use are provided; with some examples following the reference material for the functions or -methods involved. +methods involved. +

+ +Acknowledgements + + +Our immense gratitude to the authors of GBNP +for allowing us to make a small contribution. + + +Equal gratitude to Dr. Ed Green for his help as mentor and advisor, +in both this project and many others. + +

@@ -145,8 +167,12 @@ as Example 2.7 there; please see for more informa Load the GBNP package with: -gap> LoadPackage("gbnp"); +gap> LoadPackage("gbnp", false); true +gap> # remove any previous orderings +gap> UnpatchGBNP(); +LtNP restored +GtNP restored Create a noncommutative free algebra on 4 generators over the @@ -165,11 +191,11 @@ gap> a := A.a; b := A.b; c := A.c; d := A.d; (1)*d -Set up our polynomials, and convert them to GBNP NP format: +Set up our polynomials, and convert them to NP format: -gap> polys := [c*d*a*b-c*b,b*c-d*a]; +gap> polys := [c*d*a*b-c*b, b*c-d*a]; [ (-1)*c*b+(1)*c*d*a*b, (1)*b*c+(-1)*d*a ] -gap> reps := GP2NPList(polys); +gap> reps := GP2NPList( polys ); [ [ [ [ 3, 4, 1, 2 ], [ 3, 2 ] ], [ 1, -1 ] ], [ [ [ 4, 1 ], [ 2, 3 ] ], [ -1, 1 ] ] ] @@ -178,12 +204,12 @@ Compute the Gröbner basis via GBNP using its default (length left-lexicographic) ordering; that is, without patching GBNP with an NMO ordering: -gap> gbreps := Grobner(reps);; -gap> gb := NP2GPList(gbreps,A); -[ (1)*d*a+(-1)*b*c, (1)*c*b*c*b+(-1)*c*b ] +gap> gbreps := Grobner( reps );; +gap> gb := NP2GPList( gbreps, A ); +[ (1)*d*a+(-1)*b*c, (1)*(c*b)^2+(-1)*c*b ] -Create length left-lexicographic ordering, with generators +Create a (length left-lexicographic ordering, with generators ordered: a < b < c < d. Note: this is the default ordering of generators by NMO, if none is provided: @@ -194,18 +220,18 @@ NCMonomialLeftLengthLexicographicOrdering([ (1)*a, (1)*b, (1)*c, (1)*d ]) Patch GBNP with the ordering ml, and then run the same example. We should get the same answer as above: -gap> PatchGBNP(ml); +gap> PatchGBNP( ml ); LtNP patched. GtNP patched. -gap> gbreps := Grobner(reps);; -gap> gb := NP2GPList(gbreps,A); -[ (1)*d*a+(-1)*b*c, (1)*c*b*c*b+(-1)*c*b ] +gap> gbreps := Grobner( reps );; +gap> gb := NP2GPList( gbreps, A ); +[ (1)*d*a+(-1)*b*c, (1)*(c*b)^2+(-1)*c*b ] -Create a Length-Lexicographic ordering on the generators such that +Now create a Length-Lexicographic ordering on the generators such that d < c < b < a: -gap> ml2 := NCMonomialLeftLengthLexOrdering(A,[4,3,2,1]); +gap> ml2 := NCMonomialLeftLengthLexOrdering( A, [4,3,2,1] ); NCMonomialLeftLengthLexicographicOrdering([ (1)*d, (1)*c, (1)*b, (1)*a ]) @@ -215,10 +241,10 @@ on the same algebra: gap> PatchGBNP(ml2); LtNP patched. GtNP patched. -gap> gbreps2 := SGrobner(reps);; -gap> gb2 := NP2GPList(gbreps2,A); -[ (1)*b*c+(-1)*d*a, (1)*c*d*a*b+(-1)*c*b, (1)*d*a*d*a*b+(-1)*d*a*b, - (1)*c*d*a*d*a+(-1)*c*d*a, (1)*d*a*d*a*d*a+(-1)*d*a*d*a ] +gap> gbreps2 := SGrobner( reps );; +gap> gb2 := NP2GPList( gbreps2, A ); +[ (1)*b*c+(-1)*d*a, (1)*c*d*a*b+(-1)*c*b, (1)*(d*a)^2*b+(-1)*d*a*b, + (1)*c*(d*a)^2+(-1)*c*d*a, (1)*(d*a)^3+(-1)*(d*a)^2 ] @@ -227,56 +253,59 @@ gap> gb2 := NP2GPList(gbreps2,A); This example is the same as Example 1 above, except that the length and left-lexicographic orderings are created independently and then chained to form the usual length left-lexicographic ordering. Hence, -all results should be the same. Note: we assume from this point forward -in all further examples that GBNP is loaded. +all results should be the same.

+Remove any previous orderings. Create a noncommutative free algebra on 4 generators over the Rationals, label, and set up the example: +gap> UnpatchGBNP(); +LtNP restored +GtNP restored gap> A := FreeAssociativeAlgebraWithOne(Rationals,"a","b","c","d");; gap> a := A.a;; b := A.b;; c := A.c;; d := A.d;; -gap> polys := [c*d*a*b-c*b,b*c-d*a];; -gap> reps := GP2NPList(polys);; +gap> polys := [ c*d*a*b-c*b, b*c-d*a ];; +gap> reps := GP2NPList( polys );; Create left-lexicographic ordering with a < b < c < d: -gap> lexord := NCMonomialLeftLexicographicOrdering(A); +gap> lexord := NCMonomialLeftLexicographicOrdering( A ); NCMonomialLeftLexicographicOrdering([ (1)*a, (1)*b, (1)*c, (1)*d ]) -Create a length ordering on monomials in A, with ties broken by the -lexicographic order lexord: +Create a length ordering on monomials in A, +with ties broken by the lexicographic order lexord: -gap> lenlex := NCMonomialLengthOrdering(A,lexord); +gap> lenlex := NCMonomialLengthOrdering( A, lexord ); NCMonomialLengthOrdering([ (1)*a, (1)*b, (1)*c, (1)*d ]) Patch GBNP and proceed with our example: -gap> PatchGBNP(lenlex);; +gap> PatchGBNP( lenlex );; LtNP patched. GtNP patched. -gap> gbreps := Grobner(reps);; -gap> gb := NP2GPList(gbreps,A); -[ (1)*d*a+(-1)*b*c, (1)*c*b*c*b+(-1)*c*b ] +gap> gbreps := Grobner( reps );; +gap> gb := NP2GPList( gbreps, A ); +[ (1)*d*a+(-1)*b*c, (1)*(c*b)^2+(-1)*c*b ] Now, proceed similarly, with the lexicographic order such that d < c < b < a: -gap> lexord2 := NCMonomialLeftLexicographicOrdering(A,[4,3,2,1]); +gap> lexord2 := NCMonomialLeftLexicographicOrdering( A, [4,3,2,1] ); NCMonomialLeftLexicographicOrdering([ (1)*d, (1)*c, (1)*b, (1)*a ]) -gap> lenlex2 := NCMonomialLengthOrdering(A,lexord2); +gap> lenlex2 := NCMonomialLengthOrdering( A, lexord2 ); NCMonomialLengthOrdering([ (1)*a, (1)*b, (1)*c, (1)*d ]) -gap> PatchGBNP(lenlex2);; +gap> PatchGBNP( lenlex2 );; LtNP patched. GtNP patched. -gap> gbreps2 := Grobner(reps);; -gap> gb2 := NP2GPList(gbreps2,A); -[ (1)*b*c+(-1)*d*a, (1)*c*d*a*b+(-1)*c*b, (1)*d*a*d*a*b+(-1)*d*a*b, - (1)*c*d*a*d*a+(-1)*c*d*a, (1)*d*a*d*a*d*a+(-1)*d*a*d*a ] +gap> gbreps2 := Grobner( reps );; +gap> gb2 := NP2GPList( gbreps2, A ); +[ (1)*b*c+(-1)*d*a, (1)*c*d*a*b+(-1)*c*b, (1)*(d*a)^2*b+(-1)*d*a*b, + (1)*c*(d*a)^2+(-1)*c*d*a, (1)*(d*a)^3+(-1)*(d*a)^2 ] An important point can be made here. Notice that when the lenlex2 @@ -287,11 +316,11 @@ orderings, and in the case of the length order, it is not used. Only the lex table for lexord2 is ever used. Some clarification may be provided in examining: -gap> HasNextOrdering(lenlex2); +gap> HasNextOrdering( lenlex2 ); true -gap> NextOrdering(lenlex2); +gap> NextOrdering( lenlex2 ); NCMonomialLeftLexicographicOrdering([ (1)*d, (1)*c, (1)*b, (1)*a ]) -gap> LexicographicTable(NextOrdering(lenlex2)); +gap> LexicographicTable( NextOrdering( lenlex2 ) ); [ (1)*d, (1)*c, (1)*b, (1)*a ] @@ -303,16 +332,20 @@ Example 3 is taken from the book Ideals, Varieties, and Algorithms, (, Example 2, p. 93-94); it is a commutative example.

-First, we set up the problem and find a Gröbner basis with respect to the length -left-lexicographic ordering implicitly assumed in GBNP: +First, set up the problem and find a Gröbner basis with respect to the length +left-lexicographic ordering implicitly assumed in GBNP, +after removing any previous orderings: -gap> A := FreeAssociativeAlgebraWithOne(Rationals,"x","y","z");; -gap> x := A.x;; y := A.y;; z := A.z;; id := One(A);; -gap> polys := [ x^2 + y^2 + z^2 - id, x^2 + z^2 - y, x-z, -> x*y-y*x, x*z-z*x, y*z-z*y];; -gap> reps := GP2NPList(polys);; -gap> gb := Grobner(reps);; -gap> NP2GPList(gb,A); +gap> UnpatchGBNP(); +LtNP restored. +GtNP restored. +gap> A3 := FreeAssociativeAlgebraWithOne( Rationals, "x", "y", "z" );; +gap> x := A3.x;; y := A3.y;; z := A3.z;; id := One(A3);; +gap> polys3 := [ x^2 + y^2 + z^2 - id, x^2 + z^2 - y, x-z, +> x*y-y*x, x*z-z*x, y*z-z*y ];; +gap> reps3 := GP2NPList( polys3 );; +gap> gb3 := Grobner( reps3 );; +gap> NP2GPList( gb3, A3 ); [ (1)*z+(-1)*x, (1)*x^2+(-1/2)*y, (1)*y*x+(-1)*x*y, (1)*y^2+(2)*x^2+(-1)*<identity ...> ] @@ -321,13 +354,13 @@ The example, as presented in the book, uses a left-lexicographic ordering with z < y < x. We create the ordering in NMO, patch GBNP, and get the result expected: -gap> ml := NCMonomialLeftLexicographicOrdering(A,[3,2,1]); +gap> ml3 := NCMonomialLeftLexicographicOrdering( A3, [3,2,1] ); NCMonomialLeftLexicographicOrdering([ (1)*z, (1)*y, (1)*x ]) -gap> PatchGBNP(ml); +gap> PatchGBNP( ml3 ); LtNP patched. GtNP patched. -gap> gb := Grobner(reps);; -gap> NP2GPList(gb,A); +gap> gb3 := Grobner( reps3 );; +gap> NP2GPList( gb3, A3 ); [ (1)*z^4+(1/2)*z^2+(-1/4)*<identity ...>, (1)*y+(-2)*z^2, (1)*x+(-1)*z ] @@ -343,40 +376,42 @@ it also appears as Example 6 in the GBNP example set. A noncommutative free algebra on 6 generators over the Rationals is created in GAP, and the generators are labeled: -gap> A := FreeAssociativeAlgebraWithOne(Rationals,"a","b","c","d","e","f");; -gap> a := A.a;; b := A.b;; c := A.c;; d := A.d;; e := A.e;; f := A.f;; +gap> UnpatchGBNP(); +LtNP restored. +GtNP restored. +gap> A4 := FreeAssociativeAlgebraWithOne(Rationals,"a","b","c","d","e","f");; +gap> a := A4.a;; b := A4.b;; c := A4.c;; d := A4.d;; e := A4.e;; f := A4.f;; Set up list of noncommutative polynomials: -gap> polys := [ e*a, a^3 + f*a, a^9 + c*a^3, a^81 + c*a^9 + d*a^3, -> a^27 + d*a^81 + e*a^9 + f*a^3, b + c*a^27 + e*a^81 + f*a^9, -> c*b + d*a^27 + f*a^81, a + d*b + e*a^27, c*a + e*b + f*a^27, -> d*a + f*b, b^3 - b, a*b - b*a, a*c - c*a, a*d - d*a, -> a*e - e*a, a*f - f*a, b*c - c*b, b*d - d*b, b*e - e*b, -> b*f - f*b, c*d - d*c, c*e - e*c, c*f - f*c, d*e - e*d, -> d*f - f*d, e*f - f*e -> ];; -gap> reps := GP2NPList(polys);; +gap> polys4 := [ e*a, a^3 + f*a, a^9 + c*a^3, a^81 + c*a^9 + d*a^3, +> a^27 + d*a^81 + e*a^9 + f*a^3, b + c*a^27 + e*a^81 + f*a^9, +> c*b + d*a^27 + f*a^81, a + d*b + e*a^27, c*a + e*b + f*a^27, +> d*a + f*b, b^3 - b, a*b - b*a, a*c - c*a, a*d - d*a, +> a*e - e*a, a*f - f*a, b*c - c*b, b*d - d*b, b*e - e*b, +> b*f - f*b, c*d - d*c, c*e - e*c, c*f - f*c, d*e - e*d, +> d*f - f*d, e*f - f*e ];; +gap> reps4 := GP2NPList( polys4 );; Create a length left-lex ordering with the following (default) ordering on the generators a < b < c < d < e < f: -gap> ml := NCMonomialLeftLengthLexOrdering(A); +gap> ml4 := NCMonomialLeftLengthLexOrdering( A4 ); NCMonomialLeftLengthLexicographicOrdering([ (1)*a, (1)*b, (1)*c, (1)*d, (1)*e, (1)*f ]) Patch GBNP and compute the Gröbner basis with respect -to the ordering ml: +to the ordering ml4: -gap> PatchGBNP(ml); +gap> PatchGBNP( ml4 ); LtNP patched. GtNP patched. -gap> gb := Grobner(reps);; -gap> NP2GPList(gb,A); +gap> gb4 := Grobner( reps4 );; +gap> NP2GPList( gb4, A4 ); [ (1)*a, (1)*b, (1)*d*c+(-1)*c*d, (1)*e*c+(-1)*c*e, (1)*e*d+(-1)*d*e, (1)*f*c+(-1)*c*f, (1)*f*d+(-1)*d*f, (1)*f*e+(-1)*e*f ] @@ -533,10 +568,5 @@ gap> LexicographicTable(ml2);

-
- - - -
diff --git a/doc/nmo/nmo_doc.bib b/doc/nmo/nmo_doc.bib deleted file mode 100644 index a769775..0000000 --- a/doc/nmo/nmo_doc.bib +++ /dev/null @@ -1,18 +0,0 @@ -@Book{CLO97, - AUTHOR = {Cox, David and Little, John and O'Shea, Donal}, - TITLE = {Ideals, varieties, and algorithms}, - SERIES = {Undergraduate Texts in Mathematics}, - EDITION = {Second}, - NOTE = {An introduction to computational algebraic geometry and - commutative algebra}, - PUBLISHER = {Springer-Verlag}, - ADDRESS = {New York}, - YEAR = {1997} -} - -@book{gN02, -author = "Gonzalo Navarro and Mathieu Raffinot", -title = "Flexible Pattern Matching in Strings", -publisher = "Cambridge University Press", -year = "2002" -} diff --git a/lib/occurtree.gi b/lib/occurtree.gi index 1859bc7..89c88e7 100644 --- a/lib/occurtree.gi +++ b/lib/occurtree.gi @@ -121,7 +121,7 @@ end; ### GBNP.CreateOccurTreePTSLR:=function(L,pg,left) - if (pg <> GBNP.GetOptions().pg) then + if (pg <> GBNP.GetOptions().pg) then Info(InfoGBNP,2,"Warning: CreateOccurTreePTSLR: pg argument (",pg,") is not the same as pg option (",GBNP.GetOptions().pg,")\n"); fi; diff --git a/makedoc.g b/makedoc.g index 71c1969..f68ab1d 100644 --- a/makedoc.g +++ b/makedoc.g @@ -11,13 +11,13 @@ files := AUTODOC_FindMatchingFiles(DirectoryCurrent(), [ "doc/examples" ], [ "xm AutoDoc(rec( gapdoc := rec( - scan_dirs := [ "lib" ], + scan_dirs := [ "lib", "lib/nmo" ], files := files, ), #autodoc := rec( files := [ "doc/Intros.autodoc" ] ), scaffold := rec( bib := "gbnp_doc", - includes := [ "gbnp_doc.xml" ], + includes := [ "gbnp_doc.xml", "nmo.xml" ], appendix := [ "examples.xml" ], ), )); diff --git a/tst/nmo.g b/tst/nmo.g new file mode 100644 index 0000000..9efeaee --- /dev/null +++ b/tst/nmo.g @@ -0,0 +1,202 @@ +######################### BEGIN COPYRIGHT MESSAGE ######################### +# GBNP - computing Gröbner bases of noncommutative polynomials +# Copyright 2001-2010 by Arjeh M. Cohen, Dié A.H. Gijsbers, Jan Willem +# Knopper, Chris Krook. Address: Discrete Algebra and Geometry (DAM) group +# at the Department of Mathematics and Computer Science of Eindhoven +# University of Technology. +# +# For acknowledgements see the manual. The manual can be found in several +# formats in the doc subdirectory of the GBNP distribution. The +# acknowledgements formatted as text can be found in the file chap0.txt. +# +# GBNP is free software; you can redistribute it and/or modify it under +# the terms of the Lesser GNU General Public License as published by the +# Free Software Foundation (FSF); either version 2.1 of the License, or +# (at your option) any later version. For details, see the file 'LGPL' in +# the doc subdirectory of the GBNP distribution or see the FSF's own site: +# https://www.gnu.org/licenses/lgpl.html +########################## END COPYRIGHT MESSAGE ########################## + +# First load the gap package (before the example) + +LoadPackage("gbnp", false); + +# NMO Example 1 is taken from Dr. Edward Green's paper +# Noncommutative Gröbner Bases, and Projective Resolutions, +# and is referenced as Example 2.7 there; +# please see for more information. +# +Print( "starting NMO test 1:\n" ); +# remove any previous orderings +UnpatchGBNP(); +# Create a noncommutative free algebra on 4 gens over the Rationals +A := FreeAssociativeAlgebraWithOne(Rationals,"a","b","c","d"); +# Label the generators of the algebra: +a := A.a; b := A.b; c := A.c; d := A.d; +# Set up our polynomials, and convert them to NP format: +polys := [ c*d*a*b-c*b, b*c-d*a ]; + +Print( "polys = ", polys, "\n" ); +reps := GP2NPList( polys ); +Print( " reps = ", reps, "\n" ); + +# Compute the Gröbner basis via GBNP using its default +# (length left-lexicographic) ordering; that is, +# without patching GBNP with an NMO ordering: +gbreps := Grobner( reps );; + +Print( "gbreps = ", gbreps, "\n" ); +gb := NP2GPList( gbreps, A ); +Print( " gb = ", gb, "\n" ); + +# Create a length left-lexicographic ordering, +# with generators ordered: a < b < c < d. +# Note: this is the default ordering of generators by NMO, +# if none is provided: +ml := NCMonomialLeftLengthLexOrdering( A ); + +# Patch GBNP with the ordering ml, and then run the same example. +# We should get the same answer as above: +PatchGBNP( ml ); +gbreps := Grobner( reps );; +gb := NP2GPList( gbreps, A ); +Print( " gb = ", gb, "\n" ); + +# Now create a Length-Lexicographic ordering on the generators +# such that d < c < b < a +ml2 := NCMonomialLeftLengthLexOrdering( A, [4,3,2,1] ); + +# Compute the Gröbner basis w.r.t this new ordering on the same algebra: +PatchGBNP( ml2 ); +gbreps2 := SGrobner( reps );; +gb2 := NP2GPList( gbreps2, A ); +Print( " gb2 = ", gb2, "\n" ); + + +# NMO Example 2 is the same as Example 1 above, except that the length +# and left-lexicographic orderings are created independently and then +# chained to form the usual length left-lexicographic ordering. +# Hence, all results should be the same. +Print( "\nstarting NMO test 2:\n" ); +# remove any previous orderings +UnpatchGBNP(); +# Create a noncommutative free algebra on 4 generators over the +# Rationals, label, and set up the example: +A := FreeAssociativeAlgebraWithOne(Rationals,"a","b","c","d");; +a := A.a;; b := A.b;; c := A.c;; d := A.d;; +# revert to the default ordering +PatchGBNP( ml ); +polys := [ c*d*a*b-c*b, b*c-d*a ];; +reps := GP2NPList( polys );; + +Print( "in test 2, reps = ", reps, "\n" ); +Print( "and Grobner(reps) = ", Grobner(reps), "\n" ); + +# Create left-lexicographic ordering with a < b < c < d: +lexord := NCMonomialLeftLexicographicOrdering( A ); + +# Create a length ordering on monomials in A, +# with ties broken by the lexicographic order lexord: +lenlex := NCMonomialLengthOrdering( A, lexord ); + +# Patch GBNP and proceed with our example: +PatchGBNP( lenlex );; +gbreps := Grobner( reps );; + +Print( "gbreps = ", gbreps, "\n" ); + +gb := NP2GPList( gbreps, A ); + +Print( "gb = ", gb, "\n" ); + +# Now, proceed similarly, with the lexicographic order +# such that d < c < b < a: +lexord2 := NCMonomialLeftLexicographicOrdering( A, [4,3,2,1] ); +lenlex2 := NCMonomialLengthOrdering( A, lexord2 ); + +# not sure what the point is of printing out these functions +# so commenting them out for now +# GtNP1 := GtNP; +# Print( "*********************\n", GtNP, "\n**************************\n" ); +# PatchGBNP( lenlex2 );; +# Print( "*********************\n", GtNP, "\n**************************\n" ); +# GtNP2 := GtNP; +# Print( "GtNP1 = GtNP2 ? ", GtNP1 = GtNP2, "\n" ); + +gbreps2 := Grobner( reps );; +Print( "gbreps2 = ", gbreps2, "\n" ); +gb2 := NP2GPList( gbreps2, A ); +Print( "gb2 = ", gb2, "\n" ); + +# An important point can be made here. Notice that when the lenlex2 +# length ordering is created, a lexicographic (generator) ordering +# table is assigned internally to the ordering since one was not +# provided to it. +# This is just a convenience for lexicographically-dependent orderings, +# and in the case of the length order, it is not used. +# Only the lex table for lexord2 is ever used. +# Some clarification may be provided in examining: +HasNextOrdering( lenlex2 ); +NextOrdering( lenlex2 ); +Print( "LexicographicTable( NextOrdering( lenlex2 ) ) = " ); +Print( LexicographicTable( NextOrdering( lenlex2 ) ), "\n" ); + + +# NMO Example 3 is taken from the book +# 'Ideals, Varieties, and Algorithms', (, +# Example 2, p. 93-94); it is a commutative example. +Print( "starting NMO test 3:\n" ); +# remove any previous orderings +UnpatchGBNP(); +# First, set up the problem and find a Gröbner basis w.r.t. the length +# left-lexicographic ordering implicitly assumed in GBNP: +A3 := FreeAssociativeAlgebraWithOne( Rationals, "x", "y", "z" );; +x := A3.x;; y := A3.y;; z := A3.z;; id := One(A3);; +polys3 := [ x^2 + y^2 + z^2 - id, x^2 + z^2 - y, x-z, + x*y-y*x, x*z-z*x, y*z-z*y];; +reps3 := GP2NPList( polys3 );; +gb3 := Grobner( reps3 );; +Print( "in Example 3 gb3 = ", gb3, "\n" ); +Print( NP2GPList( gb3, A3 ), "\n" ) ; + +# The example, as presented in the book, uses a left-lexicographic +# ordering with z < y < x. We create the ordering in NMO, +# patch GBNP,and get the result expected: +ml3 := NCMonomialLeftLexicographicOrdering( A3, [3,2,1] ); +PatchGBNP( ml3 ); +gb3 := Grobner( reps3 );; +Print( "in Example 3, using ml3, gb3 = ", gb3, "\n" ); +Print( NP2GPList( gb3, A3 ), "\n" ) ; + + +# NMO Example 4 was taken from page 339 of the book +# 'Some Tapas of Computer Algebra' by A.M. Cohen, H. Cuypers, H. Sterk, +# ; +# it also appears as Example 6 in the GBNP example set. +# A noncommutative free algebra on 6 generators over the Rationals +# is created in GAP, and the generators are labeled: +Print( "starting NMO test 4:\n" ); +# remove any previous orderings +UnpatchGBNP(); +A4 := FreeAssociativeAlgebraWithOne(Rationals,"a","b","c","d","e","f");; +a := A4.a;; b := A4.b;; c := A4.c;; d := A4.d;; e := A4.e;; f := A4.f;; +# install the default ordering +lexord4 := NCMonomialLeftLexicographicOrdering( A4 ); +Print( "lexord4 = ", lexord4, "\n" ); +# Set up list of noncommutative polynomials: +polys4 := [ e*a, a^3 + f*a, a^9 + c*a^3, a^81 + c*a^9 + d*a^3, + a^27 + d*a^81 + e*a^9 + f*a^3, b + c*a^27 + e*a^81 + f*a^9, + c*b + d*a^27 + f*a^81, a + d*b + e*a^27, c*a + e*b + f*a^27, + d*a + f*b, b^3 - b, a*b - b*a, a*c - c*a, a*d - d*a, + a*e - e*a, a*f - f*a, b*c - c*b, b*d - d*b, b*e - e*b, + b*f - f*b, c*d - d*c, c*e - e*c, c*f - f*c, d*e - e*d, + d*f - f*d, e*f - f*e ];; +reps4 := GP2NPList( polys4 );; +# Create a length left-lex ordering with the following (default) +# ordering on the generators: a < b < c < d < e < f: +ml4 := NCMonomialLeftLengthLexOrdering( A4 ); +# Patch GBNP and compute the Gröbner basis w.r.t the ordering ml4: +PatchGBNP( ml4 ); +gb4 := Grobner( reps4 );; +Print( "in Example 4 gb4 = ", gb4, "\n" ); +Print( NP2GPList( gb4, A4 ), "\n" ) ; From c17cdc2c015aed8cfefe95d0d8e53bce11e72c57 Mon Sep 17 00:00:00 2001 From: Chris Wensley Date: Mon, 2 Oct 2023 10:52:54 +0100 Subject: [PATCH 4/4] Temporary fix for test20.tst (#29) --- tst/test20.tst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tst/test20.tst b/tst/test20.tst index 326ebbf..5dba8a1 100644 --- a/tst/test20.tst +++ b/tst/test20.tst @@ -60,6 +60,15 @@ gap> # gap> twosidrels:=[a^4-e,b^2-e,(a*b)^2-e];; gap> D:=A^2;; gap> y:=GeneratorsOfLeftModule(D);; +gap> # +gap> # (Sept. 2023) The following GBNP.SetOption command has been added +gap> # because the PrintNPList(modrelsNP); command below was throwing +gap> # an error, printing [ b - 1 ] instead of [ b - 1, 0]. +gap> # This was due to GAP not knowing that the dimension is 2. +gap> # The fix is labelled 'temporary' because SetOption commands +gap> # ought not to be used in a test situation. +gap> # +gap> GBNP.SetOption("pg", Length(y)); gap> modrels:=[y[1]*b-y[1], y[2]*b-y[2], y[1]+y[1]*a*(e+a+b) -y[2]-y[2]*a*(e+a+b)];; gap> # gap>