22#ifndef LIBSEMIGROUPS_CONG_CLASS_HPP_
23#define LIBSEMIGROUPS_CONG_CLASS_HPP_
33#include "knuth-bendix-class.hpp"
34#include "presentation.hpp"
35#include "todd-coxeter-class.hpp"
37#include "word-graph-helpers.hpp"
39#include "detail/cong-common-class.hpp"
40#include "detail/race.hpp"
45 template <
typename Node>
155 template <
typename Word>
156 class Congruence :
public detail::CongruenceCommon {
157 enum class RunnerKind :
size_t { TC = 0, KB = 1, K = 2 };
163 std::vector<Word> _generating_pairs;
165 mutable detail::Race _race;
166 mutable bool _runners_initted;
167 mutable std::vector<RunnerKind> _runner_kinds;
299 template <
typename Iterator1,
308 _runners_initted =
false;
309 _generating_pairs.emplace_back(first1, last1);
310 _generating_pairs.emplace_back(first2, last2);
311 return detail::CongruenceCommon::add_internal_generating_pair_no_checks<
329 template <
typename Iterator1,
337 _runners_initted =
false;
340 "any_runner_started() returned \"true\" so no further "
341 "generating pairs can be added at this stage");
343 return detail::CongruenceCommon::add_generating_pair<Congruence>(
344 first1, last1, first2, last2);
389 template <
typename Iterator1,
396 Iterator4 last2)
const;
416 template <
typename Iterator1,
423 Iterator4 last2)
const {
424 return detail::CongruenceCommon::currently_contains<Congruence>(
425 first1, last1, first2, last2);
449 template <
typename Iterator1,
457 return detail::CongruenceCommon::contains_no_checks<Congruence>(
458 first1, last1, first2, last2);
478 template <
typename Iterator1,
486 return detail::CongruenceCommon::contains<Congruence>(
487 first1, last1, first2, last2);
511 template <
typename OutputIterator,
typename Iterator1,
typename Iterator2>
514 Iterator2 last)
const;
533 template <
typename OutputIterator,
typename Iterator1,
typename Iterator2>
536 Iterator2 last)
const {
537 return detail::CongruenceCommon::reduce_no_run<Congruence>(
538 d_first, first, last);
556 template <
typename OutputIterator,
557 typename InputIterator1,
558 typename InputIterator2>
560 InputIterator1 first,
561 InputIterator2 last) {
562 return detail::CongruenceCommon::reduce_no_checks<Congruence>(
563 d_first, first, last);
581 template <
typename OutputIterator,
582 typename InputIterator1,
583 typename InputIterator2>
584 OutputIterator
reduce(OutputIterator d_first,
585 InputIterator1 first,
586 InputIterator2 last) {
587 return detail::CongruenceCommon::reduce<Congruence>(d_first, first, last);
611 template <
typename Iterator1,
typename Iterator2>
636 template <
typename Thing>
657 template <
typename Thing>
658 [[nodiscard]]
bool has()
const;
676 return _race.max_threads();
696 _race.max_threads(val);
712 return _race.number_of_runners();
736 return std::any_of(_race.begin(), _race.end(), [](
auto const& r) {
754 return _presentation;
769 return _generating_pairs;
772#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
814 _runner_kinds.push_back(RunnerKind::TC);
827 template <
typename Result,
typename Node>
829 FroidurePinBase& fpb,
830 WordGraph<Node>
const& wg)
832 std::is_same_v<Congruence<typename Result::native_word_type>,
836 template <
typename Result,
typename Node>
838 to(
congruence_kind knd, WordGraph<Node>
const& wg) -> std::enable_if_t<
839 std::is_same_v<Congruence<typename Result::native_word_type>, Result>,
842 void init_runners()
const;
848 void run_impl()
override;
849 bool finished_impl()
const override {
850 return _race.finished();
862 template <
typename Word>
875 template <
typename Word>
886 template <
typename Word>
897 template <
typename Word>
915 template <
typename Word>
919#include "cong-class.tpp"
Base class for FroidurePin containing non-element specific data and member functions.
Definition froidure-pin-base.hpp:67
For an implementation of presentations for semigroups or monoids.
Definition presentation.hpp:103
Class for representing word graphs.
Definition word-graph.hpp:83
std::string to_human_readable_repr(Action< Element, Point, Func, Traits, LeftOrRight > const &action)
Return a human readable representation of an Action object.
std::shared_ptr< Thing > get() const
Get a derived class of Runner being used to compute a Congruence instance.
bool has() const
Check if a derived class of Runner being used to compute a Congruence instance.
bool any_runner_started() const noexcept
Check if any runner has started.
Definition cong-class.hpp:735
Congruence(congruence_kind, Presentation< Word > const &) -> Congruence< Word >
Deduction guide.
Congruence(Congruence const &)
Copy constructor.
Congruence(Congruence &&)
Move constructor.
Congruence()
Default constructor.
Congruence & init()
Re-initialize a Congruence instance.
Congruence & operator=(Congruence &&)
Move assignment operator.
Congruence(congruence_kind knd, Presentation< Word > const &p)
Construct from congruence_kind and Presentation.
Definition cong-class.hpp:255
void throw_if_letter_not_in_alphabet(Iterator1 first, Iterator2 last) const
Throws if any letter in a range is out of bounds.
Congruence & operator=(Congruence const &)
Copy assignment operator.
Congruence & init(congruence_kind knd, Presentation< Word > const &p)
Re-initialize a Congruence instance.
OutputIterator reduce_no_checks(OutputIterator d_first, InputIterator1 first, InputIterator2 last)
Reduce a word with no checks.
Definition cong-class.hpp:559
uint64_t number_of_classes()
Compute the number of classes in the congruence.
bool contains_no_checks(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Check containment of a pair of words via iterators.
Definition cong-class.hpp:453
OutputIterator reduce_no_run_no_checks(OutputIterator d_first, Iterator1 first, Iterator2 last) const
Reduce a word with no computation or checks.
tril currently_contains(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2) const
Check containment of a pair of words via iterators.
Definition cong-class.hpp:420
Congruence & add_generating_pair(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Add generating pair via iterators.
Definition cong-class.hpp:333
OutputIterator reduce(OutputIterator d_first, InputIterator1 first, InputIterator2 last)
Reduce a word.
Definition cong-class.hpp:584
size_t number_of_generating_pairs() const noexcept
Returns the number of generating pairs.
std::vector< Word > const & generating_pairs() const noexcept
Get the generating pairs of the congruence.
Definition cong-class.hpp:768
tril currently_contains_no_checks(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2) const
Check containment of a pair of words via iterators.
Congruence & add_generating_pair_no_checks(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Add generating pair via iterators.
Definition cong-class.hpp:303
bool contains(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Check containment of a pair of words via iterators.
Definition cong-class.hpp:482
congruence_kind kind() const noexcept
The kind of the congruence (1- or 2-sided).
Presentation< Word > const & presentation() const noexcept
Get the presentation defining the parent semigroup of the congruence.
Definition cong-class.hpp:753
OutputIterator reduce_no_run(OutputIterator d_first, Iterator1 first, Iterator2 last) const
Reduce a word with no computation.
Definition cong-class.hpp:534
Word native_word_type
Type of the words in the relations of the presentation stored in a Congruence instance.
Definition cong-class.hpp:184
Congruence & max_threads(size_t val) noexcept
Set the maximum number of threads.
Definition cong-class.hpp:695
size_t max_threads() const noexcept
Get the current maximum number of threads.
Definition cong-class.hpp:675
size_t number_of_runners() const noexcept
Get the number of runners.
Definition cong-class.hpp:711
#define LIBSEMIGROUPS_EXCEPTION(...)
Throw a LibsemigroupsException.
Definition exception.hpp:99
Presentation(Presentation< Word > const &) -> Presentation< Word >
Deduction guide.
tril
Enum to indicate true, false or not currently knowable.
Definition types.hpp:54
congruence_kind
Enum to indicate the sided-ness of a congruence.
Definition types.hpp:67
Namespace for everything in the libsemigroups library.
Definition action.hpp:44