Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
SyntacticalEqualityCheckVisitor.cpp
Go to the documentation of this file.
2
4
5namespace storm {
6namespace expressions {
7
9 storm::expressions::Expression const& expression2) {
10 return boost::any_cast<bool>(expression1.accept(*this, std::ref(expression2.getBaseExpression())));
11}
12
13boost::any SyntacticalEqualityCheckVisitor::visit(IfThenElseExpression const& expression, boost::any const& data) {
14 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
15 if (otherBaseExpression.isIfThenElseExpression()) {
16 IfThenElseExpression const& otherExpression = otherBaseExpression.asIfThenElseExpression();
18 bool result = boost::any_cast<bool>(expression.getCondition()->accept(*this, std::ref(*otherExpression.getCondition())));
19 if (result) {
20 result = boost::any_cast<bool>(expression.getThenExpression()->accept(*this, std::ref(*otherExpression.getThenExpression())));
21 }
22 if (result) {
23 result = boost::any_cast<bool>(expression.getElseExpression()->accept(*this, std::ref(*otherExpression.getElseExpression())));
24 }
25 return result;
26 } else {
27 return false;
28 }
29}
30
31boost::any SyntacticalEqualityCheckVisitor::visit(BinaryBooleanFunctionExpression const& expression, boost::any const& data) {
32 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
33 if (otherBaseExpression.isBinaryBooleanFunctionExpression()) {
34 BinaryBooleanFunctionExpression const& otherExpression = otherBaseExpression.asBinaryBooleanFunctionExpression();
35
36 bool result = expression.getOperatorType() == otherExpression.getOperatorType();
37 if (result) {
38 result = boost::any_cast<bool>(expression.getFirstOperand()->accept(*this, std::ref(*otherExpression.getFirstOperand())));
39 }
40 if (result) {
41 result = boost::any_cast<bool>(expression.getSecondOperand()->accept(*this, std::ref(*otherExpression.getSecondOperand())));
42 }
43 return result;
44 } else {
45 return false;
46 }
47}
48
49boost::any SyntacticalEqualityCheckVisitor::visit(BinaryNumericalFunctionExpression const& expression, boost::any const& data) {
50 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
51 if (otherBaseExpression.isBinaryNumericalFunctionExpression()) {
52 BinaryNumericalFunctionExpression const& otherExpression = otherBaseExpression.asBinaryNumericalFunctionExpression();
53
54 bool result = expression.getOperatorType() == otherExpression.getOperatorType();
55 if (result) {
56 result = boost::any_cast<bool>(expression.getFirstOperand()->accept(*this, std::ref(*otherExpression.getFirstOperand())));
57 }
58 if (result) {
59 result = boost::any_cast<bool>(expression.getSecondOperand()->accept(*this, std::ref(*otherExpression.getSecondOperand())));
60 }
61 return result;
62 } else {
63 return false;
64 }
65}
66
67boost::any SyntacticalEqualityCheckVisitor::visit(BinaryRelationExpression const& expression, boost::any const& data) {
68 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
69 if (otherBaseExpression.isBinaryRelationExpression()) {
70 BinaryRelationExpression const& otherExpression = otherBaseExpression.asBinaryRelationExpression();
71
72 bool result = expression.getRelationType() == otherExpression.getRelationType();
73 if (result) {
74 result = boost::any_cast<bool>(expression.getFirstOperand()->accept(*this, std::ref(*otherExpression.getFirstOperand())));
75 }
76 if (result) {
77 result = boost::any_cast<bool>(expression.getSecondOperand()->accept(*this, std::ref(*otherExpression.getSecondOperand())));
78 }
79 return result;
80 } else {
81 return false;
82 }
83}
84
85boost::any SyntacticalEqualityCheckVisitor::visit(VariableExpression const& expression, boost::any const& data) {
86 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
87 if (otherBaseExpression.isVariableExpression()) {
88 VariableExpression const& otherExpression = otherBaseExpression.asVariableExpression();
89 return expression.getVariable() == otherExpression.getVariable();
90 } else {
91 return false;
92 }
93}
94
95boost::any SyntacticalEqualityCheckVisitor::visit(UnaryBooleanFunctionExpression const& expression, boost::any const& data) {
96 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
97 if (otherBaseExpression.isUnaryBooleanFunctionExpression()) {
98 UnaryBooleanFunctionExpression const& otherExpression = otherBaseExpression.asUnaryBooleanFunctionExpression();
99
100 bool result = expression.getOperatorType() == otherExpression.getOperatorType();
101 if (result) {
102 result = boost::any_cast<bool>(expression.getOperand()->accept(*this, std::ref(*otherExpression.getOperand())));
103 }
104 return result;
105 } else {
106 return false;
107 }
108}
109
110boost::any SyntacticalEqualityCheckVisitor::visit(UnaryNumericalFunctionExpression const& expression, boost::any const& data) {
111 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
112 if (otherBaseExpression.isUnaryNumericalFunctionExpression()) {
113 UnaryNumericalFunctionExpression const& otherExpression = otherBaseExpression.asUnaryNumericalFunctionExpression();
114
115 bool result = expression.getOperatorType() == otherExpression.getOperatorType();
116 if (result) {
117 result = boost::any_cast<bool>(expression.getOperand()->accept(*this, std::ref(*otherExpression.getOperand())));
118 }
119 return result;
120 } else {
121 return false;
122 }
123}
124
125boost::any SyntacticalEqualityCheckVisitor::visit(BooleanLiteralExpression const& expression, boost::any const& data) {
126 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
127 if (otherBaseExpression.isBooleanLiteralExpression()) {
128 BooleanLiteralExpression const& otherExpression = otherBaseExpression.asBooleanLiteralExpression();
129 return expression.getValue() == otherExpression.getValue();
130 } else {
131 return false;
132 }
133}
134
135boost::any SyntacticalEqualityCheckVisitor::visit(IntegerLiteralExpression const& expression, boost::any const& data) {
136 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
137 if (otherBaseExpression.isIntegerLiteralExpression()) {
138 IntegerLiteralExpression const& otherExpression = otherBaseExpression.asIntegerLiteralExpression();
139 return expression.getValue() == otherExpression.getValue();
140 } else {
141 return false;
142 }
143}
144
145boost::any SyntacticalEqualityCheckVisitor::visit(RationalLiteralExpression const& expression, boost::any const& data) {
146 BaseExpression const& otherBaseExpression = boost::any_cast<std::reference_wrapper<BaseExpression const>>(data).get();
147 if (otherBaseExpression.isRationalLiteralExpression()) {
148 RationalLiteralExpression const& otherExpression = otherBaseExpression.asRationalLiteralExpression();
149 return expression.getValue() == otherExpression.getValue();
150 } else {
151 return false;
152 }
153}
154
155} // namespace expressions
156} // namespace storm
The base class of all expression classes.
BinaryNumericalFunctionExpression const & asBinaryNumericalFunctionExpression() const
virtual bool isUnaryBooleanFunctionExpression() const
virtual bool isBinaryRelationExpression() const
virtual bool isBooleanLiteralExpression() const
BooleanLiteralExpression const & asBooleanLiteralExpression() const
virtual bool isBinaryBooleanFunctionExpression() const
IntegerLiteralExpression const & asIntegerLiteralExpression() const
virtual bool isBinaryNumericalFunctionExpression() const
virtual bool isIfThenElseExpression() const
RationalLiteralExpression const & asRationalLiteralExpression() const
virtual bool isVariableExpression() const
virtual bool isUnaryNumericalFunctionExpression() const
VariableExpression const & asVariableExpression() const
IfThenElseExpression const & asIfThenElseExpression() const
BinaryBooleanFunctionExpression const & asBinaryBooleanFunctionExpression() const
UnaryBooleanFunctionExpression const & asUnaryBooleanFunctionExpression() const
BinaryRelationExpression const & asBinaryRelationExpression() const
UnaryNumericalFunctionExpression const & asUnaryNumericalFunctionExpression() const
virtual bool isRationalLiteralExpression() const
virtual bool isIntegerLiteralExpression() const
OperatorType getOperatorType() const
Retrieves the operator associated with the expression.
std::shared_ptr< BaseExpression const > const & getSecondOperand() const
Retrieves the second operand of the expression.
std::shared_ptr< BaseExpression const > const & getFirstOperand() const
Retrieves the first operand of the expression.
OperatorType getOperatorType() const
Retrieves the operator associated with the expression.
RelationType getRelationType() const
Retrieves the relation associated with the expression.
bool getValue() const
Retrieves the value of the boolean literal.
boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const
Accepts the given visitor.
BaseExpression const & getBaseExpression() const
Retrieves the base expression underlying this expression object.
std::shared_ptr< BaseExpression const > getElseExpression() const
Retrieves the else expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getCondition() const
Retrieves the condition expression of the if-then-else expression.
std::shared_ptr< BaseExpression const > getThenExpression() const
Retrieves the then expression of the if-then-else expression.
int_fast64_t getValue() const
Retrieves the value of the integer literal.
storm::RationalNumber getValue() const
Retrieves the value of the double literal.
bool isSyntacticallyEqual(storm::expressions::Expression const &expression1, storm::expressions::Expression const &expression2)
virtual boost::any visit(IfThenElseExpression const &expression, boost::any const &data) override
OperatorType getOperatorType() const
Retrieves the operator associated with this expression.
virtual std::shared_ptr< BaseExpression const > getOperand(uint_fast64_t operandIndex) const override
Retrieves the given operand from the expression.
OperatorType getOperatorType() const
Retrieves the operator associated with this expression.
Variable const & getVariable() const
Retrieves the variable associated with this expression.
LabParser.cpp.
Definition cli.cpp:18