mCRL2
Loading...
Searching...
No Matches
maintain_variables_in_rhs.h
Go to the documentation of this file.
1// Author(s): Jan Friso Groote
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//
14
15
16#ifndef MCRL2_DATA_SUBSTITUTIONS_MAINTAIN_VARIABLES_IN_RHS_H
17#define MCRL2_DATA_SUBSTITUTIONS_MAINTAIN_VARIABLES_IN_RHS_H
18
21
22namespace mcrl2 {
23
24namespace data {
25
26
34template <typename Substitution>
35class maintain_variables_in_rhs: public Substitution
36{
37 public:
38 typedef Substitution super;
39 typedef typename super::variable_type variable_type;
40 typedef typename super::expression_type expression_type;
41
42 protected:
43 std::multiset<variable_type> m_variables_in_rhs;
44 std::set<variable_type> m_scratch_set;
45
46 public:
49 {
50 }
51
54 {
55 protected:
57 Substitution& m_sigma;
58 std::multiset<variable_type>& m_variables_in_rhs;
59 std::set<variable_type>& m_scratch_set;
60
61 public:
68 Substitution& sigma,
69 std::multiset<variable_type>& variables_in_rhs,
70 std::set<variable_type>& scratch_set) :
71 m_variable(v),
74 m_scratch_set(scratch_set)
75 { }
76
79 {
80 assert(e.defined());
81
83 if (e_old!=m_variable)
84 {
85 // Remove the free variables in the old rhs.
87 for(const variable_type& v: m_scratch_set)
88 {
89 m_variables_in_rhs.erase(v);
90 }
91 m_scratch_set.clear();
92 }
93 if (e != m_variable)
94 {
95 // Add the free variables in the new rhs.
98 m_scratch_set.clear();
99 }
100 // Set the new variable;
101 m_sigma.operator[](m_variable)=e;
102 }
103 };
104
108 {
110 }
111
113 void clear()
114 {
115 m_variables_in_rhs().clear();
116 super::clear();
117 }
118
120 const std::multiset<variable>& variables_in_rhs()
121 {
122 return m_variables_in_rhs;
123 }
124
128 {
129 return m_variables_in_rhs.find(v)!=m_variables_in_rhs.end();
130 }
131
132};
133
134} // namespace data
135
136} // namespace mcrl2
137
138#endif // MCRL2_DATA_SUBSTITUTIONS_MAINTAIN_VARIABLES_IN_RHS_H
Wrapper class for internal storage and substitution updates using operator()
assignment(const variable_type &v, Substitution &sigma, std::multiset< variable_type > &variables_in_rhs, std::set< variable_type > &scratch_set)
Constructor.
void operator=(const expression_type &e)
Actual assignment.
Wrapper that extends any substitution to a substitution maintaining the vars in its rhs.
bool variable_occurs_in_a_rhs(const variable_type &v)
Indicates whether a variable occurs in some rhs of this substitution.
assignment operator[](variable_type const &v)
Assigment operator.
const std::multiset< variable > & variables_in_rhs()
Provides a set of variables that occur in the right hand sides of the assignments.
std::multiset< variable_type > m_variables_in_rhs
add your file description here.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
std::set< data::variable > find_free_variables(const data::data_expression &x)
Definition data.cpp:99
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
add your file description here.