File: rws.xml

package info (click to toggle)
gap 4.15.1-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 110,212 kB
  • sloc: ansic: 97,261; xml: 48,343; cpp: 13,946; sh: 4,900; perl: 1,650; javascript: 255; makefile: 252; ruby: 9
file content (224 lines) | stat: -rw-r--r-- 8,587 bytes parent folder | download | duplicates (2)
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
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<!-- %% -->
<!-- %A  rws.xml                GAP documentation                Andrew Solomon -->
<!-- %% -->
<!-- %% -->
<!-- %Y  (C) 1999 School Math and Comp. Sci., University of St Andrews, Scotland -->
<!-- %Y  Copyright (C) 2002 The GAP Group -->
<!-- %% -->
<Chapter Label="Rewriting Systems">
<Heading>Rewriting Systems</Heading>

Rewriting systems in &GAP; are a framework for dealing with
the very general task of rewriting elements of a free (or <E>term</E>) algebra
in some normal form.  Although most rewriting systems currently in use
are <E>string rewriting systems</E> (where the algebra has only one
binary operation which is associative) the framework in &GAP;
is general enough to encompass the task of rewriting algebras of
any signature from groups to semirings.
<P/>
Rewriting systems are already implemented in  &GAP;
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/>
We fix some definitions and terminology for the rest of this chapter.
Let <M>T</M> be a term algebra in some signature.
A <E>term rewriting system</E> for <M>T</M> is a set of ordered pairs of
elements of <M>T</M> of the form <M>(l, r)</M>.
Viewed as a set of relations, the
rewriting system determines a presentation for a quotient algebra <M>A</M>
of <M>T</M>.
<P/>
When we take into account the fact that
the relations are expressed as <E>ordered</E> pairs, we have a way of
<E>reducing</E> the elements of <M>T</M>.
Suppose an element <M>u</M> of <M>T</M> has a
subword <M>l</M> and <M>(l, r)</M> is a rule of the rewriting system, then
we can replace the subterm <M>l</M> of <M>u</M> by the term <M>r</M>
and obtain a new word <M>v</M>.
We say that we have <E>rewritten</E> <M>u</M> as <M>v</M>.
Note that <M>u</M> and <M>v</M> represent the same element of <M>A</M>.
If <M>u</M> cannot be rewritten using any rule of the rewriting system
we sat that <M>u</M> is <E>reduced</E>.


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Operations on rewriting systems">
<Heading>Operations on rewriting systems</Heading>

<#Include Label="IsRewritingSystem">
<#Include Label="Rules">
<#Include Label="OrderOfRewritingSystem">
<#Include Label="ReducedForm">
<#Include Label="IsConfluent">
<#Include Label="ConfluentRws">
<#Include Label="IsReduced">
<#Include Label="ReduceRules">
<#Include Label="AddRule">
<#Include Label="AddRuleReduced">
<#Include Label="MakeConfluent">
<#Include Label="GeneratorsOfRws">

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Operations on elements of the algebra">
<Heading>Operations on elements of the algebra</Heading>

In this section let <M>u</M> denote an element of the term algebra
<M>T</M> representing <M>[u]</M> in the quotient algebra <M>A</M>.

<ManSection>
<Oper Name="ReducedProduct" Arg='rws, u, v'/>
<Oper Name="ReducedSum" Arg='rws, left, right'/>
<Oper Name="ReducedOne" Arg='rws'/>
<Oper Name="ReducedAdditiveInverse" Arg='rws, obj'/>
<Oper Name="ReducedComm" Arg='rws, left, right'/>
<Oper Name="ReducedConjugate" Arg='rws, left, right'/>
<Oper Name="ReducedDifference" Arg='rws, left, right'/>
<Oper Name="ReducedInverse" Arg='rws, obj'/>
<Oper Name="ReducedLeftQuotient" Arg='rws, left, right'/>
<Oper Name="ReducedPower" Arg='rws, obj, pow'/>
<Oper Name="ReducedQuotient" Arg='rws, left, right'/>
<Oper Name="ReducedScalarProduct" Arg='rws, left, right'/>
<Oper Name="ReducedZero" Arg='rws'/>

<Description>
The result of <Ref Oper="ReducedProduct"/> is <M>w</M> where
<M>[w]</M> equals [<A>u</A>][<A>v</A>] in <M>A</M> and <M>w</M>
is in reduced form.
<P/>
The remaining operations are defined similarly when they
are defined (as determined by the signature of the term algebra).
</Description>
</ManSection>

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Properties of rewriting systems">
<Heading>Properties of rewriting systems</Heading>

