22#ifndef LIBSEMIGROUPS_KNUTH_BENDIX_CLASS_HPP_
23#define LIBSEMIGROUPS_KNUTH_BENDIX_CLASS_HPP_
30#include "presentation.hpp"
32#include "detail/citow.hpp"
33#include "detail/cong-common-class.hpp"
34#include "detail/knuth-bendix-impl.hpp"
35#include "detail/rewriters.hpp"
95 template <
typename Word,
96 typename Rewriter = detail::RewriteTrie,
98 class KnuthBendix :
public detail::KnuthBendixImpl<Rewriter, ReductionOrder> {
100 using KnuthBendixImpl_ = detail::KnuthBendixImpl<Rewriter, ReductionOrder>;
102 bool _extra_letter_added;
103 std::vector<Word> _generating_pairs;
107 friend class ::libsemigroups::detail::KBE<KnuthBendix>;
110#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
173 _extra_letter_added =
false;
174 _generating_pairs.clear();
175 _presentation.
init();
176 KnuthBendixImpl_::init();
300 template <
typename Iterator1,
typename Iterator2>
303#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
350 return _generating_pairs;
378 return _presentation;
402 template <
typename Iterator1,
426 template <
typename Iterator1,
442 template <
typename Iterator1,
446 tril currently_contains_no_checks(Iterator1 first1,
449 Iterator4 last2)
const {
451 detail::citow(
this, first1),
452 detail::citow(
this, last1),
453 detail::citow(
this, first2),
454 detail::citow(
this, last2));
477 template <
typename Iterator1,
484 Iterator4 last2)
const {
487 return detail::CongruenceCommon::currently_contains<KnuthBendix>(
488 first1, last1, first2, last2);
509 template <
typename Iterator1,
542 template <
typename OutputIterator,
543 typename InputIterator1,
544 typename InputIterator2>
546 InputIterator1 first,
547 InputIterator2 last)
const {
548 return KnuthBendixImpl_::reduce_no_run_no_checks(
549 detail::itow(
this, d_first),
550 detail::citow(
this, first),
551 detail::citow(
this, last))
576 template <
typename OutputIterator,
577 typename InputIterator1,
578 typename InputIterator2>
580 InputIterator1 first,
581 InputIterator2 last) {
582 return KnuthBendixImpl_::reduce_no_checks(detail::itow(
this, d_first),
583 detail::citow(
this, first),
584 detail::citow(
this, last))
608 template <
typename OutputIterator,
609 typename InputIterator1,
610 typename InputIterator2>
612 InputIterator1 first,
613 InputIterator2 last)
const {
616 return detail::CongruenceCommon::reduce_no_run<KnuthBendix>(
617 d_first, first, last);
642 template <
typename OutputIterator,
643 typename InputIterator1,
644 typename InputIterator2>
645 OutputIterator
reduce(OutputIterator d_first,
646 InputIterator1 first,
647 InputIterator2 last) {
650 return detail::CongruenceCommon::reduce<KnuthBendix>(
651 d_first, first, last);
686 [[nodiscard]]
bool requires_extra_letter()
const {
700 template <
typename Word>
712 template <
typename Word>
723 template <
typename Word>
734 template <
typename Word>
739#include "knuth-bendix-class.tpp"
For an implementation of presentations for semigroups or monoids.
Definition presentation.hpp:103
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:172
void throw_if_letter_not_in_alphabet(Iterator1 first, Iterator2 last) const
Throws if any letter in a range is out of bounds.
KnuthBendix()
Default constructor.
OutputIterator reduce_no_checks(OutputIterator d_first, InputIterator1 first, InputIterator2 last)
Reduce a word with no checks.
Definition knuth-bendix-class.hpp:579
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.
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:481
OutputIterator reduce(OutputIterator d_first, InputIterator1 first, InputIterator2 last)
Reduce a word.
Definition knuth-bendix-class.hpp:645
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:349
tril currently_contains_no_checks(Iterator1 first1, Iterator2 last1, Iterator3 first2, Iterator4 last2) const
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:377
OutputIterator reduce_no_run_no_checks(OutputIterator d_first, InputIterator1 first, InputIterator2 last) const
Reduce a word with no run and no checks.
Definition knuth-bendix-class.hpp:545
OutputIterator reduce_no_run(OutputIterator d_first, InputIterator1 first, InputIterator2 last) const
Reduce a word with no enumeration.
Definition knuth-bendix-class.hpp:611
std::pair< Word, Word > rule_type
Type of the rules in the system.
Definition knuth-bendix-class.hpp:151
Word native_word_type
Type of the letters in the relations of the presentation stored in a KnuthBendix instance.
Definition knuth-bendix-class.hpp:144
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
@ onesided
Value representing a one-sided 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:117
overlap
Values for specifying how to measure the length of an overlap.
Definition knuth-bendix-class.hpp:126
@ MAX_AB_BC
Definition knuth-bendix-class.hpp:132
@ AB_BC
Definition knuth-bendix-class.hpp:130
@ ABC
Definition knuth-bendix-class.hpp:128
A stateless struct with binary call operator using shortlex_compare.
Definition order.hpp:380