Skip to content
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
41 changes: 24 additions & 17 deletions src/cong-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ namespace libsemigroups {

using RewriteTrie = detail::RewriteTrie;
using RewriteFromLeft = detail::RewriteFromLeft;
using MultiStringView = detail::MultiStringView;

template <typename Thing>
using MultiView = detail::MultiView<Thing>;

// Alias required because macros don't play well with commas.
using KnuthBendixStringRewriteTrie = KnuthBendix<std::string, RewriteTrie>;
Expand Down Expand Up @@ -122,7 +124,8 @@ This function default constructs an uninitialised :any:`{name}` instance.
DEF_CONSTRUCT_DEFAULT(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_CONSTRUCT_DEFAULT(Kambites<word_type>, detail::CongruenceCommon);
DEF_CONSTRUCT_DEFAULT(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_CONSTRUCT_DEFAULT(Kambites<MultiView<std::string>>,
detail::CongruenceCommon);
DEF_CONSTRUCT_DEFAULT(Kambites<std::string>, detail::CongruenceCommon);

DEF_CONSTRUCT_DEFAULT(detail::KnuthBendixImpl<RewriteTrie>,
Expand Down Expand Up @@ -182,7 +185,7 @@ have been in if it had just been newly default constructed.
DEF_INIT_DEFAULT(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_INIT_DEFAULT(Kambites<word_type>, detail::CongruenceCommon);
DEF_INIT_DEFAULT(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_INIT_DEFAULT(Kambites<MultiView<std::string>>, detail::CongruenceCommon);
DEF_INIT_DEFAULT(Kambites<std::string>, detail::CongruenceCommon);

DEF_INIT_DEFAULT(detail::KnuthBendixImpl<RewriteTrie>,
Expand Down Expand Up @@ -254,7 +257,7 @@ of kind *knd* over the semigroup or monoid defined by the presentation *p*.

DEF_CONSTRUCT_KIND_PRESENTATION(Kambites<word_type>,
detail::CongruenceCommon);
DEF_CONSTRUCT_KIND_PRESENTATION(Kambites<MultiStringView>,
DEF_CONSTRUCT_KIND_PRESENTATION(Kambites<MultiView<std::string>>,
detail::CongruenceCommon);
DEF_CONSTRUCT_KIND_PRESENTATION(Kambites<std::string>,
detail::CongruenceCommon);
Expand Down Expand Up @@ -332,7 +335,7 @@ had been newly constructed from *knd* and *p*.
DEF_INIT_KIND_PRESENTATION(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_INIT_KIND_PRESENTATION(Kambites<word_type>, detail::CongruenceCommon);
DEF_INIT_KIND_PRESENTATION(Kambites<MultiStringView>,
DEF_INIT_KIND_PRESENTATION(Kambites<MultiView<std::string>>,
detail::CongruenceCommon);
DEF_INIT_KIND_PRESENTATION(Kambites<std::string>, detail::CongruenceCommon);

Expand Down Expand Up @@ -390,7 +393,7 @@ Copy a :any:`{name}` object.
DEF_COPY(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_COPY(Kambites<word_type>, detail::CongruenceCommon);
DEF_COPY(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_COPY(Kambites<MultiView<std::string>>, detail::CongruenceCommon);
DEF_COPY(Kambites<std::string>, detail::CongruenceCommon);

DEF_COPY(detail::KnuthBendixImpl<RewriteTrie>, detail::CongruenceCommon);
Expand Down Expand Up @@ -450,7 +453,8 @@ number of classes in the congruence represented by a :any:`{name}` instance.
DEF_NUMBER_OF_CLASSES(detail::ToddCoxeterImpl, detail::CongruenceCommon);

DEF_NUMBER_OF_CLASSES(Kambites<word_type>, detail::CongruenceCommon);
DEF_NUMBER_OF_CLASSES(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_NUMBER_OF_CLASSES(Kambites<MultiView<std::string>>,
detail::CongruenceCommon);
DEF_NUMBER_OF_CLASSES(Kambites<std::string>, detail::CongruenceCommon);

DEF_NUMBER_OF_CLASSES(detail::KnuthBendixImpl<RewriteTrie>,
Expand Down Expand Up @@ -523,7 +527,8 @@ This function adds a generating pair to the congruence represented by a
DEF_ADD_GENERATING_PAIR(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_ADD_GENERATING_PAIR(Kambites<word_type>, detail::CongruenceCommon);
DEF_ADD_GENERATING_PAIR(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_ADD_GENERATING_PAIR(Kambites<MultiView<std::string>>,
detail::CongruenceCommon);
DEF_ADD_GENERATING_PAIR(Kambites<std::string>, detail::CongruenceCommon);

DEF_ADD_GENERATING_PAIR(detail::KnuthBendixImpl<RewriteTrie>,
Expand Down Expand Up @@ -605,7 +610,8 @@ contained in the congruence, but that this is not currently known.
DEF_CURRENTLY_CONTAINS(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_CURRENTLY_CONTAINS(Kambites<word_type>, detail::CongruenceCommon);
DEF_CURRENTLY_CONTAINS(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_CURRENTLY_CONTAINS(Kambites<MultiView<std::string>>,
detail::CongruenceCommon);
DEF_CURRENTLY_CONTAINS(Kambites<std::string>, detail::CongruenceCommon);

DEF_CURRENTLY_CONTAINS(detail::KnuthBendixImpl<RewriteTrie>,
Expand Down Expand Up @@ -681,7 +687,7 @@ congruence represented by a :py:class:`{name}` instance.
DEF_CONTAINS(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_CONTAINS(Kambites<word_type>, detail::CongruenceCommon);
DEF_CONTAINS(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_CONTAINS(Kambites<MultiView<std::string>>, detail::CongruenceCommon);
DEF_CONTAINS(Kambites<std::string>, detail::CongruenceCommon);

DEF_CONTAINS(detail::KnuthBendixImpl<RewriteTrie>, detail::CongruenceCommon);
Expand Down Expand Up @@ -753,7 +759,7 @@ normal form for the input word *w*.
DEF_REDUCE_NO_RUN(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_REDUCE_NO_RUN(Kambites<word_type>, detail::CongruenceCommon);
DEF_REDUCE_NO_RUN(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_REDUCE_NO_RUN(Kambites<MultiView<std::string>>, detail::CongruenceCommon);
DEF_REDUCE_NO_RUN(Kambites<std::string>, detail::CongruenceCommon);

DEF_REDUCE_NO_RUN(detail::KnuthBendixImpl<RewriteTrie>,
Expand Down Expand Up @@ -827,7 +833,7 @@ input word.
DEF_REDUCE(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_REDUCE(Kambites<word_type>, detail::CongruenceCommon);
DEF_REDUCE(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_REDUCE(Kambites<MultiView<std::string>>, detail::CongruenceCommon);
DEF_REDUCE(Kambites<std::string>, detail::CongruenceCommon);

DEF_REDUCE(detail::KnuthBendixImpl<RewriteTrie>, detail::CongruenceCommon);
Expand Down Expand Up @@ -886,7 +892,8 @@ This function returns the generating pairs of the congruence as added via
DEF_GENERATING_PAIRS(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_GENERATING_PAIRS(Kambites<word_type>, detail::CongruenceCommon);
DEF_GENERATING_PAIRS(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_GENERATING_PAIRS(Kambites<MultiView<std::string>>,
detail::CongruenceCommon);
DEF_GENERATING_PAIRS(Kambites<std::string>, detail::CongruenceCommon);

DEF_GENERATING_PAIRS(KnuthBendixStringRewriteTrie,
Expand Down Expand Up @@ -945,7 +952,7 @@ presentation, then this presentation is returned by this function.
DEF_PRESENTATION(ToddCoxeter<std::string>, detail::ToddCoxeterImpl);

DEF_PRESENTATION(Kambites<word_type>, detail::CongruenceCommon);
DEF_PRESENTATION(Kambites<MultiStringView>, detail::CongruenceCommon);
DEF_PRESENTATION(Kambites<MultiView<std::string>>, detail::CongruenceCommon);
DEF_PRESENTATION(Kambites<std::string>, detail::CongruenceCommon);

DEF_PRESENTATION(KnuthBendixStringRewriteTrie,
Expand Down Expand Up @@ -1017,7 +1024,7 @@ triggers a full enumeration of *{var}*.
DEF_PARTITION(ToddCoxeter<std::string>);

DEF_PARTITION(Kambites<word_type>);
DEF_PARTITION(Kambites<MultiStringView>);
DEF_PARTITION(Kambites<MultiView<std::string>>);
DEF_PARTITION(Kambites<std::string>);

DEF_PARTITION(KnuthBendixStringRewriteTrie);
Expand Down Expand Up @@ -1084,7 +1091,7 @@ instance *{var}*.
DEF_NON_TRIVIAL_CLASSES(ToddCoxeter<std::string>);

DEF_NON_TRIVIAL_CLASSES(Kambites<word_type>);
DEF_NON_TRIVIAL_CLASSES(Kambites<MultiStringView>);
DEF_NON_TRIVIAL_CLASSES(Kambites<MultiView<std::string>>);
DEF_NON_TRIVIAL_CLASSES(Kambites<std::string>);

DEF_NON_TRIVIAL_CLASSES(KnuthBendixStringRewriteTrie);
Expand Down Expand Up @@ -1147,7 +1154,7 @@ the congruence represented by an instance of :any:`{name}`.
DEF_NORMAL_FORMS(ToddCoxeter<std::string>);

DEF_NORMAL_FORMS(Kambites<word_type>);
DEF_NORMAL_FORMS(Kambites<MultiStringView>);
DEF_NORMAL_FORMS(Kambites<MultiView<std::string>>);
DEF_NORMAL_FORMS(Kambites<std::string>);

DEF_NORMAL_FORMS(KnuthBendixStringRewriteTrie);
Expand Down
6 changes: 3 additions & 3 deletions src/froidure-pin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,7 +1267,7 @@ This function returns the element of *fp* obtained by evaluating *w*.
});
}
} // bind_froidure_pin_stateful
} // namespace
} // namespace

void init_froidure_pin(py::module& m) {
// TODO(0) uncomment bind_froidure_pin<HPCombiTransf<16>>(m, "Transf16");
Expand Down Expand Up @@ -1315,8 +1315,8 @@ This function returns the element of *fp* obtained by evaluating *w*.
m, "KBEWordRewriteTrie");

bind_froidure_pin_stateful<detail::KE<std::string>>(m, "KEString");
bind_froidure_pin_stateful<detail::KE<detail::MultiStringView>>(
m, "KEMultiStringView");
bind_froidure_pin_stateful<detail::KE<detail::MultiView<std::string>>>(
m, "KEMultiViewString");
bind_froidure_pin_stateful<detail::KE<word_type>>(
m, "KEWord"); // codespell:ignore keword

Expand Down
2 changes: 1 addition & 1 deletion src/kambites.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ defined by a :any:`Kambites` object is obviously infinite;

void init_kambites(py::module& m) {
// One call to bind is required per list of types
bind_kambites<detail::MultiStringView>(m, "KambitesMultiStringView");
bind_kambites<detail::MultiView<std::string>>(m, "KambitesMultiViewString");
bind_kambites<std::string>(m, "KambitesString"); // returned by Congruence
bind_kambites<word_type>(m, "KambitesWord");
}
Expand Down
6 changes: 3 additions & 3 deletions src/libsemigroups_pybind11/froidure_pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
FroidurePinKBEStringRewriteTrie as _FroidurePinKBEStringRewriteTrie,
FroidurePinKBEWordRewriteFromLeft as _FroidurePinKBEWordRewriteFromLeft,
FroidurePinKBEWordRewriteTrie as _FroidurePinKBEWordRewriteTrie,
FroidurePinKEMultiStringView as _FroidurePinKEMultiStringView,
FroidurePinKEMultiViewString as _FroidurePinKEMultiViewString,
FroidurePinKEString as _FroidurePinKEString,
FroidurePinKEWord as _FroidurePinKEWord,
FroidurePinTCE as _FroidurePinTCE,
Expand Down Expand Up @@ -142,7 +142,7 @@ class FroidurePin(_CxxWrapper): # pylint: disable=missing-class-docstring
)

_all_wrapped_cxx_types = {*_py_template_params_to_cxx_type.values()} | {
_FroidurePinKEMultiStringView,
_FroidurePinKEMultiViewString,
_FroidurePinKEString,
_FroidurePinKEWord,
_FroidurePinTCE,
Expand Down Expand Up @@ -237,7 +237,7 @@ def sorted_elements( # pylint: disable=missing-function-docstring
_register_cxx_wrapped_type(_fp_type, FroidurePin)


_register_cxx_wrapped_type(_FroidurePinKEMultiStringView, FroidurePin)
_register_cxx_wrapped_type(_FroidurePinKEMultiViewString, FroidurePin)
_register_cxx_wrapped_type(_FroidurePinKEString, FroidurePin)
_register_cxx_wrapped_type(_FroidurePinKEWord, FroidurePin)
_register_cxx_wrapped_type(_FroidurePinTCE, FroidurePin)
Expand Down
6 changes: 3 additions & 3 deletions src/libsemigroups_pybind11/kambites.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from typing_extensions import Self as _Self

from _libsemigroups_pybind11 import ( # pylint: disable=no-name-in-module
KambitesMultiStringView as _KambitesMultiStringView,
KambitesMultiViewString as _KambitesMultiViewString,
KambitesWord as _KambitesWord,
KambitesString as _KambitesString,
congruence_kind as _congruence_kind,
Expand Down Expand Up @@ -45,7 +45,7 @@ class Kambites(_CongruenceCommon): # pylint: disable=missing-class-docstring

_py_template_params_to_cxx_type = {
(list[int],): _KambitesWord,
(str,): _KambitesMultiStringView,
(str,): _KambitesMultiViewString,
}

_cxx_type_to_py_template_params = dict(
Expand Down Expand Up @@ -75,7 +75,7 @@ def __init__(self: _Self, *args, **kwargs) -> None:
_copy_cxx_mem_fns(_KambitesWord, Kambites)

_register_cxx_wrapped_type(_KambitesWord, Kambites)
_register_cxx_wrapped_type(_KambitesMultiStringView, Kambites)
_register_cxx_wrapped_type(_KambitesMultiViewString, Kambites)
_register_cxx_wrapped_type(_KambitesString, Kambites)

partition = _wrap_cxx_free_fn(_kambites_partition)
Expand Down
1 change: 1 addition & 0 deletions src/main.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ namespace libsemigroups {
return static_cast<Int>(std::get<4>(val));
}
}
return 0; // To keep the compiler happy
}

template <typename Int>
Expand Down
2 changes: 1 addition & 1 deletion src/to-froidure-pin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ namespace libsemigroups {

// Kambites
bind_to_froidure_pin<Kambites<std::string>>(m);
bind_to_froidure_pin<Kambites<detail::MultiStringView>>(m);
bind_to_froidure_pin<Kambites<detail::MultiView<std::string>>>(m);
bind_to_froidure_pin<Kambites<word_type>>(m);

// KnuthBendix
Expand Down
4 changes: 2 additions & 2 deletions tests/test_to.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
FroidurePinKBEStringRewriteTrie,
FroidurePinKBEWordRewriteFromLeft,
FroidurePinKBEWordRewriteTrie,
FroidurePinKEMultiStringView,
FroidurePinKEMultiViewString,
FroidurePinKEString,
FroidurePinKEWord,
FroidurePinTCE,
Expand Down Expand Up @@ -253,7 +253,7 @@ def test_to_FroidurePin_009():
fp = to(k, rtype=(FroidurePin,))
fp.enumerate(100)
assert fp.current_size() == 8205
assert isinstance(to_cxx(fp), FroidurePinKEMultiStringView)
assert isinstance(to_cxx(fp), FroidurePinKEMultiViewString)
assert isinstance(fp, FroidurePin)


Expand Down