Skip to content

Commit 7587224

Browse files
Markus Pfeifferfingolfin
authored andcommitted
Fix IsReduced for KnuthBendixRewritingSystem
`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.
1 parent 46a5fc8 commit 7587224

1 file changed

Lines changed: 6 additions & 11 deletions

File tree

lib/kbsemi.gi

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -501,33 +501,28 @@ InstallMethod(IsReduced,
501501
"for a Knuth Bendix rewriting system", true,
502502
[IsKnuthBendixRewritingSystem and IsKnuthBendixRewritingSystemRep and IsMutable], 0,
503503
function(kbrws)
504-
local i,copy_of_kbrws,u;
504+
local i, copy_of_kbrws, u, tzr;
505505

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

509-
for i in [1..Length(Rules(kbrws))] do
509+
tzr := TzRules(kbrws);
510+
for i in [1..Length(tzr)] do
510511

511-
u := Rules(kbrws)[i];
512+
u := tzr[i];
512513

513-
#TODO
514514
copy_of_kbrws := ShallowCopy(kbrws);
515515
copy_of_kbrws!.tzrules := [];
516516
Append(copy_of_kbrws!.tzrules,kbrws!.tzrules{[1..i-1]});
517517
Append(copy_of_kbrws!.tzrules,kbrws!.tzrules
518518
{[i+1..Length(kbrws!.tzrules)]});
519519

520-
if ReduceLetterRepWordsRewSys(copy_of_kbrws!.tzrules,u[1])<>u[1] then
521-
return false;
522-
fi;
523-
if ReduceLetterRepWordsRewSys(copy_of_kbrws!.tzrules,u[2])<>u[2] then
520+
if ReduceLetterRepWordsRewSys(copy_of_kbrws!.tzrules,u[1])<>u[1] or
521+
ReduceLetterRepWordsRewSys(copy_of_kbrws!.tzrules,u[2])<>u[2] then
524522
return false;
525523
fi;
526-
527524
od;
528-
529525
return true;
530-
531526
end);
532527

533528

0 commit comments

Comments
 (0)