This chapter describes functions to construct rewriting systems for finitely presented groups which store rewriting information. The main example used is a presentation of the quaternion group `q8`

with generators \(a,b\) and relators \([a^4, b^4, abab^{-1}, a^2b^2]\).

`‣ FreeRelatorGroup` ( grp ) | ( attribute ) |

`‣ FreeRelatorHomomorphism` ( grp ) | ( attribute ) |

The function `FreeRelatorGroup`

returns a free group on the set of relators of the given fp-group `G`

. If `HasName(G)`

is `true`

then a name is automatically assigned to the free group.

The function `FreeRelatorHomomorphism`

returns the group homomorphism from the free group on the relators to the free group on the generators of `G`

, mapping each generator to the corresponding word.

gap> F := FreeGroup( 2 );; gap> a := F.1;; b:= F.2;; gap> rels := [ a^4, b^4, a*b*a*b^-1, a^2*b^2];; gap> q8 := F/rels;; gap> SetName( q8, "q8" ); gap> frq8 := FreeRelatorGroup( q8 ); q8_R gap> GeneratorsOfGroup( frq8 ); [ q8_R1, q8_R2, q8_R3, q8_R4] gap> frhomq8 := FreeRelatorHomomorphism( q8 ); [ q8_R1, q8_R2, q8_R3, q8_R4] -> [ f1^4, f2^4, f1*f2*f1*f2^-1, f1^2*f2^2]

`‣ MonoidPresentationFpGroup` ( grp ) | ( attribute ) |

`‣ ArrangementOfMonoidGenerators` ( grp ) | ( attribute ) |

`‣ FreeGroupOfPresentation` ( mon ) | ( attribute ) |

`‣ GroupRelatorsOfPresentation` ( mon ) | ( attribute ) |

`‣ InverseRelatorsOfPresentation` ( mon ) | ( attribute ) |

`‣ HomomorphismOfPresentation` ( mon ) | ( attribute ) |

A monoid presentation for a finitely presented group `G`

has two monoid generators \(g^+,g^-\) for each group generator \(g\). The relators of the monoid presentation comprise the group relators, and relators \(g^+g^-\) specifying the inverses. The function `MonoidPresentationFpGroup`

returns the monoid presentation derived in this way from an fp-presentation.

The function `FreeGroupOfPresentation`

returns the free group on the monoid generators.

The function `GroupRelatorsOfPresentation`

returns those relators of the monoid which correspond to the relators of the group. All negative powers in the group relators are converted to positive powers of the \(g^-\). The function `InverseRelatorsOfPresentation`

returns relators which specify the inverse pairs of the monoid generators.

The function `HomomorphismOfPresentation`

returns the homomorphism from the free group of the monoid presentation to the free group of the group presentation.

The attribute `ArrangementOfMonoidGenerators`

will be discussed before the second example in the next section.

In the example below, the four monoid generators \(a^+, b^+, a^-, b^-\) are named `q8_M1, q8_M2, q8_M3, q8_M4`

respectively.

gap> mon := MonoidPresentationFpGroup( q8 ); monoid presentation for an fp-group with homomorphism [ [ q8_M1, q8_M2, q8_M3, q8_M4 ], [ f1, f2, f1^-1, f2^-1 ] ] gap> fgmon := FreeGroupOfPresentation( mon); <free group on the generators [ q8_Ml, q8_M2, q8_M3, q8_M4]> gap> genfgmon := GeneratorsOfGroup( fgmon); [ q8_Ml, q8_M2, q8_M3, q8_M4] gap> gprels := GroupRelatorsOfPresentation( mon ); [ q8_Ml^4, q8_M2^4, q8_Ml*q8_M2*q8_Ml*q8_M4, q8_Ml^2*q8_M2^2] gap> invrels := InverseRelatorsOfPresentation( mon); [ q8_Ml*q8_M3, q8_M2*q8_M4, q8_M3*q8_Ml, q8_M4*q8_M2] gap> hompres := HomomorphismOfPresentation( mon ); [ q8_Ml, q8_M2, q8_M3, q8_M4] -> [ fl, f2, fl^-l, f2^-1 ]

