Storm
A Modern Probabilistic Model Checker
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
BinaryBooleanPathFormula.cpp
Go to the documentation of this file.
2#include <boost/any.hpp>
3#include <ostream>
4
6
9
10namespace storm {
11namespace logic {
12BinaryBooleanPathFormula::BinaryBooleanPathFormula(OperatorType operatorType, std::shared_ptr<Formula const> const& leftSubformula,
13 std::shared_ptr<Formula const> const& rightSubformula, FormulaContext context)
14 : BinaryPathFormula(leftSubformula, rightSubformula), operatorType(operatorType), context(context) {
15 STORM_LOG_THROW(this->getLeftSubformula().isStateFormula() || this->getLeftSubformula().isPathFormula(), storm::exceptions::InvalidPropertyException,
16 "Boolean path formula must have either path or state subformulas");
17 STORM_LOG_THROW(this->getRightSubformula().isStateFormula() || this->getRightSubformula().isPathFormula(), storm::exceptions::InvalidPropertyException,
18 "Boolean path formula must have either path or state subformulas");
19 STORM_LOG_THROW(context == FormulaContext::Probability, storm::exceptions::InvalidPropertyException, "Invalid context for formula.");
20}
21
23 return context;
24}
25
29
31 return true;
32}
33
34boost::any BinaryBooleanPathFormula::accept(FormulaVisitor const& visitor, boost::any const& data) const {
35 return visitor.visit(*this, data);
36}
37
41
43 return this->getOperator() == OperatorType::And;
44}
45
47 return this->getOperator() == OperatorType::Or;
48}
49
50std::ostream& BinaryBooleanPathFormula::writeToStream(std::ostream& out, bool allowParentheses) const {
51 if (allowParentheses) {
52 out << "(";
53 }
54 this->getLeftSubformula().writeToStream(out, true);
55 switch (operatorType) {
56 case OperatorType::And:
57 out << " & ";
58 break;
59 case OperatorType::Or:
60 out << " | ";
61 break;
62 }
63 this->getRightSubformula().writeToStream(out, true);
64 if (allowParentheses) {
65 out << ")";
66 }
67 return out;
68}
69} // namespace logic
70} // namespace storm
virtual bool isBinaryBooleanPathFormula() const override
BinaryBooleanPathFormula(OperatorType operatorType, std::shared_ptr< Formula const > const &leftSubformula, std::shared_ptr< Formula const > const &rightSubformula, FormulaContext context=FormulaContext::Probability)
virtual boost::any accept(FormulaVisitor const &visitor, boost::any const &data) const override
virtual bool isProbabilityPathFormula() const override
virtual std::ostream & writeToStream(std::ostream &out, bool allowParentheses=false) const override
Writes the forumla to the given output stream.
Formula const & getRightSubformula() const
Formula const & getLeftSubformula() const
virtual std::ostream & writeToStream(std::ostream &out, bool allowParentheses=false) const =0
Writes the forumla to the given output stream.
virtual bool isStateFormula() const
Definition Formula.cpp:24
virtual boost::any visit(AtomicExpressionFormula const &f, boost::any const &data) const =0
virtual bool isPathFormula() const override
#define STORM_LOG_THROW(cond, exception, message)
Definition macros.h:30
LabParser.cpp.
Definition cli.cpp:18