This file is indexed.

/usr/share/gap/doc/ref/chap38.html is in gap-doc 4r6p5-3.

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
<?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 38: Rewriting Systems</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="chap38"  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="chap37.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap39.html">[Next Chapter]</a>&nbsp;  </div>

<p id="mathjaxlink" class="pcenter"><a href="chap38_mj.html">[MathJax on]</a></p>
<p><a id="X7CA8FCFD81AA1890" name="X7CA8FCFD81AA1890"></a></p>
<div class="ChapSects"><a href="chap38.html#X7CA8FCFD81AA1890">38 <span class="Heading">Rewriting Systems</span></a>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap38.html#X8287CBE183EBE5D7">38.1 <span class="Heading">Operations on rewriting systems</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X842C0ED87986F7AA">38.1-1 IsRewritingSystem</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X833EAA8C86356F42">38.1-2 Rules</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X7C38C2EF817F9E0A">38.1-3 OrderOfRewritingSystem</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X8340EB2280DE6CCC">38.1-4 ReducedForm</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X8006790B86328CE8">38.1-5 <span class="Heading">IsConfluent</span></a>
</span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X870A1E1C7FB45A55">38.1-6 ConfluentRws</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X8134689C7B576946">38.1-7 IsReduced</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X864C82FD7FBA31A6">38.1-8 ReduceRules</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X81E6B5CB789A7C3A">38.1-9 AddRule</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X7FA0B54D7C533DDC">38.1-10 AddRuleReduced</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X7BD6299E85561DC3">38.1-11 MakeConfluent</a></span>
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X795DC25886007DFE">38.1-12 GeneratorsOfRws</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap38.html#X81B812C778CB1E4E">38.2 <span class="Heading">Operations on elements of the algebra</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X81BB38CC793F7CE2">38.2-1 ReducedProduct</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap38.html#X8318649681DF783B">38.3 <span class="Heading">Properties of rewriting systems</span></a>
</span>
<div class="ContSSBlock">
<span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X7B647DB77D138A49">38.3-1 IsBuiltFromAdditiveMagmaWithInverses</a></span>
</div></div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap38.html#X7F8B7848851784DF">38.4 <span class="Heading">Rewriting in Groups and Monoids</span></a>
</span>
</div>
<div class="ContSect"><span class="tocline"><span class="nocss">&nbsp;</span><a href="chap38.html#X8751F8FA7DC989A2">38.5 <span class="Heading">Developing rewriting systems</span></a>
</span>
</div>
</div>

<h3>38 <span class="Heading">Rewriting Systems</span></h3>

<p>Rewriting systems in <strong class="pkg">GAP</strong> are a framework for dealing with the very general task of rewriting elements of a free (or <em>term</em>) algebra in some normal form. Although most rewriting systems currently in use are <em>string rewriting systems</em> (where the algebra has only one binary operation which is associative) the framework in <strong class="pkg">GAP</strong> is general enough to encompass the task of rewriting algebras of any signature from groups to semirings.</p>

<p>Rewriting systems are already implemented in <strong class="pkg">GAP</strong> for finitely presented semigroups and for pc groups. The use of these particular rewriting systems is described in the corresponding chapters. We describe here only the general framework of rewriting systems with a particular emphasis on material which would be helpful for a developer implementing a rewriting system.</p>

<p>We fix some definitions and terminology for the rest of this chapter. Let <span class="SimpleMath">T</span> be a term algebra in some signature. A <em>term rewriting system</em> for <span class="SimpleMath">T</span> is a set of ordered pairs of elements of <span class="SimpleMath">T</span> of the form <span class="SimpleMath">(l, r)</span>. Viewed as a set of relations, the rewriting system determines a presentation for a quotient algebra <span class="SimpleMath">A</span> of <span class="SimpleMath">T</span>.</p>

