2#include <boost/any.hpp>
11ExtractMaximalStateFormulasVisitor::ExtractMaximalStateFormulasVisitor(ApToFormulaMap& extractedFormulas)
12 : extractedFormulas(extractedFormulas), nestingLevel(0) {}
15 ExtractMaximalStateFormulasVisitor visitor(extractedFormulas);
16 boost::any result = f.
accept(visitor, boost::any());
17 return boost::any_cast<std::shared_ptr<Formula>>(result);
21 if (nestingLevel > 0) {
25 std::shared_ptr<Formula> left = boost::any_cast<std::shared_ptr<Formula>>(f.
getLeftSubformula().accept(*
this, data));
26 if (left->hasQualitativeResult()) {
30 std::shared_ptr<Formula> right = boost::any_cast<std::shared_ptr<Formula>>(f.
getRightSubformula().accept(*
this, data));
31 if (right->hasQualitativeResult()) {
35 return std::static_pointer_cast<Formula>(std::make_shared<BinaryBooleanPathFormula>(f.
getOperator(), left, right));
39 if (nestingLevel > 0) {
44 "Can not extract maximal state formulas for multi-dimensional bounded until");
46 std::shared_ptr<Formula> left = boost::any_cast<std::shared_ptr<Formula>>(f.
getLeftSubformula().accept(*
this, data));
47 if (left->hasQualitativeResult()) {
51 std::shared_ptr<Formula> right = boost::any_cast<std::shared_ptr<Formula>>(f.
getRightSubformula().accept(*
this, data));
52 if (right->hasQualitativeResult()) {
57 std::vector<boost::optional<TimeBound>> lowerBounds, upperBounds;
58 std::vector<TimeBoundReference> timeBoundReferences;
63 lowerBounds.emplace_back();
68 upperBounds.emplace_back();
73 return std::static_pointer_cast<Formula>(std::make_shared<BoundedUntilFormula>(left, right, lowerBounds, upperBounds, timeBoundReferences));
77 if (nestingLevel > 0) {
81 std::shared_ptr<Formula> sub = boost::any_cast<std::shared_ptr<Formula>>(f.
getSubformula().accept(*
this, data));
82 if (sub->hasQualitativeResult()) {
86 return std::static_pointer_cast<Formula>(std::make_shared<EventuallyFormula>(sub));
90 if (nestingLevel > 0) {
94 std::shared_ptr<Formula> sub = boost::any_cast<std::shared_ptr<Formula>>(f.
getSubformula().accept(*
this, data));
95 if (sub->hasQualitativeResult()) {
99 return std::static_pointer_cast<Formula>(std::make_shared<GloballyFormula>(sub));
103 if (nestingLevel > 0) {
107 std::shared_ptr<Formula> sub = boost::any_cast<std::shared_ptr<Formula>>(f.
getSubformula().accept(*
this, data));
108 if (sub->hasQualitativeResult()) {
112 return std::static_pointer_cast<Formula>(std::make_shared<NextFormula>(sub));
116 if (nestingLevel > 0) {
120 std::shared_ptr<Formula> sub = boost::any_cast<std::shared_ptr<Formula>>(f.
getSubformula().accept(*
this, data));
121 if (sub->hasQualitativeResult()) {
125 return std::static_pointer_cast<Formula>(std::make_shared<UnaryBooleanPathFormula>(f.
getOperator(), sub));
129 if (nestingLevel > 0) {
133 std::shared_ptr<Formula> left = boost::any_cast<std::shared_ptr<Formula>>(f.
getLeftSubformula().accept(*
this, data));
134 if (left->hasQualitativeResult()) {
138 std::shared_ptr<Formula> right = boost::any_cast<std::shared_ptr<Formula>>(f.
getRightSubformula().accept(*
this, data));
139 if (right->hasQualitativeResult()) {
143 return std::static_pointer_cast<Formula>(std::make_shared<UntilFormula>(left, right));
147 incrementNestingLevel();
149 decrementNestingLevel();
154 incrementNestingLevel();
156 decrementNestingLevel();
161 incrementNestingLevel();
163 decrementNestingLevel();
168 incrementNestingLevel();
170 decrementNestingLevel();
175 incrementNestingLevel();
177 decrementNestingLevel();
188 auto it = cachedFormulas.find(f->toString());
189 if (it != cachedFormulas.end()) {
194 label =
"p" + std::to_string(extractedFormulas.size());
195 extractedFormulas[label] = f;
197 cachedFormulas[f->toString()] = label;
200 return std::make_shared<storm::logic::AtomicLabelFormula>(label);
203void ExtractMaximalStateFormulasVisitor::incrementNestingLevel()
const {
204 const_cast<std::size_t&
>(nestingLevel)++;
206void ExtractMaximalStateFormulasVisitor::decrementNestingLevel()
const {
208 const_cast<std::size_t&
>(nestingLevel)--;
virtual boost::any visit(AtomicExpressionFormula const &f, boost::any const &data) const override
#define STORM_LOG_ASSERT(cond, message)
#define STORM_LOG_THROW(cond, exception, message)