Skip to content

Commit 2e2ef80

Browse files
committed
doc: add docs for kambites,tc,cong,stephen to pres
1 parent 76bb165 commit 2e2ef80

File tree

1 file changed

+248
-2
lines changed

1 file changed

+248
-2
lines changed

docs/source/data-structures/presentations/to-present.rst

Lines changed: 248 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ possible:
2929

3030
- :ref:`presentation-to-presentation`;
3131
- :ref:`presentation-and-function-to-presentation`;
32-
- :ref:`knuth-bendix-to-presentation`; and
33-
- :ref:`froidure-pin-to-presentation`.
32+
- :ref:`knuth-bendix-to-presentation`;
33+
- :ref:`froidure-pin-to-presentation`;
34+
- :ref:`kambites-to-presentation`;
35+
- :ref:`todd-coxeter-to-presentation`;
36+
- :ref:`congruence-to-presentation`; and
37+
- :ref:`stephen-to-presentation`.
3438

3539
.. _presentation-to-presentation:
3640

@@ -266,3 +270,245 @@ to calling this function.
266270
>>> p = to(S, rtype=(Presentation, str))
267271
>>> len(p.alphabet()) == 4
268272
True
273+
274+
.. _kambites-to-presentation:
275+
276+
Converting a :any:`Kambites` to a :any:`Presentation`
277+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
278+
279+
To construct a :any:`Presentation` from a :any:`Kambites`, specify the
280+
following values for *args*:
281+
282+
- **k** (:any:`Kambites`) -- the :any:`Kambites` from which to obtain
283+
the presentation.
284+
285+
Additionally, specify one of the following for *Return*:
286+
287+
- ``(Presentation,)`` for constructing a :any:`Presentation` over words of
288+
the same type as that in *k*.
289+
- ``(Presentation, str)`` for constructing a :any:`Presentation` over words
290+
of type ``str``.
291+
- ``(Presentation, list[int])`` for constructing a :any:`Presentation` over
292+
words of type ``list[int]``.
293+
294+
This function constructs and returns a :any:`Presentation` object that is
295+
equivalent to the presentation used to construct the :any:`Kambites` object.
296+
When the word type matches, this function returns a reference to ``k.presentation()``.
297+
When the word types differ, a converted copy is returned.
298+
299+
No computation is performed by this function; it simply retrieves the
300+
presentation that was used to define the :any:`Kambites` object.
301+
302+
.. seealso::
303+
304+
- :any:`Kambites.presentation`.
305+
306+
.. doctest:: Python
307+
308+
>>> from libsemigroups_pybind11 import (
309+
... congruence_kind,
310+
... Kambites,
311+
... Presentation,
312+
... presentation,
313+
... to,
314+
... )
315+
316+
>>> p = Presentation([5, 6, 7, 8, 9])
317+
>>> presentation.add_rule(p, [5, 6], [7])
318+
>>> presentation.add_rule(p, [6, 7], [8])
319+
>>> presentation.add_rule(p, [7, 8], [9])
320+
>>> presentation.add_rule(p, [8, 9], [5])
321+
>>> presentation.add_rule(p, [9, 5], [6])
322+
323+
>>> k = Kambites(congruence_kind.twosided, p)
324+
>>> result = to(k, rtype=(Presentation, list[int]))
325+
>>> result == p
326+
True
327+
328+
>>> result_str = to(k, rtype=(Presentation, str))
329+
>>> result_str.alphabet()
330+
'abcde'
331+
>>> result_str.rules
332+
['ab', 'c', 'bc', 'd', 'cd', 'e', 'de', 'a', 'ea', 'b']
333+
334+
.. _todd-coxeter-to-presentation:
335+
336+
Converting a :any:`ToddCoxeter` to a :any:`Presentation`
337+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
338+
339+
To construct a :any:`Presentation` from a :any:`ToddCoxeter`, specify the
340+
following values for *args*:
341+
342+
- **tc** (:any:`ToddCoxeter`) -- the :any:`ToddCoxeter` from which to obtain
343+
the presentation.
344+
345+
Additionally, specify one of the following for *Return*:
346+
347+
- ``(Presentation,)`` for constructing a :any:`Presentation` over words of
348+
the same type as that in *tc*.
349+
- ``(Presentation, str)`` for constructing a :any:`Presentation` over words
350+
of type ``str``.
351+
- ``(Presentation, list[int])`` for constructing a :any:`Presentation` over
352+
words of type ``list[int]``.
353+
354+
This function constructs and returns a :any:`Presentation` object that is
355+
equivalent to the presentation used to construct the :any:`ToddCoxeter` object.
356+
When the word type matches, this function returns a reference to ``tc.presentation()``.
357+
When the word types differ, a converted copy is returned.
358+
359+
No computation is performed by this function; it simply retrieves the
360+
presentation that was used to define the :any:`ToddCoxeter` object.
361+
362+
.. seealso::
363+
364+
- :any:`ToddCoxeter.presentation`.
365+
366+
.. doctest:: Python
367+
368+
>>> from libsemigroups_pybind11 import (
369+
... congruence_kind,
370+
... ToddCoxeter,
371+
... Presentation,
372+
... presentation,
373+
... to,
374+
... )
375+
376+
>>> p = Presentation([5, 6, 7, 8, 9])
377+
>>> presentation.add_rule(p, [5, 6], [7])
378+
>>> presentation.add_rule(p, [6, 7], [8])
379+
>>> presentation.add_rule(p, [7, 8], [9])
380+
>>> presentation.add_rule(p, [8, 9], [5])
381+
>>> presentation.add_rule(p, [9, 5], [6])
382+
383+
>>> tc = ToddCoxeter(congruence_kind.twosided, p)
384+
>>> result = to(tc, rtype=(Presentation, list[int]))
385+
>>> result == p
386+
True
387+
388+
>>> result_str = to(tc, rtype=(Presentation, str))
389+
>>> result_str.alphabet()
390+
'abcde'
391+
>>> result_str.rules
392+
['ab', 'c', 'bc', 'd', 'cd', 'e', 'de', 'a', 'ea', 'b']
393+
394+
.. _congruence-to-presentation:
395+
396+
Converting a :any:`Congruence` to a :any:`Presentation`
397+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
398+
399+
To construct a :any:`Presentation` from a :any:`Congruence`, specify the
400+
following values for *args*:
401+
402+
- **c** (:any:`Congruence`) -- the :any:`Congruence` from which to obtain
403+
the presentation.
404+
405+
Additionally, specify one of the following for *Return*:
406+
407+
- ``(Presentation,)`` for constructing a :any:`Presentation` over words of
408+
the same type as that in *c*.
409+
- ``(Presentation, str)`` for constructing a :any:`Presentation` over words
410+
of type ``str``.
411+
- ``(Presentation, list[int])`` for constructing a :any:`Presentation` over
412+
words of type ``list[int]``.
413+
414+
This function constructs and returns a :any:`Presentation` object that is
415+
equivalent to the presentation used to construct the :any:`Congruence` object.
416+
When the word type matches, this function returns a reference to ``c.presentation()``.
417+
When the word types differ, a converted copy is returned.
418+
419+
No computation is performed by this function; it simply retrieves the
420+
presentation that was used to define the :any:`Congruence` object. Note that
421+
any generating pairs added via :any:`Congruence.add_generating_pair`
422+
are not included in the returned presentation.
423+
424+
.. seealso::
425+
426+
- :any:`Congruence.presentation`; and
427+
- :any:`Congruence.add_generating_pair`.
428+
429+
.. doctest:: Python
430+
431+
>>> from libsemigroups_pybind11 import (
432+
... congruence_kind,
433+
... Congruence,
434+
... Presentation,
435+
... presentation,
436+
... to,
437+
... )
438+
439+
>>> p = Presentation("abc")
440+
>>> presentation.add_rule(p, "aa", "b")
441+
>>> presentation.add_rule(p, "bb", "c")
442+
>>> presentation.add_rule(p, "cc", "a")
443+
444+
>>> c = Congruence(congruence_kind.twosided, p)
445+
>>> result = to(c, rtype=(Presentation, str))
446+
>>> result == p
447+
True
448+
449+
>>> result_word = to(c, rtype=(Presentation, list[int]))
450+
>>> result_word.alphabet()
451+
[0, 1, 2]
452+
>>> result_word.rules
453+
[[0, 0], [1], [1, 1], [2], [2, 2], [0]]
454+
455+
.. _stephen-to-presentation:
456+
457+
Converting a :any:`Stephen` to a :any:`Presentation`
458+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
459+
460+
To construct a :any:`Presentation` from a :any:`Stephen`, specify the
461+
following values for *args*:
462+
463+
- **s** (:any:`Stephen`) -- the :any:`Stephen` from which to obtain
464+
the presentation.
465+
466+
Additionally, specify one of the following for *Return*:
467+
468+
- ``(Presentation,)`` for constructing a :any:`Presentation` over words of
469+
the same type as that in *s*.
470+
- ``(Presentation, str)`` for constructing a :any:`Presentation` over words
471+
of type ``str``.
472+
- ``(Presentation, list[int])`` for constructing a :any:`Presentation` over
473+
words of type ``list[int]``.
474+
475+
This function constructs and returns a :any:`Presentation` object that is
476+
equivalent to the presentation used to construct the :any:`Stephen` object.
477+
A converted copy is always returned (even when word types match).
478+
479+
No computation is performed by this function; it simply retrieves the
480+
presentation that was used to define the :any:`Stephen` object. Note that
481+
:any:`Stephen` can be constructed from either a :any:`Presentation` or an
482+
:any:`InversePresentation`; in both cases, this function returns a
483+
:any:`Presentation`.
484+
485+
.. seealso::
486+
487+
- :any:`Stephen.presentation`.
488+
489+
.. doctest:: Python
490+
491+
>>> from libsemigroups_pybind11 import (
492+
... Stephen,
493+
... Presentation,
494+
... presentation,
495+
... to,
496+
... )
497+
498+
>>> p = Presentation([5, 6, 7, 8, 9])
499+
>>> presentation.add_rule(p, [5, 6], [7])
500+
>>> presentation.add_rule(p, [6, 7], [8])
501+
>>> presentation.add_rule(p, [7, 8], [9])
502+
>>> presentation.add_rule(p, [8, 9], [5])
503+
>>> presentation.add_rule(p, [9, 5], [6])
504+
505+
>>> s = Stephen(p)
506+
>>> result = to(s, rtype=(Presentation, list[int]))
507+
>>> result == p
508+
True
509+
510+
>>> result_str = to(s, rtype=(Presentation, str))
511+
>>> result_str.alphabet()
512+
'abcde'
513+
>>> result_str.rules
514+
['ab', 'c', 'bc', 'd', 'cd', 'e', 'de', 'a', 'ea', 'b']

0 commit comments

Comments
 (0)