12#ifndef MCRL2_LPS_CONSTELM_H
13#define MCRL2_LPS_CONSTELM_H
24template <
typename DataRewriter,
typename Specification = specification>
41 const DataRewriter&
R;
54 for (
const auto& i :
sigma)
66 const std::string& msg =
""
73 <<
" value before: " << Rd_j <<
"\n"
74 <<
" value after: " << Rg_ij <<
"\n"
75 <<
" replacements: " <<
sigma << std::endl;
82 const std::string& msg =
""
103 if (!contains(global_variables, v))
142 const std::set<data::variable>& global_variables =
super::m_spec.global_variables();
153 std::set<data::variable> G(d.
begin(), d.
end());
154 std::set<data::variable> dG;
157 for (; di != d.
end(); ++di, ++ei)
172 std::map<data::variable, std::set<data::variable> > undo;
177 for (
const auto& summand: process.action_summands())
184 if (dG.find(j) != dG.end())
196 if (is_variable(z) && contains(global_variables, atermpp::down_cast<data::variable>(z)))
198 sigma[atermpp::down_cast<data::variable>(z)] = r[index_j];
199 undo[d_j].insert(atermpp::down_cast<data::variable>(z));
244 std::set<data::variable> constant_parameters;
245 for (
const auto& i:
sigma)
247 constant_parameters.insert(i.first);
259 void run(
bool instantiate_global_variables =
false,
bool ignore_conditions =
false)
270template <
typename DataRewriter,
typename Specification>
271void constelm(Specification& spec,
const DataRewriter& R,
bool instantiate_global_variables =
false)
274 algorithm.
run(instantiate_global_variables);
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.
Generic substitution function. The substitution is stored as a mapping of variables to expressions....
Algorithm class for elimination of constant parameters.
void LOG_PARAMETER_CHANGE(const data::data_expression &d_j, const data::data_expression &Rd_j, const data::data_expression &Rg_ij, const data::mutable_map_substitution<> &sigma, const std::string &msg="")
lps::detail::lps_algorithm< Specification > super
bool is_constant(const data::data_expression &x, const std::set< data::variable > &global_variables) const
void remove_parameters(data::mutable_map_substitution<> &sigma)
Applies the substitution computed by compute_constant_parameters.
const DataRewriter & R
The rewriter used by the constelm algorithm.
void LOG_CONSTANT_PARAMETERS(const data::mutable_map_substitution<> &sigma, const std::string &constant_removed_msg="", const std::string ¬hing_removed_msg="")
bool m_ignore_conditions
If true, conditions are not evaluated and assumed to be true.
constelm_algorithm(Specification &spec, const DataRewriter &R_)
Constructor.
void LOG_CONDITION(const data::data_expression &cond, const data::data_expression &c_i, const data::mutable_map_substitution<> &sigma, const std::string &msg="")
void run(bool instantiate_global_variables=false, bool ignore_conditions=false)
Runs the constelm algorithm.
std::map< data::variable, std::size_t > m_index_of
Maps process parameters to their index.
data::mutable_map_substitution compute_constant_parameters(bool instantiate_global_variables=false, bool ignore_conditions=false)
Computes constant parameters.
bool m_instantiate_global_variables
If true, then the algorithm is allowed to instantiate free variables as a side effect.
Algorithm class for algorithms on linear process specifications. It can be instantiated with lps::spe...
data::data_expression next_state(const action_summand &s, const data::variable &v) const
Applies the next state substitution to the variable v.
lps_algorithm(Specification &spec)
Constructor.
Specification & m_spec
The specification that is processed by the algorithm.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Add your file description here.
const function_symbol & false_()
Constructor for function symbol false.
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
std::string pp(const abstraction &x)
void remove_parameters(Object &x, const std::set< data::variable > &to_be_removed)
Rewrites an LPS data type.
void constelm(Specification &spec, const DataRewriter &R, bool instantiate_global_variables=false)
Removes zero or more constant parameters from the specification spec.
std::set< data::variable > find_free_variables(const lps::deadlock &x)
void rewrite(T &x, Rewriter R, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
bool contains(const atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable > &c, const typename atermpp::indexed_set< Key, ThreadSafe, Hash, Equals, Allocator, KeyTable >::key_type &v, const std::size_t thread_index=0)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...