Skip to content

Commit

Permalink
Fix IsReduced for KnuthBendixRewritingSystem
Browse files Browse the repository at this point in the history
`IsReduced` did not work for KnuthBendixRewritingSystems, because it used
`Rules` to obtain the rules of a rewriting system which are stored as
`IsLetterAssocWordRep`, and then tried reducing words using a kernel function
that assumes list access is possible for such words (which it is not).

Use TzRules instead which converts rules to lists of integers.
  • Loading branch information
Markus Pfeiffer authored and fingolfin committed Jan 7, 2019
1 parent 5c4f835 commit d213d23
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions lib/kbsemi.gi
Original file line number Diff line number Diff line change
Expand Up @@ -500,33 +500,28 @@ InstallMethod(IsReduced,
"for a Knuth Bendix rewriting system", true,
[IsKnuthBendixRewritingSystem and IsKnuthBendixRewritingSystemRep and IsMutable], 0,
function(kbrws)
local i,copy_of_kbrws,u;
local i, copy_of_kbrws, u, tzr;

# if the rws already knows it is reduced return true
if kbrws!.reduced then return true; fi;

for i in [1..Length(Rules(kbrws))] do
tzr := TzRules(kbrws);
for i in [1..Length(tzr)] do

u := Rules(kbrws)[i];
u := tzr[i];

#TODO
copy_of_kbrws := ShallowCopy(kbrws);
copy_of_kbrws!.tzrules := [];
Append(copy_of_kbrws!.tzrules,kbrws!.tzrules{[1..i-1]});
Append(copy_of_kbrws!.tzrules,kbrws!.tzrules
{[i+1..Length(kbrws!.tzrules)]});

if ReduceLetterRepWordsRewSys(copy_of_kbrws!.tzrules,u[1])<>u[1] then
return false;
fi;
if ReduceLetterRepWordsRewSys(copy_of_kbrws!.tzrules,u[2])<>u[2] then
if ReduceLetterRepWordsRewSys(copy_of_kbrws!.tzrules,u[1])<>u[1] or
ReduceLetterRepWordsRewSys(copy_of_kbrws!.tzrules,u[2])<>u[2] then
return false;
fi;

od;

return true;

end);


Expand Down

0 comments on commit d213d23

Please sign in to comment.