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"
38#include "detail/cong-common-class.hpp"
39#include "detail/race.hpp"
44 template <
typename Node>
154 template <
typename Word>
155 class Congruence :
public detail::CongruenceCommon {
156 enum class RunnerKind :
size_t { TC = 0, KB = 1, K = 2 };
162 mutable detail::Race _race;
163 mutable bool _runners_initted;
164 std::vector<RunnerKind> _runner_kinds;
291 template <
typename Iterator1,
300 _runners_initted =
false;
301 return detail::CongruenceCommon::add_internal_generating_pair_no_checks<
319 template <
typename Iterator1,
327 _runners_initted =
false;
330 "any_runner_started() returned \"true\" so no further "
331 "generating pairs can be added at this stage");
333 return detail::CongruenceCommon::add_generating_pair<Congruence>(
334 first1, last1, first2, last2);
379 template <
typename Iterator1,
386 Iterator4 last2)
const;
406 template <
typename Iterator1,
413 Iterator4 last2)
const {
414 return detail::CongruenceCommon::currently_contains<Congruence>(
415 first1, last1, first2, last2);
439 template <
typename Iterator1,
447 return detail::CongruenceCommon::contains_no_checks<Congruence>(
448 first1, last1, first2, last2);
468 template <
typename Iterator1,
476 return detail::CongruenceCommon::contains<Congruence>(
477 first1, last1, first2, last2);
501 template <
typename OutputIterator,
typename Iterator1,
typename Iterator2>
504 Iterator2 last)
const;
523 template <
typename OutputIterator,
typename Iterator1,
typename Iterator2>
526 Iterator2 last)
const {
527 return detail::CongruenceCommon::reduce_no_run<Congruence>(
528 d_first, first, last);
546 template <
typename OutputIterator,
547 typename InputIterator1,
548 typename InputIterator2>
550 InputIterator1 first,
551 InputIterator2 last) {
552 return detail::CongruenceCommon::reduce_no_checks<Congruence>(
553 d_first, first, last);
571 template <
typename OutputIterator,
572 typename InputIterator1,
573 typename InputIterator2>
574 OutputIterator
reduce(OutputIterator d_first,
575 InputIterator1 first,
576 InputIterator2 last) {
577 return detail::CongruenceCommon::reduce<Congruence>(d_first, first, last);
601 template <
typename Iterator1,
typename Iterator2>
626 template <
typename Thing>
647 template <
typename Thing>
648 [[nodiscard]]
bool has()
const;
666 return _race.max_threads();
686 _race.max_threads(val);
702 return _race.number_of_runners();
726 return std::any_of(_race.begin(), _race.end(), [](
auto const& r) {
758#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
800 _runner_kinds.push_back(RunnerKind::TC);
813 template <
typename Result,
typename Node>
815 FroidurePinBase& fpb,
816 WordGraph<Node>
const& wg)
818 std::is_same_v<Congruence<typename Result::native_word_type>,
822 template <
typename Result,
typename Node>
824 to(
congruence_kind knd, WordGraph<Node>
const& wg) -> std::enable_if_t<
825 std::is_same_v<Congruence<typename Result::native_word_type>, Result>,
828 void init_runners()
const;
834 void run_impl()
override;
835 bool finished_impl()
const override {
836 return _race.finished();
848 template <
typename Word>
861 template <
typename Word>
872 template <
typename Word>
883 template <
typename Word>
901 template <
typename Word>
905#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:725
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:248
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:549
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:443
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:410
Congruence & add_generating_pair(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Add generating pair via iterators.
Definition cong-class.hpp:323
OutputIterator reduce(OutputIterator d_first, InputIterator1 first, InputIterator2 last)
Reduce a word.
Definition cong-class.hpp:574
size_t number_of_generating_pairs() const noexcept
Returns the number of generating pairs.
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:295
bool contains(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Check containment of a pair of words via iterators.
Definition cong-class.hpp:472
std::vector< Word > const & generating_pairs() const
Get the generating pairs of the congruence.
congruence_kind kind() const noexcept
The kind of the congruence (1- or 2-sided).
OutputIterator reduce_no_run(OutputIterator d_first, Iterator1 first, Iterator2 last) const
Reduce a word with no computation.
Definition cong-class.hpp:524
Presentation< Word > const & presentation() const
Get the presentation defining the parent semigroup of the congruence.
Word native_word_type
Type of the words in the relations of the presentation stored in a Congruence instance.
Definition cong-class.hpp:178
Congruence & max_threads(size_t val) noexcept
Set the maximum number of threads.
Definition cong-class.hpp:685
size_t max_threads() const noexcept
Get the current maximum number of threads.
Definition cong-class.hpp:665
size_t number_of_runners() const noexcept
Get the number of runners.
Definition cong-class.hpp:701
#define LIBSEMIGROUPS_EXCEPTION(...)
Throw a LibsemigroupsException.
Definition exception.hpp:99
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