mCRL2
Loading...
Searching...
No Matches
replace_capture_avoiding.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//
11
12#ifndef MCRL2_PBES_REPLACE_CAPTURE_AVOIDING_H
13#define MCRL2_PBES_REPLACE_CAPTURE_AVOIDING_H
14
16#include "mcrl2/pbes/builder.h"
17#include "mcrl2/pbes/find.h"
18
19namespace mcrl2 {
20
21namespace pbes_system {
22
23namespace detail {
24
25template<template<class> class Builder, class Derived, class Substitution>
27 : public data::detail::add_capture_avoiding_replacement<Builder, Derived, Substitution>
28{
29 typedef data::detail::add_capture_avoiding_replacement <Builder, Derived, Substitution> super;
30 using super::enter;
31 using super::leave;
32 using super::update;
33 using super::apply;
34 using super::sigma;
35
37 : super(sigma)
38 { }
39
40 template <class T>
41 void apply(T& result, const forall& x)
42 {
43 data::variable_list v1 = sigma.add_fresh_variable_assignments(x.variables());
44 pbes_expression body;
45 apply(body, x.body());
46 pbes_system::make_forall(result, v1, body);
47 sigma.remove_fresh_variable_assignments(x.variables());
48 }
49
50 template <class T>
51 void apply(T& result, const exists& x)
52 {
53 data::variable_list v1 = sigma.add_fresh_variable_assignments(x.variables());
54 pbes_expression body;
55 apply(body, x.body());
56 pbes_system::make_exists(result, v1, body);
57 sigma.remove_fresh_variable_assignments(x.variables());
58 }
59
61 {
62 data::variable_list v1 = sigma.add_fresh_variable_assignments(x.variable().parameters());
65 apply(formula, x.formula());
66 x.formula() = formula;
67 sigma.remove_fresh_variable_assignments(x.variable().parameters());
68 }
69
70 void update(pbes& x)
71 {
72 data::variable_list v1 = sigma.add_fresh_variable_assignments(x.global_variables());
73 x.global_variables() = std::set<data::variable>(v1.begin(), v1.end());
74 update(x.equations());
75 sigma.remove_fresh_variable_assignments(x.global_variables());
76 }
77};
78
79} // namespace detail
80
81//--- start generated pbes_system replace_capture_avoiding code ---//
86template <typename T, typename Substitution>
88 Substitution& sigma,
90 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* = nullptr
91)
92{
94 data::detail::apply_replace_capture_avoiding_variables_builder<pbes_system::data_expression_builder, pbes_system::detail::add_capture_avoiding_replacement>(sigma1).update(x);
95}
96
101template <typename T, typename Substitution>
103 Substitution& sigma,
104 data::set_identifier_generator& id_generator,
105 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* = nullptr
106)
107{
109 T result;
110 data::detail::apply_replace_capture_avoiding_variables_builder<pbes_system::data_expression_builder, pbes_system::detail::add_capture_avoiding_replacement>(sigma1).apply(result, x);
111 return result;
112}
113
117template <typename T, typename Substitution>
119 Substitution& sigma,
120 typename std::enable_if<!std::is_base_of<atermpp::aterm, T>::value>::type* = nullptr
121)
122{
125 for (const data::variable& v: substitution_variables(sigma))
126 {
127 id_generator.add_identifier(v.name());
128 }
130}
131
135template <typename T, typename Substitution>
137 Substitution& sigma,
138 typename std::enable_if<std::is_base_of<atermpp::aterm, T>::value>::type* = nullptr
139)
140{
143 for (const data::variable& v: substitution_variables(sigma))
144 {
145 id_generator.add_identifier(v.name());
146 }
148}
149//--- end generated pbes_system replace_capture_avoiding code ---//
150
151} // namespace pbes_system
152
153} // namespace mcrl2
154
155#endif // MCRL2_PBES_REPLACE_CAPTURE_AVOIDING_H
const_iterator end() const
Returns a const_iterator pointing to the end of the term_list.
Definition aterm_list.h:282
const_iterator begin() const
Returns a const_iterator pointing to the beginning of the term_list.
Definition aterm_list.h:275
void add_identifiers(const std::set< core::identifier_string > &ids)
Add a set of identifiers to the context.
Identifier generator that stores the identifiers of the context in a set. Using the operator()() and ...
void add_identifier(const core::identifier_string &s) override
Adds the identifier s to the context.
\brief A data variable
Definition variable.h:28
\brief The existential quantification operator for pbes expressions
const data::variable_list & variables() const
const pbes_expression & body() const
\brief The universal quantification operator for pbes expressions
const pbes_expression & body() const
const data::variable_list & variables() const
const pbes_expression & formula() const
Returns the predicate formula on the right hand side of the equation.
const propositional_variable & variable() const
Returns the pbes variable of the equation.
parameterized boolean equation system
Definition pbes.h:58
const std::set< data::variable > & global_variables() const
Returns the declared free variables of the pbes.
Definition pbes.h:178
const std::vector< pbes_equation > & equations() const
Returns the equations.
Definition pbes.h:164
\brief A propositional variable declaration
const data::variable_list & parameters() const
const core::identifier_string & name() const
add your file description here.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
void find_identifiers(const T &x, OutputIterator o)
Definition find.h:131
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)
pbes_expression formula(std::set< identifier_t > const &v, const owner_t owner, const std::string &prefix="X")
Definition pg_parse.h:54
void make_exists(atermpp::aterm &t, const ARGUMENTS &... args)
void make_forall(atermpp::aterm &t, const ARGUMENTS &... args)
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.
Search functions of the pbes library.
void apply(atermpp::term_list< T > &result, const assignment_list &x)
capture_avoiding_substitution_updater< Substitution > & sigma
data::detail::add_capture_avoiding_replacement< Builder, Derived, Substitution > super
capture_avoiding_substitution_updater< Substitution > & sigma
add_capture_avoiding_replacement(data::detail::capture_avoiding_substitution_updater< Substitution > &sigma)