mCRL2
Loading...
Searching...
No Matches
is_pfnf.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/is_pfnf.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_DETAIL_IS_PFNF_H
13#define MCRL2_PBES_DETAIL_IS_PFNF_H
14
15#include "mcrl2/pbes/join.h"
16#include "mcrl2/pbes/pbes_functions.h"
17
18
19
20
21
22namespace mcrl2::pbes_system::detail {
23
24/// \brief Splits a conjunction into a sequence of operands
25/// Given a pbes expression of the form p1 && p2 && ... && pn, this will yield a
26/// vector of the form [ p1, p2, ..., pn ], assuming that pi does not have a && as main
27/// function symbol.
28/// \param expr A PBES expression
29/// \return A sequence of operands
30inline
31void split_and(const pbes_expression& expr, std::vector<pbes_expression>& result)
32{
33 using namespace accessors;
34 utilities::detail::split(expr, std::back_inserter(result), is_and, left, right);
35}
36
37/// \brief Splits a conjunction into a sequence of operands
38/// Given a pbes expression of the form p1 || p2 || ... || pn, this will yield a
39/// vector of the form [ p1, p2, ..., pn ], assuming that pi does not have a || as main
40/// function symbol.
41/// \param expr A PBES expression
42/// \return A sequence of operands
43inline
44void split_or(const pbes_expression& expr, std::vector<pbes_expression>& result)
45{
46 using namespace accessors;
47 utilities::detail::split(expr, std::back_inserter(result), is_or, left, right);
48}
49
50inline
52{
53 return is_simple_expression(x, false) || data::is_data_expression(x);
54}
55
56inline
58{
60}
61
62inline
64{
65 bool result;
66 if (is_or(x))
67 {
69 }
70 else
71 {
73 }
74 return result;
75}
76
77// Determines if an expression has the format \/_{j in Ji} Xj(ej)
78inline
80{
82}
83
84// Determines if an expression has the format g_i => x with is_pfnf_or(x)
85inline
87{
88 bool result;
90 {
91 result = true;
92 }
93 else if (is_imp(x))
94 {
96 }
97 else
98 {
99 result = is_pfnf_or(x);
100 }
101 return result;
102}
103
104// Determines if an expression has the format /\_{i in I} x_i with is_pfnf_imp(x_i)
105inline
107{
108 bool result = true;
109 for (const pbes_expression& term: pbes_system::split_and(x))
110 {
111 if (!is_pfnf_imp(term))
112 {
113 result = false;
114 }
115 }
116 return result;
117}
118
119// Determines if an expression has the format h /\ x with is_pfnf_inner_and(x), where the 'h /\' part is optional
120inline
122{
123 bool result = true;
124
125 std::vector<pbes_expression> v;
126 split_and(x, v);
127 std::size_t simple_count = 0;
128 for (auto i = v.begin(); i != v.end(); ++i)
129 {
130 if (is_pfnf_inner_and(x))
131 {
132 continue;
133 }
134 else if (is_pfnf_simple_expression(x))
135 {
136 simple_count++;
137 if (simple_count > 1)
138 {
139 result = false;
140 }
141 }
142 else
143 {
144 result = false;
145 }
146 }
147 return result;
148}
149
150// Determines if an expression is in pfnf format
151inline
153{
154 if (is_forall(x))
155 {
157 }
158 else if (is_exists(x))
159 {
161 }
162 else
163 {
164 return is_pfnf_outer_and(x);
165 }
166}
167
169{
171 using super::enter;
172 using super::leave;
173 using super::apply;
174
175 bool result = true;
176
177 void apply(const pbes_expression& x)
178 {
180 }
181};
182
183template <typename T>
184bool is_pfnf(const T& x)
185{
187 f.apply(x);
188 return f.result;
189}
190
191inline
193{
194 pbes_expression y = x;
195
196 // strip the quantifiers
197 while (is_forall(y) || is_exists(y))
198 {
199 if (is_forall(y))
200 {
202 }
203 else if (is_exists(y))
204 {
206 }
207 }
208 return y;
209}
210
211// returns the implications /\_{i in I} x_i
212// \pre x is in PFNF format
213inline
215{
217
218 std::vector<pbes_expression> result;
219 split_and(y, result);
220
221 // eliminate simple expressions from result
222 result.erase(std::remove_if(result.begin(), result.end(), &is_pfnf_simple_expression), result.end());
223
224 return result;
225}
226
227// extracts the guards h and [g_i | i in I] from a pbes expression in PFNF format
228inline
229void split_pfnf_expression(const pbes_expression& phi, pbes_expression& h, std::vector<pbes_expression>& g)
230{
232 std::vector<pbes_expression> v;
233 split_and(x, v);
234 h = true_();
235 for (pbes_expression& expr: v)
236 {
237 if (is_pfnf_simple_expression(expr))
238 {
239 pbes_system::make_optimized_and(h, h, expr);
240 }
241 else
242 {
243 g.push_back(expr);
244 }
245 }
246}
247
248} // namespace mcrl2::pbes_system::detail
249
250
251
252
253
254#endif // MCRL2_PBES_DETAIL_IS_PFNF_H
\brief The existential quantification operator for pbes expressions
exists(const atermpp::aterm &term)
const pbes_expression & body() const
\brief The universal quantification operator for pbes expressions
const pbes_expression & body() const
forall(const atermpp::aterm &term)
\brief The implication operator for pbes expressions
const pbes_expression & left() const
imp(const atermpp::aterm &term)
const pbes_expression & right() const
\brief The or operator for pbes expressions
const pbes_expression & left() const
const pbes_expression & right() const
or_(const atermpp::aterm &term)
pbes_expression & operator=(const pbes_expression &) noexcept=default
bool is_data_expression(const atermpp::aterm &x)
Test for a data_expression expression.
The namespace for accessor functions on pbes expressions.
std::vector< pbes_expression > pfnf_implications(const pbes_expression &x)
Definition is_pfnf.h:214
bool is_pfnf_simple_expression(const pbes_expression &x)
Definition is_pfnf.h:51
bool is_pfnf_or_expression(const pbes_expression &x)
Definition is_pfnf.h:63
void split_and(const pbes_expression &expr, std::vector< pbes_expression > &result)
Splits a conjunction into a sequence of operands Given a pbes expression of the form p1 && p2 && ....
Definition is_pfnf.h:31
bool is_pfnf_or(const pbes_expression &x)
Definition is_pfnf.h:79
bool is_pfnf_inner_and(const pbes_expression &x)
Definition is_pfnf.h:106
bool is_pfnf_data_expression(const pbes_expression &x)
Definition is_pfnf.h:57
void split_or(const pbes_expression &expr, std::vector< pbes_expression > &result)
Splits a conjunction into a sequence of operands Given a pbes expression of the form p1 || p2 || ....
Definition is_pfnf.h:44
void split_pfnf_expression(const pbes_expression &phi, pbes_expression &h, std::vector< pbes_expression > &g)
Definition is_pfnf.h:229
bool is_pfnf(const T &x)
Definition is_pfnf.h:184
bool is_pfnf_imp(const pbes_expression &x)
Definition is_pfnf.h:86
pbes_expression remove_quantifiers(const pbes_expression &x)
Definition is_pfnf.h:192
bool is_pfnf_outer_and(const pbes_expression &x)
Definition is_pfnf.h:121
bool is_pfnf_expression(const pbes_expression &x)
Definition is_pfnf.h:152
const pbes_expression & true_()
bool is_exists(const atermpp::aterm &x)
bool is_or(const atermpp::aterm &x)
bool is_forall(const atermpp::aterm &x)
bool is_false(const pbes_expression &t)
Test for the value false.
bool is_propositional_variable_instantiation(const atermpp::aterm &x)
bool is_imp(const atermpp::aterm &x)
bool is_true(const pbes_expression &t)
Test for the value true.
void apply(const pbes_expression &x)
Definition is_pfnf.h:177