From 2087635dcbb58c6b2fc3b0138e81550ba5309f64 Mon Sep 17 00:00:00 2001 From: Friedrich Rober Date: Tue, 15 Oct 2024 15:24:23 +0200 Subject: [PATCH 1/2] Fix PQuotient error for large groups. - Return fail in AbelianPQuotient if not enough generators for current parameters (logord in PQuotient, or #gens in collector of QuotientSystem qs) - Return fail or error in PQuotient for large groups, depending on option noninteractive - Update documentation of PQuotient - Add test for bugfix --- lib/pquot.gd | 13 ++++++------ lib/pquot.gi | 27 ++++++++++++++++++++++--- tst/testbugfix/2024-10-15-PQuotient.tst | 16 +++++++++++++++ 3 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 tst/testbugfix/2024-10-15-PQuotient.tst diff --git a/lib/pquot.gd b/lib/pquot.gd index bd7d1ff8ba..4ab0519942 100644 --- a/lib/pquot.gd +++ b/lib/pquot.gd @@ -26,11 +26,11 @@ DeclareGlobalFunction( "AbelianPQuotient" ); ############################################################################# ## -#F PQuotient(,

[, ][, ][, ]) . . pq of an fp group +#F PQuotient(,

[, ][, ][, ] : noninteractive) . . pq of an fp group ## ## <#GAPDoc Label="PQuotient"> ## -## +## ## ## ## computes a factor p-group of a finitely presented group F @@ -61,10 +61,11 @@ DeclareGlobalFunction( "AbelianPQuotient" ); ## most p^{256}. If the parameter logord is present, it will ## compute with factor groups of order at most p^{logord}. ## If this parameter is specified, then the parameter c must also be -## given. The present -## implementation produces an error message if the order of a -## p-quotient exceeds p^{256} or p^{logord}, -## respectively. +## given. If the order of a p-quotient exceeds p^{256} +## or p^{logord}, +## respectively, the behaviour of the algorithm depends on the option +## noninteractive: if it is present, the current implementation +## produces an error message; otherwise it returns fail. ## Note that the order of intermediate p-groups may be larger than ## the final order of a p-quotient. ##

diff --git a/lib/pquot.gi b/lib/pquot.gi index 9c788ccd1e..4b3044c0e9 100644 --- a/lib/pquot.gi +++ b/lib/pquot.gi @@ -1310,7 +1310,9 @@ end ); ############################################################################# ## -#F AbelianPQuotient . . . . . . . . . . . initialize an abelian p-quotient +#F AbelianPQuotient . . . . . . try to initialize an abelian p-quotient +## . . . . . . return true if we are sucessful +## . . . . . . return false otherwise ## InstallGlobalFunction( AbelianPQuotient, function( qs ) @@ -1342,6 +1344,9 @@ function( qs ) generators := DifferenceLists( [1..n], trailers ); ## Their images are the first d generators. + if Length(gens) < d then + return false; + fi; qs!.images{ generators } := gens{[1..d]}; ## Fix their definitions. @@ -1367,6 +1372,8 @@ function( qs ) qs!.collector![SCP_WEIGHTS]{[1..qs!.numberOfGenerators]} := [1..qs!.numberOfGenerators] * 0 + 1; + return true; + end ); ############################################################################# @@ -1376,7 +1383,8 @@ end ); InstallGlobalFunction( PQuotient, function( arg ) - local G, p, cl, ngens, collector, qs, t,noninteractive; + local G, p, cl, ngens, collector, qs, t,noninteractive, + isAbelianPQuotientSucessful; ## First we parse the arguments to this function @@ -1453,7 +1461,20 @@ function( arg ) LengthOfDescendingSeries(qs)+1, " quotient" ); t := Runtime(); - AbelianPQuotient( qs ); + isAbelianPQuotientSucessful := AbelianPQuotient( qs ); + if not isAbelianPQuotientSucessful then + if noninteractive then + return fail; + else + Error( "Collector not large enough ", + "to define generators for abelian p-quotient.\n", + "To return the current quotient (of class ", + LengthOfDescendingSeries(qs), ") type `return;' ", + "and `quit;' otherwise.\n" ); + + return qs; + fi; + fi; Info( InfoQuotientSystem, 1, " rank of this layer: ", RanksOfDescendingSeries(qs)[LengthOfDescendingSeries(qs)], diff --git a/tst/testbugfix/2024-10-15-PQuotient.tst b/tst/testbugfix/2024-10-15-PQuotient.tst new file mode 100644 index 0000000000..1f53e44880 --- /dev/null +++ b/tst/testbugfix/2024-10-15-PQuotient.tst @@ -0,0 +1,16 @@ +# see +gap> F := FreeGroup(["a", "b"]);; +gap> a := F.1;; +gap> b := F.1;; +gap> p := 5;; +gap> G := F / [a^p, b^p, Comm(a,b)];; +gap> PQuotient(G, p, 1, 2 : noninteractive) <> fail; +true +gap> PQuotient(G, p, 1, 1 : noninteractive) = fail; +true + +# +gap> PQuotient( FreeGroup(2), 5, 10, 520 : noninteractive ) <> fail; +true +gap> gPQuotient( FreeGroup(2), 5, 10, 519 : noninteractive ) = fail; +true From ee883b67c5e2c5586786c71574dd854f4e84cdef Mon Sep 17 00:00:00 2001 From: Friedrich Rober <37139927+FriedrichRober@users.noreply.github.com> Date: Tue, 15 Oct 2024 18:06:23 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Max Horn --- lib/pquot.gi | 6 +++--- tst/testbugfix/2024-10-15-PQuotient.tst | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/pquot.gi b/lib/pquot.gi index 4b3044c0e9..f2cceb51e5 100644 --- a/lib/pquot.gi +++ b/lib/pquot.gi @@ -1310,9 +1310,9 @@ end ); ############################################################################# ## -#F AbelianPQuotient . . . . . . try to initialize an abelian p-quotient -## . . . . . . return true if we are sucessful -## . . . . . . return false otherwise +#F AbelianPQuotient . . . . . . . . try to initialize an abelian p-quotient +## +## Return true if we are successful, return false otherwise. ## InstallGlobalFunction( AbelianPQuotient, function( qs ) diff --git a/tst/testbugfix/2024-10-15-PQuotient.tst b/tst/testbugfix/2024-10-15-PQuotient.tst index 1f53e44880..a5b4e81deb 100644 --- a/tst/testbugfix/2024-10-15-PQuotient.tst +++ b/tst/testbugfix/2024-10-15-PQuotient.tst @@ -12,5 +12,5 @@ true # gap> PQuotient( FreeGroup(2), 5, 10, 520 : noninteractive ) <> fail; true -gap> gPQuotient( FreeGroup(2), 5, 10, 519 : noninteractive ) = fail; +gap> PQuotient( FreeGroup(2), 5, 10, 519 : noninteractive ) = fail; true