mCRL2
Loading...
Searching...
No Matches
pbes_gauss_elimination.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_gauss_elimination.h
10/// \brief add your file description here.
11
12#ifndef MCRL2_PBES_PBES_GAUSS_ELIMINATION_H
13#define MCRL2_PBES_PBES_GAUSS_ELIMINATION_H
14
15#include "mcrl2/pbes/gauss_elimination_algorithm.h"
16#include "mcrl2/pbes/rewriters/enumerate_quantifiers_rewriter.h"
17
18namespace mcrl2::pbes_system
19{
20
21/// \brief Traits class for pbes expressions
23{
24 public:
25 using expression_type = pbes_expression;
26 using variable_type = propositional_variable;
27 using equation_type = pbes_equation;
28 using symbol_type = fixpoint_symbol;
29
30 /// \brief Applies the substitution X := phi to the PBES expression t.
31 /// \param t A PBES expression
32 /// \param X A propositional variable
33 /// \param phi A PBES expression
34 /// \return The substition result
35 static inline
36 expression_type substitute(const expression_type& t, const variable_type& X, const expression_type& phi)
37 {
38 return replace_propositional_variables(t, propositional_variable_substitution(X, phi));
39 }
40
41 /// \brief Returns the value true
42 static inline
43 expression_type true_()
44 {
45 return core::term_traits<expression_type>::true_();
46 }
47
48 /// \brief Returns the value false
49 static inline
50 expression_type false_()
51 {
52 return core::term_traits<expression_type>::false_();
53 }
54
55 /// \brief Returns the fixpoint symbol mu
56 static inline
57 symbol_type mu()
58 {
60 }
61
62 /// \brief Returns the fixpoint symbol nu
63 static inline
64 symbol_type nu()
65 {
67 }
68
69 /// \brief Pretty print an equation without generating a newline after the equal sign
70 /// \param eq An equation
71 /// \return A pretty printed string
72 static inline
74 {
75 return pbes_system::pp(eq.symbol()) + " " + pbes_system::pp(eq.variable()) + " = " + pbes_system::pp(eq.formula());
76 }
77};
78
79/// \brief Solves an equation
80/// \param e A pbes equation
81template <typename Rewriter>
83{
84 const Rewriter& m_rewriter;
85
86 pbes_equation_solver(const Rewriter& rewriter)
87 : m_rewriter(rewriter)
88 {}
89
90 /// \brief Returns true if e.symbol() == nu(), else false.
91 /// \param e A pbes equation
92 /// \return True if e.symbol() == nu(), else false.
94 {
95 using tr = typename core::term_traits<pbes_expression>;
96 return e.symbol().is_nu() ? tr::true_() : tr::false_();
97 }
98
99 /// \brief Solves the equation e
101 {
104 }
105};
106
107/// \brief Utility function for creating a pbes_equation_solver
108template <typename Rewriter>
109pbes_equation_solver<Rewriter> make_pbes_equation_solver(const Rewriter& rewriter)
110{
111 return pbes_equation_solver<Rewriter>(rewriter);
112}
113
114/// \brief Solves a PBES equation system using Gauss elimination.
115/// \pre The pbes \p p is a bes.
116/// \param p A pbes
117/// \return 0 if the solution is false, 1 if the solution is true, 2 if the solution is unknown
118inline
120{
121 using tr = core::term_traits<pbes_expression>;
122
123 data::rewriter datar(p.data());
124 enumerate_quantifiers_rewriter pbesr(datar, p.data());
125
127 algorithm.run(p.equations().begin(), p.equations().end(), pbes_equation_solver<enumerate_quantifiers_rewriter>(pbesr));
128
129 if (tr::is_false(p.equations().front().formula()))
130 {
131 return 0;
132 }
133 else if (tr::is_true(p.equations().front().formula()))
134 {
135 return 1;
136 }
137 else
138 {
139 return 2;
140 }
141}
142
143} // namespace mcrl2::pbes_system
144
145#endif // MCRL2_PBES_PBES_GAUSS_ELIMINATION_H
Rewriter that operates on data expressions.
Definition rewriter.h:84
static fixpoint_symbol nu()
Returns the nu symbol.
bool is_nu() const
Returns true if the symbol is nu.
static fixpoint_symbol mu()
Returns the mu symbol.
Algorithm class for the Gauss elimination algorithm for solving systems of (P)BES equations.
const fixpoint_symbol & symbol() const
Returns the fixpoint symbol of the equation.
propositional_variable & variable()
Returns the pbes variable of the equation.
pbes_expression & formula()
Returns the predicate formula on the right hand side of the equation.
parameterized boolean equation system
Definition pbes.h:54
Substitution function for propositional variables.
propositional_variable_substitution(const propositional_variable &X, const pbes_expression &phi)
Constructor. Initializes the substitution with the assignment X := phi.
\brief A propositional variable declaration
int gauss_elimination(pbes &p)
Solves a PBES equation system using Gauss elimination.
pbes_equation_solver< Rewriter > make_pbes_equation_solver(const Rewriter &rewriter)
Utility function for creating a pbes_equation_solver.
enumerate_quantifiers_rewriter(const data::rewriter &R, const data::data_specification &dataspec, const enumerate_quantifiers_mode enum_mode=expand_infinite_sorts_and_use_data_rewriter)
void operator()(pbes_equation &e)
Solves the equation e.
pbes_expression sigma(const pbes_equation &e)
Returns true if e.symbol() == nu(), else false.
Traits class for pbes expressions.
static std::string print(const equation_type &eq)
Pretty print an equation without generating a newline after the equal sign.
static expression_type true_()
Returns the value true.
static symbol_type nu()
Returns the fixpoint symbol nu.
static symbol_type mu()
Returns the fixpoint symbol mu.
static expression_type false_()
Returns the value false.
static expression_type substitute(const expression_type &t, const variable_type &X, const expression_type &phi)
Applies the substitution X := phi to the PBES expression t.