These functions duplicate the standard Knuth Bendix functions which are available in the **GAP** library. There are two reasons for this: (1) these functions were first written before the standard functions were available; (2) we require logged versions of the functions, and these are most conveniently extended versions of the non-logged code.

`‣ RewritingSystemFpGroup` ( grp ) | ( attribute ) |

This function attempts to return a complete rewrite system for the group `G`

obtained from the monoid presentation `mon`

, with a length-lexicographical ordering on the words in `fgmon`

, by applying Knuth-Bendix completion. Such a rewrite system can be obtained for all finite groups. The rewrite rules are (partially) ordered, starting with the inverse relators, followed by the rules which reduce the word length the most.

In our `q8`

example there are 16 rewrite rules in the rewriting system `rws`

:

\(a^+a^- \to \rm{id}, \quad b^+b^- \to \rm{id}, \quad a^-a^+ \to \rm{id}, \quad b^-b^+ \to \rm{id}, \) |

\(a^{+2}b^- \to b^+, \quad a^{+2}b^+ \to b^-, \quad a^{+3} \to a^-, \quad b^{-2} \to a^{+2}, \quad b^-a^- \to a^+b^-, \quad b^-a^+ \to a^+b^+, \) |

\(a^-b^- \to a^+b^+, \quad a^{-2} \to a^{+2}, \quad a^-b^+ \to a^+b^-, \quad b^+a^- \to a^+b^+, \quad b^{+2} \to a^{+2}, \quad b^+a^+ \to a^+b^-. \) |

gap> rws := RewritingSystemFpGroup( q8 ); [ [q8_Ml*q8_M3, <identity ...>], [ q8_M2*q8_M4, <identity ...> ], [q8_M3*q8_Ml, <identity ...>], [ q8_M4*q8_M2, <identity ...> ], [q8_M1^2*q8_M4, q8_M2], [q8_Ml^2*q8_M2, q8_M4], [ q8_Ml^3, q8_M3 ], [ q8_M4^2, q8_Ml^2], [ q8_M4*q8_M3, q8_Ml*q8_M4], [ q8_M4*q8_Ml, q8_Ml*q8_M2], [q8_M3*q8_M4, q8_Ml*q8_M2], [ q8_M3^2, q8_Ml^2], [q8_M3*q8_M2, q8_Ml*q8_M4], [ q8_M2*q8_M3, q8_Ml*q8_M2], [q8_M2^2, q8_Ml^2], [ q8_M2*q8_Ml, q8_Ml*q8_M4] ]

The default ordering of the \(2n\) monoid generators is \( [g_1^+,g_2^+,\ldots,g_n^+,g_1^-,g_2^-,\ldots,g_n^-] \). In the case of the two-generator abelian group \(T = \langle a,b ~|~ [a,b] \rangle\) the Knuth-Bendix process starts to generate infinite sets of relations such as \(\{ab^ma^{-1} \to b^m,~ m \geqslant 1\}\). If, using the `ArrangementOfMonoidGenerators`

function, we specify the alternative ordering \( [g_1^+,g_1^-,g_2^+,g_2^-,\ldots] \), then a finite set of rules is obtained.

gap> F := FreeGroup(2);; gap> T := F/[Comm(F.1,F.2)]; <fp group of size infinity on the generators [ f1, f2 ]> gap> SetName( T, "T" ); gap> SetArrangementOfMonoidGenerators( T, [1,-1,2,-2] ); gap> monT := MonoidPresentationFpGroup(T); monoid presentation for an fp-group with homomorphism [ [ T_M1, T_M2, T_M3, T_M4 ], [ f1, f1^-1, f2, f2^-1 ] ] gap> rwsT := RewritingSystemFpGroup( T ); [ [ T_M1*T_M2, <identity ...> ], [ T_M2*T_M1, <identity ...> ], [ T_M3*T_M4, <identity ...> ], [ T_M4*T_M3, <identity ...> ], [ T_M4*T_M2, T_M2*T_M4 ], [ T_M4*T_M1, T_M1*T_M4 ], [ T_M3*T_M2, T_M2*T_M3 ], [ T_M3*T_M1, T_M1*T_M3 ] ]

The functions called by `RewritingSystemFpGroup`

are as follows.

`‣ OnePassReduceWord` ( word, rules ) | ( operation ) |

`‣ ReduceWordKB` ( word, rules ) | ( operation ) |

