29#ifndef LIBSEMIGROUPS_CONG_COMMON_HELPERS_HPP_
30#define LIBSEMIGROUPS_CONG_COMMON_HELPERS_HPP_
34#include <initializer_list>
39#include <unordered_map>
42#include "exception.hpp"
45#include "detail/string.hpp"
50 template <
typename Word>
53 template <
typename Word>
59 class ToddCoxeterImpl;
60 class CongruenceCommon;
61 struct CongruenceBase;
65 namespace congruence_common {
110 template <
typename Thing>
113 typename Thing::native_word_type
const& u,
114 typename Thing::native_word_type
const& v) {
115 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
116 thing.add_generating_pair_no_checks(
129 template <
typename Thing,
typename Int>
133 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
134 static_assert(std::is_integral_v<Int>);
135 thing.add_generating_pair_no_checks(
146 template <
typename Thing>
150 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
151 LIBSEMIGROUPS_ASSERT(u !=
nullptr);
152 LIBSEMIGROUPS_ASSERT(v !=
nullptr);
156 thing.add_generating_pair_no_checks(
168 template <
typename Thing>
171 std::string_view v) {
172 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
176 thing.add_generating_pair_no_checks(
199 template <
typename Thing>
201 typename Thing::native_word_type
const& u,
202 typename Thing::native_word_type
const& v) {
203 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
204 thing.add_generating_pair(
216 template <
typename Thing,
typename Int>
220 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
221 static_assert(std::is_integral_v<Int>);
222 thing.add_generating_pair(
232 template <
typename Thing>
234 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
235 detail::throw_if_nullptr(u,
"2nd");
236 detail::throw_if_nullptr(v,
"3rd");
251 template <
typename Thing>
254 std::string_view v) {
255 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
259 thing.add_generating_pair_no_checks(
320 template <
typename Thing>
323 typename Thing::native_word_type
const& u,
324 typename Thing::native_word_type
const& v) {
325 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
326 return thing.currently_contains_no_checks(
339 template <
typename Thing,
typename Int>
344 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
345 static_assert(std::is_integral_v<Int>);
346 return thing.currently_contains_no_checks(
357 template <
typename Thing>
361 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
362 LIBSEMIGROUPS_ASSERT(u !=
nullptr);
363 LIBSEMIGROUPS_ASSERT(v !=
nullptr);
367 return thing.currently_contains_no_checks(
380 template <
typename Thing>
383 std::string_view v) {
384 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
388 return thing.currently_contains_no_checks(
423 template <
typename Thing>
426 typename Thing::native_word_type
const& u,
427 typename Thing::native_word_type
const& v) {
428 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
429 return thing.currently_contains(
441 template <
typename Thing,
typename Int>
445 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
446 static_assert(std::is_integral_v<Int>);
447 return thing.currently_contains(
457 template <
typename Thing>
461 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
462 detail::throw_if_nullptr(u,
"2nd");
463 detail::throw_if_nullptr(v,
"3rd");
464 return thing.currently_contains(
476 template <
typename Thing>
479 std::string_view v) {
480 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
481 return thing.currently_contains(
511 template <
typename Thing>
514 typename Thing::native_word_type
const& u,
515 typename Thing::native_word_type
const& v) {
516 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
517 return thing.contains_no_checks(
529 template <
typename Thing,
typename Int>
533 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
534 static_assert(std::is_integral_v<Int>);
544 template <
typename Thing>
548 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
549 LIBSEMIGROUPS_ASSERT(u !=
nullptr);
550 LIBSEMIGROUPS_ASSERT(v !=
nullptr);
554 return thing.contains_no_checks(
566 template <
typename Thing>
569 std::string_view v) {
570 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
574 return thing.contains_no_checks(
604 template <
typename Thing>
606 typename Thing::native_word_type
const& u,
607 typename Thing::native_word_type
const& v) {
608 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
609 return thing.contains(
621 template <
typename Thing,
typename Int>
625 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
626 static_assert(std::is_integral_v<Int>);
627 return thing.contains(
639 template <
typename Thing>
642 std::string_view v) {
643 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
647 return thing.contains(
657 template <
typename Thing>
658 [[nodiscard]]
bool contains(Thing& thing,
char const* u,
char const* v) {
659 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
660 detail::throw_if_nullptr(u,
"2nd");
661 detail::throw_if_nullptr(v,
"3rd");
723 template <
typename Thing>
724 [[nodiscard]]
typename Thing::native_word_type
726 typename Thing::native_word_type
const& w);
740 template <
typename Thing,
typename Int>
741 [[nodiscard]]
typename Thing::native_word_type
751 template <
typename Thing>
752 [[nodiscard]]
typename Thing::native_word_type
784 template <
typename Thing>
785 [[nodiscard]]
typename Thing::native_word_type
787 typename Thing::native_word_type
const& w);
800 template <
typename Thing,
typename Int>
801 [[nodiscard]]
typename Thing::native_word_type
809 template <
typename Thing>
810 [[nodiscard]]
typename Thing::native_word_type
839 template <
typename Thing>
840 [[nodiscard]]
typename Thing::native_word_type
842 typename Thing::native_word_type
const& w);
855 template <
typename Thing,
typename Int>
856 [[nodiscard]]
typename Thing::native_word_type
864 template <
typename Thing>
865 [[nodiscard]]
typename Thing::native_word_type
893 template <
typename Thing>
894 [[nodiscard]]
typename Thing::native_word_type
895 reduce(Thing
const& thing,
typename Thing::native_word_type
const& w);
908 template <
typename Thing,
typename Int>
909 [[nodiscard]]
typename Thing::native_word_type
917 template <
typename Thing>
918 [[nodiscard]]
typename Thing::native_word_type
reduce(Thing
const& thing,
946#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
948 template <
typename Word,
950 typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>>
952 partition(ToddCoxeter<Word>& thing, Range r);
954 template <
typename Word,
956 typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>>
958 partition(Congruence<Word>& thing, Range r);
983 template <
typename Thing,
985 typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>>
994 template <
typename Thing,
typename Iterator1,
typename Iterator2>
996 partition(Thing& thing, Iterator1 first, Iterator2 last) {
998 return partition(thing, rx::iterator_range(first, last));
1028 template <
typename Thing,
1030 typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>>
1040 template <
typename Thing,
typename Iterator1,
typename Iterator2>
1050#include "cong-common-helpers.tpp"
void add_generating_pair(Thing &thing, typename Thing::native_word_type const &u, typename Thing::native_word_type const &v)
Helper for adding a generating pair of words.
Definition cong-common-helpers.hpp:200
void add_generating_pair_no_checks(Thing &thing, typename Thing::native_word_type const &u, typename Thing::native_word_type const &v)
Helper for adding a generating pair of words.
Definition cong-common-helpers.hpp:112
bool contains_no_checks(Thing &thing, typename Thing::native_word_type const &u, typename Thing::native_word_type const &v)
Check containment of a pair of words.
Definition cong-common-helpers.hpp:513
bool contains(Thing &thing, typename Thing::native_word_type const &u, typename Thing::native_word_type const &v)
Check containment of a pair of words.
Definition cong-common-helpers.hpp:605
tril currently_contains(Thing const &thing, typename Thing::native_word_type const &u, typename Thing::native_word_type const &v)
Check containment of a pair of words.
Definition cong-common-helpers.hpp:425
tril currently_contains_no_checks(Thing const &thing, typename Thing::native_word_type const &u, typename Thing::native_word_type const &v)
Check containment of a pair of words.
Definition cong-common-helpers.hpp:322
std::vector< std::vector< typename Thing::native_word_type > > non_trivial_classes(Thing &thing, Range r)
Find the non-trivial classes in the partition of a range of words.
std::vector< std::vector< typename Thing::native_word_type > > partition(Thing &thing, Range r)
Partition a range of words.
Thing::native_word_type reduce(Thing const &thing, typename Thing::native_word_type const &w)
Reduce a word.
Thing::native_word_type reduce_no_run_no_checks(Thing const &thing, typename Thing::native_word_type const &w)
Reduce a word with no enumeration or checks.
Thing::native_word_type reduce_no_checks(Thing const &thing, typename Thing::native_word_type const &w)
Reduce a word with no checks.
Thing::native_word_type reduce_no_run(Thing const &thing, typename Thing::native_word_type const &w)
Reduce a word with no enumeration.
tril
Enum to indicate true, false or not currently knowable.
Definition types.hpp:56
Namespace for everything in the libsemigroups library.
Definition action.hpp:44