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"
43#include "is_specialization_of.hpp"
46#include "detail/string.hpp"
51 template <
typename Word>
54 template <
typename Word>
60 class ToddCoxeterImpl;
61 class CongruenceCommon;
64 namespace congruence_common {
109 template <
typename Thing>
112 typename Thing::native_word_type
const& u,
113 typename Thing::native_word_type
const& v) {
114 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
115 thing.add_generating_pair_no_checks(
128 template <
typename Thing,
typename Int>
132 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
133 static_assert(std::is_integral_v<Int>);
134 thing.add_generating_pair_no_checks(
145 template <
typename Thing>
149 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
150 LIBSEMIGROUPS_ASSERT(u !=
nullptr);
151 LIBSEMIGROUPS_ASSERT(v !=
nullptr);
155 thing.add_generating_pair_no_checks(
167 template <
typename Thing>
170 std::string_view v) {
171 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
175 thing.add_generating_pair_no_checks(
198 template <
typename Thing>
200 typename Thing::native_word_type
const& u,
201 typename Thing::native_word_type
const& v) {
202 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
203 thing.add_generating_pair(
215 template <
typename Thing,
typename Int>
219 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
220 static_assert(std::is_integral_v<Int>);
221 thing.add_generating_pair(
231 template <
typename Thing>
233 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
234 detail::throw_if_nullptr(u,
"2nd");
235 detail::throw_if_nullptr(v,
"3rd");
250 template <
typename Thing>
253 std::string_view v) {
254 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
258 thing.add_generating_pair_no_checks(
319 template <
typename Thing>
322 typename Thing::native_word_type
const& u,
323 typename Thing::native_word_type
const& v) {
324 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
325 return thing.currently_contains_no_checks(
338 template <
typename Thing,
typename Int>
343 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
344 static_assert(std::is_integral_v<Int>);
345 return thing.currently_contains_no_checks(
356 template <
typename Thing>
360 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
361 LIBSEMIGROUPS_ASSERT(u !=
nullptr);
362 LIBSEMIGROUPS_ASSERT(v !=
nullptr);
366 return thing.currently_contains_no_checks(
379 template <
typename Thing>
382 std::string_view v) {
383 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
387 return thing.currently_contains_no_checks(
422 template <
typename Thing>
425 typename Thing::native_word_type
const& u,
426 typename Thing::native_word_type
const& v) {
427 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
428 return thing.currently_contains(
440 template <
typename Thing,
typename Int>
444 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
445 static_assert(std::is_integral_v<Int>);
446 return thing.currently_contains(
456 template <
typename Thing>
460 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
461 detail::throw_if_nullptr(u,
"2nd");
462 detail::throw_if_nullptr(v,
"3rd");
463 return thing.currently_contains(
475 template <
typename Thing>
478 std::string_view v) {
479 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
480 return thing.currently_contains(
510 template <
typename Thing>
513 typename Thing::native_word_type
const& u,
514 typename Thing::native_word_type
const& v) {
515 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
516 return thing.contains_no_checks(
528 template <
typename Thing,
typename Int>
532 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
533 static_assert(std::is_integral_v<Int>);
543 template <
typename Thing>
547 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
548 LIBSEMIGROUPS_ASSERT(u !=
nullptr);
549 LIBSEMIGROUPS_ASSERT(v !=
nullptr);
553 return thing.contains_no_checks(
565 template <
typename Thing>
568 std::string_view v) {
569 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
573 return thing.contains_no_checks(
603 template <
typename Thing>
605 typename Thing::native_word_type
const& u,
606 typename Thing::native_word_type
const& v) {
607 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
608 return thing.contains(
620 template <
typename Thing,
typename Int>
624 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
625 static_assert(std::is_integral_v<Int>);
626 return thing.contains(
638 template <
typename Thing>
641 std::string_view v) {
642 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
646 return thing.contains(
656 template <
typename Thing>
657 [[nodiscard]]
bool contains(Thing& thing,
char const* u,
char const* v) {
658 static_assert(std::is_base_of_v<detail::CongruenceCommon, Thing>);
659 detail::throw_if_nullptr(u,
"2nd");
660 detail::throw_if_nullptr(v,
"3rd");
722 template <
typename Thing>
723 [[nodiscard]]
typename Thing::native_word_type
725 typename Thing::native_word_type
const& w);
739 template <
typename Thing,
typename Int>
740 [[nodiscard]]
typename Thing::native_word_type
750 template <
typename Thing>
751 [[nodiscard]]
typename Thing::native_word_type
783 template <
typename Thing>
784 [[nodiscard]]
typename Thing::native_word_type
786 typename Thing::native_word_type
const& w);
799 template <
typename Thing,
typename Int>
800 [[nodiscard]]
typename Thing::native_word_type
808 template <
typename Thing>
809 [[nodiscard]]
typename Thing::native_word_type
838 template <
typename Thing>
839 [[nodiscard]]
typename Thing::native_word_type
841 typename Thing::native_word_type
const& w);
854 template <
typename Thing,
typename Int>
855 [[nodiscard]]
typename Thing::native_word_type
863 template <
typename Thing>
864 [[nodiscard]]
typename Thing::native_word_type
892 template <
typename Thing>
893 [[nodiscard]]
typename Thing::native_word_type
894 reduce(Thing
const& thing,
typename Thing::native_word_type
const& w);
907 template <
typename Thing,
typename Int>
908 [[nodiscard]]
typename Thing::native_word_type
916 template <
typename Thing>
917 [[nodiscard]]
typename Thing::native_word_type
reduce(Thing
const& thing,
945#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
947 template <
typename Word,
949 typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>>
951 partition(ToddCoxeter<Word>& thing, Range r);
953 template <
typename Word,
955 typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>>
957 partition(Congruence<Word>& thing, Range r);
982 template <
typename Thing,
984 typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>>
993 template <
typename Thing,
typename Iterator1,
typename Iterator2>
995 partition(Thing& thing, Iterator1 first, Iterator2 last) {
997 return partition(thing, rx::iterator_range(first, last));
1027 template <
typename Thing,
1029 typename = std::enable_if_t<rx::is_input_or_sink_v<Range>>>
1039 template <
typename Thing,
typename Iterator1,
typename Iterator2>
1049#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:199
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:111
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:512
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:604
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:424
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:321
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:54
Namespace for everything in the libsemigroups library.
Definition action.hpp:44