From 2087635dcbb58c6b2fc3b0138e81550ba5309f64 Mon Sep 17 00:00:00 2001 From: Friedrich Rober Date: Tue, 15 Oct 2024 15:24:23 +0200 Subject: [PATCH 1/5] 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/5] 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 From 721958b641e8c844368e10d08bfb25fa46a929a4 Mon Sep 17 00:00:00 2001 From: Friedrich Rober Date: Tue, 12 Nov 2024 16:01:02 +0100 Subject: [PATCH 3/5] PQuot: Adjust documentation Attempt to fix confusion about logord parameter --- lib/pquot.gd | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/pquot.gd b/lib/pquot.gd index 4ab0519942..26a1e6bedb 100644 --- a/lib/pquot.gd +++ b/lib/pquot.gd @@ -57,17 +57,21 @@ DeclareGlobalFunction( "AbelianPQuotient" ); ## In case F does not have a largest factor p-group, ## the algorithm will not terminate. ##

-## By default the algorithm computes only with factor groups of order at -## 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. If the order of a p-quotient exceeds p^{256} -## or p^{logord}, -## respectively, the behaviour of the algorithm depends on the option +## By default the value of the paramter logord is set to 256. +## If the parameter logord is specified, then the parameter c must also be +## given. +## The algorithm will only compute with factor groups of order +## at most p^{logord}. +## If the order of a factor group exceeds p^{logord}, +## 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. +## Note that the order of intermediate p-groups, which are constructed by the algorithm +## during the computation, may be larger than the final order of a p-quotient +## in the series. Thus a p-quotient is not necessarily computed +## even if its order does not exceed p^{logord}. +## However, for the first quotient we can guarantee that it is found, +## if the order does not exceed p^{logord}. ##

## The parameter ctype determines the type of collector that is used ## for computations within the factor p-group. From 99056dbf27fa5ea9462757a80b25ad066c23210f Mon Sep 17 00:00:00 2001 From: Friedrich Rober Date: Tue, 12 Nov 2024 16:01:44 +0100 Subject: [PATCH 4/5] PQuot: remove broken lines in new test file --- tst/testbugfix/2024-10-15-PQuotient.tst | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tst/testbugfix/2024-10-15-PQuotient.tst b/tst/testbugfix/2024-10-15-PQuotient.tst index a5b4e81deb..41aff2fb62 100644 --- a/tst/testbugfix/2024-10-15-PQuotient.tst +++ b/tst/testbugfix/2024-10-15-PQuotient.tst @@ -8,9 +8,3 @@ 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> PQuotient( FreeGroup(2), 5, 10, 519 : noninteractive ) = fail; -true From a2b9ba2230e2c6aed07892beae2348d1c357f966 Mon Sep 17 00:00:00 2001 From: Friedrich Rober Date: Tue, 12 Nov 2024 16:05:08 +0100 Subject: [PATCH 5/5] PQuot: Fix grammar in documentation --- lib/pquot.gd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/pquot.gd b/lib/pquot.gd index 26a1e6bedb..08db21cc1c 100644 --- a/lib/pquot.gd +++ b/lib/pquot.gd @@ -60,7 +60,7 @@ DeclareGlobalFunction( "AbelianPQuotient" ); ## By default the value of the paramter logord is set to 256. ## If the parameter logord is specified, then the parameter c must also be ## given. -## The algorithm will only compute with factor groups of order +## The algorithm only computes with factor groups of order ## at most p^{logord}. ## If the order of a factor group exceeds p^{logord}, ## the behaviour of the algorithm depends on the option