diff --git a/gap/basic/pcppara.gi b/gap/basic/pcppara.gi index 02dd365..fd39da8 100644 --- a/gap/basic/pcppara.gi +++ b/gap/basic/pcppara.gi @@ -112,8 +112,8 @@ end ); ## InstallGlobalFunction( AddToIgsParallel, function( pcs, gens, ppcs, pgens ) - local coll, rels, n, inf, todo, tododo, ind, indd, g, gg, d, h, hh, a, b, q, k, - c, i, r, sub, keep, val, j, f, nrmd, pairs; + local coll, rels, n, inf, todo, tododo, ind, indd, g, gg, d, h, hh, a, b, + q, k, c, i, r, sub, keep, val, j, f, nrmd, pairs, added; if Length( gens ) = 0 then return [pcs, ppcs]; fi; @@ -133,6 +133,9 @@ function( pcs, gens, ppcs, pgens ) indd[d] := ppcs[i]; od; + # initial gens still need to be reduced + added := true; + # do a reduction step c := TailLimit(ind, c); sub := Filtered([1..Length(gens)], i -> Depth(gens[i]) < c); @@ -150,6 +153,7 @@ function( pcs, gens, ppcs, pgens ) j := PositionMinimum(val); g := Remove(todo, j); gg := Remove(tododo, j); + Remove(val, j); d := Depth( g ); f := []; @@ -196,11 +200,16 @@ function( pcs, gens, ppcs, pgens ) d := Depth(g); od; + # ind unchanged and every todo entry already reduced, so ReduceExpo, + # TailLimit and the filter would be no-ops + if Length(f) = 0 and not added then continue; fi; + # adjust c := TailLimit(ind, c); if inf then ReduceExpoPara(ind, todo, indd, tododo, rels); fi; # add powers and commutators + added := false; for d in f do g := ind[d]; gg := indd[d]; @@ -210,6 +219,7 @@ function( pcs, gens, ppcs, pgens ) if Depth(k) < c then Add(todo, k); Add(tododo, gg^r); + added := true; fi; fi; for j in [1..n] do @@ -221,12 +231,14 @@ function( pcs, gens, ppcs, pgens ) if Depth(k) < c then Add(todo, k); Add(tododo, Comm(gg, indd[j])); + added := true; fi; if rels[j] = 0 then k := Comm(g, ind[j]^-1); if Depth(k) < c then Add(todo, k); Add(tododo, Comm(gg, indd[j]^-1)); + added := true; fi; fi; fi; diff --git a/gap/basic/pcppcps.gi b/gap/basic/pcppcps.gi index 8c89e9a..ff7904c 100644 --- a/gap/basic/pcppcps.gi +++ b/gap/basic/pcppcps.gi @@ -136,7 +136,8 @@ end ); #F AddToIgs( , ) ## InstallGlobalFunction(AddToIgs, function(igs, gens) - local coll, rels, n, inf, c, ind, g, d, todo, val, j, f, h, a, b, k, pair, t; + local coll, rels, n, inf, c, ind, g, d, todo, val, j, f, h, a, b, k, + pair, t, added; if Length(gens) = 0 then return igs; fi; @@ -151,6 +152,9 @@ InstallGlobalFunction(AddToIgs, function(igs, gens) ind := ListWithIdenticalEntries(n, false); for g in igs do ind[Depth(g)] := g; od; + # initial gens still need to be reduced + added := true; + # do a reduction step c := TailLimit(ind, c); todo := Set(Filtered(gens, x -> Depth(x) < c)); @@ -160,6 +164,7 @@ InstallGlobalFunction(AddToIgs, function(igs, gens) while Length(todo) > 0 and c > 1 do j := PositionMinimum(val); g := Remove(todo, j); + Remove(val, j); d := Depth(g); f := []; @@ -194,17 +199,25 @@ InstallGlobalFunction(AddToIgs, function(igs, gens) d := Depth(g); od; + # ind unchanged and every todo entry already reduced, so ReduceExpo, + # TailLimit and the filter would be no-ops + if Length(f) = 0 and not added then continue; fi; + # adjust c := TailLimit(ind, c); if inf then ReduceExpo(ind, todo, rels); fi; # add powers and commutators + added := false; for d in f do g := ind[d]; # skip infinite factors and powers in the tail if d < c-1 and rels[d] > 0 then k := g ^ RelativeOrderPcp(g); - if Depth(k) < c then Add(todo, k); fi; + if Depth(k) < c then + Add(todo, k); + added := true; + fi; fi; for j in [1..n] do # skip trivial commutators and those in the tail @@ -213,10 +226,16 @@ InstallGlobalFunction(AddToIgs, function(igs, gens) fi; if not IsBool(ind[j]) then k := Comm(g, ind[j]); - if Depth(k) < c then Add(todo, k); fi; + if Depth(k) < c then + Add(todo, k); + added := true; + fi; if rels[j] = 0 then k := Comm(g, ind[j]^-1); - if Depth(k) < c then Add(todo, k); fi; + if Depth(k) < c then + Add(todo, k); + added := true; + fi; fi; fi; od;