12#ifndef MCRL2_DATA_REPLACE_H
13#define MCRL2_DATA_REPLACE_H
28template <
template <
class>
class Builder,
class Substitution>
29struct replace_sort_expressions_builder:
public Builder<replace_sort_expressions_builder<Builder, Substitution> >
31 typedef Builder<replace_sort_expressions_builder<Builder, Substitution> > super;
37 const Substitution&
sigma;
40 replace_sort_expressions_builder(
const Substitution& sigma_,
bool innermost_)
46 void apply(T& result,
const sort_expression& x)
50 super::apply(result, x);
51 result =
sigma(result);
59template <
template <
class>
class Builder,
class Substitution>
60replace_sort_expressions_builder<Builder, Substitution>
61make_replace_sort_expressions_builder(
const Substitution&
sigma,
bool innermost)
63 return replace_sort_expressions_builder<Builder, Substitution>(
sigma, innermost);
66template <
template <
class>
class Builder,
class Substitution>
67struct replace_data_expressions_builder:
public Builder<replace_data_expressions_builder<Builder, Substitution> >
69 typedef Builder<replace_data_expressions_builder<Builder, Substitution> > super;
78 replace_data_expressions_builder(Substitution sigma_,
bool innermost_)
84 void apply(T& result,
const data_expression& x)
97template <
template <
class>
class Builder,
class Substitution>
98replace_data_expressions_builder<Builder, Substitution>
99make_replace_data_expressions_builder(
const Substitution&
sigma,
bool innermost)
101 return replace_data_expressions_builder<Builder, Substitution>(
sigma, innermost);
104template <
template <
class>
class Builder,
template <
template <
class>
class,
class>
class Binder, class Substitution>
105struct replace_free_variables_builder:
public Binder<Builder, replace_free_variables_builder<Builder, Binder, Substitution> >
107 typedef Binder<Builder, replace_free_variables_builder<Builder, Binder, Substitution> > super;
112 using super::is_bound;
113 using super::bound_variables;
114 using super::increase_bind_count;
116 const Substitution&
sigma;
118 explicit replace_free_variables_builder(
const Substitution& sigma_)
122 template <
typename VariableContainer>
123 replace_free_variables_builder(
const Substitution& sigma_,
const VariableContainer& bound_variables)
126 increase_bind_count(bound_variables);
130 void apply(T& result,
const variable& v)
141template <
template <
class>
class Builder,
template <
template <
class>
class,
class>
class Binder, class Substitution>
142replace_free_variables_builder<Builder, Binder, Substitution>
143make_replace_free_variables_builder(const Substitution&
sigma)
145 return replace_free_variables_builder<Builder, Binder, Substitution>(
sigma);
148template <
template <
class>
class Builder,
template <
template <
class>
class,
class>
class Binder, class Substitution, class VariableContainer>
149replace_free_variables_builder<Builder, Binder, Substitution>
150make_replace_free_variables_builder(const Substitution&
sigma,
const VariableContainer& bound_variables)
152 return replace_free_variables_builder<Builder, Binder, Substitution>(
sigma, bound_variables);
160template <
typename Substitution>
167template <
typename T,
typename Substitution>
169 const Substitution&
sigma,
171 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
174 data::detail::make_replace_sort_expressions_builder<data::sort_expression_builder>(
sigma, innermost).update(x);
177template <
typename T,
typename Substitution>
179 const Substitution&
sigma,
181 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
185 data::detail::make_replace_sort_expressions_builder<data::sort_expression_builder>(
sigma, innermost).apply(result, x);
189template <
typename T,
typename Substitution>
191 const Substitution&
sigma,
193 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
196 data::detail::make_replace_data_expressions_builder<data::data_expression_builder>(
sigma, innermost).update(x);
199template <
typename T,
typename Substitution>
201 const Substitution&
sigma,
203 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
207 data::detail::make_replace_data_expressions_builder<data::data_expression_builder>(
sigma, innermost).apply(result, x);
212template <
typename T,
typename Substitution>
214 const Substitution&
sigma,
215 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
218 core::make_update_apply_builder<data::data_expression_builder>(
sigma).update(x);
221template <
typename T,
typename Substitution>
223 const Substitution&
sigma,
224 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
228 core::make_update_apply_builder<data::data_expression_builder>(
sigma).apply(result, x);
232template <
typename T,
typename Substitution>
234 const Substitution&
sigma,
235 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
238 core::make_update_apply_builder<data::variable_builder>(
sigma).update(x);
241template <
typename T,
typename Substitution>
243 const Substitution&
sigma,
244 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
248 core::make_update_apply_builder<data::variable_builder>(
sigma).apply(result, x);
254template <
typename T,
typename Substitution>
256 const Substitution&
sigma,
257 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
261 data::detail::make_replace_free_variables_builder<data::data_expression_builder, data::add_data_variable_builder_binding>(
sigma).update(x);
266template <
typename T,
typename Substitution>
268 const Substitution&
sigma,
269 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
274 data::detail::make_replace_free_variables_builder<data::data_expression_builder, data::add_data_variable_builder_binding>(
sigma).apply(result, x);
280template <
typename T,
typename Substitution,
typename VariableContainer>
282 const Substitution&
sigma,
283 const VariableContainer& bound_variables,
284 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
288 data::detail::make_replace_free_variables_builder<data::data_expression_builder, data::add_data_variable_builder_binding>(
sigma).update(x, bound_variables);
293template <
typename T,
typename Substitution,
typename VariableContainer>
295 const Substitution&
sigma,
296 const VariableContainer& bound_variables,
297 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* =
nullptr
302 data::detail::make_replace_free_variables_builder<data::data_expression_builder, data::add_data_variable_builder_binding>(
sigma).apply(result, x, bound_variables);
307template <
typename T,
typename Substitution>
309 const Substitution&
sigma,
310 typename std::enable_if< !std::is_base_of< atermpp::aterm, T >::value >::type* = 0
313 core::make_update_apply_builder<data::sort_expression_builder>(
sigma).update(x);
316template <
typename T,
typename Substitution>
318 const Substitution&
sigma,
319 typename std::enable_if< std::is_base_of< atermpp::aterm, T >::value >::type* = 0
323 core::make_update_apply_builder<data::sort_expression_builder>(
sigma).apply(result, x);
Standard exception class for reporting runtime errors.
add your file description here.
add your file description here.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
void substitute_sorts(T &x, const Substitution &sigma, typename std::enable_if< !std::is_base_of< atermpp::aterm, T >::value >::type *=0)
void replace_all_variables(T &x, const Substitution &sigma, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
std::set< data::variable > substitution_variables(const Substitution &)
Returns the variables appearing in the right hand sides of the substitution.
void replace_sort_expressions(T &x, const Substitution &sigma, bool innermost, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
void replace_data_expressions(T &x, const Substitution &sigma, bool innermost, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
void replace_free_variables(T &x, const Substitution &sigma, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
bool is_simple_substitution(const Substitution &)
Returns true if the substitution sigma satisfies the property that FV(sigma(x)) is included in {x} fo...
void replace_variables(T &x, const Substitution &sigma, typename std::enable_if<!std::is_base_of< atermpp::aterm, T >::value >::type *=nullptr)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...