19#ifndef LIBSEMIGROUPS_STEPHEN_HPP_
20#define LIBSEMIGROUPS_STEPHEN_HPP_
31#include "constants.hpp"
34#include "exception.hpp"
36#include "presentation.hpp"
39#include "word-graph.hpp"
41#include "detail/felsch-graph.hpp"
42#include "detail/node-managed-graph.hpp"
43#include "detail/node-manager.hpp"
44#include "detail/report.hpp"
45#include "detail/string.hpp"
46#include "detail/word-graph-with-sources.hpp"
89 template <
typename PresentationType>
92 static constexpr bool is_valid_presentation() {
93 return std::is_same_v<Q, Presentation<word_type>>
94 || std::is_same_v<Q, InversePresentation<word_type>>;
103 static_assert(is_valid_presentation<PresentationType>(),
104 "the template parameter PresentationType must be "
105 "Presentation<word_type> or InversePresentation<word_type>");
125 StephenGraph _word_graph;
257 return *_presentation;
275 template <
typename Iterator1,
typename Iterator2>
277 presentation().throw_if_letter_not_in_alphabet(first, last);
296 template <
typename Iterator1,
typename Iterator2>
322 throw_if_not_ready();
338 throw_if_not_ready();
414 void report_before_run();
415 void report_after_run();
417 Stephen& init_after_presentation_set();
419 if (p.alphabet().empty()) {
423 void throw_if_not_ready()
const;
424 void init_word_graph_from_word_no_checks() {
426 _word_graph.report_prefix(
"Stephen");
427 _word_graph.complete_path(
430 _word_graph.number_of_active_nodes(_word_graph.number_of_nodes_active());
433 void run_impl()
override;
434 void really_run_impl();
436 bool finished_impl() const noexcept
override {
442 _word_graph.induced_subgraph_no_checks(
443 0, _word_graph.number_of_nodes_active());
587 template <
typename PresentationType>
614 template <
typename PresentationType>
643 template <
typename PresentationType>
673 template <
typename PresentationType>
719 template <
typename PresentationType>
756 template <
typename PresentationType>
775 template <
typename PresentationType>
791 template <
typename PresentationType>
811 template <
typename PresentationType>
838 template <
typename PresentationType>
843 "x.presentation() must equal y.presentation() when comparing "
870 template <
typename PresentationType>
886 template <
typename PresentationType>
891#include "stephen.tpp"
A representation of a graph in the DOT language of Graphviz.
Definition dot.hpp:115
For an implementation of inverse presentations for semigroups or monoids.
Definition presentation.hpp:2188
Range for iterating through paths in a WordGraph.
Definition paths.hpp:601
uint64_t number_of_paths(WordGraph< Node1 > const &wg, Node2 source)
For an implementation of presentations for semigroups or monoids.
Definition presentation.hpp:102
void run()
Run until finished.
Runner()
Default constructor.
For constructing the word graph of left factors of a word in an f.p. semigroup.
Definition stephen.hpp:90
Stephen & operator=(Stephen const &)=default
Default copy assignment operator.
Stephen(PresentationType const &p)
Construct from a presentation (copy).
Definition stephen.hpp:163
WordGraph< uint32_t > word_graph_type
The return type of the function word_graph.
Definition stephen.hpp:112
presentation_type const & presentation() const noexcept
Get the input presentation.
Definition stephen.hpp:256
Stephen & operator=(Stephen &&)=default
Default move assignment operator.
Stephen & init(std::shared_ptr< PresentationType > const &ptr)
Initialize from a shared pointer to presentation (copy).
node_type accept_state()
Get the accept state of the word graph.
Stephen & set_word(Iterator1 first, Iterator2 last)
Set the initial word.
Definition stephen.hpp:276
bool is_word_set() const noexcept
Check if the initial word is set.
Definition stephen.hpp:308
Stephen & init(PresentationType &&p)
Initialize from a presentation (move).
Definition stephen.hpp:231
PresentationType presentation_type
The underlying presentation type.
Definition stephen.hpp:109
Stephen(PresentationType &&p)
Construct from a presentation (move).
Definition stephen.hpp:175
Stephen(Stephen const &that)=default
Default copy constructor.
Stephen & init(PresentationType const &p)
Initialize from a presentation (copy).
Definition stephen.hpp:216
Stephen(std::shared_ptr< PresentationType > const &ptr)
Construct from a shared pointer to presentation (copy).
Definition stephen.hpp:187
word_type const & word() const
Get the initial word.
Definition stephen.hpp:321
void append_no_checks(Stephen< PresentationType > &that)
Append a Stephen instance (no checks).
Stephen & init()
Reinitialize an existing Stephen instance.
Stephen(Stephen &&)=default
Default move constructor.
static constexpr node_type initial_state() noexcept
Get the initial state of the word graph.
Definition stephen.hpp:367
Stephen()
Default constructor.
word_graph_type const & word_graph() const
Get the word graph.
Definition stephen.hpp:337
word_graph_type::node_type node_type
The node type of word_graph_type.
Definition stephen.hpp:114
Stephen & set_word_no_checks(Iterator1 first, Iterator2 last)
Set the initial word (no checks).
void operator*=(Stephen< PresentationType > &that)
Append a Stephen instance.
Class for representing word graphs.
Definition word-graph.hpp:82
uint32_t node_type
Definition word-graph.hpp:98
std::string to_human_readable_repr(AhoCorasick const &ac)
Return a string representation.
PositiveInfinity const POSITIVE_INFINITY
Value for positive infinity.
#define LIBSEMIGROUPS_EXCEPTION(...)
Throw a LibsemigroupsException.
Definition exception.hpp:95
bool operator==(Presentation< Word > const &lhop, Presentation< Word > const &rhop)
Compare for equality.
Definition presentation.hpp:2346
Stephen(Presentation< word_type > const &) -> Stephen< Presentation< word_type > >
Deduction guide.
std::vector< letter_type > word_type
Type for a word over the generators of a semigroup.
Definition types.hpp:101
Namespace containing helper functions for the Paths class.
Definition paths.hpp:56
Helper functions for the Stephen class.
Definition stephen.hpp:552
Dot dot(Stephen< PresentationType > &s)
Returns a Dot object representing the Stephen word graph.
auto words_accepted(Stephen< PresentationType > &s)
Returns a range object containing all words accepted by a Stephen instance in short-lex order.
Definition stephen.hpp:644
Stephen< PresentationType > & set_word(Stephen< PresentationType > &s, word_type const &w)
Set the initial word.
Definition stephen.hpp:792
bool is_left_factor(Stephen< PresentationType > &s, word_type const &w)
Check if a word is a left factor of Stephen::word.
auto left_factors(Stephen< PresentationType > &s)
Returns a range object containing all the words (in short-lex order) that are left factors of Stephen...
Definition stephen.hpp:674
uint64_t number_of_words_accepted(Stephen< PresentationType > &s, size_t min=0, size_t max=POSITIVE_INFINITY)
Returns the number of words accepted with length in a given range.
Definition stephen.hpp:720
bool accepts(Stephen< PresentationType > &s, word_type const &w)
Check if a word is accepted by a Stephen instance.
Stephen< PresentationType > & set_word_no_checks(Stephen< PresentationType > &s, word_type const &w)
Set the initial word (no checks).
Definition stephen.hpp:812
uint64_t number_of_left_factors(Stephen< PresentationType > &s, size_t min=0, size_t max=POSITIVE_INFINITY)
Returns the number of left factors with length in a given range.
Definition stephen.hpp:757
bool standardize(Graph &wg, Forest &f, Order val)
Standardizes a word graph in-place.
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
bool equal_to_no_checks(Stephen< PresentationType > const &x, Stephen< PresentationType > const &y)
Check equality of two Stephen instances (no checks).
Definition stephen.hpp:871