diff --git a/include/libsemigroups/sims.hpp b/include/libsemigroups/sims.hpp index 1899b7aca..47a8d43dd 100644 --- a/include/libsemigroups/sims.hpp +++ b/include/libsemigroups/sims.hpp @@ -324,7 +324,7 @@ namespace libsemigroups { //! * \ref number_of_threads to set the number of threads; //! * \ref include to set the pairs to be included; //! * \ref exclude to set the pairs to be excluded; - //! * \ref add_pruner to add a pruninf function; + //! * \ref add_pruner to add a pruner; //! * \ref long_rule_length to set the length of long rules; //! * \ref idle_thread_restarts to set the number of idle thread restarts. //! @@ -3120,6 +3120,13 @@ namespace libsemigroups { return false; } } + } else { + auto const N = wg.number_of_active_nodes(); + auto first = wg.cbegin_nodes(); + auto last = wg.cbegin_nodes() + N; + if (word_graph::is_complete(wg, first, last)) { + return false; + } } return true; } diff --git a/tests/test-sims.cpp b/tests/test-sims.cpp index 96588ac41..eb62dd647 100644 --- a/tests/test-sims.cpp +++ b/tests/test-sims.cpp @@ -3848,6 +3848,7 @@ namespace libsemigroups { "[quick][sims1]") { Presentation p; p.alphabet("ab"); + p.contains_empty_word(false); presentation::add_rule(p, "aaa", "bb"); presentation::add_rule(p, "aab", "ba"); @@ -3858,61 +3859,24 @@ namespace libsemigroups { SimsRefinerIdeals ip(s.presentation()); s.add_pruner(ip); - // size_t result = 0; - // s.for_each(3, [&ip, &result](auto const& wg) { - // if (ip(wg)) { - // result++; - // } - // }); - // REQUIRE(result == 5); - // result = 0; - // s.for_each(4, [&ip, &result](auto const& wg) { - // if (ip(wg)) { - // result++; - // } - // }); - // REQUIRE(result == 7); - // - // result = 0; - // s.for_each(5, [&ip, &result](auto const& wg) { - // if (ip(wg)) { - // result++; - // } - // }); - // REQUIRE(result == 9); - // - // result = 0; - // s.for_each(6, [&ip, &result](auto const& wg) { - // if (ip(wg)) { - // result++; - // } - // }); - // REQUIRE(result == 11); - // - // result = 0; - // s.for_each(7, [&ip, &result](auto const& wg) { - // if (ip(wg)) { - // result++; - // } - // }); - // REQUIRE(result == 12); - // - // result = 0; - // s.for_each(8, [&ip, &result](auto const& wg) { - // if (ip(wg)) { - // result++; - // } - // }); - // REQUIRE(result == 12); - - REQUIRE(s.number_of_congruences(1) == 1); // computed using GAP - REQUIRE(s.number_of_congruences(2) == 3); // computed using GAP - REQUIRE(s.number_of_congruences(3) == 5); // computed using GAP - REQUIRE(s.number_of_congruences(4) == 7); // computed using GAP - REQUIRE(s.number_of_congruences(5) == 9); // computed using GAP - REQUIRE(s.number_of_congruences(6) == 11); // computed using GAP - REQUIRE(s.number_of_congruences(7) == 12); // computed using GAP - REQUIRE(s.number_of_congruences(8) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(1) == 1); // computed using GAP + REQUIRE(s.number_of_congruences(2) == 3); // computed using GAP + REQUIRE(s.number_of_congruences(3) == 5); // computed using GAP + REQUIRE(s.number_of_congruences(4) == 7); // computed using GAP + REQUIRE(s.number_of_congruences(5) == 9); // computed using GAP + REQUIRE(s.number_of_congruences(6) == 11); // computed using GAP + REQUIRE(s.number_of_congruences(7) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(8) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(9) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(10) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(11) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(12) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(13) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(14) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(15) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(50) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(100) == 12); // computed using GAP + REQUIRE(s.number_of_congruences(1000) == 12); // computed using GAP } // about 2 seconds @@ -4031,6 +3995,26 @@ namespace libsemigroups { // REQUIRE(result == 6); // REQUIRE(s.number_of_congruences(15) == 0); } + + LIBSEMIGROUPS_TEST_CASE("Sims2", + "123", + "Adding and removing pruners", + "[quick][low-index]") { + Presentation p; + p.alphabet("ab"); + p.contains_empty_word(false); + presentation::add_rule(p, "aaa", "bb"); + presentation::add_rule(p, "aab", "ba"); + + Sims2 s(p); + SimsRefinerIdeals ip(s.presentation()); + s.add_pruner(ip); + REQUIRE(s.number_of_congruences(12) == 12); // computed using GAP + s.clear_pruners(); + REQUIRE(s.number_of_congruences(12) == 41); // computed using GAP + s.add_pruner(ip); + REQUIRE(s.number_of_congruences(12) == 12); // computed using GAP + } } // namespace libsemigroups // [[[0, 0, 0]], #1#