<p>When we take into account the fact that the relations are expressed as <em>ordered</em> pairs, we have a way of <em>reducing</em> the elements of <span class="SimpleMath">T</span>. Suppose an element <span class="SimpleMath">u</span> of <span class="SimpleMath">T</span> has a subword <span class="SimpleMath">l</span> and <span class="SimpleMath">(l, r)</span> is a rule of the rewriting system, then we can replace the subterm <span class="SimpleMath">l</span> of <span class="SimpleMath">u</span> by the term <span class="SimpleMath">r</span> and obtain a new word <span class="SimpleMath">v</span>. We say that we have <em>rewritten</em> <span class="SimpleMath">u</span> as <span class="SimpleMath">v</span>. Note that <span class="SimpleMath">u</span> and <span class="SimpleMath">v</span> represent the same element of <span class="SimpleMath">A</span>. If <span class="SimpleMath">u</span> can not be rewritten using any rule of the rewriting system we sat that <span class="SimpleMath">u</span> is <em>reduced</em>.</p>

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

<h4>38.1 <span class="Heading">Operations on rewriting systems</span></h4>

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

<h5>38.1-1 IsRewritingSystem</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsRewritingSystem</code>( <var class="Arg">obj</var> )</td><td class="tdright">( category )</td></tr></table></div>
<p>This is the category in which all rewriting systems lie.</p>

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

