12#ifndef MCRL2_LPS_BINARY_H
13#define MCRL2_LPS_BINARY_H
43template<
typename DataRewriter,
typename Specification>
82 if (new_parameters.empty())
84 result = enumerated_elements.front();
88 std::size_t n = enumerated_elements.
size();
89 std::size_t m =
static_cast<std::size_t
>(1) << (new_parameters.size() - 1);
108 new_parameters.pop_back();
109 result = if_(condition,
122 bool use_selection = !parameter_selection.empty();
124 std::list<data::variable> selected_params;
129 selected_params = std::list<data::variable>(sel.begin(), sel.end());
133 selected_params = std::list<data::variable>(process_parameters.
begin(), process_parameters.
end());
138 if (cannot_replace && use_selection)
140 mCRL2log(
log::info) <<
"Not selecting " << v <<
":" << v.
sort() <<
" since it is already Bool, or its type is not finite." << std::endl;
142 return cannot_replace;
146 if (use_selection && selected_params.empty())
148 mCRL2log(
log::info) <<
"No parameters were selected to be replaced." << std::endl;
151 return std::set<data::variable>(selected_params.begin(), selected_params.end());
170 bool accept_solutions_with_variables =
false;
176 if (selected_params.find(par) != selected_params.end())
187 p.add_assignments(vl, local_sigma,
m_rewriter);
188 enumerated_elements.push_back(local_sigma(par));
198 std::string par_name = par.name();
203 for (std::size_t i = 0; i<n; ++i)
206 new_parameters.push_back(v);
207 new_pars.push_back(v);
217 enumerated_elements);
221 new_parameters.push_back(par);
260 mCRL2log(
log::debug) <<
"Found " << new_parameters.size() <<
" new parameter(s) for parameter " <<
data::pp(par) << std::endl;
262 for (std::size_t j = 0; j < new_parameters.size(); ++j)
266 data::data_expression_vector::iterator k = elements.begin();
267 while (k != elements.end())
270 std::ptrdiff_t count(
static_cast<std::ptrdiff_t
>(1) << j);
271 if (std::distance(k, elements.end()) < count)
277 std::advance(k, count);
281 for (std::ptrdiff_t l = 0; l < count && k != elements.
end(); ++l)
317 mCRL2log(
log::debug) <<
"Found " << new_parameters.size() <<
" new parameter(s) for parameter " <<
data::pp(a.lhs()) << std::endl;
319 for (std::size_t j = 0; j < new_parameters.size(); ++j)
323 data::data_expression_vector::iterator k = elements.begin();
324 while (k != elements.end())
327 std::ptrdiff_t count(
static_cast<std::ptrdiff_t
>(1) << j);
328 if (std::distance(k, elements.end()) < count)
334 std::advance(k, count);
338 for (std::ptrdiff_t l = 0; l < count && k != elements.
end(); ++l)
397 const std::string parameter_selection =
"")
size_type size() const
Returns the number of arguments of this term.
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.
\brief Assignment of a data expression to a variable
const_iterator end() const
An enumerator algorithm that generates solutions of a condition.
std::size_t enumerate(const EnumeratorListElement &p, MutableSubstitution &sigma, ReportSolution report_solution, Reject reject=Reject(), Accept accept=Accept()) const
Enumerates the element p. Solutions are reported using the callback function report_solution....
An element for the todo list of the enumerator that collects the substitution corresponding to the ex...
void add_identifiers(const std::set< core::identifier_string > &ids)
Add a set of identifiers to the context.
Generic substitution function.
Generic substitution function. The substitution is stored as a mapping of variables to expressions....
Identifier generator that stores the identifiers of the context in a set. Using the operator()() and ...
void add_identifier(const core::identifier_string &s) override
Adds the identifier s to the context.
const sort_expression & sort() const
LPS summand containing a multi-action.
const lps::multi_action & multi_action() const
Returns the multi-action of this summand.
const data::assignment_list & assignments() const
Returns the sequence of assignments.
Algorithm class that can be used to apply the binary algorithm.
data::assignment_list replace_enumerated_parameters_in_assignments(data::assignment_list v)
Replace assignments in v that are of a finite sort with a vector of assignments to Boolean variables.
data::data_expression make_if_tree(data::variable_vector new_parameters, const data::data_expression_vector &enumerated_elements)
Build an if-then-else tree of enumerated elements in terms of new parameters.
binary_algorithm(Specification &spec, DataRewriter &r, const std::string parameter_selection="")
Constructor for binary algorithm.
void update_deadlock_summand(deadlock_summand &s)
Update a deadlock summand with the new Boolean parameters.
detail::lps_algorithm< Specification > super
std::map< data::variable, std::vector< data::data_expression > > m_enumerated_elements
Mapping of variables to all values they can be assigned.
stochastic_process_initializer update_initial_process(const data::variable_list ¶meters, const stochastic_process_initializer &init)
Specification::process_type process_type
data::set_identifier_generator m_if_trees_generator
Contains the names of variables appearing in rhs of m_if_trees.
const std::string m_parameter_selection
void replace_enumerated_parameters(const std::set< data::variable > &selected_params)
Take a specification and calculate a vector of boolean variables for each process parameter in select...
data::data_expression_list replace_enumerated_parameters_in_initial_expressions(const data::variable_list &vl, const data::data_expression_list &el)
Replace expressions in v that are of a finite sort with a vector of assignments to Boolean variables.
void update_action_summand(action_summand &s)
Update an action summand with the new Boolean parameters.
std::set< data::variable > select_parameters(const std::string parameter_selection) const
Determine which variables should be replaced, based on parameter_selection.
void run()
Apply the algorithm to the specification passed in the constructor.
process_type::action_summand_type action_summand_type
data::mutable_map_substitution m_if_trees
Mapping of variables to corresponding if-tree.
process_initializer update_initial_process(const data::variable_list ¶meters, const process_initializer &init)
DataRewriter m_rewriter
Rewriter.
std::map< data::variable, std::vector< data::variable > > m_new_parameters
Mapping of finite variables to boolean vectors.
void update_action_summand(stochastic_action_summand &s)
Update an action summand with the new Boolean parameters.
data::enumerator_list_element_with_substitution enumerator_element
data::enumerator_identifier_generator m_id_generator
Identifier generator for the enumerator.
LPS summand containing a deadlock.
const lps::deadlock & deadlock() const
Returns the deadlock of this summand.
Algorithm class for algorithms on linear process specifications. It can be instantiated with lps::spe...
lps_algorithm(Specification &spec)
Constructor.
Specification & m_spec
The specification that is processed by the algorithm.
LPS summand containing a multi-action.
const stochastic_distribution & distribution() const
Returns the distribution of this summand.
\brief A stochastic distribution
A stochastic process initializer.
const data::data_expression & condition() const
Returns the condition expression.
MCRL2_EXPORT bool init(rewriter_interface *i, RewriterCompilingJitty *this_rewriter)
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Add your file description here.
data_expression join_or(ForwardTraversalIterator first, ForwardTraversalIterator last)
Returns or applied to the sequence of data expressions [first, last)
const basic_sort & bool_()
Constructor for sort expression Bool.
const function_symbol & true_()
Constructor for function symbol true.
std::vector< assignment > assignment_vector
\brief vector of assignments
std::set< data::variable > substitution_variables(const Substitution &)
Returns the variables appearing in the right hand sides of the substitution.
std::vector< variable > variable_vector
\brief vector of variables
std::vector< data_expression > data_expression_vector
\brief vector of data_expressions
std::string pp(const abstraction &x)
atermpp::term_list< data_expression > data_expression_list
\brief list of data_expressions
atermpp::term_list< variable > variable_list
\brief list of variables
std::set< core::identifier_string > function_and_mapping_identifiers(const data_specification &dataspec)
Returns the names of functions and mappings that occur in a data specification.
void replace_variables_capture_avoiding(T &x, Substitution &sigma, data::set_identifier_generator &id_generator, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
atermpp::term_list< assignment > assignment_list
\brief list of assignments
function_symbol equal_to(const sort_expression &s)
Constructor for function symbol ==.
void replace_variables(T &x, const Substitution &sigma, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
std::vector< data::variable > parse_lps_parameter_selection(const data::variable_list ¶ms, const data::data_specification &dataspec, const std::string &text)
Parses parameter selection for finite pbesinst algorithm.
void replace_variables_capture_avoiding(T &x, Substitution &sigma, data::set_identifier_generator &id_generator, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
std::size_t nr_of_booleans_for_elements(std::size_t n)
void find_identifiers(const T &x, OutputIterator o)
std::size_t ceil_log2(std::size_t n)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...