mCRL2
Loading...
Searching...
No Matches
rewrite.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
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//
9/// \file pbes/include/mcrl2/pbes/rewrite.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_REWRITE_H
13#define MCRL2_PBES_REWRITE_H
14
15#include "mcrl2/data/rewrite.h"
16#include "mcrl2/pbes/builder.h"
17
18
19
20namespace mcrl2::pbes_system {
21
22namespace detail
23{
24
25template <template <class> class Builder, class Rewriter>
27{
29 using super::apply;
30 using super::update;
31
32 const Rewriter& R;
33
35 : R(R_)
36 {}
37
38 template <class T>
39 void apply(T& result, const pbes_expression& x)
40 {
41 result = R(x);
42 }
43
45 {
46 super::update(x);
47 // Handle the initial state. It is skipped by the builder because the type is not pbes_expression
48 pbes_expression initial_state;
49 apply(initial_state, static_cast<pbes_expression>(x.initial_state()));
50 x.initial_state() = atermpp::down_cast<propositional_variable_instantiation>(initial_state);
51 }
52};
53
54template <template <class> class Builder, class Rewriter>
57{
58 return rewrite_pbes_expressions_builder<Builder, Rewriter>(R);
59}
60
61template <template <class> class Builder, class Rewriter, class Substitution>
63{
65 using super::apply;
66
67 const Rewriter& R;
68 Substitution& sigma;
69
70 rewrite_pbes_expressions_with_substitution_builder(const Rewriter& R_, Substitution& sigma_)
71 : R(R_),
72 sigma(sigma_)
73 {}
74
75 template <class T>
76 void apply(T& result, const pbes_expression& x)
77 {
78 result = R(x, sigma);
79 }
80};
81
82template <template <class> class Builder, class Rewriter, class Substitution>
85{
86 return rewrite_pbes_expressions_with_substitution_builder<Builder, Rewriter, Substitution>(R, sigma);
87}
88/// \endcond
89
90} // namespace detail
91
92//--- start generated pbes_system rewrite code ---//
93/// \\brief Rewrites all embedded expressions in an object x
94/// \\param x an object containing expressions
95/// \\param R a rewriter
96template <typename T, typename Rewriter>
97void rewrite(T& x,
98 Rewriter R
99 )
100 requires (!std::is_base_of_v<atermpp::aterm, T>)
101{
102 data::detail::make_rewrite_data_expressions_builder<pbes_system::data_expression_builder>(R).update(x);
103}
104
105/// \\brief Rewrites all embedded expressions in an object x
106/// \\param x an object containing expressions
107/// \\param R a rewriter
108/// \\return the rewrite result
109template <typename T, typename Rewriter>
110T rewrite(const T& x,
111 Rewriter R
112 )
113 requires std::is_base_of_v<atermpp::aterm, T>
114{
115 T result;
117 return result;
118}
119
120/// \\brief Rewrites all embedded expressions in an object x, and applies a substitution to variables on the fly
121/// \\param x an object containing expressions
122/// \\param R a rewriter
123/// \\param sigma a substitution
124template <typename T, typename Rewriter, data::IsSubstitution Substitution>
125void rewrite(T& x,
126 Rewriter R,
127 const Substitution& sigma
128 )
129 requires (!std::is_base_of_v<atermpp::aterm, T>)
130{
132}
133
134/// \\brief Rewrites all embedded expressions in an object x, and applies a substitution to variables on the fly
135/// \\param x an object containing expressions
136/// \\param R a rewriter
137/// \\param sigma a substitution
138/// \\return the rewrite result
139template <typename T, typename Rewriter, data::IsSubstitution Substitution>
140T rewrite(const T& x,
141 Rewriter R,
142 const Substitution& sigma
143 )
144 requires std::is_base_of_v<atermpp::aterm, T>
145{
146 T result;
148 return result;
149}
150//--- end generated pbes_system rewrite code ---//
151
152/// \brief Rewrites all embedded pbes expressions in an object x
153/// \param x an object containing expressions
154/// \param R a pbes rewriter
155template <typename T, typename Rewriter>
156 requires(!std::is_base_of_v<atermpp::aterm, T>)
157void pbes_rewrite(T& x, const Rewriter& R)
158{
160}
161
162/// \brief Rewrites all embedded pbes expressions in an object x
163/// \param x an object containing expressions
164/// \param R a pbes rewriter
165/// \return the rewrite result
166template <typename T, typename Rewriter>
167 requires(std::is_base_of_v<atermpp::aterm, T>)
168T pbes_rewrite(const T& x, const Rewriter& R)
169{
170 T result;
172 return result;
173}
174
175/// \brief Rewrites all embedded pbes expressions in an object x, and applies a substitution to variables on the fly
176/// \param x an object containing expressions
177/// \param R a pbes rewriter
178/// \param sigma a substitution
179template <typename T, typename Rewriter, typename Substitution>
180 requires(!std::is_base_of_v<atermpp::aterm, T>)
182 const Rewriter& R,
184{
186}
187
188/// \brief Rewrites all embedded pbes expressions in an object x, and applies a substitution to variables on the fly
189/// \param x an object containing expressions
190/// \param R a pbes rewriter
191/// \param sigma a substitution
192/// \return the rewrite result
193template <typename T, typename Rewriter, typename Substitution>
194 requires(std::is_base_of_v<atermpp::aterm, T>)
196 const Rewriter& R,
198{
199 T result;
201 return result;
202}
203
204} // namespace mcrl2::pbes_system
205
206
207
208#endif // MCRL2_PBES_REWRITE_H
pbes_expression(const pbes_expression &) noexcept=default
Move semantics.
parameterized boolean equation system
Definition pbes.h:54
propositional_variable_instantiation & initial_state()
Returns the initial state.
Definition pbes.h:195
rewrite_pbes_expressions_with_substitution_builder< Builder, Rewriter, Substitution > make_rewrite_pbes_expressions_with_substitution_builder(const Rewriter &R, Substitution &sigma)
Definition rewrite.h:84
rewrite_pbes_expressions_builder< Builder, Rewriter > make_rewrite_pbes_expressions_builder(const Rewriter &R)
Definition rewrite.h:56
T rewrite(const T &x, Rewriter R)
Definition rewrite.h:110
void rewrite(T &x, Rewriter R)
Definition rewrite.h:97
void apply(T &result, const pbes_expression &x)
Definition rewrite.h:39
rewrite_pbes_expressions_with_substitution_builder(const Rewriter &R_, Substitution &sigma_)
Definition rewrite.h:70