Sophie

Sophie

distrib > Mandriva > 2010.0 > i586 > media > contrib-release > by-pkgid > 5e1854624d3bc613bdd0dd13d1ef9ac7 > files > 176

gap-system-4.4.12-5mdv2010.0.i586.rpm

<html><head><title>[ref] 34 Words</title></head>
<body text="#000000" bgcolor="#ffffff">
[<a href="../index.htm">Top</a>] [<a href = "chapters.htm">Up</a>] [<a href ="CHAP033.htm">Previous</a>] [<a href ="CHAP035.htm">Next</a>] [<a href = "theindex.htm">Index</a>]
<h1>34 Words</h1><p>
<P>
<H3>Sections</H3>
<oL>
<li> <A HREF="CHAP034.htm#SECT001">Categories of Words and Nonassociative Words</a>
<li> <A HREF="CHAP034.htm#SECT002">Comparison of Words</a>
<li> <A HREF="CHAP034.htm#SECT003">Operations for Words</a>
<li> <A HREF="CHAP034.htm#SECT004">Free Magmas</a>
<li> <A HREF="CHAP034.htm#SECT005">External Representation for Nonassociative Words</a>
</ol><p>
<p>
This chapter describes categories of <strong>words</strong> and <strong>nonassociative words</strong>,
and operations for them.
For information about <strong>associative words</strong>,
which occur for example as elements in free groups,
see Chapter&nbsp;<a href="CHAP035.htm">Associative Words</a>.
<p>
<p>
<h2><a name="SECT001">34.1 Categories of Words and Nonassociative Words</a></h2>
<p><p>
<a name = "I0"></a>

