Skip to content

knuth-bendix: move functionality from impl #299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 0 additions & 39 deletions src/knuth-bendix-impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -403,28 +403,6 @@ to the re-initialisation of rules where possible.

:return: The total number of rules.
:rtype: int
)pbdoc");

thing.def(
"active_rules",
[](KnuthBendixImpl<Rewriter>& kb) {
auto rules = kb.active_rules();
return py::make_iterator(rx::begin(rules), rx::end(rules));
},
R"pbdoc(
:sig=(self: KnuthBendix) -> Iterator[tuple[str, str]]:

Return a copy of the active rules.

This member function returns an iterator yielding of the pairs of strings
which represent the rewriting rules. The first entry in every such pair is
greater than the second according to the reduction ordering of the
:py:class:`KnuthBendix` instance. The rules are sorted
according to the reduction ordering used by the rewriting system, on the first
entry.

:return: An iterator yielding the currently active rules.
:rtype: Iterator[tuple[str, str]]
)pbdoc");

//////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -484,23 +462,6 @@ The semigroup is finite if the graph is acyclic, and infinite otherwise.
)pbdoc",
py::return_value_policy::reference_internal);

thing.def("gilman_graph_node_labels",
&KnuthBendixImpl<Rewriter>::gilman_graph_node_labels,
R"pbdoc(
:sig=(self: KnuthBendix) -> list[str]:

Return the node labels of the Gilman :py:class:`WordGraph`

Return the node labels of the Gilman :py:class:`WordGraph`, corresponding to the
unique prefixes of the left-hand sides of the rules of the rewriting system.

:return: The node labels of the Gilman :py:class:`WordGraph`
:rtype: list[str]

.. seealso:: :any:`gilman_graph`.
)pbdoc",
py::return_value_policy::reference_internal);

////////////////////////////////////////////////////////////////////////
// Helpers
////////////////////////////////////////////////////////////////////////
Expand Down
39 changes: 39 additions & 0 deletions src/knuth-bendix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,45 @@ the current rules in the :py:class:`KnuthBendix` instance.
def_reduce_no_run(thing, "KnuthBendix", doc{.detail = extra_detail});
def_reduce(thing, "KnuthBendix");

thing.def(
"active_rules",
[](KnuthBendix_& kb) {
auto rules = kb.active_rules();
return py::make_iterator(rx::begin(rules), rx::end(rules));
},
R"pbdoc(
:sig=(self: KnuthBendix) -> Iterator[tuple[str, str]]:

Return a copy of the active rules.

This member function returns an iterator yielding of the pairs of strings
which represent the rewriting rules. The first entry in every such pair is
greater than the second according to the reduction ordering of the
:py:class:`KnuthBendix` instance. The rules are sorted
according to the reduction ordering used by the rewriting system, on the first
entry.

:return: An iterator yielding the currently active rules.
:rtype: Iterator[tuple[str, str]]
)pbdoc");

thing.def("gilman_graph_node_labels",
&KnuthBendix_::gilman_graph_node_labels,
R"pbdoc(
:sig=(self: KnuthBendix) -> list[str]:

Return the node labels of the Gilman :py:class:`WordGraph`

Return the node labels of the Gilman :py:class:`WordGraph`, corresponding to the
unique prefixes of the left-hand sides of the rules of the rewriting system.

:return: The node labels of the Gilman :py:class:`WordGraph`
:rtype: list[str]

.. seealso:: :any:`gilman_graph`.
)pbdoc",
py::return_value_policy::reference_internal);

////////////////////////////////////////////////////////////////////////
// Helpers from cong-common.hpp . . .
////////////////////////////////////////////////////////////////////////
Expand Down
Loading