Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
storm::expressions::BaseExpression Class Referenceabstract

The base class of all expression classes. More...

#include <BaseExpression.h>

Inheritance diagram for storm::expressions::BaseExpression:
Collaboration diagram for storm::expressions::BaseExpression:

Public Member Functions

 BaseExpression (ExpressionManager const &manager, Type const &type)
 Constructs a base expression with the given return type.
 
 BaseExpression (BaseExpression const &)=default
 
BaseExpressionoperator= (BaseExpression const &)=delete
 
 BaseExpression (BaseExpression &&)=default
 
BaseExpressionoperator= (BaseExpression &&)=delete
 
virtual ~BaseExpression ()=default
 
Expression toExpression () const
 Converts the base expression to a proper expression.
 
virtual bool evaluateAsBool (Valuation const *valuation=nullptr) const
 Evaluates the expression under the valuation of unknowns (variables and constants) given by the valuation and returns the resulting boolean value.
 
virtual int_fast64_t evaluateAsInt (Valuation const *valuation=nullptr) const
 Evaluates the expression under the valuation of unknowns (variables and constants) given by the valuation and returns the resulting integer value.
 
virtual double evaluateAsDouble (Valuation const *valuation=nullptr) const
 Evaluates the expression under the valuation of unknowns (variables and constants) given by the valuation and returns the resulting double value.
 
virtual storm::RationalNumber evaluateAsRational () const
 Evaluates the expression and returns the resulting rational number.
 
virtual uint_fast64_t getArity () const
 Returns the arity of the expression.
 
virtual std::shared_ptr< BaseExpression const > getOperand (uint_fast64_t operandIndex) const
 Retrieves the given operand from the expression.
 
virtual std::string const & getIdentifier () const
 Retrieves the identifier associated with this expression.
 
virtual OperatorType getOperator () const
 Retrieves the operator of a function application.
 
virtual bool containsVariables () const
 Retrieves whether the expression contains a variable.
 
virtual bool isLiteral () const
 Retrieves whether the expression is a literal.
 
virtual bool isVariable () const
 Retrieves whether the expression is a variable.
 
virtual bool isTrue () const
 Checks if the expression is equal to the boolean literal true.
 
virtual bool isFalse () const
 Checks if the expression is equal to the boolean literal false.
 
virtual bool isFunctionApplication () const
 Checks if the expression is a function application (of any sort).
 
virtual void gatherVariables (std::set< storm::expressions::Variable > &variables) const =0
 Retrieves the set of all variables that appear in the expression.
 
virtual std::shared_ptr< BaseExpression const > simplify () const =0
 Simplifies the expression according to some simple rules.
 
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 boost::any accept (ExpressionVisitor &visitor, boost::any const &data) const =0
 Accepts the given visitor by calling its visit method.
 
bool hasNumericalType () const
 Retrieves whether the expression has a numerical type, i.e., integer or double.
 
bool hasIntegerType () const
 Retrieves whether the expression has an integer type.
 
bool hasBitVectorType () const
 Retrieves whether the expression has a bitvector type.
 
bool hasBooleanType () const
 Retrieves whether the expression has a boolean type.
 
bool hasRationalType () const
 Retrieves whether the expression has a rational return type.
 
std::shared_ptr< BaseExpression const > getSharedPointer () const
 Retrieves a shared pointer to this expression.
 
ExpressionManager const & getManager () const
 Retrieves the manager responsible for this expression.
 
Type const & getType () const
 Retrieves the type of the expression.
 
virtual bool isIfThenElseExpression () const
 
IfThenElseExpression const & asIfThenElseExpression () const
 
virtual bool isBinaryBooleanFunctionExpression () const
 
BinaryBooleanFunctionExpression const & asBinaryBooleanFunctionExpression () const
 
virtual bool isBinaryNumericalFunctionExpression () const
 
BinaryNumericalFunctionExpression const & asBinaryNumericalFunctionExpression () const
 
virtual bool isBinaryRelationExpression () const
 
BinaryRelationExpression const & asBinaryRelationExpression () const
 
virtual bool isBooleanLiteralExpression () const
 
BooleanLiteralExpression const & asBooleanLiteralExpression () const
 
virtual bool isIntegerLiteralExpression () const
 
