This file is indexed.

/usr/share/gap/doc/ref/chap36.html is in gap-doc 4r7p5-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>GAP (ref) - Chapter 36: Words</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<meta name="generator" content="GAPDoc2HTML" />
<link rel="stylesheet" type="text/css" href="manual.css" />
<script src="manual.js" type="text/javascript"></script>
<script type="text/javascript">overwriteStyle();</script>
</head>
<body class="chap36"  onload="jscontent()">


<div class="chlinktop"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chap12.html">12</a>  <a href="chap13.html">13</a>  <a href="chap14.html">14</a>  <a href="chap15.html">15</a>  <a href="chap16.html">16</a>  <a href="chap17.html">17</a>  <a href="chap18.html">18</a>  <a href="chap19.html">19</a>  <a href="chap20.html">20</a>  <a href="chap21.html">21</a>  <a href="chap22.html">22</a>  <a href="chap23.html">23</a>  <a href="chap24.html">24</a>  <a href="chap25.html">25</a>  <a href="chap26.html">26</a>  <a href="chap27.html">27</a>  <a href="chap28.html">28</a>  <a href="chap29.html">29</a>  <a href="chap30.html">30</a>  <a href="chap31.html">31</a>  <a href="chap32.html">32</a>  <a href="chap33.html">33</a>  <a href="chap34.html">34</a>  <a href="chap35.html">35</a>  <a href="chap36.html">36</a>  <a href="chap37.html">37</a>  <a href="chap38.html">38</a>  <a href="chap39.html">39</a>  <a href="chap40.html">40</a>  <a href="chap41.html">41</a>  <a href="chap42.html">42</a>  <a href="chap43.html">43</a>  <a href="chap44.html">44</a>  <a href="chap45.html">45</a>  <a href="chap46.html">46</a>  <a href="chap47.html">47</a>  <a href="chap48.html">48</a>  <a href="chap49.html">49</a>  <a href="chap50.html">50</a>  <a href="chap51.html">51</a>  <a href="chap52.html">52</a>  <a href="chap53.html">53</a>  <a href="chap54.html">54</a>  <a href="chap55.html">55</a>  <a href="chap56.html">56</a>  <a href="chap57.html">57</a>  <a href="chap58.html">58</a>  <a href="chap59.html">59</a>  <a href="chap60.html">60</a>  <a href="chap61.html">61</a>  <a href="chap62.html">62</a>  <a href="chap63.html">63</a>  <a href="chap64.html">64</a>  <a href="chap65.html">65</a>  <a href="chap66.html">66</a>  <a href="chap67.html">67</a>  <a href="chap68.html">68</a>  <a href="chap69.html">69</a>  <a href="chap70.html">70</a>  <a href="chap71.html">71</a>  <a href="chap72.html">72</a>  <a href="chap73.html">73</a>  <a href="chap74.html">74</a>  <a href="chap75.html">75</a>  <a href="chap76.html">76</a>  <a href="chap77.html">77</a>  <a href="chap78.html">78</a>  <a href="chap79.html">79</a>  <a href="chap80.html">80</a>  <a href="chap81.html">81</a>  <a href="chap82.html">82</a>  <a href="chap83.html">83</a>  <a href="chap84.html">84</a>  <a href="chap85.html">85</a>  <a href="chap86.html">86</a>  <a href="chap87.html">87</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<div class="chlinkprevnexttop">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp;  <a href="chap0.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap35.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap37.html">[Next Chapter]</a>&nbsp;  </div>

<p id="mathjaxlink" class="pcenter"><a href="chap36_mj.html">[MathJax on]</a></p>
<p><a id="X7CB0D2F780D15136" name="X7CB0D2F780D15136"></a></p>
<div class="ChapSects"><a href="chap36.html#X7CB0D2F780D15136">36 <span class="Heading">Words</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap36.html#X79AEC832815B9317">36.1 <span class="Heading">Categories of Words and Nonassociative Words</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X843F5C3A82239398">36.1-1 IsWord</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X804B616579F223D8">36.1-2 IsWordCollection</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X808FA6F97E16502F">36.1-3 IsNonassocWord</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X7F81276C80F690DC">36.1-4 IsNonassocWordCollection</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap36.html#X852C815F85DBE4BD">36.2 <span class="Heading">Comparison of Words</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X7CA51DD7874115DF">36.2-1 \=</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X82D4C7BE803166D6">36.2-2 \&lt;</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap36.html#X7A60A8E57AF13901">36.3 <span class="Heading">Operations for Words</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X7EC17930781D104A">36.3-1 MappedWord</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap36.html#X7F51B17983019D3E">36.4 <span class="Heading">Free Magmas</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X7CFFD9027DDD1555">36.4-1 <span class="Heading">FreeMagma</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X86DB748080B4A9B9">36.4-2 <span class="Heading">FreeMagmaWithOne</span></a>
</span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap36.html#X84C2F9037EEE9CED">36.5 <span class="Heading">External Representation for Nonassociative Words</span></a>
</span>
</div>
</div>

