23#ifndef LIBSEMIGROUPS_OBVINF_HPP_
24#define LIBSEMIGROUPS_OBVINF_HPP_
35#include "word-graph-helpers.hpp"
36#include "word-graph.hpp"
37#include "word-range.hpp"
39#include "detail/eigen.hpp"
40#include "detail/uf.hpp"
43#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
46 template <
typename Rewriter,
typename ReductionOrder>
47 class KnuthBendixImpl;
48 class ToddCoxeterImpl;
51 template <
typename Word>
54 template <
typename Word>
57 template <
typename Word>
62 template <
typename Word>
133 class IsObviouslyInfinite {
136 IsObviouslyInfinite() =
default;
181 IsObviouslyInfinite&
init(
size_t n);
193 : IsObviouslyInfinite(lphbt.size()) {}
221 IsObviouslyInfinite&
operator=(IsObviouslyInfinite
const&) =
delete;
224 IsObviouslyInfinite&
operator=(IsObviouslyInfinite&&) =
delete;
226 ~IsObviouslyInfinite();
271 template <
typename Char>
276#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
277 auto matrix_start = _matrix.rows();
278 _matrix.conservativeResize(matrix_start + (last - first) / 2,
280 _matrix.block(matrix_start, 0, (last - first) / 2, _matrix.cols())
283 auto matrix_start = 0;
284 std::fill(_matrix.begin(), _matrix.end(), 0);
289 for (
auto it = first; it < last; ++it) {
292 private_add_rule(matrix_start + (it - first) / 2, lhs, rhs);
294 _nr_letter_components = _letter_components.number_of_blocks();
345 template <
typename Char>
350#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
351 auto matrix_start = _matrix.rows();
352 _matrix.conservativeResize(matrix_start + (last - first) / 2,
354 _matrix.block(matrix_start, 0, (last - first) / 2, _matrix.cols())
357 auto matrix_start = 0;
358 std::fill(_matrix.begin(), _matrix.end(), 0);
364 for (
auto it = first; it < last; ++it) {
366 tmp.
assign(it->begin(), it->end());
370 tmp.
assign(it->begin(), it->end());
372 private_add_rule(matrix_start + (it - first) / 2, lhs, rhs);
374 _nr_letter_components = _letter_components.number_of_blocks();
421 inline void letters_in_word(
size_t row,
word_type const& w, int64_t adv) {
422 for (
size_t const& x : w) {
423 matrix(row, x) += adv;
428 inline void plus_letters_in_word(
size_t row,
word_type const& w) {
429 letters_in_word(row, w, 1);
432 inline void minus_letters_in_word(
size_t row,
word_type const& w) {
433 letters_in_word(row, w, -1);
436 inline int64_t& matrix(
size_t row,
size_t col) {
437#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
438 return _matrix(row, col);
445 inline bool matrix_row_sums_to_0(
size_t row) {
446#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
447 return _matrix.row(row).sum() == 0;
459 detail::Duf<> _letter_components;
461 size_t _nr_letter_components;
462 size_t _nr_relations;
463 bool _preserve_length;
464 std::vector<bool> _preserve;
465 std::vector<bool> _seen;
466 std::vector<bool> _unique;
468#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
469 Eigen::Matrix<int64_t, Eigen::Dynamic, Eigen::Dynamic> _matrix;
471 std::vector<int64_t> _matrix;
496 template <
typename Word>
589 template <
typename Word>
613 template <
typename Word>
622 k.internal_generating_pairs().
cbegin(),
623 k.internal_generating_pairs().
cend());
651 template <
typename Rewriter,
typename ReductionOrder>
657 auto const& p = kb.internal_presentation();
658 if (p.alphabet().empty()) {
664 kb.internal_generating_pairs().
cbegin(),
665 kb.internal_generating_pairs().
cend());
Class for checking if a finitely presented semigroup or monoid is obviously infinite.
Definition obvinf.hpp:133
typename std::vector< std::pair< std::string, std::string > >::const_iterator const_iterator_pair_string
Alias for std::vector< std::pair<std::string, std::string>>::const_iterator.
Definition obvinf.hpp:148
IsObviouslyInfinite & add_rules_no_checks(word_type const &, const_iterator_word_type first, const_iterator_word_type last)
Add rules from iterators to word_type.
IsObviouslyInfinite(size_t n)
Construct from alphabet size.
IsObviouslyInfinite & add_rules_no_checks(char const *lphbt, typename std::vector< std::string >::const_iterator first, typename std::vector< std::string >::const_iterator last)
Add rules from iterators to std::vector of std::string.
Definition obvinf.hpp:319
IsObviouslyInfinite & add_rules_no_checks(std::string const &lphbt, const_iterator_pair_string first, const_iterator_pair_string last)
Add rules from iterators to std::pair of std::string.
IsObviouslyInfinite(IsObviouslyInfinite &&)=delete
Deleted.
IsObviouslyInfinite(std::string const &lphbt)
Construct from alphabet.
Definition obvinf.hpp:192
IsObviouslyInfinite & operator=(IsObviouslyInfinite const &)=delete
Deleted.
IsObviouslyInfinite & add_rules_no_checks(std::basic_string< Char > const &lphbt, typename std::vector< std::basic_string< Char > >::const_iterator first, typename std::vector< std::basic_string< Char > >::const_iterator last)
Add rules from iterators to std::string.
Definition obvinf.hpp:272
IsObviouslyInfinite & init(std::string const &lphbt)
Definition obvinf.hpp:210
IsObviouslyInfinite & add_rules_no_checks(std::basic_string< Char > const &lphbt, const_iterator_word_type first, const_iterator_word_type last)
Add rules from iterators to word_type.
Definition obvinf.hpp:347
typename std::vector< word_type >::const_iterator const_iterator_word_type
Alias for std::vector<word_type>::const_iterator.
Definition obvinf.hpp:140
typename std::vector< std::string >::const_iterator const_iterator_string
Alias for std::vector<std::string>::const_iterator.
Definition obvinf.hpp:152
IsObviouslyInfinite(IsObviouslyInfinite const &)=delete
Deleted.
IsObviouslyInfinite & init(size_t n)
bool result() const
Returns whether or not the finitely presented semigroup or monoid is obviously infinite.
IsObviouslyInfinite & operator=(IsObviouslyInfinite &&)=delete
Deleted.
For an implementation of presentations for semigroups or monoids.
Definition presentation.hpp:103
void throw_if_bad_alphabet_or_rules() const
Check if the alphabet and rules are valid.
Definition presentation.hpp:639
std::vector< word_type > rules
Data member holding the rules of the presentation.
Definition presentation.hpp:132
word_type const & alphabet() const noexcept
Return the alphabet of the presentation.
Definition presentation.hpp:184
typename word_type::value_type letter_type
Type of the letters in the words that constitute the rules of a Presentation object.
Definition presentation.hpp:110
bool finished() const
Check if run has been run to completion or not.
Class for converting strings to word_type with specified alphabet.
Definition word-range.hpp:772
size_t small_overlap_class()
Get the small overlap class.
Presentation< native_word_type > const & presentation() const noexcept
Get the presentation used to define a Kambites instance (if any).
Definition kambites-class.hpp:343
WordGraph< uint32_t > const & gilman_graph()
Return the Gilman WordGraph.
bool is_obviously_infinite(Presentation< Word > const &p)
Function for checking if the finitely presented semigroup or monoid defined by a Presentation object ...
Definition obvinf.hpp:497
std::vector< letter_type > word_type
Type for a word over the generators of a semigroup.
Definition types.hpp:99
Namespace for Presentation helper functions.
Definition obvinf.hpp:61
void change_alphabet(Presentation< Word > &, Word const &)
Change or re-order the alphabet.
Namespace for everything in the libsemigroups library.
Definition action.hpp:44