mCRL2
Loading...
Searching...
No Matches
lps2pbes_sat.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 mcrl2/pbes/detail/lps2pbes_sat.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_DETAIL_LPS2PBES_SAT_H
13#define MCRL2_PBES_DETAIL_LPS2PBES_SAT_H
14
15#include "mcrl2/data/detail/data_utility.h"
16#include "mcrl2/data/detail/find.h"
17#include "mcrl2/modal_formula/replace.h"
18#include "mcrl2/pbes/detail/lps2pbes_utility.h"
19
20
21
22
23
24namespace mcrl2::pbes_system::detail {
25
26template <typename TermTraits>
27typename TermTraits::term_type Sat(const lps::multi_action& a,
29 data::set_identifier_generator& id_generator,
30 TermTraits tr
31 );
32
33template <typename Derived, typename TermTraits>
35{
37 using tr = TermTraits;
38 using expression_type = typename tr::term_type;
39
40 using super::enter;
41 using super::leave;
42 using super::apply;
43
47
48 sat_traverser(const lps::multi_action& a_, data::set_identifier_generator& id_generator_, TermTraits)
49 : a(a_), id_generator(id_generator_)
50 {}
51
52 Derived& derived()
53 {
54 return static_cast<Derived&>(*this);
55 }
56
57 void push(const expression_type& x)
58 {
59 result_stack.push_back(x);
60 }
61
62 const expression_type& top() const
63 {
64 return result_stack.back();
65 }
66
67 expression_type pop()
68 {
69 expression_type result = top();
70 result_stack.pop_back();
71 return result;
72 }
73
74 void leave(const data::data_expression& x)
75 {
76 push(atermpp::down_cast<pbes_expression>(x));
77 }
78
80 {
81 push(atermpp::down_cast<pbes_expression>(lps::equal_multi_actions(a, lps::multi_action(x.actions()))));
82 }
83
85 {
87 }
88
90 {
92 }
93
94 void apply(const action_formulas::not_& x)
95 {
96 push(tr::not_(Sat(a, x.operand(), id_generator, TermTraits())));
97 }
98
100 {
101 expression_type right = pop();
102 expression_type left = pop();
103 push(tr::and_(left, right));
104 }
105
107 {
108 expression_type right = pop();
109 expression_type left = pop();
110 push(tr::or_(left, right));
111 }
112
114 {
115 expression_type right = pop();
116 expression_type left = pop();
117 push(tr::imp(left, right));
118 }
119
121 {
122 data::mutable_map_substitution<> sigma_x = pbes_system::detail::make_fresh_variable_substitution(x.variables(), id_generator, false);
123 const action_formulas::action_formula& alpha = x.body();
124 data::variable_list y = data::replace_variables(x.variables(), sigma_x);
125
126 pbes_expression result;
127 tr::make_forall(result, y, Sat(a, action_formulas::replace_variables_capture_avoiding(alpha, sigma_x), id_generator, TermTraits()));
128 push(result);
129 }
130
132 {
133 data::mutable_map_substitution<> sigma_x = pbes_system::detail::make_fresh_variable_substitution(x.variables(), id_generator, false);
134 const action_formulas::action_formula& alpha = x.body();
135 data::variable_list y = data::replace_variables(x.variables(), sigma_x);
136
137 pbes_expression result;
138 tr::make_exists(result, y, Sat(a, action_formulas::replace_variables_capture_avoiding(alpha, sigma_x), id_generator, TermTraits()));
139 push(result);
140 }
141
142 void apply(const action_formulas::at& x)
143 {
147 push(tr::and_(Sat(a, alpha, id_generator, TermTraits()), atermpp::down_cast<pbes_expression>(data::equal_to(t, u))));
148 }
149};
150
151template <template <class, class> class Traverser, typename TermTraits>
153{
155 using super::enter;
156 using super::leave;
157 using super::apply;
158 using super::top;
159
160 apply_sat_traverser(const lps::multi_action& a, data::set_identifier_generator& id_generator, TermTraits tr)
162 {}
163};
164
165template <typename TermTraits>
166typename TermTraits::term_type Sat(const lps::multi_action& a,
168 data::set_identifier_generator& id_generator,
169 TermTraits tr
170 )
171{
172 apply_sat_traverser<sat_traverser, TermTraits> f(a, id_generator, tr);
173 f.apply(x);
174 return f.top();
175}
176
177} // namespace mcrl2::pbes_system::detail
178
179
180
181
182
183#endif // MCRL2_PBES_DETAIL_LPS2PBES_SAT_H
\brief The and operator for action formulas
\brief The at operator for action formulas
const data::data_expression & time_stamp() const
const action_formula & operand() const
\brief The existential quantification operator for action formulas
const action_formula & body() const
\brief The value false for action formulas
\brief The universal quantification operator for action formulas
const action_formula & body() const
\brief The implication operator for action formulas
\brief The multi action for action formulas
\brief The not operator for action formulas
const action_formula & operand() const
\brief The or operator for action formulas
\brief The value true for action formulas
Identifier generator that stores the identifiers of the context in a set. Using the operator()() and ...
\brief A timed multi-action
const data::data_expression & time() const
The main namespace for the LPS library.
Definition constelm.h:18
TermTraits::term_type Sat(const lps::multi_action &a, const action_formulas::action_formula &x, data::set_identifier_generator &id_generator, TermTraits tr)
const pbes_expression & true_()
const pbes_expression & false_()
apply_sat_traverser(const lps::multi_action &a, data::set_identifier_generator &id_generator, TermTraits tr)
void apply(const action_formulas::forall &x)
const expression_type & top() const
void leave(const action_formulas::true_ &)
std::vector< expression_type > result_stack
void apply(const action_formulas::not_ &x)
void leave(const action_formulas::and_ &)
void leave(const action_formulas::or_ &)
sat_traverser(const lps::multi_action &a_, data::set_identifier_generator &id_generator_, TermTraits)
data::set_identifier_generator & id_generator
void push(const expression_type &x)
void apply(const action_formulas::at &x)
void leave(const data::data_expression &x)
void leave(const action_formulas::imp &)
void leave(const action_formulas::false_ &)
void apply(const action_formulas::exists &x)
void leave(const action_formulas::multi_action &x)