Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Assignment.cpp
Go to the documentation of this file.
2
5
7
10
11namespace storm {
12namespace jani {
13
14Assignment::Assignment(storm::jani::LValue const& lValue, storm::expressions::Expression const& expression, int64_t level)
15 : lValue(lValue), expression(expression), level(level) {
16 // Intentionally left empty
17}
18
19Assignment::Assignment(storm::jani::Variable const& lValue, storm::expressions::Expression const& expression, int64_t level)
20 : lValue(lValue), expression(expression), level(level) {
21 // Intentionally left empty
22}
23
24bool Assignment::operator==(Assignment const& other) const {
25 return this->isTransient() == other.isTransient() && this->getLValue() == other.getLValue() &&
27}
28
30 return lValue.isVariable();
31}
32
34 return lValue.isArrayAccess();
35}
36
38 return lValue;
39}
40
42 return lValue;
43}
44
46 return lValue.getVariable();
47}
48
52
54 return expression;
55}
56
58 this->expression = expression;
59}
60
62 return lValue.isTransient();
63}
64
65void Assignment::substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution,
66 bool const substituteTranscendentalNumbers) {
67 this->setAssignedExpression(substituteJaniExpression(this->getAssignedExpression(), substitution, substituteTranscendentalNumbers).simplify());
68 if (lValue.isArrayAccess()) {
69 std::vector<storm::expressions::Expression> substitutedExpressions;
70 for (auto& index : lValue.getArrayIndexVector()) {
71 substitutedExpressions.push_back(substituteJaniExpression(index, substitution, substituteTranscendentalNumbers).simplify());
72 }
73
74 lValue = LValue(lValue.getVariable(), substitutedExpressions);
75 }
76}
77
78int64_t Assignment::getLevel() const {
79 return level;
80}
81
82void Assignment::setLevel(int64_t level) {
83 this->level = level;
84}
85
88 return linearityChecker.check(this->getAssignedExpression(), true);
89}
90
91std::ostream& operator<<(std::ostream& stream, Assignment const& assignment) {
92 if (assignment.getLevel() != 0) {
93 stream << "@" << assignment.getLevel() << ": ";
94 }
95 stream << assignment.getLValue() << " := " << assignment.getAssignedExpression();
96 return stream;
97}
98
100 return left.getLevel() < right.getLevel() || (left.getLevel() == right.getLevel() && left.getLValue() < right.getLValue());
101}
102
103bool AssignmentPartialOrderByLevelAndLValue::operator()(Assignment const& left, std::shared_ptr<Assignment> const& right) const {
104 return left.getLevel() < right->getLevel() || (left.getLevel() == right->getLevel() && left.getLValue() < right->getLValue());
105}
106
107bool AssignmentPartialOrderByLevelAndLValue::operator()(std::shared_ptr<Assignment> const& left, std::shared_ptr<Assignment> const& right) const {
108 return left->getLevel() < right->getLevel() || (left->getLevel() == right->getLevel() && left->getLValue() < right->getLValue());
109}
110
111bool AssignmentPartialOrderByLevelAndLValue::operator()(std::shared_ptr<Assignment> const& left, Assignment const& right) const {
112 return left->getLevel() < right.getLevel() || (left->getLevel() == right.getLevel() && left->getLValue() < right.getLValue());
113}
114} // namespace jani
115} // namespace storm
Expression simplify() const
Simplifies the expression according to some basic rules.
bool isSyntacticallyEqual(storm::expressions::Expression const &other) const
Checks whether the two expressions are syntatically the same.
bool check(Expression const &expression, bool booleanIsLinear=false)
Checks that the given expression is linear.
storm::expressions::Expression const & getAssignedExpression() const
Retrieves the expression whose value is assigned to the target variable.
storm::jani::LValue const & getLValue() const
Retrieves the lValue that is written in this assignment.
storm::expressions::Variable const & getExpressionVariable() const
Retrieves the expression variable that is written in this assignment.
bool lValueIsArrayAccess() const
Returns true if the lValue is an array access.
Assignment(storm::jani::LValue const &lValue, storm::expressions::Expression const &expression, int64_t level=0)
Creates an assignment of the given expression to the given LValue.
void setAssignedExpression(storm::expressions::Expression const &expression)
Sets a new expression that is assigned to the target LValue.
bool lValueIsVariable() const
Returns true if the lValue is a variable.
bool isLinear() const
Checks the assignment for linearity.
storm::jani::Variable const & getVariable() const
Retrieves the Variable that is written in this assignment.
int64_t getLevel() const
Retrieves the level of the assignment.
bool operator==(Assignment const &other) const
void substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution, bool const substituteTranscendentalNumbers)
Substitutes all variables in all expressions according to the given substitution.
bool isTransient() const
Retrieves whether the assignment assigns to a transient variable.
void setLevel(int64_t level)
Sets the level.
bool isTransient() const
Definition LValue.cpp:70
bool isVariable() const
Definition LValue.cpp:20
std::vector< storm::expressions::Expression > & getArrayIndexVector()
Returns the referred variable. In case of an array access, this is the referred array variable.
Definition LValue.cpp:40
bool isArrayAccess() const
Returns true if the lValue refers either to an array variable or to an array access.
Definition LValue.cpp:32
storm::jani::Variable const & getVariable() const
To check if the array is fully accessed, so result will be of the most inner child Type....
Definition LValue.cpp:28
storm::expressions::Variable const & getExpressionVariable() const
Retrieves the associated expression variable.
Definition Variable.cpp:26
storm::expressions::Expression substituteJaniExpression(storm::expressions::Expression const &expression, std::map< storm::expressions::Variable, storm::expressions::Expression > const &identifierToExpressionMap, bool const substituteTranscendentalNumbers)
std::ostream & operator<<(std::ostream &stream, Assignment const &assignment)
LabParser.cpp.
Definition cli.cpp:18
bool operator()(Assignment const &left, Assignment const &right) const