Skip to content

Commit

Permalink
Merge pull request #843 from hulpke/newmtc
Browse files Browse the repository at this point in the history
New Implementation of MTC
  • Loading branch information
hulpke authored Aug 4, 2016
2 parents 651e337 + 257e7a0 commit 5ccbeaa
Show file tree
Hide file tree
Showing 7 changed files with 1,586 additions and 662 deletions.
97 changes: 61 additions & 36 deletions lib/ghomfp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -197,30 +197,29 @@ end);
InstallMethod(CosetTableFpHom,"for fp homomorphisms",true,
[ IsFromFpGroupGeneralMappingByImages and IsGroupGeneralMappingByImages],0,
function(hom)
local u,aug,hgu,mapi;
local u,aug,hgu,mapi,w;
# source group with suitable generators
u:=Source(hom);
aug:=false;
mapi:=MappingGeneratorsImages(hom);
hgu:=List(mapi[1],UnderlyingElement);
# try to re-use an existing augmented coset table:
aug:=AugmentedCosetTableInWholeGroup(u,mapi[1]);
if not IsSubset(hgu,aug.primaryGeneratorWords) then
# we don't know what to do with the extra primary words, so enforce MTC
# version
aug:=AugmentedCosetTableMtcInWholeGroup(
SubgroupNC(FamilyObj(u)!.wholeGroup,mapi[1]));
fi;
# as we add homomorphism specific entries, lets be safe and copy.
aug:=CopiedAugmentedCosetTable(aug);

# construct augmented coset table
w:=FamilyObj(mapi[1])!.wholeGroup;
aug:=NEWTC_CosetEnumerator(FreeGeneratorsOfFpGroup(w),
RelatorsOfFpGroup(w),
hgu,
true);

aug.homgens:=mapi[1];
aug.homgenims:=mapi[2];

# assign the primary generator images
aug.primaryImages:=List(aug.primaryGeneratorWords,
aug.primaryImages:=List(aug.subgens,
i->aug.homgenims[Position(hgu,i)]);

# TODO: possibly re-use an existing augmented table stored already

TrySecondaryImages(aug);

return aug;
Expand All @@ -235,7 +234,7 @@ InstallMethod( ImagesRepresentative, "map from (sub)fp group, rewrite",
[ IsFromFpGroupGeneralMappingByImages and IsGroupGeneralMappingByImages,
IsMultiplicativeElementWithInverse ], 0,
function( hom, word )
local aug,si,r,i,j,tt,ct,cft,c,f,g,ind,e;
local aug,si,r,i,j,tt,ct,cft,c,f,g,ind,e,eval;
# get a coset table
aug:=CosetTableFpHom(hom);
r:=One(Range(hom));
Expand All @@ -247,6 +246,36 @@ local aug,si,r,i,j,tt,ct,cft,c,f,g,ind,e;
else
Error("no decoding possible");
fi;
word:=UnderlyingElement(word);

if IsBound(aug.isNewAugmentedTable) then

eval:=function(i)
local w,j;
w:=One(si[1]);
if not IsBound(si[i]) then
for j in aug.secondary[i] do
if j<0 then
w:=w/eval(-j);
else
w:=w*eval(j);
fi;
od;
si[i]:=w;
fi;
return si[i];
end;

for i in NEWTC_Rewrite(aug,1,LetterRepAssocWord(word)) do
if i<0 then r:=r/eval(-i);
else r:=r*eval(i);
fi;
od;
return r;

fi;

# old version

# instead of calling `RewriteWord', we rewrite locally in the images.
# this ought to be a bit faster and better on memory.
Expand All @@ -260,7 +289,6 @@ local aug,si,r,i,j,tt,ct,cft,c,f,g,ind,e;
fi;
tt:=aug.transtab;

word:=UnderlyingElement(word);
c:=1; # current coset

if not IsLetterAssocWordRep(word) then
Expand Down Expand Up @@ -818,41 +846,38 @@ InstallMethod(IsomorphismFpGroupByGeneratorsNC,"subgroups of fp group",
[IsSubgroupFpGroup,IsList and IsMultiplicativeElementWithInverseCollection,
IsString],0,
function(u,gens,nam)
local aug,w,p,pres,f,fam;
local aug,w,p,pres,f,fam,G;
if HasIsWholeFamily(u) and IsWholeFamily(u) and
IsIdenticalObj(gens,GeneratorsOfGroup(u)) then
return IdentityMapping(u);
fi;
# get an augmented coset table from the group. It must be compatible with
# `gens', so we must always use MTC.
if HasGeneratorsOfGroup(u) and IsIdenticalObj(GeneratorsOfGroup(u),gens) then
aug:=AugmentedCosetTableMtcInWholeGroup(u);
else
w:=FamilyObj(u)!.wholeGroup;
aug:=AugmentedCosetTableMtc(w,SubgroupNC(w,gens),2,"%");
# do not store the generators for the subgroup (the user could do this
# himself if he wanted), the danger of consequential errors due to a
# wrong <gens> list is too high.
fi;

# force computation of words for the secondary generators
SecondaryGeneratorWordsAugmentedCosetTable(aug);

# create a tietze object to reduce the presentation a bit
if not IsBound(aug.subgroupRelators) then
aug.subgroupRelators := RewriteSubgroupRelators( aug, aug.groupRelators);

# use new MTC
w:=FamilyObj(u)!.wholeGroup;
aug:=NEWTC_CosetEnumerator(FreeGeneratorsOfFpGroup(w),
RelatorsOfFpGroup(w),
List(GeneratorsOfGroup(u),UnderlyingElement),
true);

pres:=NEWTC_PresentationMTC(aug,1,"%");
if Length(GeneratorsOfPresentation(pres))>Length(gens) then
aug:=NEWTC_CosetEnumerator(FreeGeneratorsOfFpGroup(w),
RelatorsOfFpGroup(w),
List(GeneratorsOfGroup(u),UnderlyingElement),
true,false);

pres:=NEWTC_PresentationMTC(aug,0,"%");
fi;
aug:=CopiedAugmentedCosetTable(aug);
pres := PresentationAugmentedCosetTable( aug,nam,0,true );
TzOptions(pres).printLevel:=InfoLevel(InfoFpGroup);
DecodeTree(pres);
Assert(0,Length(GeneratorsOfPresentation(pres))=Length(gens));

# new free group
f:=FpGroupPresentation(pres);
aug.homgens:=gens;
aug.homgenims:=GeneratorsOfGroup(f);
aug.primaryImages:=GeneratorsOfGroup(f);
SecondaryImagesAugmentedCosetTable(aug);
aug.secondaryImages:=ShallowCopy(GeneratorsOfGroup(f));

f:=GroupHomomorphismByImagesNC(u,f,gens,GeneratorsOfGroup(f):noassert);

Expand Down
33 changes: 17 additions & 16 deletions lib/grpfp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -1340,12 +1340,6 @@ function( H )
return AugmentedCosetTableRrsInWholeGroup(H).cosetTable;
end );

InstallMethod( CosetTableInWholeGroup,"from augmented table Mtc",
true, [ IsSubgroupFpGroup and HasAugmentedCosetTableMtcInWholeGroup], 0,
function( H )
return AugmentedCosetTableMtcInWholeGroup(H).cosetTable;
end );

InstallMethod(CosetTableInWholeGroup,"ByQuoSubRep",true,
[IsSubgroupOfWholeGroupByQuotientRep],0,
function(G)
Expand Down Expand Up @@ -3768,6 +3762,7 @@ local fgens, # generators of the free group
H, # subgroup of <G>
gen, # generator of cyclic subgroup
max, # maximal coset table length required
e,
T; # coset table of <G> by <H>

fgens := FreeGeneratorsOfFpGroup( G );
Expand All @@ -3793,11 +3788,14 @@ local fgens, # generators of the free group
gen:=gen[1];

H := Subgroup(G,[gen]);
T := AugmentedCosetTableMtc( G, H, -1, "_x":max:=max );
if T.exponent = infinity then
T := NEWTC_CosetEnumerator( FreeGeneratorsOfFpGroup(G),
RelatorsOfFpGroup(G),GeneratorsOfGroup(H),true,false:
cyclic:=true,limit:=1+max );
e:=NEWTC_CyclicSubgroupOrder(T);
if e=0 then
return infinity;
else
return T.index * T.exponent;
return T.index * e;
fi;
fi;

Expand Down Expand Up @@ -3839,7 +3837,8 @@ end);
##
InstallGlobalFunction(IsomorphismPermGroupOrFailFpGroup,
function(arg)
local mappow, G, max, p, gens, rels, comb, i, l, m, H, t, gen, silent, sz, t1, bad, trial, b, bs, r, nl, o, u, rp, eo, rpo, e, e2, sc, j, z;
local mappow, G, max, p, gens, rels, comb, i, l, m, H, t, gen, silent, sz,
t1, bad, trial, b, bs, r, nl, o, u, rp, eo, rpo, e, e2, sc, j, z;

mappow:=function(n,g,e)
while e>0 do
Expand Down Expand Up @@ -3904,23 +3903,25 @@ function(arg)
if t<>fail then
gen:=t[1];
Unbind(t);
t:=AugmentedCosetTableMtc(G,Subgroup(G,[gen]),1,"@":
silent:=true,max:=max );
t := NEWTC_CosetEnumerator( FreeGeneratorsOfFpGroup(G),
RelatorsOfFpGroup(G),[gen],true,false:
cyclic:=true,limit:=1+max,quiet:=true );
fi;
if t=fail then
# we cannot get the size within the permitted limits -- give up
return fail;
fi;
if t.exponent=infinity then
e:=NEWTC_CyclicSubgroupOrder(t);
if e=0 then
SetSize(G,infinity);
return fail;
fi;
sz:=t.exponent*IndexCosetTab(t.cosetTable);
sz:=e*t.index;
SetSize(G,sz);
Info(InfoFpGroup,1,"found size ",sz);
if sz>200*IndexCosetTab(t.cosetTable) then
if sz>200*t.index then
# try the corresponding perm rep
p:=t.cosetTable{[1,3..Length(t.cosetTable)-1]};
p:=t.ct{t.offset+[1..Length(FreeGeneratorsOfFpGroup(G))]};
Unbind(t);

for j in [1..Length(p)] do
Expand Down
4 changes: 4 additions & 0 deletions lib/sgpres.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,10 @@ DeclareGlobalFunction("SecondaryGeneratorWordsAugmentedCosetTable");
##
DeclareGlobalFunction("CopiedAugmentedCosetTable");

# forward declaration of the new mtc worker and presentation builder fct.
DeclareGlobalFunction("NEWTC_CosetEnumerator");
DeclareGlobalFunction("NEWTC_PresentationMTC");
DeclareGlobalFunction("NEWTC_CyclicSubgroupOrder");

#############################################################################
##
Expand Down
Loading

0 comments on commit 5ccbeaa

Please sign in to comment.