libsemigroups  v3.1.2
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
Constructors + initializers

This page documents the constructors and initialisers for the KnuthBendix class.

Every constructor (except the move + copy constructors, and the move and copy assignment operators) has a matching init function with the same signature that can be used to re-initialize a KnuthBendix instance as if it had just been constructed; but without necessarily releasing any previous allocated memory.

Functions

 KnuthBendix ()
 Default constructor.
 
 KnuthBendix (congruence_kind knd, Presentation< Word > const &p)
 Construct from congruence_kind and Presentation.
 
 KnuthBendix (KnuthBendix &&)
 Move constructor.
 
 KnuthBendix (KnuthBendix const &that)
 Copy constructor.
 
KnuthBendixinit ()
 Remove the presentation and rewriter data.
 
KnuthBendixinit (congruence_kind knd, Presentation< Word > const &p)
 Re-initialize a KnuthBendix instance.
 
KnuthBendixoperator= (KnuthBendix &&)
 Move assignment operator.
 
KnuthBendixoperator= (KnuthBendix const &)
 Copy assignment operator.
 
template<typename Iterator1, typename Iterator2>
void throw_if_letter_not_in_alphabet (Iterator1 first, Iterator2 last) const
 Throws if any letter in a range is out of bounds.
 

Function Documentation

◆ KnuthBendix() [1/4]

template<typename Word, typename Rewriter = detail::RewriteTrie, typename ReductionOrder = ShortLexCompare>
KnuthBendix ( )

This function default constructs an uninitialised KnuthBendix instance.

◆ KnuthBendix() [2/4]

template<typename Word, typename Rewriter = detail::RewriteTrie, typename ReductionOrder = ShortLexCompare>
KnuthBendix ( congruence_kind knd,
Presentation< Word > const & p )
inline

This function constructs a KnuthBendix instance representing a congruence of kind knd over the semigroup or monoid defined by the presentation p.

Parameters
kndthe kind (onesided or twosided) of the congruence.
pthe presentation.
Exceptions
LibsemigroupsExceptionif p is not valid.
LibsemigroupsExceptionif p has too many letters in its alphabet, see the warning below.
Warning
At present it is only possible to create KnuthBendix objects from presentations with alphabets containing at most:
  • 128 letters if char is a signed integer;
  • 256 letters if char is an unsigned integer.

◆ KnuthBendix() [3/4]

template<typename Word, typename Rewriter = detail::RewriteTrie, typename ReductionOrder = ShortLexCompare>
KnuthBendix ( KnuthBendix< Word, Rewriter, ReductionOrder > && )

Move constructor.

◆ KnuthBendix() [4/4]

template<typename Word, typename Rewriter = detail::RewriteTrie, typename ReductionOrder = ShortLexCompare>
KnuthBendix ( KnuthBendix< Word, Rewriter, ReductionOrder > const & that)

Copy constructor.

Parameters
thatthe KnuthBendix instance to copy.
Complexity
\(O(n)\) where \(n\) is the sum of the lengths of the words in rules of that.

◆ init() [1/2]

template<typename Word, typename Rewriter = detail::RewriteTrie, typename ReductionOrder = ShortLexCompare>
KnuthBendix & init ( )
inline

This function clears the rewriter, presentation, settings and stats from the KnuthBendix object, putting it back into the state it would be in if it was newly default constructed.

Returns
A reference to this.

◆ init() [2/2]

template<typename Word, typename Rewriter = detail::RewriteTrie, typename ReductionOrder = ShortLexCompare>
KnuthBendix & init ( congruence_kind knd,
Presentation< Word > const & p )
inline

This function puts a KnuthBendix instance back into the state that it would have been in if it had just been newly constructed from knd and p.

Parameters
kndthe kind (onesided or twosided) of the congruence.
pthe presentation.
Returns
A reference to *this.
Exceptions
LibsemigroupsExceptionif p is not valid.
LibsemigroupsExceptionif p has too many letters in its alphabet, see the warning below.
Warning
At present it is only possible to create KnuthBendix objects from presentations with alphabets containing at most:
  • 128 letters if char a signed integer;
  • 256 letters if char is an unsigned integer.

◆ operator=() [1/2]

template<typename Word, typename Rewriter = detail::RewriteTrie, typename ReductionOrder = ShortLexCompare>
KnuthBendix & operator= ( KnuthBendix< Word, Rewriter, ReductionOrder > && )

Move assignment operator.

◆ operator=() [2/2]

template<typename Word, typename Rewriter = detail::RewriteTrie, typename ReductionOrder = ShortLexCompare>
KnuthBendix & operator= ( KnuthBendix< Word, Rewriter, ReductionOrder > const & )

Copy assignment operator.

◆ throw_if_letter_not_in_alphabet()

template<typename Word, typename Rewriter = detail::RewriteTrie, typename ReductionOrder = ShortLexCompare>
template<typename Iterator1, typename Iterator2>
void throw_if_letter_not_in_alphabet ( Iterator1 first,
Iterator2 last ) const

This function throws a LibsemigroupsException if any value pointed at by an iterator in the range first to last is out of bounds (i.e. does not belong to the alphabet of the presentation used to construct the KnuthBendix instance, see the warning below).

Template Parameters
Iterator1the type of first argument first.
Iterator2the type of second argument last.
Parameters
firstiterator pointing at the first letter of the word.
lastiterator pointing one beyond the last letter of the word.
Exceptions
LibsemigroupsExceptionif any letter in the range from first to last is out of bounds.
Warning
If a KnuthBendix instance represents a 1-sided congruence (kind) and there are any generating pairs (number_of_generating_pairs > 0), then the alphabet of the presentation will contain one more letter than the original input alphabet. This extra letter cannot be used in the input of any function, and is required for the algorithm to work in this case, and is present in the output of, for example, active_rules.