mCRL2
Loading...
Searching...
No Matches
strategy_rule.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//
10
11#ifndef MCRL2_DATA_DETAIL_REWRITE_STRATEGY_RULE_H
12#define MCRL2_DATA_DETAIL_REWRITE_STRATEGY_RULE_H
13
15
16namespace mcrl2
17{
18namespace data
19{
20namespace detail
21{
22
25{
26 protected:
27 // Only one of the fields rewrite_rule, rewrite_index or cpp_function will be used
28 // at any given time. As this hardly requires a lot of memory, we do not optimise
29 // this using for instance a union type.
33 std::function<void(data_expression&, const data_expression&)> m_cpp_function;
34
35 public:
36 strategy_rule(const std::size_t n)
39 {}
40
41 strategy_rule(const std::function<void(data_expression&, const data_expression&)> f)
44 {}
45
49 {}
50
51 bool is_rewrite_index() const
52 {
54 }
55
56 bool is_cpp_code() const
57 {
58
60 }
61
62 bool is_equation() const
63 {
65 }
66
67 const data_equation& equation() const
68 {
69 assert(is_equation());
71 return m_rewrite_rule;
72 }
73
74 std::size_t rewrite_index() const
75 {
76 assert(is_rewrite_index());
77 return m_rewrite_index;
78 }
79
80 const std::function<void(data_expression&, const data_expression&)> rewrite_cpp_code() const
81 {
82 assert(is_cpp_code());
83 return m_cpp_function;
84 }
85};
86
89{
90 protected:
92 std::vector<strategy_rule> m_rules;
93
94 public:
96 strategy(size_t n, const std::vector<strategy_rule>& r)
98 m_rules(r)
99 {}
100
104 {}
105
107 std::size_t number_of_variables() const
108 {
109 return m_number_of_variables;
110 }
111
113 const std::vector<strategy_rule>& rules() const
114 {
115 return m_rules;
116 }
117
118};
119
122
123} // namespace detail
124} // namespace data
125} // namespace mcrl2
126
127#endif // MCRL2_DATA_DETAIL_REWRITE_STRATEGY_RULE_H
128
A list of aterm objects.
Definition aterm_list.h:24
\brief A data equation
Is either a rewrite rule to be matched or an index that should be rewritten.
std::function< void(data_expression &, const data_expression &)> m_cpp_function
strategy_rule(const std::function< void(data_expression &, const data_expression &)> f)
const std::function< void(data_expression &, const data_expression &)> rewrite_cpp_code() const
const data_equation & equation() const
enum mcrl2::data::detail::strategy_rule::@0 m_strategy_element_type
strategy_rule(const data_equation &eq)
strategy_rule(const std::size_t n)
A strategy is a list of rules and the number of variables that occur in it.
std::size_t number_of_variables() const
Provides the maximal number of variables used in the rewrite rules making up this strategy.
const std::vector< strategy_rule > & rules() const
Yield the rules of the strategy.
strategy(size_t n, const std::vector< strategy_rule > &r)
Default constructor.
strategy()
Default constructor.
std::vector< strategy_rule > m_rules
The class data_equation.
strategy create_strategy(data_equation_list rules)
Creates a strategy for given set of rewrite rules with head symbol f.
bool is_data_equation(const atermpp::aterm &t)
Recognizer function.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72