@@ -39,14 +39,24 @@ Contents
39
39
* - :py:func: `remove_duplicate_rules `
40
40
- Remove duplicate rules.
41
41
42
+ * - :py:func: `remove_redundant_generators `
43
+ - Remove any trivially redundant generators.
44
+
45
+ * - :py:func: `remove_trivial_rules `
46
+ - Remove rules consisting of identical words.
47
+
42
48
* - :py:func: `reduce_complements `
43
- - If there are rules :math: `u = v` and :math: `v = w` where :math: `\lvert w \rvert < \lvert v \rvert `, then replace :math: `u = v` with :math: `u = w`.
49
+ - If there are rules :math: `u = v` and :math: `v = w` where :math: `\lvert w
50
+ \rvert < \lvert v \rvert `, then replace :math: `u = v` with :math: `u =
51
+ w`.
44
52
45
53
* - :py:func: `sort_each_rule `
46
- - Sort each rule :math: `u = v` so that the left hand side is shortlex greater than the right hand side.
54
+ - Sort each rule :math: `u = v` so that the left hand side is shortlex
55
+ greater than the right hand side.
47
56
48
57
* - :py:func: `sort_rules `
49
- - Sort the rules :math: `u_1 = v_1 , \ldots , u_n = v_n` so that :math: `u_1 v_1 < \cdots < u_n v_n`, where :math: `<` is the shortlex order.
58
+ - Sort the rules :math: `u_1 = v_1 , \ldots , u_n = v_n` so that :math: `u_1
59
+ v_1 < \cdots < u_n v_n`, where :math: `<` is the shortlex order.
50
60
51
61
* - :py:func: `longest_common_subword `
52
62
- Return the longest common subword of the rules.
@@ -192,8 +202,8 @@ Full API
192
202
193
203
Add rules for an identity element.
194
204
195
- Adds rules of the form :math: `a e = e a = a` for every letter :math: `a` in the alphabet of
196
- ``p ``, where :math: `e` is the second parameter.
205
+ Adds rules of the form :math: `a e = e a = a` for every letter :math: `a` in
206
+ the alphabet of ``p ``, where :math: `e` is the second parameter.
197
207
198
208
:param p: the presentation to add rules to
199
209
:type p: Presentation
@@ -213,10 +223,11 @@ Full API
213
223
214
224
Add rules for inverses.
215
225
216
- The letter `` a`` with index `` i`` in `` vals`` is the inverse of the letter in the alphabet
217
- of `` p`` with index `` i`` . The rules added are :math:`a_i b_i = e` , where the alphabet is
218
- :math:`\{a_i, \ldots, a_n\}`; the parameter ``vals`` is :math:`\{b_1, \ldots, b_n\}`; and
219
- :math:` e` is the 3rd parameter.
226
+ The letter `` a`` with index `` i`` in `` vals`` is the inverse of the letter
227
+ in the alphabet of `` p`` with index `` i`` . The rules added are :math:`a_i
228
+ b_i = e`, where the alphabet is :math:` \{a_i, \ldots, a_n\}`; the parameter
229
+ `` vals`` is :math:`\{b_1, \ldots, b_n\}`; and :math:`e` is the 3rd
230
+ parameter.
220
231
221
232
:param p: the presentation to add rules to
222
233
:type p: Presentation
@@ -238,9 +249,10 @@ Full API
238
249
239
250
Remove duplicate rules.
240
251
241
- Removes all but one instance of any duplicate rules (if any ). Note that rules of the form
242
- :math:`u = v` and :math:`v = u` (if any ) are considered duplicates. Also note that the
243
- rules may be reordered by this function even if there are no duplicate rules.
252
+ Removes all but one instance of any duplicate rules (if any ). Note that
253
+ rules of the form :math:`u = v` and :math:`v = u` (if any ) are considered
254
+ duplicates. Also note that the rules may be reordered by this function even
255
+ if there are no duplicate rules.
244
256
245
257
:param p: the presentation
246
258
:type p: Presentation
@@ -257,15 +269,50 @@ Full API
257
269
presentation.remove_duplicate_rules(p)
258
270
p.rules # ['ab', 'baa']
259
271
272
+ .. py:function:: remove_redundant_generators(p: Presentation) -> None
273
+
274
+ Remove any trivially redundant generators.
275
+
276
+ If one side of any of the rules in the presentation `` p`` is a letter
277
+ `` a`` and the other side of the rule does not contain `` a`` , then this
278
+ function replaces every occurrence of `` a`` in every rule by the other
279
+ side of the rule. This substitution is performed for every such
280
+ rule in the presentation; and the trivial rules (with both sides being
281
+ identical) are removed. If both sides of a rule are letters, then the
282
+ greater letter is replaced by the lesser one.
283
+
284
+ :param p: the presentation
285
+ :type p: Presentation
286
+
287
+ :returns: None
288
+
289
+ :raises RuntimeError : if `` len (p.rules)`` is odd.
290
+
291
+ .. py:function:: remove_trivial_rules(p: Presentation) -> None
292
+
293
+ Remove rules consisting of identical words.
294
+
295
+ Removes all instance of rules (if any ) where the left hand side and the
296
+ right hand side are identical.
297
+
298
+ :param p: the presentation
299
+ :type p: Presentation
300
+
301
+ :returns: None
302
+
303
+ :raises RuntimeError : if `` len (p.rules)`` is odd.
304
+
260
305
.. py:function:: reduce_complements(p: Presentation) -> None
261
306
262
- If there are rules :math:`u = v` and :math:`v = w` where :math:`\lvert w \rvert < \lvert v \rvert`, then replace :math:`u = v` with :math:`u = w`.
307
+ If there are rules :math:`u = v` and :math:`v = w` where :math:`\lvert w
308
+ \rvert < \lvert v \rvert`, then replace :math:`u = v` with :math:`u = w`.
263
309
264
- Attempts to reduce the length of the words by finding the equivalence relation on the
265
- relation words generated by the pairs of identical relation words. If
266
- :math:`\{u_1, u_2, \ldots, u_n\}` are distinct words in an equivalence class and
267
- :math:` u_1` is the shortlex minimum word in the class , then the relation words are
268
- replaced by :math:`u_1 = u_2, u_1 = u_3, \ldots, u_1 = u_n`.
310
+ Attempts to reduce the length of the words by finding the equivalence
311
+ relation on the relation words generated by the pairs of identical relation
312
+ words. If :math:`\{u_1, u_2, \ldots, u_n\}` are distinct words in an
313
+ equivalence class and :math:` u_1` is the shortlex minimum word in the class ,
314
+ then the relation words are replaced by :math:`u_1 = u_2, u_1 = u_3, \ldots,
315
+ u_1 = u_n` .
269
316
270
317
:param p: the presentation
271
318
:type p: Presentation
@@ -284,8 +331,8 @@ Full API
284
331
285
332
.. py:function:: sort_each_rule(p: Presentation) -> None
286
333
287
- Sort each rule :math:`u = v` so that the left hand side is shortlex greater than the right
288
- hand side.
334
+ Sort each rule :math:`u = v` so that the left hand side is shortlex greater
335
+ than the right hand side.
289
336
290
337
:param p: the presentation
291
338
:type p: Presentation
@@ -306,24 +353,45 @@ Full API
306
353
307
354
Return the longest common subword of the rules.
308
355
309
- If it is possible to find a subword :math:`w` of the rules
310
- :math: `u_1 = v_1, \ldots, u_n = v_n` such that the introduction of a new generator
311
- :math:` z ` and the relation :math:` z = w` reduces the length (see :py:func:`length` )
312
- of the presentation, then this function returns the word :math:`w` . If no such word can be
313
- found, a word of length :math:`0 ` is returned.
356
+ If it is possible to find a subword :math:`w` of the rules :math: `u_1 = v_1,
357
+ \ldots, u_n = v_n` such that the introduction of a new generator :math:`z`
358
+ and the relation :math:`z = w` reduces the length (see :py:func:`length` ) of
359
+ the presentation, then this function returns the word :math:`w` . If no such
360
+ word can be found, a word of length :math:`0 ` is returned.
314
361
315
362
:param p: the presentation
316
363
:type p: Presentation
317
364
318
365
:returns: None
319
366
367
+ .. py:function:: replace_subword(p: Presentation, existing: Union[str , List[int ]], replacement: Union[str , List[int ]])
368
+ :noindex:
369
+
370
+ Replace non- overlapping instances of a subword by another word.
371
+
372
+ If `` existing`` and `` replacement`` are words, then this function replaces
373
+ every non- overlapping instance of `` existing`` in every rule by
374
+ `` replacement`` . The presentation `` p`` is changed in - place.
375
+
376
+ :param p: the presentation
377
+ :type p: Presentation
378
+ :param existing: the word to be replaced
379
+ :type existing: str or List[int ]
380
+ :param replacement: the replacement word.
381
+ :type replacement: str or List[int ]
382
+
383
+ :returns: None
384
+
385
+ :raises RuntimeError : if `` existing`` is empty.
386
+
320
387
.. py:function:: replace_subword(p: Presentation, w: Union[str , List[int ]])
321
388
322
389
Replace non- overlapping instances of a subword.
323
390
324
- A new generator :math:`z` is added to the presentation, along with the rule :math:`w = z` .
325
- Each (if any ) non- overlapping instance (from left to right) of the word :math:`w` in every
326
- rule of the presentation is replaced with :math:`z` .
391
+ A new generator :math:`z` is added to the presentation, along with the rule
392
+ :math:`w = z` . Each (if any ) non- overlapping instance (from left to right)
393
+ of the word :math:`w` in every rule of the presentation is replaced with
394
+ :math:`z` .
327
395
328
396
:param p: the presentation
329
397
:type p: Presentation
@@ -359,10 +427,11 @@ Full API
359
427
360
428
.. py:function:: normalize_alphabet(p: Presentation) -> None
361
429
362
- Modify the presentation so that the alphabet is :math:`\{0, \ldots, n - 1\}` (or equivalent),
363
- and rewrites the rules to use this alphabet.
430
+ Modify the presentation so that the alphabet is :math:`\{0, \ldots, n - 1\}`
431
+ ( or equivalent), and rewrites the rules to use this alphabet.
364
432
365
- If the alphabet is already normalized, then no changes are made to the presentation.
433
+ If the alphabet is already normalized, then no changes are made to the
434
+ presentation.
366
435
367
436
:param p: the presentation
368
437
:type p: Presentation
0 commit comments