mCRL2
Loading...
Searching...
No Matches
pbes.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/pbes.h
10/// \brief The class pbes.
11
12#ifndef MCRL2_PBES_PBES_H
13#define MCRL2_PBES_PBES_H
14
15#include "mcrl2/data/detail/equal_sorts.h"
16#include "mcrl2/pbes/pbes_equation.h"
17
18namespace mcrl2
19{
20
21/// \brief The main namespace for the PBES library.
22namespace pbes_system
23{
24
25class pbes;
27
28// template function overloads
29std::string pp(const pbes& x);
30void normalize_sorts(pbes& x, const data::sort_specification& sortspec);
36
38 const std::set<data::sort_expression>& declared_sorts,
39 const std::set<data::variable>& declared_global_variables,
40 const data::data_specification& data_spec
41 );
42
43bool is_well_typed_pbes(const std::set<data::sort_expression>& declared_sorts,
44 const std::set<data::variable>& declared_global_variables,
45 const std::set<data::variable>& occurring_global_variables,
46 const std::set<propositional_variable>& declared_variables,
47 const std::set<propositional_variable_instantiation>& occ,
49 const data::data_specification& data_spec
50 );
51
53
54/// \brief parameterized boolean equation system
55// <PBES> ::= PBES(<DataSpec>, <GlobVarSpec>, <PBEqnSpec>, <PBInit>)
56// <PBEqnSpec> ::= PBEqnSpec(<PBEqn>*)
57class pbes
58{
59 public:
61
62 protected:
63 /// \brief The data specification
65
66 /// \brief The sequence of pbes equations
68
69 /// \brief The set of global variables
71
72 /// \brief The initial state
74
75 /// \brief Returns the predicate variables appearing in the left hand side of an equation.
76 /// \return The predicate variables appearing in the left hand side of an equation.
78 {
79 std::set<propositional_variable> result;
80 for (const pbes_equation& eqn: equations())
81 {
82 result.insert(eqn.variable());
83 }
84 return result;
85 }
86
87 /// \brief Checks if the propositional variable instantiation v appears with the right type in the
88 /// sequence of propositional variable declarations [first, last).
89 /// \param first Start of a sequence of propositional variable declarations
90 /// \param last End of a sequence of propositional variable declarations
91 /// \param v A propositional variable instantation
92 /// \param data_spec A data specification.
93 /// \return True if the type of \p v is matched correctly
94 /// \param v A propositional variable instantiation
95 template <typename Iter>
96 bool is_declared_in(Iter first, Iter last, const propositional_variable_instantiation& v, const data::data_specification& data_spec) const
97 {
98 for (Iter i = first; i != last; ++i)
99 {
100 if (i->name() == v.name() && data::detail::equal_sorts(i->parameters(), v.parameters(), data_spec))
101 {
102 return true;
103 }
104 }
105 return false;
106 }
107
108 public:
109 /// \brief Constructor.
110 pbes() = default;
111
112 /// \brief Constructor.
113 /// \param data A data specification
114 /// \param equations A sequence of pbes equations
115 /// \param initial_state A propositional variable instantiation
117 const std::vector<pbes_equation>& equations,
119 :
120 m_data(data),
122 m_initial_state(initial_state)
123 {
124 m_global_variables = pbes_system::find_free_variables(*this);
125 assert(core::detail::check_rule_PBES(pbes_to_aterm(*this)));
126 assert(is_well_typed());
127 }
128
129 /// \brief Constructor.
130 /// \param data A data specification
131 /// \param equations A sequence of pbes equations
132 /// \param global_variables A sequence of free variables
133 /// \param initial_state A propositional variable instantiation
135 const std::set<data::variable>& global_variables,
136 const std::vector<pbes_equation>& equations,
138 :
139 m_data(data),
142 m_initial_state(initial_state)
143 {
144 assert(core::detail::check_rule_PBES(pbes_to_aterm(*this)));
145 assert(is_well_typed());
146 }
147
148 /// \brief Returns the data specification.
149 /// \return The data specification of the pbes
150 const data::data_specification& data() const
151 {
152 return m_data;
153 }
154
155 /// \brief Returns the data specification.
156 /// \return The data specification of the pbes
158 {
159 return m_data;
160 }
161
162 /// \brief Returns the equations.
163 /// \return The equations.
165 {
166 return m_equations;
167 }
168
169 /// \brief Returns the equations.
170 /// \return The equations.
172 {
173 return m_equations;
174 }
175
176 /// \brief Returns the declared free variables of the pbes.
177 /// \return The declared free variables of the pbes.
179 {
180 return m_global_variables;
181 }
182
183 /// \brief Returns the declared free variables of the pbes.
184 /// \return The declared free variables of the pbes.
186 {
187 return m_global_variables;
188 }
189
190 /// \brief Returns the initial state.
191 /// \return The initial state.
193 {
194 return m_initial_state;
195 }
196
197 /// \brief Returns the initial state.
198 /// \return The initial state.
200 {
201 return m_initial_state;
202 }
203
204 /// \brief Returns the set of binding variables of the pbes.
205 /// This is the set variables that occur on the left hand side of an equation.
206 /// \return The set of binding variables of the pbes.
208 {
209 using namespace std::rel_ops; // for definition of operator!= in terms of operator==
210
211 std::set<propositional_variable> result;
212 for (const pbes_equation& eqn: equations())
213 {
214 result.insert(eqn.variable());
215 }
216 return result;
217 }
218
219 /// \brief Returns the set of occurring propositional variable instantiations of the pbes.
220 /// This is the set of variables that occur in the right hand side of an equation.
221 /// \return The occurring propositional variable instantiations of the pbes
223
224 /// \brief Returns the set of occurring propositional variable declarations of the pbes, i.e.
225 /// the propositional variable declarations that occur in the right hand side of an equation.
226 /// \return The occurring propositional variable declarations of the pbes
228 {
229 std::set<propositional_variable> result;
230 std::set<propositional_variable_instantiation> occ = occurring_variable_instantiations();
231 std::map<core::identifier_string, propositional_variable> declared_variables;
232 for (const pbes_equation& eqn: equations())
233 {
234 declared_variables[eqn.variable().name()] = eqn.variable();
235 }
236 for (const propositional_variable_instantiation& v: occ)
237 {
238 result.insert(declared_variables[v.name()]);
239 }
240 return result;
241 }
242
243 /// \brief True if the pbes is closed
244 /// \return Returns true if all occurring variables are binding variables, and the initial state variable is a binding variable.
245 bool is_closed() const
246 {
247 std::set<propositional_variable> bnd = binding_variables();
248 std::set<propositional_variable> occ = occurring_variables();
249 return std::includes(bnd.begin(), bnd.end(), occ.begin(), occ.end()) && is_declared_in(bnd.begin(), bnd.end(), initial_state(), data());
250 }
251
252 /// \brief Checks if the PBES is well typed
253 /// \return True if
254 /// <ul>
255 /// <li>the sorts occurring in the free variables of the equations are declared in the data specification</li>
256 /// <li>the sorts occurring in the binding variable parameters are declared in the data specification </li>
257 /// <li>the sorts occurring in the quantifier variables of the equations are declared in the data specification </li>
258 /// <li>the binding variables of the equations have unique names (well formedness)</li>
259 /// <li>the global variables occurring in the equations are declared in global_variables()</li>
260 /// <li>the global variables occurring in the equations with the same name are identical</li>
261 /// <li>the declared global variables and the quantifier variables occurring in the equations have different names</li>
262 /// <li>the predicate variable instantiations occurring in the equations match with their declarations</li>
263 /// <li>the predicate variable instantiation occurring in the initial state matches with the declaration</li>
264 /// <li>the data specification is well typed</li>
265 /// </ul>
266 /// N.B. Conflicts between the types of instantiations and declarations of binding variables are not checked!
267 bool is_well_typed() const
268 {
269 std::set<data::sort_expression> declared_sorts = data::detail::make_set(data().sorts());
270 const std::set<data::variable>& declared_global_variables = global_variables();
271 std::set<data::variable> occurring_global_variables = pbes_system::find_free_variables(*this);
272 std::set<propositional_variable> declared_variables = compute_declared_variables();
273 std::set<propositional_variable_instantiation> occ = occurring_variable_instantiations();
274
275 // check 1), 4), 5), 6), 8) and 9)
276 if (!is_well_typed_pbes(declared_sorts, declared_global_variables, occurring_global_variables, declared_variables, occ, initial_state(), data()))
277 {
278 return false;
279 }
280
281 // check 2), 3) and 7)
282 for (const pbes_equation& eqn: equations())
283 {
284 if (!is_well_typed_equation(eqn, declared_sorts, declared_global_variables, data()))
285 {
286 return false;
287 }
288 }
289
290 // check 10)
291 return data().is_well_typed();
292 }
293};
294
295//--- start generated class pbes ---//
296// prototype declaration
297std::string pp(const pbes& x);
298
299/// \\brief Outputs the object to a stream
300/// \\param out An output stream
301/// \\param x Object x
302/// \\return The output stream
303inline
304std::ostream& operator<<(std::ostream& out, const pbes& x)
305{
306 return out << pbes_system::pp(x);
307}
308//--- end generated class pbes ---//
309
310
311/// \brief Adds all sorts that appear in the PBES \a p to the data specification of \a p.
312/// \param p a PBES.
313inline
315{
316 std::set<data::sort_expression> s = pbes_system::find_sort_expressions(p);
317 p.data().add_context_sorts(s);
318}
319
320/// \brief Equality operator on PBESs
321/// \return True if the PBESs have exactly the same internal representation. Note
322/// that this is in general not a very useful test.
323// TODO: improve the comparison
324inline
325bool operator==(const pbes& p1, const pbes& p2)
326{
328}
329
330} // namespace pbes_system
331
332} // namespace mcrl2
333
334#endif // MCRL2_PBES_PBES_H
bool operator==(const unprotected_aterm_core &t) const
Comparison operator.
Definition aterm_core.h:83
bool is_well_typed() const
Returns true if.
Algorithm class for the abstract algorithm.
Definition abstract.h:120
void run(pbes &p, const detail::pbes_parameter_map &parameter_map, bool value_true)
Runs the algorithm.
Definition abstract.h:126
parameterized boolean equation system
Definition pbes.h:58
std::set< data::variable > & global_variables()
Returns the declared free variables of the pbes.
Definition pbes.h:185
bool is_closed() const
True if the pbes is closed.
Definition pbes.h:245
data::data_specification m_data
The data specification.
Definition pbes.h:64
pbes(const data::data_specification &data, const std::vector< pbes_equation > &equations, propositional_variable_instantiation initial_state)
Constructor.
Definition pbes.h:116
std::set< data::variable > m_global_variables
The set of global variables.
Definition pbes.h:70
std::set< propositional_variable > compute_declared_variables() const
Returns the predicate variables appearing in the left hand side of an equation.
Definition pbes.h:77
pbes_equation equation_type
Definition pbes.h:60
pbes(const data::data_specification &data, const std::set< data::variable > &global_variables, const std::vector< pbes_equation > &equations, propositional_variable_instantiation initial_state)
Constructor.
Definition pbes.h:134
const propositional_variable_instantiation & initial_state() const
Returns the initial state.
Definition pbes.h:192
std::set< propositional_variable > binding_variables() const
Returns the set of binding variables of the pbes. This is the set variables that occur on the left ha...
Definition pbes.h:207
std::set< propositional_variable > occurring_variables() const
Returns the set of occurring propositional variable declarations of the pbes, i.e....
Definition pbes.h:227
std::set< propositional_variable_instantiation > occurring_variable_instantiations() const
Returns the set of occurring propositional variable instantiations of the pbes. This is the set of va...
Definition pbes.cpp:108
const std::set< data::variable > & global_variables() const
Returns the declared free variables of the pbes.
Definition pbes.h:178
std::vector< pbes_equation > & equations()
Returns the equations.
Definition pbes.h:171
propositional_variable_instantiation & initial_state()
Returns the initial state.
Definition pbes.h:199
propositional_variable_instantiation m_initial_state
The initial state.
Definition pbes.h:73
pbes()=default
Constructor.
std::vector< pbes_equation > m_equations
The sequence of pbes equations.
Definition pbes.h:67
bool is_declared_in(Iter first, Iter last, const propositional_variable_instantiation &v, const data::data_specification &data_spec) const
Checks if the propositional variable instantiation v appears with the right type in the sequence of p...
Definition pbes.h:96
const std::vector< pbes_equation > & equations() const
Returns the equations.
Definition pbes.h:164
bool is_well_typed() const
Checks if the PBES is well typed.
Definition pbes.h:267
\brief A propositional variable instantiation
const data::data_expression_list & parameters() const
propositional_variable_instantiation(const propositional_variable_instantiation &) noexcept=default
Move semantics.
Standard exception class for reporting runtime errors.
Definition exception.h:27
Simple timer to time the CPU time used by a piece of code.
void write_report(std::ostream &s)
Write the report to an output stream.
std::map< std::string, timing > m_timings
collection of timings
void start(const std::string &timing_name)
Start measurement with a hint.
std::string m_filename
name of the file to write timings to
void finish(const std::string &timing_name)
Finish a measurement with a hint.
void report()
Write all timing information that has been recorded.
execution_timer(const std::string &tool_name="", std::string const &filename="")
Constructor of a simple execution timer.
std::string m_tool_name
name of the tool we are timing
std::vector< std::string > m_extensions
const std::string & shortname() const
bool operator==(const file_format &other) const
bool operator<(const file_format &other) const
const std::string & description() const
The main namespace for the aterm++ library.
Definition algorithm.h:21
bool equal_sorts(const data::variable_list &v, const data::data_expression_list &w, const data::data_specification &data_spec)
Checks if the sorts of the variables/expressions in both lists are equal.
Definition equal_sorts.h:28
Namespace for all data library functionality.
Definition data.cpp:22
rewrite_strategy
The strategy of the rewriter.
void normalize(pbes &x)
The function normalize brings (embedded) pbes expressions into positive normal form,...
std::map< core::identifier_string, std::vector< data::variable > > pbes_parameter_map
Data structure for storing the variables that should be expanded by the finite pbesinst algorithm.
pbes_parameter_map parse_pbes_parameter_map(const pbes &p, const std::string &text)
Parses parameter selection for finite pbesinst algorithm.
The main namespace for the PBES library.
bool is_pbes_file_format(const utilities::file_format &format)
Definition io.h:29
void lps2pbes(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &output_format, const std::string &formula_filename, bool timed, bool structured, bool unoptimized, bool preprocess_modal_operators, bool generate_counter_example, bool check_only)
Definition lps2pbes.h:42
std::set< data::variable > find_free_variables(const pbes_system::pbes &x)
Definition pbes.cpp:54
std::string description(const absinthe_strategy strategy)
Prints an absinthe strategy.
std::istream & operator>>(std::istream &is, pbesinst_strategy &s)
std::istream & operator>>(std::istream &is, absinthe_strategy &strategy)
pbes_rewriter_type parse_pbes_rewriter_type(const std::string &type)
Parses a pbes rewriter type.
void pbesabstract(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &input_format, const utilities::file_format &output_format, const std::string &parameter_selection, bool value_true)
pbes_rewriter_type
An enumerated type for the available pbes rewriters.
std::set< data::sort_expression > find_sort_expressions(const pbes_system::pbes &x)
Definition pbes.cpp:52
const utilities::file_format & pbes_format_internal_bes()
Definition io.h:46
void txt2pbes(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &output_format, bool normalize)
Definition txt2pbes.h:21
void pbesstategraph(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &input_format, const utilities::file_format &output_format, const pbesstategraph_options &options)
void lpsbisim2pbes(const std::string &input_filename1, const std::string &input_filename2, const std::string &output_filename, const utilities::file_format &output_format, bisimulation_type type, bool normalize)
const utilities::file_format & pbes_format_pgsolver()
Definition io.h:48
void complps2pbes(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &output_format, const std::string &formula_filename)
void normalize_sorts(pbes_system::pbes &x, const data::sort_specification &)
Definition pbes.cpp:48
pbesinst_strategy
pbesinst transformation strategies
void pbesrewr(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &input_format, const utilities::file_format &output_format, data::rewrite_strategy rewrite_strategy, pbes_rewriter_type rewriter_type)
Definition pbesrewr.h:31
std::istream & operator>>(std::istream &is, pbes_rewriter_type &t)
Stream operator for rewriter type.
bool is_well_typed_pbes(const std::set< data::sort_expression > &declared_sorts, const std::set< data::variable > &declared_global_variables, const std::set< data::variable > &occurring_global_variables, const std::set< propositional_variable > &declared_variables, const std::set< propositional_variable_instantiation > &occ, const propositional_variable_instantiation &init, const data::data_specification &data_spec)
Definition pbes.cpp:91
void pbesinfo(const std::string &input_filename, const std::string &input_file_message, const utilities::file_format &file_format, bool opt_full)
Definition pbesinfo.h:22
std::set< data::function_symbol > find_function_symbols(const pbes_system::pbes &x)
Definition pbes.cpp:57
void pbespareqelm(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &input_format, const utilities::file_format &output_format, data::rewrite_strategy rewrite_strategy, pbes_rewriter_type rewriter_type, bool ignore_initial_state)
void pbespp(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &input_format, core::print_format_type format, bool use_pfnf_printer)
Definition pbespp.h:22
void pbesparelm(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &input_format, const utilities::file_format &output_format)
Definition pbesparelm.h:22
pbesinst_strategy parse_pbesinst_strategy(const std::string &s)
Parse a pbesinst transformation strategy.
atermpp::aterm pbes_to_aterm(const pbes &p)
Conversion to atermappl.
Definition io.cpp:328
std::string print_pbesinst_strategy(const pbesinst_strategy strategy)
Returns a string representation of a pbesinst transformation strategy.
std::istream & operator>>(std::istream &is, bisimulation_type &t)
bool operator==(const pbes &p1, const pbes &p2)
Equality operator on PBESs.
Definition pbes.h:325
const std::vector< utilities::file_format > & pbes_file_formats()
Definition io.cpp:26
void save_bes_pgsolver(const pbes &bes, std::ostream &stream, bool maxpg)
Definition pgsolver.cpp:142
std::string print_pbes_rewriter_type(const pbes_rewriter_type type)
Prints a pbes rewriter type.
std::string pp(const pbes_system::pbes &x)
Definition pbes.cpp:42
std::string print_absinthe_strategy(const absinthe_strategy strategy)
Prints an absinthe strategy.
void save_pbes(const pbes &pbes, std::ostream &stream, utilities::file_format format)
Save a PBES in the format specified.
Definition io.cpp:49
std::string print_bisimulation_type(const bisimulation_type t)
Returns a description of a bisimulation type.
std::set< data::variable > find_all_variables(const pbes_system::pbes &x)
Definition pbes.cpp:53
void complete_data_specification(pbes &)
Adds all sorts that appear in the PBES p to the data specification of p.
Definition pbes.h:314
bisimulation_type
An enumerated type for the available bisimulation types.
const utilities::file_format & pbes_format_internal()
Definition io.h:42
void pbesconstelm(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &input_format, const utilities::file_format &output_format, data::rewrite_strategy rewrite_strategy, pbes_rewriter_type rewriter_type, bool compute_conditions, bool remove_redundant_equations, bool check_quantifiers)
const utilities::file_format & pbes_format_text()
Definition io.h:44
bool is_well_typed_equation(const pbes_equation &eqn, const std::set< data::sort_expression > &declared_sorts, const std::set< data::variable > &declared_global_variables, const data::data_specification &data_spec)
Definition pbes.cpp:82
absinthe_strategy parse_absinthe_strategy(const std::string &strategy)
Parses an absinthe strategy.
std::string description(const pbes_rewriter_type type)
Returns a description of a pbes rewriter.
std::string description(const pbesinst_strategy strategy)
Returns a string representation of a pbesinst transformation strategy.
void translate_user_notation(pbes_system::pbes &x)
Definition pbes.cpp:50
std::string description(const bisimulation_type t)
Returns a description of a bisimulation type.
void pbesabsinthe(const std::string &input_filename, const std::string &output_filename, const utilities::file_format &input_format, const utilities::file_format &output_format, const std::string &abstraction_file, absinthe_strategy strategy, bool print_used_function_symbols, bool enable_logging)
bisimulation_type parse_bisimulation_type(const std::string &type)
Returns the string corresponding to a bisimulation type.
absinthe_strategy
The approximation strategies of the absinthe tool.
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Pair of start and finish times.
std::chrono::steady_clock::time_point finish
std::chrono::steady_clock::time_point start
std::size_t operator()(const atermpp::detail::reference_aterm< T > &t) const