22#ifndef LIBSEMIGROUPS_CONG_CLASS_HPP_
23#define LIBSEMIGROUPS_CONG_CLASS_HPP_
33#include "knuth-bendix-class.hpp"
34#include "presentation.hpp"
37#include "detail/cong-common-class.hpp"
38#include "detail/race.hpp"
43 template <
typename Node>
46 template <
typename Word>
50 struct CongruenceBase {};
158 template <
typename Word>
159 class Congruence :
public detail::CongruenceCommon,
160 public detail::CongruenceBase {
161 enum class RunnerKind :
size_t { TC = 0, KB = 1, K = 2 };
167 mutable detail::Race _race;
168 mutable bool _runners_initted;
169 std::vector<RunnerKind> _runner_kinds;
295 template <
typename Iterator1,
303 _runners_initted =
false;
304 return detail::CongruenceCommon::add_internal_generating_pair_no_checks<
322 template <
typename Iterator1,
330 _runners_initted =
false;
331 return detail::CongruenceCommon::add_generating_pair<Congruence>(
332 first1, last1, first2, last2);
377 template <
typename Iterator1,
384 Iterator4 last2)
const;
404 template <
typename Iterator1,
411 Iterator4 last2)
const {
412 return detail::CongruenceCommon::currently_contains<Congruence>(
413 first1, last1, first2, last2);
437 template <
typename Iterator1,
445 return detail::CongruenceCommon::contains_no_checks<Congruence>(
446 first1, last1, first2, last2);
466 template <
typename Iterator1,
474 return detail::CongruenceCommon::contains<Congruence>(
475 first1, last1, first2, last2);
499 template <
typename OutputIterator,
typename Iterator1,
typename Iterator2>
502 Iterator2 last)
const;
521 template <
typename OutputIterator,
typename Iterator1,
typename Iterator2>
524 Iterator2 last)
const {
525 return detail::CongruenceCommon::reduce_no_run<Congruence>(
526 d_first, first, last);
544 template <
typename OutputIterator,
545 typename InputIterator1,
546 typename InputIterator2>
548 InputIterator1 first,
549 InputIterator2 last) {
550 return detail::CongruenceCommon::reduce_no_checks<Congruence>(
551 d_first, first, last);
569 template <
typename OutputIterator,
570 typename InputIterator1,
571 typename InputIterator2>
572 OutputIterator
reduce(OutputIterator d_first,
573 InputIterator1 first,
574 InputIterator2 last) {
575 return detail::CongruenceCommon::reduce<Congruence>(d_first, first, last);
599 template <
typename Iterator1,
typename Iterator2>
624 template <
typename Thing>
646 template <
typename Thing>
647 [[nodiscard]]
bool has()
const;
665 return _race.max_threads();
685 _race.max_threads(val);
701 return _race.number_of_runners();
731#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
773 _runner_kinds.push_back(RunnerKind::TC);
786 template <
typename Result,
typename Node>
788 FroidurePinBase& fpb,
789 WordGraph<Node>
const& wg)
791 std::is_same_v<Congruence<typename Result::native_word_type>,
795 void init_runners()
const;
801 void run_impl()
override;
802 bool finished_impl()
const override {
803 return _race.finished();
815 template <
typename Word>
828 template <
typename Word>
839 template <
typename Word>
850 template <
typename Word>
868 template <
typename Word>
872#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:253
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:547
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:441
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:408
Congruence & add_generating_pair(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Add generating pair via iterators.
Definition cong-class.hpp:326
OutputIterator reduce(OutputIterator d_first, InputIterator1 first, InputIterator2 last)
Reduce a word.
Definition cong-class.hpp:572
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:299
bool contains(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Check containment of a pair of words via iterators.
Definition cong-class.hpp:470
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:522
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:183
Congruence & max_threads(size_t val) noexcept
Set the maximum number of threads.
Definition cong-class.hpp:684
size_t max_threads() const noexcept
Get the current maximum number of threads.
Definition cong-class.hpp:664
size_t number_of_runners() const noexcept
Get the number of runners.
Definition cong-class.hpp:700
tril
Enum to indicate true, false or not currently knowable.
Definition types.hpp:56
congruence_kind
Enum to indicate the sided-ness of a congruence.
Definition types.hpp:69
Namespace for everything in the libsemigroups library.
Definition action.hpp:44