<a name = "SSEC001.1"></a>
<li><code>IsWord( </code><var>obj</var><code> ) C</code>
<a name = "SSEC001.1"></a>
<li><code>IsWordWithOne( </code><var>obj</var><code> ) C</code>
<a name = "SSEC001.1"></a>
<li><code>IsWordWithInverse( </code><var>obj</var><code> ) C</code>
<p>
Given a free multiplicative structure <i>M</i> that is freely generated by
a subset <i>X</i>,
any expression of an element in <i>M</i> as an iterated product of elements
in <i>X</i> is called a <strong>word</strong> over <i>X</i>.
<p>
Interesting cases of free multiplicative structures are those of
free semigroups, free monoids, and free groups,
where the multiplication is associative (see&nbsp;<a href="CHAP033.htm#SSEC004.7">IsAssociative</a>),
which are described in Chapter&nbsp;<a href="CHAP035.htm">Associative Words</a>,
and also the case of free magmas,
where the multiplication is nonassociative (see&nbsp;<a href="CHAP034.htm#SSEC001.3">IsNonassocWord</a>).
<p>
Elements in free magmas (see&nbsp;<a href="CHAP034.htm#SSEC004.1">FreeMagma</a>) lie in the category <code>IsWord</code>;
similarly, elements in free magmas-with-one (see&nbsp;<a href="CHAP034.htm#SSEC004.2">FreeMagmaWithOne</a>) 
lie in the category <code>IsWordWithOne</code>, and so on.
<p>
<code>IsWord</code> is mainly a ``common roof'' for the two <strong>disjoint</strong> categories
<code>IsAssocWord</code> (see&nbsp;<a href="CHAP035.htm#SSEC001.1">IsAssocWord</a>) and <code>IsNonassocWord</code>
(see&nbsp;<a href="CHAP034.htm#SSEC001.3">IsNonassocWord</a>) of associative and nonassociative words.
This means that associative words are <strong>not</strong> regarded as special cases
of nonassociative words.
The main reason for this setup is that we are interested in different
external representations for associative and nonassociative words
(see&nbsp;<a href="CHAP034.htm#SECT005">External Representation for Nonassociative Words</a> and
<a href="CHAP035.htm#SECT007">The External Representation for Associative Words</a>).
<p>
Note that elements in finitely presented groups and also elements in
polycyclic groups in <font face="Gill Sans,Helvetica,Arial">GAP</font> are <strong>not</strong> in <code>IsWord</code> although they are
usually called words,
see Chapters&nbsp;<a href="CHAP045.htm">Finitely Presented Groups</a> and&nbsp;<a href="CHAP044.htm">Pc Groups</a>.
<p>
Words are <strong>constants</strong> (see&nbsp;<a href="CHAP012.htm#SECT006">Mutability and Copyability</a>),
that is, they are not copyable and not mutable.
<p>
The usual way to create words is to form them as products of known words,
starting from <strong>generators</strong> of a free structure such as a free magma or a
free group (see&nbsp;<a href="CHAP034.htm#SSEC004.1">FreeMagma</a>, <a href="CHAP035.htm#SSEC002.1">FreeGroup</a>).
<p>
Words are also used to implement free algebras,
in the same way as group elements are used to implement group algebras
(see&nbsp;<a href="CHAP060.htm#SECT002">Constructing Algebras as Free Algebras</a> and Chapter&nbsp;<a href="CHAP063.htm">Magma Rings</a>).
<p>
<pre>
gap&gt; m:= FreeMagmaWithOne( 2 );;  gens:= GeneratorsOfMagmaWithOne( m );
[ x1, x2 ]
gap&gt; w1:= gens[1] * gens[2] * gens[1];
((x1*x2)*x1)
gap&gt; w2:= gens[1] * ( gens[2] * gens[1] );
(x1*(x2*x1))
gap&gt; w1 = w2;  IsAssociative( m );
false
false
gap&gt; IsWord( w1 );  IsAssocWord( w1 );  IsNonassocWord( w1 );
true
false
true
gap&gt; s:= FreeMonoid( 2 );;  gens:= GeneratorsOfMagmaWithOne( s );
[ m1, m2 ]
gap&gt; u1:= ( gens[1] * gens[2] ) * gens[1];
m1*m2*m1
gap&gt; u2:= gens[1] * ( gens[2] * gens[1] );
m1*m2*m1
gap&gt; u1 = u2;  IsAssociative( s );
true
true
gap&gt; IsWord( u1 );  IsAssocWord( u1 );  IsNonassocWord( u1 );
true
true
false
gap&gt; a:= (1,2,3);;  b:= (1,2);;
gap&gt; w:= a*b*a;;  IsWord( w );
false
</pre>
<p>
<a name = "SSEC001.2"></a>
<li><code>IsWordCollection( </code><var>obj</var><code> ) C</code>
<p>
<code>IsWordCollection</code> is the collections category
(see&nbsp;<a href="CHAP028.htm#SSEC001.4">CategoryCollections</a>) of <code>IsWord</code>.
<p>
<pre>
gap&gt; IsWordCollection( m );  IsWordCollection( s );
true
true
gap&gt; IsWordCollection( [ "a", "b" ] );
false
</pre>
<p>
<a name = "SSEC001.3"></a>
<li><code>IsNonassocWord( </code><var>obj</var><code> ) C</code>
<a name = "SSEC001.3"></a>
<li><code>IsNonassocWordWithOne( </code><var>obj</var><code> ) C</code>
<p>
A <strong>nonassociative word</strong> in <font face="Gill Sans,Helvetica,Arial">GAP</font> is an element in a free magma or
a free magma-with-one (see&nbsp;<a href="CHAP034.htm#SECT004">Free Magmas</a>).
<p>
The default methods for <code>ViewObj</code> and <code>PrintObj</code> (see&nbsp;<a href="CHAP006.htm#SECT003">View and Print</a>)
show nonassociative words as products of letters,
where the succession of multiplications is determined by round brackets.
<p>
In this sense each nonassociative word describes a ``program'' to
form a product of generators.
(Also associative words can be interpreted as such programs,
except that the exact succession of multiplications is not prescribed
due to the associativity.)
The function <code>MappedWord</code> (see&nbsp;<a href="CHAP034.htm#SSEC003.1">MappedWord</a>) implements a way to
apply such a program.
A more general way is provided by straight line programs
(see&nbsp;<a href="CHAP035.htm#SECT008">Straight Line Programs</a>).
<p>
Note that associative words (see Chapter&nbsp;<a href="CHAP035.htm">Associative Words</a>)
are <strong>not</strong> regarded as special cases of nonassociative words
(see&nbsp;<a href="CHAP034.htm#SSEC001.1">IsWord</a>).
<p>
<a name = "SSEC001.4"></a>
<li><code>IsNonassocWordCollection( </code><var>obj</var><code> ) C</code>
<a name = "SSEC001.4"></a>
<li><code>IsNonassocWordWithOneCollection( </code><var>obj</var><code> ) C</code>
<p>
<code>IsNonassocWordCollection</code> is the collections category
(see&nbsp;<a href="CHAP028.htm#SSEC001.4">CategoryCollections</a>) of <code>IsNonassocWord</code>,
and <code>IsNonassocWordWithOneCollection</code> is the collections category
of <code>IsNonassocWordWithOne</code>.
<p>
<p>
<h2><a name="SECT002">34.2 Comparison of Words</a></h2>
<p><p>
<a name = "SSEC002.1"></a>
<li><code></code><var>w1</var><code> = </code><var>w2</var><code></code>
<p>
Two words are equal if and only if they are words over the same alphabet
and with equal external representations
(see&nbsp;<a href="CHAP034.htm#SECT005">External Representation for Nonassociative Words</a> and
<a href="CHAP035.htm#SECT007">The External Representation for Associative Words</a>).
For nonassociative words, the latter means that the words arise from the
letters of the alphabet by the same sequence of multiplications.
<p>
<a name = "SSEC002.2"></a>
<li><code></code><var>w1</var><code> &lt; </code><var>w2</var><code></code>
<p>
Words are ordered according to their external representation.
More precisely, two words can be compared if they are words over the same
alphabet, and the word with smaller external representation is smaller.
For nonassociative words, the ordering is defined
in&nbsp;<a href="CHAP034.htm#SECT005">External Representation for Nonassociative Words</a>;
associative words are ordered by the shortlex ordering via <code>&lt;</code>
(see&nbsp;<a href="CHAP035.htm#SECT007">The External Representation for Associative Words</a>).
<p>
Note that the alphabet of a word is determined by its family
(see&nbsp;<a href="CHAP013.htm#SECT001">Families</a>),
and that the result of each call to <code>FreeMagma</code>, <code>FreeGroup</code> etc.
consists of words over a new alphabet.
In particular, there is no ``universal'' empty word,
every families of words in <code>IsWordWithOne</code> has its own empty word.
<p>
<pre>
gap&gt; m:= FreeMagma( "a", "b" );;
gap&gt; x:= FreeMagma( "a", "b" );;
gap&gt; mgens:= GeneratorsOfMagma( m );
[ a, b ]
gap&gt; xgens:= GeneratorsOfMagma( x );
[ a, b ]
gap&gt; a:= mgens[1];;  b:= mgens[2];;
gap&gt; a = xgens[1];
false
gap&gt; a*(a*a) = (a*a)*a;  a*b = b*a;  a*a = a*a;
false
false
true
gap&gt; a &lt; b;  b &lt; a;  a &lt; a*b;
true
false
true
</pre>
<p>
<p>
<h2><a name="SECT003">34.3 Operations for Words</a></h2>
<p><p>
Two words can be multiplied via <code>*</code> only if they are words over the same
alphabet (see&nbsp;<a href="CHAP034.htm#SECT002">Comparison of Words</a>).
<p>
<a name = "SSEC003.1"></a>
<li><code>MappedWord( </code><var>w</var><code>, </code><var>gens</var><code>, </code><var>imgs</var><code> ) O</code>
<p>
<code>MappedWord</code> returns the object that is obtained by replacing each
occurrence in the word <var>w</var> of a generator in the list <var>gens</var>
by the corresponding object in the list <var>imgs</var>.
The lists <var>gens</var> and <var>imgs</var> must of course have the same length.
<p>
<code>MappedWord</code> needs to do some preprocessing to get internal generator
numbers etc. When mapping many (several thousand) words, an
explicit loop over the words syllables might be faster.
<p>
(For example, If the elements in <var>imgs</var> are all <strong>associative words</strong>
(see Chapter&nbsp;<a href="CHAP035.htm">Associative Words</a>)
in the same family as the elements in <var>gens</var>,
and some of them are equal to the corresponding generators in <var>gens</var>,
then those may be omitted from <var>gens</var> and <var>imgs</var>.
In this situation, the special case that the lists <var>gens</var>
and <var>imgs</var> have only length 1 is handled more efficiently by
<code>EliminatedWord</code> (see&nbsp;<a href="CHAP035.htm#SSEC004.6">EliminatedWord</a>).)
<p>
<pre>
gap&gt; m:= FreeMagma( "a", "b" );;  gens:= GeneratorsOfMagma( m );;
gap&gt; a:= gens[1];  b:= gens[2];
a
b
gap&gt; w:= (a*b)*((b*a)*a)*b;
(((a*b)*((b*a)*a))*b)
gap&gt; MappedWord( w, gens, [ (1,2), (1,2,3,4) ] );
(2,4,3)
gap&gt; a:= (1,2);; b:= (1,2,3,4);;  (a*b)*((b*a)*a)*b;
(2,4,3)
</pre>
<p>
<pre>
gap&gt; f:= FreeGroup( "a", "b" );;
gap&gt; a:= GeneratorsOfGroup(f)[1];;  b:= GeneratorsOfGroup(f)[2];;
gap&gt; w:= a^5*b*a^2/b^4*a;
a^5*b*a^2*b^-4*a
gap&gt; MappedWord( w, [ a, b ], [ (1,2), (1,2,3,4) ] );
(1,3,4,2)
gap&gt; (1,2)^5*(1,2,3,4)*(1,2)^2/(1,2,3,4)^4*(1,2);
(1,3,4,2)
gap&gt; MappedWord( w, [ a ], [ a^2 ] );
a^10*b*a^4*b^-4*a^2
</pre>
<p>
<p>
<h2><a name="SECT004">34.4 Free Magmas</a></h2>
<p><p>
The easiest way to create a family of words is to construct the free
object generated by these words.
Each such free object defines a unique alphabet,
and its generators are simply the words of length one over this alphabet;
These generators can be accessed via <code>GeneratorsOfMagma</code> in the case of
a free magma, and via <code>GeneratorsOfMagmaWithOne</code> in the case of a free
magma-with-one.
<p>
<a name = "SSEC004.1"></a>
<li><code>FreeMagma( </code><var>rank</var><code> ) F</code>
<li><code>FreeMagma( </code><var>rank</var><code>, </code><var>name</var><code> ) F</code>
<li><code>FreeMagma( </code><var>name1</var><code>, </code><var>name2</var><code>, ... ) F</code>
<li><code>FreeMagma( </code><var>names</var><code> ) F</code>
<li><code>FreeMagma( infinity, </code><var>name</var><code>, </code><var>init</var><code> ) F</code>
<p>
Called in the first form, <code>FreeMagma</code> returns a free magma on          
<var>rank</var> generators.
Called in the second form, <code>FreeMagma</code> returns a free magma on         
<var>rank</var> generators, printed as <code></code><var>name</var><code>1</code>, <code></code><var>name</var><code>2</code> etc.,
that is, each name is the concatenation of the string <var>name</var> and an
integer from <code>1</code> to <var>range</var>.
Called in the third form, <code>FreeMagma</code> returns a free magma on
as many generators as arguments, printed as <var>name1</var>, <var>name2</var> etc.
Called in the fourth form, <code>FreeMagma</code> returns a free magma on
as many generators as the length of the list <var>names</var>, the <i>i</i>-th         
generator being printed as <code></code><var>names</var><code>[<i>i</i>]</code>.
Called in the fifth form, <code>FreeMagma</code> returns a free magma on          
infinitely many generators, where the first generators are printed
by the names in the list <var>init</var>, and the other generators by <var>name</var>
and an appended number.
<p>
<a name = "SSEC004.2"></a>
<li><code>FreeMagmaWithOne( </code><var>rank</var><code> ) F</code>
<li><code>FreeMagmaWithOne( </code><var>rank</var><code>, </code><var>name</var><code> ) F</code>
<li><code>FreeMagmaWithOne( </code><var>name1</var><code>, </code><var>name2</var><code>, ... ) F</code>
<li><code>FreeMagmaWithOne( </code><var>names</var><code> ) F</code>
<li><code>FreeMagmaWithOne( infinity, </code><var>name</var><code>, </code><var>init</var><code> ) F</code>
<p>
Called in the first form, <code>FreeMagmaWithOne</code> returns
a free magma-with-one on <var>rank</var> generators.
Called in the second form, <code>FreeMagmaWithOne</code> returns
a free magma-with-one on <var>rank</var> generators,
printed as <code></code><var>name</var><code>1</code>, <code></code><var>name</var><code>2</code> etc.
Called in the third form, <code>FreeMagmaWithOne</code> returns
a free magma-with-one on as many generators as arguments,
printed as <var>name1</var>, <var>name2</var> etc.
Called in the fourth form, <code>FreeMagmaWithOne</code> returns
a free magma-with-one on as many generators as the length of the list
<var>names</var>, the <i>i</i>-th generator being printed as <code></code><var>names</var><code>[<i>i</i>]</code>.
Called in the fifth form, <code>FreeMagmaWithOne</code> returns
a free magma on infinitely many generators,
where the first generators are printed by the names in the list <var>init</var>,
and the other generators by <var>name</var> and an appended number.
<p>
<pre>
gap&gt; FreeMagma( 3 );
&lt;free magma on the generators [ x1, x2, x3 ]&gt;
gap&gt; FreeMagma( "a", "b" );
&lt;free magma on the generators [ a, b ]&gt;
gap&gt; FreeMagma( infinity );
&lt;free magma with infinity generators&gt;
gap&gt; FreeMagmaWithOne( 3 );
&lt;free magma-with-one on the generators [ x1, x2, x3 ]&gt;
gap&gt; FreeMagmaWithOne( "a", "b" );
&lt;free magma-with-one on the generators [ a, b ]&gt;
gap&gt; FreeMagmaWithOne( infinity );
&lt;free magma-with-one with infinity generators&gt;
</pre>
<p>
Remember that the names of generators used for printing
do not necessarily distinguish letters of the alphabet;
so it is possible to create arbitrarily weird
situations by choosing strange letter names.
<p>
<pre>
gap&gt; m:= FreeMagma( "x", "x" );  gens:= GeneratorsOfMagma( m );;
&lt;free magma on the generators [ x, x ]&gt;
gap&gt; gens[1] = gens[2];
false
</pre>
<p>
<p>
<h2><a name="SECT005">34.5 External Representation for Nonassociative Words</a></h2>
<p><p>
The external representation of nonassociative words is defined
as follows.
The <i>i</i>-th generator of the family of elements in question has external
representation <i>i</i>,
the identity (if exists) has external representation 0,
the inverse of the <i>i</i>-th generator (if exists) has external
representation &#8722;<i>i</i>.
If <i>v</i> and <i>w</i> are nonassociative words with external representations
<i>e</i><sub><i>v</i></sub> and <i>e</i><sub><i>w</i></sub>, respectively then the product <i>v</i> * <i>w</i> has external
representation [ <i>e</i><sub><i>v</i></sub>, <i>e</i><sub><i>w</i></sub> ].
So the external representation of any nonassociative word is either an
integer or a nested list of integers and lists, where each list has
length two.
<p>
One can create a nonassociative word from a family of words and the
external representation of a nonassociative word using <code>ObjByExtRep</code>.
<p>
<pre>
gap&gt; m:= FreeMagma( 2 );;  gens:= GeneratorsOfMagma( m );
[ x1, x2 ]
gap&gt; w:= ( gens[1] * gens[2] ) * gens[1];
((x1*x2)*x1)
gap&gt; ExtRepOfObj( w );  ExtRepOfObj( gens[1] );
[ [ 1, 2 ], 1 ]
1
gap&gt;  ExtRepOfObj( w*w );
[ [ [ 1, 2 ], 1 ], [ [ 1, 2 ], 1 ] ]
gap&gt; ObjByExtRep( FamilyObj( w ), 2 );
x2
gap&gt; ObjByExtRep( FamilyObj( w ), [ 1, [ 2, 1 ] ] );
(x1*(x2*x1))
</pre>
<p>
<p>
[<a href="../index.htm">Top</a>] [<a href = "chapters.htm">Up</a>] [<a href ="CHAP033.htm">Previous</a>] [<a href ="CHAP035.htm">Next</a>] [<a href = "theindex.htm">Index</a>]
<P>
<font face="Gill Sans,Helvetica,Arial">GAP 4 manual<br>December 2008
</font></body></html>