22#ifndef LIBSEMIGROUPS_TODD_COXETER_HELPERS_HPP_
23#define LIBSEMIGROUPS_TODD_COXETER_HELPERS_HPP_
28#include <initializer_list>
35#include "cong-common-helpers.hpp"
36#include "constants.hpp"
37#include "exception.hpp"
39#include "presentation.hpp"
41#include "todd-coxeter-class.hpp"
43#include "word-graph.hpp"
45#include "detail/fmt.hpp"
46#include "detail/path-iterators.hpp"
57#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
59 using index_type =
typename detail::ToddCoxeterImpl::index_type;
106 template <
typename Word>
107 [[nodiscard]] index_type
129 template <
typename Word>
152 template <
typename Word>
175 template <
typename Word>
176 [[nodiscard]] index_type
index_of(ToddCoxeter<Word>& tc, Word
const& w) {
197 template <
typename Word,
typename Int>
198 [[nodiscard]] index_type
201 static_assert(std::is_integral_v<Int>);
222 template <
typename Word,
typename Int>
223 [[nodiscard]] index_type
226 static_assert(std::is_integral_v<Int>);
247 template <
typename Word,
typename Int>
248 [[nodiscard]] index_type
251 static_assert(std::is_integral_v<Int>);
272 template <
typename Word,
typename Int>
273 [[nodiscard]] index_type
index_of(ToddCoxeter<Word>& tc,
275 static_assert(std::is_integral_v<Int>);
294 template <
typename Word>
295 [[nodiscard]]
inline index_type
297 LIBSEMIGROUPS_ASSERT(w !=
nullptr);
316 template <
typename Word>
319 detail::throw_if_nullptr(w,
"2nd");
338 template <
typename Word>
341 LIBSEMIGROUPS_ASSERT(w !=
nullptr);
360 template <
typename Word>
361 [[nodiscard]]
inline index_type
index_of(ToddCoxeter<Word>& tc,
363 detail::throw_if_nullptr(w,
"2nd");
384 template <
typename Word>
401 template <
typename Word>
417 template <
typename Word>
433 template <
typename Word>
434 [[nodiscard]] Word
word_of(ToddCoxeter<Word>& tc, index_type i);
462 template <
typename Word>
464 size_t const offset = (tc.
presentation().contains_empty_word() ? 0 : 1);
473 | rx::transform([&tc](
auto const& w) {
475 for (
auto index : w) {
476 ww.push_back(tc.
presentation().letter_no_checks(index));
504 template <
typename Word>
507 size_t const offset = (tc.
presentation().contains_empty_word() ? 0 : 1);
517 .target_no_checks(n + offset)
518 | rx::transform([&tc](
auto const& w) {
520 for (
auto index : w) {
521 ww.push_back(tc.
presentation().letter_no_checks(index));
551 template <
typename Word,
typename Iterator1,
typename Iterator2>
582 template <
typename Word,
typename Iterator1,
typename Iterator2>
612 template <
typename Word>
613 [[nodiscard]]
auto class_of(ToddCoxeter<Word>& tc, Word
const& w) {
640 template <
typename Word>
669 template <
typename Word,
typename Int>
672 static_assert(std::is_integral_v<Int>);
699 template <
typename Word,
typename Int>
702 static_assert(std::is_integral_v<Int>);
727 template <
typename Word>
730 LIBSEMIGROUPS_ASSERT(w !=
nullptr);
755 template <
typename Word>
756 [[nodiscard]]
auto class_of(ToddCoxeter<Word>& tc,
char const* w) {
757 detail::throw_if_nullptr(w,
"2nd");
758 LIBSEMIGROUPS_ASSERT(w !=
nullptr);
760#if defined(__GNUC__) && !defined(__clang__)
761#pragma GCC diagnostic push
762#pragma GCC diagnostic ignored "-Wnonnull"
765#if defined(__GNUC__) && !defined(__clang__)
766#pragma GCC diagnostic pop
809 float threshold = 0.99);
847 template <
typename Word,
typename Time>
858 namespace congruence_common {
885 template <
typename Word>
886 [[nodiscard]]
auto normal_forms(ToddCoxeter<Word>& tc);
917 template <
typename Word,
typename Range,
typename>
919 partition(ToddCoxeter<Word>& tc, Range r);
947 template <
typename Word>
955 namespace todd_coxeter {
986 using congruence_common::normal_forms;
992#include "todd-coxeter-helpers.tpp"
Paths(WordGraph< Node > const &) -> Paths< Node >
For an implementation of presentations for semigroups or monoids.
Definition presentation.hpp:102
void run()
Run until finished.
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.
word_graph_type const & current_word_graph() const noexcept
Get the current word graph.
Definition todd-coxeter-impl.hpp:1213
Presentation< Word > const & presentation() const noexcept
Get the presentation used to define a ToddCoxeter instance (if any).
Definition todd-coxeter-class.hpp:649
index_type current_index_of(Iterator1 first, Iterator2 last) const
Returns the current index of the class containing a word.
Definition todd-coxeter-class.hpp:1055
index_type current_index_of_no_checks(Iterator1 first, Iterator2 last) const
Returns the current index of the class containing a word.
Definition todd-coxeter-class.hpp:1025
index_type index_of_no_checks(Iterator1 first, Iterator2 last)
Returns the index of the class containing a word.
Definition todd-coxeter-class.hpp:1085
index_type index_of(Iterator1 first, Iterator2 last)
Returns the index of the class containing a word.
Definition todd-coxeter-class.hpp:1115
auto class_of(ToddCoxeter< Word > &tc, Iterator1 first, Iterator2 last)
Returns a range object containing every word in the congruence class of a word given by iterators.
Definition todd-coxeter-helpers.hpp:552
auto class_by_index_no_checks(ToddCoxeter< Word > &tc, index_type n)
Returns a range object containing every word in the congruence class with given index.
Definition todd-coxeter-helpers.hpp:505
auto class_by_index(ToddCoxeter< Word > &tc, index_type n)
Returns a range object containing every word in the congruence class with given index.
Definition todd-coxeter-helpers.hpp:463
Word current_word_of(ToddCoxeter< Word > &tc, index_type i)
Returns a word representing a class with given index.
tril is_non_trivial(detail::ToddCoxeterImpl &tc, size_t tries=10, std::chrono::milliseconds try_for=std::chrono::milliseconds(100), float threshold=0.99)
Check if the congruence has more than one class.
Word current_word_of_no_checks(ToddCoxeter< Word > &tc, index_type i)
Returns a word representing a class with given index.
Word word_of(ToddCoxeter< Word > &tc, index_type i)
Returns a word representing a class with given index.
auto class_of_no_checks(ToddCoxeter< Word > &tc, Iterator1 first, Iterator2 last)
Returns a range object containing every word in the congruence class of a word given by iterators.
Definition todd-coxeter-helpers.hpp:583
index_type index_of_no_checks(ToddCoxeter< Word > &tc, Word const &w)
Returns the index of the class containing a word.
Definition todd-coxeter-helpers.hpp:153
index_type current_index_of(ToddCoxeter< Word > const &tc, Word const &w)
Returns the current index of the class containing a word.
Definition todd-coxeter-helpers.hpp:130
index_type current_index_of_no_checks(ToddCoxeter< Word > const &tc, Word const &w)
Returns the current index of the class containing a word.
Definition todd-coxeter-helpers.hpp:108
index_type index_of(ToddCoxeter< Word > &tc, Word const &w)
Returns the index of the class containing a word.
Definition todd-coxeter-helpers.hpp:176
Word word_of_no_checks(ToddCoxeter< Word > &tc, index_type i)
Returns a word representing a class with given index.
std::vector< Word >::const_iterator redundant_rule(Presentation< Word > const &p, Time t)
Return an iterator pointing at the left hand side of a redundant rule.
tril
Enum to indicate true, false or not currently knowable.
Definition types.hpp:56
Definition todd-coxeter-helpers.hpp:52
Namespace for everything in the libsemigroups library.
Definition action.hpp:44