IntegerLiteralExpression const & asIntegerLiteralExpression () const
 
virtual bool isRationalLiteralExpression () const
 
RationalLiteralExpression const & asRationalLiteralExpression () const
 
virtual bool isUnaryBooleanFunctionExpression () const
 
UnaryBooleanFunctionExpression const & asUnaryBooleanFunctionExpression () const
 
virtual bool isUnaryNumericalFunctionExpression () const
 
UnaryNumericalFunctionExpression const & asUnaryNumericalFunctionExpression () const
 
virtual bool isVariableExpression () const
 
VariableExpression const & asVariableExpression () const
 
virtual bool isPredicateExpression () const
 
PredicateExpression const & asPredicateExpression () const
 

Protected Member Functions

virtual void printToStream (std::ostream &stream) const =0
 Prints the expression to the given stream.
 

Friends

std::ostream & operator<< (std::ostream &stream, BaseExpression const &expression)
 

Detailed Description

The base class of all expression classes.

Definition at line 43 of file BaseExpression.h.

Constructor & Destructor Documentation

◆ BaseExpression() [1/3]

storm::expressions::BaseExpression::BaseExpression ( ExpressionManager const &  manager,
Type const &  type 
)

Constructs a base expression with the given return type.

Parameters
typeThe type of the expression.

Definition at line 14 of file BaseExpression.cpp.

◆ BaseExpression() [2/3]

storm::expressions::BaseExpression::BaseExpression ( BaseExpression const &  )
default

◆ BaseExpression() [3/3]

storm::expressions::BaseExpression::BaseExpression ( BaseExpression &&  )
default

◆ ~BaseExpression()

virtual storm::expressions::BaseExpression::~BaseExpression ( )
virtualdefault

Member Function Documentation

◆ accept()

◆ asBinaryBooleanFunctionExpression()

BinaryBooleanFunctionExpression const & storm::expressions::BaseExpression::asBinaryBooleanFunctionExpression ( ) const

Definition at line 129 of file BaseExpression.cpp.

◆ asBinaryNumericalFunctionExpression()

BinaryNumericalFunctionExpression const & storm::expressions::BaseExpression::asBinaryNumericalFunctionExpression ( ) const

Definition at line 137 of file BaseExpression.cpp.

◆ asBinaryRelationExpression()

BinaryRelationExpression const & storm::expressions::BaseExpression::asBinaryRelationExpression ( ) const

Definition at line 145 of file BaseExpression.cpp.

◆ asBooleanLiteralExpression()

BooleanLiteralExpression const & storm::expressions::BaseExpression::asBooleanLiteralExpression ( ) const

Definition at line 153 of file BaseExpression.cpp.

◆ asIfThenElseExpression()

IfThenElseExpression const & storm::expressions::BaseExpression::asIfThenElseExpression ( ) const

Definition at line 121 of file BaseExpression.cpp.

◆ asIntegerLiteralExpression()

IntegerLiteralExpression const & storm::expressions::BaseExpression::asIntegerLiteralExpression ( ) const

Definition at line 161 of file BaseExpression.cpp.

◆ asPredicateExpression()

PredicateExpression const & storm::expressions::BaseExpression::asPredicateExpression ( ) const

Definition at line 201 of file BaseExpression.cpp.

◆ asRationalLiteralExpression()

RationalLiteralExpression const & storm::expressions::BaseExpression::asRationalLiteralExpression ( ) const

Definition at line 169 of file BaseExpression.cpp.

◆ asUnaryBooleanFunctionExpression()

UnaryBooleanFunctionExpression const & storm::expressions::BaseExpression::asUnaryBooleanFunctionExpression ( ) const

Definition at line 177 of file BaseExpression.cpp.

◆ asUnaryNumericalFunctionExpression()

UnaryNumericalFunctionExpression const & storm::expressions::BaseExpression::asUnaryNumericalFunctionExpression ( ) const

Definition at line 185 of file BaseExpression.cpp.

◆ asVariableExpression()

VariableExpression const & storm::expressions::BaseExpression::asVariableExpression ( ) const

Definition at line 193 of file BaseExpression.cpp.

◆ containsVariables()

bool storm::expressions::BaseExpression::containsVariables ( ) const
virtual

◆ evaluateAsBool()

bool storm::expressions::BaseExpression::evaluateAsBool ( Valuation const *  valuation = nullptr) const
virtual

Evaluates the expression under the valuation of unknowns (variables and constants) given by the valuation and returns the resulting boolean value.

If the return type of the expression is not a boolean an exception is thrown.

Parameters
valuationThe valuation of unknowns under which to evaluate the expression.
Returns
The boolean value of the expression under the given valuation.

Reimplemented in storm::expressions::BinaryBooleanFunctionExpression, storm::expressions::BinaryRelationExpression, storm::expressions::BooleanLiteralExpression, storm::expressions::IfThenElseExpression, storm::expressions::PredicateExpression, storm::expressions::UnaryBooleanFunctionExpression, and storm::expressions::VariableExpression.

Definition at line 50 of file BaseExpression.cpp.

◆ evaluateAsDouble()

double storm::expressions::BaseExpression::evaluateAsDouble ( Valuation const *  valuation = nullptr) const
virtual

Evaluates the expression under the valuation of unknowns (variables and constants) given by the valuation and returns the resulting double value.

If the return type of the expression is not a double an exception is thrown.

Parameters
valuationThe valuation of unknowns under which to evaluate the expression.
Returns
The double value of the expression under the given valuation.

Reimplemented in storm::expressions::BinaryNumericalFunctionExpression, storm::expressions::IfThenElseExpression, storm::expressions::IntegerLiteralExpression, storm::expressions::RationalLiteralExpression, storm::expressions::UnaryNumericalFunctionExpression, storm::expressions::VariableExpression, and storm::expressions::TranscendentalNumberLiteralExpression.

Definition at line 54 of file BaseExpression.cpp.

◆ evaluateAsInt()

int_fast64_t storm::expressions::BaseExpression::evaluateAsInt ( Valuation const *  valuation = nullptr) const
virtual

Evaluates the expression under the valuation of unknowns (variables and constants) given by the valuation and returns the resulting integer value.

If the return type of the expression is not an integer an exception is thrown.

Parameters
valuationThe valuation of unknowns under which to evaluate the expression.
Returns
The integer value of the expression under the given valuation.

Reimplemented in storm::expressions::BinaryNumericalFunctionExpression, storm::expressions::IfThenElseExpression, storm::expressions::IntegerLiteralExpression, storm::expressions::UnaryNumericalFunctionExpression, and storm::expressions::VariableExpression.

Definition at line 46 of file BaseExpression.cpp.

◆ evaluateAsRational()

storm::RationalNumber storm::expressions::BaseExpression::evaluateAsRational ( ) const
virtual

Evaluates the expression and returns the resulting rational number.

If the return type of the expression is not a rational number or the expression could not be evaluated, an exception is thrown.

Returns
The rational number value of the expression.

Definition at line 58 of file BaseExpression.cpp.

◆ gatherVariables()

◆ getArity()

uint_fast64_t storm::expressions::BaseExpression::getArity ( ) const
virtual

Returns the arity of the expression.

Returns
The arity of the expression.

Reimplemented in storm::expressions::BinaryExpression, storm::expressions::IfThenElseExpression, storm::expressions::PredicateExpression, and storm::expressions::UnaryExpression.

Definition at line 63 of file BaseExpression.cpp.

◆ getIdentifier()

std::string const & storm::expressions::BaseExpression::getIdentifier ( ) const
virtual

Retrieves the identifier associated with this expression.

This is only legal to call if the expression is a variable.

Returns
The identifier associated with this expression.

Reimplemented in storm::expressions::VariableExpression.

Definition at line 72 of file BaseExpression.cpp.

◆ getManager()

ExpressionManager const & storm::expressions::BaseExpression::getManager ( ) const

Retrieves the manager responsible for this expression.

Returns
The manager responsible for this expression.

Definition at line 109 of file BaseExpression.cpp.

◆ getOperand()

std::shared_ptr< BaseExpression const > storm::expressions::BaseExpression::getOperand ( uint_fast64_t  operandIndex) const
virtual

Retrieves the given operand from the expression.

Parameters
operandIndexThe index of the operand to retrieve. This must be lower than the arity of the expression.
Returns
The operand at the given index.

Reimplemented in storm::expressions::BinaryExpression, storm::expressions::IfThenElseExpression, storm::expressions::PredicateExpression, and storm::expressions::UnaryExpression.

Definition at line 67 of file BaseExpression.cpp.

◆ getOperator()

OperatorType storm::expressions::BaseExpression::getOperator ( ) const
virtual

Retrieves the operator of a function application.

This is only legal to call if the expression is function application.

Returns
The operator associated with the function application.

Reimplemented in storm::expressions::BinaryBooleanFunctionExpression, storm::expressions::BinaryNumericalFunctionExpression, storm::expressions::BinaryRelationExpression, storm::expressions::IfThenElseExpression, storm::expressions::PredicateExpression, storm::expressions::UnaryBooleanFunctionExpression, and storm::expressions::UnaryNumericalFunctionExpression.

Definition at line 76 of file BaseExpression.cpp.

◆ getSharedPointer()

std::shared_ptr< BaseExpression const > storm::expressions::BaseExpression::getSharedPointer ( ) const

Retrieves a shared pointer to this expression.

Returns
A shared pointer to this expression.

Definition at line 113 of file BaseExpression.cpp.

◆ getType()

Type const & storm::expressions::BaseExpression::getType ( ) const

Retrieves the type of the expression.

Returns
The type of the expression.

Definition at line 22 of file BaseExpression.cpp.

◆ hasBitVectorType()

bool storm::expressions::BaseExpression::hasBitVectorType ( ) const

Retrieves whether the expression has a bitvector type.

Returns
True iff the expression has a bitvector type.

Definition at line 30 of file BaseExpression.cpp.

◆ hasBooleanType()

bool storm::expressions::BaseExpression::hasBooleanType ( ) const

Retrieves whether the expression has a boolean type.

Returns
True iff the expression has a boolean type.

Definition at line 38 of file BaseExpression.cpp.

◆ hasIntegerType()

bool storm::expressions::BaseExpression::hasIntegerType ( ) const

Retrieves whether the expression has an integer type.

Returns
True iff the expression has an integer type.

Definition at line 26 of file BaseExpression.cpp.

◆ hasNumericalType()

bool storm::expressions::BaseExpression::hasNumericalType ( ) const

Retrieves whether the expression has a numerical type, i.e., integer or double.

Returns
True iff the expression has a numerical type.

Definition at line 34 of file BaseExpression.cpp.

◆ hasRationalType()

bool storm::expressions::BaseExpression::hasRationalType ( ) const

Retrieves whether the expression has a rational return type.

Returns
True iff the expression has a rational return type.

Definition at line 42 of file BaseExpression.cpp.

◆ isBinaryBooleanFunctionExpression()

bool storm::expressions::BaseExpression::isBinaryBooleanFunctionExpression ( ) const
virtual

Reimplemented in storm::expressions::BinaryBooleanFunctionExpression.

Definition at line 125 of file BaseExpression.cpp.

◆ isBinaryNumericalFunctionExpression()

bool storm::expressions::BaseExpression::isBinaryNumericalFunctionExpression ( ) const
virtual

Reimplemented in storm::expressions::BinaryNumericalFunctionExpression.

Definition at line 133 of file BaseExpression.cpp.

◆ isBinaryRelationExpression()

bool storm::expressions::BaseExpression::isBinaryRelationExpression ( ) const
virtual

Reimplemented in storm::expressions::BinaryRelationExpression.

Definition at line 141 of file BaseExpression.cpp.

◆ isBooleanLiteralExpression()

bool storm::expressions::BaseExpression::isBooleanLiteralExpression ( ) const
virtual

Reimplemented in storm::expressions::BooleanLiteralExpression.

Definition at line 149 of file BaseExpression.cpp.

◆ isFalse()

bool storm::expressions::BaseExpression::isFalse ( ) const
virtual

Checks if the expression is equal to the boolean literal false.

Returns
True iff the expression is equal to the boolean literal false.

Reimplemented in storm::expressions::BooleanLiteralExpression.

Definition at line 101 of file BaseExpression.cpp.

◆ isFunctionApplication()

bool storm::expressions::BaseExpression::isFunctionApplication ( ) const
virtual

Checks if the expression is a function application (of any sort).

Returns
True iff the expression is a function application.

Reimplemented in storm::expressions::BinaryExpression, storm::expressions::IfThenElseExpression, storm::expressions::PredicateExpression, and storm::expressions::UnaryExpression.

Definition at line 105 of file BaseExpression.cpp.

◆ isIfThenElseExpression()

bool storm::expressions::BaseExpression::isIfThenElseExpression ( ) const
virtual

Reimplemented in storm::expressions::IfThenElseExpression.

Definition at line 117 of file BaseExpression.cpp.

◆ isIntegerLiteralExpression()

bool storm::expressions::BaseExpression::isIntegerLiteralExpression ( ) const
virtual

Reimplemented in storm::expressions::IntegerLiteralExpression.

Definition at line 157 of file BaseExpression.cpp.

◆ isLiteral()

bool storm::expressions::BaseExpression::isLiteral ( ) const
virtual

Retrieves whether the expression is a literal.

Returns
True iff the expression is a literal.

Reimplemented in storm::expressions::BooleanLiteralExpression, storm::expressions::IntegerLiteralExpression, storm::expressions::RationalLiteralExpression, and storm::expressions::TranscendentalNumberLiteralExpression.

Definition at line 89 of file BaseExpression.cpp.

◆ isPredicateExpression()

bool storm::expressions::BaseExpression::isPredicateExpression ( ) const
virtual

Reimplemented in storm::expressions::PredicateExpression.

Definition at line 197 of file BaseExpression.cpp.

◆ isRationalLiteralExpression()

bool storm::expressions::BaseExpression::isRationalLiteralExpression ( ) const
virtual

Reimplemented in storm::expressions::RationalLiteralExpression.

Definition at line 165 of file BaseExpression.cpp.

◆ isTrue()

bool storm::expressions::BaseExpression::isTrue ( ) const
virtual

Checks if the expression is equal to the boolean literal true.

Returns
True iff the expression is equal to the boolean literal true.

Reimplemented in storm::expressions::BooleanLiteralExpression.

Definition at line 97 of file BaseExpression.cpp.

◆ isUnaryBooleanFunctionExpression()

bool storm::expressions::BaseExpression::isUnaryBooleanFunctionExpression ( ) const
virtual

Reimplemented in storm::expressions::UnaryBooleanFunctionExpression.

Definition at line 173 of file BaseExpression.cpp.

◆ isUnaryNumericalFunctionExpression()

bool storm::expressions::BaseExpression::isUnaryNumericalFunctionExpression ( ) const
virtual

Reimplemented in storm::expressions::UnaryNumericalFunctionExpression.

Definition at line 181 of file BaseExpression.cpp.

◆ isVariable()

bool storm::expressions::BaseExpression::isVariable ( ) const
virtual

Retrieves whether the expression is a variable.

Returns
True iff the expression is a variable.

Reimplemented in storm::expressions::VariableExpression.

Definition at line 93 of file BaseExpression.cpp.

◆ isVariableExpression()

bool storm::expressions::BaseExpression::isVariableExpression ( ) const
virtual

Reimplemented in storm::expressions::VariableExpression.

Definition at line 189 of file BaseExpression.cpp.

◆ operator=() [1/2]

BaseExpression & storm::expressions::BaseExpression::operator= ( BaseExpression &&  )
delete

◆ operator=() [2/2]

BaseExpression & storm::expressions::BaseExpression::operator= ( BaseExpression const &  )
delete

◆ printToStream()

◆ reduceNesting()

std::shared_ptr< BaseExpression const > storm::expressions::BaseExpression::reduceNesting ( ) const

Tries to flatten the syntax tree of the expression, e.g., 1 + (2 + (3 + 4)) becomes (1 + 2) + (3 + 4)

Returns
A semantically equivalent expression with reduced nesting

Definition at line 80 of file BaseExpression.cpp.

◆ simplify()

◆ toExpression()

Expression storm::expressions::BaseExpression::toExpression ( ) const

Converts the base expression to a proper expression.

Definition at line 18 of file BaseExpression.cpp.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  stream,
BaseExpression const &  expression 
)
friend

Definition at line 205 of file BaseExpression.cpp.


The documentation for this class was generated from the following files: