template<typename Word>
class libsemigroups::Presentation< Word >
Defined in presentation.hpp
.
This class template can be used to construction presentations for semigroups or monoids and is intended to be used as the input to other algorithms in libsemigroups
. The idea is to provide a shallow wrapper around a vector of words of type Word
. We refer to this vector of words as the rules of the presentation. In addition to the rules, a Presentation object has an alphabet.
In a valid presentation, rules will only consist of letters from within the alphabet; however, for performance reasons, it is possible to update both the rules and the alphabet independently of each other. For this reason, it is possible for the alphabet and the rules to become out of sync. The Presentation class provides some checks that the rules define a valid presentation, and some related functionality is available in the namespace libsemigroups::presentation
.
- Template Parameters
-
Word | the type of the underlying words. |
|
| Presentation () |
| Default constructor.
|
|
| Presentation (Presentation &&) |
| Default move constructor.
|
|
| Presentation (Presentation const &) |
| Default copy constructor.
|
|
letter_type | add_generator () |
| Add a generator.
|
|
void | add_generator (letter_type x) |
| Add x as a generator.
|
|
void | add_generator_no_checks (letter_type x) |
| Add x as a generator.
|
|
template<typename Iterator1, typename Iterator2> |
Presentation & | add_rule (Iterator1 lhs_begin, Iterator1 lhs_end, Iterator2 rhs_begin, Iterator2 rhs_end) |
| Add a rule to the presentation and check it is valid.
|
|
template<typename Iterator1, typename Iterator2> |
Presentation & | add_rule_no_checks (Iterator1 lhs_begin, Iterator1 lhs_end, Iterator2 rhs_begin, Iterator2 rhs_end) |
| Add a rule to the presentation.
|
|
word_type const & | alphabet () const noexcept |
| Return the alphabet of the presentation.
|
|
Presentation & | alphabet (size_type n) |
| Set the alphabet by size.
|
|
Presentation & | alphabet (word_type &&lphbt) |
| Set the alphabet from rvalue reference.
|
|
Presentation & | alphabet (word_type const &lphbt) |
| Set the alphabet const reference.
|
|
Presentation & | alphabet_from_rules () |
| Set the alphabet to be the letters in the rules.
|
|
bool | contains_empty_word () const noexcept |
| Return whether the empty word is a valid relation word.
|
|
Presentation & | contains_empty_word (bool val) noexcept |
| Set whether whether the empty word is a valid relation word.
|
|
bool | in_alphabet (letter_type val) const |
| Check if a letter belongs to the alphabet or not.
|
|
size_type | index (letter_type val) const |
| Return the index of a letter in the alphabet.
|
|
size_type | index_no_checks (letter_type val) const |
| Return the index of a letter in the alphabet.
|
|
Presentation & | init () |
| Remove the alphabet and all rules.
|
|
letter_type | letter (size_type i) const |
| Return a letter in the alphabet by index.
|
|
letter_type | letter_no_checks (size_type i) const |
| Return a letter in the alphabet by index.
|
|
Presentation & | operator= (Presentation &&) |
| Default move assignment operator.
|
|
Presentation & | operator= (Presentation const &) |
| Default copy assignment operator.
|
|
void | remove_generator (letter_type x) |
| Remove x as a generator.
|
|
void | remove_generator_no_checks (letter_type x) |
| Remove x as a generator.
|
|
void | throw_if_alphabet_has_duplicates () const |
| Check if the alphabet is valid.
|
|
void | throw_if_bad_alphabet_or_rules () const |
| Check if the alphabet and rules are valid.
|
|
void | throw_if_bad_rules () const |
| Check if every word in every rule consists only of letters belonging to the alphabet.
|
|
template<typename Iterator1, typename Iterator2> |
void | throw_if_letter_not_in_alphabet (Iterator1 first, Iterator2 last) const |
| Check if every letter in a range belongs to the alphabet.
|
|
void | throw_if_letter_not_in_alphabet (letter_type c) const |
| Check if a letter belongs to the alphabet or not.
|
|
template<typename Word>
template<typename Iterator1, typename Iterator2>
Presentation & add_rule_no_checks |
( |
Iterator1 | lhs_begin, |
|
|
Iterator1 | lhs_end, |
|
|
Iterator2 | rhs_begin, |
|
|
Iterator2 | rhs_end ) |
|
inline |
Adds the rule with left-hand side [lhs_begin, lhs_end)
and right-hand side [rhs_begin, rhs_end)
to the rules. It is possible to add rules directly via the data member rules, this function just exists to encourage adding rules with both sides defined at the same time.
- Template Parameters
-
Iterator1 | the type of the first two parameters (iterators, or pointers). |
Iterator2 | the type of the second two parameters (iterators, or pointers). |
- Parameters
-
lhs_begin | an iterator pointing to the first letter of the left-hand side of the rule to be added. |
lhs_end | an iterator pointing one past the last letter of the left-hand side of the rule to be added. |
rhs_begin | an iterator pointing to the first letter of the right-hand side of the rule to be added. |
rhs_end | an iterator pointing one past the last letter of the right-hand side of the rule to be added. |
- Returns
- A const reference to
*this
.
- Exceptions
- This function guarantees not to throw a LibsemigroupsException.
- Complexity
- Amortized constant.
- Warning
- It is not checked that the arguments describe words over the alphabet of the presentation.
- See also
-
template<typename Word>
bool contains_empty_word |
( |
| ) |
const |
|
inlinenodiscardnoexcept |
Returns true
if the empty word is a valid relation word, and false
if the empty word is not a valid relation word.
If the presentation is not allowed to contain the empty word (according to this function), the presentation may still be isomorphic to a monoid, but is not given as a quotient of a free monoid.
- Returns
- A value of type
bool
.
- Exceptions
- This function is
noexcept
and is guaranteed never to throw.
- Complexity
- Constant.
Specify whether the empty word should be a valid relation word (corresponding to val
being true
), or not (corresponding to val
being false
).
If the presentation is not allowed to contain the empty word (according to the value specified here), the presentation may still be isomorphic to a monoid, but is not given as a quotient of a free monoid.
- Parameters
-
val | whether the presentation can contain the empty word. |
- Returns
- A const reference to
*this
.
- Exceptions
- This function is
noexcept
and is guaranteed never to throw.
- Complexity
- Constant.