diff --git a/include/libsemigroups/detail/aho-corasick-impl.hpp b/include/libsemigroups/detail/aho-corasick-impl.hpp index b3c9512f12..88320c8a27 100644 --- a/include/libsemigroups/detail/aho-corasick-impl.hpp +++ b/include/libsemigroups/detail/aho-corasick-impl.hpp @@ -65,6 +65,7 @@ namespace libsemigroups { // Private data //////////////////////////////////////////////////////////////////////// private: + mutable size_t _last_checked; uint32_t _height; index_type _link; index_type _parent; @@ -97,6 +98,10 @@ namespace libsemigroups { // Getters - public //////////////////////////////////////////////////////////////////////// + [[nodiscard]] size_t last_checked() const noexcept { + return _last_checked; + } + [[nodiscard]] size_t height() const noexcept { return _height; } @@ -126,12 +131,22 @@ namespace libsemigroups { return _value; } + //////////////////////////////////////////////////////////////////////// + // Setters - public + //////////////////////////////////////////////////////////////////////// + + Node const& last_checked(size_t val) const noexcept { + _last_checked = val; + return *this; + } + private: //////////////////////////////////////////////////////////////////////// // Setters - private //////////////////////////////////////////////////////////////////////// - // All setters are private to avoid corrupting the objects. + // All setters of non-mutable members are private to avoid corrupting + // the objects. Node const& height(size_t val) noexcept { _height = val; @@ -148,7 +163,6 @@ namespace libsemigroups { _value = value; return *this; } - }; // class Node // TODO(1) if we store pointers here instead of Nodes, then inside the @@ -162,6 +176,7 @@ namespace libsemigroups { std::vector _inactive_nodes_index; std::vector _node_indices_to_update; std::unordered_set _terminal_nodes_index; + mutable size_t _generation; // TODO(1): it seems likely that the positions of the active nodes in // _all_nodes will become scattered and disordered over time, and so it'd @@ -187,6 +202,14 @@ namespace libsemigroups { ~AhoCorasickImpl(); + void increment_generation() const noexcept { + ++_generation; + } + + size_t generation() const noexcept { + return _generation; + } + size_t alphabet_size() const noexcept { return _children.number_of_cols(); } @@ -407,7 +430,7 @@ namespace libsemigroups { Word const& w); } // namespace aho_corasick_impl - } // namespace detail + } // namespace detail } // namespace libsemigroups #include "aho-corasick-impl.tpp" diff --git a/include/libsemigroups/detail/aho-corasick-impl.tpp b/include/libsemigroups/detail/aho-corasick-impl.tpp index 135f7d925b..64a436630e 100644 --- a/include/libsemigroups/detail/aho-corasick-impl.tpp +++ b/include/libsemigroups/detail/aho-corasick-impl.tpp @@ -29,6 +29,7 @@ namespace libsemigroups { LIBSEMIGROUPS_ASSERT(val != nullptr); index_type current = root; for (auto it = first; it != last; ++it) { + _all_nodes[current].last_checked(generation()); index_type next = _children.get(current, *it); if (next == UNDEFINED) { // index of next node added @@ -40,7 +41,7 @@ namespace libsemigroups { if (inserted) { _all_nodes[current].value(val); } - + _all_nodes[current].last_checked(generation()); return {current, inserted}; } @@ -309,5 +310,5 @@ namespace libsemigroups { } } // namespace aho_corasick_impl - } // namespace detail + } // namespace detail } // namespace libsemigroups diff --git a/include/libsemigroups/detail/knuth-bendix-impl.hpp b/include/libsemigroups/detail/knuth-bendix-impl.hpp index 6cc9078982..7a3a4f8499 100644 --- a/include/libsemigroups/detail/knuth-bendix-impl.hpp +++ b/include/libsemigroups/detail/knuth-bendix-impl.hpp @@ -831,7 +831,7 @@ namespace libsemigroups { bool finished_impl() const override; }; // class KnuthBendixImpl - } // namespace detail + } // namespace detail //////////////////////////////////////////////////////////////////////// // global functions - to_human_readable_repr diff --git a/include/libsemigroups/detail/knuth-bendix-impl.tpp b/include/libsemigroups/detail/knuth-bendix-impl.tpp index 394c58c2aa..d4d9c5696b 100644 --- a/include/libsemigroups/detail/knuth-bendix-impl.tpp +++ b/include/libsemigroups/detail/knuth-bendix-impl.tpp @@ -565,6 +565,7 @@ namespace libsemigroups { _rewriter.add_rule(u.begin(), u.end(), v.begin(), v.end()); ++start; } + _rewriter.trie().increment_generation(); } else { // _rewriter.rules() calls process_pending_rules, so can't call it // inside the rule1 loop below. diff --git a/include/libsemigroups/detail/knuth-bendix-nf.hpp b/include/libsemigroups/detail/knuth-bendix-nf.hpp index ef3588c69f..4a2bdc4627 100644 --- a/include/libsemigroups/detail/knuth-bendix-nf.hpp +++ b/include/libsemigroups/detail/knuth-bendix-nf.hpp @@ -39,7 +39,7 @@ namespace libsemigroups { class KnuthBendixNormalFormRange : public Paths { using Paths_ = Paths; - mutable Word _current; + mutable Word _current; KnuthBendix* _kb; public: @@ -113,14 +113,14 @@ namespace libsemigroups { template KnuthBendixNormalFormRange& - KnuthBendixNormalFormRange::operator=( - KnuthBendixNormalFormRange const&) + KnuthBendixNormalFormRange:: + operator=(KnuthBendixNormalFormRange const&) = default; template KnuthBendixNormalFormRange& - KnuthBendixNormalFormRange::operator=( - KnuthBendixNormalFormRange&&) + KnuthBendixNormalFormRange:: + operator=(KnuthBendixNormalFormRange&&) = default; template diff --git a/include/libsemigroups/detail/overlap-iterators.hpp b/include/libsemigroups/detail/overlap-iterators.hpp index 3c57adc22f..ff211ffb0c 100644 --- a/include/libsemigroups/detail/overlap-iterators.hpp +++ b/include/libsemigroups/detail/overlap-iterators.hpp @@ -87,10 +87,10 @@ namespace libsemigroups::detail { _suffix_descendent_index(), _overlap(), _trie(nullptr), - _index_stack() {}; + _index_stack() {} // TODO: Use an init rather than setting default values? - OverlapIteratorTrie(Trie const& trie) + explicit OverlapIteratorTrie(Trie const& trie) : _current_word_iterator(trie.cbegin_terminal_nodes()), _last_word_iterator(trie.cend_terminal_nodes()), _word_index(Trie::root), @@ -177,9 +177,11 @@ namespace libsemigroups::detail { // TODO better name bool traverse_to_root() { while (_suffix_index != Trie::root) { - _index_stack.emplace_back(_suffix_index); - if (find_next_descendent()) { - return true; + if (should_check_descendants(_suffix_index)) { + _index_stack.emplace_back(_suffix_index); + if (find_next_descendent()) { + return true; + } } _suffix_index = _trie->node_no_checks(_suffix_index).suffix_link(); } @@ -204,14 +206,23 @@ namespace libsemigroups::detail { for (letter_type x = 0; x < _trie->alphabet_size(); ++x) { index_type child_index = _trie->child_no_checks(_suffix_descendent_index, x); - if (child_index != UNDEFINED) { + if (child_index != UNDEFINED + && should_check_descendants(child_index)) { _index_stack.emplace_back(child_index); } } } return false; } + + // The of a trie represents which iteration + bool should_check_descendants(size_t index) { + return _trie->node_no_checks(_word_index).last_checked() + == _trie->generation() + || _trie->node_no_checks(index).last_checked() + == _trie->generation(); + } }; // class OverlapIteratorTrie } // namespace libsemigroups::detail -#endif +#endif // LIBSEMIGROUPS_DETAIL_OVERLAP_ITERATORS_HPP_ diff --git a/include/libsemigroups/detail/rewriters.hpp b/include/libsemigroups/detail/rewriters.hpp index 6eed351d82..1f2d9376e9 100644 --- a/include/libsemigroups/detail/rewriters.hpp +++ b/include/libsemigroups/detail/rewriters.hpp @@ -172,7 +172,6 @@ namespace libsemigroups { virtual void report_reducing_rules( std::atomic_uint64_t const&, std::chrono::high_resolution_clock::time_point const&) const {} - }; // class RewritingSystemBase //////////////////////////////////////////////////////////////////////// @@ -386,6 +385,10 @@ namespace libsemigroups { return _rule_trie; } + [[nodiscard]] Trie& trie() noexcept { + return _rule_trie; + } + private: //////////////////////////////////////////////////////////////////////// // Private member functions diff --git a/include/libsemigroups/detail/rules.hpp b/include/libsemigroups/detail/rules.hpp index 6708dc3075..38e698c8fd 100644 --- a/include/libsemigroups/detail/rules.hpp +++ b/include/libsemigroups/detail/rules.hpp @@ -26,6 +26,7 @@ #include // for size_t #include // for uint64_t #include // for list +#include // for std::string #include // for move #include // for vector @@ -273,4 +274,4 @@ namespace libsemigroups { } // namespace detail } // namespace libsemigroups -#endif +#endif // LIBSEMIGROUPS_DETAIL_RULES_HPP_ diff --git a/include/libsemigroups/knuth-bendix-helpers.hpp b/include/libsemigroups/knuth-bendix-helpers.hpp index e3b7931502..11357128e5 100644 --- a/include/libsemigroups/knuth-bendix-helpers.hpp +++ b/include/libsemigroups/knuth-bendix-helpers.hpp @@ -64,9 +64,9 @@ namespace libsemigroups { //! This function triggers a full enumeration of \p kb. //! //! \tparam Word the type of the words contained in the output range. - //! \tparam RewritingSystem the first template parameter for \ref_knuth_bendix. - //! \tparam ReductionOrder the second template parameter for - //! \ref_knuth_bendix. + //! \tparam RewritingSystem the first template parameter for + //! \ref_knuth_bendix. \tparam ReductionOrder the second template parameter + //! for \ref_knuth_bendix. //! //! \param kb the \ref_knuth_bendix instance. //! @@ -79,8 +79,8 @@ namespace libsemigroups { template [[nodiscard]] auto normal_forms(KnuthBendix& kb) { - return detail::KnuthBendixNormalFormRange( - kb); + return detail:: + KnuthBendixNormalFormRange(kb); } //////////////////////////////////////////////////////////////////////// @@ -106,9 +106,9 @@ namespace libsemigroups { //! //! \tparam Word the type of the words contained in the output range //! (default: std::string). - //! \tparam RewritingSystem the first template parameter for \ref_knuth_bendix. - //! \tparam ReductionOrder the second template parameter for - //! \ref_knuth_bendix. + //! \tparam RewritingSystem the first template parameter for + //! \ref_knuth_bendix. \tparam ReductionOrder the second template parameter + //! for \ref_knuth_bendix. //! //! \param kb1 the first \ref_knuth_bendix instance. //! \param kb2 the second \ref_knuth_bendix instance. @@ -128,9 +128,9 @@ namespace libsemigroups { //! //! \cong_common_warn_undecidable{Knuth-Bendix}. template - [[nodiscard]] std::vector> - non_trivial_classes(KnuthBendix& kb1, - KnuthBendix& kb2); + [[nodiscard]] std::vector> non_trivial_classes( + KnuthBendix& kb1, + KnuthBendix& kb2); } // namespace congruence_common @@ -174,9 +174,9 @@ namespace libsemigroups { //! //! \tparam Word the type of the words in the //! \ref KnuthBendix::presentation. - //! \tparam RewritingSystem the first template parameter for \ref_knuth_bendix. - //! \tparam ReductionOrder the second template parameter for - //! \ref_knuth_bendix. + //! \tparam RewritingSystem the first template parameter for + //! \ref_knuth_bendix. \tparam ReductionOrder the second template parameter + //! for \ref_knuth_bendix. //! //! \param kb the \ref_knuth_bendix instance. //! @@ -188,7 +188,8 @@ namespace libsemigroups { //! //! \sa KnuthBendix::run. template - void by_overlap_length(KnuthBendix& kb); + void + by_overlap_length(KnuthBendix& kb); //! \ingroup knuth_bendix_helpers_group //! @@ -198,9 +199,9 @@ namespace libsemigroups { //! //! \tparam Word the type of the words in the //! \ref KnuthBendix::presentation. - //! \tparam RewritingSystem the first template parameter for \ref_knuth_bendix. - //! \tparam ReductionOrder the second template parameter for - //! \ref_knuth_bendix. + //! \tparam RewritingSystem the first template parameter for + //! \ref_knuth_bendix. \tparam ReductionOrder the second template parameter + //! for \ref_knuth_bendix. //! //! \param kb the \ref_knuth_bendix instance defining the rules that are to //! be checked for being reduced. diff --git a/include/libsemigroups/obvinf.hpp b/include/libsemigroups/obvinf.hpp index f5434e1eb6..29b63a2a66 100644 --- a/include/libsemigroups/obvinf.hpp +++ b/include/libsemigroups/obvinf.hpp @@ -649,8 +649,8 @@ namespace libsemigroups { //! \note If this function returns \c false, it is still possible that the //! quotient defined by the \ref_knuth_bendix object \p kb is infinite. template - bool - is_obviously_infinite(detail::KnuthBendixImpl& kb) { + bool is_obviously_infinite( + detail::KnuthBendixImpl& kb) { if (kb.finished()) { return !v4::word_graph::is_acyclic(kb.gilman_graph()); } diff --git a/include/libsemigroups/to-froidure-pin.hpp b/include/libsemigroups/to-froidure-pin.hpp index b208faacfe..af7ddd7f81 100644 --- a/include/libsemigroups/to-froidure-pin.hpp +++ b/include/libsemigroups/to-froidure-pin.hpp @@ -167,8 +167,9 @@ namespace libsemigroups { //! \p kb. //! //! \tparam Thing used for SFINAE should be FroidurePin. - //! \tparam RewritingSystem the second template parameter for \ref_knuth_bendix. - //! \tparam ReductionOrder the third template parameter for \ref_knuth_bendix. + //! \tparam RewritingSystem the second template parameter for + //! \ref_knuth_bendix. \tparam ReductionOrder the third template parameter for + //! \ref_knuth_bendix. //! //! \param kb the \ref_knuth_bendix instance to convert. //! @@ -180,9 +181,11 @@ namespace libsemigroups { typename Word, typename RewritingSystem, typename ReductionOrder> - auto to(KnuthBendix& kb) -> std::enable_if_t< - std::is_same_v, FroidurePin>, - FroidurePin>>>; + auto to(KnuthBendix& kb) + -> std::enable_if_t< + std::is_same_v, FroidurePin>, + FroidurePin< + detail::KBE>>>; //! \ingroup to_froidure_pin_group //! diff --git a/include/libsemigroups/to-froidure-pin.tpp b/include/libsemigroups/to-froidure-pin.tpp index 12d489d015..a1e6ed7472 100644 --- a/include/libsemigroups/to-froidure-pin.tpp +++ b/include/libsemigroups/to-froidure-pin.tpp @@ -27,7 +27,8 @@ namespace libsemigroups { template FroidurePin(KnuthBendix const&) - -> FroidurePin>>; + -> FroidurePin< + detail::KBE>>; FroidurePin(detail::ToddCoxeterImpl const&)->FroidurePin; @@ -89,9 +90,11 @@ namespace libsemigroups { typename Word, typename RewritingSystem, typename ReductionOrder> - auto to(KnuthBendix& kb) -> std::enable_if_t< - std::is_same_v, FroidurePin>, - FroidurePin>>> { + auto to(KnuthBendix& kb) + -> std::enable_if_t< + std::is_same_v, FroidurePin>, + FroidurePin>>> { size_t const n = kb.presentation().alphabet().size(); if (n == 0) { diff --git a/include/libsemigroups/to-presentation.hpp b/include/libsemigroups/to-presentation.hpp index ec2f636996..b94d2eddce 100644 --- a/include/libsemigroups/to-presentation.hpp +++ b/include/libsemigroups/to-presentation.hpp @@ -130,8 +130,9 @@ namespace libsemigroups { //! `Presentation` for some type `WordOut`. //! \tparam WordIn the type of the rules in the presentation of the //! \ref_knuth_bendix object \p kb. - //! \tparam RewritingSystem the second template parameter for \ref_knuth_bendix. - //! \tparam ReductionOrder the third template parameter for \ref_knuth_bendix. + //! \tparam RewritingSystem the second template parameter for + //! \ref_knuth_bendix. \tparam ReductionOrder the third template parameter for + //! \ref_knuth_bendix. //! //! \param kb the \ref_knuth_bendix object from which to obtain the rules. //! diff --git a/include/libsemigroups/to-todd-coxeter.hpp b/include/libsemigroups/to-todd-coxeter.hpp index 48a3c8e4fe..eb761b2e7a 100644 --- a/include/libsemigroups/to-todd-coxeter.hpp +++ b/include/libsemigroups/to-todd-coxeter.hpp @@ -136,7 +136,8 @@ namespace libsemigroups { typename Word, typename RewritingSystem, typename ReductionOrder> - auto to(congruence_kind knd, KnuthBendix& kb) + auto to(congruence_kind knd, + KnuthBendix& kb) -> std::enable_if_t, Thing>, ToddCoxeter>; diff --git a/include/libsemigroups/to-todd-coxeter.tpp b/include/libsemigroups/to-todd-coxeter.tpp index 9e42c5d4bc..ea360fb792 100644 --- a/include/libsemigroups/to-todd-coxeter.tpp +++ b/include/libsemigroups/to-todd-coxeter.tpp @@ -54,7 +54,8 @@ namespace libsemigroups { typename Word, typename RewritingSystem, typename ReductionOrder> - auto to(congruence_kind knd, KnuthBendix& kb) + auto to(congruence_kind knd, + KnuthBendix& kb) -> std::enable_if_t, Thing>, ToddCoxeter> { if (kb.number_of_classes() == POSITIVE_INFINITY) { diff --git a/src/detail/aho-corasick-impl.cpp b/src/detail/aho-corasick-impl.cpp index 37712da5c3..b1d8aa45cb 100644 --- a/src/detail/aho-corasick-impl.cpp +++ b/src/detail/aho-corasick-impl.cpp @@ -39,7 +39,8 @@ namespace libsemigroups { //////////////////////////////////////////////////////////////////////// AhoCorasickImpl::Node::Node(index_type parent, letter_type a) - : _height(), + : _last_checked(0), + _height(), _link(), _parent(), _parent_letter(), @@ -50,7 +51,8 @@ namespace libsemigroups { typename AhoCorasickImpl::Node& AhoCorasickImpl::Node::init(index_type parent, letter_type a) noexcept { - _height = parent == UNDEFINED ? 0 : UNDEFINED; + _height = parent == UNDEFINED ? 0 : UNDEFINED; + _last_checked = 0; if (_parent == root || _parent == UNDEFINED) { _link = root; } else { @@ -77,7 +79,8 @@ namespace libsemigroups { _active_nodes_index({root}), _inactive_nodes_index(), _node_indices_to_update(), - _terminal_nodes_index() {} + _terminal_nodes_index(), + _generation(0) {} AhoCorasickImpl& AhoCorasickImpl::init() { init(0); @@ -99,7 +102,8 @@ namespace libsemigroups { _active_nodes_index({root}), _inactive_nodes_index(), _node_indices_to_update(), - _terminal_nodes_index() {} + _terminal_nodes_index(), + _generation(0) {} AhoCorasickImpl& AhoCorasickImpl::init(size_t num_letters) { LIBSEMIGROUPS_ASSERT(!_all_nodes.empty()); @@ -124,6 +128,7 @@ namespace libsemigroups { + _inactive_nodes_index.size() == _all_nodes.size()); LIBSEMIGROUPS_ASSERT(_children.number_of_rows() == _all_nodes.size()); + _generation = 0; return *this; } diff --git a/tests/test-aho-corasick.cpp b/tests/test-aho-corasick.cpp index 0f19e84938..d16788bff0 100644 --- a/tests/test-aho-corasick.cpp +++ b/tests/test-aho-corasick.cpp @@ -506,7 +506,7 @@ namespace libsemigroups { "017", "terminal_nodes", "[quick]") { - using rx::operator|; + using rx:: operator|; AhoCorasickImpl ac(2); REQUIRE((ac.terminal_nodes() | rx::count()) == 0); diff --git a/tests/test-knuth-bendix-2.cpp b/tests/test-knuth-bendix-2.cpp index 5a67bce39a..41e36169ee 100644 --- a/tests/test-knuth-bendix-2.cpp +++ b/tests/test-knuth-bendix-2.cpp @@ -1808,7 +1808,7 @@ namespace libsemigroups { p.alphabet(2); presentation::add_idempotent_rules_no_checks(p, 01_w); using words::operator+; - WordRange words; + WordRange words; words.alphabet_size(2).min(0).max(6); size_t n = 2; for (size_t a = 0; a < n - 1; ++a) { diff --git a/tests/test-knuth-bendix-5.cpp b/tests/test-knuth-bendix-5.cpp index 9d0c94dfe3..31af2290ba 100644 --- a/tests/test-knuth-bendix-5.cpp +++ b/tests/test-knuth-bendix-5.cpp @@ -272,10 +272,11 @@ namespace libsemigroups { auto ntc = (iterator_range(pp.begin(), pp.end()) | filter([](auto const& val) { return val.size() > 1; }) | transform([](auto& val) { - std::for_each(val.begin(), val.end(), [](auto& w) -> auto& { - w.erase(w.begin()); - return w; - }); + std::for_each( + val.begin(), val.end(), [](auto& w) -> auto& { + w.erase(w.begin()); + return w; + }); return val; })); diff --git a/tests/test-knuth-bendix-6.cpp b/tests/test-knuth-bendix-6.cpp index 2e7cde5cea..0bedc04323 100644 --- a/tests/test-knuth-bendix-6.cpp +++ b/tests/test-knuth-bendix-6.cpp @@ -359,7 +359,7 @@ namespace libsemigroups { "[quick][knuth-bendix]", REWRITING_SYSTEM_TYPES) { using literals::operator""_w; - auto rg = ReportGuard(false); + auto rg = ReportGuard(false); Presentation p1; p1.contains_empty_word(true); diff --git a/tests/test-rewriters.cpp b/tests/test-rewriters.cpp index 1311ef0e2f..b040f19494 100644 --- a/tests/test-rewriters.cpp +++ b/tests/test-rewriters.cpp @@ -504,5 +504,74 @@ namespace libsemigroups { ++start; REQUIRE(start == end); } + + LIBSEMIGROUPS_TEST_CASE("OverlapIteratorTrie", + "017", + "different generations", + "[quick]") { + auto rg = ReportGuard(false); + RewritingSystemTrie rt; + rt.increase_alphabet_size_by(2); + + // Words added in generation 0 + rewriting_system::add_rule(rt, "abba"_w, "aaa"_w); + rewriting_system::add_rule(rt, "abab"_w, "bbb"_w); + rt.reduce(); + + // Word added in generation 1 + rt.trie().increment_generation(); + rewriting_system::add_rule(rt, "baa"_w, "a"_w); + rt.reduce(); + + { + auto const& trie = rt.trie(); + + // Should only find the overlaps between + auto start = OverlapIteratorTrie(trie); + auto end = OverlapIteratorTrie(); + + v4::ToWord toword(std::string({0, 1})); + + REQUIRE(toword(start->lhs->lhs()) == "baa"_w); + REQUIRE(toword(start->lhs->rhs()) == "a"_w); + REQUIRE(toword(start->rhs->lhs()) == "abba"_w); + REQUIRE(toword(start->rhs->rhs()) == "aaa"_w); + REQUIRE(start->length == 1); + + ++start; + REQUIRE(toword(start->lhs->lhs()) == "baa"_w); + REQUIRE(toword(start->lhs->rhs()) == "a"_w); + REQUIRE(toword(start->rhs->lhs()) == "abab"_w); + REQUIRE(toword(start->rhs->rhs()) == "bbb"_w); + REQUIRE(start->length == 1); + + ++start; + REQUIRE(toword(start->lhs->lhs()) == "abba"_w); + REQUIRE(toword(start->lhs->rhs()) == "aaa"_w); + REQUIRE(toword(start->rhs->lhs()) == "baa"_w); + REQUIRE(toword(start->rhs->rhs()) == "a"_w); + REQUIRE(start->length == 2); + + ++start; + REQUIRE(toword(start->lhs->lhs()) == "abab"_w); + REQUIRE(toword(start->lhs->rhs()) == "bbb"_w); + REQUIRE(toword(start->rhs->lhs()) == "baa"_w); + REQUIRE(toword(start->rhs->rhs()) == "a"_w); + REQUIRE(start->length == 1); + + ++start; + REQUIRE(start == end); + } + + rt.increase_alphabet_size_by(1); + + // Word added in generation 2 + rt.trie().increment_generation(); + rewriting_system::add_rule(rt, "c"_w, "b"_w); + rt.reduce(); + + // No overlaps where at least one word is in generation 2 + REQUIRE(OverlapIteratorTrie(rt.trie()) == OverlapIteratorTrie()); + } } // namespace detail } // namespace libsemigroups diff --git a/tests/test-to-froidure-pin.cpp b/tests/test-to-froidure-pin.cpp index 3be8280b0f..30ce2d1e46 100644 --- a/tests/test-to-froidure-pin.cpp +++ b/tests/test-to-froidure-pin.cpp @@ -84,7 +84,7 @@ namespace libsemigroups { namespace { template void check_from_ke(Presentation const& p) { - using literals::operator""_w; + using literals:: operator""_w; Kambites k(twosided, p); auto s = to(k); REQUIRE(s.is_finite() == tril::FALSE); @@ -193,7 +193,7 @@ namespace libsemigroups { "from Todd-Coxeter", "[quick][no-valgrind]") { using literals::operator""_w; - auto rg = ReportGuard(false); + auto rg = ReportGuard(false); Presentation p; p.alphabet(4); @@ -253,7 +253,7 @@ namespace libsemigroups { "from KnuthBendix", "[quick]", REWRITER_TYPES) { - using literals::operator""_w; + using literals:: operator""_w; auto rg = ReportGuard(false); Presentation p; p.alphabet(2); @@ -277,8 +277,8 @@ namespace libsemigroups { "008", "from ToddCoxeter", "[quick][no-valgrind]") { - auto rg = ReportGuard(false); - using literals::operator""_w; + auto rg = ReportGuard(false); + using literals:: operator""_w; Presentation p; p.alphabet(4); presentation::add_rule(p, 00_w, 0_w);