23#ifndef LIBSEMIGROUPS_OBVINF_HPP_
24#define LIBSEMIGROUPS_OBVINF_HPP_
35#include "word-graph.hpp"
37#include "detail/eigen.hpp"
38#include "detail/uf.hpp"
41#ifndef LIBSEMIGROUPS_PARSED_BY_DOXYGEN
44 template <
typename Rewriter,
typename ReductionOrder>
45 class KnuthBendixImpl;
46 class ToddCoxeterImpl;
49 template <
typename Word>
52 template <
typename Word>
55 template <
typename Word>
60 template <
typename Word>
128 class IsObviouslyInfinite {
131 IsObviouslyInfinite() =
default;
176 IsObviouslyInfinite&
init(
size_t n);
188 : IsObviouslyInfinite(lphbt.size()) {}
216 IsObviouslyInfinite&
operator=(IsObviouslyInfinite
const&) =
delete;
219 IsObviouslyInfinite&
operator=(IsObviouslyInfinite&&) =
delete;
221 ~IsObviouslyInfinite();
335 inline void letters_in_word(
size_t row,
word_type const& w, int64_t adv) {
336 for (
size_t const& x : w) {
337 matrix(row, x) += adv;
342 inline void plus_letters_in_word(
size_t row,
word_type const& w) {
343 letters_in_word(row, w, 1);
346 inline void minus_letters_in_word(
size_t row,
word_type const& w) {
347 letters_in_word(row, w, -1);
350 inline int64_t& matrix(
size_t row,
size_t col) {
351#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
352 return _matrix(row, col);
359 inline bool matrix_row_sums_to_0(
size_t row) {
360#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
361 return _matrix.row(row).sum() == 0;
373 detail::Duf<> _letter_components;
375 size_t _nr_letter_components;
376 size_t _nr_relations;
377 bool _preserve_length;
378 std::vector<bool> _preserve;
379 std::vector<bool> _seen;
380 std::vector<bool> _unique;
382#ifdef LIBSEMIGROUPS_EIGEN_ENABLED
383 Eigen::Matrix<int64_t, Eigen::Dynamic, Eigen::Dynamic> _matrix;
385 std::vector<int64_t> _matrix;
410 template <
typename Word>
503 template <
typename Word>
527 template <
typename Word>
559 template <
typename Rewriter,
typename ReductionOrder>
565 auto const& p = kb.internal_presentation();
566 if (p.alphabet().empty()) {
572 kb.internal_generating_pairs().
cbegin(),
573 kb.internal_generating_pairs().
cend());
Class for checking if a finitely presented semigroup or monoid is obviously infinite.
Definition obvinf.hpp:128
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:143
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(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:187
IsObviouslyInfinite & operator=(IsObviouslyInfinite const &)=delete
Deleted.
IsObviouslyInfinite & add_rules_no_checks(std::string const &lphbt, const_iterator_word_type first, const_iterator_word_type last)
Add rules from iterators to word_type.
IsObviouslyInfinite & add_rules_no_checks(std::string const &lphbt, const_iterator_string first, const_iterator_string last)
Add rules from iterators to std::string.
IsObviouslyInfinite & init(std::string const &lphbt)
Definition obvinf.hpp:205
typename std::vector< word_type >::const_iterator const_iterator_word_type
Alias for std::vector<word_type>::const_iterator.
Definition obvinf.hpp:135
typename std::vector< std::string >::const_iterator const_iterator_string
Alias for std::vector<std::string>::const_iterator.
Definition obvinf.hpp:147
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:102
void throw_if_bad_alphabet_or_rules() const
Check if the alphabet and rules are valid.
Definition presentation.hpp:596
std::vector< word_type > rules
Data member holding the rules of the presentation.
Definition presentation.hpp:131
word_type const & alphabet() const noexcept
Return the alphabet of the presentation.
Definition presentation.hpp:183
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:109
bool finished() const
Check if run has been run to completion or not.
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:411
std::vector< letter_type > word_type
Type for a word over the generators of a semigroup.
Definition types.hpp:101
Namespace for Presentation helper functions.
Definition obvinf.hpp:59
void change_alphabet(Presentation< Word > &, Word const &)
Change or re-order the alphabet.
bool is_acyclic(WordGraph< Node > const &wg)
Check if a word graph is acyclic.
Namespace for everything in the libsemigroups library.
Definition action.hpp:44