Skip to content

Commit

Permalink
Fix bug in SimsRefinerIdeals, start adding coverage tests
Browse files Browse the repository at this point in the history
  • Loading branch information
reiniscirpons committed Apr 30, 2024
1 parent e0fe861 commit 2538d24
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 56 deletions.
9 changes: 8 additions & 1 deletion include/libsemigroups/sims.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//!
Expand Down Expand Up @@ -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;
}
Expand Down
94 changes: 39 additions & 55 deletions tests/test-sims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3848,6 +3848,7 @@ namespace libsemigroups {
"[quick][sims1]") {
Presentation<std::string> p;
p.alphabet("ab");
p.contains_empty_word(false);
presentation::add_rule(p, "aaa", "bb");
presentation::add_rule(p, "aab", "ba");

Expand All @@ -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
Expand Down Expand Up @@ -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<std::string> 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#
Expand Down

0 comments on commit 2538d24

Please sign in to comment.