mCRL2
Loading...
Searching...
No Matches
pbes_equation.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_equation.h
10/// \brief The class pbes_equation.
11
12#ifndef MCRL2_PBES_PBES_EQUATION_H
13#define MCRL2_PBES_PBES_EQUATION_H
14
15#include "mcrl2/data/detail/sequence_algorithm.h"
16#include "mcrl2/pbes/fixpoint_symbol.h"
17#include "mcrl2/pbes/pbes_expression.h"
18
19namespace mcrl2::pbes_system
20{
21
22class pbes_equation;
24bool is_well_typed(const pbes_equation& eqn);
26
27/// \brief pbes equation.
29{
30 protected:
31 /// \brief The fixpoint symbol of the equation
33
34 /// \brief The variable on the left hand side of the equation
36
37 /// \brief The expression on the right hand side of the equation
39
40 public:
41 /// \brief The expression type of the equation.
42 using term_type = pbes_expression;
43
44 /// \brief The variable type of the equation.
45 using variable_type = propositional_variable;
46
47 /// \brief The symbol type of the equation.
48 using symbol_type = fixpoint_symbol;
49
50 /// \brief Constructor.
51 pbes_equation() = default;
52
53 /// \brief Constructor.
54 /// \param symbol A fixpoint symbol
55 /// \param variable A propositional variable declaration
56 /// \param expr A PBES expression
57 pbes_equation(const fixpoint_symbol& symbol, const propositional_variable& variable, const pbes_expression& expr)
58 :
59 m_symbol(symbol),
60 m_variable(variable),
61 m_formula(expr)
62 {
63 }
64
65 /// \brief Returns the fixpoint symbol of the equation.
66 /// \return The fixpoint symbol of the equation.
67 const fixpoint_symbol& symbol() const
68 {
69 return m_symbol;
70 }
71
72 /// \brief Returns the fixpoint symbol of the equation.
73 /// \return The fixpoint symbol of the equation.
75 {
76 return m_symbol;
77 }
78
79 /// \brief Returns the pbes variable of the equation.
80 /// \return The pbes variable of the equation.
82 {
83 return m_variable;
84 }
85
86 /// \brief Returns the pbes variable of the equation.
87 /// \return The pbes variable of the equation.
89 {
90 return m_variable;
91 }
92
93 /// \brief Returns the predicate formula on the right hand side of the equation.
94 /// \return The predicate formula on the right hand side of the equation.
95 const pbes_expression& formula() const
96 {
97 return m_formula;
98 }
99
100 /// \brief Returns the predicate formula on the right hand side of the equation.
101 /// \return The predicate formula on the right hand side of the equation.
103 {
104 return m_formula;
105 }
106
107 /// \brief Returns true if the predicate formula on the right hand side contains no predicate variables.
108 // (Comment Wieger: is_const would be a better name)
109 /// \return True if the predicate formula on the right hand side contains no predicate variables.
110 bool is_solved() const;
111
112 /// \brief Swaps the contents
113 void swap(pbes_equation& other) noexcept
114 {
115 using std::swap;
119 }
120
121 /// \brief A comparison operator on pbes equations.
122 /// \details The comparison is on the addresses of aterm objects and can therefore differ in every run.
123 /// \param other The variable to compare with.
124 /// \return True if the this argument is smaller than other.
125 bool operator<(const pbes_equation& other) const
126 {
127 return (m_formula < other.m_formula) ||
128 ((m_formula == other.m_formula &&
129 (m_variable < other.m_variable ||
130 (m_variable == other.m_variable &&
131 m_symbol < other.m_symbol))));
132 }
133};
134
135//--- start generated class pbes_equation ---//
136/// \\brief list of pbes_equations
137using pbes_equation_list = atermpp::term_list<pbes_equation>;
138
139/// \\brief vector of pbes_equations
141
142// prototype declaration
143std::string pp(const pbes_equation& x, bool precedence_aware = true);
144
145/// \\brief Outputs the object to a stream
146/// \\param out An output stream
147/// \\param x Object x
148/// \\return The output stream
149inline
151{
152 return out << pbes_system::pp(x);
153}
154
155/// \\brief swap overload
156inline void swap(pbes_equation& t1, pbes_equation& t2) noexcept
157{
158 t1.swap(t2);
159}
160//--- end generated class pbes_equation ---//
161
162inline bool
164{
165 return x.symbol() == y.symbol() &&
168}
169
170inline bool
172{
173 return !(x == y);
174}
175
176/// \brief Conversion to atermaPpl.
177/// \return The specification converted to aterm format.
178inline
180{
181 return atermpp::aterm(core::detail::function_symbol_PBEqn(), eqn.symbol(), eqn.variable(), eqn.formula());
182}
183
184// template function overloads
186void normalize_sorts(pbes_equation_vector& x, const data::sort_specification& sortspec);
188
189} // namespace mcrl2::pbes_system
190
191#endif // MCRL2_PBES_PBES_EQUATION_H
A list of aterm objects.
Definition aterm_list.h:26
A unordered_map class in which aterms can be stored.
bool is_well_typed() const
Returns true if.
\brief A data variable
Definition variable.h:25
\brief The and operator for pbes expressions
const pbes_expression & left() const
const pbes_expression & right() const
\brief The existential quantification operator for pbes expressions
const data::variable_list & variables() const
const pbes_expression & body() const
fixpoint_symbol(const fixpoint_symbol &) noexcept=default
Move semantics.
\brief The universal quantification operator for pbes expressions
const pbes_expression & body() const
const data::variable_list & variables() const
\brief The implication operator for pbes expressions
const pbes_expression & left() const
const pbes_expression & right() const
\brief The not operator for pbes expressions
const pbes_expression & operand() const
\brief The or operator for pbes expressions
const pbes_expression & left() const
const pbes_expression & right() const
const pbes_expression & formula() const
Returns the predicate formula on the right hand side of the equation.
fixpoint_symbol & symbol()
Returns the fixpoint symbol of the equation.
pbes_equation(const fixpoint_symbol &symbol, const propositional_variable &variable, const pbes_expression &expr)
Constructor.
bool is_solved() const
Returns true if the predicate formula on the right hand side contains no predicate variables.
Definition pbes.cpp:102
fixpoint_symbol m_symbol
The fixpoint symbol of the equation.
propositional_variable m_variable
The variable on the left hand side of the equation.
const fixpoint_symbol & symbol() const
Returns the fixpoint symbol of the equation.
bool operator<(const pbes_equation &other) const
A comparison operator on pbes equations.
propositional_variable & variable()
Returns the pbes variable of the equation.
pbes_expression m_formula
The expression on the right hand side of the equation.
void swap(pbes_equation &other) noexcept
Swaps the contents.
pbes_equation()=default
Constructor.
pbes_expression & formula()
Returns the predicate formula on the right hand side of the equation.
const propositional_variable & variable() const
Returns the pbes variable of the equation.
pbes_expression(const pbes_expression &) noexcept=default
Move semantics.
parameterized boolean equation system
Definition pbes.h:54
std::set< data::variable > & global_variables()
Returns the declared free variables of the pbes.
Definition pbes.h:180
bool is_closed() const
True if the pbes is closed.
Definition pbes.h:238
data::data_specification m_data
The data specification.
Definition pbes.h:60
pbes(const data::data_specification &data, const std::vector< pbes_equation > &equations, propositional_variable_instantiation initial_state)
Constructor.
Definition pbes.h:111
std::set< data::variable > m_global_variables
The set of global variables.
Definition pbes.h:66
std::set< propositional_variable > compute_declared_variables() const
Returns the predicate variables appearing in the left hand side of an equation.
Definition pbes.h:73
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:129
const propositional_variable_instantiation & initial_state() const
Returns the initial state.
Definition pbes.h:187
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:202
std::set< propositional_variable > occurring_variables() const
Returns the set of occurring propositional variable declarations of the pbes, i.e....
Definition pbes.h:220
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
const std::set< data::variable > & global_variables() const
Returns the declared free variables of the pbes.
Definition pbes.h:173
std::vector< pbes_equation > & equations()
Returns the equations.
Definition pbes.h:166
propositional_variable_instantiation & initial_state()
Returns the initial state.
Definition pbes.h:194
propositional_variable_instantiation m_initial_state
The initial state.
Definition pbes.h:69
pbes()=default
Constructor.
std::vector< pbes_equation > m_equations
The sequence of pbes equations.
Definition pbes.h:63
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:91
const std::vector< pbes_equation > & equations() const
Returns the equations.
Definition pbes.h:159
bool is_well_typed() const
Checks if the PBES is well typed.
Definition pbes.h:260
\brief A propositional variable instantiation
const data::data_expression_list & parameters() const
propositional_variable_instantiation(const propositional_variable_instantiation &) noexcept=default
Move semantics.
\brief A propositional variable declaration
const data::variable_list & parameters() const
propositional_variable(const propositional_variable &) noexcept=default
Move semantics.
const core::identifier_string & name() const
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.
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:25
bool is_data_expression(const atermpp::aterm &x)
Test for a data_expression expression.
bool is_untyped_data_parameter(const atermpp::aterm &x)
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::ostream & operator<<(std::ostream &out, const pbes_equation &x)
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
bool operator!=(const pbes_equation &x, const pbes_equation &y)
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
bool is_not(const atermpp::aterm &x)
std::set< pbes_system::propositional_variable_instantiation > find_propositional_variable_instantiations(const pbes_system::pbes_expression &x)
Definition pbes.cpp:57
bool is_exists(const atermpp::aterm &x)
bool operator==(const pbes_equation &x, const pbes_equation &y)
void normalize_sorts(pbes_system::pbes &x, const data::sort_specification &)
Definition pbes.cpp:47
std::ostream & operator<<(std::ostream &out, const pbes &x)
Definition pbes.h:297
bool is_or(const atermpp::aterm &x)
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
bool has_propositional_variables(const pbes_expression &x)
bool is_forall(const atermpp::aterm &x)
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
atermpp::aterm pbes_to_aterm(const pbes &p)
Conversion to atermappl.
Definition io.cpp:315
bool operator==(const pbes &p1, const pbes &p2)
Equality operator on PBESs.
Definition pbes.h:318
void swap(pbes_equation &t1, pbes_equation &t2) noexcept
\brief swap overload
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
void swap(propositional_variable &t1, propositional_variable &t2) noexcept
\brief swap overload
atermpp::aterm pbes_equation_to_aterm(const pbes_equation &eqn)
Conversion to atermaPpl.
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
void swap(pbes_expression &t1, pbes_expression &t2) noexcept
\brief swap overload
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_propositional_variable_instantiation(const atermpp::aterm &x)
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
bool is_and(const atermpp::aterm &x)
std::string pp(const pbes_equation_vector &x)
void translate_user_notation(pbes_system::pbes &x)
Definition pbes.cpp:49
void swap(fixpoint_symbol &t1, fixpoint_symbol &t2) noexcept
\brief swap overload
std::string pp(const pbes_system::pbes &x, bool arg0)
Definition pbes.cpp:41
bool is_imp(const atermpp::aterm &x)
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
expression traverser that visits all sub expressions
Definition traverser.h:29
void apply(const pbes_system::imp &x)
Definition traverser.h:236
void apply(const pbes_system::not_ &x)
Definition traverser.h:213
void apply(const pbes_system::propositional_variable_instantiation &x)
Definition traverser.h:206
void apply(const pbes_system::exists &x)
Definition traverser.h:251
void apply(const pbes_system::pbes &x)
Definition traverser.h:198
void apply(const pbes_system::pbes_equation &x)
Definition traverser.h:191
void apply(const pbes_system::pbes_expression &x)
Definition traverser.h:258
void apply(const pbes_system::or_ &x)
Definition traverser.h:228
void apply(const pbes_system::and_ &x)
Definition traverser.h:220
void apply(const pbes_system::forall &x)
Definition traverser.h:244
void apply(const pbes_system::pbes_expression &x)
Definition traverser.h:662
void apply(const pbes_system::exists &x)
Definition traverser.h:654
void apply(const pbes_system::propositional_variable &x)
Definition traverser.h:582
void apply(const pbes_system::forall &x)
Definition traverser.h:646
void apply(const pbes_system::pbes_equation &x)
Definition traverser.h:590
void apply(const pbes_system::propositional_variable_instantiation &x)
Definition traverser.h:607
void apply(const pbes_system::propositional_variable_instantiation &x)
Definition traverser.h:332
void apply(const pbes_system::and_ &x)
Definition traverser.h:346
void apply(const pbes_system::forall &x)
Definition traverser.h:370
void apply(const pbes_system::pbes_equation &x)
Definition traverser.h:318
void apply(const pbes_system::or_ &x)
Definition traverser.h:354
void apply(const pbes_system::imp &x)
Definition traverser.h:362
void apply(const pbes_system::pbes_expression &x)
Definition traverser.h:384
void apply(const pbes_system::exists &x)
Definition traverser.h:377
void apply(const pbes_system::not_ &x)
Definition traverser.h:339
void apply(const pbes_system::pbes &x)
Definition traverser.h:325
void apply(const pbes_system::exists &x)
Definition traverser.h:123
void apply(const pbes_system::or_ &x)
Definition traverser.h:99
void apply(const pbes_system::propositional_variable_instantiation &x)
Definition traverser.h:77
void apply(const pbes_system::propositional_variable &x)
Definition traverser.h:53
void apply(const pbes_system::imp &x)
Definition traverser.h:107
void apply(const pbes_system::and_ &x)
Definition traverser.h:91
void apply(const pbes_system::pbes &x)
Definition traverser.h:68
void apply(const pbes_system::forall &x)
Definition traverser.h:115
void apply(const pbes_system::pbes_equation &x)
Definition traverser.h:60
void apply(const pbes_system::pbes_expression &x)
Definition traverser.h:131
void apply(const pbes_system::not_ &x)
Definition traverser.h:84
void apply(const pbes_system::pbes &x)
Definition traverser.h:459
void apply(const pbes_system::propositional_variable &x)
Definition traverser.h:444
void apply(const pbes_system::or_ &x)
Definition traverser.h:490
void apply(const pbes_system::propositional_variable_instantiation &x)
Definition traverser.h:468
void apply(const pbes_system::not_ &x)
Definition traverser.h:475
void apply(const pbes_system::exists &x)
Definition traverser.h:514
void apply(const pbes_system::and_ &x)
Definition traverser.h:482
void apply(const pbes_system::imp &x)
Definition traverser.h:498
void apply(const pbes_system::pbes_expression &x)
Definition traverser.h:522
void apply(const pbes_system::pbes_equation &x)
Definition traverser.h:451
void apply(const pbes_system::forall &x)
Definition traverser.h:506
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
Traversal class for pbes_expressions. Used as a base class for pbes_expression_traverser.
Definition traverser.h:23
void apply(const data::data_expression &x)
Definition traverser.h:29
void apply(const data::untyped_data_parameter &x)
Definition traverser.h:36