mCRL2
Loading...
Searching...
No Matches
replace_capture_avoiding_with_an_identifier_generator.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//
9/// \file mcrl2/pbes/replace_capture_avoiding_with_an_identifier_generator.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_REPLACE_CAPTURE_AVOIDING_WITH_AN_IDENTIFIER_GENERATOR_H
13#define MCRL2_PBES_REPLACE_CAPTURE_AVOIDING_WITH_AN_IDENTIFIER_GENERATOR_H
14
15#include "mcrl2/data/replace_capture_avoiding_with_an_identifier_generator.h"
16#include "mcrl2/pbes/add_binding.h"
17#include "mcrl2/pbes/builder.h"
18
19namespace mcrl2::pbes_system
20{
21
22namespace detail {
23
24// Below the code for the capture avoiding replacement with an identifier generator is provided.
25
26template<template<class> class Builder, class Derived, class Substitution, class IdentifierGenerator>
29{
31 Derived,
34 using super::enter;
35 using super::leave;
36 using super::update;
37 using super::apply;
38 using super::update_sigma;
39
40 template <class T>
41 void apply(T& result, const forall& x)
42 {
43 data::variable_list v = update_sigma.push(x.variables());
44 pbes_expression body;
45 apply(body, x.body());
46 make_forall(result, v, apply(x.body()));
47 update_sigma.pop(v);
48 }
49
50 template <class T>
51 void apply(T& result, const exists& x)
52 {
53 data::variable_list v = update_sigma.push(x.variables());
54 pbes_expression body;
55 apply(body, x.body());
56 make_exists(result, v, apply(x.body()));
57 update_sigma.pop(v);
58 }
59
61 {
62 data::variable_list v = update_sigma.push(x.variable().parameters());
63 x.variable() = propositional_variable(x.variable().name(), v);
64 pbes_expression formula;
65 apply(formula, x.formula());
66 x.formula() = formula;
67 update_sigma.pop(v);
68 }
69
70 void update(pbes& x)
71 {
72 std::set<data::variable> v = update_sigma(x.global_variables());
73 x.global_variables() = v;
74 update(x.equations());
75 update_sigma.pop(v);
76 }
77
78 add_capture_avoiding_replacement_with_an_identifier_generator(Substitution& sigma, IdentifierGenerator& id_generator)
80 {
81 }
82};
83
84} // namespace detail
85
86//--- start generated pbes_system replace_capture_avoiding_with_identifier_generator code ---//
87/// \\brief Applies sigma as a capture avoiding substitution to x using an identifier generator.
88/// \\details This substitution function is much faster than replace_variables_capture_avoiding, but
89/// it requires an identifier generator that generates strings for fresh variables. These
90/// strings must be unique in the sense that they have not been used for other variables.
91/// \\param x The object to which the subsitution is applied.
92/// \\param sigma A mutable substitution of which it can efficiently be checked whether a variable occurs in its
93/// right hand side. The class maintain_variables_in_rhs is useful for this purpose.
94/// \\param id_generator A generator that generates unique strings, not yet used as variable names.
95
96template <typename T, data::IsSubstitution Substitution, typename IdentifierGenerator>
98 Substitution& sigma,
99 IdentifierGenerator& id_generator
100 )
101 requires (!std::is_base_of_v<atermpp::aterm, T>)
102{
103 data::detail::apply_replace_capture_avoiding_variables_builder_with_an_identifier_generator<pbes_system::data_expression_builder, pbes_system::detail::add_capture_avoiding_replacement_with_an_identifier_generator>(sigma, id_generator).update(x);
104}
105
106/// \\brief Applies sigma as a capture avoiding substitution to x using an identifier generator..
107/// \\details This substitution function is much faster than replace_variables_capture_avoiding, but
108/// it requires an identifier generator that generates strings for fresh variables. These
109/// strings must be unique in the sense that they have not been used for other variables.
110/// \\param x The object to which the substiution is applied.
111/// \\param sigma A mutable substitution of which it can efficiently be checked whether a variable occurs in its
112/// right hand side. The class maintain_variables_in_rhs is useful for this purpose.
113/// \\param id_generator A generator that generates unique strings, not yet used as variable names.
114/// \\return The result is the term x to which sigma has been applied.
115template <typename T, data::IsSubstitution Substitution, typename IdentifierGenerator>
117 Substitution& sigma,
118 IdentifierGenerator& id_generator
119 )
120 requires std::is_base_of_v<atermpp::aterm, T>
121{
122 T result;
124 return result;
125}
126//--- end generated pbes_system replace_capture_avoiding_with_identifier_generator code ---//
127
128} // namespace mcrl2::pbes_system
129
130#endif // MCRL2_PBES_REPLACE_CAPTURE_AVOIDING_WITH_AN_IDENTIFIER_GENERATOR_H
\brief The existential quantification operator for pbes expressions
const pbes_expression & body() const
\brief The universal quantification operator for pbes expressions
const pbes_expression & body() const
pbes_expression & formula()
Returns the predicate formula on the right hand side of the equation.
pbes_expression & operator=(const pbes_expression &) noexcept=default
parameterized boolean equation system
Definition pbes.h:54
T replace_variables_capture_avoiding_with_an_identifier_generator(const T &x, Substitution &sigma, IdentifierGenerator &id_generator)
void replace_variables_capture_avoiding_with_an_identifier_generator(T &x, Substitution &sigma, IdentifierGenerator &id_generator)