Assuming that `word`

is an element of a free monoid and `rules`

is a list of ordered pairs of such words, the function `OnePassReduceWord`

searches the list of rules until it finds that the left-hand side of a `rule`

is a `subword`

of `word`

, whereupon it replaces that `subword`

with the right-hand side of the matching rule. The search is continued from the next `rule`

in `rules`

, but using the new `word`

. When the end of `rules`

is reached, one pass is considered to have been made and the reduced `word`

is returned. If no matches are found then the original `word`

is returned.

The function `ReduceWordKB`

repeatedly applies the function `OnePassReduceWord`

until the `word`

remaining contains no left-hand side of a `rule`

as a `subword`

. If `rules`

is a complete rewrite system, then the irreducible `word`

that is returned is unique, otherwise the order of the rules in `rules`

will determine which irreducible word is returned. In the example we see that \(b^9a^9\) reduces to \(ba\) which is not a normal form as we have seen in 2.2-1, where \(b^+a^+ \to a^+b^-\) is the last rule.

gap> monrels := Concatenation( gprels, invrels ); [ q8_Ml^4, q8_M2^4, q8_Ml*q8_M2*q8_Ml*q8_M4, q8_Ml^2*q8_M2^2, q8_Ml*q8_M3, q8_M2*q8_M4, q8_M3*q8_Ml, q8_M4*q8_M2] gap> id := One( monrels[l] );; gap> r0 := List( monrels, r -> [ r, id ] ); [ [ q8_Ml^4, <identity ...> ], [ q8_M2^4, <identity. ..> ], [ q8_Ml*q8_M2*q8_Ml*q8_M4, <identity ...> ], [ q8_Ml^2*q8_M2^2, <identity. ..>], [ q8_Ml*q8_M3, <identity ...> ], [ q8_M2*q8_M4, <identity ...> ], [ q8_M3*q8_Ml, <identity. ..>], [ q8_M4*q8_M2, <identity ...> ] ] gap> ap := genfgmon[l];; bp := genfgmon[2];; ## p for plus gap> am := genfgmon[3];; bm := genfgmon[4];; ## m for minus gap> w0 := bp^9 * ap^9; q8_M2^9*q8_M1^9 gap> w1 := OnePassReduceWord( w0, r0 ); q8_M2^5*q8_M1^5 gap> w2 := ReduceWordKB( w0, r0 ); q8_M2*q8_M1

`‣ OnePassKB` ( rules ) | ( operation ) |

`‣ RewriteReduce` ( rules ) | ( operation ) |

`‣ KnuthBendix` ( rules ) | ( operation ) |

`‣ ShorterRule` ( rule1, rule2 ) | ( operation ) |

The function `OnePassKB`

implements the main loop of the Knuth-Bendix completion algorithm. Rules are compared with each other; all critical pairs are calculated; and the irreducible critical pairs are orientated with respect to the length-lexicographical ordering and added to the rewrite system.

The function `RewriteReduce`

will remove unnecessary rules from a rewrite system. A rule is deemed to be unnecessary if it is implied by the other rules, i.e. if both sides can be reduced to the same thing by the remaining rules.

The function `KnuthBendix`

implements the Knuth-Bendix algorithm, attempting to complete a rewrite system with respect to a length-lexicographic ordering. It calls first `OnePassKB`

, which adds rules, and then (for efficiency) `RewriteReduce`

which removes any unnecessary ones. This procedure is repeated until `OnePassKB`

adds no more rules. It will not always terminate, but for many examples (all finite groups) it will be successful. The rewrite system returned is complete, that is: it will rewrite any given word in the free monoid to a unique irreducible; there is one irreducible for each element of the quotient monoid; and any two elements of the free monoid which are in the same class will rewrite to the same irreducible.

The function `ShorterRule`

gives an ordering on rules. Rules \((g_lg_2,id)\) that identify two generators (or one generator with the inverse of another) come first in the ordering. Otherwise one precedes another if it reduces the length of a word by a greater amount.

One pass of this procedure for our `q8`

example adds 13 relators to the original 8, and these 21 are then reduced to 9. A second pass and reduction gives the list of 16 rules seen above, forming a complete rewrite system for the group. Now \(b^9a^9\) correctly reduces to \(ab^{-1}\).

