19#ifndef LIBSEMIGROUPS_FROIDURE_PIN_BASE_HPP_
20#define LIBSEMIGROUPS_FROIDURE_PIN_BASE_HPP_
25#include <initializer_list>
30#include "constants.hpp"
34#include "word-graph.hpp"
36#include "detail/containers.hpp"
67 template <
typename Element,
typename Traits>
68 friend class FroidurePin;
100#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
104 Settings() noexcept : _batch_size(8'192) {}
105 Settings(Settings
const&)
noexcept =
default;
106 Settings(Settings&&)
noexcept =
default;
107 Settings&
operator=(Settings
const&)
noexcept =
default;
108 Settings&
operator=(Settings&&)
noexcept =
default;
109 ~Settings() =
default;
122 bool _idempotents_found;
131 enumerate_index_type _pos;
134 detail::DynamicArray2<bool> _reduced;
226 return _settings._batch_size;
229#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
234 [[nodiscard]]
virtual size_t number_of_generators()
const = 0;
235 [[nodiscard]]
virtual tril is_finite()
const = 0;
274 template <
typename Iterator1,
typename Iterator2>
309 template <
typename Iterator1,
typename Iterator2>
311 Iterator2 last)
const {
346 template <
typename Iterator1,
typename Iterator2>
384 template <
typename Iterator1,
typename Iterator2>
414 LIBSEMIGROUPS_ASSERT(i < _letter_to_pos.size());
415 return _letter_to_pos[i];
466 return _length[_enumerate_order.back()];
484 [[nodiscard]]
size_t degree() const noexcept {
544 LIBSEMIGROUPS_ASSERT(pos < _prefix.size());
588 LIBSEMIGROUPS_ASSERT(pos < _suffix.size());
641 LIBSEMIGROUPS_ASSERT(pos < _first.size());
702 LIBSEMIGROUPS_ASSERT(pos < _final.size());
757 LIBSEMIGROUPS_ASSERT(pos < _length.size());
1024 template <
typename Iterator>
1053 template <
typename Iterator>
1085 template <
typename Iterator>
1123 template <
typename Iterator>
1154 template <
typename Iterator>
1225#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
1229 using difference_type =
1233 using const_reference =
1246 enumerate_index_type pos,
1253 return _gen == that._gen && _pos == that._pos;
1261 [[nodiscard]] const_reference
operator*()
const {
1262 populate_relation();
1266 [[nodiscard]] const_pointer operator->()
const {
1267 populate_relation();
1282 _current.swap(that._current);
1283 std::swap(_froidure_pin, that._froidure_pin);
1290 void populate_relation()
const;
1295 enumerate_index_type _pos;
1300 static_assert(std::is_default_constructible_v<const_rule_iterator>,
1301 "forward iterator requires default-constructible");
1302 static_assert(std::is_copy_constructible_v<const_rule_iterator>,
1303 "forward iterator requires copy-constructible");
1304 static_assert(std::is_copy_assignable_v<const_rule_iterator>,
1305 "forward iterator requires copy-assignable");
1306 static_assert(std::is_destructible_v<const_rule_iterator>,
1307 "forward iterator requires destructible");
1523#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
1526 enumerate_index_type _pos;
1550 enumerate_index_type pos)
1551 : _froidure_pin(ptr), _pos(pos), _word() {}
1555 return _pos == that._pos;
1560 return !(*
this == that);
1565 return _pos < that._pos;
1570 return _pos > that._pos;
1575 return _pos < that._pos;
1580 return _pos > that._pos;
1583 [[nodiscard]] const_reference
operator*()
const noexcept {
1588 [[nodiscard]] const_pointer operator->()
const noexcept {
1593 [[nodiscard]] const_reference operator[](
size_type index)
const {
1623 void operator+=(
size_type val)
noexcept {
1627 void operator-=(
size_type val)
noexcept {
1639 operator-(
size_type val)
const noexcept {
1645 [[nodiscard]] difference_type
1647 return _pos - that._pos;
1651 std::swap(_froidure_pin, that._froidure_pin);
1657 void populate_word()
const {
1804 template <
typename Iterator1,
typename Iterator2>
1806 Iterator2 last)
const {
1807 for (
auto it = first; it != last; ++it) {
1823 template <
typename Iterator1,
typename Iterator2>
1826 Iterator2 last)
const {
1827 if (first == last) {
1931 template <
typename Word>
1966 template <
typename Word>
2002 template <
typename Word>
2037 template <
typename Word>
2073 template <
typename Word>
2109 template <
typename Word = word_type>
2137 template <
typename Word>
2171 template <
typename Word = word_type>
2203 template <
typename Word>
2241 template <
typename Word = word_type>
2274 template <
typename Word>
2303 template <
typename Word>
2333 template <
typename Word = word_type>
2354 [[nodiscard]] rx::iterator_range<
2376 [[nodiscard]] rx::iterator_range<
2397 [[nodiscard]] rx::iterator_range<FroidurePinBase::const_rule_iterator>
2417 [[nodiscard]] rx::iterator_range<FroidurePinBase::const_rule_iterator>
T back_inserter(T... args)
Return type of cbegin_rules and cend_rules.
Definition froidure-pin-base.hpp:1224
Base class for FroidurePin containing non-element specific data and member functions.
Definition froidure-pin-base.hpp:66
size_t number_of_rules()
Returns the total number of relations in the presentation.
Definition froidure-pin-base.hpp:917
cayley_graph_type const & left_cayley_graph()
Returns a const reference to the left Cayley graph.
Definition froidure-pin-base.hpp:975
element_index_type position_no_checks(Iterator1 first, Iterator2 last)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:347
const_rule_iterator cend_rules()
Returns a forward iterator pointing one past the last rule (if any).
Definition froidure-pin-base.hpp:1509
size_t size()
Returns the size of a FroidurePin instance.
Definition froidure-pin-base.hpp:850
const_normal_form_iterator cbegin_current_normal_forms() const
Returns an iterator pointing at the first normal form (if any).
Definition froidure-pin-base.hpp:1685
void enumerate(size_t limit)
Enumerate until at least a specified number of elements are found.
size_t batch_size() const noexcept
Returns the current value of the batch size.
Definition froidure-pin-base.hpp:225
size_t current_number_of_rules() const noexcept
Returns the number of rules that have been found so far.
Definition froidure-pin-base.hpp:522
const_rule_iterator cbegin_rules()
Returns a forward iterator pointing to the first rule (if any).
Definition froidure-pin-base.hpp:1405
element_index_type current_position(Iterator1 first, Iterator2 last) const
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:310
cayley_graph_type const & current_left_cayley_graph() const noexcept
Returns a const reference to the left Cayley graph.
Definition froidure-pin-base.hpp:996
const_normal_form_iterator cend_current_normal_forms() const
Returns an iterator pointing one beyond the last normal form (if any).
Definition froidure-pin-base.hpp:1709
element_index_type prefix(element_index_type pos) const
Returns the position of the longest proper prefix.
Definition froidure-pin-base.hpp:564
FroidurePinBase(FroidurePinBase &&other)=default
Default move constructor.
FroidurePinBase & operator=(FroidurePinBase const &)
Copy assignment operator.
size_t current_max_word_length() const noexcept
Returns the maximum length of a word in the generators so far computed.
Definition froidure-pin-base.hpp:465
size_t current_length(element_index_type pos) const
Returns the length of the short-lex least word equal to the element with given index.
Definition froidure-pin-base.hpp:780
FroidurePinBase & batch_size(size_t batch_size) noexcept
Set a new value for the batch size.
Definition froidure-pin-base.hpp:206
size_t number_of_elements_of_length(size_t min, size_t max) const
Returns the number of elements so far enumerated with length in a given range.
element_index_type position_of_generator(generator_index_type i) const
Returns the position of the generator with specified index.
Definition froidure-pin-base.hpp:441
size_t degree() const noexcept
Returns the degree of any and all elements.
Definition froidure-pin-base.hpp:484
size_t number_of_elements_of_length(size_t len) const
Returns the number of elements so far enumerated with given length.
FroidurePinBase()
Default constructor.
generator_index_type first_letter_no_checks(element_index_type pos) const
Returns the first letter of the element with specified index.
Definition froidure-pin-base.hpp:640
size_t length(element_index_type pos)
Returns the length of the short-lex least word equal to the element with given index.
element_index_type prefix_no_checks(element_index_type pos) const
Returns the position of the longest proper prefix.
Definition froidure-pin-base.hpp:543
const_rule_iterator cbegin_current_rules() const
Returns a forward iterator pointing to the first rule (if any).
Definition froidure-pin-base.hpp:1375
void current_factorisation_no_checks(Iterator d_first, element_index_type pos) const
Output to an iterator a word representing an element given by index.
Definition froidure-pin-base.hpp:1124
element_index_type suffix_no_checks(element_index_type pos) const
Returns the position of the longest proper suffix.
Definition froidure-pin-base.hpp:587
element_index_type position_of_generator_no_checks(generator_index_type i) const
Returns the position of the generator with specified index.
Definition froidure-pin-base.hpp:413
const_normal_form_iterator cend_normal_forms()
Returns an iterator pointing one beyond the last normal form (if any).
Definition froidure-pin-base.hpp:1759
element_index_type current_position_no_checks(Iterator1 first, Iterator2 last) const
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:1825
const_normal_form_iterator cbegin_normal_forms()
Returns an iterator pointing at the first normal form (if any).
Definition froidure-pin-base.hpp:1733
void minimal_factorisation(Iterator d_first, element_index_type pos)
Output to an iterator the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:1086
size_t current_size() const noexcept
Returns the number of elements so far enumerated.
Definition froidure-pin-base.hpp:504
FroidurePinBase(FroidurePinBase const &S)
Copy constructor.
void throw_if_element_index_out_of_range(element_index_type i) const
Throw an exception if an index is out of range.
size_type element_index_type
Alias for the index of an element.
Definition froidure-pin-base.hpp:87
void factorisation(Iterator d_first, element_index_type pos)
Output to an iterator a word representing an element given by index.
Definition froidure-pin-base.hpp:1155
bool contains_one()
Check if the categorical multiplicative identity is an element.
generator_index_type final_letter(element_index_type pos) const
Returns the last letter of the element with specified index.
Definition froidure-pin-base.hpp:730
void throw_if_any_generator_index_out_of_range(Iterator1 first, Iterator2 last) const
Throw an exception if any generator index is out of range.
Definition froidure-pin-base.hpp:1805
cayley_graph_type const & right_cayley_graph()
Returns a const reference to the right Cayley graph.
Definition froidure-pin-base.hpp:937
cayley_graph_type const & current_right_cayley_graph() const noexcept
Returns a const reference to the right Cayley graph.
Definition froidure-pin-base.hpp:957
FroidurePinBase & init()
Reinitialize a FroidurePinBase object.
void current_minimal_factorisation_no_checks(Iterator d_first, element_index_type pos) const
Output to an iterator the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:1025
size_t current_length_no_checks(element_index_type pos) const
Returns the length of the short-lex least word equal to the element with given index.
Definition froidure-pin-base.hpp:756
size_t length_no_checks(element_index_type pos)
Returns the length of the short-lex least word equal to the element with given index.
void throw_if_generator_index_out_of_range(generator_index_type i) const
Throw an exception if a generator index is out of range.
generator_index_type final_letter_no_checks(element_index_type pos) const
Returns the first letter of the element with specified index.
Definition froidure-pin-base.hpp:701
generator_index_type first_letter(element_index_type pos) const
Returns the first letter of the element with specified index.
Definition froidure-pin-base.hpp:669
FroidurePinBase & operator=(FroidurePinBase &&)=default
Move assignment operator.
size_type generator_index_type
Alias for the index of a generator.
Definition froidure-pin-base.hpp:81
WordGraph< element_index_type > cayley_graph_type
Alias for the types of the left and right Cayley graphs.
Definition froidure-pin-base.hpp:90
void current_minimal_factorisation(Iterator d_first, element_index_type pos) const
Output to an iterator the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:1054
uint32_t size_type
Alias for the type of the size of the enumerated semigroup.
Definition froidure-pin-base.hpp:75
const_rule_iterator cend_current_rules() const
Returns a forward iterator pointing one past the last rule (if any).
Definition froidure-pin-base.hpp:1478
bool currently_contains_one() const noexcept
Check if the categorical multiplicative identity is known to be an element.
Definition froidure-pin-base.hpp:895
element_index_type position(Iterator1 first, Iterator2 last)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:385
element_index_type suffix(element_index_type pos) const
Returns the position of the longest proper suffix.
Definition froidure-pin-base.hpp:609
void run()
Run until finished.
Runner()
Default constructor.
bool finished() const
Check if run has been run to completion or not.
Class for representing word graphs.
Definition word-graph.hpp:82
bool operator<=(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1647
bool operator>=(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1669
bool operator>(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1658
Bipartition operator*(Bipartition const &x, Bipartition const &y)
Multiply two bipartitions.
bool operator!=(Bipartition const &x, Bipartition const &y)
Check bipartitions for inequality.
Definition bipart.hpp:1637
Undefined const UNDEFINED
Value for something undefined.
auto operator+(typename Mat::scalar_type a, Mat const &x) -> std::enable_if_t< IsMatrix< Mat >, Mat >
Add a scalar to a matrix.
Definition matrix.hpp:7933
bool operator==(Presentation< Word > const &lhop, Presentation< Word > const &rhop)
Compare for equality.
Definition presentation.hpp:2346
std::vector< letter_type > word_type
Type for a word over the generators of a semigroup.
Definition types.hpp:101
std::pair< word_type, word_type > relation_type
Type for a pair of word_type (a relation) of a semigroup.
Definition types.hpp:104
tril
Enum to indicate true, false or not currently knowable.
Definition types.hpp:56
This namespace contains helper functions for the FroidurePin class template.
Definition froidure-pin-base.hpp:1843
FroidurePinBase::element_index_type position(FroidurePinBase &fpb, Word const &w)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:2039
FroidurePinBase::element_index_type product_by_reduction(FroidurePinBase const &fpb, typename FroidurePinBase::element_index_type i, typename FroidurePinBase::element_index_type j)
Compute a product using the Cayley graph.
FroidurePinBase::element_index_type current_position(FroidurePinBase const &fpb, Word const &w)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:1968
void current_minimal_factorisation(FroidurePinBase const &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:2139
rx::iterator_range< FroidurePinBase::const_normal_form_iterator > normal_forms(FroidurePinBase &fpb)
Returns a range object containing normal forms for all the elements.
rx::iterator_range< FroidurePinBase::const_rule_iterator > current_rules(FroidurePinBase const &fpb)
Returns a range object containing the so-far enumerated rules.
FroidurePinBase::element_index_type product_by_reduction_no_checks(FroidurePinBase const &fpb, typename FroidurePinBase::element_index_type i, typename FroidurePinBase::element_index_type j)
Compute a product using the Cayley graph.
rx::iterator_range< FroidurePinBase::const_normal_form_iterator > current_normal_forms(FroidurePinBase const &fpb)
Returns a range object containing normal forms for the so-far enumerated elements.
void current_minimal_factorisation_no_checks(FroidurePinBase const &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:2074
void current_factorisation_no_checks(FroidurePinBase const &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain a word representing an element given by index.
Definition froidure-pin-base.hpp:2276
FroidurePinBase::element_index_type current_position_no_checks(FroidurePinBase const &fpb, Word const &w)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:1933
void factorisation(FroidurePinBase &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain a word representing an element given by index.
Definition froidure-pin-base.hpp:2304
void minimal_factorisation(FroidurePinBase &fpb, Word &word, FroidurePinBase::element_index_type pos)
Modify a word to contain the short-lex least word representing an element given by index.
Definition froidure-pin-base.hpp:2204
rx::iterator_range< FroidurePinBase::const_rule_iterator > rules(FroidurePinBase &fpb)
Returns a range object containing all of the rules.
FroidurePinBase::element_index_type position_no_checks(FroidurePinBase &fpb, Word const &w)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:2004
Node1 follow_path_no_checks(WordGraph< Node1 > const &wg, Node2 from, Iterator first, Iterator last) noexcept
Follow the path from a specified node labelled by a word.
Namespace for everything in the libsemigroups library.
Definition action.hpp:44