From 53bcc24bf4c91c477e67e08cb898ac21b094c728 Mon Sep 17 00:00:00 2001 From: reiniscirpons Date: Wed, 4 Dec 2024 09:23:31 +0000 Subject: [PATCH] Fix some issues from rebase --- include/libsemigroups/sims.hpp | 30 +++++++++++++++++++++--------- include/libsemigroups/sims.tpp | 13 ++++++------- src/sims.cpp | 2 +- tests/test-sims.cpp | 4 ++-- 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/include/libsemigroups/sims.hpp b/include/libsemigroups/sims.hpp index 53874c634..291a690d6 100644 --- a/include/libsemigroups/sims.hpp +++ b/include/libsemigroups/sims.hpp @@ -2946,12 +2946,14 @@ namespace libsemigroups { using node_type = uint32_t; using KnuthBendix_ = KnuthBendix<>; std::vector _knuth_bendices; + Presentation _presentation; public: //! Default constructor. explicit SimsRefinerIdeals() : _knuth_bendices(std::thread::hardware_concurrency() + 1, - KnuthBendix_()) { + KnuthBendix_()), + _presentation() { init(); } @@ -2962,6 +2964,7 @@ namespace libsemigroups { //! //! \returns A reference to \c *this. SimsRefinerIdeals& init() { + _presentation.init(); _knuth_bendices[0].init(); std::fill(_knuth_bendices.begin() + 1, _knuth_bendices.end(), @@ -2981,7 +2984,8 @@ namespace libsemigroups { template explicit SimsRefinerIdeals(Presentation const& p) : _knuth_bendices(std::thread::hardware_concurrency() + 1, - KnuthBendix_(congruence_kind::twosided, p)) { + KnuthBendix_()), + _presentation() { init(p); } @@ -3006,9 +3010,18 @@ namespace libsemigroups { //! terminate on certain inputs. //! //! \sa presentation(Presentation const&) - template - SimsRefinerIdeals& init(Presentation const& p) { - _knuth_bendices[0].init(congruence_kind::twosided, p).run(); + SimsRefinerIdeals& init(Presentation const& p) { + _presentation = p; + _knuth_bendices[0].init(congruence_kind::twosided, _presentation).run(); + std::fill(_knuth_bendices.begin() + 1, + _knuth_bendices.end(), + _knuth_bendices[0]); + return *this; + } + + SimsRefinerIdeals& init(Presentation const& p) { + _presentation = to_presentation(p); + _knuth_bendices[0].init(congruence_kind::twosided, _presentation).run(); std::fill(_knuth_bendices.begin() + 1, _knuth_bendices.end(), _knuth_bendices[0]); @@ -3024,13 +3037,12 @@ namespace libsemigroups { //! This function returns the defining presentation of a SimsRefinerIdeals //! instance. //! - //! \returns A const reference to `Presentation`. + //! \returns A const reference to `Presentation`. //! //! \exceptions //! \noexcept - [[nodiscard]] Presentation const& - presentation() const noexcept { - return _knuth_bendices[0].presentation(); + [[nodiscard]] Presentation const& presentation() const noexcept { + return _presentation; } //! \brief Check if a word graph can be extended to one defining a Rees diff --git a/include/libsemigroups/sims.tpp b/include/libsemigroups/sims.tpp index b15407c1f..8a7fd5aa3 100644 --- a/include/libsemigroups/sims.tpp +++ b/include/libsemigroups/sims.tpp @@ -171,19 +171,18 @@ namespace libsemigroups { // TODO(2) avoid the copy here copy.induced_subgraph_no_checks(static_cast(0), wg.number_of_active_nodes()); - tc.init(congruence_kind::onesided, copy) - .add_generating_pair_no_checks( - wx.cbegin(), wx.cend(), wy.cbegin(), wy.cend()); - LIBSEMIGROUPS_ASSERT(tc.word_graph().number_of_nodes() - == wg.number_of_active_nodes()); + tc.init(congruence_kind::onesided, copy); + todd_coxeter::add_generating_pair(tc, wx, wy); + // LIBSEMIGROUPS_ASSERT(tc.word_graph().number_of_nodes() + // == wg.number_of_active_nodes()); // fmt::print("x = {}, y = {}\n", x, y); // fmt::print("wx = {}, wy = {}\n", wx, wy); // std::cout << copy << std::endl; // fmt::print("tc.number_of_classes() == {}\n", // tc.number_of_classes()); fmt::print("copy.number_of_nodes() == // {}\n", copy.number_of_nodes()); - LIBSEMIGROUPS_ASSERT(tc.number_of_classes() - < wg.number_of_active_nodes()); + // LIBSEMIGROUPS_ASSERT(tc.number_of_classes() + // < wg.number_of_active_nodes()); if (tc.number_of_classes() > 1) { return false; } diff --git a/src/sims.cpp b/src/sims.cpp index 86bff3dd9..d5470c081 100644 --- a/src/sims.cpp +++ b/src/sims.cpp @@ -1525,7 +1525,7 @@ namespace libsemigroups { auto const& v = p.second; // TODO(1) change this to be const_contains for knuth // bendix when we have it - if (!kb.contains(u.cbegin(), u.cend(), v.cbegin(), v.cend())) { + if (!knuth_bendix::contains(kb, u, v)) { auto beta = word_graph::follow_path_no_checks(wg, 0, u.cbegin(), u.cend()); if (sink == UNDEFINED) { diff --git a/tests/test-sims.cpp b/tests/test-sims.cpp index 996c5d76c..0ecc4c874 100644 --- a/tests/test-sims.cpp +++ b/tests/test-sims.cpp @@ -4242,7 +4242,7 @@ namespace libsemigroups { LIBSEMIGROUPS_TEST_CASE("Sims2", "119", "2-sided ideals Jura's example", - "[fail][sims1][no-valgrind]") { + "[quick][sims1][no-valgrind]") { // TODO(0) change category back to quick, these fail // currently because of changes to the api in // ToddCoxeter @@ -4404,7 +4404,7 @@ namespace libsemigroups { LIBSEMIGROUPS_TEST_CASE("Sims2", "123", "Adding and removing pruners", - "[fail][low-index]") { + "[quick][low-index]") { // TODO(0) change category back to quick, these fail // currently because of changes to the api in // ToddCoxeter