  
  [1X52 [33X[0;0YFinitely Presented Semigroups and Monoids[133X[101X
  
  [33X[0;0YA  [13Xfinitely  presented  semigroup[113X  (resp.  [13Xfinitely  presented  monoid[113X) is a
  quotient  of  a  free  semigroup  (resp.  free monoid) on a finite number of
  generators over a finitely generated congruence on the free semigroup (resp.
  free monoid).[133X
  
  [33X[0;0YFinitely  presented semigroups are obtained by factoring a free semigroup by
  a  set  of  relations  (a generating set for the congruence), i.e., a set of
  pairs of words in the free semigroup.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf:=FreeSemigroup("a","b");;[127X[104X
    [4X[25Xgap>[125X [27Xx:=GeneratorsOfSemigroup(f);;[127X[104X
    [4X[25Xgap>[125X [27Xs:=f/[ [x[1]*x[2],x[2]*x[1]] ];[127X[104X
    [4X[28X<fp semigroup on the generators [ a, b ]>[128X[104X
    [4X[25Xgap>[125X [27XGeneratorsOfSemigroup(s);[127X[104X
    [4X[28X[ a, b ][128X[104X
    [4X[25Xgap>[125X [27XRelationsOfFpSemigroup(s);[127X[104X
    [4X[28X[ [ a*b, b*a ] ][128X[104X
  [4X[32X[104X
  
  [33X[0;0YFinitely  presented monoids are obtained by factoring a free monoid by a set
  of relations, i.e. a set of pairs of words in the free monoid.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf:=FreeMonoid("a","b");;[127X[104X
    [4X[25Xgap>[125X [27Xx:=GeneratorsOfMonoid(f);[127X[104X
    [4X[28X[ a, b ][128X[104X
    [4X[25Xgap>[125X [27Xe:=Identity(f);[127X[104X
    [4X[28X<identity ...>[128X[104X
    [4X[25Xgap>[125X [27Xm:=f/[ [x[1]*x[2],e] ];[127X[104X
    [4X[28X<fp monoid on the generators [ a, b ]>[128X[104X
    [4X[25Xgap>[125X [27XRelationsOfFpMonoid(m);[127X[104X
    [4X[28X[ [ a*b, <identity ...> ] ][128X[104X
  [4X[32X[104X
  
  [33X[0;0YNotice  that for [5XGAP[105X a finitely presented monoid is not a finitely presented
  semigroup.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XIsFpSemigroup(m);[127X[104X
    [4X[28Xfalse[128X[104X
  [4X[32X[104X
  
  [33X[0;0YHowever,  one  can  build  a finitely presented semigroup isomorphic to that
  finitely presented monoid (see [2XIsomorphismFpSemigroup[102X ([14X52.2-3[114X)).[133X
  
  [33X[0;0YAlso  note  that  is not possible to refer to the generators by their names.
  These names are not variables, but just display figures. So, if one wants to
  access  the  generators  by  their  names,  one  first  has to introduce the
  respective variables and to assign the generators to them.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XUnbind(a);[127X[104X
    [4X[25Xgap>[125X [27Xf:=FreeSemigroup("a","b");;[127X[104X
    [4X[25Xgap>[125X [27Xx:=GeneratorsOfSemigroup(f);;[127X[104X
    [4X[25Xgap>[125X [27Xs:=f/[ [x[1]*x[2],x[2]*x[1]] ];;[127X[104X
    [4X[25Xgap>[125X [27Xa;[127X[104X
    [4X[28XError, Variable: 'a' must have a value[128X[104X
    [4X[25Xgap>[125X [27Xa:=GeneratorsOfSemigroup(s)[1];[127X[104X
    [4X[28Xa[128X[104X
    [4X[25Xgap>[125X [27Xb:=GeneratorsOfSemigroup(s)[2];[127X[104X
    [4X[28Xb[128X[104X
    [4X[25Xgap>[125X [27Xa in f;[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xa in s;[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [33X[0;0YThe  generators of the free semigroup (resp. free monoid) are different from
  the generators of the finitely presented semigroup (resp. finitely presented
  monoid)  (even though they are displayed by the same names). This means that
  words  in  the  generators of the free semigroup (resp. free monoid) are not
  elements  of  the  finitely  presented  semigroup  (resp. finitely presented
  monoid).  Conversely  elements  of  the  finitely presented semigroup (resp.
  finitely  presented  monoid) are not words of the free semigroup (resp. free
  monoid).[133X
  
  [33X[0;0YCalculations  comparing  elements of an finitely presented semigroup may run
  into  problems:  there  are  finitely  presented  semigroups  for  which  no
  algorithm  exists  (it  is known that no such algorithm can exist) that will
  tell  for  two  arbitrary  words in the generators whether the corresponding
  elements  in  the  finitely  presented  semigroup  are  equal. Therefore the
  methods used by [5XGAP[105X to compute in finitely presented semigroups may run into
  warning  errors, run out of memory or run forever. If the finitely presented
  semigroup is (by theory) known to be finite the algorithms are guaranteed to
  terminate (if there is sufficient memory available), but the time needed for
  the  calculation  cannot  be  bounded  a  priori.  The  same can be said for
  monoids. (See [14X52.6[114X.)[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xa*b=a^5;[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xa^5*b^2*a=a^6*b^2;[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [33X[0;0YNote  that  elements  of  a finitely presented semigroup (or monoid) are not
  printed in a unique way:[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xa^5*b^2*a;[127X[104X
    [4X[28Xa^5*b^2*a[128X[104X
    [4X[25Xgap>[125X [27Xa^6*b^2;[127X[104X
    [4X[28Xa^6*b^2[128X[104X
  [4X[32X[104X
  
  
  [1X52.1 [33X[0;0YIsSubsemigroupFpSemigroup (Filter)[133X[101X
  
  [1X52.1-1 IsSubsemigroupFpSemigroup[101X
  
  [29X[2XIsSubsemigroupFpSemigroup[102X( [3Xt[103X ) [32X attribute
  
  [33X[0;0Ytrue  if [3Xt[103X is a finitely presented semigroup or a subsemigroup of a finitely
  presented   semigroup  (generally  speaking,  such  a  subsemigroup  can  be
  constructed  with  [10XSemigroup([3Xgens[103X[10X)[110X,  where  [3Xgens[103X  is a list of elements of a
  finitely presented semigroup).[133X
  
  [1X52.1-2 IsSubmonoidFpMonoid[101X
  
  [29X[2XIsSubmonoidFpMonoid[102X( [3Xt[103X ) [32X attribute
  
  [33X[0;0Ytrue  if  [3Xt[103X  is  a  finitely  presented  monoid or a submonoid of a finitely
  presented  monoid  (generally  speaking, such a semigroup can be constructed
  with  [10XMonoid([3Xgens[103X[10X)[110X, where [3Xgens[103X is a list of elements of a finitely presented
  monoid).[133X
  
  [33X[0;0YA submonoid of a monoid has the same identity as the monoid.[133X
  
  [1X52.1-3 IsFpSemigroup[101X
  
  [29X[2XIsFpSemigroup[102X( [3Xs[103X ) [32X property
  
  [33X[0;0Yis  a synonym for [10XIsSubsemigroupFpSemigroup([3Xs[103X[10X)[110X and [10XIsWholeFamily([3Xs[103X[10X)[110X (this is
  because  a subsemigroup of a finitely presented semigroup is not necessarily
  finitely presented).[133X
  
  [1X52.1-4 IsFpMonoid[101X
  
  [29X[2XIsFpMonoid[102X( [3Xm[103X ) [32X property
  
  [33X[0;0Yis  a  synonym  for  [10XIsSubmonoidFpMonoid([3Xm[103X[10X)[110X  and  [10XIsWholeFamily([3Xm[103X[10X)[110X  (this is
  because  a  submonoid  of  a  finitely  presented  monoid is not necessarily
  finitely presented).[133X
  
  [1X52.1-5 IsElementOfFpSemigroup[101X
  
  [29X[2XIsElementOfFpSemigroup[102X( [3Xelm[103X ) [32X Category
  
  [33X[0;0Yreturns true if [3Xelm[103X is an element of a finitely presented semigroup.[133X
  
  [1X52.1-6 IsElementOfFpMonoid[101X
  
  [29X[2XIsElementOfFpMonoid[102X( [3Xelm[103X ) [32X Category
  
  [33X[0;0Yreturns true if [3Xelm[103X is an element of a finitely presented monoid.[133X
  
  [1X52.1-7 FpGrpMonSmgOfFpGrpMonSmgElement[101X
  
  [29X[2XFpGrpMonSmgOfFpGrpMonSmgElement[102X( [3Xelm[103X ) [32X operation
  
  [33X[0;0Yreturns  the  finitely  presented  group,  monoid  or semigroup to which [3Xelm[103X
  belongs[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf := FreeSemigroup("a","b");;[127X[104X
    [4X[25Xgap>[125X [27Xa := GeneratorsOfSemigroup( f )[ 1 ];;[127X[104X
    [4X[25Xgap>[125X [27Xb := GeneratorsOfSemigroup( f )[ 2 ];;[127X[104X
    [4X[25Xgap>[125X [27Xs := f / [ [ a^2 , a*b ] ];;[127X[104X
    [4X[25Xgap>[125X [27XIsFpSemigroup( s );[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xt := Semigroup( [ GeneratorsOfSemigroup( s )[ 1 ] ]);[127X[104X
    [4X[28X<semigroup with 1 generator>[128X[104X
    [4X[25Xgap>[125X [27XIsSubsemigroupFpSemigroup( t );[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XIsElementOfFpSemigroup( GeneratorsOfSemigroup( t )[ 1 ] );[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  
  [1X52.2 [33X[0;0YCreating Finitely Presented Semigroups[133X[101X
  
  [1X52.2-1 \/[101X
  
  [29X[2X\/[102X( [3XF[103X, [3Xrels[103X ) [32X method
  
  [33X[0;0Ycreates  a  finitely  presented semigroup given by the presentation [22X⟨ gens ∣
  [3Xrels[103X  ⟩[122X  where  [22Xgens[122X  are  the  generators  of the free semigroup [3XF[103X, and the
  relations  [3Xrels[103X  are entered as pairs of words in the generators of the free
  semigroup.[133X
  
  [33X[0;0YThe same result is obtained with the infix operator [10X/[110X, i.e., as [3XF[103X [10X/[110X [3Xrels[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf:=FreeSemigroup(3);;[127X[104X
    [4X[25Xgap>[125X [27Xs:=GeneratorsOfSemigroup(f);;[127X[104X
    [4X[25Xgap>[125X [27Xf/[ [s[1]*s[2]*s[1],s[1]] , [s[2]^4,s[1]] ];[127X[104X
    [4X[28X<fp semigroup on the generators [ s1, s2, s3 ]>[128X[104X
  [4X[32X[104X
  
  [1X52.2-2 FactorFreeSemigroupByRelations[101X
  
  [29X[2XFactorFreeSemigroupByRelations[102X( [3Xf[103X, [3Xrels[103X ) [32X function
  
  [33X[0;0Yfor a free semigroup [3Xf[103X and [3Xrels[103X is a list of pairs of elements of [3Xf[103X. Returns
  the  finitely  presented  semigroup  which is the quotient of [3Xf[103X by the least
  congruence on [3Xf[103X generated by the pairs in [3Xrels[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27XFactorFreeSemigroupByRelations(f,[127X[104X
    [4X[25X>[125X [27X                           [[s[1]*s[2]*s[1],s[1]],[s[2]^4,s[1]]]);[127X[104X
    [4X[28X<fp semigroup on the generators [ s1, s2, s3 ]>[128X[104X
  [4X[32X[104X
  
  [1X52.2-3 IsomorphismFpSemigroup[101X
  
  [29X[2XIsomorphismFpSemigroup[102X( [3Xs[103X ) [32X attribute
  
  [33X[0;0Yfor  a  semigroup  [3Xs[103X  returns  an isomorphism from [3Xs[103X to a finitely presented
  semigroup[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf := FreeGroup(2);;[127X[104X
    [4X[25Xgap>[125X [27Xg := f/[f.1^4,f.2^5];[127X[104X
    [4X[28X<fp group on the generators [ f1, f2 ]>[128X[104X
    [4X[25Xgap>[125X [27Xphi := IsomorphismFpSemigroup(g);[127X[104X
    [4X[28XMappingByFunction( <fp group on the generators [128X[104X
    [4X[28X[ f1, f2 ]>, <fp semigroup on the generators [128X[104X
    [4X[28X[ <identity ...>, f1^-1, f1, f2^-1, f2 [128X[104X
    [4X[28X ]>, function( x ) ... end, function( x ) ... end )[128X[104X
    [4X[25Xgap>[125X [27Xs := Range(phi);[127X[104X
    [4X[28X<fp semigroup on the generators [ <identity ...>, f1^-1, f1, f2^-1, [128X[104X
    [4X[28X  f2 ]>[128X[104X
  [4X[32X[104X
  
  
  [1X52.3 [33X[0;0YComparison of Elements of Finitely Presented Semigroups[133X[101X
  
  [1X52.3-1 \=[101X
  
  [29X[2X\=[102X( [3Xa[103X, [3Xb[103X ) [32X method
  
  [33X[0;0YTwo  elements  [3Xa[103X,  [3Xb[103X of a finitely presented semigroup are equal if they are
  equal  in  the  semigroup. Nevertheless they may be represented as different
  words  in  the  generators. Because of the fundamental problems mentioned in
  the  introduction  to this chapter such a test may take a very long time and
  cannot be guaranteed to finish (see [14X52.6[114X).[133X
  
  
  [1X52.4 [33X[0;0YPreimages in the Free Semigroup[133X[101X
  
  [33X[0;0YElements   of  a  finitely  presented  semigroup  are  not  words,  but  are
  represented using a word from the free semigroup as representative.[133X
  
  [1X52.4-1 UnderlyingElement[101X
  
  [29X[2XUnderlyingElement[102X( [3Xelm[103X ) [32X operation
  
  [33X[0;0Yfor  an  element  [3Xelm[103X of a finitely presented semigroup, it returns the word
  from the free semigroup that is used as a representative for [3Xelm[103X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf := FreeSemigroup( "a" , "b" );;[127X[104X
    [4X[25Xgap>[125X [27Xa := GeneratorsOfSemigroup( f )[ 1 ];;[127X[104X
    [4X[25Xgap>[125X [27Xb := GeneratorsOfSemigroup( f )[ 2 ];;[127X[104X
    [4X[25Xgap>[125X [27Xs := f / [ [ a^3 , a ] , [ b^3 , b ] , [ a*b , b*a ] ];[127X[104X
    [4X[28X<fp semigroup on the generators [ a, b ]>[128X[104X
    [4X[25Xgap>[125X [27Xw := GeneratorsOfSemigroup(s)[1] * GeneratorsOfSemigroup(s)[2];[127X[104X
    [4X[28Xa*b[128X[104X
    [4X[25Xgap>[125X [27XIsWord (w );[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xue := UnderlyingElement( w );[127X[104X
    [4X[28Xa*b[128X[104X
    [4X[25Xgap>[125X [27XIsWord( ue );[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [1X52.4-2 ElementOfFpSemigroup[101X
  
  [29X[2XElementOfFpSemigroup[102X( [3Xfam[103X, [3Xw[103X ) [32X operation
  
  [33X[0;0Yfor  a family [3Xfam[103X of elements of a finitely presented semigroup and a word [3Xw[103X
  in  the  free  generators underlying this finitely presented semigroup, this
  operation  creates  the element of the finitely presented semigroup with the
  representative [3Xw[103X in the free semigroup.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xfam := FamilyObj( GeneratorsOfSemigroup(s)[1] );;[127X[104X
    [4X[25Xgap>[125X [27Xge := ElementOfFpSemigroup( fam, a*b );[127X[104X
    [4X[28Xa*b[128X[104X
    [4X[25Xgap>[125X [27Xge in f;[127X[104X
    [4X[28Xfalse[128X[104X
    [4X[25Xgap>[125X [27Xge in s;[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [1X52.4-3 FreeSemigroupOfFpSemigroup[101X
  
  [29X[2XFreeSemigroupOfFpSemigroup[102X( [3Xs[103X ) [32X attribute
  
  [33X[0;0Yreturns  the  underlying free semigroup for the finitely presented semigroup
  [3Xs[103X, ie, the free semigroup over which [3Xs[103X is defined as a quotient (this is the
  free    semigroup   generated   by   the   free   generators   provided   by
  [10XFreeGeneratorsOfFpSemigroup([3Xs[103X[10X)[110X).[133X
  
  [1X52.4-4 FreeGeneratorsOfFpSemigroup[101X
  
  [29X[2XFreeGeneratorsOfFpSemigroup[102X( [3Xs[103X ) [32X attribute
  
  [33X[0;0Yreturns  the  underlying  free generators corresponding to the generators of
  the finitely presented semigroup [3Xs[103X.[133X
  
  [1X52.4-5 RelationsOfFpSemigroup[101X
  
  [29X[2XRelationsOfFpSemigroup[102X( [3Xs[103X ) [32X attribute
  
  [33X[0;0Yreturns  the  relations  of  the  finitely presented semigroup [3Xs[103X as pairs of
  words in the free generators provided by [10XFreeGeneratorsOfFpSemigroup([3Xs[103X[10X)[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf := FreeSemigroup( "a" , "b" );;[127X[104X
    [4X[25Xgap>[125X [27Xa := GeneratorsOfSemigroup( f )[ 1 ];;[127X[104X
    [4X[25Xgap>[125X [27Xb := GeneratorsOfSemigroup( f )[ 2 ];;[127X[104X
    [4X[25Xgap>[125X [27Xs := f / [ [ a^3 , a ] , [ b^3 , b ] , [ a*b , b*a ] ];[127X[104X
    [4X[28X<fp semigroup on the generators [ a, b ]>[128X[104X
    [4X[25Xgap>[125X [27XSize( s );[127X[104X
    [4X[28X8[128X[104X
    [4X[25Xgap>[125X [27Xfs := FreeSemigroupOfFpSemigroup( s );;[127X[104X
    [4X[25Xgap>[125X [27Xf = fs;[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XFreeGeneratorsOfFpSemigroup( s );[127X[104X
    [4X[28X[ a, b ][128X[104X
    [4X[25Xgap>[125X [27XRelationsOfFpSemigroup( s );[127X[104X
    [4X[28X[ [ a^3, a ], [ b^3, b ], [ a*b, b*a ] ][128X[104X
  [4X[32X[104X
  
  
  [1X52.5 [33X[0;0YFinitely presented monoids[133X[101X
  
  [33X[0;0YThe  functionality  available  for finitely presented monoids is essentially
  the  same  as that available for finitely presented semigroups, and thus the
  previous  sections  apply  (with  the obvious changes) to finitely presented
  monoids.[133X
  
  [1X52.5-1 \/[101X
  
  [29X[2X\/[102X( [3XF[103X, [3Xrels[103X ) [32X method
  
  [33X[0;0Ycreates  a finitely presented monoid given by the monoid presentation [22X⟨ [3Xgens[103X
  ∣  [3Xrels[103X  ⟩[122X  where  [3Xgens[103X  are  the  generators  of the free monoid [3XF[103X, and the
  relations  [3Xrels[103X  are  entered as pairs of words in both the identity and the
  generators of the free monoid.[133X
  
  [33X[0;0YThe same result is obtained with the infix operator [10X/[110X, i.e., as [10X[3XF[103X[10X/[3Xrels[103X[10X[110X.[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf := FreeMonoid( 3 );[127X[104X
    [4X[28X<free monoid on the generators [ m1, m2, m3 ]>[128X[104X
    [4X[25Xgap>[125X [27Xx := GeneratorsOfMonoid( f );[127X[104X
    [4X[28X[ m1, m2, m3 ][128X[104X
    [4X[25Xgap>[125X [27Xe:= Identity ( f );[127X[104X
    [4X[28X<identity ...>[128X[104X
    [4X[25Xgap>[125X [27Xm := f/[ [x[1]^3,e] , [x[1]*x[2],x[2] ]];[127X[104X
    [4X[28X<fp monoid on the generators [ m1, m2, m3 ]>[128X[104X
  [4X[32X[104X
  
  
  [1X52.6 [33X[0;0YRewriting Systems and the Knuth-Bendix Procedure[133X[101X
  
  [33X[0;0YIf  a  finitely presented semigroup has a confluent rewriting system then it
  has  a  solvable word problem, that is, there is an algorithm to decide when
  two words in the free underlying semigroup represent the same element of the
  finitely  presented  semigroup.  Indeed,  once we have a confluent rewriting
  system,  it  is  possible  to successfully test that two words represent the
  same  element  in  the semigroup, by reducing both words using the rewriting
  system  rules.  This  is,  at  the moment, the method that [5XGAP[105X uses to check
  equality in finitely presented semigroups and monoids.[133X
  
  [1X52.6-1 ReducedConfluentRewritingSystem[101X
  
  [29X[2XReducedConfluentRewritingSystem[102X( [3XS[103X[, [3Xordering[103X] ) [32X attribute
  
  [33X[0;0Yreturns  a  reduced  confluent  rewriting  system  of the finitely presented
  semigroup  or  monoid [3XS[103X with respect to the reduction ordering [3Xordering[103X (see
  [14X34[114X).[133X
  
  [33X[0;0YThe default for [3Xordering[103X is the length plus lexicographic ordering on words,
  also  called  the  shortlex  ordering;  for  the  definition see for example
  [Sim94].[133X
  
  [33X[0;0YNotice  that  this  might  not terminate. In particular, if the semigroup or
  monoid  [3XS[103X  does not have a solvable word problem then it this will certainly
  never end. Also, in this case, the object returned is an immutable rewriting
  system,  because  once  we  have a confluent rewriting system for a finitely
  presented  semigroup  or  monoid we do not want to allow it to change (as it
  was  most  probably  very  time  consuming  to  get  it in the first place).
  Furthermore, this is also an attribute storing object (see [14X13.4[114X).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf := FreeSemigroup( "a" , "b" );;[127X[104X
    [4X[25Xgap>[125X [27Xa := GeneratorsOfSemigroup( f )[ 1 ];;[127X[104X
    [4X[25Xgap>[125X [27Xb := GeneratorsOfSemigroup( f )[ 2 ];;[127X[104X
    [4X[25Xgap>[125X [27Xg := f /  [ [ a^2 , a*b ] , [ a^4 , b] ];;[127X[104X
    [4X[25Xgap>[125X [27Xrws := ReducedConfluentRewritingSystem(g);[127X[104X
    [4X[28XRewriting System for Semigroup( [ a, b ] ) with rules [128X[104X
    [4X[28X[ [ a*b, a^2 ], [ a^4, b ], [ b*a, a^2 ], [ b^2, a^2 ] ][128X[104X
  [4X[32X[104X
  
  [33X[0;0YThe  creation of a reduced confluent rewriting system for a semigroup or for
  a  monoid,  in  [5XGAP[105X,  uses  the  Knuth-Bendix  procedure  for strings, which
  manipulates  a  rewriting  system of the semigroup or monoid and attempts to
  make  it  confluent (See [14X38[114X. See also Sims [Sim94]). (Since the word problem
  for  semigroups/monoids  is  not solvable in general, Knuth-Bendix procedure
  cannot always terminate).[133X
  
  [33X[0;0YIn  order  to  apply this procedure we will build a rewriting system for the
  semigroup  or monoid, which we will call a [13XKnuth-Bendix Rewriting System[113X (we
  need  to  define  this  because  we  need the rewriting system to store some
  information needed for the implementation of the Knuth-Bendix procedure).[133X
  
  [33X[0;0YActually,  Knuth-Bendix  Rewriting  Systems  do not only serve this purpose.
  Indeed these are objects which are mutable and which can be manipulated (see
  [14X38[114X).[133X
  
  [33X[0;0YNote  that  the  implemented  version  of the Knuth-Bendix procedure, in [5XGAP[105X
  returns,  if  it  terminates, a confluent rewriting system which is reduced.
  Also,  a  reduction  ordering  has to be specified when building a rewriting
  system.  If  none  is specified, the shortlex ordering is assumed (note that
  the  procedure  may  terminate  with a certain ordering and not with another
  one).[133X
  
  [33X[0;0YOn Unix systems it is possible to replace the built-in Knuth-Bendix by other
  routines, for example the package [5Xkbmag[105X offers such a possibility.[133X
  
  [1X52.6-2 KB_REW[101X
  
  [29X[2XKB_REW[102X[32X global variable
  [29X[2XGAPKB_REW[102X[32X global variable
  
  [33X[0;0Y[10XKB_REW[110X  is  a global record variable whose components contain functions used
  for Knuth-Bendix. By default [10XKB_REW[110X is assigned to [10XGAPKB_REW[110X, which contains
  the KB functions provided by the GAP library.[133X
  
  
  [1X52.6-3 [33X[0;0YKnuthBendixRewritingSystem[133X[101X
  
  [29X[2XKnuthBendixRewritingSystem[102X( [3Xs[103X, [3Xwordord[103X ) [32X function
  [29X[2XKnuthBendixRewritingSystem[102X( [3Xm[103X, [3Xwordord[103X ) [32X function
  
  [33X[0;0Yin  the  first  form,  for  a  semigroup  [3Xs[103X and a reduction ordering for the
  underlying  free  semigroup, it returns the Knuth-Bendix rewriting system of
  the  finitely presented semigroup [3Xs[103X using the reduction ordering [3Xwordord[103X. In
  the  second form, for a monoid [3Xm[103X and a reduction ordering for the underlying
  free  monoid,  it  returns the Knuth-Bendix rewriting system of the finitely
  presented monoid [3Xm[103X using the reduction ordering [3Xwordord[103X.[133X
  
  [1X52.6-4 SemigroupOfRewritingSystem[101X
  
  [29X[2XSemigroupOfRewritingSystem[102X( [3Xrws[103X ) [32X attribute
  
  [33X[0;0Yreturns the semigroup over which [3Xrws[103X is a rewriting system[133X
  
  [1X52.6-5 MonoidOfRewritingSystem[101X
  
  [29X[2XMonoidOfRewritingSystem[102X( [3Xrws[103X ) [32X attribute
  
  [33X[0;0Yreturns the monoid over which [3Xrws[103X is a rewriting system[133X
  
  [1X52.6-6 FreeSemigroupOfRewritingSystem[101X
  
  [29X[2XFreeSemigroupOfRewritingSystem[102X( [3Xrws[103X ) [32X attribute
  
  [33X[0;0Yreturns the free semigroup over which [3Xrws[103X is a rewriting system[133X
  
  [1X52.6-7 FreeMonoidOfRewritingSystem[101X
  
  [29X[2XFreeMonoidOfRewritingSystem[102X( [3Xrws[103X ) [32X attribute
  
  [33X[0;0Yreturns the free monoid over which [3Xrws[103X is a rewriting system[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xf1 := FreeSemigroupOfRewritingSystem(rws);[127X[104X
    [4X[28X<free semigroup on the generators [ a, b ]>[128X[104X
    [4X[25Xgap>[125X [27Xf1=f;[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27Xg1 := SemigroupOfRewritingSystem(rws);[127X[104X
    [4X[28X<fp semigroup on the generators [ a, b ]>[128X[104X
    [4X[25Xgap>[125X [27Xg1=g;[127X[104X
    [4X[28Xtrue[128X[104X
  [4X[32X[104X
  
  [33X[0;0YAs  mentioned  before,  having  a confluent rewriting system, one can decide
  whether  two  words  represent  the  same  element  of  a finitely presented
  semigroup (or finitely presented monoid).[133X
  
  [4X[32X  Example  [32X[104X
    [4X[25Xgap>[125X [27Xa := GeneratorsOfSemigroup( g )[ 1 ];[127X[104X
    [4X[28Xa[128X[104X
    [4X[25Xgap>[125X [27Xb := GeneratorsOfSemigroup( g )[ 2 ];[127X[104X
    [4X[28Xb[128X[104X
    [4X[25Xgap>[125X [27Xa*b*a=a^3;[127X[104X
    [4X[28Xtrue[128X[104X
    [4X[25Xgap>[125X [27XReducedForm(rws,UnderlyingElement(a*b*a));[127X[104X
    [4X[28Xa^3[128X[104X
    [4X[25Xgap>[125X [27XReducedForm(rws,UnderlyingElement(a^3));[127X[104X
    [4X[28Xa^3[128X[104X
  [4X[32X[104X
  
  
  [1X52.7 [33X[0;0YTodd-Coxeter Procedure[133X[101X
  
  [33X[0;0YThis   procedure   gives   a   standard  way  of  finding  a  transformation
  representation  of  a  finitely  presented  semigroup.  Usually one does not
  explicitly  call  this procedure but uses [2XIsomorphismTransformationSemigroup[102X
  ([14X53.7-5[114X).[133X
  
  [1X52.7-1 CosetTableOfFpSemigroup[101X
  
  [29X[2XCosetTableOfFpSemigroup[102X( [3Xr[103X ) [32X attribute
  
  [33X[0;0Y[3Xr[103X  is  a  right congruence of an fp-semigroup [3XS[103X. This attribute is the coset
  table  of FP semigroup [3XS[103X on a right congruence [3Xr[103X. Given a right congruence [3Xr[103X
  we represent [3XS[103X as a set of transformations of the congruence classes of [3Xr[103X.[133X
  
  [33X[0;0YThe  images  of the cosets under the generators are compiled in a list [3Xtable[103X
  such that [3Xtable[i][s][103X contains the image of coset [3Xs[103X under generator [3Xi[103X.[133X
  
