22#ifndef LIBSEMIGROUPS_KNUTH_BENDIX_CLASS_HPP_
23#define LIBSEMIGROUPS_KNUTH_BENDIX_CLASS_HPP_
29#include "presentation.hpp"
31#include "detail/cong-common-class.hpp"
32#include "detail/knuth-bendix-impl.hpp"
33#include "detail/rewriters.hpp"
86 template <
typename Word,
87 typename Rewriter = detail::RewriteTrie,
89 class KnuthBendix :
public detail::KnuthBendixImpl<Rewriter, ReductionOrder> {
91 using KnuthBendixImpl_ = detail::KnuthBendixImpl<Rewriter, ReductionOrder>;
93 std::vector<Word> _generating_pairs;
97#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
160 _generating_pairs.clear();
161 _presentation.
init();
162 KnuthBendixImpl_::init();
264 template <
typename Iterator1,
typename Iterator2>
266 Iterator2 last)
const {
267 presentation().throw_if_letter_not_in_alphabet(first, last);
270#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
317 return _generating_pairs;
337 return _presentation;
360 template <
typename Iterator1,
383 template <
typename Iterator1,
393 return detail::CongruenceCommon::add_generating_pair<KnuthBendix>(
394 first1, last1, first2, last2);
422 template <
typename Iterator1,
429 Iterator4 last2)
const {
432 return detail::CongruenceCommon::currently_contains<KnuthBendix>(
433 first1, last1, first2, last2);
453 template <
typename Iterator1,
488 template <
typename OutputIterator,
489 typename InputIterator1,
490 typename InputIterator2>
492 InputIterator1 first,
493 InputIterator2 last)
const {
496 return detail::CongruenceCommon::reduce_no_run<KnuthBendix>(
497 d_first, first, last);
520 template <
typename OutputIterator,
521 typename InputIterator1,
522 typename InputIterator2>
523 OutputIterator
reduce(OutputIterator d_first,
524 InputIterator1 first,
525 InputIterator2 last) {
528 return detail::CongruenceCommon::reduce<KnuthBendix>(
529 d_first, first, last);
570 template <
typename Word>
582 template <
typename Word>
593 template <
typename Word>
604 template <
typename Word>
609#include "knuth-bendix-class.tpp"
For an implementation of presentations for semigroups or monoids.
Definition presentation.hpp:102
auto active_rules()
Return a range object containing the active rules.
KnuthBendix(congruence_kind, Presentation< Word > const &) -> KnuthBendix< Word >
Deduction guide.
KnuthBendix & operator=(KnuthBendix const &)
Copy assignment operator.
KnuthBendix & init()
Remove the presentation and rewriter data.
Definition knuth-bendix-class.hpp:159
void throw_if_letter_not_in_alphabet(Iterator1 first, Iterator2 last) const
Throws if any letter in a range is out of bounds.
Definition knuth-bendix-class.hpp:265
KnuthBendix()
Default constructor.
KnuthBendix & add_generating_pair_no_checks(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Add generating pair via iterators.
KnuthBendix & add_generating_pair(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Add generating pair via iterators.
Definition knuth-bendix-class.hpp:387
tril currently_contains(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2) const
Check containment of a pair of words via iterators.
Definition knuth-bendix-class.hpp:426
OutputIterator reduce(OutputIterator d_first, InputIterator1 first, InputIterator2 last)
Reduce a word.
Definition knuth-bendix-class.hpp:523
size_t number_of_generating_pairs() const noexcept
std::vector< Word > const & generating_pairs() const noexcept
Get the generating pairs of the congruence (if any).
Definition knuth-bendix-class.hpp:316
bool contains(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2)
Check containment of a pair of words via iterators.
congruence_kind kind() const noexcept
The kind of the congruence (1- or 2-sided).
Presentation< Word > const & presentation() const noexcept
Return the presentation used to construct or initialize a KnuthBendix object.
Definition knuth-bendix-class.hpp:336
OutputIterator reduce_no_run(OutputIterator d_first, InputIterator1 first, InputIterator2 last) const
Reduce a word with no enumeration.
Definition knuth-bendix-class.hpp:491
std::pair< Word, Word > rule_type
Type of the rules in the system.
Definition knuth-bendix-class.hpp:138
Word native_word_type
Type of the letters in the relations of the presentation stored in a KnuthBendix instance.
Definition knuth-bendix-class.hpp:131
Presentation(Presentation< Word > const &) -> Presentation< Word >
Deduction guide.
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
Struct containing various options that can be used to control the behaviour of Knuth-Bendix.
Definition knuth-bendix-class.hpp:104
overlap
Values for specifying how to measure the length of an overlap.
Definition knuth-bendix-class.hpp:113
@ MAX_AB_BC
Definition knuth-bendix-class.hpp:119
@ AB_BC
Definition knuth-bendix-class.hpp:117
@ ABC
Definition knuth-bendix-class.hpp:115
A stateless struct with binary call operator using shortlex_compare.
Definition order.hpp:356