12#ifndef MCRL2_PBES_PBESINST_ALGORITHM_H
13#define MCRL2_PBES_PBESINST_ALGORITHM_H
15#include "mcrl2/pbes/detail/bes_equation_limit.h"
16#include "mcrl2/pbes/detail/instantiate_global_variables.h"
17#include "mcrl2/pbes/rewriters/enumerate_quantifiers_rewriter.h"
18#include "mcrl2/pbes/rewriters/one_point_rule_rewriter.h"
19#include "mcrl2/pbes/rewriters/simplify_quantifiers_rewriter.h"
33 assert(v.size() == e.size());
34 data::variable_list::iterator i = v.begin();
35 data::data_expression_list::iterator j = e.begin();
36 for (; i != v.end(); ++i, ++j)
57 std::string name = Ye.name();
58 for (
const data::data_expression& exp: Ye.parameters())
60 if (is_function_symbol(exp) && exp.sort() != data::sort_pos::pos() && exp.sort() != data::sort_nat::nat())
66 name += atermpp::down_cast<data::function_symbol>(exp).name();
68 else if (is_function_symbol(exp) || is_application(exp) || is_abstraction(exp))
71 name += data::pp(exp);
75 throw mcrl2::runtime_error(std::string(
"pbesinst_rename_long: could not rename the variable ") + pbes_system::pp(Ye) +
" " + data::pp(exp));
133 if (size > 0 && size % 1000 == 0)
135 std::ostringstream out;
136 out <<
"Generated " << size <<
" BES equations" << std::endl;
155 data::rewriter::strategy rewrite_strategy =
data::jitty,
156 bool print_equations =
false)
170 pbes_system::detail::instantiate_global_variables(p);
181 for (pbes_equation& eqn: p.equations())
183 eqn.formula() = one_point_rule_rewriter(simplify_rewriter(eqn.formula()));
188 auto const& equations = p.equations();
189 for (
const pbes_equation& eqn : equations)
191 equation_index[eqn.variable().name()] = eqn_index++;
194 init = atermpp::down_cast<propositional_variable_instantiation>(R(p.initial_state()));
196 while (!todo.empty())
198 auto const& X_e = pick_element(todo);
200 int index = equation_index[X_e.name()];
201 const pbes_equation& eqn = p.equations()[index];
202 data::rewriter::substitution_type sigma;
203 make_pbesinst_substitution(eqn.variable().parameters(), X_e.parameters(), sigma);
204 auto const& phi = eqn.formula();
205 pbes_expression psi_e = R(phi, sigma);
206 R.clear_identifier_generator();
207 for (
const propositional_variable_instantiation& v: find_propositional_variable_instantiations(psi_e))
209 if (!contains(done, v))
214 pbes_equation new_eqn(eqn.symbol(), propositional_variable(pbesinst_rename()(X_e).name(), data::variable_list()), rho(psi_e));
215 if (m_print_equations)
217 mCRL2log(log::info) << eqn.symbol() <<
" " << X_e <<
" = " << psi_e << std::endl;
219 E[index].push_back(new_eqn);
220 mCRL2log(log::verbose) << print_equation_count(++m_equation_count);
221 detail::check_bes_equation_limit(m_equation_count);
230 for (
const std::vector<pbes_equation>& equations: E)
232 result.equations().insert(result.equations().end(), equations.begin(), equations.end());
Rewriter that operates on data expressions.
A rewriter that applies one point rule quantifier elimination to a PBES.
parameterized boolean equation system
propositional_variable_instantiation & initial_state()
Returns the initial state.
Algorithm class for the pbesinst instantiation algorithm.
std::map< core::identifier_string, int > equation_index
A lookup map for PBES equations.
propositional_variable_instantiation init
The initial value.
enumerate_quantifiers_rewriter & rewriter()
void run(pbes &p)
Runs the algorithm. The result is obtained by calling the function get_result.
bool m_print_equations
Print the equations to standard out.
std::set< propositional_variable_instantiation > done
Propositional variable instantiations that have been handled.
std::size_t m_equation_count
The number of generated equations.
std::string print_equation_count(std::size_t size) const
Prints a log message for every 1000-th equation.
pbes_expression rho(const pbes_expression &x) const
bool & print_equations()
Returns the flag for printing the generated bes equations.
enumerate_quantifiers_rewriter R
The rewriter.
pbes get_result()
Returns the computed bes in pbes format.
data::rewriter datar
Data rewriter.
std::set< propositional_variable_instantiation > todo
Propositional variable instantiations that need to be handled.
pbesinst_algorithm(data::data_specification const &data_spec, data::rewriter::strategy rewrite_strategy=data::jitty, bool print_equations=false)
Constructor.
\brief A propositional variable instantiation
propositional_variable_instantiation(const core::identifier_string &name, const data::data_expression_list ¶meters)
Constructor.
propositional_variable_instantiation & operator=(propositional_variable_instantiation &&) noexcept=default
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
void make_pbesinst_substitution(const data::variable_list &v, const data::data_expression_list &e, data::rewriter::substitution_type &sigma)
Creates a substitution function for the pbesinst rewriter.
bool pbesinst_is_constant(const pbes_expression &x)
An attempt for improving the efficiency.
Creates a unique name for a propositional variable instantiation. The propositional variable instanti...
core::identifier_string operator()(const propositional_variable_instantiation &Ye) const
Creates a unique name for a propositional variable instantiation. The propositional variable instanti...
propositional_variable_instantiation operator()(const propositional_variable_instantiation &Ye) const
A rewriter that simplifies boolean expressions and quantifiers, and rewrites data expressions.