12#ifndef MCRL2_LPS_SUMINST_H
13#define MCRL2_LPS_SUMINST_H
15#include "mcrl2/atermpp/set_operations.h"
17#include "mcrl2/data/enumerator.h"
19#include "mcrl2/lps/detail/lps_algorithm.h"
28 const std::set<data::sort_expression>& sorts = s.sorts();
29 std::set<data::sort_expression> result;
31 for(
const data::sort_expression& sort : sorts)
33 if(s.is_certainly_finite(sort))
41template<
typename DataRewriter,
typename Specification>
46 using process_type =
typename Specification::process_type;
47 using action_summand_type =
typename process_type::action_summand_type;
68 template <
typename SummandType,
typename Container>
72 std::size_t nr_summands = 0;
73 std::deque< variable > variables;
76 for (
const variable& v: s.summation_variables())
78 if(m_sorts.find(v.sort()) != m_sorts.end())
80 if (m_spec.data().is_certainly_finite(v
.sort()))
82 variables.push_front(v);
86 variables.push_back(v);
91 if (variables.empty())
101 const variable_list vl(variables.begin(),variables.end());
102 variable_list new_summation_variables = term_list_difference(s.summation_variables(), vl);
106 mCRL2log(log::log_level_t::debug) <<
"enumerating variables " << vl <<
" in condition: " << data::pp(s.condition()) << std::endl;
107 data::mutable_indexed_substitution<> local_sigma;
108 m_enumerator.enumerate(enumerator_element(vl, s.condition()),
110 [&](
const enumerator_element& p)
112 mutable_indexed_substitution<> sigma;
113 p.add_assignments(vl, sigma, m_rewriter);
114 mCRL2log(log::log_level_t::debug) <<
"substitutions: " << sigma << std::endl;
116 t.summation_variables() = new_summation_variables;
117 lps::rewrite(t, m_rewriter, sigma);
122 sort_bool::is_false_function_symbol
130 mCRL2log(log::log_level_t::debug) <<
"An error occurred in enumeration, removing already added summands, and keeping the original" << std::endl;
131 mCRL2log(log::log_level_t::debug) << e.what() << std::endl;
133 result.resize(result.size() - nr_summands);
151 template <
typename SummandListType,
typename Container>
152 void run(
const SummandListType& list, Container& result)
154 for (
typename SummandListType::const_iterator i = list.begin(); i != list.end(); ++i)
156 if (must_instantiate(*i))
158 std::size_t newsummands = instantiate_summand(*i, result);
161 m_added += newsummands - 1;
170 result.push_back(*i);
173 mCRL2log(log::log_level_t::status) <<
"Replaced " << m_processed <<
" summands by " << (m_processed + m_added - m_deleted)
174 <<
" summands (" << m_deleted <<
" were deleted)" << std::endl;
182 bool tau_summands_only =
false)
191 mCRL2log(log::log_level_t::info) <<
"an empty set of sorts to be unfolded was provided; defaulting to all finite sorts" << std::endl;
192 m_sorts = finite_sorts(spec.data());
198 action_summand_vector_type action_summands;
199 deadlock_summand_vector deadlock_summands;
203 run(m_spec.process().action_summands(), action_summands);
204 run(m_spec.process().deadlock_summands(), deadlock_summands);
205 m_spec.process().action_summands().swap(action_summands);
206 m_spec.process().deadlock_summands().swap(deadlock_summands);
207 mCRL2log(log::log_level_t::status) << std::endl;
const sort_expression & sort() const
LPS summand containing a deadlock.
Algorithm class for algorithms on linear process specifications. It can be instantiated with lps::spe...
DataRewriter m_rewriter
Rewriter.
void run(const SummandListType &list, Container &result)
std::set< data::sort_expression > m_sorts
Sorts to be instantiated.
data::enumerator_identifier_generator m_id_generator
data::enumerator_algorithm m_enumerator
std::size_t instantiate_summand(const SummandType &s, Container &result)
std::size_t m_processed
Statistiscs for verbose output.
bool must_instantiate(const action_summand_type &summand)
bool must_instantiate(const deadlock_summand &)
suminst_algorithm(Specification &spec, DataRewriter &r, std::set< data::sort_expression > sorts=std::set< data::sort_expression >(), bool tau_summands_only=false)
bool m_tau_summands_only
Only instantiate tau summands.
Standard exception class for reporting runtime errors.
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
The main namespace for the LPS library.
std::set< data::sort_expression > finite_sorts(const data::data_specification &s)
Return a set with all finite sorts in data specification s.