12#ifndef MCRL2_BES_SMALL_PROGRESS_MEASURES_H
13#define MCRL2_BES_SMALL_PROGRESS_MEASURES_H
16#define MCRL2_SMALL_PROGRESS_MEASURES_DEBUG
19#include "mcrl2/core/detail/print_utility.h"
20#include "mcrl2/pbes/find.h"
21#include "mcrl2/pbes/normal_forms.h"
22#include "mcrl2/pbes/print.h"
23#include "mcrl2/utilities/math.h"
28template <
typename InputIterator1,
typename InputIterator2>
30 InputIterator2 first2, InputIterator2 last2)
32 while (first1 != last1 && first2 != last2)
34 if (*first1 < *first2)
38 if (*first2 < *first1)
47 return !(first1 == last1);
66 for (
auto i = b.equations().begin(); i != b.equations().end(); ++i)
68 if (i == b.equations().begin())
70 result = i->symbol().is_nu() ? 0 : 1;
72 else if (i->symbol() != last_symbol)
76 last_symbol = i->symbol();
105 out << core::detail::print_list(pm.v);
162 bool operator()(
const progress_measures_vertex* x,
const progress_measures_vertex* y)
const
164 if (x->alpha.is_top())
168 else if (y->alpha.is_top())
172 int n = lexicographical_compare_3way(x->alpha.v.begin(), x->alpha.v.begin() + m + 1, y->alpha.v.begin(), y->alpha.v.begin() + m + 1);
180 out <<
" alpha = " << v.alpha;
181 out <<
" successors = {";
182 for (
auto i = v.successors.begin(); i != v.successors.end(); ++i)
184 if (i != v.successors.begin())
188 out << std::string((*i)->name);
191 out <<
" rank = " << v.rank;
192 out <<
" disjunctive = " << std::boolalpha << v.even;
207 unsigned int block_size = 0;
210 for (
const pbes_equation& eqn: m_bes.equations())
212 if (eqn.symbol() != last_symbol)
214 if (utilities::is_even(m_beta.size()))
220 m_beta.push_back(
static_cast<
int>(block_size));
224 last_symbol = eqn.symbol();
227 m_vertices[propositional_variable_instantiation(eqn.variable().name())] = vertex(is_disjunctive(eqn.formula()), last_rank, m_d);
229 if (utilities::is_even(m_beta.size()))
235 m_beta.push_back(
static_cast<
int>(block_size));
239 for (
const pbes_equation& eqn: m_bes.equations())
241 std::set<propositional_variable_instantiation> succ = pbes_system::find_propositional_variable_instantiations(eqn.formula());
242 auto k = m_vertices.find(propositional_variable_instantiation(eqn.variable().name()));
243 std::vector<vertex*>& k_successors = k->second.successors;
244 for (
const propositional_variable_instantiation& v: succ)
246 k_successors.push_back(&m_vertices[v]);
250 k->second.name = std::string(eqn.variable().name());
257 std::ostringstream out;
258 for (
const pbes_equation& eqn: m_bes.equations())
260 const vertex& v = m_vertices.find(propositional_variable_instantiation(eqn.variable().name()))->second;
261 out << v.name <<
" " << v << std::endl;
268 std::ostringstream out;
269 out << v.name <<
" (alpha = " << v.alpha <<
", rank = " << v.rank <<
")";
276 std::ostringstream out;
277 for (progress_measures_vertex* successor: v.successors)
279 out <<
"\n " << print_vertex(*successor);
296 mCRL2log(log::verbose) <<
"Applying small progress measures.\n";
297 mCRL2log(log::debug) <<
"BES " << pbes_system::pp(m_bes) <<
"\n\n";
299 mCRL2log(log::debug) <<
"--- vertices ---\n" << print_vertices();
300 mCRL2log(log::debug) <<
"\nbeta = " << core::detail::print_list(m_beta) <<
"\n";
303 bool changed =
false;
304 for (
auto &i: m_vertices)
306 vertex& v = i.second;
307 mCRL2log(log::debug) <<
"\nchoose vertex " << print_vertex(v);
309 std::vector<progress_measures_vertex*>::const_iterator j;
310 mCRL2log(log::debug) <<
"\n neighbors:" << print_neighbors(v);
313 j = std::min_element(v.successors.begin(), v.successors.end(), compare_progress_measures_vertex(m));
314 mCRL2log(log::debug) <<
"\n minimum neighbor " << print_vertex(**j);
318 j = std::max_element(v.successors.begin(), v.successors.end(), compare_progress_measures_vertex(m));
319 mCRL2log(log::debug) <<
"\n maximum neighbor " << print_vertex(**j);
321 std::vector<
int> alpha(m_d, 0);
322 const progress_measures_vertex& w = **j;
323 std::copy(w.alpha.v.begin(), w.alpha.v.begin() + m + 1, alpha.begin());
324 if (utilities::is_odd(m))
326 mCRL2log(log::debug) <<
"\n inc(" << core::detail::print_list(alpha) <<
", " << std::to_string(m) <<
") = ";
327 inc(alpha, m, m_beta);
328 mCRL2log(log::debug) << (alpha[0] < 0 ?
"top" : core::detail::print_list(alpha));
331 if (!std::equal(alpha.begin(), alpha.end(), v.alpha.v.begin()))
335 mCRL2log(log::debug) <<
"\nupdate vertex " << print_vertex(v);
343 mCRL2log(log::debug) <<
"\n--- vertices ---\n" << print_vertices();
344 return !m_vertices[first_variable].alpha.is_top();
352 assert(b.equations().front().variable().parameters().empty());
355 return algorithm
.run(first
);
static fixpoint_symbol nu()
Returns the nu symbol.
parameterized boolean equation system
\brief A propositional variable instantiation
Algorithm class for the small progress measures algorithm.
bool run(const propositional_variable_instantiation &first_variable)
small_progress_measures_algorithm(const pbes &b)
std::vector< int > m_beta
std::string print_vertices() const
std::string print_vertex(const vertex &v) const
std::string print_neighbors(const progress_measures_vertex &v) const
Logs the neighbors of a vertex.
void initialize_vertices()
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
int lexicographical_compare_3way(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2)
bool is_or(const atermpp::aterm &x)
int maximum_rank(const pbes &b)
bool is_disjunctive(const pbes_expression &x)
void inc(std::vector< int > &alpha, int m, const std::vector< int > &beta)
std::ostream & operator<<(std::ostream &out, const progress_measures_vertex &v)
std::ostream & operator<<(std::ostream &out, const progress_measure &pm)
bool small_progress_measures(pbes &b)
void make_standard_form(pbes &eqn, bool recursive_form=false)
Transforms a PBES into standard form.
#define MCRL2_SMALL_PROGRESS_MEASURES_DEBUG
compare_progress_measures_vertex(unsigned int m_)
bool operator()(const progress_measures_vertex *x, const progress_measures_vertex *y) const
progress_measure(std::size_t d)