  
  [1X3 [33X[0;0YLogged Rewriting Systems[133X[101X
  
  [33X[0;0YA [13Xlogged rewrite system[113X is associated with a group presentation. Each [13Xlogged
  rewrite rule[113X contains, in addition to the standard rewrite rule, a record or
  [13Xlog  component[113X which expresses the rule in terms of the original relators of
  the  group.  We  represent  such  a rule by a triple [10X[ u, [L1,L2,..,Lk], v][110X,
  where  [10X[u,v][110X  is  a  rewrite  rule  and [22XL_i = [n_i,w_i][122X where [22Xn_i[122X is a group
  relator  and  [22Xw_i[122X  is  a  word. These three components obey the identity [22Xu =
  n_1^w_1 ... n_k^w_k v[122X.[133X
  
  [33X[0;0YRules  of  the  form [22Xg^+g^-[122X apply to the monoid presentation, but not to the
  group presentation, so are given an empty logged component.[133X
  
  
  [1X3.1 [33X[0;0YLogged Knuth-Bendix Completion[133X[101X
  
  [33X[0;0YThe  functions  in  this  section  are  the  logged versions of those in the
  previous chapter.[133X
  
  [1X3.1-1 LoggedOnePassKB[101X
  
  [29X[2XLoggedOnePassKB[102X( [3Xloggedrules[103X ) [32X operation
  
  [33X[0;0YGiven  a logged rewrite system, this function finds all the rules that would
  be  added to complete the rewrite system of [10XOnePassKB[110X in [14X2.2-3[114X, and also the
  logs  which  relate  the  new rules to the originals. The result of applying
  this  function  to  [10Xloggedrules[110X  is  to  add  new logged rules to the system
  without changing the monoid it defines.[133X
  
  [33X[0;0YIn the example, we first convert the presentation for [10Xq8[110X into an initial set
  of logged rules, and then apply one pass of Knuth-Bendix.[133X
  
  [33X[0;0YIn   the   development   version  the  function  [10XLoggedOnePassKB[110X  returns  a
  two-element  list  of  lists. The first element is a set of logged rules and
  the second element is an empty list of r-sequences, whatever they are! (Need
  more here.)[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xl0 := ListWithIdenticalEntries( 8, 0 );;[127X[104X
    [4X[25Xgap>[125X [27Xfor j in [1..8] do [127X[104X
    [4X[25X>[125X [27X       r := r0[j];[127X[104X
    [4X[25X>[125X [27X       if ( j<5 ) then[127X[104X
    [4X[25X>[125X [27X          l0[j] := [ r[1], [ [j,id] ], r[2] ];[127X[104X
    [4X[25X>[125X [27X       else[127X[104X
    [4X[25X>[125X [27X          l0[j] := [ r[1], [ ], r[2] ];[127X[104X
    [4X[25X>[125X [27X       fi;[127X[104X
    [4X[25X>[125X [27X   od;[127X[104X
    [4X[25Xgap>[125X [27Xl0;[127X[104X
    [4X[28X[ [ q8_M1^4, [ [ 1, <identity ...>] ], <identity. ..> ], [128X[104X
    [4X[28X  [ q8_M2^4, [ [ 2, <identity ...>] ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_M1*q8_M2*q8_M1*q8_M4, [ [ 3, <identity ...> ] ], <identity ...> ],   [128X[104X
    [4X[28X  [ q8_M1^2*q8_M2^2, [ [ 4, <identity ...> ] ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_M1*q8_M3, [ ], <identity ...> ], [ q8_M2*q8_M4, [ ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_M3*q8_M1, [ ], <identity ...> ], [ q8_M4*q8_M2, [ ], <identity ...> ] ] [128X[104X
    [4X[25Xgap>[125X [27Xl1 := LoggedOnePassKB( l0 );;[127X[104X
    [4X[25Xgap>[125X [27XLength( l1[1] ); [127X[104X
    [4X[28X21[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [33X[0;0YNote  that  the  length  [22X21[122X of [10Xl1[110X is, as expected, the same as that of [10Xr1[110X in
  [14X2.2-3[114X.[133X
  
  [1X3.1-2 LoggedKnuthBendix[101X
  
  [29X[2XLoggedKnuthBendix[102X( [3Xloggedrules[103X ) [32X operation
  [29X[2XLoggedRewriteReduce[102X( [3Xloggedrules[103X ) [32X operation
  
  [33X[0;0YThe  function  [10XLoggedRewriteReduce[110X  removes  unnecessary rules from a logged
  rewrite system. It works on the same principle as [10XRewriteReduce[110X in [14X2.2-3[114X.[133X
  
  [33X[0;0YThe  function [10XLoggedKnuthBendix[110X repeatedly applies functions [10XLoggedOnePassKB[110X
  and [10XLoggedRewriteReduce[110X until no new rules are added and no unnecessary ones
  are included. The output is a reduced complete logged rewrite system.[133X
  
  [33X[0;0YIn order to clarify the meaning of the rules below, consider the second rule
  in  [10Xl2[110X  which  shows  how [22Xb^+a^+[122X reduces to [22Xa^+b^-[122X. For this rule [10X[u,L,v][110X we
  will verify that [22Xu = n_1^w_1n_2^w_2n_3^w_3 v[122X, as in the introduction to this
  chapter. The rule is:[133X
  
  [4X[32X[104X
    [4X[104X
    [4X[ q8_M2*q8_M1, [ [3,q8_M3^-1], [-1,<identity...>], [4,q8_M1^-1] ], q8_M1*q8_M4 ]. [104X
    [4X[104X
  [4X[32X[104X
  
  [33X[0;0YAs   before,  we  write  [22Xa^+,  b^+,  a^-,  b^-[122X  for  [10Xq8_M1,q8_M2,q8_M3,q8_M4[110X
  respectively.  The relators [22X3,4[122X and the inverse of relator [22X1[122X (denoted by [22X-1[122X)
  are   [22Xa^+b^+a^+b^-,   a^+2b^+2[122X   and  [22Xa^-4[122X,  and  these  are  conjugated  by
  [22X(a^-)^-1=a^+,  (a^+)^-1=a^-[122X and the identity respectively. So the second and
  third parts of the rule expand to:[133X
  
  
  [24X[33X[0;6Y(a^-(a^+b^+a^+b^-)a^+)(a^{-4})(a^+(a^{+2}b^{+2})a^-)a^+b^-               ~=~
  (a^-a^+)b^+a^+(b^-(a^+a^{-4}a^{+3})b^+)(b^+(a^-a^+)b^-)[133X
  
  [124X
  
  [33X[0;0Ywhich reduces to the first part of the rule, [22Xb^+a^+[122X.[133X
  
  [33X[0;0YIn   the   development   version  the  function  [10XLoggedOnePassKB[110X  returns  a
  two-element  list  of  lists. The first element is a set of logged rules and
  the  second  element is a long list of r-sequences, whatever they are! (Need
  more here.)[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xl11 := LoggedRewriteReduce( l1[1] );[127X[104X
    [4X[28X[ [ q8_M1*q8_M3, [ ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_M2^2, [ [ -4, <identity ...> ], [ 2, q8_M1^-2 ] ], q8_M1^2 ], [128X[104X
    [4X[28X  [ q8_M2*q8_M4, [ ], <identity ...> ], [ q8_M3*q8_M1, [ ], <identity ...> ], [128X[104X
    [4X[28X      [ q8_M4*q8_M2, [ ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_M1^3, [ [ 1, <identity. ..> ] ], q8_M3 ], [128X[104X
    [4X[28X  [ q8_M1^2*q8_M2, [ [ 4, <identity. ..> ] ], q8_M4 ], [128X[104X
    [4X[28X  [ q8_M1*q8_M2*q8_M1, [ [ 3, <identity ...> ] ], q8_M2 ], [128X[104X
    [4X[28X  [ q8_M2*q8_M1*q8_M4, [ [ 3, q8_M3^-1 ] ], q8_M3] ][128X[104X
    [4X[25Xgap>[125X [27XLength( l11 ); [127X[104X
    [4X[28X9[128X[104X
    [4X[25Xgap>[125X [27Xl2 := LoggedKnuthBendix( l11 );;[127X[104X
    [4X[25Xgap>[125X [27Xl2[1];[127X[104X
    [4X[28X[ [ q8_M1*q8_M3, [ ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_M2*q8_M1, [ [ 3, q8_M3^-1 ], [-1, <identity. ..> ], [ 4, q8_M1^-1 ] ], [128X[104X
    [4X[28X      q8_M1*q8_M4 ], [128X[104X
    [4X[28X  [ q8_M2^2, [ [ -4, <identity ...> ], [2, q8_M1^-2] ], q8_M1^2 ], [128X[104X
    [4X[28X  [ q8_M2*q8_M3, [ [ -3, <identity ...> ] ], q8_M1*q8_M2 ], [128X[104X
    [4X[28X  [ q8_M2*q8_M4, [ ], <identity ...> ], [ q8_M3*q8_M1, [ ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_M3*q8_M2, [ [ -1, <identity ...>], [4, q8_M1^-1 ] ], q8_M1*q8_M4 ],[128X[104X
    [4X[28X  [ q8_M3^2, [ [ -1, <identity ...>] ], q8_M1^2 ], [128X[104X
    [4X[28X  [ q8_M3*q8_M4, [ [ -1, <identity ...>], [ -2, q8_M1^-2], [128X[104X
    [4X[28X        [ 4, <identity ...> ], [ 3, q8_M3^-1*q8_M2^-1 ], [128X[104X
    [4X[28X        [ -3, <identity. ..> ] ], q8_M1*q8_M2 ], [128X[104X
    [4X[28X  [ q8_M4*q8_M1, [ [ -4, <identity ...> ], [ 3, q8_M1^-1 ] ], q8_M1*q8_M2 ], [128X[104X
    [4X[28X  [ q8_M4*q8_M2, [ ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_M4*q8_M3, [ [ -3, q8_M3^-1*q8_M4^-1] ], q8_M1*q8_M4 ], [128X[104X
    [4X[28X  [ q8_M4^2, [ [ -4, <identity. ..> ] ], q8_M1^2 ], [128X[104X
    [4X[28X  [ q8_M1^3, [ [ 1, <identity ...> ] ], q8_M3 ], [128X[104X
    [4X[28X  [ q8_M1^2*q8_M2, [ [4, <identity. ..> ] ], q8_M4 ], [128X[104X
    [4X[28X  [ q8_M1^2*q8_M4, [ [ -4, q8_M1^-2], [ 1, <identity ...> ] ], q8_M2 ] ] [128X[104X
    [4X[25Xgap>[125X [27XLength( l2[1] );[127X[104X
    [4X[28X16[128X[104X
    [4X[25Xgap>[125X [27XLength( l2[2] );[127X[104X
    [4X[28X49[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  
  [1X3.2 [33X[0;0YLogged reduction of a word[133X[101X
  
  [1X3.2-1 LoggedReduceWordKB[101X
  
  [29X[2XLoggedReduceWordKB[102X( [3Xword[103X, [3Xloggedrules[103X ) [32X operation
  [29X[2XLoggedOnePassReduceWord[102X( [3Xword[103X, [3Xloggedrules[103X ) [32X operation
  [29X[2XShorterLoggedRule[102X( [3Xlogrule1[103X, [3Xlogrule2[103X ) [32X operation
  
  [33X[0;0YGiven    a    word    and    a   logged   rewrite   system,   the   function
  [10XLoggedOnePassReduceWord[110X  makes  one  reduction  pass  of  the word (possibly
  involving  several  reductions)  (as  does  [10XOnePassReduceWord[110X  in [14X2.2-2[114X) and
  records this, using the log part of the rule(s) used and the position in the
  original word of the replaced part.[133X
  
  [33X[0;0YThe  function  [10XLoggedReduceWordKB[110X repeatedly applies [10XOnePassLoggedReduceWord[110X
  until  the  word  can  no  longer  be reduced. Each step of the reduction is
  logged,  showing  how  the  original  word  can be expressed in terms of the
  original relators and the irreducible word. When [10Xloggedrules[110X is complete the
  reduced  word is a unique normal form for that group element. The log of the
  reduction depends on the order in which the rules are applied.[133X
  
  [33X[0;0YThe  function  [10XShorterLoggedrule[110X  decides  whether one logged rule is better
  than  another,  using  the  same  criteria  as  [10XShorterRule[110X in [14X2.2-3[114X. In the
  example  we  perform  logged reductions of [22Xw_0 = a^9b^9[122X corresponding to the
  ordinary reductions performed in the previous chapter (section [14X2.2-2[114X).[133X
  
  [33X[0;0YIn  order  to  clarify  the  following  output, note that, in the log below,
  [22Xb^9a^9[122X  reduces to [22Xb^5a^5[122X in [10Xlw1[110X and to [22Xba[122X in the first [10Xlw2[110X. These expand to
  the initial [10Xw0[110X using the given logged parts as follows:[133X
  
  
  [24X[33X[0;6Y(b^{+9}a^{+4}b^{-9})(b^{+4})b^{+5}a^{+5}      ~=~      b^{+9}a^{+9}      ~=~
  (b^{+9}a^{+4}b^{-9})(b^{+4})(b^{+5}a^{+4}b^{-5})(b^{+4})b^+a^+\,.[133X
  
  [124X
  
  [33X[0;0YThe corresponding expansion of the final [10Xlw2[110X is too lengthy to include here.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xw0; [127X[104X
    [4X[28Xq8_M2^9*q8_M1^9[128X[104X
    [4X[25Xgap>[125X [27Xlw1 := LoggedOnePassReduceWord( w0, l0 );[127X[104X
    [4X[28X[ [ [ 1, q8_M2^-9 ], [ 2, <identity ...> ] ], q8_M2^5*q8_M1^5 ][128X[104X
    [4X[25Xgap>[125X [27Xlw2 := LoggedReduceWordKB( w0, l0 ); [127X[104X
    [4X[28X[ [ [ 1, q8_M2^-9 ], [ 2, <identity ...> ], [ 1, q8_M2^-5 ],[128X[104X
    [4X[28X      [ 2, <identity ...> ] ], q8_M2*q8_M1 ][128X[104X
    [4X[25Xgap>[125X [27Xlw2 := LoggedReduceWordKB( w0, l2[1] ); [127X[104X
    [4X[28X[ [ [ 3, q8_M3^-1*q8_M2^-8 ], [ -1, q8_M2^-8 ], [ 4, q8_M1^-1*q8_M2^-8 ], [128X[104X
    [4X[28X      [ -4, <identity ...> ], [ 2, q8_M1^-2 ], [128X[104X
    [4X[28X      [ -4, q8_M1^-1*q8_M2^-6*q8_M1^-2 ], [ 3, q8_M1^-2*q8_M2^-6*q8_M1^-2 ], [128X[104X
    [4X[28X      [ 1, q8_M2^-1*q8_M1^-2*q8_M2^-6*q8_M1^-2 ], [ 4, <identity ...> ], [128X[104X
    [4X[28X      [ 3, q8_M3^-1*q8_M2^-4*q8_M4^-1 ], [ -1, q8_M2^-4*q8_M4^-1 ], [128X[104X
    [4X[28X      [ 4, q8_M1^-1*q8_M2^-4*q8_M4^-1 ], [ -4, q8_M4^-1 ], [128X[104X
    [4X[28X      [ 2, q8_M1^-2*q8_M4^-1 ], [128X[104X
    [4X[28X      [ -3, q8_M1^-1*q8_M4^-1*q8_M1^-1*q8_M2^-2*q8_M1^-2*q8_M4^-1 ], [128X[104X
    [4X[28X      [ -4, <identity ...> ], [ 3, q8_M1^-1 ], [128X[104X
    [4X[28X      [ 1, q8_M2^-1*q8_M1^-2*q8_M4^-1*q8_M1^-1*q8_M2^-1*(q8_M2^-1*q8_M1^-1)^2 [128X[104X
    [4X[28X         ], [ 4, q8_M4^-1*q8_M1^-1*q8_M2^-1*(q8_M2^-1*q8_M1^-1)^2 ], [128X[104X
    [4X[28X      [ 3, q8_M3^-1*q8_M1^-1 ], [ -1, q8_M1^-1 ], [ 4, q8_M1^-2 ], [128X[104X
    [4X[28X      [ -4, q8_M4^-1*q8_M1^-2 ], [ 2, q8_M1^-2*q8_M4^-1*q8_M1^-2 ], [128X[104X
    [4X[28X      [ -4, q8_M1^-2 ], [ 3, q8_M1^-3 ], [ -4, q8_M1^-2*q8_M2^-1*q8_M1^-3 ], [128X[104X
    [4X[28X      [ 1, <identity ...> ], [ 3, q8_M3^-2 ], [ -1, q8_M3^-1 ], [128X[104X
    [4X[28X      [ 4, q8_M1^-1*q8_M3^-1 ], [ -4, <identity ...> ], [ 3, q8_M1^-1 ], [128X[104X
    [4X[28X      [ 3, q8_M3^-1*q8_M1^-1 ], [ -1, q8_M1^-1 ], [ 4, q8_M1^-2 ], [128X[104X
    [4X[28X      [ -4, q8_M1^-2 ], [ 3, q8_M1^-3 ], [ 1, <identity ...> ], [128X[104X
    [4X[28X      [ -1, <identity ...> ], [ 4, q8_M1^-1 ] ], q8_M1*q8_M4 ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [1X3.2-2 LoggedRewritingSystemFpGroup[101X
  
  [29X[2XLoggedRewritingSystemFpGroup[102X( [3Xloggedrules[103X ) [32X attribute
  
  [33X[0;0YGiven   a  group  presentation,  the  function  [10XLoggedRewritingSystemFpGroup[110X
  determines a logged rewrite system based on the relators. The initial logged
  rewrite system associated with a group presentation consists of two types of
  rule.  These  are  logged  versions  of  the two types of rule in the monoid
  presentation.  For  each  relator  [10Xrel[110X  of  the group there is a logged rule
  [10X[rel,[[1,rel]],id][110X.  For  each  inverse  relator  there  is  a logged rule [10X[
  gen*inv,  [],  id  ][110X.  The function then attempts a completion of the logged
  rewrite  system.  The rules in the final system are partially ordered by the
  function [10XShorterLoggedRule[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27Xlwrs := LoggedRewritingSystemFpGroup( q8 );[127X[104X
    [4X[28X[ [ q8_M4*q8_M2, [ ], <identity ...> ], [ q8_M3*q8_Ml, [ ], <identity ...> ], [128X[104X
    [4X[28X    [ q8_M2*q8_M4, [ ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_Ml*q8_M3, [ ], <identity ...> ], [128X[104X
    [4X[28X  [ q8_Ml^2*q8_M4, [ [ -8, q8_Ml^-2 ], [ 5, <identity ...> ] ], q8_M2 ], [128X[104X
    [4X[28X  [ q8_Ml^2*q8_M2, [ [ 8, <identity ...> ] ], q8_M4 ], [128X[104X
    [4X[28X  [ q8_Ml^3, [ [ 5, <identity ...> ] ], q8_M3 ], [128X[104X
    [4X[28X  [ q8_M4^2, [ [ -8, <identity ...> ] ], q8_Ml^2 ], [128X[104X
    [4X[28X  [ q8_M4*q8_M3, [ [ -7, q8_M3^-1*q8_M4^-1 ] ], q8_Ml*q8_M4 ], [128X[104X
    [4X[28X  [ q8_M4*q8_Ml, [ [ -8, <identity. ..> ], [ 7, q8_Ml^-1 ] ], q8_Ml*q8_M2 ], [128X[104X
    [4X[28X  [ q8_M3*q8_M4, [128X[104X
    [4X[28X      [ [ -5, <identity ...>], [ -6, q8_Ml^-2 ], [ 8, <identity ...> ], [128X[104X
    [4X[28X          [ 7, q8_M3^-1*q8_M2^-1 ], [ -7, <identity. ..> ] ], q8_Ml*q8_M2 ], [128X[104X
    [4X[28X  [ q8_M3^2, [ [ -5, <identity ...>] ], q8_Ml^2 ], [128X[104X
    [4X[28X  [ q8_M3*q8_M2, [ [ -5, <identity. ..> ], [ 8, q8_Ml^-1 ] ], q8_Ml*q8_M4 ], [128X[104X
    [4X[28X  [ q8_M2*q8_M3, [ [ -7, <identity ...> ] ], q8_M1*q8_M2 ], [128X[104X
    [4X[28X  [ q8_M2^2, [ [ -a, <identity ...> ], [ 6, q8_M1^-2 ] ], q8_M1^2 ], [128X[104X
    [4X[28X  [ q8_M2*q8_M1, [ [ 7, q8_M3^-1 ], [ -5, <identity ...> ], [ a, q8_M1^-1 ] ], [128X[104X
    [4X[28X      q8_M1*q8_M4 ] ] [128X[104X
    [4X[25Xgap>[125X [27XLength( lwrs );[127X[104X
    [4X[28X16[128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
  [33X[0;0YConsider  now  the  two-generator abelian group [22XT[122X considered in the previous
  chapter  ([14X2.2-1[114X). Using the alternative ordering on the monoid generators, [10X[
  T_M1[110X[22X=a^+[122X,  [10XT_M2[110X[22X=a^-[122X,  [10XT_M3[110X[22X=b^+[122X, [10XT_M4[110X[22X=b^-[122X [10X][110X, we obtain the following set of [22X8[122X
  logged rules. The last of these may be checked as follows:[133X
  
  
  [24X[33X[0;6Y(b^+a^+(b^-a^-b^+a^+)a^-b^-)a^+b^+                                       ~=~
  b^+a^+(b^-(a^-(b^+(a^+a^-)b^-)a^+)b^+)[133X
  
  [124X
  
  [33X[0;0Yand is a logged version of the rule [22Xb^+a^+ -> a^+b^+[122X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[28X[128X[104X
    [4X[25Xgap>[125X [27XlrwsT := LoggedRewritingSystemFpGroup( T );[127X[104X
    [4X[28X[ [ T_M4*T_M3, [  ], <identity ...> ], [ T_M3*T_M4, [  ], <identity ...> ], [128X[104X
    [4X[28X  [ T_M2*T_M1, [  ], <identity ...> ], [ T_M1*T_M2, [  ], <identity ...> ], [128X[104X
    [4X[28X  [ T_M4*T_M2, [ [ -5, <identity ...> ] ], T_M2*T_M4 ], [128X[104X
    [4X[28X  [ T_M4*T_M1, [ [ 5, T_M1^-1 ] ], T_M1*T_M4 ], [128X[104X
    [4X[28X  [ T_M3*T_M2, [ [ 5, T_M3^-1 ] ], T_M2*T_M3 ], [128X[104X
    [4X[28X  [ T_M3*T_M1, [ [ -5, T_M1^-1*T_M3^-1 ] ], T_M1*T_M3 ] ][128X[104X
    [4X[28X[128X[104X
  [4X[32X[104X
  
