mCRL2
Loading...
Searching...
No Matches
sequence_sequence_substitution.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_DATA_SUBSTITUTIONS_SEQUENCE_SEQUENCE_SUBSTITUTION_H
13#define MCRL2_DATA_SUBSTITUTIONS_SEQUENCE_SEQUENCE_SUBSTITUTION_H
14
17
18namespace mcrl2 {
19
20namespace data {
21
24template <typename VariableContainer, typename ExpressionContainer>
26{
28 typedef typename VariableContainer::value_type variable_type;
29
31 typedef typename ExpressionContainer::value_type expression_type;
32
35
36 const VariableContainer& variables;
37 const ExpressionContainer& expressions;
38
39 sequence_sequence_substitution(const VariableContainer& variables_, const ExpressionContainer& expressions_)
40 : variables(variables_),
41 expressions(expressions_)
42 {
43 assert(variables.size() == expressions.size());
44 }
45
47 {
48 typename VariableContainer::const_iterator i = variables.begin();
49 typename ExpressionContainer::const_iterator j = expressions.begin();
50
51 for (; i != variables.end(); ++i, ++j)
52 {
53 if (*i == v)
54 {
55 return *j;
56 }
57 }
58 return expression_type(v);
59 }
60
61 std::string to_string() const
62 {
63 std::ostringstream out;
64 out << "[";
65 typename VariableContainer::const_iterator i = variables.begin();
66 typename ExpressionContainer::const_iterator j = expressions.begin();
67 for (; i != variables.end(); ++i, ++j)
68 {
69 out << (i == variables.begin() ? "" : "; ") << *i << " := " << *j;
70 }
71 out << "]";
72 return out.str();
73 }
74};
75
77template <typename VariableContainer, typename ExpressionContainer>
78sequence_sequence_substitution<VariableContainer, ExpressionContainer>
79make_sequence_sequence_substitution(const VariableContainer& vc, const ExpressionContainer& ec)
80{
82}
83
84template <typename VariableContainer, typename ExpressionContainer>
86{
87 return out << sigma.to_string();
88}
89
90template <typename VariableContainer, typename ExpressionContainer>
92{
93 auto i = sigma.variables.begin();
94 auto j = sigma.expressions.begin();
95 for (i = sigma.variables.begin(); i != sigma.variables.end(); ++i, ++j)
96 {
97 if (!is_simple_substitution(*i, *j))
98 {
99 return false;
100 }
101 }
102 return true;
103}
104
105} // namespace data
106
107} // namespace mcrl2
108
109#endif // MCRL2_DATA_SUBSTITUTIONS_SEQUENCE_SEQUENCE_SUBSTITUTION_H
add your file description here.
static RewriterCompilingJitty::substitution_type & sigma(RewriterCompilingJitty *this_rewriter)
sequence_sequence_substitution< VariableContainer, ExpressionContainer > make_sequence_sequence_substitution(const VariableContainer &vc, const ExpressionContainer &ec)
Utility function for creating a sequence_sequence_substitution.
bool is_simple_substitution(const Substitution &)
Returns true if the substitution sigma satisfies the property that FV(sigma(x)) is included in {x} fo...
std::ostream & operator<<(std::ostream &out, const abstraction &x)
Definition abstraction.h:94
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72
Generic substitution function. The substitution is stored as a sequence of variables and a sequence o...
ExpressionContainer::value_type expression_type
type used to represent expressions
VariableContainer::value_type variable_type
type used to represent variables
expression_type operator()(const variable_type &v) const
sequence_sequence_substitution(const VariableContainer &variables_, const ExpressionContainer &expressions_)
add your file description here.