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>
48 struct CongruenceBase {};
156 template <
typename Word>
157 class Congruence :
public detail::CongruenceCommon,
158 public detail::CongruenceBase {
159 enum class RunnerKind :
size_t { TC = 0, KB = 1, K = 2 };
165 mutable detail::Race _race;
166 mutable bool _runners_initted;
167 std::vector<RunnerKind> _runner_kinds;
293 template <
typename Iterator1,
301 _runners_initted =
false;
302 return detail::CongruenceCommon::add_internal_generating_pair_no_checks<
320 template <
typename Iterator1,
328 _runners_initted =
false;
329 return detail::CongruenceCommon::add_generating_pair<Congruence>(
330 first1, last1, first2, last2);
375 template <
typename Iterator1,
382 Iterator4 last2)
const;
402 template <
typename Iterator1,
409 Iterator4 last2)
const {
410 return detail::CongruenceCommon::currently_contains<Congruence>(
411 first1, last1, first2, last2);
435 template <
typename Iterator1,
443 return detail::CongruenceCommon::contains_no_checks<Congruence>(
444 first1, last1, first2, last2);
464 template <
typename Iterator1,
472 return detail::CongruenceCommon::contains<Congruence>(
473 first1, last1, first2, last2);
497 template <
typename OutputIterator,
typename Iterator1,
typename Iterator2>
500 Iterator2 last)
const;
519 template <
typename OutputIterator,
typename Iterator1,
typename Iterator2>
522 Iterator2 last)
const {
523 return detail::CongruenceCommon::reduce_no_run<Congruence>(
524 d_first, first, last);
542 template <
typename OutputIterator,
543 typename InputIterator1,
544 typename InputIterator2>
546 InputIterator1 first,
547 InputIterator2 last) {
548 return detail::CongruenceCommon::reduce_no_checks<Congruence>(
549 d_first, first, last);
567 template <
typename OutputIterator,
568 typename InputIterator1,
569 typename InputIterator2>
570 OutputIterator
reduce(OutputIterator d_first,
571 InputIterator1 first,
572 InputIterator2 last) {
573 return detail::CongruenceCommon::reduce<Congruence>(d_first, first, last);
597 template <
typename Iterator1,
typename Iterator2>
622 template <
typename Thing>
644 template <
typename Thing>
645 [[nodiscard]]
bool has()
const;
663 return _race.max_threads();
683 _race.max_threads(val);
699 return _race.number_of_runners();
729#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
771 _runner_kinds.push_back(RunnerKind::TC);
784 template <
typename Result,
typename Node>
786 FroidurePinBase& fpb,
787 WordGraph<Node>
const& wg)
789 std::is_same_v<Congruence<typename Result::native_word_type>,
793 void init_runners()
const;
799 void run_impl()
override;
800 bool finished_impl()
const override {
801 return _race.finished();
813 template <
typename Word>
826 template <
typename Word>
837 template <
typename Word>
848 template <
typename Word>
866 template <
typename Word>
870#include "cong-class.tpp"
Base class for FroidurePin containing non-element specific data and member functions.
Definition froidure-pin-base.hpp:66
For an implementation of presentations for semigroups or monoids.
Definition presentation.hpp:102
Class for representing word graphs.
Definition word-graph.hpp:82
std::string to_human_readable_repr(AhoCorasick const &ac)
Return a string representation.
std::shared_ptr< Thing > get() const
Get a derived class of detail::CongruenceCommon being used to compute a Congruence instance.
bool has() const
Check if a derived class of detail::CongruenceCommon being used to compute a Congruence instance.
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:251
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:545
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:439
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:406
Congruence & add_generating_pair(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Add generating pair via iterators.
Definition cong-class.hpp:324
OutputIterator reduce(OutputIterator d_first, InputIterator1 first, InputIterator2 last)
Reduce a word.
Definition cong-class.hpp:570
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:297
bool contains(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Check containment of a pair of words via iterators.
Definition cong-class.hpp:468
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:520
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:181
Congruence & max_threads(size_t val) noexcept
Set the maximum number of threads.
Definition cong-class.hpp:682
size_t max_threads() const noexcept
Get the current maximum number of threads.
Definition cong-class.hpp:662
size_t number_of_runners() const noexcept
Get the number of runners.
Definition cong-class.hpp:698
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