Storm
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
FunctionEliminator.cpp
Go to the documentation of this file.
2
3#include <unordered_map>
4
13
16
19
20namespace storm {
21namespace jani {
22namespace detail {
23
25 public:
27
28 typedef std::shared_ptr<storm::expressions::BaseExpression const> BaseExprPtr;
29
30 FunctionEliminationExpressionVisitor(std::unordered_map<std::string, FunctionDefinition> const* globalFunctions,
31 std::unordered_map<std::string, FunctionDefinition> const* localFunctions = nullptr)
32 : globalFunctions(globalFunctions), localFunctions(localFunctions) {}
33
35
36 FunctionEliminationExpressionVisitor setLocalFunctions(std::unordered_map<std::string, FunctionDefinition> const* localFunctions) {
37 return FunctionEliminationExpressionVisitor(this->globalFunctions, localFunctions);
38 }
39
41 auto res = storm::expressions::Expression(boost::any_cast<BaseExprPtr>(expression.accept(*this, boost::any())));
42 return res.simplify();
43 }
44
45 virtual boost::any visit(storm::expressions::IfThenElseExpression const& expression, boost::any const& data) override {
46 BaseExprPtr conditionExpression = boost::any_cast<BaseExprPtr>(expression.getCondition()->accept(*this, data));
47 BaseExprPtr thenExpression = boost::any_cast<BaseExprPtr>(expression.getThenExpression()->accept(*this, data));
48 BaseExprPtr elseExpression = boost::any_cast<BaseExprPtr>(expression.getElseExpression()->accept(*this, data));
49
50 // If the arguments did not change, we simply push the expression itself.
51 if (conditionExpression.get() == expression.getCondition().get() && thenExpression.get() == expression.getThenExpression().get() &&
52 elseExpression.get() == expression.getElseExpression().get()) {
53 return expression.getSharedPointer();
54 } else {
55 return std::const_pointer_cast<storm::expressions::BaseExpression const>(
56 std::shared_ptr<storm::expressions::BaseExpression>(new storm::expressions::IfThenElseExpression(
57 expression.getManager(), thenExpression->getType(), conditionExpression, thenExpression, elseExpression)));
58 }
59 }
60
61 virtual boost::any visit(storm::expressions::BinaryBooleanFunctionExpression const& expression, boost::any const& data) override {
62 BaseExprPtr firstExpression = boost::any_cast<BaseExprPtr>(expression.getFirstOperand()->accept(*this, data));
63 BaseExprPtr secondExpression = boost::any_cast<BaseExprPtr>(expression.getSecondOperand()->accept(*this, data));
64
65 // If the arguments did not change, we simply push the expression itself.
66 if (firstExpression.get() == expression.getFirstOperand().get() && secondExpression.get() == expression.getSecondOperand().get()) {
67 return expression.getSharedPointer();
68 } else {
69 return std::const_pointer_cast<storm::expressions::BaseExpression const>(
70 std::shared_ptr<storm::expressions::BaseExpression>(new storm::expressions::BinaryBooleanFunctionExpression(
71 expression.getManager(), expression.getType(), firstExpression, secondExpression, expression.getOperatorType())));
72 }
73 }
74
75 virtual boost::any visit(storm::expressions::BinaryNumericalFunctionExpression const& expression, boost::any const& data) override {
76 BaseExprPtr firstExpression = boost::any_cast<BaseExprPtr>(expression.getFirstOperand()->accept(*this, data));
77 BaseExprPtr secondExpression = boost::any_cast<BaseExprPtr>(expression.getSecondOperand()->accept(*this, data));
78
79 // If the arguments did not change, we simply push the expression itself.
80 if (firstExpression.get() == expression.getFirstOperand().get() && secondExpression.get() == expression.getSecondOperand().get()) {
81 return expression.getSharedPointer();
82 } else {
83 return std::const_pointer_cast<storm::expressions::BaseExpression const>(
84 std::shared_ptr<storm::expressions::BaseExpression>(new storm::expressions::BinaryNumericalFunctionExpression(
85 expression.getManager(), expression.getType(), firstExpression, secondExpression, expression.getOperatorType())));
86 }
87 }
88
89 virtual boost::any visit(storm::expressions::BinaryRelationExpression const& expression, boost::any const& data) override {
90 BaseExprPtr firstExpression = boost::any_cast<BaseExprPtr>(expression.getFirstOperand()->accept(*this, data));
91 BaseExprPtr secondExpression = boost::any_cast<BaseExprPtr>(expression.getSecondOperand()->accept(*this, data));
92
93 // If the arguments did not change, we simply push the expression itself.
94 if (firstExpression.get() == expression.getFirstOperand().get() && secondExpression.get() == expression.getSecondOperand().get()) {
95 return expression.getSharedPointer();
96 } else {
97 return std::const_pointer_cast<storm::expressions::BaseExpression const>(
98 std::shared_ptr<storm::expressions::BaseExpression>(new storm::expressions::BinaryRelationExpression(
99 expression.getManager(), expression.getType(), firstExpression, secondExpression, expression.getRelationType())));
100 }
101 }
102
103 virtual boost::any visit(storm::expressions::VariableExpression const& expression, boost::any const&) override {
104 return expression.getSharedPointer();
105 }
106
107 virtual boost::any visit(storm::expressions::UnaryBooleanFunctionExpression const& expression, boost::any const& data) override {
108 BaseExprPtr operandExpression = boost::any_cast<BaseExprPtr>(expression.getOperand()->accept(*this, data));
109
110 // If the argument did not change, we simply push the expression itself.
111 if (operandExpression.get() == expression.getOperand().get()) {
112 return expression.getSharedPointer();
113 } else {
114 return std::const_pointer_cast<storm::expressions::BaseExpression const>(
115 std::shared_ptr<storm::expressions::BaseExpression>(new storm::expressions::UnaryBooleanFunctionExpression(
116 expression.getManager(), expression.getType(), operandExpression, expression.getOperatorType())));
117 }
118 }
119
120 virtual boost::any visit(storm::expressions::UnaryNumericalFunctionExpression const& expression, boost::any const& data) override {
121 BaseExprPtr operandExpression = boost::any_cast<BaseExprPtr>(expression.getOperand()->accept(*this, data));
122
123 // If the argument did not change, we simply push the expression itself.
124 if (operandExpression.get() == expression.getOperand().get()) {
125 return expression.getSharedPointer();
126 } else {
127 return std::const_pointer_cast<storm::expressions::BaseExpression const>(
128 std::shared_ptr<storm::expressions::BaseExpression>(new storm::expressions::UnaryNumericalFunctionExpression(
129 expression.getManager(), expression.getType(), operandExpression, expression.getOperatorType())));
130 }
131 }
132
133 virtual boost::any visit(storm::expressions::BooleanLiteralExpression const& expression, boost::any const&) override {
134 return expression.getSharedPointer();
135 }
136
137 virtual boost::any visit(storm::expressions::IntegerLiteralExpression const& expression, boost::any const&) override {
138 return expression.getSharedPointer();
139 }
140
141 virtual boost::any visit(storm::expressions::RationalLiteralExpression const& expression, boost::any const&) override {
142 return expression.getSharedPointer();
143 }
144
145 virtual boost::any visit(storm::expressions::ValueArrayExpression const& expression, boost::any const& data) override {
146 STORM_LOG_ASSERT(expression.size()->isIntegerLiteralExpression(),
147 "unexpected kind of size expression of ValueArrayExpression (" << expression.size()->toExpression() << ").");
148 uint64_t size = expression.size()->evaluateAsInt();
149 std::vector<BaseExprPtr> elements;
150 bool changed = false;
151 for (uint64_t i = 0; i < size; ++i) {
152 BaseExprPtr element = boost::any_cast<BaseExprPtr>(expression.at(i)->accept(*this, data));
153 if (element.get() != expression.at(i).get()) {
154 changed = true;
155 }
156 elements.push_back(element);
157 }
158 if (changed) {
159 return std::const_pointer_cast<storm::expressions::BaseExpression const>(std::shared_ptr<storm::expressions::BaseExpression>(
160 new storm::expressions::ValueArrayExpression(expression.getManager(), expression.getType(), elements)));
161 } else {
162 return expression.getSharedPointer();
163 }
164 }
165
166 virtual boost::any visit(storm::expressions::ConstructorArrayExpression const& expression, boost::any const& data) override {
167 BaseExprPtr sizeExpression = boost::any_cast<BaseExprPtr>(expression.size()->accept(*this, data));
168 BaseExprPtr elementExpression = boost::any_cast<BaseExprPtr>(expression.getElementExpression()->accept(*this, data));
169
170 // If the arguments did not change, we simply push the expression itself.
171 if (sizeExpression.get() == expression.size().get() && elementExpression.get() == expression.getElementExpression().get()) {
172 return expression.getSharedPointer();
173 } else {
174 return std::const_pointer_cast<storm::expressions::BaseExpression const>(
175 std::shared_ptr<storm::expressions::BaseExpression>(new storm::expressions::ConstructorArrayExpression(
176 expression.getManager(), expression.getType(), sizeExpression, expression.getIndexVar(), elementExpression)));
177 }
178 }
179
180 virtual boost::any visit(storm::expressions::ArrayAccessExpression const& expression, boost::any const& data) override {
181 BaseExprPtr firstExpression = boost::any_cast<BaseExprPtr>(expression.getFirstOperand()->accept(*this, data));
182 BaseExprPtr secondExpression = boost::any_cast<BaseExprPtr>(expression.getSecondOperand()->accept(*this, data));
183
184 // If the arguments did not change, we simply push the expression itself.
185 if (firstExpression.get() == expression.getFirstOperand().get() && secondExpression.get() == expression.getSecondOperand().get()) {
186 return expression.getSharedPointer();
187 } else {
188 return std::const_pointer_cast<storm::expressions::BaseExpression const>(std::shared_ptr<storm::expressions::BaseExpression>(
189 new storm::expressions::ArrayAccessExpression(expression.getManager(), expression.getType(), firstExpression, secondExpression)));
190 }
191 }
192
193 virtual boost::any visit(storm::expressions::FunctionCallExpression const& expression, boost::any const& data) override {
194 // Find the associated function definition
195 FunctionDefinition const* funDef = nullptr;
196 if (localFunctions != nullptr) {
197 auto funDefIt = localFunctions->find(expression.getFunctionIdentifier());
198 if (funDefIt != localFunctions->end()) {
199 funDef = &(funDefIt->second);
200 }
201 }
202 if (globalFunctions != nullptr) {
203 auto funDefIt = globalFunctions->find(expression.getFunctionIdentifier());
204 if (funDefIt != globalFunctions->end()) {
205 funDef = &(funDefIt->second);
206 }
207 }
208
209 STORM_LOG_THROW(funDef != nullptr, storm::exceptions::UnexpectedException,
210 "Unable to find function definition for function call " << expression << ".");
211
212 return boost::any_cast<BaseExprPtr>(funDef->call(expression.getArguments()).getBaseExpression().accept(*this, data));
213 }
214
215 virtual boost::any visit(storm::expressions::TranscendentalNumberLiteralExpression const& expression, boost::any const&) override {
216 return expression.getSharedPointer();
217 }
218
219 private:
220 std::unordered_map<std::string, FunctionDefinition> const* globalFunctions;
221 std::unordered_map<std::string, FunctionDefinition> const* localFunctions;
222};
223
225 public:
227
229
230 virtual ~FunctionEliminatorTraverser() = default;
231
232 void eliminate(Model& model, std::vector<Property>& properties) {
233 // Replace all function calls by the function definition
234 traverse(model, boost::any());
235
236 // Replace function definitions in properties
237 if (!model.getGlobalFunctionDefinitions().empty()) {
239 for (auto& property : properties) {
240 property = property.substitute([&v](storm::expressions::Expression const& exp) { return v.eliminate(exp); });
241 }
242 }
243
244 // Erase function definitions in model and automata
245 model.getGlobalFunctionDefinitions().clear();
246 for (auto& automaton : model.getAutomata()) {
247 automaton.getFunctionDefinitions().clear();
248 }
249
250 // Clear the model feature 'functions'
252
253 // finalize the model
254 model.finalize();
255 }
256
257 // To detect cyclic dependencies between function bodies, we need to eliminate the functions in a topological order
260 std::unordered_map<std::string, FunctionDefinition>& functions,
261 std::unordered_map<std::string, FunctionDefinitionStatus>& status, std::string const& current) {
262 status[current] = FunctionDefinitionStatus::Current;
263 FunctionDefinition& funDef = functions.find(current)->second;
264 auto calledFunctions = getOccurringFunctionCalls(funDef.getFunctionBody());
265 for (auto const& calledFunction : calledFunctions) {
266 STORM_LOG_THROW(calledFunction != current, storm::exceptions::NotSupportedException,
267 "Function '" << calledFunction << "' calls itself. This is not supported.");
268 auto calledStatus = status.find(calledFunction);
269 // Check whether the called function belongs to the ones that actually needed processing
270 if (calledStatus != status.end()) {
271 STORM_LOG_THROW(calledStatus->second != FunctionDefinitionStatus::Current, storm::exceptions::NotSupportedException,
272 "Found cyclic dependencies between functions '" << calledFunction << "' and '" << current << "'. This is not supported.");
273 if (calledStatus->second == FunctionDefinitionStatus::Unprocessed) {
274 eliminateFunctionsInFunctionBodies(eliminationVisitor, functions, status, calledFunction);
275 }
276 }
277 }
278 // At this point, all called functions are processed already. So we can finally process this one.
279 funDef.setFunctionBody(eliminationVisitor.eliminate(funDef.getFunctionBody()));
280 status[current] = FunctionDefinitionStatus::Processed;
281 }
283 std::unordered_map<std::string, FunctionDefinition>& functions) {
284 std::unordered_map<std::string, FunctionDefinitionStatus> status;
285 for (auto const& f : functions) {
286 status.emplace(f.first, FunctionDefinitionStatus::Unprocessed);
287 }
288 for (auto const& f : functions) {
289 if (status[f.first] == FunctionDefinitionStatus::Unprocessed) {
290 eliminateFunctionsInFunctionBodies(eliminationVisitor, functions, status, f.first);
291 }
292 }
293 }
294
295 virtual void traverse(Model& model, boost::any const&) override {
296 // First we need to apply functions called in function bodies
297 FunctionEliminationExpressionVisitor globalFunctionEliminationVisitor(&model.getGlobalFunctionDefinitions());
298 eliminateFunctionsInFunctionBodies(globalFunctionEliminationVisitor, model.getGlobalFunctionDefinitions());
299
300 // Now run through the remaining components
301 for (auto& c : model.getConstants()) {
302 traverse(c, &globalFunctionEliminationVisitor);
303 }
304 traverse(model.getGlobalVariables(), &globalFunctionEliminationVisitor);
305 for (auto& aut : model.getAutomata()) {
306 traverse(aut, &globalFunctionEliminationVisitor);
307 }
308 if (model.hasInitialStatesRestriction()) {
309 model.setInitialStatesRestriction(globalFunctionEliminationVisitor.eliminate(model.getInitialStatesRestriction()));
310 }
311 for (auto& nonTrivRew : model.getNonTrivialRewardExpressions()) {
312 nonTrivRew.second = globalFunctionEliminationVisitor.eliminate(nonTrivRew.second);
313 }
314 }
315
316 void traverse(Automaton& automaton, boost::any const& data) override {
317 // First we need to apply functions called in function bodies
318 auto functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data)->setLocalFunctions(&automaton.getFunctionDefinitions());
319 eliminateFunctionsInFunctionBodies(functionEliminationVisitor, automaton.getFunctionDefinitions());
320
321 // Now run through the remaining components
322 traverse(automaton.getVariables(), &functionEliminationVisitor);
323 for (auto& loc : automaton.getLocations()) {
324 traverse(loc, &functionEliminationVisitor);
325 }
326 traverse(automaton.getEdgeContainer(), &functionEliminationVisitor);
327 if (automaton.hasInitialStatesRestriction()) {
328 automaton.setInitialStatesRestriction(functionEliminationVisitor.eliminate(automaton.getInitialStatesRestriction()));
329 }
330 }
331
332 void traverse(Location& location, boost::any const& data) override {
333 traverse(location.getAssignments(), data);
334 if (location.hasTimeProgressInvariant()) {
335 FunctionEliminationExpressionVisitor* functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data);
336 location.setTimeProgressInvariant(functionEliminationVisitor->eliminate(location.getTimeProgressInvariant()));
337 }
338 }
339
340 void traverse(Constant& constant, boost::any const& data) override {
341 if (constant.isDefined()) {
342 FunctionEliminationExpressionVisitor* functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data);
343 constant.define(functionEliminationVisitor->eliminate(constant.getExpression()));
344 }
345 }
346
347 void traverse(Variable& variable, boost::any const& data) override {
348 FunctionEliminationExpressionVisitor* functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data);
349 if (variable.hasInitExpression()) {
350 variable.setInitExpression(functionEliminationVisitor->eliminate(variable.getInitExpression()));
351 }
352 traverse(variable.getType(), data);
353 }
354
355 void traverse(JaniType& type, boost::any const& data) override {
356 if (type.isBoundedType()) {
357 FunctionEliminationExpressionVisitor* functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data);
358 auto& bndType = type.asBoundedType();
359 if (bndType.hasLowerBound()) {
360 bndType.setLowerBound(functionEliminationVisitor->eliminate(bndType.getLowerBound()));
361 }
362 if (bndType.hasUpperBound()) {
363 bndType.setUpperBound(functionEliminationVisitor->eliminate(bndType.getUpperBound()));
364 }
365 } else if (type.isArrayType()) {
366 traverse(type.asArrayType().getBaseType(), data);
367 }
368 }
369
370 void traverse(TemplateEdge& templateEdge, boost::any const& data) override {
371 FunctionEliminationExpressionVisitor* functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data);
372 templateEdge.setGuard(functionEliminationVisitor->eliminate(templateEdge.getGuard()));
373 for (auto& dest : templateEdge.getDestinations()) {
374 traverse(dest, data);
375 }
376 traverse(templateEdge.getAssignments(), data);
377 }
378
379 void traverse(Edge& edge, boost::any const& data) override {
380 FunctionEliminationExpressionVisitor* functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data);
381 if (edge.hasRate()) {
382 edge.setRate(functionEliminationVisitor->eliminate(edge.getRate()));
383 }
384 for (auto& dest : edge.getDestinations()) {
385 traverse(dest, data);
386 }
387 }
388
389 void traverse(EdgeDestination& edgeDestination, boost::any const& data) override {
390 FunctionEliminationExpressionVisitor* functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data);
391 edgeDestination.setProbability(functionEliminationVisitor->eliminate(edgeDestination.getProbability()));
392 }
393
394 void traverse(Assignment& assignment, boost::any const& data) override {
395 FunctionEliminationExpressionVisitor* functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data);
396 assignment.setAssignedExpression(functionEliminationVisitor->eliminate(assignment.getAssignedExpression()));
397 traverse(assignment.getLValue(), data);
398 }
399
400 void traverse(LValue& lValue, boost::any const& data) override {
401 if (lValue.isArrayAccess()) {
402 FunctionEliminationExpressionVisitor* functionEliminationVisitor = boost::any_cast<FunctionEliminationExpressionVisitor*>(data);
403 std::vector<storm::expressions::Expression> arrayIndex;
404 for (auto const& indexExpr : lValue.getArrayIndexVector()) {
405 arrayIndex.push_back(functionEliminationVisitor->eliminate(indexExpr));
406 }
407 lValue.setArrayIndex(arrayIndex);
408 }
409 }
410
411 void traverse(storm::expressions::Expression const& expression, boost::any const&) override {
412 STORM_LOG_THROW(getOccurringFunctionCalls(expression).empty(), storm::exceptions::UnexpectedException,
413 "Did not translate functions in expression " << expression);
414 }
415};
416} // namespace detail
417
418void eliminateFunctions(Model& model, std::vector<Property>& properties) {
419 // Only perform actions if there actually are functions.
420 if (model.getModelFeatures().hasFunctions()) {
422 }
423 STORM_LOG_ASSERT(!containsFunctionCallExpression(model), "The model still seems to contain function calls.");
424}
425
427 if (model.getModelFeatures().hasFunctions()) {
429 return visitor.eliminate(expression);
430 } else {
431 return expression;
432 }
433}
434} // namespace jani
435} // namespace storm
virtual boost::any accept(ExpressionVisitor &visitor, boost::any const &data) const =0
Accepts the given visitor by calling its visit method.
ExpressionManager const & getManager() const
Retrieves the manager responsible for this expression.
Type const & getType() const
Retrieves the type of the expression.
std::shared_ptr< BaseExpression const > getSharedPointer() const
Retrieves a shared pointer to this expression.
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.
Represents an array of the given size, where the i'th entry is determined by the elementExpression,...
virtual std::shared_ptr< BaseExpression const > size() const override
std::shared_ptr< BaseExpression const > const & getElementExpression() const
storm::expressions::Variable const & getIndexVar() const
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.
virtual boost::any visit(IfThenElseExpression const &expression, boost::any const &data)=0
Represents an array with a given list of elements.
std::vector< std::shared_ptr< BaseExpression const > > const & getArguments() const
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.
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.
Represents an array with a given list of elements.
virtual std::shared_ptr< BaseExpression const > size() const override
virtual std::shared_ptr< BaseExpression const > at(uint64_t i) const override
JaniType & getBaseType()
Definition ArrayType.cpp:18
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.
void setAssignedExpression(storm::expressions::Expression const &expression)
Sets a new expression that is assigned to the target LValue.
VariableSet & getVariables()
Retrieves the variables of this automaton.
Definition Automaton.cpp:59
storm::expressions::Expression const & getInitialStatesRestriction() const
Gets the expression restricting the legal initial values of the automaton's variables.
void setInitialStatesRestriction(storm::expressions::Expression const &initialStatesRestriction)
Sets the expression restricting the legal initial values of the automaton's variables.
std::vector< Location > const & getLocations() const
Retrieves the locations of the automaton.
Definition Automaton.cpp:98
bool hasInitialStatesRestriction() const
Retrieves whether this automaton has an initial states restriction.
std::unordered_map< std::string, FunctionDefinition > const & getFunctionDefinitions() const
Retrieves all function definitions of this automaton.
Definition Automaton.cpp:86
EdgeContainer const & getEdgeContainer() const
Retrieves the container of all edges of this automaton.
void setLowerBound(storm::expressions::Expression const &expression)
void define(storm::expressions::Expression const &expression)
Defines the constant with the given expression.
Definition Constant.cpp:38
bool isDefined() const
Retrieves whether the constant is defined in the sense that it has a defining expression.
Definition Constant.cpp:34
storm::expressions::Expression const & getExpression() const
Retrieves the expression that defines this constant (if any).
Definition Constant.cpp:67
storm::expressions::Expression const & getProbability() const
Retrieves the probability of choosing this destination.
void setProbability(storm::expressions::Expression const &probability)
Sets a new probability for this edge destination.
void setRate(storm::expressions::Expression const &rate)
Sets a new rate for this edge.
Definition Edge.cpp:61
std::vector< EdgeDestination > const & getDestinations() const
Retrieves the destinations of this edge.
Definition Edge.cpp:77
bool hasRate() const
Retrieves whether this edge has an associated rate.
Definition Edge.cpp:49
storm::expressions::Expression const & getRate() const
Retrieves the rate of this edge.
Definition Edge.cpp:53
storm::expressions::Expression const & getFunctionBody() const
Retrieves the expression that defines the function.
storm::expressions::Expression call(std::vector< std::shared_ptr< storm::expressions::BaseExpression const > > const &arguments) const
Calls the function with the given arguments.
void setFunctionBody(storm::expressions::Expression const &body)
sets the expression that defines the function
virtual void traverse(Model &model, boost::any const &data)
ArrayType const & asArrayType() const
Definition JaniType.cpp:47
virtual bool isArrayType() const
Definition JaniType.cpp:19
virtual bool isBoundedType() const
Definition JaniType.cpp:15
BoundedType const & asBoundedType() const
Definition JaniType.cpp:39
void setArrayIndex(std::vector< storm::expressions::Expression > const &newIndex)
Definition LValue.cpp:60
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
Jani Location:
Definition Location.h:15
OrderedAssignments const & getAssignments() const
Retrieves the assignments of this location.
Definition Location.cpp:23
void setTimeProgressInvariant(storm::expressions::Expression const &expression)
Sets the time progress invariant of this location.
Definition Location.cpp:44
storm::expressions::Expression const & getTimeProgressInvariant() const
Retrieves the time progress invariant.
Definition Location.cpp:40
bool hasTimeProgressInvariant() const
Retrieves whether a time progress invariant is attached to this location.
Definition Location.cpp:36
void remove(ModelFeature const &modelFeature)
void setInitialStatesRestriction(storm::expressions::Expression const &initialStatesRestriction)
Sets the expression restricting the legal initial values of the global variables.
Definition Model.cpp:1280
VariableSet & getGlobalVariables()
Retrieves the variables of this automaton.
Definition Model.cpp:721
std::unordered_map< std::string, storm::expressions::Expression > const & getNonTrivialRewardExpressions() const
Retrieves all available non-trivial reward model names and expressions of the model.
Definition Model.cpp:855
bool hasInitialStatesRestriction() const
Retrieves whether there is an expression restricting the legal initial values of the global variables...
Definition Model.cpp:1284
storm::expressions::Expression const & getInitialStatesRestriction() const
Gets the expression restricting the legal initial values of the global variables.
Definition Model.cpp:1288
std::vector< Automaton > & getAutomata()
Retrieves the automata of the model.
Definition Model.cpp:872
std::vector< Constant > const & getConstants() const
Retrieves the constants of the model.
Definition Model.cpp:689
ModelFeatures const & getModelFeatures() const
Retrieves the enabled model features.
Definition Model.cpp:129
void finalize()
After adding all components to the model, this method has to be called.
Definition Model.cpp:1399
std::unordered_map< std::string, FunctionDefinition > const & getGlobalFunctionDefinitions() const
Retrieves all global function definitions.
Definition Model.cpp:781
storm::expressions::Expression const & getGuard() const
std::vector< TemplateEdgeDestination > const & getDestinations() const
void setGuard(storm::expressions::Expression const &newGuard)
OrderedAssignments const & getAssignments() const
bool hasInitExpression() const
Retrieves whether an initial expression is set.
Definition Variable.cpp:46
JaniType & getType()
Definition Variable.cpp:67
storm::expressions::Expression const & getInitExpression() const
Retrieves the initial expression Should only be called if an initial expression is set for this varia...
Definition Variable.cpp:50
void setInitExpression(storm::expressions::Expression const &initialExpression)
Sets the initial expression for this variable.
Definition Variable.cpp:55
virtual boost::any visit(storm::expressions::BinaryRelationExpression const &expression, boost::any const &data) override
virtual boost::any visit(storm::expressions::BinaryNumericalFunctionExpression const &expression, boost::any const &data) override
virtual boost::any visit(storm::expressions::ValueArrayExpression const &expression, boost::any const &data) override
virtual boost::any visit(storm::expressions::RationalLiteralExpression const &expression, boost::any const &) override
virtual boost::any visit(storm::expressions::ConstructorArrayExpression const &expression, boost::any const &data) override
virtual boost::any visit(storm::expressions::TranscendentalNumberLiteralExpression const &expression, boost::any const &) override
FunctionEliminationExpressionVisitor(std::unordered_map< std::string, FunctionDefinition > const *globalFunctions, std::unordered_map< std::string, FunctionDefinition > const *localFunctions=nullptr)
virtual boost::any visit(storm::expressions::IfThenElseExpression const &expression, boost::any const &data) override
virtual boost::any visit(storm::expressions::UnaryNumericalFunctionExpression const &expression, boost::any const &data) override
virtual boost::any visit(storm::expressions::IntegerLiteralExpression const &expression, boost::any const &) override
virtual boost::any visit(storm::expressions::BooleanLiteralExpression const &expression, boost::any const &) override
virtual boost::any visit(storm::expressions::BinaryBooleanFunctionExpression const &expression, boost::any const &data) override
storm::expressions::Expression eliminate(storm::expressions::Expression const &expression)
virtual boost::any visit(storm::expressions::UnaryBooleanFunctionExpression const &expression, boost::any const &data) override
virtual boost::any visit(storm::expressions::ArrayAccessExpression const &expression, boost::any const &data) override
FunctionEliminationExpressionVisitor setLocalFunctions(std::unordered_map< std::string, FunctionDefinition > const *localFunctions)
virtual boost::any visit(storm::expressions::VariableExpression const &expression, boost::any const &) override
std::shared_ptr< storm::expressions::BaseExpression const > BaseExprPtr
virtual boost::any visit(storm::expressions::FunctionCallExpression const &expression, boost::any const &data) override
void eliminateFunctionsInFunctionBodies(FunctionEliminationExpressionVisitor &eliminationVisitor, std::unordered_map< std::string, FunctionDefinition > &functions)
void traverse(LValue &lValue, boost::any const &data) override
void traverse(storm::expressions::Expression const &expression, boost::any const &) override
void traverse(Location &location, boost::any const &data) override
void traverse(TemplateEdge &templateEdge, boost::any const &data) override
void traverse(Variable &variable, boost::any const &data) override
void eliminate(Model &model, std::vector< Property > &properties)
void traverse(Constant &constant, boost::any const &data) override
void eliminateFunctionsInFunctionBodies(FunctionEliminationExpressionVisitor &eliminationVisitor, std::unordered_map< std::string, FunctionDefinition > &functions, std::unordered_map< std::string, FunctionDefinitionStatus > &status, std::string const &current)
void traverse(JaniType &type, boost::any const &data) override
void traverse(EdgeDestination &edgeDestination, boost::any const &data) override
void traverse(Edge &edge, boost::any const &data) override
void traverse(Automaton &automaton, boost::any const &data) override
virtual void traverse(Model &model, boost::any const &) override
void traverse(Assignment &assignment, boost::any const &data) override
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:11
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
void eliminateFunctions(Model &model, std::vector< Property > &properties)
Eliminates all function references in the given model and the given properties by replacing them with...
storm::expressions::Expression eliminateFunctionCallsInExpression(storm::expressions::Expression const &expression, Model const &model)
Eliminates all function calls in the given expression by replacing them with their corresponding defi...
std::unordered_set< std::string > getOccurringFunctionCalls(storm::expressions::Expression const &expression)
bool containsFunctionCallExpression(Model const &model)
LabParser.cpp.
Definition cli.cpp:18