libsemigroups  v3.0.0
C++ library for semigroups and monoids
Loading...
Searching...
No Matches
froidure-pin-base.hpp
1//
2// libsemigroups - C++ library for semigroups and monoids
3// Copyright (C) 2019-2025 James D. Mitchell
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program. If not, see <http://www.gnu.org/licenses/>.
17//
18
19#ifndef LIBSEMIGROUPS_FROIDURE_PIN_BASE_HPP_
20#define LIBSEMIGROUPS_FROIDURE_PIN_BASE_HPP_
21
22#include <array> // for array
23#include <cstddef> // for size_t
24#include <cstdint> // for uint32_t
25#include <initializer_list> // for initializer_list
26#include <iterator> // for forward_iterator_tag
27#include <utility> // for swap
28#include <vector> // for vector, allocator
29
30#include "constants.hpp" // for UNDEFINED
31#include "ranges.hpp" // for iterator_range
32#include "runner.hpp" // for Runner
33#include "types.hpp" // for word_type, generator_index_type, tril
34#include "word-graph.hpp" // for WordGraph
35
36#include "detail/containers.hpp" // for DynamicArray2
37
38namespace libsemigroups {
39
49
66 class FroidurePinBase : public Runner {
67 template <typename Element, typename Traits>
68 friend class FroidurePin;
69
70 public:
72 // It should be possible to change this type and everything will just work,
73 // provided the size of the semigroup is less than the maximum value of
74 // this type of integer.
75 using size_type = uint32_t;
76
82
88
91
92 private:
93 // See comments in FroidurePin
94 using enumerate_index_type = size_type;
95
97 // FroidurePin - data members - private
99
100#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
101 // This now only contains a single data member, which might make it a bit
102 // redundant.
103 struct Settings {
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;
110
111 size_t _batch_size;
112 } _settings;
113#endif
114
115 size_t _degree;
117 _duplicate_gens;
118 std::vector<element_index_type> _enumerate_order;
121 bool _found_one;
122 bool _idempotents_found;
123 std::vector<int> _is_idempotent;
124 cayley_graph_type _left;
127 std::vector<element_index_type> _letter_to_pos;
128 size_type _nr;
129 size_t _nr_products;
130 size_t _nr_rules;
131 enumerate_index_type _pos;
132 element_index_type _pos_one;
134 detail::DynamicArray2<bool> _reduced;
135 cayley_graph_type _right;
137 size_t _wordlen;
138
139 public:
141 // FroidurePinBase - constructors - public
143
148
159
164
169
174
179
180 virtual ~FroidurePinBase();
181
183 // FroidurePinBase - settings - public
185
207 _settings._batch_size = batch_size;
208 return *this;
209 }
210
225 [[nodiscard]] size_t batch_size() const noexcept {
226 return _settings._batch_size;
227 }
228
229#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
231 // FroidurePinBase - pure virtual member functions - public
233
234 [[nodiscard]] virtual size_t number_of_generators() const = 0;
235 [[nodiscard]] virtual tril is_finite() const = 0;
236
237#endif // LIBSEMIGROUPS_PARSED_BY_DOXYGEN not defined
238
240 // FroidurePinBase - member functions - public
242
274 template <typename Iterator1, typename Iterator2>
275 [[nodiscard]] element_index_type
276 current_position_no_checks(Iterator1 first, Iterator2 last) const;
277
309 template <typename Iterator1, typename Iterator2>
310 [[nodiscard]] element_index_type current_position(Iterator1 first,
311 Iterator2 last) const {
313 return current_position_no_checks(first, last);
314 }
315
346 template <typename Iterator1, typename Iterator2>
347 [[nodiscard]] element_index_type position_no_checks(Iterator1 first,
348 Iterator2 last) {
349 run();
350 return current_position_no_checks(first, last);
351 }
352
384 template <typename Iterator1, typename Iterator2>
385 [[nodiscard]] element_index_type position(Iterator1 first, Iterator2 last) {
386 run();
387 return current_position(first, last);
388 }
389
412 [[nodiscard]] element_index_type
414 LIBSEMIGROUPS_ASSERT(i < _letter_to_pos.size());
415 return _letter_to_pos[i];
416 }
417
440 [[nodiscard]] element_index_type
445
465 [[nodiscard]] size_t current_max_word_length() const noexcept {
466 return _length[_enumerate_order.back()];
467 }
468
484 [[nodiscard]] size_t degree() const noexcept {
485 return _degree;
486 }
487
504 [[nodiscard]] size_t current_size() const noexcept {
505 return _nr;
506 }
507
522 [[nodiscard]] size_t current_number_of_rules() const noexcept {
523 return _nr_rules;
524 }
525
544 LIBSEMIGROUPS_ASSERT(pos < _prefix.size());
545 return _prefix[pos];
546 }
547
568
586 [[nodiscard]] element_index_type
588 LIBSEMIGROUPS_ASSERT(pos < _suffix.size());
589 return _suffix[pos];
590 }
591
611 return suffix_no_checks(pos);
612 }
613
639 [[nodiscard]] generator_index_type
641 LIBSEMIGROUPS_ASSERT(pos < _first.size());
642 return _first[pos];
643 }
644
668 [[nodiscard]] generator_index_type
673
700 [[nodiscard]] generator_index_type
702 LIBSEMIGROUPS_ASSERT(pos < _final.size());
703 return _final[pos];
704 }
705
729 [[nodiscard]] generator_index_type
734
755 [[nodiscard]] size_t
757 LIBSEMIGROUPS_ASSERT(pos < _length.size());
758 return _length[pos];
759 }
760
780 [[nodiscard]] size_t current_length(element_index_type pos) const {
782 return current_length_no_checks(pos);
783 }
784
805 // This function could be a helper, but current_length cannot be, so keeping
806 // this as a mem fn.
807 [[nodiscard]] size_t length(element_index_type pos);
808
829 // This function could be a helper, but current_length cannot be, so keeping
830 // this as a mem fn.
831 [[nodiscard]] size_t length_no_checks(element_index_type pos);
832
850 [[nodiscard]] size_t size() {
851 run();
852 return current_size();
853 }
854
872 [[nodiscard]] bool contains_one();
873
895 [[nodiscard]] bool currently_contains_one() const noexcept {
896 return _found_one;
897 }
898
917 [[nodiscard]] size_t number_of_rules() {
918 run();
919 return _nr_rules;
920 }
921
937 [[nodiscard]] cayley_graph_type const& right_cayley_graph() {
938 run();
939 return _right;
940 }
941
956 [[nodiscard]] cayley_graph_type const&
957 current_right_cayley_graph() const noexcept {
958 return _right;
959 }
960
975 [[nodiscard]] cayley_graph_type const& left_cayley_graph() {
976 run();
977 return _left;
978 }
979
995 [[nodiscard]] cayley_graph_type const&
996 current_left_cayley_graph() const noexcept {
997 return _left;
998 }
999
1000 // Here's a little summary of the functions for minimal_factorisation:
1001 // [x] current_minimal_factorisation_no_checks(2 args)
1002 // [x] current_minimal_factorisation(2 args)
1003 // [x] minimal_factorisation(2 args)
1004
1024 template <typename Iterator>
1026 element_index_type pos) const {
1027 LIBSEMIGROUPS_ASSERT(pos < current_size());
1028 while (pos != UNDEFINED) {
1029 *d_first = first_letter_no_checks(pos);
1030 pos = suffix_no_checks(pos);
1031 }
1032 }
1033
1053 template <typename Iterator>
1054 void current_minimal_factorisation(Iterator d_first,
1055 element_index_type pos) const {
1058 }
1059
1081 //
1082 // Note: There's no no_check version of this function because it doesn't
1083 // make sense (see the impl of minimal_factorisation(word_type&,
1084 // element_index_type)
1085 template <typename Iterator>
1086 void minimal_factorisation(Iterator d_first, element_index_type pos) {
1087 if (pos >= current_size() && !finished()) {
1088 enumerate(pos + 1);
1089 }
1092 }
1093
1094 // Here's a little summary of the functions for (non-minimal) factorisation:
1095 // [x] current_factorisation_no_checks(2 args)
1096 // [ ] current_factorisation(2 args) TODO(1)
1097 // [x] factorisation(2 args)
1098
1122 // TODO(1) check that all _no_checks functions have this warning
1123 template <typename Iterator>
1124 void current_factorisation_no_checks(Iterator d_first,
1125 element_index_type pos) const {
1127 }
1128
1150 //
1151 // Note: There's no no_check version of this function because it doesn't
1152 // make sense (see the impl of minimal_factorisation(word_type&,
1153 // element_index_type)
1154 template <typename Iterator>
1155 void factorisation(Iterator d_first, element_index_type pos) {
1156 minimal_factorisation(d_first, pos);
1157 }
1158
1176 void enumerate(size_t limit);
1177
1197 [[nodiscard]] size_t number_of_elements_of_length(size_t min,
1198 size_t max) const;
1199
1218 [[nodiscard]] size_t number_of_elements_of_length(size_t len) const;
1219
1225#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
1226
1227 public:
1229 using difference_type =
1231 using const_pointer = typename std::vector<relation_type>::const_pointer;
1232 using pointer = typename std::vector<relation_type>::pointer;
1233 using const_reference =
1235 using reference = typename std::vector<relation_type>::reference;
1236 using value_type = relation_type;
1237 using iterator_category = std::forward_iterator_tag;
1238
1239 const_rule_iterator() = default;
1240 const_rule_iterator(const_rule_iterator const&) = default;
1244
1246 enumerate_index_type pos,
1248
1249 ~const_rule_iterator() = default;
1250
1251 [[nodiscard]] bool
1252 operator==(const_rule_iterator const& that) const noexcept {
1253 return _gen == that._gen && _pos == that._pos;
1254 }
1255
1256 [[nodiscard]] bool
1257 operator!=(const_rule_iterator const& that) const noexcept {
1258 return !(this->operator==(that));
1259 }
1260
1261 [[nodiscard]] const_reference operator*() const {
1262 populate_relation();
1263 return _relation;
1264 }
1265
1266 [[nodiscard]] const_pointer operator->() const {
1267 populate_relation();
1268 return &_relation;
1269 }
1270
1271 // prefix
1272 const_rule_iterator const& operator++() noexcept;
1273
1274 // postfix
1275 [[nodiscard]] const_rule_iterator operator++(int) noexcept {
1276 const_rule_iterator copy(*this);
1277 ++(*this);
1278 return copy;
1279 }
1280
1281 void swap(const_rule_iterator& that) noexcept {
1282 _current.swap(that._current);
1283 std::swap(_froidure_pin, that._froidure_pin);
1284 std::swap(_gen, that._gen);
1285 std::swap(_pos, that._pos);
1286 }
1287#endif // LIBSEMIGROUPS_PARSED_BY_DOXYGEN not defined
1288
1289 private:
1290 void populate_relation() const;
1291
1293 FroidurePinBase const* _froidure_pin;
1295 enumerate_index_type _pos;
1296 mutable relation_type _relation;
1297 }; // const_rule_iterator
1298
1299 // Assert that the forward iterator requirements are met
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");
1308
1334 // clang-format off
1374 // clang-format on
1376 return const_rule_iterator(this, UNDEFINED, 0);
1377 }
1378
1406 run();
1407 return const_rule_iterator(this, UNDEFINED, 0);
1408 }
1409
1438 // clang-format off
1477 // clang-format on
1479 return const_rule_iterator(this, current_size(), 0);
1480 }
1481
1510 run();
1511 return const_rule_iterator(this, current_size(), 0);
1512 }
1513
1514 // TODO(later) it'd be more efficient to have this be a forward
1515 // iterator only (i.e. as is done in the GAP version of FroidurePin)
1523#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
1524 // Private data
1525 mutable FroidurePinBase const* _froidure_pin;
1526 enumerate_index_type _pos;
1527 mutable word_type _word;
1528
1529 public:
1531 using difference_type = typename std::vector<word_type>::difference_type;
1532 using const_pointer = typename std::vector<word_type>::const_pointer;
1533 using pointer = typename std::vector<word_type>::pointer;
1534 using const_reference = typename std::vector<word_type>::const_reference;
1535 using reference = typename std::vector<word_type>::reference;
1536 using value_type = word_type;
1537 using iterator_category = std::random_access_iterator_tag;
1538
1539 const_normal_form_iterator() = default;
1543 = default;
1545 = default;
1546
1547 ~const_normal_form_iterator() = default;
1548
1550 enumerate_index_type pos)
1551 : _froidure_pin(ptr), _pos(pos), _word() {}
1552
1553 [[nodiscard]] bool
1554 operator==(const_normal_form_iterator const& that) const noexcept {
1555 return _pos == that._pos;
1556 }
1557
1558 [[nodiscard]] bool
1559 operator!=(const_normal_form_iterator const& that) const noexcept {
1560 return !(*this == that);
1561 }
1562
1563 [[nodiscard]] bool
1564 operator<(const_normal_form_iterator const& that) const noexcept {
1565 return _pos < that._pos;
1566 }
1567
1568 [[nodiscard]] bool
1569 operator>(const_normal_form_iterator const& that) const noexcept {
1570 return _pos > that._pos;
1571 }
1572
1573 [[nodiscard]] bool
1574 operator<=(const_normal_form_iterator const& that) const noexcept {
1575 return _pos < that._pos;
1576 }
1577
1578 [[nodiscard]] bool
1579 operator>=(const_normal_form_iterator const& that) const noexcept {
1580 return _pos > that._pos;
1581 }
1582
1583 [[nodiscard]] const_reference operator*() const noexcept {
1584 populate_word();
1585 return _word;
1586 }
1587
1588 [[nodiscard]] const_pointer operator->() const noexcept {
1589 populate_word();
1590 return &_word;
1591 }
1592
1593 [[nodiscard]] const_reference operator[](size_type index) const {
1594 const_cast<const_normal_form_iterator*>(this)->_pos += index;
1595 populate_word();
1596 const_cast<const_normal_form_iterator*>(this)->_pos -= index;
1597 return _word;
1598 }
1599
1600 // prefix
1601 const_normal_form_iterator const& operator++() noexcept {
1602 _pos++;
1603 return *this;
1604 }
1605
1606 [[nodiscard]] const_normal_form_iterator operator++(int) noexcept {
1607 const_normal_form_iterator copy(*this);
1608 ++(*this);
1609 return copy;
1610 }
1611
1612 const_normal_form_iterator const& operator--() noexcept {
1613 _pos--;
1614 return *this;
1615 }
1616
1617 [[nodiscard]] const_normal_form_iterator operator--(int) noexcept {
1618 const_normal_form_iterator copy(*this);
1619 --(*this);
1620 return copy;
1621 }
1622
1623 void operator+=(size_type val) noexcept {
1624 _pos += val;
1625 }
1626
1627 void operator-=(size_type val) noexcept {
1628 _pos -= val;
1629 }
1630
1631 [[nodiscard]] const_normal_form_iterator
1632 operator+(size_type val) const noexcept {
1633 const_normal_form_iterator copy(*this);
1634 copy += val;
1635 return copy;
1636 }
1637
1638 [[nodiscard]] const_normal_form_iterator
1639 operator-(size_type val) const noexcept {
1640 const_normal_form_iterator copy(*this);
1641 copy -= val;
1642 return copy;
1643 }
1644
1645 [[nodiscard]] difference_type
1646 operator-(const_normal_form_iterator const& that) const noexcept {
1647 return _pos - that._pos;
1648 }
1649
1650 void swap(const_normal_form_iterator& that) noexcept {
1651 std::swap(_froidure_pin, that._froidure_pin);
1652 std::swap(_pos, that._pos);
1653 std::swap(_word, that._word);
1654 }
1655
1656 private:
1657 void populate_word() const {
1658 _word.clear();
1660 std::back_inserter(_word), _pos);
1661 }
1662#endif // LIBSEMIGROUPS_PARSED_BY_DOXYGEN not defined
1663 };
1664
1684 [[nodiscard]] const_normal_form_iterator
1686 return const_normal_form_iterator(this, 0);
1687 }
1688
1712
1734 run();
1735 return const_normal_form_iterator(this, 0);
1736 }
1737
1760 run();
1761 return const_normal_form_iterator(this, size());
1762 }
1763
1765 // FroidurePin - validation member functions - public
1767
1777
1788
1804 template <typename Iterator1, typename Iterator2>
1806 Iterator2 last) const {
1807 for (auto it = first; it != last; ++it) {
1809 }
1810 }
1811
1812 private:
1814 // FroidurePinBase - member functions - private
1816 void partial_copy(FroidurePinBase const& S);
1817 }; // class FroidurePinBase
1818
1820 // Implementations of mem fn templates for FroidurePinBase
1822
1823 template <typename Iterator1, typename Iterator2>
1826 Iterator2 last) const {
1827 if (first == last) {
1828 if (_found_one) {
1829 return _pos_one;
1830 } else {
1831 return UNDEFINED;
1832 }
1833 }
1836 current_right_cayley_graph(), s, first + 1, last);
1837 }
1838
1843 namespace froidure_pin {
1870 FroidurePinBase const& fpb,
1873
1897 [[nodiscard]] typename FroidurePinBase::element_index_type
1901
1903 // Position helper functions
1905
1931 template <typename Word>
1933 current_position_no_checks(FroidurePinBase const& fpb, Word const& w) {
1935 }
1936
1938 [[nodiscard]] static inline FroidurePinBase::element_index_type
1943
1966 template <typename Word>
1968 current_position(FroidurePinBase const& fpb, Word const& w) {
1969 return fpb.current_position(std::begin(w), std::end(w));
1970 }
1971
1973 [[nodiscard]] static inline FroidurePinBase::element_index_type
1978
2002 template <typename Word>
2005 return fpb.position_no_checks(std::begin(w), std::end(w));
2006 }
2007
2009 [[nodiscard]] static inline FroidurePinBase::element_index_type
2014
2037 template <typename Word>
2039 position(FroidurePinBase& fpb, Word const& w) {
2040 return fpb.position(std::begin(w), std::end(w));
2041 }
2042
2044 [[nodiscard]] static inline FroidurePinBase::element_index_type
2048
2050 // Minimal factorisation helper functions
2052
2073 template <typename Word>
2075 FroidurePinBase const& fpb,
2076 Word& word,
2078 // TODO(1) remove the clear (makes the functions more flexible), but will
2079 // require care
2080 word.clear();
2082 pos);
2083 }
2084
2109 template <typename Word = word_type>
2111 FroidurePinBase const& fpb,
2113 Word word;
2115 return word;
2116 }
2117
2137 template <typename Word>
2138 void
2140 Word& word,
2142 // TODO(1) remove the clear (makes the functions more flexible), but will
2143 // require care
2144 word.clear();
2146 }
2147
2171 template <typename Word = word_type>
2172 [[nodiscard]] Word
2175 Word word;
2176 current_minimal_factorisation(fpb, word, pos);
2177 return word;
2178 }
2179
2200 // Note: there's no no_check version of this function because it doesn't
2201 // make sense (see the impl of minimal_factorisation(word_type&,
2202 // FroidurePinBase::element_index_type);
2203 template <typename Word>
2205 Word& word,
2207 // TODO(1) remove the clear (makes the functions more flexible), but will
2208 // require care
2209 word.clear();
2211 }
2212
2237 // Notes:
2238 // * There's no no_check version of this function because it doesn't make
2239 // sense (see the impl of minimal_factorisation(word_type&,
2240 // FroidurePinBase::element_index_type);
2241 template <typename Word = word_type>
2242 [[nodiscard]] Word
2245 Word word;
2246 minimal_factorisation(fpb, word, pos);
2247 return word;
2248 }
2249
2251 // (Non-minimal) factorisation helper functions
2253
2274 template <typename Word>
2275 void
2281
2303 template <typename Word>
2305 Word& word,
2307 return minimal_factorisation<Word>(fpb, word, pos);
2308 }
2309
2333 template <typename Word = word_type>
2334 [[nodiscard]] Word factorisation(FroidurePinBase& fpb,
2336 return minimal_factorisation<Word>(fpb, pos);
2337 }
2338
2353 // TODO(1) complexity?
2354 [[nodiscard]] rx::iterator_range<
2357
2376 [[nodiscard]] rx::iterator_range<
2379
2396 // TODO(1) complexity?
2397 [[nodiscard]] rx::iterator_range<FroidurePinBase::const_rule_iterator>
2399
2417 [[nodiscard]] rx::iterator_range<FroidurePinBase::const_rule_iterator>
2419
2420 } // namespace froidure_pin
2421} // namespace libsemigroups
2422#endif // LIBSEMIGROUPS_FROIDURE_PIN_BASE_HPP_
T back_inserter(T... args)
T begin(T... args)
Return type of cbegin_normal_forms and cend_normal_forms.
Definition froidure-pin-base.hpp:1522
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
T clear(T... args)
T end(T... args)
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
T swap(T... args)