From 7587224d230911bd713d2dcb49b2de51e85834d1 Mon Sep 17 00:00:00 2001 From: Markus Pfeiffer Date: Thu, 20 Dec 2018 14:48:56 +0000 Subject: [PATCH] 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. --- lib/kbsemi.gi | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lib/kbsemi.gi b/lib/kbsemi.gi index d1854d4b52..6d56458b35 100644 --- a/lib/kbsemi.gi +++ b/lib/kbsemi.gi @@ -501,33 +501,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);