<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<!-- %% -->
<!-- %A  fpsemi.msk                GAP documentation                Isabel Araújo -->
<!-- %% -->
<!-- %A  @(#)<M>Id: fpsemi.msk,v 1.27 2002/08/09 17:49:33 gap Exp </M> -->
<!-- %% -->
<!-- %Y  (C) 1999 School Math and Comp. Sci., University of St Andrews, Scotland -->
<!-- %Y  Copyright (C) 2002 The GAP Group -->
<!-- %% -->
<Chapter Label="Finitely Presented Semigroups and Monoids">
<Heading>Finitely Presented Semigroups and Monoids</Heading>

A <E>finitely presented semigroup</E> (resp. <E>finitely presented monoid</E>)
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).
<P/>
Finitely 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.
<P/>
<Example><![CDATA[
gap> f:=FreeSemigroup("a","b");;
gap> x:=GeneratorsOfSemigroup(f);;
gap> s:=f/[ [x[1]*x[2],x[2]*x[1]] ];
<fp semigroup on the generators [ a, b ]>
gap> GeneratorsOfSemigroup(s);
[ a, b ]
gap> RelationsOfFpSemigroup(s);
[ [ a*b, b*a ] ]
]]></Example>
<P/>
Finitely 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. 
<P/>
<Example><![CDATA[
gap> f:=FreeMonoid("a","b");;
gap> x:=GeneratorsOfMonoid(f);
[ a, b ]
gap> e:=Identity(f);
<identity ...>
gap> m:=f/[ [x[1]*x[2],e] ];
<fp monoid on the generators [ a, b ]>
gap> RelationsOfFpMonoid(m);
[ [ a*b, <identity ...> ] ]
]]></Example>
<P/>
Notice that for &GAP; a finitely presented monoid is not a finitely 
presented semigroup.
<P/>
<Example><![CDATA[
gap> IsFpSemigroup(m);
false
]]></Example>
<P/>
However, one can build a finitely presented semigroup isomorphic
to that finitely presented monoid (see <Ref Func="IsomorphismFpSemigroup"/>).
<P/>
Also 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.
 
<Example><![CDATA[
gap> Unbind(a);
gap> f:=FreeSemigroup("a","b");;
gap> x:=GeneratorsOfSemigroup(f);;
gap> s:=f/[ [x[1]*x[2],x[2]*x[1]] ];;
gap> a;
Error, Variable: 'a' must have a value
gap> a:=GeneratorsOfSemigroup(s)[1];
a
gap> b:=GeneratorsOfSemigroup(s)[2];
b
gap> a in f;
false
gap> a in s;
true
]]></Example>
<P/>
The 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).
<P/>
Calculations 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 &GAP; 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 <Ref Sect="Rewriting Systems and the Knuth-Bendix Procedure"/>.)
<P/>
<Example><![CDATA[
gap> a*b=a^5;
false
gap> a^5*b^2*a=a^6*b^2;
true
]]></Example>
<P/>
Note that elements of a finitely presented semigroup (or monoid) are not 
printed in a unique way:
<P/>
<Example><![CDATA[
gap> a^5*b^2*a;
a^5*b^2*a
gap> a^6*b^2;
a^6*b^2
]]></Example>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="sect:IsSubsemigroupFpSemigroup">
<Heading>IsSubsemigroupFpSemigroup (Filter)</Heading>

<#Include Label="IsSubsemigroupFpSemigroup">
<#Include Label="IsSubmonoidFpMonoid">
<#Include Label="IsFpSemigroup">
<#Include Label="IsFpMonoid">
<#Include Label="IsElementOfFpSemigroup">
<#Include Label="IsElementOfFpMonoid">
<#Include Label="FpGrpMonSmgOfFpGrpMonSmgElement">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Creating Finitely Presented Semigroups">
<Heading>Creating Finitely Presented Semigroups</Heading>

<ManSection>
<Meth Name="\/" Arg="F, rels"
 Label="for a free semigroup and a list of pairs of elements"/>

<Description>
<Index Subkey="of free semigroup">quotient</Index> 
creates a finitely presented semigroup given by the presentation
<M>\langle gens \mid <A>rels</A> \rangle</M>
where <M>gens</M> are the generators of the free
semigroup <A>F</A>, and the relations <A>rels</A> are entered as pairs of
words in the generators of the free semigroup. 
<P/>
The same result is obtained with the infix operator <C>/</C>,
i.e., as <A>F</A> <C>/</C> <A>rels</A>.
<P/>
<Example><![CDATA[
gap> f:=FreeSemigroup(3);;
gap> s:=GeneratorsOfSemigroup(f);;
gap> f/[ [s[1]*s[2]*s[1],s[1]] , [s[2]^4,s[1]] ];
<fp semigroup on the generators [ s1, s2, s3 ]>
]]></Example>
</Description>
</ManSection>

<#Include Label="FactorFreeSemigroupByRelations">
<#Include Label="IsomorphismFpSemigroup">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Comparison of Elements of Finitely Presented Semigroups">
<Heading>Comparison of Elements of Finitely Presented Semigroups</Heading>

<ManSection>
<Meth Name="\=" Arg="a, b" Label="for two elements in a f.p. semigroup"/>

<Description>
<Index Subkey="fp semigroup elements">comparison</Index>
Two elements <A>a</A>, <A>b</A> 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 <Ref Sect="Rewriting Systems and the Knuth-Bendix Procedure"/>).
</Description>
</ManSection>

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Preimages in the Free Semigroup">
<Heading>Preimages in the Free Semigroup</Heading>

Elements of a finitely presented semigroup are not words, but are represented
using a word from the free semigroup as representative. 
<P/>
<ManSection>
<Oper Name="UnderlyingElement" Arg='elm' Label="fp semigroup elements"/>

<Description>
for an element <A>elm</A> of a finitely presented semigroup, it 
returns the word from the free semigroup that is used as a
representative for <A>elm</A>.
<P/>
<Example><![CDATA[
gap> f := FreeSemigroup( "a" , "b" );;
gap> a := GeneratorsOfSemigroup( f )[ 1 ];;
gap> b := GeneratorsOfSemigroup( f )[ 2 ];;
gap> s := f / [ [ a^3 , a ] , [ b^3 , b ] , [ a*b , b*a ] ];
<fp semigroup on the generators [ a, b ]>
gap> w := GeneratorsOfSemigroup(s)[1] * GeneratorsOfSemigroup(s)[2];
a*b
gap> IsWord (w );
false
gap> ue := UnderlyingElement( w );
a*b
gap> IsWord( ue );
true
]]></Example>
</Description>
</ManSection>

<#Include Label="ElementOfFpSemigroup">
<#Include Label="FreeSemigroupOfFpSemigroup">
<#Include Label="FreeGeneratorsOfFpSemigroup">
<#Include Label="RelationsOfFpSemigroup">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Finitely presented monoids">
<Heading>Finitely presented monoids</Heading>

The 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.

<ManSection>
<Meth Name="\/" Arg="F, rels"
 Label="for a free monoid and a list of pairs of elements"/>

<Description>
<Index Subkey="of free monoid">quotient</Index>
creates a finitely presented monoid given by the monoid presentation 
<M>\langle <A>gens</A> \mid <A>rels</A> \rangle</M>
where <A>gens</A> are the generators of 
the free monoid <A>F</A>, and the relations <A>rels</A> are entered as pairs of 
words in both the identity and the generators of the free monoid.
<P/>
The same result is obtained with the infix operator <C>/</C>,
i.e., as <C><A>F</A>/<A>rels</A></C>.
<P/>
<Example><![CDATA[
gap> f := FreeMonoid( 3 );
<free monoid on the generators [ m1, m2, m3 ]>
gap> x := GeneratorsOfMonoid( f );
[ m1, m2, m3 ]
gap> e:= Identity ( f );
<identity ...>
gap> m := f/[ [x[1]^3,e] , [x[1]*x[2],x[2] ]];
<fp monoid on the generators [ m1, m2, m3 ]>
]]></Example>
</Description>
</ManSection>

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Rewriting Systems and the Knuth-Bendix Procedure">
<Heading>Rewriting Systems and the Knuth-Bendix Procedure</Heading>

If 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 &GAP; uses to check equality
in finitely presented semigroups and monoids.
<P/>
<#Include Label="ReducedConfluentRewritingSystem">
<#Include Label="KB_REW">


<ManSection>
<Heading>KnuthBendixRewritingSystem</Heading>
<Oper Name="KnuthBendixRewritingSystem" Arg='s, wordord'
 Label="for a semigroup and a reduction ordering"/>
<Oper Name="KnuthBendixRewritingSystem" Arg='m, wordord'
 Label="for a monoid and a reduction ordering"/>

<Description>
in the first form, for a semigroup <A>s</A> and a reduction ordering
for the underlying free semigroup, it returns the Knuth-Bendix 
rewriting system of the finitely presented semigroup <A>s</A> using the 
reduction ordering <A>wordord</A>.
In the second form, for a monoid <A>m</A> and a reduction ordering
for the underlying free monoid, it returns the Knuth-Bendix 
rewriting system of the finitely presented monoid <A>m</A> using the 
reduction ordering <A>wordord</A>.
</Description>
</ManSection>


<#Include Label="SemigroupOfRewritingSystem">
<#Include Label="MonoidOfRewritingSystem">
<#Include Label="FreeSemigroupOfRewritingSystem">
<#Include Label="FreeMonoidOfRewritingSystem">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Todd-Coxeter Procedure">
<Heading>Todd-Coxeter Procedure</Heading>

This 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
<Ref Func="IsomorphismTransformationSemigroup"/>.
<!--or <Ref Func="HomomorphismTransformationSemigroup"/>-->

<#Include Label="CosetTableOfFpSemigroup">

</Section>
</Chapter>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<!-- %% -->
<!-- %E -->

