libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
InversePresentation< Word >
template<typename Word>
class libsemigroups::InversePresentation< Word >

Defined in presentation.hpp.

This class template can be used to construction inverse presentations for semigroups or monoids and is intended to be used as the input to other algorithms in libsemigroups. This class inherits from Presentation<Word>.

Template Parameters
Wordthe type of the underlying words.
Inheritance diagram for InversePresentation< Word >:
[legend]

Public Types

using const_iterator = typename Presentation<Word>::const_iterator
 Type of a const iterator to either side of a rule.
 
using iterator = typename Presentation<Word>::iterator
 Type of an iterator to either side of a rule.
 
using letter_type = typename Presentation<Word>::letter_type
 Type of the letters in the words that constitute the rules of an InversePresentation object.
 
using size_type = typename Presentation<Word>::size_type
 Size type for rules.
 
using word_type = typename Presentation<Word>::word_type
 Type of the words in the rules of an InversePresentation object.
 
- Public Types inherited from Presentation< Word >
using const_iterator = typename std::vector<word_type>::const_iterator
 Type of a const iterator to either side of a rule.
 
using iterator = typename std::vector<word_type>::iterator
 Type of an iterator to either side of a rule.
 
using letter_type = typename word_type::value_type
 Type of the letters in the words that constitute the rules of a Presentation object.
 
using size_type = typename std::vector<word_type>::size_type
 Size type for rules.
 
using word_type = Word
 Type of the words in the rules of a Presentation object.
 

Public Member Functions

 InversePresentation (Presentation< Word > &&p)
 Construct an InversePresentation from a Presentation rvalue reference.
 
 InversePresentation (Presentation< Word > const &p)
 Construct an InversePresentation from a Presentation reference.
 
letter_type inverse (letter_type x) const
 Return the inverse of a letter in the alphabet.
 
word_type const & inverses () const noexcept
 Return the inverse of each letter in the alphabet.
 
InversePresentationinverses (word_type const &w)
 Set the inverse of each letter in the alphabet.
 
InversePresentationinverses_no_checks (word_type const &w)
 Set the inverse of each letter in the alphabet.
 
void throw_if_bad_alphabet_rules_or_inverses () const
 Check if the InversePresentation is valid.
 
- Public Member Functions inherited from Presentation< Word >
 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>
Presentationadd_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>
Presentationadd_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.
 
Presentationalphabet (size_type n)
 Set the alphabet by size.
 
Presentationalphabet (word_type &&lphbt)
 Set the alphabet from rvalue reference.
 
Presentationalphabet (word_type const &lphbt)
 Set the alphabet const reference.
 
Presentationalphabet_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.
 
Presentationcontains_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.
 
Presentationinit ()
 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.
 
Presentationoperator= (Presentation &&)
 Default move assignment operator.
 
Presentationoperator= (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.
 

Constructor & Destructor Documentation

◆ InversePresentation() [1/2]

template<typename Word>
InversePresentation ( Presentation< Word > const & p)
inlineexplicit

Construct an InversePresentation, initially with empty inverses, from a reference to a Presentation.

Template Parameters
Wordthe type of the words in the presentation.
Parameters
pa reference to the Presentation to construct from.

◆ InversePresentation() [2/2]

template<typename Word>
InversePresentation ( Presentation< Word > && p)
inlineexplicit

Construct an InversePresentation, initially with empty inverses, from a Presentation rvalue reference

Template Parameters
Wordthe type of the words in the presentation.
Parameters
pan rvalue reference to the Presentation to construct from.

Member Function Documentation

◆ inverse()

template<typename Word>
letter_type inverse ( letter_type x) const

Returns the inverse of the letter x.

Parameters
xthe letter whose index is sought.
Returns
A value of type letter_type.
Exceptions
LibsemigroupsExceptionif no inverses have been set, or if index(letter_type x) const throws.

◆ inverses() [1/2]

template<typename Word>
word_type const & inverses ( ) const
inlinenoexcept

Returns the inverse of each letter in the alphabet.

Returns
A value of type word_type.
Exceptions
This function is noexcept and is guaranteed never to throw.

◆ inverses() [2/2]

template<typename Word>
InversePresentation & inverses ( word_type const & w)
inline

Set the inverse of each letter in the alphabet.

Parameters
wa word containing the inverses.
Returns
A reference to this.
Exceptions
LibsemigroupsExceptionif:
  • the alphabet contains duplicate letters
  • the inverses do not act as semigroup inverses
Note
Whilst the alphabet is not specified as an argument to this function, it is necessary to throw_if_bad_alphabet_or_rules the alphabet here; a specification of inverses cannot make sense if the alphabet contains duplicate letters.
See also

◆ inverses_no_checks()

template<typename Word>
InversePresentation & inverses_no_checks ( word_type const & w)

Set the inverse of each letter in the alphabet.

Parameters
wa word containing the inverses.
Returns
A reference to this.
Exceptions
This function guarantees not to throw a LibsemigroupsException.
Warning
This function does no checks on its argument. In particular, it does not check that the letters in w belong to the alphabet, nor does it add new letters to the alphabet.

◆ throw_if_bad_alphabet_rules_or_inverses()

template<typename Word>
void throw_if_bad_alphabet_rules_or_inverses ( ) const
inline

Check if the InversePresentation is valid. Specifically, check that the alphabet does not contain duplicate letters, that all rules only contain letters defined in the alphabet, and that the inverses act as semigroup inverses.

Exceptions
LibsemigroupsExceptionif:
  • the alphabet contains duplicate letters
  • the rules contain letters not defined in the alphabet
  • the inverses do not act as semigroup inverses
See also

The documentation for this class was generated from the following file: