Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
BaseExpression.cpp
Go to the documentation of this file.
2#include <boost/any.hpp>
7
11
12namespace storm {
13namespace expressions {
14BaseExpression::BaseExpression(ExpressionManager const& manager, Type const& type) : manager(manager), type(type) {
15 // Intentionally left empty.
16}
17
19 return Expression(shared_from_this());
20}
21
23 return this->type;
24}
25
27 return this->getType().isIntegerType();
28}
29
31 return this->getType().isBitVectorType();
32}
33
35 return this->getType().isNumericalType();
36}
37
39 return this->getType().isBooleanType();
40}
41
43 return this->getType().isRationalType();
44}
45
46int_fast64_t BaseExpression::evaluateAsInt(Valuation const*) const {
47 STORM_LOG_THROW(false, storm::exceptions::InvalidTypeException, "Unable to evaluate expression as integer.");
48}
49
51 STORM_LOG_THROW(false, storm::exceptions::InvalidTypeException, "Unable to evaluate expression as boolean.");
52}
53
55 STORM_LOG_THROW(false, storm::exceptions::InvalidTypeException, "Unable to evaluate expression as double.");
56}
57
62
63uint_fast64_t BaseExpression::getArity() const {
64 return 0;
65}
66
67std::shared_ptr<BaseExpression const> BaseExpression::getOperand(uint_fast64_t operandIndex) const {
68 STORM_LOG_THROW(false, storm::exceptions::InvalidAccessException,
69 "Unable to access operand " << operandIndex << " in expression '" << *this << "' of arity 0.");
70}
71
72std::string const& BaseExpression::getIdentifier() const {
73 STORM_LOG_THROW(false, storm::exceptions::InvalidAccessException, "Unable to access identifier of non-constant, non-variable expression.");
74}
75
77 STORM_LOG_THROW(false, storm::exceptions::InvalidAccessException, "Unable to access operator of non-function application expression.");
78}
79
80std::shared_ptr<BaseExpression const> BaseExpression::reduceNesting() const {
83}
84
86 return false;
87}
88
90 return false;
91}
92
94 return false;
95}
96
98 return false;
99}
100
102 return false;
103}
104
106 return false;
107}
108
110 return manager;
111}
112
113std::shared_ptr<BaseExpression const> BaseExpression::getSharedPointer() const {
114 return this->shared_from_this();
115}
116
118 return false;
119}
120
122 return static_cast<IfThenElseExpression const&>(*this);
123}
124
126 return false;
127}
128
132
134 return false;
135}
136
140
142 return false;
143}
144
146 return static_cast<BinaryRelationExpression const&>(*this);
147}
148
150 return false;
151}
152
154 return static_cast<BooleanLiteralExpression const&>(*this);
155}
156
158 return false;
159}
160
162 return static_cast<IntegerLiteralExpression const&>(*this);
163}
164
166 return false;
167}
168
172
174 return false;
175}
176
180
182 return false;
183}
184
188
190 return false;
191}
192
194 return static_cast<VariableExpression const&>(*this);
195}
196
198 return false;
199}
200
202 return static_cast<PredicateExpression const&>(*this);
203}
204
205std::ostream& operator<<(std::ostream& stream, BaseExpression const& expression) {
206 expression.printToStream(stream);
207 return stream;
208}
209} // namespace expressions
210} // namespace storm
The base class of all expression classes.
BinaryNumericalFunctionExpression const & asBinaryNumericalFunctionExpression() const
bool hasBooleanType() const
Retrieves whether the expression has a boolean type.
virtual bool isUnaryBooleanFunctionExpression() const
virtual storm::RationalNumber evaluateAsRational() const
Evaluates the expression and returns the resulting rational number.
virtual bool isBinaryRelationExpression() const
virtual bool isBooleanLiteralExpression() const
Expression toExpression() const
Converts the base expression to a proper expression.
virtual std::string const & getIdentifier() const
Retrieves the identifier associated with this expression.
virtual bool isFunctionApplication() const
Checks if the expression is a function application (of any sort).
BooleanLiteralExpression const & asBooleanLiteralExpression() const
virtual bool isFalse() const
Checks if the expression is equal to the boolean literal false.
virtual bool isBinaryBooleanFunctionExpression() const
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
virtual double evaluateAsDouble(Valuation const *valuation=nullptr) const
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
IntegerLiteralExpression const & asIntegerLiteralExpression() const
virtual bool isBinaryNumericalFunctionExpression() const
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const
Retrieves the given operand from the expression.
std::shared_ptr< BaseExpression const > reduceNesting() const
Tries to flatten the syntax tree of the expression, e.g., 1 + (2 + (3 + 4)) becomes (1 + 2) + (3 + 4)
virtual bool isVariable() const
Retrieves whether the expression is a variable.
bool hasIntegerType() const
Retrieves whether the expression has an integer type.
bool hasBitVectorType() const
Retrieves whether the expression has a bitvector type.
virtual bool isIfThenElseExpression() const
virtual bool evaluateAsBool(Valuation const *valuation=nullptr) const
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
virtual bool isLiteral() const
Retrieves whether the expression is a literal.
bool hasRationalType() const
Retrieves whether the expression has a rational return type.
RationalLiteralExpression const & asRationalLiteralExpression() const
virtual bool isVariableExpression() const
virtual bool isUnaryNumericalFunctionExpression() const
bool hasNumericalType() const
Retrieves whether the expression has a numerical type, i.e., integer or double.
virtual bool isTrue() const
Checks if the expression is equal to the boolean literal true.
VariableExpression const & asVariableExpression() const
Type const & getType() const
Retrieves the type of the expression.
IfThenElseExpression const & asIfThenElseExpression() const
BinaryBooleanFunctionExpression const & asBinaryBooleanFunctionExpression() const
virtual bool isPredicateExpression() const
std::shared_ptr< BaseExpression const > getSharedPointer() const
Retrieves a shared pointer to this expression.
UnaryBooleanFunctionExpression const & asUnaryBooleanFunctionExpression() const
BinaryRelationExpression const & asBinaryRelationExpression() const
virtual uint_fast64_t getArity() const
Returns the arity of the expression.
BaseExpression(ExpressionManager const &manager, Type const &type)
Constructs a base expression with the given return type.
virtual void printToStream(std::ostream &stream) const =0
Prints the expression to the given stream.
virtual bool containsVariables() const
Retrieves whether the expression contains a variable.
virtual OperatorType getOperator() const
Retrieves the operator of a function application.
UnaryNumericalFunctionExpression const & asUnaryNumericalFunctionExpression() const
virtual int_fast64_t evaluateAsInt(Valuation const *valuation=nullptr) const
Evaluates the expression under the valuation of unknowns (variables and constants) given by the valua...
virtual bool isRationalLiteralExpression() const
PredicateExpression const & asPredicateExpression() const
virtual bool isIntegerLiteralExpression() const
std::shared_ptr< BaseExpression const > const & getBaseExpressionPointer() const
Retrieves a pointer to the base expression underlying this expression object.
This class is responsible for managing a set of typed variables and all expressions using these varia...
The base class of all binary expressions.
Expression reduceNesting(Expression const &expression)
Reduces the nesting in the given expression.
RationalNumberType toRationalNumber(Expression const &expression)
bool isBooleanType() const
Checks whether this type is a boolean type.
Definition Type.cpp:178
bool isIntegerType() const
Checks whether this type is an integral type.
Definition Type.cpp:182
bool isNumericalType() const
Checks whether this type is a numerical type.
Definition Type.cpp:190
bool isRationalType() const
Checks whether this type is a rational type.
Definition Type.cpp:214
bool isBitVectorType() const
Checks whether this type is a bitvector type.
Definition Type.cpp:186
The base class of all valuations of variables.
Definition Valuation.h:16
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
std::ostream & operator<<(std::ostream &stream, BaseExpression const &expression)
LabParser.cpp.
Definition cli.cpp:18