libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
to<Presentation>

This file contains documentation for creating semigroup and monoid presentations in libsemigroups from other types of objects.

See also
The `to` function for an overview of possible conversions between libsemigroups types.

Functions

template<typename Result>
auto to (FroidurePinBase &fp) -> std::enable_if_t< std::is_same_v< Presentation< typename Result::word_type >, Result >, Result >
 Make a presentation from a FroidurePin object.
 
template<template< typename... > typename Thing, typename Word, typename Rewriter, typename ReductionOrder>
auto to (KnuthBendix< Word, Rewriter, ReductionOrder > &kb) -> std::enable_if_t< std::is_same_v< Thing< Word >, Presentation< Word > >, Presentation< Word > >
 Make a presentation from a KnuthBendix object.
 
template<typename Result, typename Word>
auto to (Presentation< Word > const &p) -> std::enable_if_t< std::is_same_v< Presentation< typename Result::word_type >, Result > &&!std::is_same_v< typename Result::word_type, Word >, Result >
 Make a presentation from a different type of presentation.
 
template<typename Result, typename Word, typename Func>
auto to (Presentation< Word > const &p, Func &&f) -> std::enable_if_t< std::is_same_v< Presentation< typename Result::word_type >, Result >, Result >
 Make a presentation from a different type of presentation.
 

Function Documentation

◆ to() [1/4]

template<typename Result>
auto to ( FroidurePinBase & fp) -> std::enable_if_t< std::is_same_v< Presentation< typename Result::word_type >, Result >, Result >

Defined in to-presentation.hpp.

Despite the hideous signature, this function should be invoked as follows:

auto to(detail::KnuthBendixImpl< Rewriter, ReductionOrder > &kb) -> std::enable_if_t< std::is_same_v< Presentation< typename Result::word_type >, Result >, Result >
No doc.

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
Resultthe return type, also used for SFINAE, should be Presentation<Word> for some type Word.
Parameters
fpthe FroidurePin object from which to obtain the rules.
Returns
An object of type Presentation<Word>.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ to() [2/4]

template<template< typename... > typename Thing, typename Word, typename Rewriter, typename ReductionOrder>
auto to ( KnuthBendix< Word, Rewriter, ReductionOrder > & kb) -> std::enable_if_t<std::is_same_v<Thing<Word>, Presentation<Word>>, Presentation<Word>>

Defined in to-presentation.hpp.

Despite the hideous signature, this function should be invoked as follows:

This function constructs and returns a Presentation object using the currently active rules of kb.

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

Template Parameters
Thingused for SFINAE, must be Presentation.
Wordthe type of the rules in the presentation of the KnuthBendix object kb.
Rewriterthe second template parameter for KnuthBendix.
ReductionOrderthe third template parameter for KnuthBendix. constructed.
Parameters
kbthe KnuthBendix object from which to obtain the rules.
Returns
An object of type Presentation<Word>.
Exceptions
This function guarantees not to throw a LibsemigroupsException.

◆ to() [3/4]

template<typename Result, typename Word>
auto to ( Presentation< Word > const & p) -> std::enable_if_t< std::is_same_v<Presentation<typename Result::word_type>, Result> && !std::is_same_v<typename Result::word_type, Word>, Result>
noexcept

Defined in to-presentation.hpp.

Despite the hideous signature, this function should be invoked as follows:

There are 2 versions of this function:

  1. When typename Result::word_type and Word are not the same, this function 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).
  2. When typename Result::word_type and Word are the same, this function just returns its argument p (as a reference), and is included solely for the purpose of simplifying certain client code, where presentations must be converted from one type to another sometimes, but not other times.

If the alphabet of of p is \(\{a_0, a_1, \dots a_{n-1}\}\), then the conversion from Presentation<WordInput>::letter_type to Presentation<WordOutput>::letter_type is \(a_i \mapsto\) human_readable_letter<WordOutput>(size_t i).

Template Parameters
Resultthe return type, also used for SFINAE, should be Presentation<T> for some type T.
Wordthe type of the words in the input presentation.
Parameters
pthe input presentation.
Returns
A value of type Result.
Exceptions
LibsemigroupsExceptionif typename Result::word_type and Word are not the same and p.throw_if_bad_alphabet_or_rules() throws. If typename Result::word_type and Word are the same, then this function is noexcept.

◆ to() [4/4]

template<typename Result, typename Word, typename Func>
auto to ( Presentation< Word > const & p,
Func && f ) -> std::enable_if_t< std::is_same_v< Presentation< typename Result::word_type >, Result >, Result >

Defined in to-presentation.hpp.

Despite the hideous signature, this function should be invoked as follows:

This function 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
Resultthe return type, also used for SFINAE, should be Presentation<T> for some type T.
Wordthe type of the words in the input presentation.
Functhe type of a function for transforming letters.
Parameters
pthe input presentation.
fa function mapping Presentation<Word>::letter_type to Result::letter_type.
Returns
A value of type Result.
Exceptions
LibsemigroupsExceptionif p.throw_if_bad_alphabet_or_rules() throws.
Note
Func must be a function type that is invocable with values of Presentation<Word>::letter_type. If this is not true, then template substitution will fail.