# Initialization¶

Add a rule using a relation_type.

Complexity

Constant.

Parameters

rel – the rule being added.

Throws

LibsemigroupsException – if any of the following apply:

• started() returns true; or

• rel.first or rel.second contains a letter that is out of bounds.

Returns

(None)

Add a rule using a rule_type.

Complexity

Constant.

Parameters

rel – the rule being added.

Throws

LibsemigroupsException – if any of the following apply:

• started() returns true; or

• rel.first or rel.second contains a letter that is out of bounds.

Returns

(None)

inline void libsemigroups::FpSemigroupInterface::add_rule(std::initializer_list<size_t> u, std::initializer_list<size_t> v)

Add a rule using two word_type const references.

Complexity

Constant.

Parameters
• u – the left-hand side of the rule being added.

• v – the right-hand side of the rule being added.

Throws

LibsemigroupsException – if any of the following apply:

• started() returns true; or

• u or v contains a letter that is out of bounds.

Returns

(None)

inline void libsemigroups::FpSemigroupInterface::add_rule(std::string const &u, std::string const &v)

Add a rule using two std::string const references.

Complexity

Constant.

Parameters
• u – the left-hand side of the rule being added.

• v – the right-hand side of the rule being added.

Throws

LibsemigroupsException – if any of the following apply:

Returns

(None)

inline void libsemigroups::FpSemigroupInterface::add_rule(word_type const &u, word_type const &v)

Add a rule using two word_type const references.

Complexity

Constant.

Parameters
• u – the left-hand side of the rule being added.

• v – the right-hand side of the rule being added.

Throws

LibsemigroupsException – if any of the following apply:

• started() returns true; or

• u or v contains a letter that is out of bounds.

Returns

(None)

Add rules from a FroidurePin instance.

Complexity

At most $$O(|S||A|)$$ where $$A$$ is a generating set for S.

Parameters

S – a FroidurePin object representing a semigroup.

Throws

LibsemigroupsException – if any of the following apply:

Returns

(None)

Complexity

$$O(n)$$ where $$n$$ is the size of rels.

Parameters

rels – a vector of rule_type.

Throws

LibsemigroupsException – if add_rule() with argument any item in rels throws.

Returns

(None)

inline std::string const &libsemigroups::FpSemigroupInterface::alphabet() const noexcept

Returns a const reference to the alphabet.

Complexity

Constant.

Parameters

(None)

Throws

(None) – This function is noexcept and is guaranteed never to throw.

Returns

A const reference to the alphabet, a value of type std::string.

inline std::string libsemigroups::FpSemigroupInterface::alphabet(size_t i) const

Returns the ith letter of the alphabet.

Complexity

Constant.

Parameters

i – the index of the letter.

Throws

std::range_error – if the index i is out of range.

Returns

A std::string by value.

inline bool libsemigroups::FpSemigroupInterface::has_identity() const noexcept

Check if an identity has been set.

This function returns true if an identity has been set and false if it has not.

Complexity

Constant.

Parameters

(None)

Throws

(None) – This function is noexcept and is guaranteed never to throw.

Returns

A value of type bool.

std::string const &libsemigroups::FpSemigroupInterface::identity() const

Returns the identity (if any).

Complexity

Constant.

Parameters

(None)

Throws

LibsemigroupsException – if no identity has been defined.

Returns

A const reference to the identity, a value of type std::string.

std::string const &libsemigroups::FpSemigroupInterface::inverses() const

Returns the inverses (if any).

set_inverses() for the meaning of the return value of this function.

Complexity

Constant.

Parameters

(None)

Throws

LibsemigroupsException – if no identity has been defined.

Returns

A const reference to the inverses, a value of type std::string.

inline size_t libsemigroups::FpSemigroupInterface::number_of_rules() const noexcept

Returns the number of rules.

Complexity

Constant.

Parameters

(None)

Throws

(None) – This function is noexcept and is guaranteed never to throw.

Returns

A value of type size_t.

void libsemigroups::FpSemigroupInterface::set_alphabet(size_t n)

Set the size of the alphabet.

Use this to specify the alphabet of a finitely presented semigroup if you intend to use indices rather than the actual letters in the alphabet in subsequent calculations.

Complexity

Constant.

Parameters

n – the number of letters.

Throws

LibsemigroupsException – If the size of the of alphabet has already been set to another value, or the parameter n is 0.

Returns

(None)

void libsemigroups::FpSemigroupInterface::set_alphabet(std::string const &a)

Set the alphabet of the finitely presented semigroup.

Complexity

Constant.

Parameters

a – the alphabet.

Throws

LibsemigroupsException – If the alphabet has already been set to another value, the parameter a is empty, or there are repeated characters in a.

Returns

(None)

inline void libsemigroups::FpSemigroupInterface::set_identity(letter_type id)

Set a character in alphabet() to be the identity using its index.

This function adds rules to this so that id is the identity. This function can be called repeatedly.

Complexity

$$O(n)$$ where $$n$$ is alphabet().size().

Parameters

id – the index of the character to be the identity.

Throws

LibsemigroupsException – If id is out of bounds.

Returns

(None)

void libsemigroups::FpSemigroupInterface::set_identity(std::string const &id)

Set a character in alphabet() to be the identity.

This function adds rules to this so that id is the identity. This function can be called repeatedly.

Complexity

$$O(n)$$ where $$n$$ is alphabet().size().

Parameters

id – a string containing the character to be the identity.

Throws

LibsemigroupsException – If id has length greater than 1, or id contains a character that is not in alphabet().

Returns

(None)

void libsemigroups::FpSemigroupInterface::set_inverses(std::string const &a)

Set the inverses of letters in alphabet().

The letter in a with index i is the inverse of the letter in alphabet() with index i.

Complexity

$$O(n)$$ where $$n$$ is alphabet().size().

Parameters

a – a string of length alphabet().size().

Throws

LibsemigroupsException – if any of the following apply:

Returns

(None)