mCRL2
Loading...
Searching...
No Matches
is_monotonous.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/is_monotonous.h
10/// \brief Functions for computing monotonicity of pbes data types.
11
12#ifndef MCRL2_PBES_IS_MONOTONOUS_H
13#define MCRL2_PBES_IS_MONOTONOUS_H
14
15#include "mcrl2/pbes/pbes.h"
16
17
18
19namespace mcrl2::pbes_system
20{
21
22/// \brief Returns true if the pbes expression is monotonous.
23/// \param f A pbes expression.
24/// \return True if the pbes expression is monotonous.
25inline
27{
28 //--- handle negations ---//
29 if (is_not(f))
30 {
31 f = atermpp::down_cast<not_>(f).operand(); // remove the not
33 {
34 return true;
35 }
36 else if (is_true(f))
37 {
38 return true;
39 }
40 else if (is_false(f))
41 {
42 return true;
43 }
44 else if (is_not(f))
45 {
46 return is_monotonous(atermpp::down_cast<not_>(f).operand());
47 }
48 else if (is_and(f))
49 {
50 const auto& left = atermpp::down_cast<and_>(f).left();
51 const auto& right = atermpp::down_cast<and_>(f).right();
52 return is_monotonous(not_(left)) && is_monotonous(not_(right));
53 }
54 else if (is_or(f))
55 {
56 const auto& left = atermpp::down_cast<or_>(f).left();
57 const auto& right = atermpp::down_cast<or_>(f).right();
58 return is_monotonous(not_(left)) && is_monotonous(not_(right));
59 }
60 else if (is_imp(f))
61 {
62 const auto& left = atermpp::down_cast<imp>(f).left();
63 const auto& right = atermpp::down_cast<imp>(f).right();
64 return is_monotonous(left) && is_monotonous(not_(right));
65 }
66 else if (is_forall(f))
67 {
68 const auto& body = atermpp::down_cast<forall>(f).body();
69 return is_monotonous(not_(body));
70 }
71 else if (is_exists(f))
72 {
73 const auto& body = atermpp::down_cast<exists>(f).body();
74 return is_monotonous(not_(body));
75 }
77 {
78 return false;
79 }
80 }
81
82 //--- handle everything except negations ---//
84 {
85 return true;
86 }
87 else if (is_true(f))
88 {
89 return true;
90 }
91 else if (is_false(f))
92 {
93 return true;
94 }
95 else if (is_and(f))
96 {
97 const auto& left = atermpp::down_cast<and_>(f).left();
98 const auto& right = atermpp::down_cast<and_>(f).right();
99 return is_monotonous(left) && is_monotonous(right);
100 }
101 else if (is_or(f))
102 {
103 const auto& left = atermpp::down_cast<or_>(f).left();
104 const auto& right = atermpp::down_cast<or_>(f).right();
105 return is_monotonous(left) && is_monotonous(right);
106 }
107 else if (is_imp(f))
108 {
109 const auto& left = atermpp::down_cast<imp>(f).left();
110 const auto& right = atermpp::down_cast<imp>(f).right();
111 return is_monotonous(not_(left)) && is_monotonous(right);
112 }
113 else if (is_forall(f))
114 {
115 const auto& body = atermpp::down_cast<forall>(f).body();
116 return is_monotonous(body);
117 }
118 else if (is_exists(f))
119 {
120 const auto& body = atermpp::down_cast<exists>(f).body();
121 return is_monotonous(body);
122 }
124 {
125 return true;
126 }
127
128 throw mcrl2::runtime_error(std::string("is_monotonous(pbes_expression) error: unknown argument ") + pp(f));
129 return false;
130}
131
132/// \brief Returns true if the pbes equation is monotonous.
133inline
135{
137}
138
139/// \brief Returns true if the pbes is monotonous.
140inline
141bool is_monotonous(const pbes& p)
142{
143 for (const pbes_equation& eqn: p.equations())
144 {
145 if (!is_monotonous(eqn))
146 {
147 return false;
148 }
149 }
150 return true;
151}
152
153} // namespace mcrl2::pbes_system
154
155
156
157#endif // MCRL2_PBES_IS_MONOTONOUS_H
const pbes_expression & formula() const
Returns the predicate formula on the right hand side of the equation.
parameterized boolean equation system
Definition pbes.h:54
bool is_data_expression(const atermpp::aterm &x)
Test for a data_expression expression.
bool is_not(const atermpp::aterm &x)
bool is_exists(const atermpp::aterm &x)
bool is_or(const atermpp::aterm &x)
bool is_forall(const atermpp::aterm &x)
bool is_monotonous(pbes_expression f)
Returns true if the pbes expression is monotonous.
bool is_false(const pbes_expression &t)
Test for the value false.
bool is_monotonous(const pbes &p)
Returns true if the pbes is monotonous.
bool is_propositional_variable_instantiation(const atermpp::aterm &x)
bool is_and(const atermpp::aterm &x)
bool is_imp(const atermpp::aterm &x)
bool is_true(const pbes_expression &t)
Test for the value true.
bool is_monotonous(const pbes_equation &e)
Returns true if the pbes equation is monotonous.