diff --git a/src/storage/expressions/Expression.cpp b/src/storage/expressions/Expression.cpp index 3d6094d8b..410b613ec 100644 --- a/src/storage/expressions/Expression.cpp +++ b/src/storage/expressions/Expression.cpp @@ -185,11 +185,26 @@ namespace storm { return Expression(std::shared_ptr(new BinaryNumericalFunctionExpression(first.getManager(), first.getType().plusMinusTimes(second.getType()), first.getBaseExpressionPointer(), second.getBaseExpressionPointer(), BinaryNumericalFunctionExpression::OperatorType::Plus))); } + Expression operator+(Expression const& first, int64_t second) { + return first + Expression(std::shared_ptr(new IntegerLiteralExpression(first.getBaseExpression().getManager(), second))); + } + + Expression operator+(int64_t first, Expression const& second) { + return second + first; + } + Expression operator-(Expression const& first, Expression const& second) { assertSameManager(first.getBaseExpression(), second.getBaseExpression()); return Expression(std::shared_ptr(new BinaryNumericalFunctionExpression(first.getBaseExpression().getManager(), first.getType().plusMinusTimes(second.getType()), first.getBaseExpressionPointer(), second.getBaseExpressionPointer(), BinaryNumericalFunctionExpression::OperatorType::Minus))); } + Expression operator-(Expression const& first, int64_t second) { + return first - Expression(std::shared_ptr(new IntegerLiteralExpression(first.getBaseExpression().getManager(), second))); + } + + Expression operator-(int64_t first, Expression const& second) { + return Expression(std::shared_ptr(new IntegerLiteralExpression(second.getBaseExpression().getManager(), first))) - second; } + Expression operator-(Expression const& first) { return Expression(std::shared_ptr(new UnaryNumericalFunctionExpression(first.getBaseExpression().getManager(), first.getType().minus(), first.getBaseExpressionPointer(), UnaryNumericalFunctionExpression::OperatorType::Minus))); } diff --git a/src/storage/expressions/Expression.h b/src/storage/expressions/Expression.h index 40fcaa572..176d9316d 100644 --- a/src/storage/expressions/Expression.h +++ b/src/storage/expressions/Expression.h @@ -23,7 +23,11 @@ namespace storm { template friend class SubstitutionVisitor; friend Expression operator+(Expression const& first, Expression const& second); + friend Expression operator+(Expression const& first, int64_t second); + friend Expression operator+(int64_t first, Expression const& second); friend Expression operator-(Expression const& first, Expression const& second); + friend Expression operator-(Expression const& first, int64_t second); + friend Expression operator-(int64_t first, Expression const& second); friend Expression operator-(Expression const& first); friend Expression operator*(Expression const& first, Expression const& second); friend Expression operator/(Expression const& first, Expression const& second); @@ -328,7 +332,11 @@ namespace storm { // Provide operator overloads to conveniently construct new expressions from other expressions. Expression operator+(Expression const& first, Expression const& second); + Expression operator+(Expression const& first, int64_t second); + Expression operator+(int64_t first, Expression const& second); Expression operator-(Expression const& first, Expression const& second); + Expression operator-(Expression const& first, int64_t second); + Expression operator-(int64_t first, Expression const& second); Expression operator-(Expression const& first); Expression operator*(Expression const& first, Expression const& second); Expression operator/(Expression const& first, Expression const& second);