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"
93 template <
typename Word,
94 typename Rewriter = detail::RewriteTrie,
96 class KnuthBendix :
public detail::KnuthBendixImpl<Rewriter, ReductionOrder> {
98 using KnuthBendixImpl_ = detail::KnuthBendixImpl<Rewriter, ReductionOrder>;
100 bool _extra_letter_added;
101 std::vector<Word> _generating_pairs;
105 friend class ::libsemigroups::detail::KBE<KnuthBendix>;
108#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
171 _extra_letter_added =
false;
172 _generating_pairs.clear();
173 _presentation.
init();
174 KnuthBendixImpl_::init();
298 template <
typename Iterator1,
typename Iterator2>
301#ifdef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
348 return _generating_pairs;
376 return _presentation;
400 template <
typename Iterator1,
424 template <
typename Iterator1,
440 template <
typename Iterator1,
444 tril currently_contains_no_checks(Iterator1 first1,
447 Iterator4 last2)
const {
449 detail::citow(
this, first1),
450 detail::citow(
this, last1),
451 detail::citow(
this, first2),
452 detail::citow(
this, last2));
475 template <
typename Iterator1,
482 Iterator4 last2)
const {
485 return detail::CongruenceCommon::currently_contains<KnuthBendix>(
486 first1, last1, first2, last2);
507 template <
typename Iterator1,
540 template <
typename OutputIterator,
541 typename InputIterator1,
542 typename InputIterator2>
544 InputIterator1 first,
545 InputIterator2 last)
const {
546 return KnuthBendixImpl_::reduce_no_run_no_checks(
547 detail::itow(
this, d_first),
548 detail::citow(
this, first),
549 detail::citow(
this, last))
574 template <
typename OutputIterator,
575 typename InputIterator1,
576 typename InputIterator2>
578 InputIterator1 first,
579 InputIterator2 last) {
580 return KnuthBendixImpl_::reduce_no_checks(detail::itow(
this, d_first),
581 detail::citow(
this, first),
582 detail::citow(
this, last))
606 template <
typename OutputIterator,
607 typename InputIterator1,
608 typename InputIterator2>
610 InputIterator1 first,
611 InputIterator2 last)
const {
614 return detail::CongruenceCommon::reduce_no_run<KnuthBendix>(
615 d_first, first, last);
640 template <
typename OutputIterator,
641 typename InputIterator1,
642 typename InputIterator2>
643 OutputIterator
reduce(OutputIterator d_first,
644 InputIterator1 first,
645 InputIterator2 last) {
648 return detail::CongruenceCommon::reduce<KnuthBendix>(
649 d_first, first, last);
684 [[nodiscard]]
bool requires_extra_letter()
const {
698 template <
typename Word>
710 template <
typename Word>
721 template <
typename Word>
732 template <
typename Word>
737#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:170
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:577
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:479
OutputIterator reduce(OutputIterator d_first, InputIterator1 first, InputIterator2 last)
Reduce a word.
Definition knuth-bendix-class.hpp:643
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:347
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:375
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:543
OutputIterator reduce_no_run(OutputIterator d_first, InputIterator1 first, InputIterator2 last) const
Reduce a word with no enumeration.
Definition knuth-bendix-class.hpp:609
std::pair< Word, Word > rule_type
Type of the rules in the system.
Definition knuth-bendix-class.hpp:149
Word native_word_type
Type of the letters in the relations of the presentation stored in a KnuthBendix instance.
Definition knuth-bendix-class.hpp:142
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:115
overlap
Values for specifying how to measure the length of an overlap.
Definition knuth-bendix-class.hpp:124
@ MAX_AB_BC
Definition knuth-bendix-class.hpp:130
@ AB_BC
Definition knuth-bendix-class.hpp:128
@ ABC
Definition knuth-bendix-class.hpp:126
A stateless struct with binary call operator using shortlex_compare.
Definition order.hpp:362