Debian Codegraph @

doc/ref/chap36.html

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
4 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5
6 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
7 <head>
8 <title>GAP (ref) - Chapter 36: Words</title>
9 <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
10 <meta name="generator" content="GAPDoc2HTML" />
11 <link rel="stylesheet" type="text/css" href="manual.css" />
12 <script src="manual.js" type="text/javascript"></script>
13 <script type="text/javascript">overwriteStyle();</script>
14 </head>
15 <body class="chap36" onload="jscontent()">
16
17
18 <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>
19
20 <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>
21
22 <p id="mathjaxlink" class="pcenter"><a href="chap36_mj.html">[MathJax on]</a></p>
23 <p><a id="X7CB0D2F780D15136" name="X7CB0D2F780D15136"></a></p>
24 <div class="ChapSects"><a href="chap36.html#X7CB0D2F780D15136">36 <span class="Heading">Words</span></a>
25 <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>
26 </span>
27 <div class="ContSSBlock">
28 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X843F5C3A82239398">36.1-1 IsWord</a></span>
29 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X804B616579F223D8">36.1-2 IsWordCollection</a></span>
30 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X808FA6F97E16502F">36.1-3 IsNonassocWord</a></span>
31 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X7F81276C80F690DC">36.1-4 IsNonassocWordCollection</a></span>
32 </div></div>
33 <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>
34 </span>
35 <div class="ContSSBlock">
36 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X7CA51DD7874115DF"><code>36.2-1 \=</code></a></span>
37 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X82D4C7BE803166D6"><code>36.2-2 \&lt;</code></a></span>
38 </div></div>
39 <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>
40 </span>
41 <div class="ContSSBlock">
42 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X7EC17930781D104A">36.3-1 MappedWord</a></span>
43 </div></div>
44 <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>
45 </span>
46 <div class="ContSSBlock">
47 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X7CFFD9027DDD1555">36.4-1 <span class="Heading">FreeMagma</span></a>
48 </span>
49 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap36.html#X86DB748080B4A9B9">36.4-2 <span class="Heading">FreeMagmaWithOne</span></a>
50 </span>
51 </div></div>
52 <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>
53 </span>
54 </div>
55 </div>
56
57 <h3>36 <span class="Heading">Words</span></h3>
58
59 <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>
60
61 <p><a id="X79AEC832815B9317" name="X79AEC832815B9317"></a></p>
62
63 <h4>36.1 <span class="Heading">Categories of Words and Nonassociative Words</span></h4>
64
65 <p><a id="X843F5C3A82239398" name="X843F5C3A82239398"></a></p>
66
67 <h5>36.1-1 IsWord</h5>
68
69 <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">(&nbsp;category&nbsp;)</td></tr></table></div>
70 <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">(&nbsp;category&nbsp;)</td></tr></table></div>
71 <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">(&nbsp;category&nbsp;)</td></tr></table></div>
72 <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>
73
74 <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>
75
76 <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>
77
78 <p><code class="func">IsWord</code> is mainly a <q>common roof</q> 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>
79
80 <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>
81
82 <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>
83
84 <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>
85
86 <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>
87
88
89 <div class="example"><pre>
90 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= FreeMagmaWithOne( 2 );; gens:= GeneratorsOfMagmaWithOne( m );</span>
91 [ x1, x2 ]
92 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w1:= gens[1] * gens[2] * gens[1];</span>
93 ((x1*x2)*x1)
94 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w2:= gens[1] * ( gens[2] * gens[1] );</span>
95 (x1*(x2*x1))
96 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w1 = w2; IsAssociative( m );</span>
97 false
98 false
99 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWord( w1 ); IsAssocWord( w1 ); IsNonassocWord( w1 );</span>
100 true
101 false
102 true
103 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">s:= FreeMonoid( 2 );; gens:= GeneratorsOfMagmaWithOne( s );</span>
104 [ m1, m2 ]
105 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">u1:= ( gens[1] * gens[2] ) * gens[1];</span>
106 m1*m2*m1
107 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">u2:= gens[1] * ( gens[2] * gens[1] );</span>
108 m1*m2*m1
109 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">u1 = u2; IsAssociative( s );</span>
110 true
111 true
112 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWord( u1 ); IsAssocWord( u1 ); IsNonassocWord( u1 );</span>
113 true
114 true
115 false
116 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= (1,2,3);; b:= (1,2);;</span>
117 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w:= a*b*a;; IsWord( w );</span>
118 false
119 </pre></div>
120
121 <p><a id="X804B616579F223D8" name="X804B616579F223D8"></a></p>
122
123 <h5>36.1-2 IsWordCollection</h5>
124
125 <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">(&nbsp;category&nbsp;)</td></tr></table></div>
126 <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>
127
128
129 <div class="example"><pre>
130 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWordCollection( m ); IsWordCollection( s );</span>
131 true
132 true
133 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">IsWordCollection( [ "a", "b" ] );</span>
134 false
135 </pre></div>
136
137 <p><a id="X808FA6F97E16502F" name="X808FA6F97E16502F"></a></p>
138
139 <h5>36.1-3 IsNonassocWord</h5>
140
141 <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">(&nbsp;category&nbsp;)</td></tr></table></div>
142 <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">(&nbsp;category&nbsp;)</td></tr></table></div>
143 <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>
144
145 <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>
146
147 <p>In this sense each nonassociative word describes a <q>program</q> 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>
148
149 <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>
150
151 <p><a id="X7F81276C80F690DC" name="X7F81276C80F690DC"></a></p>
152
153 <h5>36.1-4 IsNonassocWordCollection</h5>
154
155 <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">(&nbsp;category&nbsp;)</td></tr></table></div>
156 <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">(&nbsp;category&nbsp;)</td></tr></table></div>
157 <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>
158
159 <p><a id="X852C815F85DBE4BD" name="X852C815F85DBE4BD"></a></p>
160
161 <h4>36.2 <span class="Heading">Comparison of Words</span></h4>
162
163 <p><a id="X7CA51DD7874115DF" name="X7CA51DD7874115DF"></a></p>
164
165 <h5><code>36.2-1 \=</code></h5>
166
167 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
168 <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>
169
170 <p><a id="X82D4C7BE803166D6" name="X82D4C7BE803166D6"></a></p>
171
172 <h5><code>36.2-2 \&lt;</code></h5>
173
174 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
175 <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>
176
177 <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 <q>universal</q> 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>
178
179
180 <div class="example"><pre>
181 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= FreeMagma( "a", "b" );;</span>
182 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">x:= FreeMagma( "a", "b" );;</span>
183 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mgens:= GeneratorsOfMagma( m );</span>
184 [ a, b ]
185 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">xgens:= GeneratorsOfMagma( x );</span>
186 [ a, b ]
187 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= mgens[1];; b:= mgens[2];;</span>
188 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a = xgens[1];</span>
189 false
190 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a*(a*a) = (a*a)*a; a*b = b*a; a*a = a*a;</span>
191 false
192 false
193 true
194 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a &lt; b; b &lt; a; a &lt; a*b;</span>
195 true
196 false
197 true
198 </pre></div>
199
200 <p><a id="X7A60A8E57AF13901" name="X7A60A8E57AF13901"></a></p>
201
202 <h4>36.3 <span class="Heading">Operations for Words</span></h4>
203
204 <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>
205
206 <p><a id="X7EC17930781D104A" name="X7EC17930781D104A"></a></p>
207
208 <h5>36.3-1 MappedWord</h5>
209
210 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
211 <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>
212
213 <p><code class="func">MappedWord</code> needs to do some preprocessing to get internal generator numbers etc. When mapping many (several thousand) words, a dedicated loop might be faster.</p>
214
215 <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>
216
217 <p>If the word is from a free group, it is permitted to give inverses of (some) of the generators as extra generators. This can speed up the execution by removing the need to calculate inverses anew.</p>
218
219
220 <div class="example"><pre>
221 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= FreeMagma( "a", "b" );; gens:= GeneratorsOfMagma( m );;</span>
222 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= gens[1]; b:= gens[2];</span>
223 a
224 b
225 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w:= (a*b)*((b*a)*a)*b;</span>
226 (((a*b)*((b*a)*a))*b)
227 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MappedWord( w, gens, [ (1,2), (1,2,3,4) ] );</span>
228 (2,4,3)
229 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= (1,2);; b:= (1,2,3,4);; (a*b)*((b*a)*a)*b;</span>
230 (2,4,3)
231 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">f:= FreeGroup( "a", "b" );;</span>
232 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:= GeneratorsOfGroup(f)[1];; b:= GeneratorsOfGroup(f)[2];;</span>
233 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w:= a^5*b*a^2/b^4*a;</span>
234 a^5*b*a^2*b^-4*a
235 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MappedWord( w, [ a, b ], [ (1,2), (1,2,3,4) ] );</span>
236 (1,3,4,2)
237 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MappedWord( w, [ a, b, b^-1 ], [ (1,2), (1,2,3,4), (1,4,3,2) ] );</span>
238 (1,3,4,2)
239 <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>
240 (1,3,4,2)
241 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MappedWord( w, [ a ], [ a^2 ] );</span>
242 a^10*b*a^4*b^-4*a^2
243 </pre></div>
244
245 <p><a id="X7F51B17983019D3E" name="X7F51B17983019D3E"></a></p>
246
247 <h4>36.4 <span class="Heading">Free Magmas</span></h4>
248
249 <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>
250
251 <p><a id="X7CFFD9027DDD1555" name="X7CFFD9027DDD1555"></a></p>
252
253 <h5>36.4-1 <span class="Heading">FreeMagma</span></h5>
254
255 <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">(&nbsp;function&nbsp;)</td></tr></table></div>
256 <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">(&nbsp;function&nbsp;)</td></tr></table></div>
257 <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">(&nbsp;function&nbsp;)</td></tr></table></div>
258 <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">(&nbsp;function&nbsp;)</td></tr></table></div>
259 <p><code class="code">FreeMagma</code> returns a free magma. The number of generators, and the labels given to the generators, can be specified in several different ways. Warning: the labels of generators are only an aid for printing, and do not necessarily distinguish generators; see the examples at the end of <code class="func">FreeSemigroup</code> (<a href="chap51.html#X7C72E4747BF642BB"><span class="RefLink">51.1-10</span></a>) for more information.</p>
260
261
262 <dl>
263 <dt><strong class="Mark">
264 1: For a given rank, and an optional generator name prefix
265 </strong></dt>
266 <dd><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. The optional argument <var class="Arg">name</var> must be a string; its default value is <code class="code">"x"</code>.</p>
267
268 <p>If <var class="Arg">name</var> is not given but the <code class="code">generatorNames</code> option is, then this option is respected as described in Section <a href="chap50.html#X7D0FFDA4793995FC"><span class="RefLink">50.1-16</span></a>.</p>
269
270 <p>Otherwise, the generators of the returned free magma are labelled <var class="Arg">name</var><code class="code">1</code>, ..., <var class="Arg">name</var><code class="code">k</code>, where <code class="code">k</code> is the value of <var class="Arg">rank</var>.</p>
271
272 </dd>
273 <dt><strong class="Mark">2: For given generator names</strong></dt>
274 <dd><p>Called with various (at least one) nonempty strings, <code class="func">FreeMagma</code> returns a free magma on as many generators as arguments, which are labelled <var class="Arg">name1</var>, <var class="Arg">name2</var>, etc.</p>
275
276 </dd>
277 <dt><strong class="Mark">3: For a given list of generator names</strong></dt>
278 <dd><p>Called with a finite nonempty list <var class="Arg">names</var> of nonempty strings, <code class="func">FreeMagma</code> returns a free magma on <code class="code">Length(<var class="Arg">names</var>)</code> generators, whose <code class="code">i</code>-th generator is labelled <var class="Arg">names</var><code class="code">[i]</code>.</p>
279
280 </dd>
281 <dt><strong class="Mark">
282 4: For the rank <code class="keyw">infinity</code>,
283 an optional default generator name prefix,
284 and an optional finite list of generator names
285 </strong></dt>
286 <dd><p>Called in the fourth form, <code class="func">FreeMagma</code> returns a free magma on infinitely many generators. The optional argument <var class="Arg">name</var> must be a string; its default value is <code class="code">"x"</code>, and the optional argument <var class="Arg">init</var> must be a finite list of nonempty strings; its default value is an empty list. The generators are initially labelled according to the list <var class="Arg">init</var>, followed by <var class="Arg">name</var><code class="code">i</code> for each <code class="code">i</code> in the range from <code class="code">Length(<var class="Arg">init</var>)+1</code> to <code class="keyw">infinity</code>.</p>
287
288 </dd>
289 </dl>
290
291 <div class="example"><pre>
292 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( 4 );</span>
293 &lt;free magma on the generators [ x1, x2, x3, x4 ]&gt;
294 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( 3, "a" );</span>
295 &lt;free magma on the generators [ a1, a2, a3 ]&gt;
296 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( "a", "b" );</span>
297 &lt;free magma on the generators [ a, b ]&gt;
298 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( [ "a", "b" ] );</span>
299 &lt;free magma on the generators [ a, b ]&gt;
300 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( infinity );</span>
301 &lt;free magma with infinity generators&gt;
302 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">F := FreeMagma( infinity, "gen" );;</span>
303 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">GeneratorsOfMagma( F ){[ 1 .. 4 ]};</span>
304 [ gen1, gen2, gen3, gen4 ]
305 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">F := FreeMagma( infinity, [ "z", "a" ] );;</span>
306 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">GeneratorsOfMagma( F ){[ 1 .. 3 ]};</span>
307 [ z, a, x3 ]
308 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">F := FreeMagma( infinity, "y", [ "z", "a" ] );;</span>
309 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">GeneratorsOfMagma( F ){[ 1 .. 4 ]};</span>
310 [ z, a, y3, y4 ]
311 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( 3 : generatorNames := "elt" );</span>
312 &lt;free magma on the generators [ elt1, elt2, elt3 ]&gt;
313 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagma( 2 : generatorNames := [ "u", "v", "w" ] );</span>
314 &lt;free magma on the generators [ u, v ]&gt;
315 </pre></div>
316
317 <p><a id="X86DB748080B4A9B9" name="X86DB748080B4A9B9"></a></p>
318
319 <h5>36.4-2 <span class="Heading">FreeMagmaWithOne</span></h5>
320
321 <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">(&nbsp;function&nbsp;)</td></tr></table></div>
322 <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">(&nbsp;function&nbsp;)</td></tr></table></div>
323 <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">(&nbsp;function&nbsp;)</td></tr></table></div>
324 <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">(&nbsp;function&nbsp;)</td></tr></table></div>
325 <p><code class="code">FreeMagmaWithOne</code> returns a free magma-with-one. The number of generators, and the labels given to the generators, can be specified in several different ways. Warning: the labels of generators are only an aid for printing, and do not necessarily distinguish generators; see the examples at the end of <code class="func">FreeSemigroup</code> (<a href="chap51.html#X7C72E4747BF642BB"><span class="RefLink">51.1-10</span></a>) for more information.</p>
326
327
328 <dl>
329 <dt><strong class="Mark">
330 1: For a given rank, and an optional generator name prefix
331 </strong></dt>
332 <dd><p>Called with a nonnegative integer <var class="Arg">rank</var>, <code class="func">FreeMagmaWithOne</code> returns a free magma-with-one on <var class="Arg">rank</var> generators. The optional argument <var class="Arg">name</var> must be a string; its default value is <code class="code">"x"</code>.</p>
333
334 <p>If <var class="Arg">name</var> is not given but the <code class="code">generatorNames</code> option is, then this option is respected as described in Section <a href="chap50.html#X7D0FFDA4793995FC"><span class="RefLink">50.1-16</span></a>.</p>
335
336 <p>Otherwise, the generators of the returned free magma-with-one are labelled <var class="Arg">name</var><code class="code">1</code>, ..., <var class="Arg">name</var><code class="code">k</code>, where <code class="code">k</code> is the value of <var class="Arg">rank</var>.</p>
337
338 </dd>
339 <dt><strong class="Mark">2: For given generator names</strong></dt>
340 <dd><p>Called with various nonempty strings, <code class="func">FreeMagmaWithOne</code> returns a free magma-with-one on as many generators as arguments, which are labelled <var class="Arg">name1</var>, <var class="Arg">name2</var>, etc.</p>
341
342 </dd>
343 <dt><strong class="Mark">3: For a given list of generator names</strong></dt>
344 <dd><p>Called with a finite list <var class="Arg">names</var> of nonempty strings, <code class="func">FreeMagmaWithOne</code> returns a free magma-with-one on <code class="code">Length(<var class="Arg">names</var>)</code> generators, whose <code class="code">i</code>-th generator is labelled <var class="Arg">names</var><code class="code">[i]</code>.</p>
345
346 </dd>
347 <dt><strong class="Mark">
348 4: For the rank <code class="keyw">infinity</code>,
349 an optional default generator name prefix,
350 and an optional finite list of generator names
351 </strong></dt>
352 <dd><p>Called in the fourth form, <code class="func">FreeMagmaWithOne</code> returns a free magma-with-one on infinitely many generators. The optional argument <var class="Arg">name</var> must be a string; its default value is <code class="code">"x"</code>, and the optional argument <var class="Arg">init</var> must be a finite list of nonempty strings; its default value is an empty list. The generators are initially labelled according to the list <var class="Arg">init</var>, followed by <var class="Arg">name</var><code class="code">i</code> for each <code class="code">i</code> in the range from <code class="code">Length(<var class="Arg">init</var>)+1</code> to <code class="keyw">infinity</code>.</p>
353
354 </dd>
355 </dl>
356
357 <div class="example"><pre>
358 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( 4 );</span>
359 &lt;free magma-with-one on the generators [ x1, x2, x3, x4 ]&gt;
360 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( 3, "a" );</span>
361 &lt;free magma-with-one on the generators [ a1, a2, a3 ]&gt;
362 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( "a", "b" );</span>
363 &lt;free magma-with-one on the generators [ a, b ]&gt;
364 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( [ "a", "b" ] );</span>
365 &lt;free magma-with-one on the generators [ a, b ]&gt;
366 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( infinity );</span>
367 &lt;free magma-with-one with infinity generators&gt;
368 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">F := FreeMagmaWithOne( infinity, "gen" );;</span>
369 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">GeneratorsOfMagmaWithOne( F ){[ 1 .. 4 ]};</span>
370 [ gen1, gen2, gen3, gen4 ]
371 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">F := FreeMagmaWithOne( infinity, [ "z", "a" ] );;</span>
372 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">GeneratorsOfMagmaWithOne( F ){[ 1 .. 3 ]};</span>
373 [ z, a, x3 ]
374 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">F := FreeMagmaWithOne( infinity, "y", [ "z", "a" ] );;</span>
375 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">GeneratorsOfMagmaWithOne( F ){[ 1 .. 4 ]};</span>
376 [ z, a, y3, y4 ]
377 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( 0 );</span>
378 &lt;free group of rank zero&gt;
379 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( 3 : generatorNames := "elt" );</span>
380 &lt;free magma-with-one on the generators [ elt1, elt2, elt3 ]&gt;
381 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">FreeMagmaWithOne( 2 : generatorNames := [ "u", "v", "w" ] );</span>
382 &lt;free magma-with-one on the generators [ u, v ]&gt;
383 </pre></div>
384
385 <p><a id="X84C2F9037EEE9CED" name="X84C2F9037EEE9CED"></a></p>
386
387 <h4>36.5 <span class="Heading">External Representation for Nonassociative Words</span></h4>
388
389 <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>
390
391 <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.8-1</span></a>).</p>
392
393
394 <div class="example"><pre>
395 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">m:= FreeMagma( 2 );; gens:= GeneratorsOfMagma( m );</span>
396 [ x1, x2 ]
397 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">w:= ( gens[1] * gens[2] ) * gens[1];</span>
398 ((x1*x2)*x1)
399 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ExtRepOfObj( w ); ExtRepOfObj( gens[1] );</span>
400 [ [ 1, 2 ], 1 ]
401 1
402 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput"> ExtRepOfObj( w*w );</span>
403 [ [ [ 1, 2 ], 1 ], [ [ 1, 2 ], 1 ] ]
404 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ObjByExtRep( FamilyObj( w ), 2 );</span>
405 x2
406 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ObjByExtRep( FamilyObj( w ), [ 1, [ 2, 1 ] ] );</span>
407 (x1*(x2*x1))
408 </pre></div>
409
410
411 <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>
412
413
414 <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>
415
416 <hr />
417 <p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
418 </body>
419 </html>