Making presentations from other objects

Defined in make-present.hpp.

This page describes the functionality for creating semigroup and monoid presentations in libsemigroups from other types of objects.

template<typename T, typename = std::enable_if_t<std::is_base_of<PresentationBase, T>::value>>
T libsemigroups::make(FroidurePinBase &fp)

Make presentation from a FroidurePin object.

This function constructs and returns a Presentation object using the rules of a FroidurePin object, accessed via FroidurePin::cbegin_rules and FroidurePin::cend_rules.

No enumeration of the argument fp is performed, so it might be the case that the resulting presentation does not define the same semigroup as fp. To ensure that the resulting presentation defines the same semigroup as fp, run FroidurePin::run (or any other function that fully enumerates fp) prior to calling this function.

Template Parameters

T – the type of the presentation to construct (must be a type of Presentation).

Parameters

fp – the FroidurePin object from which to obtain the rules.

Throws

(None) – This function guarantees not to throw a LibsemigroupsException.

Returns

An object of type T.

Presentation<std::string> libsemigroups::make(FroidurePinBase &fp, std::string const &alphabet)

Make presentation with strings from a FroidurePin object.

This function constructs and returns a Presentation object using the rules of a FroidurePin object, accessed via FroidurePin::cbegin_rules and FroidurePin::cend_rules.

No enumeration of the argument fp is performed, so it might be the case that the resulting presentation does not define the same semigroup as fp. To ensure that the resulting presentation defines the same semigroup as fp, run FroidurePin::run (or any other function that fully enumerates fp) prior to calling this function.

Parameters
  • fp – the FroidurePin object from which to obtain the rules.

  • alphabet – the alphabet of the presentation to be constructed.

Throws
Returns

An object of type Presentation<std::string>.

template<typename S, typename W, typename F, typename = std::enable_if_t<std::is_base_of<PresentationBase, S>::value && !std::is_same<std::decay_t<F>, std::string>::value>>
S libsemigroups::make(Presentation<W> const &p, F &&f)

Make a presentation from a different type of presentation.

Returns a presentation equivalent to the input presentation but of a different type (for example, can be used to convert from std::string to word_type). The second parameter specifies how to map the letters of one presentation to the other.

Template Parameters
  • S – the type of the returned presentation, must be a type of Presentation

  • W – the type of the words in the input presentation

  • F – the type of a function from transforming letters

Parameters
Throws

LibsemigroupsException – if p.validate() throws.

Returns

A value of type S.

template<typename S, typename W>
S make(Presentation<W> const &p)

Make a presentation from a different type of presentation.

Returns a presentation equivalent to the input presentation but of a different type (for example, can be used to convert from std::string to word_type).

Template Parameters
  • S – the type of the returned presentation, must be a type of Presentation

  • W – the type of the words in the input presentation

Parameters

p – the input presentation

Returns

A value of type S.

Throws

LibsemigroupsException – if p.validate() throws.

template<typename S, typename W, typename = std::enable_if_t<std::is_same<Presentation<std::string>, S>::value>>
Presentation<std::string> libsemigroups::make(Presentation<W> const &p, std::string const &alphabet)

Make a string presentation from a different type of presentation.

Returns a presentation equivalent to the input presentation but of a different type (for example, can be used to convert from std::string to word_type).

The alphabet of the returned presentation is the second parameter alphabet where \(n\) is the size of the alphabet of the input presentation.

Template Parameters

W – the type of the words in the input presentation

Parameters
  • p – the input presentation

  • alphabet – the output presentations alphabet

Throws
Returns

A value of type Presentation<std::string>.