Skip to content

Commit cc5eec5

Browse files
james-d-mitchellJoseph-Edwards
authored andcommitted
knuth-bendix: adjust doc
1 parent 7ee5436 commit cc5eec5

4 files changed

Lines changed: 44 additions & 23 deletions

File tree

docs/source/main-algorithms/knuth-bendix/to-knuth-bendix.rst

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
The full license is in the file LICENSE, distributed with this software.
77

8-
.. TODO update
9-
108
.. currentmodule:: libsemigroups_pybind11
119

1210
Converting to a KnuthBendix
@@ -35,8 +33,8 @@ possible:
3533

3634
.. _todd-coxeter-to-knuth-bendix-default:
3735

38-
Converting a :any:`ToddCoxeter` to a :any:`KnuthBendix` (default rewriter)
39-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
36+
Converting a :any:`ToddCoxeter` to a :any:`KnuthBendix` (default rewriting system and order)
37+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4038

4139
To construct a :any:`KnuthBendix` from a :any:`ToddCoxeter` using the default
4240
rewriter, specify all of the following values for *args*:
@@ -99,12 +97,19 @@ following values for *args*:
9997
- **tc** (:any:`ToddCoxeter`) -- the :any:`ToddCoxeter` object being
10098
converted.
10199

102-
Additionally, specify one of the following for *rtype*:
100+
Additionally, specify *rtype* to be a tuple with first item :any:`KnuthBendix`, second item one of
101+
102+
- ``'Trie'`` for constructing a :any:`KnuthBendix`
103+
with a trie based rewriting system.
104+
- ``'Set'`` for constructing a :any:`KnuthBendix`
105+
with a set based rewriting system.
103106

104-
- ``(KnuthBendix, 'RewriteTrie')`` for constructing a :any:`KnuthBendix`
105-
with the ``RewriteTrie`` rewriter.
106-
- ``(KnuthBendix, 'RewriteFromLeft')`` for constructing a :any:`KnuthBendix`
107-
with the ``RewriteFromLeft`` rewriter.
107+
and the third item one of:
108+
109+
- :any:`Order.shortlex` for constructing a :any:`KnuthBendix`
110+
with short-lex reduction ordering.
111+
- :any:`Order.recursive` for constructing a :any:`KnuthBendix`
112+
with recursive path reduction ordering.
108113

109114
This function converts a :any:`ToddCoxeter` object *tc* to a :any:`KnuthBendix`
110115
object with the rewriter as specified above, using
@@ -119,6 +124,7 @@ the semigroup defined by *tc*.
119124
... congruence_kind,
120125
... to,
121126
... KnuthBendix,
127+
... Order,
122128
... Presentation,
123129
... presentation,
124130
... ToddCoxeter,
@@ -134,7 +140,7 @@ the semigroup defined by *tc*.
134140
>>> kb = to(
135141
... congruence_kind.twosided, # knd
136142
... tc, # tc
137-
... rtype=(KnuthBendix, 'RewriteFromLeft')
143+
... rtype=(KnuthBendix, 'Set', Order.shortlex)
138144
... )
139145
>>> kb.run()
140146

@@ -156,18 +162,30 @@ following values for *args*:
156162

157163
Additionally, specify one of the following for *rtype*:
158164

