mCRL2
Loading...
Searching...
No Matches
sumelm.h
Go to the documentation of this file.
1// Author(s): Jeroen Keiren, Thomas Neele
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
17
18#ifndef MCRL2_LPS_SUMELM_H
19#define MCRL2_LPS_SUMELM_H
20
23#include "mcrl2/lps/decluster.h"
24
25namespace mcrl2
26{
27namespace lps
28{
29
31template <typename Specification = specification>
32class sumelm_algorithm: public detail::lps_algorithm<Specification>
33{
35 using super::m_spec;
36
37 protected:
39 std::size_t m_removed;
40
43
44 public:
50 sumelm_algorithm(Specification& spec, bool decluster = false)
51 : lps::detail::lps_algorithm<Specification>(spec),
52 m_removed(0),
53 m_decluster(decluster)
54 {}
55
58 void run()
59 {
60 if (m_decluster)
61 {
62 // First decluster specification
64 }
65
66 m_removed = 0; // Re-initialise number of removed variables for a fresh run.
67
68 for (action_summand& s: m_spec.process().action_summands())
69 {
70 (*this)(s);
71 }
72
73 for (deadlock_summand& s: m_spec.process().deadlock_summands())
74 {
75 (*this)(s);
76 }
77
78 mCRL2log(log::verbose) << "Removed " << m_removed << " summation variables" << std::endl;
79 }
80
83 template <class Summand>
84 void operator()(Summand& s)
85 {
86 std::map<data::variable, std::set<data::data_expression> > equalities = data::find_equalities(s.condition());
87 auto [sigma,remaining_variables] = data::make_one_point_rule_substitution(equalities, s.summation_variables());
88
89 std::size_t original_num_vars = s.summation_variables().size();
90 if (remaining_variables.size() != original_num_vars)
91 {
92 // A substitution was found
93 // Temporarily remove sumvars, otherwise the capture avoiding substitution will modify them
94 s.summation_variables() = data::variable_list();
96 s.summation_variables() = data::variable_list(remaining_variables.begin(), remaining_variables.end());
97 }
98
100 m_removed += original_num_vars - s.summation_variables().size();
101 }
102
104 std::size_t removed() const
105 {
106 return m_removed;
107 }
108};
109
113inline
115{
116 specification spec;
117 sumelm_algorithm<specification> algorithm(spec);
118 algorithm(s);
119 return algorithm.removed() > 0;
120}
121
125inline
127{
130 algorithm(s);
131 return algorithm.removed() > 0;
132}
133
137inline
139{
140 specification spec;
141 sumelm_algorithm<specification> algorithm(spec);
142 algorithm(s);
143 return algorithm.removed() > 0;
144}
145
146} // namespace lps
147} // namespace mcrl2
148
149#endif // MCRL2_LPS_SUMELM_H
150
LPS summand containing a multi-action.
LPS summand containing a deadlock.
Algorithm class for algorithms on linear process specifications. It can be instantiated with lps::spe...
void summand_remove_unused_summand_variables(SummandType &summand_)
lps_algorithm(Specification &spec)
Constructor.
Specification & m_spec
The specification that is processed by the algorithm.
Linear process specification.
LPS summand containing a multi-action.
Class implementing the sum elimination lemma.
Definition sumelm.h:33
std::size_t removed() const
Returns the amount of removed summation variables.
Definition sumelm.h:104
std::size_t m_removed
Stores the number of summation variables that has been removed.
Definition sumelm.h:39
sumelm_algorithm(Specification &spec, bool decluster=false)
Constructor.
Definition sumelm.h:50
void operator()(Summand &s)
Apply the sum elimination lemma to summand s.
Definition sumelm.h:84
detail::lps_algorithm< Specification > super
Definition sumelm.h:34
bool m_decluster
Whether to decluster disjunctive conditions first.
Definition sumelm.h:42
void run()
Apply the sum elimination lemma to all summands in the specification.
Definition sumelm.h:58
add your file description here.
Split summands with disjuncts as conditions.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
#define mCRL2log(LEVEL)
mCRL2log(LEVEL) provides the stream used to log.
Definition logger.h:391
std::map< variable, std::set< data_expression > > find_equalities(const data_expression &x)
std::pair< data::mutable_map_substitution<>, std::vector< data::variable > > make_one_point_rule_substitution(const std::map< data::variable, std::set< data::data_expression > > &equalities, const data::variable_list &quantifier_variables, bool find_all_assignments=true)
creates a substitution from a set of (in-)equalities for a given list of quantifier variables
atermpp::term_list< variable > variable_list
\brief list of variables
@ verbose
Definition logger.h:37
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)
bool sumelm(action_summand &s)
Apply the sum elimination lemma to summand s.
Definition sumelm.h:114
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72