<h3>36 <span class="Heading">Words</span></h3>

<p>This chapter describes categories of <em>words</em> and <em>nonassociative words</em>, and operations for them. For information about <em>associative words</em>, which occur for example as elements in free groups, see Chapter <a href="chap37.html#X78C56A0A87CE380E"><span class="RefLink">37</span></a>.</p>

<p><a id="X79AEC832815B9317" name="X79AEC832815B9317"></a></p>

<h4>36.1 <span class="Heading">Categories of Words and Nonassociative Words</span></h4>

<p><a id="X843F5C3A82239398" name="X843F5C3A82239398"></a></p>

<h5>36.1-1 IsWord</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsWord</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsWordWithOne</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsWordWithInverse</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>Given a free multiplicative structure <span class="SimpleMath">M</span> that is freely generated by a subset <span class="SimpleMath">X</span>, any expression of an element in <span class="SimpleMath">M</span> as an iterated product of elements in <span class="SimpleMath">X</span> is called a <em>word</em> over <span class="SimpleMath">X</span>.</p>

<p>Interesting cases of free multiplicative structures are those of free semigroups, free monoids, and free groups, where the multiplication is associative (see <code class="func">IsAssociative</code> (<a href="chap35.html#X7C83B5A47FD18FB7"><span class="RefLink">35.4-7</span></a>)), which are described in Chapter <a href="chap37.html#X78C56A0A87CE380E"><span class="RefLink">37</span></a>, and also the case of free magmas, where the multiplication is nonassociative (see <code class="func">IsNonassocWord</code> (<a href="chap36.html#X808FA6F97E16502F"><span class="RefLink">36.1-3</span></a>)).</p>

<p>Elements in free magmas (see <code class="func">FreeMagma</code> (<a href="chap36.html#X7CFFD9027DDD1555"><span class="RefLink">36.4-1</span></a>)) lie in the category <code class="func">IsWord</code>; similarly, elements in free magmas-with-one (see <code class="func">FreeMagmaWithOne</code> (<a href="chap36.html#X86DB748080B4A9B9"><span class="RefLink">36.4-2</span></a>)) lie in the category <code class="func">IsWordWithOne</code>, and so on.</p>

<p><code class="func">IsWord</code> is mainly a "common roof" for the two <em>disjoint</em> categories <code class="func">IsAssocWord</code> (<a href="chap37.html#X7FA8DA728773BA89"><span class="RefLink">37.1-1</span></a>) and <code class="func">IsNonassocWord</code> (<a href="chap36.html#X808FA6F97E16502F"><span class="RefLink">36.1-3</span></a>) of associative and nonassociative words. This means that associative words are <em>not</em> 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 <a href="chap36.html#X84C2F9037EEE9CED"><span class="RefLink">36.5</span></a> and <a href="chap37.html#X7934D3D5797102EC"><span class="RefLink">37.7</span></a>).</p>

<p>Note that elements in finitely presented groups and also elements in polycyclic groups in <strong class="pkg">GAP</strong> are <em>not</em> in <code class="func">IsWord</code> although they are usually called words, see Chapters <a href="chap47.html#X7AA982637E90B35A"><span class="RefLink">47</span></a> and <a href="chap46.html#X7EAD57C97EBF7E67"><span class="RefLink">46</span></a>.</p>

<p>Words are <em>constants</em> (see <a href="chap12.html#X7F0C119682196D65"><span class="RefLink">12.6</span></a>), that is, they are not copyable and not mutable.</p>

