mCRL2
Loading...
Searching...
No Matches
pbes.cpp
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 pbes.cpp
10/// \brief
11
12#include "mcrl2/pbes/detail/has_propositional_variables.h"
13#include "mcrl2/pbes/detail/instantiate_global_variables.h"
14#include "mcrl2/pbes/detail/is_well_typed.h"
15#include "mcrl2/pbes/detail/occurring_variable_visitor.h"
16#include "mcrl2/pbes/is_bes.h"
17#include "mcrl2/pbes/parse_impl.h"
18#include "mcrl2/pbes/print.h"
19#include "mcrl2/pbes/translate_user_notation.h"
20
21
22
23namespace mcrl2::pbes_system
24{
25
26//--- start generated pbes_system overloads ---//
27std::string pp(const pbes_system::pbes_equation_vector& x, bool arg0) { return pbes_system::pp< pbes_system::pbes_equation_vector >(x, arg0); }
28std::string pp(const pbes_system::pbes_expression_list& x, bool arg0) { return pbes_system::pp< pbes_system::pbes_expression_list >(x, arg0); }
29std::string pp(const pbes_system::pbes_expression_vector& x, bool arg0) { return pbes_system::pp< pbes_system::pbes_expression_vector >(x, arg0); }
30std::string pp(const pbes_system::propositional_variable_list& x, bool arg0) { return pbes_system::pp< pbes_system::propositional_variable_list >(x, arg0); }
31std::string pp(const pbes_system::propositional_variable_vector& x, bool arg0) { return pbes_system::pp< pbes_system::propositional_variable_vector >(x, arg0); }
32std::string pp(const pbes_system::propositional_variable_instantiation_list& x, bool arg0) { return pbes_system::pp< pbes_system::propositional_variable_instantiation_list >(x, arg0); }
33std::string pp(const pbes_system::propositional_variable_instantiation_vector& x, bool arg0) { return pbes_system::pp< pbes_system::propositional_variable_instantiation_vector >(x, arg0); }
34std::string pp(const pbes_system::and_& x, bool arg0) { return pbes_system::pp< pbes_system::and_ >(x, arg0); }
35std::string pp(const pbes_system::exists& x, bool arg0) { return pbes_system::pp< pbes_system::exists >(x, arg0); }
36std::string pp(const pbes_system::fixpoint_symbol& x, bool arg0) { return pbes_system::pp< pbes_system::fixpoint_symbol >(x, arg0); }
37std::string pp(const pbes_system::forall& x, bool arg0) { return pbes_system::pp< pbes_system::forall >(x, arg0); }
38std::string pp(const pbes_system::imp& x, bool arg0) { return pbes_system::pp< pbes_system::imp >(x, arg0); }
39std::string pp(const pbes_system::not_& x, bool arg0) { return pbes_system::pp< pbes_system::not_ >(x, arg0); }
40std::string pp(const pbes_system::or_& x, bool arg0) { return pbes_system::pp< pbes_system::or_ >(x, arg0); }
41std::string pp(const pbes_system::pbes& x, bool arg0) { return pbes_system::pp< pbes_system::pbes >(x, arg0); }
42std::string pp(const pbes_system::pbes_equation& x, bool arg0) { return pbes_system::pp< pbes_system::pbes_equation >(x, arg0); }
43std::string pp(const pbes_system::pbes_expression& x, bool arg0) { return pbes_system::pp< pbes_system::pbes_expression >(x, arg0); }
44std::string pp(const pbes_system::propositional_variable& x, bool arg0) { return pbes_system::pp< pbes_system::propositional_variable >(x, arg0); }
45std::string pp(const pbes_system::propositional_variable_instantiation& x, bool arg0) { return pbes_system::pp< pbes_system::propositional_variable_instantiation >(x, arg0); }
46void normalize_sorts(pbes_system::pbes_equation_vector& x, const data::sort_specification& sortspec) { pbes_system::normalize_sorts< pbes_system::pbes_equation_vector >(x, sortspec); }
47void normalize_sorts(pbes_system::pbes& x, const data::sort_specification& /* sortspec */) { pbes_system::normalize_sorts< pbes_system::pbes >(x, x.data()); }
48pbes_system::pbes_expression normalize_sorts(const pbes_system::pbes_expression& x, const data::sort_specification& sortspec) { return pbes_system::normalize_sorts< pbes_system::pbes_expression >(x, sortspec); }
49void translate_user_notation(pbes_system::pbes& x) { pbes_system::translate_user_notation< pbes_system::pbes >(x); }
50pbes_system::pbes_expression translate_user_notation(const pbes_system::pbes_expression& x) { return pbes_system::translate_user_notation< pbes_system::pbes_expression >(x); }
51std::set<data::sort_expression> find_sort_expressions(const pbes_system::pbes& x) { return pbes_system::find_sort_expressions< pbes_system::pbes >(x); }
52std::set<data::variable> find_all_variables(const pbes_system::pbes& x) { return pbes_system::find_all_variables< pbes_system::pbes >(x); }
53std::set<data::variable> find_free_variables(const pbes_system::pbes& x) { return pbes_system::find_free_variables< pbes_system::pbes >(x); }
54std::set<data::variable> find_free_variables(const pbes_system::pbes_expression& x) { return pbes_system::find_free_variables< pbes_system::pbes_expression >(x); }
55std::set<data::variable> find_free_variables(const pbes_system::pbes_equation& x) { return pbes_system::find_free_variables< pbes_system::pbes_equation >(x); }
56std::set<data::function_symbol> find_function_symbols(const pbes_system::pbes& x) { return pbes_system::find_function_symbols< pbes_system::pbes >(x); }
57std::set<pbes_system::propositional_variable_instantiation> find_propositional_variable_instantiations(const pbes_system::pbes_expression& x) { return pbes_system::find_propositional_variable_instantiations< pbes_system::pbes_expression >(x); }
58std::set<core::identifier_string> find_identifiers(const pbes_system::pbes_expression& x) { return pbes_system::find_identifiers< pbes_system::pbes_expression >(x); }
59bool search_variable(const pbes_system::pbes_expression& x, const data::variable& v) { return pbes_system::search_variable< pbes_system::pbes_expression >(x, v); }
60//--- end generated pbes_system overloads ---//
61
62namespace algorithms {
63
65{
66 pbes_system::detail::instantiate_global_variables(p);
67}
68
69bool is_bes(const pbes& x)
70{
71 return pbes_system::is_bes(x);
72}
73
74} // namespace algorithms
75
77{
79}
80
82 const std::set<data::sort_expression>& declared_sorts,
83 const std::set<data::variable>& declared_global_variables,
84 const data::data_specification& data_spec
85 )
86{
87 return pbes_system::detail::is_well_typed_equation(eqn, declared_sorts, declared_global_variables, data_spec);
88}
89
90bool is_well_typed_pbes(const std::set<data::sort_expression>& declared_sorts,
91 const std::set<data::variable>& declared_global_variables,
92 const std::set<data::variable>& occurring_global_variables,
93 const std::set<propositional_variable>& declared_variables,
94 const std::set<propositional_variable_instantiation>& occ,
96 const data::data_specification& data_spec
97 )
98{
99 return pbes_system::detail::is_well_typed_pbes(declared_sorts, declared_global_variables, occurring_global_variables, declared_variables, occ, init, data_spec);
100}
101
103{
105}
106
108{
109 std::set<propositional_variable_instantiation> result;
110 for (const pbes_equation& eqn: equations())
111 {
112 detail::occurring_variable_visitor f;
113 f.apply(eqn.formula());
114 result.insert(f.variables.begin(), f.variables.end());
115 }
116 return result;
117}
118
119namespace detail {
120
122{
123 core::parser p(parser_tables_mcrl2, core::detail::ambiguity_fn, core::detail::syntax_error_fn);
124 unsigned int start_symbol_index = p.start_symbol_index("PbesExpr");
125 bool partial_parses = false;
126 core::parse_node node = p.parse(text, start_symbol_index, partial_parses);
129 return result;
130}
131
132untyped_pbes parse_pbes_new(const std::string& text)
133{
134 core::parser p(parser_tables_mcrl2, core::detail::ambiguity_fn, core::detail::syntax_error_fn);
135 unsigned int start_symbol_index = p.start_symbol_index("PbesSpec");
136 bool partial_parses = false;
137 core::parse_node node = p.parse(text, start_symbol_index, partial_parses);
140 return result;
141}
142
144{
148}
149
151{
152 core::parser p(parser_tables_mcrl2, core::detail::ambiguity_fn, core::detail::syntax_error_fn);
153 unsigned int start_symbol_index = p.start_symbol_index("PropVarDecl");
154 bool partial_parses = false;
155 core::parse_node node = p.parse(text, start_symbol_index, partial_parses);
157}
158
160{
161 core::parser p(parser_tables_mcrl2, core::detail::ambiguity_fn, core::detail::syntax_error_fn);
162 unsigned int start_symbol_index = p.start_symbol_index("PbesExpr");
163 bool partial_parses = false;
164 core::parse_node node = p.parse(text, start_symbol_index, partial_parses);
167}
168
169} // namespace detail
170
171} // namespace mcrl2::pbes_system
\brief A data variable
Definition variable.h:25
const pbes_expression & formula() const
Returns the predicate formula on the right hand side of the equation.
bool is_solved() const
Returns true if the predicate formula on the right hand side contains no predicate variables.
Definition pbes.cpp:102
parameterized boolean equation system
Definition pbes.h:54
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:107
\brief A propositional variable instantiation
\brief A propositional variable declaration
D_ParserTables parser_tables_mcrl2
void warn_and_or(const parse_node &)
Prints a warning for each occurrence of 'x && y || z' in the parse tree.
void instantiate_global_variables(pbes &p)
Attempts to eliminate the free variables of a PBES, by substituting a constant value for them....
Definition pbes.cpp:64
bool is_bes(const pbes &x)
Returns true if a PBES is in BES form.
Definition pbes.cpp:69
untyped_pbes parse_pbes_new(const std::string &text)
Definition pbes.cpp:132
void complete_pbes(pbes &x)
Definition pbes.cpp:143
bool has_propositional_variables(const pbes_expression &x)
propositional_variable parse_propositional_variable(const std::string &text)
Definition pbes.cpp:150
pbes_expression parse_pbes_expression(const std::string &text)
Definition pbes.cpp:159
bool is_well_typed(const pbes_equation &eqn)
Checks if the equation is well typed.
pbes_expression parse_pbes_expression_new(const std::string &text)
Definition pbes.cpp:121
The main namespace for the PBES library.
std::set< data::variable > find_free_variables(const pbes_system::pbes_equation &x)
Definition pbes.cpp:55
std::string pp(const pbes_system::propositional_variable_list &x, bool arg0)
Definition pbes.cpp:30
std::string pp(const pbes_system::or_ &x, bool arg0)
Definition pbes.cpp:40
std::set< data::variable > find_free_variables(const pbes_system::pbes &x)
Definition pbes.cpp:53
void normalize_sorts(pbes_system::pbes_equation_vector &x, const data::sort_specification &sortspec)
Definition pbes.cpp:46
std::string pp(const pbes_system::imp &x, bool arg0)
Definition pbes.cpp:38
std::string pp(const pbes_system::propositional_variable_instantiation_list &x, bool arg0)
Definition pbes.cpp:32
pbes_system::pbes_expression normalize_sorts(const pbes_system::pbes_expression &x, const data::sort_specification &sortspec)
Definition pbes.cpp:48
std::set< data::sort_expression > find_sort_expressions(const pbes_system::pbes &x)
Definition pbes.cpp:51
std::string pp(const pbes_system::pbes_equation_vector &x, bool arg0)
Definition pbes.cpp:27
std::string pp(const pbes_system::pbes_expression_list &x, bool arg0)
Definition pbes.cpp:28
std::set< pbes_system::propositional_variable_instantiation > find_propositional_variable_instantiations(const pbes_system::pbes_expression &x)
Definition pbes.cpp:57
void normalize_sorts(pbes_system::pbes &x, const data::sort_specification &)
Definition pbes.cpp:47
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:90
std::set< data::function_symbol > find_function_symbols(const pbes_system::pbes &x)
Definition pbes.cpp:56
void typecheck_pbes(pbes &pbesspec)
Type check a parsed mCRL2 pbes specification. Throws an exception if something went wrong.
Definition typecheck.h:272
std::string pp(const pbes_system::propositional_variable &x, bool arg0)
Definition pbes.cpp:44
std::string pp(const pbes_system::exists &x, bool arg0)
Definition pbes.cpp:35
std::string pp(const pbes_system::pbes_expression &x, bool arg0)
Definition pbes.cpp:43
bool is_well_typed(const pbes_equation &eqn)
Definition pbes.cpp:76
std::set< data::variable > find_free_variables(const pbes_system::pbes_expression &x)
Definition pbes.cpp:54
pbes_system::pbes_expression translate_user_notation(const pbes_system::pbes_expression &x)
Definition pbes.cpp:50
bool search_variable(const pbes_system::pbes_expression &x, const data::variable &v)
Definition pbes.cpp:59
std::set< data::variable > find_all_variables(const pbes_system::pbes &x)
Definition pbes.cpp:52
std::string pp(const pbes_system::not_ &x, bool arg0)
Definition pbes.cpp:39
void complete_data_specification(pbes &)
Adds all sorts that appear in the PBES p to the data specification of p.
Definition pbes.h:307
std::string pp(const pbes_system::pbes_equation &x, bool arg0)
Definition pbes.cpp:42
std::set< core::identifier_string > find_identifiers(const pbes_system::pbes_expression &x)
Definition pbes.cpp:58
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:81
std::string pp(const pbes_system::propositional_variable_instantiation &x, bool arg0)
Definition pbes.cpp:45
void translate_user_notation(pbes_system::pbes &x)
Definition pbes.cpp:49
std::string pp(const pbes_system::pbes &x, bool arg0)
Definition pbes.cpp:41
std::string pp(const pbes_system::and_ &x, bool arg0)
Definition pbes.cpp:34
std::string pp(const pbes_system::fixpoint_symbol &x, bool arg0)
Definition pbes.cpp:36
std::string pp(const pbes_system::forall &x, bool arg0)
Definition pbes.cpp:37
pbes_system::propositional_variable parse_PropVarDecl(const core::parse_node &node) const
Definition parse_impl.h:47
pbes_actions(const core::parser &parser_)
Definition parse_impl.h:25
untyped_pbes parse_PbesSpec(const core::parse_node &node) const
Definition parse_impl.h:84
pbes_system::pbes_expression parse_PbesExpr(const core::parse_node &node) const
Definition parse_impl.h:29