Debian Codegraph @

doc/ref/chap38.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 38: Rewriting Systems</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="chap38" 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="chap37.html">[Previous Chapter]</a>&nbsp; &nbsp;<a href="chap39.html">[Next Chapter]</a>&nbsp; </div>
21
22 <p id="mathjaxlink" class="pcenter"><a href="chap38_mj.html">[MathJax on]</a></p>
23 <p><a id="X7CA8FCFD81AA1890" name="X7CA8FCFD81AA1890"></a></p>
24 <div class="ChapSects"><a href="chap38.html#X7CA8FCFD81AA1890">38 <span class="Heading">Rewriting Systems</span></a>
25 <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>
26 </span>
27 <div class="ContSSBlock">
28 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X842C0ED87986F7AA">38.1-1 IsRewritingSystem</a></span>
29 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X833EAA8C86356F42">38.1-2 Rules</a></span>
30 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X7C38C2EF817F9E0A">38.1-3 OrderOfRewritingSystem</a></span>
31 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X8340EB2280DE6CCC">38.1-4 ReducedForm</a></span>
32 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X8006790B86328CE8">38.1-5 <span class="Heading">IsConfluent</span></a>
33 </span>
34 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X870A1E1C7FB45A55">38.1-6 ConfluentRws</a></span>
35 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X8134689C7B576946">38.1-7 IsReduced</a></span>
36 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X864C82FD7FBA31A6">38.1-8 ReduceRules</a></span>
37 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X81E6B5CB789A7C3A">38.1-9 AddRule</a></span>
38 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X7FA0B54D7C533DDC">38.1-10 AddRuleReduced</a></span>
39 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X7BD6299E85561DC3">38.1-11 MakeConfluent</a></span>
40 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X795DC25886007DFE">38.1-12 GeneratorsOfRws</a></span>
41 </div></div>
42 <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>
43 </span>
44 <div class="ContSSBlock">
45 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X81BB38CC793F7CE2">38.2-1 ReducedProduct</a></span>
46 </div></div>
47 <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>
48 </span>
49 <div class="ContSSBlock">
50 <span class="ContSS"><br /><span class="nocss">&nbsp;&nbsp;</span><a href="chap38.html#X7B647DB77D138A49">38.3-1 IsBuiltFromAdditiveMagmaWithInverses</a></span>
51 </div></div>
52 <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>
53 </span>
54 </div>
55 <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>
56 </span>
57 </div>
58 </div>
59
60 <h3>38 <span class="Heading">Rewriting Systems</span></h3>
61
62 <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>
63
64 <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>
65
66 <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>
67
68 <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> cannot be rewritten using any rule of the rewriting system we sat that <span class="SimpleMath">u</span> is <em>reduced</em>.</p>
69
70 <p><a id="X8287CBE183EBE5D7" name="X8287CBE183EBE5D7"></a></p>
71
72 <h4>38.1 <span class="Heading">Operations on rewriting systems</span></h4>
73
74 <p><a id="X842C0ED87986F7AA" name="X842C0ED87986F7AA"></a></p>
75
76 <h5>38.1-1 IsRewritingSystem</h5>
77
78 <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">(&nbsp;category&nbsp;)</td></tr></table></div>
79 <p>This is the category in which all rewriting systems lie.</p>
80
81 <p><a id="X833EAA8C86356F42" name="X833EAA8C86356F42"></a></p>
82
83 <h5>38.1-2 Rules</h5>
84
85 <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">(&nbsp;attribute&nbsp;)</td></tr></table></div>
86 <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>
87
88 <p><a id="X7C38C2EF817F9E0A" name="X7C38C2EF817F9E0A"></a></p>
89
90 <h5>38.1-3 OrderOfRewritingSystem</h5>
91
92 <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">(&nbsp;attribute&nbsp;)</td></tr></table></div>
93 <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">(&nbsp;attribute&nbsp;)</td></tr></table></div>
94 <p>return the ordering of the rewriting system <var class="Arg">rws</var>.</p>
95
96 <p><a id="X8340EB2280DE6CCC" name="X8340EB2280DE6CCC"></a></p>
97
98 <h5>38.1-4 ReducedForm</h5>
99
100 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
101 <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>
102
103 <p><a id="X8006790B86328CE8" name="X8006790B86328CE8"></a></p>
104
105 <h5>38.1-5 <span class="Heading">IsConfluent</span></h5>
106
107 <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">(&nbsp;property&nbsp;)</td></tr></table></div>
108 <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">(&nbsp;property&nbsp;)</td></tr></table></div>
109 <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>
110
111 <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>
112
113 <p>Also seeĀ <code class="func">IsConfluent</code> (<a href="chap46.html#X7DF4835F79667099"><span class="RefLink">46.4-7</span></a>).</p>
114
115 <p><a id="X870A1E1C7FB45A55" name="X870A1E1C7FB45A55"></a></p>
116
117 <h5>38.1-6 ConfluentRws</h5>
118
119 <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">(&nbsp;attribute&nbsp;)</td></tr></table></div>
120 <p>Return a new rewriting system defining the same algebra as <var class="Arg">rws</var> which is confluent.</p>
121
122 <p><a id="X8134689C7B576946" name="X8134689C7B576946"></a></p>
123
124 <h5>38.1-7 IsReduced</h5>
125
126 <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">(&nbsp;property&nbsp;)</td></tr></table></div>
127 <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>
128
129 <p><a id="X864C82FD7FBA31A6" name="X864C82FD7FBA31A6"></a></p>
130
131 <h5>38.1-8 ReduceRules</h5>
132
133 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
134 <p>Reduce rules and remove redundant rules to make <var class="Arg">rws</var> reduced.</p>
135
136 <p><a id="X81E6B5CB789A7C3A" name="X81E6B5CB789A7C3A"></a></p>
137
138 <h5>38.1-9 AddRule</h5>
139
140 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
141 <p>Add <var class="Arg">rule</var> to a rewriting system <var class="Arg">rws</var>.</p>
142
143 <p><a id="X7FA0B54D7C533DDC" name="X7FA0B54D7C533DDC"></a></p>
144
145 <h5>38.1-10 AddRuleReduced</h5>
146
147 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
148 <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>
149
150 <p><a id="X7BD6299E85561DC3" name="X7BD6299E85561DC3"></a></p>
151
152 <h5>38.1-11 MakeConfluent</h5>
153
154 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
155 <p>Add rules (and perhaps reduce) in order to make <var class="Arg">rws</var> confluent</p>
156
157 <p><a id="X795DC25886007DFE" name="X795DC25886007DFE"></a></p>
158
159 <h5>38.1-12 GeneratorsOfRws</h5>
160
161 <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">(&nbsp;attribute&nbsp;)</td></tr></table></div>
162 <p>Returns the list of generators of the rewriting system <var class="Arg">rws</var>.</p>
163
164 <p><a id="X81B812C778CB1E4E" name="X81B812C778CB1E4E"></a></p>
165
166 <h4>38.2 <span class="Heading">Operations on elements of the algebra</span></h4>
167
168 <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>
169
170 <p><a id="X81BB38CC793F7CE2" name="X81BB38CC793F7CE2"></a></p>
171
172 <h5>38.2-1 ReducedProduct</h5>
173
174 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
175 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
176 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
177 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
178 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
179 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
180 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
181 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
182 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
183 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
184 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
185 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
186 <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">(&nbsp;operation&nbsp;)</td></tr></table></div>
187 <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>
188
189 <p>The remaining operations are defined similarly when they are defined (as determined by the signature of the term algebra).</p>
190
191 <p><a id="X8318649681DF783B" name="X8318649681DF783B"></a></p>
192
193 <h4>38.3 <span class="Heading">Properties of rewriting systems</span></h4>
194
195 <p><a id="X7B647DB77D138A49" name="X7B647DB77D138A49"></a></p>
196
197 <h5>38.3-1 IsBuiltFromAdditiveMagmaWithInverses</h5>
198
199 <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">(&nbsp;property&nbsp;)</td></tr></table></div>
200 <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">(&nbsp;property&nbsp;)</td></tr></table></div>
201 <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">(&nbsp;property&nbsp;)</td></tr></table></div>
202 <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">(&nbsp;property&nbsp;)</td></tr></table></div>
203 <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">(&nbsp;property&nbsp;)</td></tr></table></div>
204 <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">(&nbsp;property&nbsp;)</td></tr></table></div>
205 <p>These properties may be used to identify the type of term algebra over which the rewriting system is defined.</p>
206
207 <p><a id="X7F8B7848851784DF" name="X7F8B7848851784DF"></a></p>
208
209 <h4>38.4 <span class="Heading">Rewriting in Groups and Monoids</span></h4>
210
211 <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>
212
213
214 <div class="example"><pre>
215 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">f:=FreeGroup(3);;</span>
216 <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>
217 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">g:=f/rels;</span>
218 &lt;fp group on the generators [ f1, f2, f3 ]&gt;
219 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mhom:=IsomorphismFpMonoid(g);</span>
220 MappingByFunction( &lt;fp group on the generators
221 [ f1, f2, f3 ]&gt;, &lt;fp monoid on the generators
222 [ f1, f1^-1, f2, f2^-1, f3, f3^-1
223 ]&gt;, function( x ) ... end, function( x ) ... end )
224 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">mon:=Image(mhom);</span>
225 &lt;fp monoid on the generators [ f1, f1^-1, f2, f2^-1, f3, f3^-1 ]&gt;
226 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">k:=KnuthBendixRewritingSystem(mon);</span>
227 Knuth Bendix Rewriting System for Monoid(
228 [ f1, f1^-1, f2, f2^-1, f3, f3^-1 ] ) with rules
229 [ [ f1*f1^-1, &lt;identity ...&gt; ], [ f1^-1*f1, &lt;identity ...&gt; ],
230 [ f2*f2^-1, &lt;identity ...&gt; ], [ f2^-1*f2, &lt;identity ...&gt; ],
231 [ f3*f3^-1, &lt;identity ...&gt; ], [ f3^-1*f3, &lt;identity ...&gt; ],
232 [ f1*f2^2*f3^-1, &lt;identity ...&gt; ], [ f2*f3^2*f1^-1, &lt;identity ...&gt; ]
233 , [ f3*f1^2*f2^-1, &lt;identity ...&gt; ] ]
234 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">MakeConfluent(k);</span>
235 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">a:=Product(GeneratorsOfMonoid(mon));</span>
236 f1*f1^-1*f2*f2^-1*f3*f3^-1
237 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">ReducedForm(k,UnderlyingElement(a));</span>
238 &lt;identity ...&gt;
239 </pre></div>
240
241 <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>
242
243
244 <div class="example"><pre>
245 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">r:=PseudoRandom(g);;</span>
246 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">Length(r);</span>
247 3704
248 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">melm:=Image(mhom,r);;</span>
249 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">red:=ReducedForm(k,UnderlyingElement(melm));</span>
250 f1^-1^3*f2^-1*f1^2
251 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">melm:=ElementOfFpMonoid(FamilyObj(One(mon)),red);</span>
252 f1^-1^3*f2^-1*f1^2
253 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">gpelm:=PreImagesRepresentative(mhom,melm);</span>
254 f1^-3*f2^-1*f1^2
255 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">r=gpelm;</span>
256 true
257 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">CategoriesOfObject(red);</span>
258 [ "IsExtLElement", "IsExtRElement", "IsMultiplicativeElement",
259 "IsMultiplicativeElementWithOne", "IsAssociativeElement", "IsWord" ]
260 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">CategoriesOfObject(melm);</span>
261 [ "IsExtLElement", "IsExtRElement", "IsMultiplicativeElement",
262 "IsMultiplicativeElementWithOne", "IsAssociativeElement",
263 "IsElementOfFpMonoid" ]
264 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">CategoriesOfObject(gpelm);</span>
265 [ "IsExtLElement", "IsExtRElement", "IsMultiplicativeElement",
266 "IsMultiplicativeElementWithOne", "IsMultiplicativeElementWithInverse",
267 "IsAssociativeElement", "IsElementOfFpGroup" ]
268 </pre></div>
269
270 <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>
271
272 <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="chap52.html#X7A3F8AE285C41D80"><span class="RefLink">52.5-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>
273
274
275 <div class="example"><pre>
276 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">LoadPackage("kbmag");</span>
277 true
278 <span class="GAPprompt">gap&gt;</span> <span class="GAPinput">KB_REW:=KBMAG_REW;;</span>
279 </pre></div>
280
281 <p><a id="X8751F8FA7DC989A2" name="X8751F8FA7DC989A2"></a></p>
282
283 <h4>38.5 <span class="Heading">Developing rewriting systems</span></h4>
284
285 <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="chap52.html#X7DE7C52A7C4BDADE"><span class="RefLink">52</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>
286
287
288 <div class="example"><pre>
289 kbrws := Objectify(NewType(rwsfam,
290 IsMutable and IsKnuthBendixRewritingSystem and
291 IsKnuthBendixRewritingSystemRep),
292 rec(family:= fam,
293 reduced:=false,
294 tzrules:=List(relwco,i-&gt;
295 [LetterRepAssocWord(i[1]),LetterRepAssocWord(i[2])]),
296 pairs2check:=CantorList(Length(r)),
297 ordering:=wordord,
298 freefam:=freefam));
299 </pre></div>
300
301 <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.1-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>
302
303
304 <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>
305
306
307 <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>
308
309 <hr />
310 <p class="foot">generated by <a href="https://www.math.rwth-aachen.de/~Frank.Luebeck/GAPDoc">GAPDoc2HTML</a></p>
311 </body>
312 </html>