Skip to content

Commit

Permalink
Ensure fp groups for which Size successfully computed the order can a…
Browse files Browse the repository at this point in the history
…lso be enumerated (previously this could run out of memory) (#5677)

* grpfp: detect relators that are powers

* grpfp: fix enumerator for fp groups with a known cyclic subgroup

* grpfp: fix "working horse" -> "workhorse"
  • Loading branch information
james-d-mitchell authored Apr 2, 2024
1 parent cfebe1d commit 6e61ecc
Show file tree
Hide file tree
Showing 3 changed files with 111 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/grpfp.gd
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ TCENUM:=GAPTCENUM;
## is an internal function which is called by the functions
## <Ref Oper="CosetTable"/>, <Ref Attr="CosetTableInWholeGroup"/>
## and others.
## It is, in fact, the proper working horse that performs a Todd-Coxeter
## It is, in fact, the workhorse that performs a Todd-Coxeter
## coset enumeration.
## <A>fgens</A> must be a set of free generators and <A>grels</A> a set
## of relators in these generators. <A>fsgens</A> are subgroup generators
Expand Down Expand Up @@ -1364,3 +1364,5 @@ DeclareGlobalFunction("MakeFpGroupToMonoidHomType1");

# used in homomorphisms
DeclareGlobalName("TRIVIAL_FP_GROUP");

DeclareAttribute("CyclicSubgroupFpGroup", IsFpGroup);
57 changes: 55 additions & 2 deletions lib/grpfp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ end );
#M CosetTableFromGensAndRels( <fgens>, <grels>, <fsgens> ) . . . . . . . . .
#M do a coset enumeration
##
## 'CosetTableFromGensAndRels' is the working horse for computing a coset
## 'CosetTableFromGensAndRels' is the workhorse for computing a coset
## table of H in G where G is a finitley presented group, H is a subgroup of
## G, and G is the whole group of H. It applies a Felsch strategy Todd-
## Coxeter coset enumeration. The expected parameters are
Expand Down Expand Up @@ -3790,15 +3790,26 @@ end );
## enumerations with cumulatively bigger coset tables up to table size
## <maxtable>. It returns `fail' if no table could be found.
BindGlobal("FinIndexCyclicSubgroupGenerator",function(G,maxtable)
local fgens,grels,max,gens,t,Attempt,perms,short;
local fgens, grels, powers, max, gens, t, Attempt, perms, short;

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

max:=ValueOption("max");
if max=fail then
max:=CosetTableDefaultMaxLimit;
fi;
max:=Minimum(max,maxtable);

powers := List(grels, ExtRepOfObj);
powers := Filtered(powers, x -> Length(x) = 2);
if not IsEmpty(powers) then
SortBy(powers, x -> x[2]);
if Last(powers)[2] > 10 then
max := Last(powers)[2];
fi;
fi;

# take the generators, most frequent first
gens:=GeneratorsOfGroup(G);
t:=MostFrequentGeneratorFpGroup(G);
Expand Down Expand Up @@ -3919,6 +3930,9 @@ local fgens, # generators of the free group
RelatorsOfFpGroup(G),GeneratorsOfGroup(H),true,false:
cyclic:=true,limit:=1+max );
e:=NEWTC_CyclicSubgroupOrder(T);
SetCyclicSubgroupFpGroup(G, H);
# TODO is this correct?
SetAugmentedCosetTableMtcInWholeGroup(H, T);
if e=0 then
return infinity;
else
Expand Down Expand Up @@ -5507,6 +5521,45 @@ end );
InstallMethod( Enumerator,"fp gp.", true,[IsSubgroupFpGroup and IsFinite],0,
G->RightTransversal(G,TrivialSubgroup(G)));

InstallMethod(Enumerator,
"for a finite subgroup of an f. p. group with known cyclic subgroup",
[IsSubgroupFpGroup and IsFinite and HasCyclicSubgroupFpGroup],
function(G)
local H, record;

H := CyclicSubgroupFpGroup(G);
if Size(H) = 1 then # Checking IsTrivial is slow
TryNextMethod();
fi;

record := rec(G_mod_H := RightTransversal(G, H),
H_mod_1 := RightTransversal(H, TrivialSubgroup(H)));

record.Length := enum -> Size(enum!.G_mod_H!.group);

record.NumberElement := function(enum, elt)
local n, r, q;
n := Size(enum!.G_mod_H!.subgroup);
q := PositionCanonical(enum!.G_mod_H, elt);
r := PositionCanonical(enum!.H_mod_1, elt * enum!.G_mod_H[q] ^ -1);
return (q - 1) * n + r;
end;

record.ElementNumber := function(enum, pos)
local n, r, q;
n := Size(enum!.G_mod_H!.subgroup);
r := RemInt(pos - 1, n) + 1;
q := QuoInt(pos - 1, n) + 1;
return enum!.H_mod_1[r] * enum!.G_mod_H[q];
end;

record.Membership := function(elt, enum)
return ElementsFamily(FamilyObj(enum)) = FamilyObj(elt);
end;

return EnumeratorByFunctions(G, record);
end);