<ManSection>
<Prop Name="IsBuiltFromAdditiveMagmaWithInverses" Arg='obj'/>
<Prop Name="IsBuiltFromMagma" Arg='obj'/>
<Prop Name="IsBuiltFromMagmaWithOne" Arg='obj'/>
<Prop Name="IsBuiltFromMagmaWithInverses" Arg='obj'/>
<Prop Name="IsBuiltFromSemigroup" Arg='obj'/>
<Prop Name="IsBuiltFromGroup" Arg='obj'/>

<Description>
These properties may be used to identify the type of term algebra
over which the rewriting system is defined.
</Description>
</ManSection>

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Rewriting in Groups and Monoids">
<Heading>Rewriting in Groups and Monoids</Heading>

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 <C>IsomorphismFpMonoid</C> for conversion). Rewriting
then can take place for words in the underlying free monoid. (These can be
obtained from monoid elements with the command <C>UnderlyingElement</C>.)
<P/>
<Example><![CDATA[
gap> f:=FreeGroup(3);;
gap> rels:=[f.1*f.2^2/f.3,f.2*f.3^2/f.1,f.3*f.1^2/f.2];;
gap> g:=f/rels;
<fp group on the generators [ f1, f2, f3 ]>
gap> mhom:=IsomorphismFpMonoid(g);
MappingByFunction( <fp group on the generators
[ f1, f2, f3 ]>, <fp monoid on the generators
[ f1, f1^-1, f2, f2^-1, f3, f3^-1
 ]>, function( x ) ... end, function( x ) ... end )
gap> mon:=Image(mhom);
<fp monoid on the generators [ f1, f1^-1, f2, f2^-1, f3, f3^-1 ]>
gap> k:=KnuthBendixRewritingSystem(mon);
Knuth Bendix Rewriting System for Monoid(
[ f1, f1^-1, f2, f2^-1, f3, f3^-1 ] ) with rules
[ [ f1*f1^-1, <identity ...> ], [ f1^-1*f1, <identity ...> ],
  [ f2*f2^-1, <identity ...> ], [ f2^-1*f2, <identity ...> ],
  [ f3*f3^-1, <identity ...> ], [ f3^-1*f3, <identity ...> ],
  [ f1*f2^2*f3^-1, <identity ...> ], [ f2*f3^2*f1^-1, <identity ...> ]
    , [ f3*f1^2*f2^-1, <identity ...> ] ]
gap> MakeConfluent(k);
gap> a:=Product(GeneratorsOfMonoid(mon));
f1*f1^-1*f2*f2^-1*f3*f3^-1
gap> ReducedForm(k,UnderlyingElement(a));
<identity ...>
]]></Example>
<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/>
<!-- % this example uses random and would be a hassle to modify every time -->
<!-- % something changes -->
<Log><![CDATA[
gap> r:=PseudoRandom(g);;
gap> Length(r);
3704
gap> melm:=Image(mhom,r);;
gap> red:=ReducedForm(k,UnderlyingElement(melm));
f1^-1^3*f2^-1*f1^2
gap> melm:=ElementOfFpMonoid(FamilyObj(One(mon)),red);
f1^-1^3*f2^-1*f1^2
gap> gpelm:=PreImagesRepresentative(mhom,melm);
f1^-3*f2^-1*f1^2
gap> r=gpelm;
true
gap> CategoriesOfObject(red);
[ "IsExtLElement", "IsExtRElement", "IsMultiplicativeElement",
  "IsMultiplicativeElementWithOne", "IsAssociativeElement", "IsWord" ]
gap> CategoriesOfObject(melm);
[ "IsExtLElement", "IsExtRElement", "IsMultiplicativeElement",
  "IsMultiplicativeElementWithOne", "IsAssociativeElement",
  "IsElementOfFpMonoid" ]
gap> CategoriesOfObject(gpelm);
[ "IsExtLElement", "IsExtRElement", "IsMultiplicativeElement",
  "IsMultiplicativeElementWithOne", "IsMultiplicativeElementWithInverse",
  "IsAssociativeElement", "IsElementOfFpGroup" ]
]]></Log>
<P/>
Note, that the elements <C>red</C> (free monoid) <C>melm</C> (fp monoid) and <C>gpelm</C>
(group) differ, though they are displayed identically.
<P/>
Under Unix, it is possible to use the <Package>kbmag</Package> package
to replace the built-in rewriting by this packages efficient C implementation.
You can do this (after loading the <Package>kbmag</Package> package)
by assigning the variable <Ref Var="KB_REW"/> to <C>KBMAG_REW</C>.
Assignment to <C>GAPKB_REW</C> reverts to the built-in implementation.
<Log><![CDATA[
gap> LoadPackage("kbmag");
true
gap> KB_REW:=KBMAG_REW;;
]]></Log>

</Section>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Developing rewriting systems">
<Heading>Developing rewriting systems</Heading>

<#Include Label="[2]{rws}">

</Section>
</Chapter>


<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<!-- %% -->
<!-- %E -->