Browse Source
added visitor that checks for syntatical equality of expressions
added visitor that checks for syntatical equality of expressions
Former-commit-id:mainb6753a4891
[formerly2b36b42bfa
] Former-commit-id:f693de5f30
48 changed files with 677 additions and 327 deletions
-
54src/adapters/AddExpressionAdapter.cpp
-
20src/adapters/AddExpressionAdapter.h
-
44src/adapters/MathsatExpressionAdapter.h
-
44src/adapters/Z3ExpressionAdapter.cpp
-
20src/adapters/Z3ExpressionAdapter.h
-
82src/storage/expressions/BaseExpression.cpp
-
46src/storage/expressions/BaseExpression.h
-
4src/storage/expressions/BinaryBooleanFunctionExpression.cpp
-
2src/storage/expressions/BinaryBooleanFunctionExpression.h
-
4src/storage/expressions/BinaryNumericalFunctionExpression.cpp
-
2src/storage/expressions/BinaryNumericalFunctionExpression.h
-
4src/storage/expressions/BinaryRelationExpression.cpp
-
2src/storage/expressions/BinaryRelationExpression.h
-
4src/storage/expressions/BooleanLiteralExpression.cpp
-
2src/storage/expressions/BooleanLiteralExpression.h
-
13src/storage/expressions/Expression.cpp
-
9src/storage/expressions/Expression.h
-
20src/storage/expressions/ExpressionVisitor.h
-
4src/storage/expressions/IfThenElseExpression.cpp
-
2src/storage/expressions/IfThenElseExpression.h
-
4src/storage/expressions/IntegerLiteralExpression.cpp
-
2src/storage/expressions/IntegerLiteralExpression.h
-
28src/storage/expressions/LinearCoefficientVisitor.cpp
-
20src/storage/expressions/LinearCoefficientVisitor.h
-
28src/storage/expressions/LinearityCheckVisitor.cpp
-
20src/storage/expressions/LinearityCheckVisitor.h
-
4src/storage/expressions/RationalLiteralExpression.cpp
-
2src/storage/expressions/RationalLiteralExpression.h
-
44src/storage/expressions/SubstitutionVisitor.cpp
-
20src/storage/expressions/SubstitutionVisitor.h
-
155src/storage/expressions/SyntacticalEqualityCheckVisitor.cpp
-
27src/storage/expressions/SyntacticalEqualityCheckVisitor.h
-
108src/storage/expressions/ToExprtkStringVisitor.cpp
-
20src/storage/expressions/ToExprtkStringVisitor.h
-
26src/storage/expressions/ToRationalFunctionVisitor.cpp
-
20src/storage/expressions/ToRationalFunctionVisitor.h
-
26src/storage/expressions/ToRationalNumberVisitor.cpp
-
20src/storage/expressions/ToRationalNumberVisitor.h
-
4src/storage/expressions/UnaryBooleanFunctionExpression.cpp
-
2src/storage/expressions/UnaryBooleanFunctionExpression.h
-
4src/storage/expressions/UnaryNumericalFunctionExpression.cpp
-
2src/storage/expressions/UnaryNumericalFunctionExpression.h
-
4src/storage/expressions/VariableExpression.cpp
-
2src/storage/expressions/VariableExpression.h
-
4src/storage/jani/Assignment.cpp
-
2src/storage/jani/Assignment.h
-
8src/storage/jani/Edge.cpp
-
16src/storage/jani/Edge.h
@ -0,0 +1,155 @@ |
|||
#include "src/storage/expressions/SyntacticalEqualityCheckVisitor.h"
|
|||
|
|||
#include "src/storage/expressions/Expressions.h"
|
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
|
|||
bool SyntacticalEqualityCheckVisitor::isSyntaticallyEqual(storm::expressions::Expression const& expression1, storm::expressions::Expression const& expression2) { |
|||
return boost::any_cast<bool>(expression1.accept(*this, std::ref(expression2.getBaseExpression()))); |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(IfThenElseExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isIfThenElseExpression()) { |
|||
IfThenElseExpression const& otherExpression = otherBaseExpression.asIfThenElseExpression(); |
|||
|
|||
bool result = boost::any_cast<bool>(expression.getCondition()->accept(*this, std::ref(*otherExpression.getCondition()))); |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getThenExpression()->accept(*this, std::ref(*otherExpression.getThenExpression()))); |
|||
} |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getElseExpression()->accept(*this, std::ref(*otherExpression.getElseExpression()))); |
|||
} |
|||
return result; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(BinaryBooleanFunctionExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isBinaryBooleanFunctionExpression()) { |
|||
BinaryBooleanFunctionExpression const& otherExpression = otherBaseExpression.asBinaryBooleanFunctionExpression(); |
|||
|
|||
bool result = expression.getOperatorType() == otherExpression.getOperatorType(); |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getFirstOperand()->accept(*this, std::ref(*otherExpression.getFirstOperand()))); |
|||
} |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getSecondOperand()->accept(*this, std::ref(*otherExpression.getSecondOperand()))); |
|||
} |
|||
return result; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(BinaryNumericalFunctionExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isBinaryNumericalFunctionExpression()) { |
|||
BinaryNumericalFunctionExpression const& otherExpression = otherBaseExpression.asBinaryNumericalFunctionExpression(); |
|||
|
|||
bool result = expression.getOperatorType() == otherExpression.getOperatorType(); |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getFirstOperand()->accept(*this, std::ref(*otherExpression.getFirstOperand()))); |
|||
} |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getSecondOperand()->accept(*this, std::ref(*otherExpression.getSecondOperand()))); |
|||
} |
|||
return result; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(BinaryRelationExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isBinaryRelationExpression()) { |
|||
BinaryRelationExpression const& otherExpression = otherBaseExpression.asBinaryRelationExpression(); |
|||
|
|||
bool result = expression.getRelationType() == otherExpression.getRelationType(); |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getFirstOperand()->accept(*this, std::ref(*otherExpression.getFirstOperand()))); |
|||
} |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getSecondOperand()->accept(*this, std::ref(*otherExpression.getSecondOperand()))); |
|||
} |
|||
return result; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(VariableExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isVariableExpression()) { |
|||
VariableExpression const& otherExpression = otherBaseExpression.asVariableExpression(); |
|||
return expression.getVariable() == otherExpression.getVariable(); |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(UnaryBooleanFunctionExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isBinaryBooleanFunctionExpression()) { |
|||
UnaryBooleanFunctionExpression const& otherExpression = otherBaseExpression.asUnaryBooleanFunctionExpression(); |
|||
|
|||
bool result = expression.getOperatorType() == otherExpression.getOperatorType(); |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getOperand()->accept(*this, std::ref(*otherExpression.getOperand()))); |
|||
} |
|||
return result; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(UnaryNumericalFunctionExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isBinaryBooleanFunctionExpression()) { |
|||
UnaryNumericalFunctionExpression const& otherExpression = otherBaseExpression.asUnaryNumericalFunctionExpression(); |
|||
|
|||
bool result = expression.getOperatorType() == otherExpression.getOperatorType(); |
|||
if (result) { |
|||
result = boost::any_cast<bool>(expression.getOperand()->accept(*this, std::ref(*otherExpression.getOperand()))); |
|||
} |
|||
return result; |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(BooleanLiteralExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isBooleanLiteralExpression()) { |
|||
BooleanLiteralExpression const& otherExpression = otherBaseExpression.asBooleanLiteralExpression(); |
|||
return expression.getValue() == otherExpression.getValue(); |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(IntegerLiteralExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isIntegerLiteralExpression()) { |
|||
IntegerLiteralExpression const& otherExpression = otherBaseExpression.asIntegerLiteralExpression(); |
|||
return expression.getValue() == otherExpression.getValue(); |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
boost::any SyntacticalEqualityCheckVisitor::visit(RationalLiteralExpression const& expression, boost::any const& data) { |
|||
BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get(); |
|||
if (otherBaseExpression.isRationalLiteralExpression()) { |
|||
RationalLiteralExpression const& otherExpression = otherBaseExpression.asRationalLiteralExpression(); |
|||
return expression.getValue() == otherExpression.getValue(); |
|||
} else { |
|||
return false; |
|||
} |
|||
} |
|||
|
|||
} |
|||
} |
@ -0,0 +1,27 @@ |
|||
#pragma once |
|||
|
|||
#include "src/storage/expressions/ExpressionVisitor.h" |
|||
|
|||
namespace storm { |
|||
namespace expressions { |
|||
|
|||
class Expression; |
|||
|
|||
class SyntacticalEqualityCheckVisitor : public ExpressionVisitor { |
|||
public: |
|||
bool isSyntaticallyEqual(storm::expressions::Expression const& expression1, storm::expressions::Expression const& expression2); |
|||
|
|||
virtual boost::any visit(IfThenElseExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(BinaryBooleanFunctionExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(BinaryNumericalFunctionExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(BinaryRelationExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(VariableExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(UnaryBooleanFunctionExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(UnaryNumericalFunctionExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(BooleanLiteralExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(IntegerLiteralExpression const& expression, boost::any const& data) override; |
|||
virtual boost::any visit(RationalLiteralExpression const& expression, boost::any const& data) override; |
|||
}; |
|||
|
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue