Skip to content

Commit

Permalink
Fix IsomorphismPermGroupOrFailFpGroup(G,max)
Browse files Browse the repository at this point in the history
... to honor its second argument, which limits the coset table size
that gets used before it gives up.
  • Loading branch information
fingolfin committed Jan 9, 2025
1 parent 920eefc commit f1a8d2d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 5 deletions.
23 changes: 18 additions & 5 deletions lib/grpfp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -3899,15 +3899,20 @@ end);
#M Size( <G> ) . . . . . . . . . . . . . size of a finitely presented group
##
BindGlobal("SIZE_FP_FROM_CYCLIC_INDEX",
function( G )
function( G, max... ) # max = maximal coset table length required
local fgens, # generators of the free group
rels, # relators of <G>
H, # subgroup of <G>
gen, # generator of cyclic subgroup
max, # maximal coset table length required
e,
T; # coset table of <G> by <H>

if Length(max) = 0 then
max := infinity;
else
max := max[1];
fi;

fgens := FreeGeneratorsOfFpGroup( G );
rels := RelatorsOfFpGroup( G );

Expand All @@ -3926,8 +3931,13 @@ local fgens, # generators of the free group
fi;
# the group could be quite big -- try to find a cyclic subgroup of
# finite index.
gen:=FinIndexCyclicSubgroupGenerator(G,infinity);
max:=gen[2];
gen:=FinIndexCyclicSubgroupGenerator(G,max);
if gen = fail then
return fail;

Check warning on line 3936 in lib/grpfp.gi

View check run for this annotation

Codecov / codecov/patch

lib/grpfp.gi#L3936

Added line #L3936 was not covered by tests
fi;
if max = infinity then
max:=gen[2];
fi;
gen:=gen[1];

H := Subgroup(G,[gen]);
Expand Down Expand Up @@ -4049,7 +4059,10 @@ local mappow, G, max, p, gens, rels, comb, i, l, m, H, HH, t, sz,

H:=[]; # indicate pseudo-size 0
if not HasSize(G) then
sz:=SIZE_FP_FROM_CYCLIC_INDEX(G);
sz:=SIZE_FP_FROM_CYCLIC_INDEX(G, max);
if sz = fail then
return fail;

Check warning on line 4064 in lib/grpfp.gi

View check run for this annotation

Codecov / codecov/patch

lib/grpfp.gi#L4064

Added line #L4064 was not covered by tests
fi;
SetSize(G,sz);
fi;
if Size(G)=infinity then
Expand Down
11 changes: 11 additions & 0 deletions tst/testbugfix/2024-07-29-fpgroup-enum.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Sometimes GAP was able to compute the size of an fp group but then
# for any further action failed to compute a permutation representation.
# See https://github.com/gap-system/gap/issues/5764 for the report,
# and https://github.com/gap-system/gap/pull/5770 for the fix.
gap> f := FreeGroup("a","b","c");;
gap> g := f / [ f.1*f.1*f.1,f.1*f.2*f.3*f.1*f.3^-1*f.2*f.3*f.3,f.1*f.3*f.2^-1 ];
<fp group on the generators [ a, b, c ]>
gap> Size(g);
84
gap> IdGroup(g);
[ 84, 1 ]
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# IsomorphismPermGroupOrFailFpGroup ignored its second argument
# which is supposed to limit the number of cosets that get defined
# before it gives up
gap> F:=FreeGroup(2);;G:=F/[F.1^2, F.2^2];;
gap> IsomorphismPermGroupOrFailFpGroup(G, 100);

0 comments on commit f1a8d2d

Please sign in to comment.