<h5>38.1-2 Rules</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; Rules</code>( <var class="Arg">rws</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>The rules comprising the rewriting system. Note that these may change through the life of the rewriting system, however they will always be a set of defining relations of the algebra described by the rewriting system.</p>

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

<h5>38.1-3 OrderOfRewritingSystem</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OrderOfRewritingSystem</code>( <var class="Arg">rws</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; OrderingOfRewritingSystem</code>( <var class="Arg">rws</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>return the ordering of the rewriting system <var class="Arg">rws</var>.</p>

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

<h5>38.1-4 ReducedForm</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedForm</code>( <var class="Arg">rws</var>, <var class="Arg">u</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Given an element <var class="Arg">u</var> in the free (or term) algebra <span class="SimpleMath">T</span> over which <var class="Arg">rws</var> is defined, rewrite <var class="Arg">u</var> by successive applications of the rules of <var class="Arg">rws</var> until no further rewriting is possible, and return the resulting element of <span class="SimpleMath">T</span>.</p>

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

<h5>38.1-5 <span class="Heading">IsConfluent</span></h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsConfluent</code>( <var class="Arg">rws</var> )</td><td class="tdright">( property )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsConfluent</code>( <var class="Arg">A</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>For a rewriting system <var class="Arg">rws</var>, <code class="func">IsConfluent</code> returns <code class="keyw">true</code> if and only if <var class="Arg">rws</var> is confluent. A rewriting system is <em>confluent</em> if, for every two words <span class="SimpleMath">u</span> and <span class="SimpleMath">v</span> in the free algebra <span class="SimpleMath">T</span> which represent the same element of the algebra <span class="SimpleMath">A</span> defined by <var class="Arg">rws</var>, <code class="code">ReducedForm( <var class="Arg">rws</var>, </code><span class="SimpleMath">u</span> <code class="code">) = ReducedForm( <var class="Arg">rws</var>, </code><span class="SimpleMath">v</span><code class="code">)</code> as words in the free algebra <span class="SimpleMath">T</span>. This element is the <em>unique normal form</em> of the element represented by <span class="SimpleMath">u</span>.</p>

<p>For an algebra <var class="Arg">A</var> with a canonical rewriting system associated with it, <code class="func">IsConfluent</code> checks whether that rewriting system is confluent.</p>

<p>Also seeĀ <code class="func">IsConfluent</code> (<a href="chap46.html#X7DF4835F79667099"><span class="RefLink">46.4-7</span></a>).</p>

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

<h5>38.1-6 ConfluentRws</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ConfluentRws</code>( <var class="Arg">rws</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Return a new rewriting system defining the same algebra as <var class="Arg">rws</var> which is confluent.</p>

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

<h5>38.1-7 IsReduced</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsReduced</code>( <var class="Arg">rws</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>A rewriting system is reduced if for each rule <span class="SimpleMath">(l, r)</span>, <span class="SimpleMath">l</span> and <span class="SimpleMath">r</span> are both reduced.</p>

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

<h5>38.1-8 ReduceRules</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReduceRules</code>( <var class="Arg">rws</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Reduce rules and remove redundant rules to make <var class="Arg">rws</var> reduced.</p>

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

<h5>38.1-9 AddRule</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddRule</code>( <var class="Arg">rws</var>, <var class="Arg">rule</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Add <var class="Arg">rule</var> to a rewriting system <var class="Arg">rws</var>.</p>

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

<h5>38.1-10 AddRuleReduced</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; AddRuleReduced</code>( <var class="Arg">rws</var>, <var class="Arg">rule</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Add <var class="Arg">rule</var> to rewriting system <var class="Arg">rws</var>. Performs a reduction operation on the resulting system, so that if <var class="Arg">rws</var> is reduced it will remain reduced.</p>

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

<h5>38.1-11 MakeConfluent</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; MakeConfluent</code>( <var class="Arg">rws</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>Add rules (and perhaps reduce) in order to make <var class="Arg">rws</var> confluent</p>

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

<h5>38.1-12 GeneratorsOfRws</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; GeneratorsOfRws</code>( <var class="Arg">rws</var> )</td><td class="tdright">( attribute )</td></tr></table></div>
<p>Returns the list of generators of the rewriting system <var class="Arg">rws</var>.</p>

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

<h4>38.2 <span class="Heading">Operations on elements of the algebra</span></h4>

<p>In this section let <span class="SimpleMath">u</span> denote an element of the term algebra <span class="SimpleMath">T</span> representing <span class="SimpleMath">[u]</span> in the quotient algebra <span class="SimpleMath">A</span>.</p>

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

<h5>38.2-1 ReducedProduct</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedProduct</code>( <var class="Arg">rws</var>, <var class="Arg">u</var>, <var class="Arg">v</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedSum</code>( <var class="Arg">rws</var>, <var class="Arg">left</var>, <var class="Arg">right</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedOne</code>( <var class="Arg">rws</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedAdditiveInverse</code>( <var class="Arg">rws</var>, <var class="Arg">obj</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedComm</code>( <var class="Arg">rws</var>, <var class="Arg">left</var>, <var class="Arg">right</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedConjugate</code>( <var class="Arg">rws</var>, <var class="Arg">left</var>, <var class="Arg">right</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedDifference</code>( <var class="Arg">rws</var>, <var class="Arg">left</var>, <var class="Arg">right</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedInverse</code>( <var class="Arg">rws</var>, <var class="Arg">obj</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedLeftQuotient</code>( <var class="Arg">rws</var>, <var class="Arg">left</var>, <var class="Arg">right</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedPower</code>( <var class="Arg">rws</var>, <var class="Arg">obj</var>, <var class="Arg">pow</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedQuotient</code>( <var class="Arg">rws</var>, <var class="Arg">left</var>, <var class="Arg">right</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedScalarProduct</code>( <var class="Arg">rws</var>, <var class="Arg">left</var>, <var class="Arg">right</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; ReducedZero</code>( <var class="Arg">rws</var> )</td><td class="tdright">( operation )</td></tr></table></div>
<p>The result of <code class="func">ReducedProduct</code> is <span class="SimpleMath">w</span> where <span class="SimpleMath">[w]</span> equals [<var class="Arg">u</var>][<var class="Arg">v</var>] in <span class="SimpleMath">A</span> and <span class="SimpleMath">w</span> is in reduced form.</p>

<p>The remaining operations are defined similarly when they are defined (as determined by the signature of the term algebra).</p>

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

<h4>38.3 <span class="Heading">Properties of rewriting systems</span></h4>

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

<h5>38.3-1 IsBuiltFromAdditiveMagmaWithInverses</h5>

<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsBuiltFromAdditiveMagmaWithInverses</code>( <var class="Arg">obj</var> )</td><td class="tdright">( property )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsBuiltFromMagma</code>( <var class="Arg">obj</var> )</td><td class="tdright">( property )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsBuiltFromMagmaWithOne</code>( <var class="Arg">obj</var> )</td><td class="tdright">( property )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsBuiltFromMagmaWithInverses</code>( <var class="Arg">obj</var> )</td><td class="tdright">( property )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsBuiltFromSemigroup</code>( <var class="Arg">obj</var> )</td><td class="tdright">( property )</td></tr></table></div>
<div class="func"><table class="func" width="100%"><tr><td class="tdleft"><code class="func">&#8227; IsBuiltFromGroup</code>( <var class="Arg">obj</var> )</td><td class="tdright">( property )</td></tr></table></div>
<p>These properties may be used to identify the type of term algebra over which the rewriting system is defined.</p>

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

<h4>38.4 <span class="Heading">Rewriting in Groups and Monoids</span></h4>

<p>One application of rewriting is to reduce words in finitely presented groups and monoids. The rewriting system still has to be built for a finitely presented monoid (using <code class="code">IsomorphismFpMonoid</code> for conversion). Rewriting then can take place for words in the underlying free monoid. (These can be obtained from monoid elements with the command <code class="code">UnderlyingElement</code>.)</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">f:=FreeGroup(3);;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">rels:=[f.1*f.2^2/f.3,f.2*f.3^2/f.1,f.3*f.1^2/f.2];;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">g:=f/rels;</span>
&lt;fp group on the generators [ f1, f2, f3 ]&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mhom:=IsomorphismFpMonoid(g);</span>
MappingByFunction( &lt;fp group on the generators 
[ f1, f2, f3 ]&gt;, &lt;fp monoid on the generators 
[ f1, f1^-1, f2, f2^-1, f3, f3^-1 
 ]&gt;, function( x ) ... end, function( x ) ... end )
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mon:=Image(mhom);</span>
&lt;fp monoid on the generators [ f1, f1^-1, f2, f2^-1, f3, f3^-1 ]&gt;
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">k:=KnuthBendixRewritingSystem(mon);</span>
Knuth Bendix Rewriting System for Monoid( 
[ f1, f1^-1, f2, f2^-1, f3, f3^-1 ], ... ) with rules 
[ [ f1*f1^-1, &lt;identity ...&gt; ], [ f1^-1*f1, &lt;identity ...&gt; ], 
  [ f2*f2^-1, &lt;identity ...&gt; ], [ f2^-1*f2, &lt;identity ...&gt; ], 
  [ f3*f3^-1, &lt;identity ...&gt; ], [ f3^-1*f3, &lt;identity ...&gt; ], 
  [ f1*f2^2*f3^-1, &lt;identity ...&gt; ], [ f2*f3^2*f1^-1, &lt;identity ...&gt; ]
    , [ f3*f1^2*f2^-1, &lt;identity ...&gt; ] ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MakeConfluent(k);</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:=Product(GeneratorsOfMonoid(mon));</span>
f1*f1^-1*f2*f2^-1*f3*f3^-1
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ReducedForm(k,UnderlyingElement(a));</span>
&lt;identity ...&gt;
</pre></div>

<p>To rewrite a word in the finitely presented group, one has to convert it to a word in the monoid first, rewrite in the underlying free monoid and convert back (by forming first again an element of the fp monoid) to the finitely presented group.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">r:=PseudoRandom(g);;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Length(r);</span>
3704
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">melm:=Image(mhom,r);;</span>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">red:=ReducedForm(k,UnderlyingElement(melm));</span>
f1^-1^3*f2^-1*f1^2
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">melm:=ElementOfFpMonoid(FamilyObj(One(mon)),red);</span>
f1^-1^3*f2^-1*f1^2
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">gpelm:=PreImagesRepresentative(mhom,melm);</span>
f1^-3*f2^-1*f1^2
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">r=gpelm;</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">CategoriesOfObject(red);</span>
[ "IsExtLElement", "IsExtRElement", "IsMultiplicativeElement", 
  "IsMultiplicativeElementWithOne", "IsAssociativeElement", "IsWord" ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">CategoriesOfObject(melm);</span>
[ "IsExtLElement", "IsExtRElement", "IsMultiplicativeElement", 
  "IsMultiplicativeElementWithOne", "IsAssociativeElement", 
  "IsElementOfFpMonoid" ]
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">CategoriesOfObject(gpelm);</span>
[ "IsExtLElement", "IsExtRElement", "IsMultiplicativeElement", 
  "IsMultiplicativeElementWithOne", "IsMultiplicativeElementWithInverse", 
  "IsAssociativeElement", "IsElementOfFpGroup" ]
</pre></div>

<p>Note, that the elements <code class="code">red</code> (free monoid) <code class="code">melm</code> (fp monoid) and <code class="code">gpelm</code> (group) differ, though they are displayed identically.</p>

<p>Under Unix, it is possible to use the <strong class="pkg">kbmag</strong> package to replace the built-in rewriting by this packages efficient C implementation. You can do this (after loading the <strong class="pkg">kbmag</strong> package) by assigning the variable <code class="func">KB_REW</code> (<a href="chap53.html#X7A3F8AE285C41D80"><span class="RefLink">53.6-2</span></a>) to <code class="code">KBMAG_REW</code>. Assignment to <code class="code">GAPKB_REW</code> reverts to the built-in implementation.</p>


<div class="example"><pre>
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">LoadPackage("kbmag");</span>
true
<span class="GAPprompt">gap&gt;</span> <span class="GAPinput">KB_REW:=KBMAG_REW;;</span>
</pre></div>

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

<h4>38.5 <span class="Heading">Developing rewriting systems</span></h4>

<p>The key point to note about rewriting systems is that they have properties such as <code class="func">IsConfluent</code> (<a href="chap38.html#X8006790B86328CE8"><span class="RefLink">38.1-5</span></a>) and attributes such as <code class="func">Rules</code> (<a href="chap38.html#X833EAA8C86356F42"><span class="RefLink">38.1-2</span></a>), however they are rarely stored, but rather computed afresh each time they are asked for, from data stored in the private members of the rewriting system object. This is because a rewriting system often evolves through a session, starting with some rules which define the algebra <var class="Arg">A</var> as relations, and then adding more rules to make the system confluent. For example, in the case of Knuth-Bendix rewriting systems (see ChapterĀ <a href="chap53.html#X7DE7C52A7C4BDADE"><span class="RefLink">53</span></a>), the function <code class="code">CreateKnuthBendixRewritingSystem</code> creating the rewriting system (in the file <code class="file">lib/kbsemi.gi</code>) uses</p>


<div class="example"><pre>
kbrws := Objectify(NewType(rwsfam, 
  IsMutable and IsKnuthBendixRewritingSystem and 
  IsKnuthBendixRewritingSystemRep), 
  rec(family:= fam,
  reduced:=false,
  tzrules:=List(relwco,i-&gt;
   [LetterRepAssocWord(i[1]),LetterRepAssocWord(i[2])]),
  pairs2check:=CantorList(Length(r)),
  ordering:=wordord,
  freefam:=freefam));
</pre></div>

<p>In particular, since we don't use the filter <code class="code">IsAttributeStoringRep</code> in the <code class="func">Objectify</code> (<a href="chap79.html#X7CB5C12E813F512B"><span class="RefLink">79.8-1</span></a>), whenever <code class="func">IsConfluent</code> (<a href="chap38.html#X8006790B86328CE8"><span class="RefLink">38.1-5</span></a>) is called, the appropriate method to determine confluence is called.</p>


<div class="chlinkprevnextbot">&nbsp;<a href="chap0.html">[Top of Book]</a>&nbsp;  <a href="chap0.html#contents">[Contents]</a>&nbsp;  &nbsp;<a href="chap37.html">[Previous Chapter]</a>&nbsp;  &nbsp;<a href="chap39.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>