12#ifndef MCRL2_DATA_ENUMERATOR_WITH_ITERATOR_H
13#define MCRL2_DATA_ENUMERATOR_WITH_ITERATOR_H
39template <
typename Rewriter = data::rewriter,
typename DataRewriter = data::rewriter>
54 template <
typename EnumeratorListElement>
65 template <
typename EnumeratorListElement,
typename MutableSubstitution,
typename Filter,
typename Expression>
67 MutableSubstitution&
sigma,
70 const Expression& phi,
71 const EnumeratorListElement& p,
78 P.
push_back(EnumeratorListElement(variables, phi1, p, v, e));
83 template <
typename EnumeratorListElement,
typename MutableSubstitution,
typename Filter,
typename Expression>
85 MutableSubstitution&
sigma,
89 const Expression& phi,
90 const EnumeratorListElement& p,
98 P.
push_back(EnumeratorListElement(variables + added_variables, phi1, p, v, e));
104 template <
typename MutableSubstitution,
typename Filter,
typename Expression>
106 MutableSubstitution&
sigma,
110 const Expression& phi,
135 const DataRewriter&
r,
137 std::size_t
max_count = (std::numeric_limits<std::size_t>::max)(),
145 template <
typename T>
156 template <
typename EnumeratorListElement,
typename MutableSubstitution,
typename Filter>
162 const auto& v = p.variables();
163 const auto& phi = p.expression();
167 const auto& v1 = v.front();
168 const auto& v_tail = v.tail();
169 const auto& v1_sort = v1.sort();
173 const function_sort& function = atermpp::down_cast<function_sort>(v1_sort);
190 sigma[v1] = sigma_v1;
199 const sort_expression& element_sort = atermpp::down_cast<container_sort>(v1_sort).element_sort();
208 sigma[v1] = sigma_v1;
218 const auto& fset = atermpp::down_cast<container_sort>(v1_sort);
234 sigma[v1] = sigma_v1;
261 auto const& domain = atermpp::down_cast<data::function_sort>(c.sort()).domain();
272 const auto e1 =
r(c,
sigma);
294 template <
typename EnumeratorListElement,
typename MutableSubstitution,
typename Filter>
297 std::size_t count = 0;
304 if (P.
front().is_solution())
323template <
typename Rewriter = data::rewriter,
typename EnumeratorListElement = enumerator_list_element_with_substitution<>,
typename Filter = data::is_not_false,
typename DataRewriter = data::rewriter,
typename MutableSubstitution = data::mutable_indexed_substitution<> >
336 class iterator:
public boost::iterator_facade<iterator, const EnumeratorListElement, boost::forward_traversal_tag>
347#ifdef MCRL2_ENABLE_MULTITHREADING
361 MutableSubstitution* sigma_,
362 Filter accept_ = Filter()
385 std::ostringstream out;
386 out <<
"enumeration was aborted, since it did not complete within " <<
E->
max_count() <<
" iterations";
399 return P->size() == other.
P->size();
412 const DataRewriter& datar,
414 std::size_t
max_count = (std::numeric_limits<std::size_t>::max)(),
416 const Filter& f = Filter())
427 assert(P.
size() == 1);
442#ifdef MCRL2_ENABLE_MULTITHREADING
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
An abstraction expression.
An application of a data expression to a number of arguments.
const sort_expression & element_sort() const
bool is_certainly_finite(const sort_expression &s) const
Checks whether a sort is certainly finite.
const function_symbol_vector & constructors() const
Gets all constructors including those that are system defined.
A class to enumerate solutions for terms.
enumerator_algorithm_with_iterator< Rewriter, EnumeratorListElement, Filter, DataRewriter, MutableSubstitution > * E
enumerator_queue< EnumeratorListElement > * P
bool equal(iterator const &other) const
static enumerator_queue< EnumeratorListElement > & default_deque()
const EnumeratorListElement & dereference() const
iterator(enumerator_algorithm_with_iterator< Rewriter, EnumeratorListElement, Filter, DataRewriter, MutableSubstitution > *E_, enumerator_queue< EnumeratorListElement > *P_, MutableSubstitution *sigma_, Filter accept_=Filter())
iterator(Filter accept_=Filter())
MutableSubstitution * sigma
friend class boost::iterator_core_access
An enumerator algorithm with an iterator interface.
enumerator_algorithm_without_callback< Rewriter, DataRewriter > super
iterator begin(MutableSubstitution &sigma, enumerator_queue< EnumeratorListElement > &P)
Returns an iterator that enumerates solutions for variables that satisfy a condition.
enumerator_algorithm_with_iterator(const Rewriter &R, const data::data_specification &dataspec, const DataRewriter &datar, enumerator_identifier_generator &id_generator, std::size_t max_count=(std::numeric_limits< std::size_t >::max)(), bool throw_exceptions=false, const Filter &f=Filter())
An enumerator algorithm that generates solutions of a condition.
void add_element(enumerator_queue< EnumeratorListElement > &P, MutableSubstitution &sigma, Filter accept, const data::variable_list &variables, const data::variable_list &added_variables, const Expression &phi, const EnumeratorListElement &p, const data::variable &v, const data::data_expression &e) const
void add_element(enumerator_queue< enumerator_list_element< Expression > > &P, MutableSubstitution &sigma, Filter accept, const data::variable_list &variables, const data::variable_list &added_variables, const Expression &phi, const enumerator_list_element< Expression > &p, const data::variable &v, const data::data_expression &e) const
enumerator_algorithm< Rewriter, DataRewriter > super
std::size_t next(enumerator_queue< EnumeratorListElement > &P, MutableSubstitution &sigma, Filter accept) const
Enumerates the front elements of the todo list P until a solution has been found, or until P is empty...
bool throw_exceptions() const
enumerator_algorithm_without_callback(const enumerator_algorithm< Rewriter, DataRewriter > &)=delete
void step(enumerator_queue< EnumeratorListElement > &P, MutableSubstitution &sigma, Filter accept) const
Enumerates the front element of the todo list P.
bool m_throw_exceptions
throw_exceptions If true, an exception is thrown when the enumeration is aborted.
void add_element(enumerator_queue< EnumeratorListElement > &P, MutableSubstitution &sigma, Filter accept, const data::variable_list &variables, const Expression &phi, const EnumeratorListElement &p, const data::variable &v, const data::data_expression &e) const
enumerator_algorithm_without_callback(const Rewriter &R, const data::data_specification &dataspec, const DataRewriter &r, enumerator_identifier_generator &id_generator, std::size_t max_count=(std::numeric_limits< std::size_t >::max)(), bool throw_exceptions=false)
void cannot_enumerate(EnumeratorListElement &e, const std::string &msg) const
An enumerator algorithm that generates solutions of a condition.
enumerator_identifier_generator & id_generator
std::size_t m_max_count
max_count The enumeration is aborted after max_count iterations
std::size_t max_count() const
const data::data_specification & dataspec
A data specification.
Expression rewrite(const Expression &phi, MutableSubstitution &sigma) const
The default element for the todo list of the enumerator.
Contains the enumerator queue.
atermpp::deque< EnumeratorListElement >::size_type size() const
void push_back(const EnumeratorListElement &x)
const EnumeratorListElement & front() const
\brief Binder for lambda abstraction
Standard exception class for reporting runtime errors.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
bool compute_finite_function_sorts(const function_sort &sort, enumerator_identifier_generator &id_generator, const data::data_specification &dataspec, Rewriter datar, data_expression_vector &result, variable_list &function_parameter_list)
Computes the elements of a finite function sort, and puts them in result. If there are too many eleme...
bool compute_finite_set_elements(const container_sort &sort, const data_specification &dataspec, Rewriter datar, MutableSubstitution &sigma, data_expression_vector &result, enumerator_identifier_generator &id_generator)
Computes the elements of a finite set sort, and puts them in result. If there are too many elements,...
bool is_bag(const sort_expression &e)
Recogniser for sort expression Bag(s)
bool is_false_function_symbol(const atermpp::aterm &e)
Recogniser for function false.
const function_symbol & false_()
Constructor for function symbol false.
bool is_true_function_symbol(const atermpp::aterm &e)
Recogniser for function true.
bool is_fbag(const sort_expression &e)
Recogniser for sort expression FBag(s)
bool is_fset(const sort_expression &e)
Recogniser for sort expression FSet(s)
container_sort fset(const sort_expression &s)
Constructor for sort expression FSet(S)
bool is_set(const sort_expression &e)
Recogniser for sort expression Set(s)
function_symbol constructor(const sort_expression &s)
Constructor for function symbol @set.
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
std::string pp(const abstraction &x)
bool is_function_sort(const atermpp::aterm &x)
Returns true if the term t is a function sort.
std::vector< function_symbol > function_symbol_vector
\brief vector of function_symbols
static constexpr bool GlobalThreadSafe
Enables thread safety for the whole toolset.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
bool operator()(const T &)
bool operator()(const data_expression &x) const
bool operator()(const data_expression &x) const