gap> r1 := OnePassKB( r0 ); [ [ q8_Ml^4, <identity ...> ], [ q8_M2^4, <identity ...> ], [ q8_Ml*q8_M2*q8_Ml*q8_M4, <identity ...> ], [ q8_Ml^2*q8_M2^2, <identity. ..> ], [ q8_Ml*q8_M3, <identity ...> ], [ q8_M2*q8_M4, <identity ...> ], [ q8_M3*q8_Ml, <identity ...> ], [ q8_M4*q8_M2, <identity ...> ], [ q8_M2*q8_Ml*q8_M4, q8_Ml^3], [ q8_Ml*q8_M2^2, q8_Ml^3 ], [ q8_M2^2, q8_Ml^2 ], [q8_Ml^3, q8_M3 ], [ q8_M2^3, q8_M4 ], [ q8_Ml*q8_M2*q8_Ml, q8_M2], [ q8_M2^3, q8_Ml^2*q8_M2], [ q8_M2^2, q8_Ml^2 ], [q8_Ml^2*q8_M2, q8_M4 ], [ q8_Ml^3, q8_M3 ], [ q8_M2*q8_Ml*q8_M4, q8_M3 ], [q8_Ml*q8_M2^2, q8_M3 ], [ q8_M2^3, q8_M4 ] ] gap> Length( r1 ); 21 gap> r1 := RewriteReduce( r1 ); [ [ q8_Ml*q8_M3, <identity ...> ], [ q8_M2^2, q8_Ml^2 ], [ q8_M2*q8_M4, <identity ...> ], [ q8_M3*q8_Ml, <identity ...> ], [ q8_M4*q8_M2, <identity ...> ], [ q8_Ml^3, q8_M3 ], [ q8_Ml^2*q8_M2, q8_M4 ], [ q8_Ml*q8_M2*q8_Ml, q8_M2 ], [ q8_M2*q8_Ml*q8_M4, q8_M3 ] ] gap> Length( r1 ); 9 gap> r2 := KnuthBendix( r1 ); [ [ q8_Ml*q8_M3, <identity ...> ], [ q8_M2*q8_Ml, q8_Ml*q8_M4 ], [ q8_M2^2, q8_Ml^2], [ q8_M2*q8_M3, q8_Ml*q8_M2 ], [ q8_M2*q8_M4, <identity ...> ], [ q8_M3*q8_Ml, <identity ...> ], [ q8_M3*q8_M2, q8_Ml*q8_M4 ], [ q8_M3^2, q8_Ml^2 ], [ q8_M3*q8_M4, q8_Ml*q8_M2 ], [ q8_M4*q8_Ml, q8_Ml*q8_M2 ], [ q8_M4*q8_M2, <identity ...> ], [ q8_M4*q8_M3, q8_Ml*q8_M4 ], [ q8_M4^2, q8_Ml^2], [ q8_Ml^3, q8_M3 ], [q8_Ml^2*q8_M2, q8_M4 ], [ q8_Ml^2*q8_M4, q8_M2 ] ] gap> Length( r2 ); 16 gap> w2 := ReduceWordKB( w0, r2 ); q8_M1*q8_M4

`‣ ElementsOfMonoidPresentation` ( mon ) | ( attribute ) |

The function `ElementsOfMonoidPresentation`

returns a list of normal forms for the elements of the group given by the monoid presentation `mon`

. The normal forms are the least elements in each equivalence class (with respect to length-lex order). When `rules`

is a complete rewrite system for `G`

the list returned is a set of normal forms for the group elements. For `q8`

this list is

\[ [\; {\rm id},\; a^+,\; b^+,\; a^-,\; b^-,\; a^{+2},\; a^+b^+,\; a^+b^-\; ]. \]

gap> elq8 := Elements( q8 ); [ <identity ...>, f1, f1^3, f2, f1^2*f2, f1^2, f1*f2, f1^3*f2 ] gap> elmonq8 := ElementsOfMonoidPresentation( monq8 ); [ <identity. ..>, q8_Ml, q8_M2, q8_M3, q8_M4, q8_Ml^2, q8_Ml*q8_M2, q8_Ml*q8_M4 ]

generated by GAPDoc2HTML