// // libsemigroups - C++ library for semigroups and monoids // Copyright (C) 2019 James D. Mitchell // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see <http://www.gnu.org/licenses/>.
// The purpose of this file is to test the CongruenceInterface class.
#include"catch.hpp"// for REQUIRE #include"test-main.hpp"// for LIBSEMIGROUPS_TEST_CASE
#include"libsemigroups/cong-intf.hpp"// for CongruenceInterface #include"libsemigroups/cong-pair.hpp"// for CongruenceByPairs #include"libsemigroups/cong.hpp"// for Congruence #include"libsemigroups/fpsemi.hpp"// for FpSemigroup #include"libsemigroups/knuth-bendix.hpp"// for KnuthBendix #include"libsemigroups/tce.hpp"// for TCE #include"libsemigroups/todd-coxeter.hpp"// for ToddCoxeter #include"libsemigroups/transf.hpp"// for Transf<>
SECTION("ToddCoxeter") {
cong = std::make_unique<ToddCoxeter>(twosided);
}
SECTION("KnuthBendix") {
cong = std::make_unique<KnuthBendix>();
}
SECTION("CongruenceByPairs") {
ToddCoxeter tc(twosided);
tc.set_number_of_generators(2);
tc.add_pair({0, 0, 0}, {0});
tc.add_pair({1, 1, 1, 1}, {1});
tc.add_pair({0, 1, 0, 1}, {0, 0});
cong = std::make_unique<CongruenceByPairs<FroidurePinTCE>>(
right, tc.quotient_froidure_pin()); // FIXME(when CongruenceByPairs has a proper traits class) We can't use // "twosided" here because TCE's products are only defined on the right // by generators, and CongruenceByPairs(twosided) does left and right // multiplication by generators. When CongruenceByPairs has a proper // traits class we can define Product to be the product in // tc.quotient_froidure_pin and via operator*.
}
SECTION("Congruence") {
FpSemigroup S; // free semigroup
S.set_alphabet(2);
cong = std::make_unique<Congruence>(twosided, S);
}
LIBSEMIGROUPS_TEST_CASE("CongruenceInterface", "001", "contains/const_contains", "[quick]") { auto rg = ReportGuard(REPORT);
std::unique_ptr<CongruenceInterface> cong;
SECTION("no parent") {
SECTION("ToddCoxeter") {
cong = std::make_unique<ToddCoxeter>(twosided);
}
SECTION("KnuthBendix") {
cong = std::make_unique<KnuthBendix>();
}
REQUIRE_THROWS_AS(cong->const_contains({0}, {1}),
LibsemigroupsException);
REQUIRE_THROWS_AS(cong->const_contains({0}, {0}),
LibsemigroupsException);
}
SECTION("parent") {
SECTION("Congruence") {
FpSemigroup S; // free semigroup
S.set_alphabet(2);
cong = std::make_unique<Congruence>(twosided, S);
}
SECTION("CongruenceByPairs") {
ToddCoxeter tc(twosided);
tc.set_number_of_generators(2);
tc.add_pair({0, 0, 0}, {0});
tc.add_pair({1, 1, 1, 1}, {1});
tc.add_pair({0, 1, 0, 1}, {0, 0});
cong = std::make_unique<CongruenceByPairs<FroidurePinTCE>>(
right, tc.quotient_froidure_pin()); // FIXME(when CongruenceByPairs has a proper traits class) We can't // use "twosided" here because TCE's products are only defined on the // right by generators, and CongruenceByPairs(twosided) does left and // right multiplication by generators. When CongruenceByPairs has a // proper traits class we can define Product to be the product in // tc.quotient_froidure_pin and via operator*.
REQUIRE(cong->const_contains({0}, {1}) == tril::unknown);
}
REQUIRE(cong->contains({0}, {0}));
}
LIBSEMIGROUPS_TEST_CASE("CongruenceInterface", "002", "less", "[quick][no-valgrind]") { auto rg = ReportGuard(REPORT);
std::unique_ptr<CongruenceInterface> cong;
SECTION("ToddCoxeter") {
cong = std::make_unique<ToddCoxeter>(twosided);
REQUIRE_THROWS_AS(cong->less({0}, {1}), LibsemigroupsException);
REQUIRE(!cong->has_parent_froidure_pin());
}
SECTION("KnuthBendix") {
cong = std::make_unique<KnuthBendix>();
REQUIRE_THROWS_AS(cong->less({0}, {1}), LibsemigroupsException);
REQUIRE(!cong->has_parent_froidure_pin());
}
SECTION("CongruenceByPairs") {
ToddCoxeter tc(twosided);
tc.set_number_of_generators(2);
tc.add_pair({0, 0, 0}, {0});
tc.add_pair({1, 1, 1, 1}, {1});
tc.add_pair({0, 1, 0, 1}, {0, 0});
cong = std::make_unique<CongruenceByPairs<FroidurePinTCE>>(
right, tc.quotient_froidure_pin()); // FIXME(when CongruenceByPairs has a proper traits class) We can't use // "twosided" here because TCE's products are only defined on the right // by generators, and CongruenceByPairs(twosided) does left and right // multiplication by generators. When CongruenceByPairs has a proper // traits class we can define Product to be the product in // tc.quotient_froidure_pin and via operator*.
// Wouldn't throw because of the parent semigroup, commented out anyway // so can add more pairs below // REQUIRE_NOTHROW(cong->less({0}, {1}));
REQUIRE(cong->has_parent_froidure_pin());
}
SECTION("Congruence") {
FpSemigroup S; // free semigroup
S.set_alphabet(2);
cong = std::make_unique<Congruence>(twosided, S);
}
REQUIRE(!cong->is_quotient_obviously_infinite()); // So far cong is not-defined, and hence not finite or infinite
REQUIRE(!cong->is_quotient_obviously_finite());
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.