2#include <boost/any.hpp>
12ExtractMaximalStateFormulasVisitor::ExtractMaximalStateFormulasVisitor(ApToFormulaMap& extractedFormulas)
13 : extractedFormulas(extractedFormulas), nestingLevel(0) {}
16 ExtractMaximalStateFormulasVisitor visitor(extractedFormulas);
17 boost::any result = f.
accept(visitor, boost::any());
18 return boost::any_cast<std::shared_ptr<Formula>>(result);
22 if (nestingLevel > 0) {
26 std::shared_ptr<Formula> left = boost::any_cast<std::shared_ptr<Formula>>(f.
getLeftSubformula().accept(*
this, data));
27 if (left->hasQualitativeResult()) {
31 std::shared_ptr<Formula> right = boost::any_cast<std::shared_ptr<Formula>>(f.
getRightSubformula().accept(*
this, data));
32 if (right->hasQualitativeResult()) {
36 return std::static_pointer_cast<Formula>(std::make_shared<BinaryBooleanPathFormula>(f.
getOperator(), left, right));
40 if (nestingLevel > 0) {
45 "Can not extract maximal state formulas for multi-dimensional bounded until.");
47 std::shared_ptr<Formula> left = boost::any_cast<std::shared_ptr<Formula>>(f.
getLeftSubformula().accept(*
this, data));
48 if (left->hasQualitativeResult()) {
52 std::shared_ptr<Formula> right = boost::any_cast<std::shared_ptr<Formula>>(f.
getRightSubformula().accept(*
this, data));
53 if (right->hasQualitativeResult()) {
58 std::vector<std::optional<TimeBound>> lowerBounds, upperBounds;
59 std::vector<TimeBoundReference> timeBoundReferences;
64 lowerBounds.emplace_back();
69 upperBounds.emplace_back();
74 return std::static_pointer_cast<Formula>(std::make_shared<BoundedUntilFormula>(left, right, lowerBounds, upperBounds, timeBoundReferences));
78 if (nestingLevel > 0) {
82 std::shared_ptr<Formula> sub = boost::any_cast<std::shared_ptr<Formula>>(f.
getSubformula().accept(*
this, data));
83 if (sub->hasQualitativeResult()) {
87 return std::static_pointer_cast<Formula>(std::make_shared<EventuallyFormula>(sub));
91 if (nestingLevel > 0) {
95 std::shared_ptr<Formula> sub = boost::any_cast<std::shared_ptr<Formula>>(f.
getSubformula().accept(*
this, data));
96 if (sub->hasQualitativeResult()) {
100 return std::static_pointer_cast<Formula>(std::make_shared<GloballyFormula>(sub));
104 if (nestingLevel > 0) {
108 std::shared_ptr<Formula> sub = boost::any_cast<std::shared_ptr<Formula>>(f.
getSubformula().accept(*
this, data));
109 if (sub->hasQualitativeResult()) {
113 return std::static_pointer_cast<Formula>(std::make_shared<NextFormula>(sub));
117 if (nestingLevel > 0) {
121 std::shared_ptr<Formula> sub = boost::any_cast<std::shared_ptr<Formula>>(f.
getSubformula().accept(*
this, data));
122 if (sub->hasQualitativeResult()) {
126 return std::static_pointer_cast<Formula>(std::make_shared<UnaryBooleanPathFormula>(f.
getOperator(), sub));
130 if (nestingLevel > 0) {
134 std::shared_ptr<Formula> left = boost::any_cast<std::shared_ptr<Formula>>(f.
getLeftSubformula().accept(*
this, data));
135 if (left->hasQualitativeResult()) {
139 std::shared_ptr<Formula> right = boost::any_cast<std::shared_ptr<Formula>>(f.
getRightSubformula().accept(*
this, data));
140 if (right->hasQualitativeResult()) {
144 return std::static_pointer_cast<Formula>(std::make_shared<UntilFormula>(left, right));
148 incrementNestingLevel();
150 decrementNestingLevel();
155 incrementNestingLevel();
157 decrementNestingLevel();
162 incrementNestingLevel();
164 decrementNestingLevel();
169 incrementNestingLevel();
171 decrementNestingLevel();
176 incrementNestingLevel();
178 decrementNestingLevel();
189 auto it = cachedFormulas.find(f->toString());
190 if (it != cachedFormulas.end()) {
195 label =
"p" + std::to_string(extractedFormulas.size());
196 extractedFormulas[label] = f;
198 cachedFormulas[f->toString()] = label;
201 return std::make_shared<storm::logic::AtomicLabelFormula>(label);
204void ExtractMaximalStateFormulasVisitor::incrementNestingLevel()
const {
205 const_cast<std::size_t&
>(nestingLevel)++;
207void ExtractMaximalStateFormulasVisitor::decrementNestingLevel()
const {
209 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)