InstallGlobalFunction(NewmanInfinityCriterion,function(G,p)
local GO,q,d,e,b,r,val,agemo,ngens;
if not IsPrimeInt(p) then
Expand Down
53 changes: 53 additions & 0 deletions tst/testbugfix/2024-03-16-FpGroups.tst
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
gap> F:=FreeGroup(2);; f1:=F.1;; f2:=F.2;;
gap> G := F / [ f2^100, f1^2, f2*f1*f2^-99*f1^-1 ];;
gap> Size(G);
200
gap> AsList(G);
[ <identity ...>, <[ [ 1, 1 ] ]|f2>, <[ [ 1, -1 ] ]|f2^-1>,
<[ [ 1, 2 ] ]|f2^2>, <[ [ 1, -2 ] ]|f2^-2>, <[ [ 1, 3 ] ]|f2^3>,
<[ [ 1, -3 ] ]|f2^-3>, <[ [ 1, 4 ] ]|f2^4>, <[ [ 1, -4 ] ]|f2^-4>,
<[ [ 1, 5 ] ]|f2^5>, <[ [ 1, -5 ] ]|f2^-5>, <[ [ 1, 6 ] ]|f2^6>,
<[ [ 1, -6 ] ]|f2^-6>, <[ [ 1, 7 ] ]|f2^7>, <[ [ 1, -7 ] ]|f2^-7>,
<[ [ 1, 8 ] ]|f2^8>, <[ [ 1, -8 ] ]|f2^-8>, <[ [ 1, 9 ] ]|f2^9>,
<[ [ 1, -9 ] ]|f2^-9>, <[ [ 1, 10 ] ]|f2^10>, <[ [ 1, -10 ] ]|f2^-10>,
<[ [ 1, 11 ] ]|f2^11>, <[ [ 1, -11 ] ]|f2^-11>, <[ [ 1, 12 ] ]|f2^12>,
<[ [ 1, -12 ] ]|f2^-12>, <[ [ 1, 13 ] ]|f2^13>, <[ [ 1, -13 ] ]|f2^-13>,
<[ [ 1, 14 ] ]|f2^14>, <[ [ 1, -14 ] ]|f2^-14>, <[ [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[ [ 1, -37 ] ]|f2^-37>,
<[ [ 1, 38 ] ]|f2^38>, <[ [ 1, -38 ] ]|f2^-38>, <[ [ 1, 39 ] ]|f2^39>,
<[ [ 1, -39 ] ]|f2^-39>, <[ [ 1, 40 ] ]|f2^40>, <[ [ 1, -40 ] ]|f2^-40>,
<[ [ 1, 41 ] ]|f2^41>, <[ [ 1, -41 ] ]|f2^-41>, <[ [ 1, 42 ] ]|f2^42>,
<[ [ 1, -42 ] ]|f2^-42>, <[ [ 1, 43 ] ]|f2^43>, <[ [ 1, -43 ] ]|f2^-43>,
<[ [ 1, 44 ] ]|f2^44>, <[ [ 1, -44 ] ]|f2^-44>, <[ [ 1, 45 ] ]|f2^45>,
<[ [ 1, -45 ] ]|f2^-45>, <[ [ 1, 46 ] ]|f2^46>, <[ [ 1, -46 ] ]|f2^-46>,
<[ [ 1, 47 ] ]|f2^47>, <[ [ 1, -47 ] ]|f2^-47>, <[ [ 1, 48 ] ]|f2^48>,
<[ [ 1, -48 ] ]|f2^-48>, <[ [ 1, 49 ] ]|f2^49>, <[ [ 1, -49 ] ]|f2^-49>,
<[ [ 1, 50 ] ]|f2^50>, f1, f2*f1, f2^-1*f1, f2^2*f1, f2^-2*f1, f2^3*f1,
f2^-3*f1, f2^4*f1, f2^-4*f1, f2^5*f1, f2^-5*f1, f2^6*f1, f2^-6*f1, f2^7*f1,
f2^-7*f1, f2^8*f1, f2^-8*f1, f2^9*f1, f2^-9*f1, f2^10*f1, f2^-10*f1,
f2^11*f1, f2^-11*f1, f2^12*f1, f2^-12*f1, f2^13*f1, f2^-13*f1, f2^14*f1,
f2^-14*f1, f2^15*f1, f2^-15*f1, f2^16*f1, f2^-16*f1, f2^17*f1, f2^-17*f1,
f2^18*f1, f2^-18*f1, f2^19*f1, f2^-19*f1, f2^20*f1, f2^-20*f1, f2^21*f1,
f2^-21*f1, f2^22*f1, f2^-22*f1, f2^23*f1, f2^-23*f1, f2^24*f1, f2^-24*f1,
f2^25*f1, f2^-25*f1, f2^26*f1, f2^-26*f1, f2^27*f1, f2^-27*f1, f2^28*f1,
f2^-28*f1, f2^29*f1, f2^-29*f1, f2^30*f1, f2^-30*f1, f2^31*f1, f2^-31*f1,
f2^32*f1, f2^-32*f1, f2^33*f1, f2^-33*f1, f2^34*f1, f2^-34*f1, f2^35*f1,
f2^-35*f1, f2^36*f1, f2^-36*f1, f2^37*f1, f2^-37*f1, f2^38*f1, f2^-38*f1,
f2^39*f1, f2^-39*f1, f2^40*f1, f2^-40*f1, f2^41*f1, f2^-41*f1, f2^42*f1,
f2^-42*f1, f2^43*f1, f2^-43*f1, f2^44*f1, f2^-44*f1, f2^45*f1, f2^-45*f1,
f2^46*f1, f2^-46*f1, f2^47*f1, f2^-47*f1, f2^48*f1, f2^-48*f1, f2^49*f1,
f2^-49*f1, f2^50*f1 ]

0 comments on commit 6e61ecc

Please sign in to comment.