<p>The usual way to create words is to form them as products of known words, starting from <em>generators</em> of a free structure such as a free magma or a free group (see <code class="func">FreeMagma</code> (<a href="chap36.html#X7CFFD9027DDD1555"><span class="RefLink">36.4-1</span></a>), <code class="func">FreeGroup</code> (<a href="chap37.html#X8215999E835290F0"><span class="RefLink">37.2-1</span></a>)).</p>

<p>Words are also used to implement free algebras, in the same way as group elements are used to implement group algebras (see <a href="chap62.html#X7A7B00127DC9DD40"><span class="RefLink">62.3</span></a> and Chapter <a href="chap65.html#X825897DC7A16E07D"><span class="RefLink">65</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= FreeMagmaWithOne( 2 );;  gens:= GeneratorsOfMagmaWithOne( m );</span>
[ x1, x2 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w1:= gens[1] * gens[2] * gens[1];</span>
((x1*x2)*x1)
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w2:= gens[1] * ( gens[2] * gens[1] );</span>
(x1*(x2*x1))
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w1 = w2;  IsAssociative( m );</span>
false
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWord( w1 );  IsAssocWord( w1 );  IsNonassocWord( w1 );</span>
true
false
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">s:= FreeMonoid( 2 );;  gens:= GeneratorsOfMagmaWithOne( s );</span>
[ m1, m2 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">u1:= ( gens[1] * gens[2] ) * gens[1];</span>
m1*m2*m1
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">u2:= gens[1] * ( gens[2] * gens[1] );</span>
m1*m2*m1
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">u1 = u2;  IsAssociative( s );</span>
true
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWord( u1 );  IsAssocWord( u1 );  IsNonassocWord( u1 );</span>
true
true
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= (1,2,3);;  b:= (1,2);;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w:= a*b*a;;  IsWord( w );</span>
false
</pre></div>

<p><a id="X804B616579F223D8" name="X804B616579F223D8"></a></p>

<h5>36.1-2 IsWordCollection</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsWordCollection</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p><code class="func">IsWordCollection</code> is the collections category (see <code class="func">CategoryCollections</code> (<a href="chap30.html#X78C38017804B2EA7"><span class="RefLink">30.2-4</span></a>)) of <code class="func">IsWord</code> (<a href="chap36.html#X843F5C3A82239398"><span class="RefLink">36.1-1</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWordCollection( m );  IsWordCollection( s );</span>
true
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWordCollection( [ "a", "b" ] );</span>
false
</pre></div>

<p><a id="X808FA6F97E16502F" name="X808FA6F97E16502F"></a></p>

<h5>36.1-3 IsNonassocWord</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsNonassocWord</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsNonassocWordWithOne</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>A <em>nonassociative word</em> in <strong class="pkg">GAP</strong> is an element in a free magma or a free magma-with-one (see <a href="chap36.html#X7F51B17983019D3E"><span class="RefLink">36.4</span></a>).</p>

<p>The default methods for <code class="func">ViewObj</code> (<a href="chap6.html#X815BF22186FD43C9"><span class="RefLink">6.3-5</span></a>) and <code class="func">PrintObj</code> (<a href="chap6.html#X815BF22186FD43C9"><span class="RefLink">6.3-5</span></a>) show nonassociative words as products of letters, where the succession of multiplications is determined by round brackets.</p>

<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 class="func">MappedWord</code> (<a href="chap36.html#X7EC17930781D104A"><span class="RefLink">36.3-1</span></a>) implements a way to apply such a program. A more general way is provided by straight line programs (see <a href="chap37.html#X7DC99E4284093FBB"><span class="RefLink">37.8</span></a>).</p>

<p>Note that associative words (see Chapter <a href="chap37.html#X78C56A0A87CE380E"><span class="RefLink">37</span></a>) are <em>not</em> regarded as special cases of nonassociative words (see <code class="func">IsWord</code> (<a href="chap36.html#X843F5C3A82239398"><span class="RefLink">36.1-1</span></a>)).</p>

<p><a id="X7F81276C80F690DC" name="X7F81276C80F690DC"></a></p>

<h5>36.1-4 IsNonassocWordCollection</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsNonassocWordCollection</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsNonassocWordWithOneCollection</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p><code class="func">IsNonassocWordCollection</code> is the collections category (see <code class="func">CategoryCollections</code> (<a href="chap30.html#X78C38017804B2EA7"><span class="RefLink">30.2-4</span></a>)) of <code class="func">IsNonassocWord</code> (<a href="chap36.html#X808FA6F97E16502F"><span class="RefLink">36.1-3</span></a>), and <code class="func">IsNonassocWordWithOneCollection</code> is the collections category of <code class="func">IsNonassocWordWithOne</code> (<a href="chap36.html#X808FA6F97E16502F"><span class="RefLink">36.1-3</span></a>).</p>

<p><a id="X852C815F85DBE4BD" name="X852C815F85DBE4BD"></a></p>

<h4>36.2 <span class="Heading">Comparison of Words</span></h4>

<p><a id="X7CA51DD7874115DF" name="X7CA51DD7874115DF"></a></p>

<h5>36.2-1 \=</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \=</code>( <var class="Arg">w1</var>, <var class="Arg">w2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Two words are equal if and only if they are words over the same alphabet and with equal external representations (see <a href="chap36.html#X84C2F9037EEE9CED"><span class="RefLink">36.5</span></a> and <a href="chap37.html#X7934D3D5797102EC"><span class="RefLink">37.7</span></a>). For nonassociative words, the latter means that the words arise from the letters of the alphabet by the same sequence of multiplications.</p>

<p><a id="X82D4C7BE803166D6" name="X82D4C7BE803166D6"></a></p>

<h5>36.2-2 \&lt;</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; \&lt;</code>( <var class="Arg">w1</var>, <var class="Arg">w2</var> )</td><td class="tdright">( function )</td></tr></table></div>
<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 <a href="chap36.html#X84C2F9037EEE9CED"><span class="RefLink">36.5</span></a>; associative words are ordered by the shortlex ordering via <code class="code">&lt;</code> (see <a href="chap37.html#X7934D3D5797102EC"><span class="RefLink">37.7</span></a>).</p>

<p>Note that the alphabet of a word is determined by its family (see <a href="chap13.html#X846063757EC05986"><span class="RefLink">13.1</span></a>), and that the result of each call to <code class="func">FreeMagma</code> (<a href="chap36.html#X7CFFD9027DDD1555"><span class="RefLink">36.4-1</span></a>), <code class="func">FreeGroup</code> (<a href="chap37.html#X8215999E835290F0"><span class="RefLink">37.2-1</span></a>) etc. consists of words over a new alphabet. In particular, there is no "universal" empty word, every families of words in <code class="func">IsWordWithOne</code> (<a href="chap36.html#X843F5C3A82239398"><span class="RefLink">36.1-1</span></a>) has its own empty word.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= FreeMagma( "a", "b" );;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">x:= FreeMagma( "a", "b" );;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mgens:= GeneratorsOfMagma( m );</span>
[ a, b ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">xgens:= GeneratorsOfMagma( x );</span>
[ a, b ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= mgens[1];;  b:= mgens[2];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a = xgens[1];</span>
false
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a*(a*a) = (a*a)*a;  a*b = b*a;  a*a = a*a;</span>
false
false
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a &lt; b;  b &lt; a;  a &lt; a*b;</span>
true
false
true
</pre></div>

<p><a id="X7A60A8E57AF13901" name="X7A60A8E57AF13901"></a></p>

<h4>36.3 <span class="Heading">Operations for Words</span></h4>

<p>Two words can be multiplied via <code class="code">*</code> only if they are words over the same alphabet (see <a href="chap36.html#X852C815F85DBE4BD"><span class="RefLink">36.2</span></a>).</p>

<p><a id="X7EC17930781D104A" name="X7EC17930781D104A"></a></p>

<h5>36.3-1 MappedWord</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MappedWord</code>( <var class="Arg">w</var>, <var class="Arg">gens</var>, <var class="Arg">imgs</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p><code class="func">MappedWord</code> returns the object that is obtained by replacing each occurrence in the word <var class="Arg">w</var> of a generator in the list <var class="Arg">gens</var> by the corresponding object in the list <var class="Arg">imgs</var>. The lists <var class="Arg">gens</var> and <var class="Arg">imgs</var> must of course have the same length.</p>

<p><code class="func">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>

<p>For example, if the elements in <var class="Arg">imgs</var> are all <em>associative words</em> (see Chapter <a href="chap37.html#X78C56A0A87CE380E"><span class="RefLink">37</span></a>) in the same family as the elements in <var class="Arg">gens</var>, and some of them are equal to the corresponding generators in <var class="Arg">gens</var>, then those may be omitted from <var class="Arg">gens</var> and <var class="Arg">imgs</var>. In this situation, the special case that the lists <var class="Arg">gens</var> and <var class="Arg">imgs</var> have only length <span class="SimpleMath">1</span> is handled more efficiently by <code class="func">EliminatedWord</code> (<a href="chap37.html#X8486BFE1844CFE59"><span class="RefLink">37.4-6</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= FreeMagma( "a", "b" );;  gens:= GeneratorsOfMagma( m );;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= gens[1];  b:= gens[2];</span>
a
b
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w:= (a*b)*((b*a)*a)*b;</span>
(((a*b)*((b*a)*a))*b)
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MappedWord( w, gens, [ (1,2), (1,2,3,4) ] );</span>
(2,4,3)
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= (1,2);; b:= (1,2,3,4);;  (a*b)*((b*a)*a)*b;</span>
(2,4,3)
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">f:= FreeGroup( "a", "b" );;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= GeneratorsOfGroup(f)[1];;  b:= GeneratorsOfGroup(f)[2];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w:= a^5*b*a^2/b^4*a;</span>
a^5*b*a^2*b^-4*a
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MappedWord( w, [ a, b ], [ (1,2), (1,2,3,4) ] );</span>
(1,3,4,2)
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">(1,2)^5*(1,2,3,4)*(1,2)^2/(1,2,3,4)^4*(1,2);</span>
(1,3,4,2)
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MappedWord( w, [ a ], [ a^2 ] );</span>
a^10*b*a^4*b^-4*a^2
</pre></div>

<p><a id="X7F51B17983019D3E" name="X7F51B17983019D3E"></a></p>

<h4>36.4 <span class="Heading">Free Magmas</span></h4>

<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 class="func">GeneratorsOfMagma</code> (<a href="chap35.html#X872E05B478EC20CA"><span class="RefLink">35.4-1</span></a>) in the case of a free magma, and via <code class="func">GeneratorsOfMagmaWithOne</code> (<a href="chap35.html#X87DD93EC8061DD81"><span class="RefLink">35.4-2</span></a>) in the case of a free magma-with-one.</p>

<p><a id="X7CFFD9027DDD1555" name="X7CFFD9027DDD1555"></a></p>

<h5>36.4-1 <span class="Heading">FreeMagma</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; FreeMagma</code>( <var class="Arg">rank</var>[, <var class="Arg">name</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; FreeMagma</code>( <var class="Arg">name1</var>, <var class="Arg">name2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; FreeMagma</code>( <var class="Arg">names</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; FreeMagma</code>( <var class="Arg">infinity</var>, <var class="Arg">name</var>, <var class="Arg">init</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Called with a positive integer <var class="Arg">rank</var>, <code class="func">FreeMagma</code> returns a free magma on <var class="Arg">rank</var> generators. If the optional argument <var class="Arg">name</var> is given then the generators are printed as <var class="Arg">name</var><code class="code">1</code>, <var class="Arg">name</var><code class="code">2</code> etc., that is, each name is the concatenation of the string <var class="Arg">name</var> and an integer from <code class="code">1</code> to <var class="Arg">range</var>. The default for <var class="Arg">name</var> is the string <code class="code">"m"</code>.</p>

<p>Called in the second form, <code class="func">FreeMagma</code> returns a free magma on as many generators as arguments, printed as <var class="Arg">name1</var>, <var class="Arg">name2</var> etc.</p>

<p>Called in the third form, <code class="func">FreeMagma</code> returns a free magma on as many generators as the length of the list <var class="Arg">names</var>, the <span class="SimpleMath">i</span>-th generator being printed as <var class="Arg">names</var><code class="code">[</code><span class="SimpleMath">i</span><code class="code">]</code>.</p>

<p>Called in the fourth form, <code class="func">FreeMagma</code> returns a free magma on infinitely many generators, where the first generators are printed by the names in the list <var class="Arg">init</var>, and the other generators by <var class="Arg">name</var> and an appended number.</p>

<p><a id="X86DB748080B4A9B9" name="X86DB748080B4A9B9"></a></p>

<h5>36.4-2 <span class="Heading">FreeMagmaWithOne</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; FreeMagmaWithOne</code>( <var class="Arg">rank</var>[, <var class="Arg">name</var>] )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; FreeMagmaWithOne</code>( <var class="Arg">name1</var>, <var class="Arg">name2</var>, <var class="Arg">...</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; FreeMagmaWithOne</code>( <var class="Arg">names</var> )</td><td class="tdright">( function )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; FreeMagmaWithOne</code>( <var class="Arg">infinity</var>, <var class="Arg">name</var>, <var class="Arg">init</var> )</td><td class="tdright">( function )</td></tr></table></div>
<p>Called with a positive integer <var class="Arg">rank</var>, <code class="func">FreeMagmaWithOne</code> returns a free magma-with-one on <var class="Arg">rank</var> generators. If the optional argument <var class="Arg">name</var> is given then the generators are printed as <var class="Arg">name</var><code class="code">1</code>, <var class="Arg">name</var><code class="code">2</code> etc., that is, each name is the concatenation of the string <var class="Arg">name</var> and an integer from <code class="code">1</code> to <var class="Arg">range</var>. The default for <var class="Arg">name</var> is the string <code class="code">"m"</code>.</p>

<p>Called in the second form, <code class="func">FreeMagmaWithOne</code> returns a free magma-with-one on as many generators as arguments, printed as <var class="Arg">name1</var>, <var class="Arg">name2</var> etc.</p>

<p>Called in the third form, <code class="func">FreeMagmaWithOne</code> returns a free magma-with-one on as many generators as the length of the list <var class="Arg">names</var>, the <span class="SimpleMath">i</span>-th generator being printed as <var class="Arg">names</var><code class="code">[</code><span class="SimpleMath">i</span><code class="code">]</code>.</p>

<p>Called in the fourth form, <code class="func">FreeMagmaWithOne</code> returns a free magma-with-one on infinitely many generators, where the first generators are printed by the names in the list <var class="Arg">init</var>, and the other generators by <var class="Arg">name</var> and an appended number.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( 3 );</span>
&lt;free magma on the generators [ x1, x2, x3 ]&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( "a", "b" );</span>
&lt;free magma on the generators [ a, b ]&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( infinity );</span>
&lt;free magma with infinity generators&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( 3 );</span>
&lt;free magma-with-one on the generators [ x1, x2, x3 ]&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( "a", "b" );</span>
&lt;free magma-with-one on the generators [ a, b ]&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( infinity );</span>
&lt;free magma-with-one with infinity generators&gt;
</pre></div>

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


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= FreeMagma( "x", "x" );  gens:= GeneratorsOfMagma( m );;</span>
&lt;free magma on the generators [ x, x ]&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">gens[1] = gens[2];</span>
false
</pre></div>

<p><a id="X84C2F9037EEE9CED" name="X84C2F9037EEE9CED"></a></p>

<h4>36.5 <span class="Heading">External Representation for Nonassociative Words</span></h4>

<p>The external representation of nonassociative words is defined as follows. The <span class="SimpleMath">i</span>-th generator of the family of elements in question has external representation <span class="SimpleMath">i</span>, the identity (if exists) has external representation <span class="SimpleMath">0</span>, the inverse of the <span class="SimpleMath">i</span>-th generator (if exists) has external representation <span class="SimpleMath">-i</span>. If <span class="SimpleMath">v</span> and <span class="SimpleMath">w</span> are nonassociative words with external representations <span class="SimpleMath">e_v</span> and <span class="SimpleMath">e_w</span>, respectively then the product <span class="SimpleMath">v * w</span> has external representation <span class="SimpleMath">[ e_v, e_w ]</span>. 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>

<p>One can create a nonassociative word from a family of words and the external representation of a nonassociative word using <code class="func">ObjByExtRep</code> (<a href="chap79.html#X8542B32A8206118C"><span class="RefLink">79.16-1</span></a>).</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= FreeMagma( 2 );;  gens:= GeneratorsOfMagma( m );</span>
[ x1, x2 ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w:= ( gens[1] * gens[2] ) * gens[1];</span>
((x1*x2)*x1)
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ExtRepOfObj( w );  ExtRepOfObj( gens[1] );</span>
[ [ 1, 2 ], 1 ]
1
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput"> ExtRepOfObj( w*w );</span>
[ [ [ 1, 2 ], 1 ], [ [ 1, 2 ], 1 ] ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ObjByExtRep( FamilyObj( w ), 2 );</span>
x2
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ObjByExtRep( FamilyObj( w ), [ 1, [ 2, 1 ] ] );</span>
(x1*(x2*x1))
</pre></div>


<div class="chlinkprevnextbot">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp;  <a href="chap0.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap35.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap37.html">[Next Chapter]</a>&nbsp;  </div>


<div class="chlinkbot"><span class="chlink1">Goto Chapter: </span><a href="chap0.html">Top</a>  <a href="chap1.html">1</a>  <a href="chap2.html">2</a>  <a href="chap3.html">3</a>  <a href="chap4.html">4</a>  <a href="chap5.html">5</a>  <a href="chap6.html">6</a>  <a href="chap7.html">7</a>  <a href="chap8.html">8</a>  <a href="chap9.html">9</a>  <a href="chap10.html">10</a>  <a href="chap11.html">11</a>  <a href="chap12.html">12</a>  <a href="chap13.html">13</a>  <a href="chap14.html">14</a>  <a href="chap15.html">15</a>  <a href="chap16.html">16</a>  <a href="chap17.html">17</a>  <a href="chap18.html">18</a>  <a href="chap19.html">19</a>  <a href="chap20.html">20</a>  <a href="chap21.html">21</a>  <a href="chap22.html">22</a>  <a href="chap23.html">23</a>  <a href="chap24.html">24</a>  <a href="chap25.html">25</a>  <a href="chap26.html">26</a>  <a href="chap27.html">27</a>  <a href="chap28.html">28</a>  <a href="chap29.html">29</a>  <a href="chap30.html">30</a>  <a href="chap31.html">31</a>  <a href="chap32.html">32</a>  <a href="chap33.html">33</a>  <a href="chap34.html">34</a>  <a href="chap35.html">35</a>  <a href="chap36.html">36</a>  <a href="chap37.html">37</a>  <a href="chap38.html">38</a>  <a href="chap39.html">39</a>  <a href="chap40.html">40</a>  <a href="chap41.html">41</a>  <a href="chap42.html">42</a>  <a href="chap43.html">43</a>  <a href="chap44.html">44</a>  <a href="chap45.html">45</a>  <a href="chap46.html">46</a>  <a href="chap47.html">47</a>  <a href="chap48.html">48</a>  <a href="chap49.html">49</a>  <a href="chap50.html">50</a>  <a href="chap51.html">51</a>  <a href="chap52.html">52</a>  <a href="chap53.html">53</a>  <a href="chap54.html">54</a>  <a href="chap55.html">55</a>  <a href="chap56.html">56</a>  <a href="chap57.html">57</a>  <a href="chap58.html">58</a>  <a href="chap59.html">59</a>  <a href="chap60.html">60</a>  <a href="chap61.html">61</a>  <a href="chap62.html">62</a>  <a href="chap63.html">63</a>  <a href="chap64.html">64</a>  <a href="chap65.html">65</a>  <a href="chap66.html">66</a>  <a href="chap67.html">67</a>  <a href="chap68.html">68</a>  <a href="chap69.html">69</a>  <a href="chap70.html">70</a>  <a href="chap71.html">71</a>  <a href="chap72.html">72</a>  <a href="chap73.html">73</a>  <a href="chap74.html">74</a>  <a href="chap75.html">75</a>  <a href="chap76.html">76</a>  <a href="chap77.html">77</a>  <a href="chap78.html">78</a>  <a href="chap79.html">79</a>  <a href="chap80.html">80</a>  <a href="chap81.html">81</a>  <a href="chap82.html">82</a>  <a href="chap83.html">83</a>  <a href="chap84.html">84</a>  <a href="chap85.html">85</a>  <a href="chap86.html">86</a>  <a href="chap87.html">87</a>  <a href="chapBib.html">Bib</a>  <a href="chapInd.html">Ind</a>  </div>

<hr />
<p class="foot">generated by <a href="http://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
</body>
</html>