Skip to content

Commit

Permalink
ENHANCE: Secondary gens in MTC
Browse files Browse the repository at this point in the history
Ensure secondary generators are all properly eliminated and a length-optimizing
Tietze did not end up in a dead end.
  • Loading branch information
hulpke committed Aug 1, 2024
1 parent 05bb9f8 commit 690ea0c
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 57 deletions.
3 changes: 2 additions & 1 deletion lib/grpfp.gi
Original file line number Diff line number Diff line change
Expand Up @@ -4046,7 +4046,8 @@ local mappow, G, max, p, gens, rels, comb, i, l, m, H, HH, t, gen, sz,
if not HasSize(G) then
sz:=SIZE_FP_FROM_CYCLIC_INDEX(G);
SetSize(G,sz);
elif Size(G)=infinity then
fi;
if Size(G)=infinity then
return fail;
fi;

Expand Down
86 changes: 44 additions & 42 deletions lib/sgpres.gi
Original file line number Diff line number Diff line change
Expand Up @@ -3514,7 +3514,7 @@ end );
# -1: No relators
InstallGlobalFunction(NEWTC_PresentationMTC,function(arg)
local DATA,rels,i,j,w,f,r,s,fam,ri,a,offset,rset,re,stack,pres,
subnum,bad,warn,parameter,str;
subnum,parameter,str,wordefs;

DATA:=arg[1];
if Length(arg)=1 then
Expand Down Expand Up @@ -3605,9 +3605,11 @@ local DATA,rels,i,j,w,f,r,s,fam,ri,a,offset,rset,re,stack,pres,
fi;

# add definitions of secondary generators
wordefs:=[];
for i in [subnum+1..DATA.secount] do
r:=WordProductLetterRep(DATA.secondary[i],[-i]);
Add(rels,r);
wordefs[i]:=r;
od;

if ForAll(str,IsString) and DATA.secount >=Length(str) then
Expand All @@ -3630,49 +3632,49 @@ local DATA,rels,i,j,w,f,r,s,fam,ri,a,offset,rset,re,stack,pres,
TzSearch(pres);
TzOptions(pres).lengthLimit:=pres!.tietze[TZ_TOTAL]+1;
fi;
#TzGoGo(pres);
TzOptions(pres).eliminationsLimit:=5;
TzGoElim(pres,subnum);
TzGoElim(pres,subnum,wordefs);
if IsEvenInt(parameter) and Length(GeneratorsOfPresentation(pres))>subnum then
warn:=true;
# Help Tietze with elimination
bad:=Reversed(List(GeneratorsOfPresentation(pres)
{[subnum+1..Length(GeneratorsOfPresentation(pres))]},
x->LetterRepAssocWord(x)[1]));
for i in bad do
r:=DATA.secondary[i];
re:=true;
while re do
s:=[];
re:=false;
for j in r do
if AbsInt(j)>subnum then
re:=true;
if j>0 then
Append(s,DATA.secondary[j]);
else
Append(s,-Reversed(DATA.secondary[-j]));
fi;
else
Add(s,j);
fi;
od;
Info(InfoFpGroup,2,"Length =",Length(s));
r:=s;
if warn and Length(s)>100*Sum(rels,Length) then
warn:=false;
Error(
"Trying to eliminate all auxiliary generators might cause the\n",
"size of the presentation to explode. Proceed at risk!");
fi;
od;
r:=AssocWordByLetterRep(fam,Concatenation(r,[-i]));
AddRelator(pres,r);
#TzSearch(pres); Do *not* search, as this might kill the relator we
#just added.
TzEliminate(pres,i);
od;
Assert(0,Length(GeneratorsOfPresentation(pres))=subnum);
Error("did not eliminate properly");
# warn:=true;
# # Help Tietze with elimination
# bad:=Reversed(List(GeneratorsOfPresentation(pres)
# {[subnum+1..Length(GeneratorsOfPresentation(pres))]},
# x->LetterRepAssocWord(x)[1]));
# for i in bad do
# r:=DATA.secondary[i];
# re:=true;
# while re do
# s:=[];
# re:=false;
# for j in r do
# if AbsInt(j)>subnum then
# re:=true;
# if j>0 then
# Append(s,DATA.secondary[j]);
# else
# Append(s,-Reversed(DATA.secondary[-j]));
# fi;
# else
# Add(s,j);
# fi;
# od;
# Info(InfoFpGroup,2,"Length =",Length(s));
# r:=s;
# if warn and Length(s)>100*Sum(rels,Length) then
# warn:=false;
# Error(
# "Trying to eliminate all auxiliary generators might cause the\n",
# "size of the presentation to explode. Proceed at risk!");
# fi;
# od;
# r:=AssocWordByLetterRep(fam,Concatenation(r,[-i]));
# AddRelator(pres,r);
# #TzSearch(pres); Do *not* search, as this might kill the relator we
# #just added.
# TzEliminate(pres,i);
# od;
# Assert(0,Length(GeneratorsOfPresentation(pres))=subnum);

fi;
r:=List(GeneratorsOfPresentation(pres){[1..subnum]},
Expand Down
47 changes: 33 additions & 14 deletions lib/tietze.gi
Original file line number Diff line number Diff line change
Expand Up @@ -2324,25 +2324,44 @@ InstallGlobalFunction( TzGo, function ( arg )
end );

# reduce presentation in generators (for MTC)
InstallGlobalFunction(TzGoElim,function(T,downto)
local tietze,len,olen;
InstallGlobalFunction(TzGoElim,function(T,downto,wordefs)
local tietze,oll,num,gens;
gens:=ShallowCopy(T!.generators);
num:=Length(gens);
TzTestInitialSetup(T); # run `1Or2Relators' if not yet done
tietze := T!.tietze;

len:=tietze[TZ_TOTAL];
olen:=len+1;
while tietze[TZ_NUMGENS]-tietze[TZ_NUMREDUNDS]>downto and olen<>len do
TzSearch(T);
TzEliminateGens(T);
while num>downto do
if gens[num] in T!.generators then
#Print("eliminate ",num,"\n");
TzSearch(T);
# the search might have killed the generator
if gens[num] in T!.generators then
TzEliminate(T,gens[num]);
fi;
if gens[num] in T!.generators then
Info(InfoFpGroup,1,"increase length limit");
TzOptions(T).lengthLimit:=TzOptions(T)!.lengthLimit*100;
# and re-add the defining relator
AddRelator(T,AssocWordByLetterRep(FamilyObj(T!.1),wordefs[num]));
TzEliminate(T,gens[num]);
if gens[num] in T!.generators then
Error("still not eliminated");
fi;
fi;
fi;
num:=num-1;
if not tietze[TZ_MODIFIED] then TzSearchEqual(T);fi;
olen:=len;
len:=tietze[TZ_TOTAL];
if TzOptions(T).printLevel>0 then TzPrintStatus(T,true); fi;
if TzOptions(T).printLevel>0 and (num mod 100=0 or num<20) then
TzOptions(T).protected:=num;
oll:=TzOptions(T).loopLimit;
TzOptions(T).loopLimit:=5;
TzGo(T); # cleanup
TzOptions(T).loopLimit:=oll;
TzOptions(T).protected:=downto;
TzPrintStatus(T,true);
fi;
od;
olen:=TzOptions(T).loopLimit;
TzOptions(T).loopLimit:=5;
TzGo(T); # cleanup
TzOptions(T).loopLimit:=olen;
end);


Expand Down

0 comments on commit 690ea0c

Please sign in to comment.