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-helpers.hpp"
35#include "word-graph.hpp"
37#include "detail/containers.hpp"
68 template <
typename Element,
typename Traits>
69 friend class FroidurePin;
101#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
105 Settings() noexcept : _batch_size(8'192) {}
106 Settings(Settings
const&)
noexcept =
default;
107 Settings(Settings&&)
noexcept =
default;
108 Settings&
operator=(Settings
const&)
noexcept =
default;
109 Settings&
operator=(Settings&&)
noexcept =
default;
110 ~Settings() =
default;
123 bool _idempotents_found;
132 enumerate_index_type _pos;
135 detail::DynamicArray2<bool> _reduced;
227 return _settings._batch_size;
230#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
235 [[nodiscard]]
virtual size_t number_of_generators()
const = 0;
236 [[nodiscard]]
virtual tril is_finite()
const = 0;
275 template <
typename Iterator1,
typename Iterator2>
310 template <
typename Iterator1,
typename Iterator2>
312 Iterator2 last)
const {
347 template <
typename Iterator1,
typename Iterator2>
385 template <
typename Iterator1,
typename Iterator2>
415 LIBSEMIGROUPS_ASSERT(i < _letter_to_pos.size());
416 return _letter_to_pos[i];
467 return _length[_enumerate_order.back()];
485 [[nodiscard]]
size_t degree() const noexcept {
545 LIBSEMIGROUPS_ASSERT(pos < _prefix.size());
589 LIBSEMIGROUPS_ASSERT(pos < _suffix.size());
642 LIBSEMIGROUPS_ASSERT(pos < _first.size());
703 LIBSEMIGROUPS_ASSERT(pos < _final.size());
758 LIBSEMIGROUPS_ASSERT(pos < _length.size());
1025 template <
typename Iterator>
1054 template <
typename Iterator>
1086 template <
typename Iterator>
1124 template <
typename Iterator>
1155 template <
typename Iterator>
1226#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
1230 using difference_type =
1234 using const_reference =
1247 enumerate_index_type pos,
1254 return _gen == that._gen && _pos == that._pos;
1262 [[nodiscard]] const_reference
operator*()
const {
1263 populate_relation();
1267 [[nodiscard]] const_pointer operator->()
const {
1268 populate_relation();
1283 _current.swap(that._current);
1284 std::swap(_froidure_pin, that._froidure_pin);
1291 void populate_relation()
const;
1296 enumerate_index_type _pos;
1301 static_assert(std::is_default_constructible_v<const_rule_iterator>,
1302 "forward iterator requires default-constructible");
1303 static_assert(std::is_copy_constructible_v<const_rule_iterator>,
1304 "forward iterator requires copy-constructible");
1305 static_assert(std::is_copy_assignable_v<const_rule_iterator>,
1306 "forward iterator requires copy-assignable");
1307 static_assert(std::is_destructible_v<const_rule_iterator>,
1308 "forward iterator requires destructible");
1524#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
1527 enumerate_index_type _pos;
1551 enumerate_index_type pos)
1552 : _froidure_pin(ptr), _pos(pos), _word() {}
1556 return _pos == that._pos;
1561 return !(*
this == that);
1566 return _pos < that._pos;
1571 return _pos > that._pos;
1576 return _pos < that._pos;
1581 return _pos > that._pos;
1584 [[nodiscard]] const_reference
operator*()
const noexcept {
1589 [[nodiscard]] const_pointer operator->()
const noexcept {
1594 [[nodiscard]] const_reference operator[](
size_type index)
const {
1624 void operator+=(
size_type val)
noexcept {
1628 void operator-=(
size_type val)
noexcept {
1640 operator-(
size_type val)
const noexcept {
1646 [[nodiscard]] difference_type
1648 return _pos - that._pos;
1652 std::swap(_froidure_pin, that._froidure_pin);
1658 void populate_word()
const {
1805 template <
typename Iterator1,
typename Iterator2>
1807 Iterator2 last)
const {
1808 for (
auto it = first; it != last; ++it) {
1824 template <
typename Iterator1,
typename Iterator2>
1827 Iterator2 last)
const {
1828 if (first == last) {
1836 return v4::word_graph::follow_path_no_checks(
1932 template <
typename Word>
1967 template <
typename Word>
2003 template <
typename Word>
2038 template <
typename Word>
2074 template <
typename Word>
2110 template <
typename Word = word_type>
2138 template <
typename Word>
2172 template <
typename Word = word_type>
2204 template <
typename Word>
2242 template <
typename Word = word_type>
2275 template <
typename Word>
2304 template <
typename Word>
2334 template <
typename Word = word_type>
2355 [[nodiscard]] rx::iterator_range<
2377 [[nodiscard]] rx::iterator_range<
2398 [[nodiscard]] rx::iterator_range<FroidurePinBase::const_rule_iterator>
2418 [[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:1225
Base class for FroidurePin containing non-element specific data and member functions.
Definition froidure-pin-base.hpp:67
size_t number_of_rules()
Returns the total number of relations in the presentation.
Definition froidure-pin-base.hpp:918
cayley_graph_type const & left_cayley_graph()
Returns a const reference to the left Cayley graph.
Definition froidure-pin-base.hpp:976
element_index_type position_no_checks(Iterator1 first, Iterator2 last)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:348
const_rule_iterator cend_rules()
Returns a forward iterator pointing one past the last rule (if any).
Definition froidure-pin-base.hpp:1510
size_t size()
Returns the size of a FroidurePin instance.
Definition froidure-pin-base.hpp:851
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:1686
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:226
size_t current_number_of_rules() const noexcept
Returns the number of rules that have been found so far.
Definition froidure-pin-base.hpp:523
const_rule_iterator cbegin_rules()
Returns a forward iterator pointing to the first rule (if any).
Definition froidure-pin-base.hpp:1406
element_index_type current_position(Iterator1 first, Iterator2 last) const
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:311
cayley_graph_type const & current_left_cayley_graph() const noexcept
Returns a const reference to the left Cayley graph.
Definition froidure-pin-base.hpp:997
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:1710
element_index_type prefix(element_index_type pos) const
Returns the position of the longest proper prefix.
Definition froidure-pin-base.hpp:565
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:466
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:781
FroidurePinBase & batch_size(size_t batch_size) noexcept
Set a new value for the batch size.
Definition froidure-pin-base.hpp:207
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:442
size_t degree() const noexcept
Returns the degree of any and all elements.
Definition froidure-pin-base.hpp:485
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:641
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:544
const_rule_iterator cbegin_current_rules() const
Returns a forward iterator pointing to the first rule (if any).
Definition froidure-pin-base.hpp:1376
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:1125
element_index_type suffix_no_checks(element_index_type pos) const
Returns the position of the longest proper suffix.
Definition froidure-pin-base.hpp:588
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:414
const_normal_form_iterator cend_normal_forms()
Returns an iterator pointing one beyond the last normal form (if any).
Definition froidure-pin-base.hpp:1760
element_index_type current_position_no_checks(Iterator1 first, Iterator2 last) const
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:1826
const_normal_form_iterator cbegin_normal_forms()
Returns an iterator pointing at the first normal form (if any).
Definition froidure-pin-base.hpp:1734
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:1087
size_t current_size() const noexcept
Returns the number of elements so far enumerated.
Definition froidure-pin-base.hpp:505
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:88
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:1156
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:731
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:1806
cayley_graph_type const & right_cayley_graph()
Returns a const reference to the right Cayley graph.
Definition froidure-pin-base.hpp:938
cayley_graph_type const & current_right_cayley_graph() const noexcept
Returns a const reference to the right Cayley graph.
Definition froidure-pin-base.hpp:958
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:1026
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:757
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:702
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:670
FroidurePinBase & operator=(FroidurePinBase &&)=default
Move assignment operator.
size_type generator_index_type
Alias for the index of a generator.
Definition froidure-pin-base.hpp:82
WordGraph< element_index_type > cayley_graph_type
Alias for the types of the left and right Cayley graphs.
Definition froidure-pin-base.hpp:91
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:1055
uint32_t size_type
Alias for the type of the size of the enumerated semigroup.
Definition froidure-pin-base.hpp:76
const_rule_iterator cend_current_rules() const
Returns a forward iterator pointing one past the last rule (if any).
Definition froidure-pin-base.hpp:1479
bool currently_contains_one() const noexcept
Check if the categorical multiplicative identity is known to be an element.
Definition froidure-pin-base.hpp:896
element_index_type position(Iterator1 first, Iterator2 last)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:386
element_index_type suffix(element_index_type pos) const
Returns the position of the longest proper suffix.
Definition froidure-pin-base.hpp:610
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:83
bool operator<=(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1737
bool operator>=(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1759
bool operator>(Bipartition const &x, Bipartition const &y)
Compare bipartitions.
Definition bipart.hpp:1748
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:1727
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:7946
bool operator==(Presentation< Word > const &lhop, Presentation< Word > const &rhop)
Compare for equality.
Definition presentation.hpp:2893
std::vector< letter_type > word_type
Type for a word over the generators of a semigroup.
Definition types.hpp:99
std::pair< word_type, word_type > relation_type
Type for a pair of word_type (a relation) of a semigroup.
Definition types.hpp:102
tril
Enum to indicate true, false or not currently knowable.
Definition types.hpp:54
This namespace contains helper functions for the FroidurePin class template.
Definition froidure-pin-base.hpp:1844
FroidurePinBase::element_index_type position(FroidurePinBase &fpb, Word const &w)
Returns the position corresponding to a word.
Definition froidure-pin-base.hpp:2040
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:1969
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:2140
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:2075
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:2277
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:1934
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:2305
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:2205
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:2005
Namespace for everything in the libsemigroups library.
Definition action.hpp:44