159-
- ``(KnuthBendix, str, 'RewriteTrie')`` for constructing a
160-
:any:`KnuthBendix` on words with type ``str`` using the ``RewriteTrie``
161-
rewriter.
162-
- ``(KnuthBendix, list[int], 'RewriteTrie')`` for constructing a
165+
- ``(KnuthBendix, str, 'Trie', Order.shortlex)`` for constructing a
166+
:any:`KnuthBendix` on words with type ``str`` using the
167+
trie based rewriting system and short-lex reduction ordering.
168+
- ``(KnuthBendix, list[int], 'Trie', Order.shortlex)`` for constructing a
163169
:any:`KnuthBendix` on words with type ``list[int]`` using the
164-
``RewriteTrie`` rewriter.
165-
- ``(KnuthBendix, str, 'RewriteFromLeft')`` for constructing a
170+
trie based rewriting system and short-lex reduction ordering.
171+
- ``(KnuthBendix, str, 'Set', Order.shortlex)`` for constructing a
172+
:any:`KnuthBendix` on words with type ``str`` using a set based rewriting
173+
system and short-lex reduction ordering.
174+
- ``(KnuthBendix, list[int], 'Set', Order.shortlex)`` for constructing a
175+
:any:`KnuthBendix` on words with type ``list[int]`` using a set based
176+
rewriting system and short-lex reduction ordering.
177+
- ``(KnuthBendix, str, 'Trie', Order.recursive)`` for constructing a
166178
:any:`KnuthBendix` on words with type ``str`` using the
167-
``RewriteFromLeft`` rewriter.
168-
- ``(KnuthBendix, list[int], 'RewriteFromLeft')`` for constructing a
179+
trie based rewriting system and recursive path reduction ordering.
180+
- ``(KnuthBendix, list[int], 'Trie', Order.recursive)`` for constructing a
169181
:any:`KnuthBendix` on words with type ``list[int]`` using the
170-
``RewriteFromLeft`` rewriter.
182+
trie based rewriting system and recursive path reduction ordering.
183+
- ``(KnuthBendix, str, 'Set', Order.recursive)`` for constructing a
184+
:any:`KnuthBendix` on words with type ``str`` using a set based rewriting
185+
system and recursive path reduction ordering.
186+
- ``(KnuthBendix, list[int], 'Set', Order.recursive)`` for constructing a
187+
:any:`KnuthBendix` on words with type ``list[int]`` using a set based
188+
rewriting system and short-lex reduction ordering.
171189

172190
This function converts a :any:`FroidurePin` object *fpb* to a :any:`KnuthBendix`
173191
object with the word type and rewriter as specified above. This is done using
@@ -198,7 +216,7 @@ the semigroup defined by *fpb*.
198216
>>> kb = to(
199217
... congruence_kind.twosided, # knd
200218
... S, # tc
201-
... rtype=(KnuthBendix, list[int], 'RewriteFromLeft')
219+
... rtype=(KnuthBendix, list[int], 'Set', Order.recursive)
202220
... )
203221
>>> kb.run()
204222

src/knuth-bendix.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ nested class :any:`KnuthBendix.options`.
8787
def_construct_default(
8888
thing,
8989
"KnuthBendix",
90-
// TODO update
91-
doc{.extra_kwargs = ", rewriter: str", .extra_kwargs_doc = R"pbdoc(
92-
* **rewriter** (*str*) -- the type of rewriter to use, must be either ``"RewriteTrie"`` or ``"RewriteFromLeft"``.)pbdoc"sv});
90+
doc{.extra_kwargs = ", rewriting_system: str, order: Order",
91+
.extra_kwargs_doc = R"pbdoc(
92+
* **rewriting_system** (*str*) -- the type of rewriting system to use, must be either ``"Trie"`` or ``"Set"``.
93+
* **order** (*Order*) -- the reduction ordering to use, must be either :any:`Order.shortlex` or :any:`Order.recursive`.)pbdoc"sv});
9394

9495
def_init_default(thing, "KnuthBendix");
9596
def_construct_kind_presentation(thing, "KnuthBendix");

src/libsemigroups_pybind11/knuth_bendix.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class KnuthBendix(_CongruenceCommon):
7575
@_copydoc(_KnuthBendixStringLenLexTrie.__init__)
7676
def __init__(self, *args, rewriting_system="Trie", order=_Order.shortlex, **kwargs) -> None:
7777
if "rewriter" in kwargs:
78+
# TODO(v2) remove this entire if-statement
7879
warn(
7980
'The keyword argument "rewriter" is deprecated, please use a combination '
8081
'of "rewriting_system" and "order" instead. If you also specified the '

src/libsemigroups_pybind11/to.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from .todd_coxeter import ToddCoxeter as _ToddCoxeter
4848

4949

50+
# FIXME this function converts list[int] -> list, but shouldn't
5051
def _nice_name(type_list):
5152
"""Convert an iterable of type-like things into a string"""
5253
single_element = False

0 commit comments

Comments
 (0)