Storm 1.14.0.1
A Modern Probabilistic Model Checker
Loading...
Searching...
No Matches
Formula.cpp
Go to the documentation of this file.
2
3namespace storm {
4namespace prism {
5Formula::Formula(storm::expressions::Variable const& variable, storm::expressions::Expression const& expression, std::string const& filename,
6 uint_fast64_t lineNumber)
7 : LocatedInformation(filename, lineNumber), name(variable.getName()), variable(variable), expression(expression) {
8 // Intentionally left empty.
9}
10
11Formula::Formula(std::string const& name, storm::expressions::Expression const& expression, std::string const& filename, uint_fast64_t lineNumber)
12 : LocatedInformation(filename, lineNumber), name(name), expression(expression) {
13 // Intentionally left empty.
14}
15
16Formula::Formula(std::string const& name, std::string const& filename, uint_fast64_t lineNumber) : LocatedInformation(filename, lineNumber), name(name) {
17 // Intentionally left empty.
18}
19
20std::string const& Formula::getName() const {
21 return this->name;
22}
23
25 return this->variable.is_initialized();
26}
27
29 return this->variable.get();
30}
31
33 return this->expression;
34}
35
37 STORM_LOG_ASSERT(this->getExpression().isInitialized(), "Expression not initialized.");
39 "Expression variable type mismatch.");
40 return this->getExpressionVariable().getType();
41}
42
43Formula Formula::substitute(std::map<storm::expressions::Variable, storm::expressions::Expression> const& substitution) const {
44 STORM_LOG_ASSERT(this->getExpression().isInitialized(), "Expression not initialized.");
46 return Formula(this->getExpressionVariable(), this->getExpression().substitute(substitution), this->getFilename(), this->getLineNumber());
47 } else {
48 return Formula(this->getName(), this->getExpression().substitute(substitution), this->getFilename(), this->getLineNumber());
49 }
50}
51
53 STORM_LOG_ASSERT(this->getExpression().isInitialized(), "Expression not initialized.");
56 } else {
57 return Formula(this->getName(), this->getExpression().substituteNonStandardPredicates(), this->getFilename(), this->getLineNumber());
58 }
59}
60
61std::ostream& operator<<(std::ostream& stream, Formula const& formula) {
62 stream << "formula " << formula.getName() << " = " << formula.getExpression() << ";";
63 return stream;
64}
65} // namespace prism
66} // namespace storm
Type const & getType() const
Retrieves the type of the variable.
Definition Variable.cpp:50
Formula(storm::expressions::Variable const &variable, storm::expressions::Expression const &expression, std::string const &filename="", uint_fast64_t lineNumber=0)
Creates a formula with the given placeholder variable and expression.
Definition Formula.cpp:5
Formula substituteNonStandardPredicates() const
Definition Formula.cpp:52
storm::expressions::Expression const & getExpression() const
Retrieves the expression that is associated with this formula.
Definition Formula.cpp:32
bool hasExpressionVariable() const
Retrieves wheter a placeholder variable is used in expressions to represent this formula.
Definition Formula.cpp:24
Formula substitute(std::map< storm::expressions::Variable, storm::expressions::Expression > const &substitution) const
Substitutes all variables in the expression of the formula according to the given map.
Definition Formula.cpp:43
std::string const & getName() const
Retrieves the name that is associated with this formula.
Definition Formula.cpp:20
storm::expressions::Type const & getType() const
Retrieves the return type of the formula, i.e., the return-type of the defining expression.
Definition Formula.cpp:36
storm::expressions::Variable const & getExpressionVariable() const
Retrieves the placeholder variable that is used in expressions to represent this formula.
Definition Formula.cpp:28
uint_fast64_t getLineNumber() const
Retrieves the line number in which the information was found.
std::string const & getFilename() const
Retrieves the name of the file in which the information was found.
LocatedInformation(std::string const &filename, uint_fast64_t lineNumber)
Constructs a located information with the given filename and line number.
#define STORM_LOG_ASSERT(cond, message)
Definition macros.h:9
std::ostream & operator<<(std::ostream &stream, Assignment const &assignment)