32 Associative Words

Associative words are used to represent free groups, semigroups and monoids in GAP. These words are just sequences of letters (and probably their inverses) in an alphabet. These words can be concatenated and may (in free monoids, respectively free groups) permit computation of an identity and of inverses.

  • IsAssocWord( obj ) C

    is the category of associative words in free semigroups.

  • IsAssocWordWithOne( obj ) C

    is the category of associative words in free monoids (which have an identity).

  • IsAssocWordWithInverse( obj ) C

    is the category of associative words in free groups (which have an inverse).

    It is possible to have various alphabets and each alphabet yields a separate family of associative words. There is no relation whatsoever between words in different families.

    gap> f:=FreeGroup("a","b","c");
    <free group on the generators [a,b,c]>
    gap> gens:=GeneratorsOfGroup(f);;                                    
    gap> w:=gens[1]*gens[2]/gens[3]*gens[2]*gens[1]/gens[1]*gens[3]/gens[2];
    a*b*c^-1*b*c*b^-1
    gap> w^-1;
    b*c^-1*b^-1*c*b^-1*a^-1
    

    Words are displayed as products of letters. The letters are usually printed like f1, f2, ¼, but it is also possible to give user defined names (which can be arbitrary strings) to them. These names do not necessarily identify a unique generator, it is possible to have several letters (even in the same family) that are displayed in the same way. There is no relation between the names of letters and variable names.

    Using homomorphisms it is possible to express elements of a group as words in generators, see Expressing group elements as words in generators.

    Sections

    1. Free Groups, Monoids and Semigroups
    2. Comparison of Words
    3. Operations for Words
    4. Operations for Words by their Syllables
    5. External Representation for Associative Words

    32.1 Free Groups, Monoids and Semigroups

    Usually a family of associative words will be generated by a constructing the free object generated by them.

  • FreeGroup( rank ) F
  • FreeGroup( rank, name ) F
  • FreeGroup( name1, name2, ... ) F
  • FreeGroup( names ) F
  • FreeGroup( infinity, name, init ) F

    Called in the first form, FreeGroup returns a free group on rank generators. Called in the second form, FreeGroup returns a free group on rank generators, printed as name1, name2 etc. Called in the third form, FreeGroup returns a free group on as many generators as arguments, printed as name1, name2 etc. Called in the fourth form, FreeGroup returns a free group on as many generators as the length of the list names, the i-th generator being printed as names[ i]. Called in the fifth form, FreeGroup returns a free group on infinitely many generators, where the first generators are printed by the names in the list init, and the other generators by name and an appended number.

  • IsFreeGroup( obj ) C

  • FreeMonoid( rank ) F
  • FreeMonoid( rank, name ) F
  • FreeMonoid( name1, name2, ... ) F
  • FreeMonoid( names ) F
  • FreeMonoid( infinity, name, init ) F

    Called in the first form, FreeMonoid returns a free monoid on rank generators. Called in the second form, FreeMonoid returns a free monoid on rank generators, printed as name1, name2 etc., that is, each name is the concatenation of the string name and an integer from 1 to range. Called in the third form, FreeMonoid returns a free monoid on as many generators as arguments, printed as name1, name2 etc. Called in the fourth form, FreeMonoid returns a free monoid on as many generators as the length of the list names, the i-th generator being printed as names[ i]. Called in the fifth form, FreeMonoid returns a free monoid on infinitely many generators, where the first generators are printed by the names in the list init, and the other generators by name and an appended number.

  • FreeSemigroup( rank ) F
  • FreeSemigroup( rank, name ) F
  • FreeSemigroup( name1, name2, ... ) F
  • FreeSemigroup( names ) F
  • FreeSemigroup( infinity, name, init ) F

    Called in the first form, FreeSemigroup returns a free semigroup on rank generators. Called in the second form, FreeSemigroup returns a free semigroup on rank generators, printed as name1, name2 etc., that is, each name is the concatenation of the string name and an integer from 1 to range. Called in the third form, FreeSemigroup returns a free semigroup on as many generators as arguments, printed as name1, name2 etc. Called in the fourth form, FreeSemigroup returns a free semigroup on as many generators as the length of the list names, the i-th generator being printed as names[ i]. Called in the fifth form, FreeSemigroup returns a free semigroup on infinitely many generators, where the first generators are printed by the names in the list init, and the other generators by name and an appended number.

    Each free object defines a unique alphabet (and thus a unique family of words) and its generators are simply the words of length one in this alphabet.

    gap> FreeGroup(5);      
    <free group on the generators [ f1, f2, f3, f4, f5 ] >
    gap> FreeGroup("a","b");
    <free group on the generators [a,b]>
    gap> FreeGroup(infinity);
    <free group with infinity generators>
    gap> FreeSemigroup("x","y");
    <free semigroup on the generators [ x, y ]>
    gap> FreeMonoid(7);
    <free monoid on the generators [ m1, m2, m3, m4, m5, m6, m7 ]>
    

    Remember that names are just a help for printing and do not necessarily distinguish letters and it is possible to create arbitrarily weird situations with strange letter names.

    gap> f:=FreeGroup("x","x");gens:=GeneratorsOfGroup(f);;
    <free group on the generators [x,x]>
    gap> gens[1]=gens[2];
    false
    gap> f:=FreeGroup("f1*f2","f2^-1","Group( [ f1, f2 ] )");
    <free group on the generators [ f1*f2, f2^-1, Group( [ f1, f2 ] ) ]>
    gap> gens:=GeneratorsOfGroup(f);;
    gap> gens[1]*gens[2];
    f1*f2*f2^-1
    gap> gens[1]/gens[3];
    f1*f2*Group( [ f1, f2 ] )^-1
    gap> gens[3]/gens[1]/gens[2];
    Group( [ f1, f2 ] )*f1*f2^-1*f2^-1^-1
    

    32.2 Comparison of Words

  • w1 = w2

    Two words are equal if they are words over the same alphabet and if they are a sequence of the same letters. There is no ``universal'' empty word, every alphabet (that is every family of words) has its own empty word.

    gap> f:=FreeGroup("a","b","b");;
    gap> gens:=GeneratorsOfGroup(f); 
    [ a, b, b ]
    gap> gens[2]=gens[3];
    false
    gap> x:=gens[1]*gens[2];
    a*b
    gap> y:=gens[2]/gens[2]*gens[1]*gens[2];
    a*b
    gap> x=y;
    true
    gap> z:=gens[2]/gens[2]*gens[1]*gens[3];
    a*b
    gap> x=z;
    false
    

  • w1 < w2

    Words are ordered as follows: A word w1 is considered smaller than another word w2 it it is shorted, or, if they have the same length, if it is first in the lexicographical ordering implied by the ordering of the letters. Letters are sorted in the order in which they were created. Each letter g is larger than its inverse g and its inverse is larger than every letter that is smaller than g.

    gap> f:=FreeGroup("a","b");;    
    gap> a:=GeneratorsOfGroup(f)[1];;b:=GeneratorsOfGroup(f)[2];;
    gap> a<b;
    true
    gap> a<a^-1;
    false
    gap> a<b^-1;
    true
    gap> b^-1<b;
    true
    gap> a*b<a*b^-1;
    false
    

    32.3 Operations for Words

    Multiplication of associative words is performed by concatenating the words and reducing adjacent pairs of generators and their inverses. The usual arithmetical operators *, One and (if the generators are invertible) Inverse, /,^, and Comm are applicable to associative words.

  • Length(w) O

    returns the number of letter in the word w

    gap> f:=FreeGroup("a","b");;    
    gap> a:=GeneratorsOfGroup(f)[1];;b:=GeneratorsOfGroup(f)[2];;
    gap> w:=a^5*b*a^2/b^4*a;
    a^5*b*a^2*b^-4*a
    gap> Length(w);
    13
    

  • MappedWord( w, gens, imgs ) O

    is the new object that is obtained by replacing each occurrence in the word w of a generator gen in the list gens by the corresponding object img in the list imgs. The lists gens and imgs must of course have the same length.

    If the images in imgs are all words, and some of them are equal to the corresponding generators in gens, then those may be omitted.

    Note that for associative words, the special case that the list gens and imgs have only length 1 is handled more efficiently by EliminatedWord (see EliminatedWord).

    gap> MappedWord(w,[a,b],[(1,2),(1,2,3,4)]);
    (1,3,4,2)
    gap> (1,2)^5*(1,2,3,4)*(1,2)^2/(1,2,3,4)^4*(1,2);   
    (1,3,4,2)
    

  • Subword( w, from, to ) O

    is the subword of the associative word w that begins at position from and ends at position to. from and to must be positive integers. Indexing is done with origin 1.

    gap> Subword(w,3,7);
    a^3*b*a
    

  • PositionWord( w, sub, from ) O

    is the position of the first occurrence of the associative word sub in the associative word w starting at position from. If there is no such occurrence, fail is returned. from must be a positive integer. Indexing is done with origin 1.

    In other words, PositionWord(w,sub,from) is the smallest integer i larger than or equal to from such that Subword( w, i, i+Length(sub)-1 ) = sub (see Subword).

    gap> PositionWord(w,a/b,1);
    8
    gap> Subword(w,8,9);
    a*b^-1
    gap> PositionWord(w,a^2,1);
    1
    gap> PositionWord(w,a^2,2);
    2
    gap> PositionWord(w,a^2,6);
    7
    gap> PositionWord(w,a^2,8);
    fail
    

  • SubstitutedWord( w, from, to, by ) O

    is a new associative word where the subword of the associative word w that begins at position from and ends at position to is replaced by the associative word by. from and to must be positive integers. Indexing is done with origin 1.

    In other words SubstitutedWord(w,from,to,by) = Subword(w,1,from-1)*by*Subword(w,to+1,Length(w) (see Subword).

    gap> SubstitutedWord(w,3,7,a^19);
    a^22*b^-4*a
    

  • EliminatedWord( word, gen, by ) O

    is a new associative word where each occurrence of the generator gen in the associative word word is replaced by the associative word by.

    gap> EliminatedWord(w,a,a^2);
    a^10*b*a^4*b^-4*a^2
    gap> EliminatedWord(w,a,b^-1);
    b^-11
    

  • ExponentSumWord( w, gen ) O

    is the number of times the generator gen appears in the associative word w minus the number of times its inverse appears in w. If gen and its inverse do not occur in w, 0 is returned. gen may also be the inverse of a generator.

    gap> ExponentSumWord(w,a);
    8
    gap> ExponentSumWord(w,b);
    -3
    

    32.4 Operations for Words by their Syllables

    When writing a word as a product of powers of generators, we call these powers of generators the syllables of the word.

  • NumberSyllables( w ) A

    Let w be an associative word of the form x1n1 x2n2 ¼xknk, such that xi ¹ xi+1±1 for 1 £ i £ k-1. Then NumberSyllables( w ) is k.

  • ExponentSyllable( w, i ) O

    is the exponent of the i-th syllable of the associative word w.

  • GeneratorSyllable( w, i ) O

    is the generator of the i-th syllable of the associative word w.

  • SubSyllables( w, from, to ) O

    is the subword of the associative word w that consists of the syllables from positions from to to. from and to must be positive integers. Indexing is done with origin 1.

    gap> NumberSyllables(w);             
    5
    gap> ExponentSyllable(w,3);
    2
    gap> GeneratorSyllable(w,3);
    1
    gap> SubSyllables(w,2,3);
    b*a^2
    

    32.5 External Representation for Associative Words

    Two associative words are equal if they are words over the same alphabet and if they are a sequence of the same letters. There is no ``universal'' empty word, every alphabet (that is every family of words) has its own empty word.

    gap> w:=ObjByExtRep(FamilyObj(a),[1,5,2,-7,1,3,2,4,1,-2]);
    a^5*b^-7*a^3*b^4*a^-2
    gap> ExtRepOfObj(w^2);
    [ 1, 5, 2, -7, 1, 3, 2, 4, 1, 3, 2, -7, 1, 3, 2, 4, 1, -2 ]
    
    [Top] [Previous] [Up] [Next] [Index]

    GAP 4 manual
    July 1999