diff --git a/lib/kbsemi.gi b/lib/kbsemi.gi index 5b1f508ccce..16ad3c489d8 100644 --- a/lib/kbsemi.gi +++ b/lib/kbsemi.gi @@ -182,6 +182,9 @@ DeclareRepresentation("IsKnuthBendixRewritingSystemRep", ## refers to one of the rules. A pair corresponds to a pair ## of rules where confluence was not yet checked (according to ## the Knuth Bendix algorithm). +## Pairs might also be given in the form of a 3-entry list +## ['A',x,l] to denote all pairs of the form [x,y] for y in l, +## respectively ['B',l,y] for pairs [x,y[] with x in l. ## ## Note that at this stage the kb rws obtained might not be reduced ## (the same relation might even appear several times). @@ -767,6 +770,22 @@ function ( rws ) " rules" ); end); +# We store compressed data -- expand, (and also delete old stuff) +BindGlobal("KBRWSUnpackPairsAt",function(kbrws,p) +local i,a; + i:=kbrws!.pairs2check[p]; + if IsChar(i[1]) then + # We store compressed data -- expand, (and also delete old stuff) + if i[1]='A' then + a:=List(i[3],x->[i[2],x]); + elif i[1]='B' then + a:=List(i[2],x->[x,i[3]]); + else Error("kind"); fi; + kbrws!.pairs2check:=Concatenation(a,kbrws!.pairs2check{[p+1..Length(kbrws!.pairs2check)]}); + p:=1; + fi; + return p; +end); @@ -776,7 +795,15 @@ end); BindGlobal("KBOverlaps",function(ui,vi,kbrws,p) local u,v,m,k,a,c,lsu,lsv,lu,eq,i,j; + # work around copied code in kan package + if IsChar(ui) then # must unpack + p:=KBRWSUnpackPairsAt(kbrws,p); + vi:=kbrws!.pairs2check[p]; + ui:=vi[1];vi:=vi[2]; + fi; + u:=kbrws!.tzrules[ui]; v:=kbrws!.tzrules[vi]; + lsu:=u[1]; lu:=Length(lsu); lsv:=v[1]; @@ -860,15 +887,7 @@ local pn,lp,rl,p,i,a; i:=kbrws!.pairs2check[p]; if IsChar(i[1]) then # We store compressed data -- expand, (and also delete old stuff) - if i[1]='A' then - a:=List(i[3],x->[i[2],x]); - elif i[1]='B' then - a:=List(i[2],x->[x,i[3]]); - else Error("kind"); fi; - kbrws!.pairs2check:=Concatenation(a,kbrws!.pairs2check{[p+1..Length(kbrws!.pairs2check)]}); - p:=1; - i:=kbrws!.pairs2check[p]; - lp:=Length(kbrws!.pairs2check); + p:=KBRWSUnpackPairsAt(kbrws,p); fi; p:=KBOverlaps(i[1],i[2],kbrws,p)+1;