diff --git a/src/formula/abstract/AbstractFormula.h b/src/formula/abstract/AbstractFormula.h index b7f453fcb..0d41d4450 100644 --- a/src/formula/abstract/AbstractFormula.h +++ b/src/formula/abstract/AbstractFormula.h @@ -32,7 +32,7 @@ namespace abstract { * @attention This class is abstract. * @note Formula classes do not have copy constructors. The parameters of the constructors are usually the subtrees, so * the syntax conflicts with copy constructors for unary operators. To produce an identical object, the classes - * AbstractPathFormula and AbstractStateFormula offer the method clone(). + * AbstractFormula and AbstractFormula offer the method clone(). * * This is the base class for every formula class in every logic. */ diff --git a/src/formula/abstract/And.h b/src/formula/abstract/And.h index 1bdbca9ed..e1b3a07c4 100644 --- a/src/formula/abstract/And.h +++ b/src/formula/abstract/And.h @@ -15,26 +15,7 @@ namespace storm { namespace formula { - -template class And; - -/*! - * @brief Interface class for model checkers that support And. - * - * All model checkers that support the formula class And must inherit - * this pure virtual class. - */ -template -class IAndModelChecker { - public: - /*! - * @brief Evaluates And formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual storm::storage::BitVector* checkAnd(const And& obj) const = 0; -}; +namespace abstract { /*! * @brief @@ -48,7 +29,7 @@ class IAndModelChecker { * The subtrees are seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to NULL before deletion) * - * @see AbstractStateFormula + * @see AbstractFormula * @see AbstractFormula */ template @@ -91,12 +72,35 @@ public: } } + /*! + * @returns a string representation of the formula + */ + virtual std::string toString() const { + std::string result = "("; + result += left->toString(); + result += " & "; + result += right->toString(); + result += ")"; + return result; + } + + /*! + * @brief Checks if all subtrees conform to some logic. + * + * @param checker Formula checker object. + * @return true iff all subtrees conform to some logic. + */ + virtual bool conforms(const AbstractFormulaChecker& checker) const { + return checker.conforms(this->left) && checker.conforms(this->right); + } + +protected: /*! * Sets the left child node. * * @param newLeft the new left child. */ - void setLeft(AbstractStateFormula* newLeft) { + void setLeft(AbstractFormula* newLeft) { left = newLeft; } @@ -105,82 +109,31 @@ public: * * @param newRight the new right child. */ - void setRight(AbstractStateFormula* newRight) { + void setRight(AbstractFormula* newRight) { right = newRight; } /*! * @returns a pointer to the left child node */ - const AbstractStateFormula& getLeft() const { + const AbstractFormula& getLeft() const { return *left; } /*! * @returns a pointer to the right child node */ - const AbstractStateFormula& getRight() const { + const AbstractFormula& getRight() const { return *right; } - /*! - * @returns a string representation of the formula - */ - virtual std::string toString() const { - std::string result = "("; - result += left->toString(); - result += " & "; - result += right->toString(); - result += ")"; - return result; - } - - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new AND-object that is identical the called object. - */ - virtual AbstractStateFormula* clone() const { - And* result = new And(); - if (this->left != NULL) { - result->setLeft(left->clone()); - } - if (this->right != NULL) { - result->setRight(right->clone()); - } - return result; - } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A bit vector indicating all states that satisfy the formula represented by the called object. - */ - virtual storm::storage::BitVector* check(const storm::modelchecker::AbstractModelChecker& modelChecker) const { - return modelChecker.template as()->checkAnd(*this); - } - - /*! - * @brief Checks if all subtrees conform to some logic. - * - * @param checker Formula checker object. - * @return true iff all subtrees conform to some logic. - */ - virtual bool conforms(const AbstractFormulaChecker& checker) const { - return checker.conforms(this->left) && checker.conforms(this->right); - } - private: AbstractFormula* left; AbstractFormula* right; }; +} //namespace abstract + } //namespace formula } //namespace storm diff --git a/src/formula/abstract/Ap.h b/src/formula/abstract/Ap.h index 0cb0d2480..6378719c4 100644 --- a/src/formula/abstract/Ap.h +++ b/src/formula/abstract/Ap.h @@ -5,35 +5,16 @@ * Author: Thomas Heinemann */ -#ifndef STORM_FORMULA_AP_H_ -#define STORM_FORMULA_AP_H_ +#ifndef STORM_FORMULA_ABSTRACT_AP_H_ +#define STORM_FORMULA_ABSTRACT_AP_H_ -#include "src/formula/AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" #include "src/modelchecker/ForwardDeclarations.h" namespace storm { namespace formula { - -template class Ap; - -/*! - * @brief Interface class for model checkers that support Ap. - * - * All model checkers that support the formula class Ap must inherit - * this pure virtual class. - */ -template -class IApModelChecker { - public: - /*! - * @brief Evaluates Ap formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual storm::storage::BitVector* checkAp(const Ap& obj) const = 0; -}; +namespace abstract { /*! * @brief @@ -41,11 +22,11 @@ class IApModelChecker { * * This class represents the leaves in the formula tree. * - * @see AbstractStateFormula + * @see AbstractFormula * @see AbstractFormula */ template -class Ap : public AbstractStateFormula { +class Ap : public AbstractFormula { public: /*! @@ -79,28 +60,6 @@ public: virtual std::string toString() const { return getAp(); } - - /*! - * Clones the called object. - * - * @returns a new Ap-object that is identical the called object. - */ - virtual AbstractStateFormula* clone() const { - return new Ap(ap); - } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A bit vector indicating all states that satisfy the formula represented by the called object. - */ - virtual storm::storage::BitVector *check(const storm::modelchecker::AbstractModelChecker& modelChecker) const { - return modelChecker.template as()->checkAp(*this); - } /*! * @brief Checks if all subtrees conform to some logic. @@ -118,8 +77,10 @@ private: std::string ap; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_AP_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_ABSTRCT_AP_H_ */ diff --git a/src/formula/abstract/BoundedEventually.h b/src/formula/abstract/BoundedEventually.h index 33c42f1ba..3753fbab3 100644 --- a/src/formula/abstract/BoundedEventually.h +++ b/src/formula/abstract/BoundedEventually.h @@ -5,11 +5,10 @@ * Author: Christian Dehnert */ -#ifndef STORM_FORMULA_BOUNDEDEVENTUALLY_H_ -#define STORM_FORMULA_BOUNDEDEVENTUALLY_H_ +#ifndef STORM_FORMULA_ABSTRACT_BOUNDEDEVENTUALLY_H_ +#define STORM_FORMULA_ABSTRACT_BOUNDEDEVENTUALLY_H_ -#include "src/formula/AbstractPathFormula.h" -#include "src/formula/AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" #include "boost/integer/integer_mask.hpp" #include @@ -19,25 +18,7 @@ namespace storm { namespace formula { -template class BoundedEventually; - -/*! - * @brief Interface class for model checkers that support BoundedEventually. - * - * All model checkers that support the formula class BoundedEventually must inherit - * this pure virtual class. - */ -template -class IBoundedEventuallyModelChecker { - public: - /*! - * @brief Evaluates BoundedEventually formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual std::vector* checkBoundedEventually(const BoundedEventually& obj, bool qualitative) const = 0; -}; +namespace abstract { /*! * @brief @@ -51,11 +32,11 @@ class IBoundedEventuallyModelChecker { * The subtrees are seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to NULL before deletion) * - * @see AbstractPathFormula + * @see AbstractFormula * @see AbstractFormula */ template -class BoundedEventually : public AbstractPathFormula { +class BoundedEventually : public AbstractFormula { public: /*! @@ -72,7 +53,7 @@ public: * @param child The child formula subtree * @param bound The maximal number of steps */ - BoundedEventually(AbstractStateFormula* child, uint_fast64_t bound) { + BoundedEventually(AbstractFormula* child, uint_fast64_t bound) { this->child = child; this->bound = bound; } @@ -89,21 +70,6 @@ public: } } - /*! - * @returns the child node - */ - const AbstractStateFormula& getChild() const { - return *child; - } - - /*! - * Sets the subtree - * @param child the new child node - */ - void setChild(AbstractStateFormula* child) { - this->child = child; - } - /*! * @returns the maximally allowed number of steps for the bounded until operator */ @@ -130,36 +96,6 @@ public: result += child->toString(); return result; } - - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new BoundedUntil-object that is identical the called object. - */ - virtual AbstractPathFormula* clone() const { - BoundedEventually* result = new BoundedEventually(); - result->setBound(bound); - if (child != nullptr) { - result->setChild(child->clone()); - } - return result; - } - - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A vector indicating the probability that the formula holds for each state. - */ - virtual std::vector* check(const storm::modelchecker::AbstractModelChecker& modelChecker, bool qualitative) const { - return modelChecker.template as()->checkBoundedEventually(*this, qualitative); - } /*! * @brief Checks if the subtree conforms to some logic. @@ -171,13 +107,32 @@ public: return checker.conforms(this->child); } +protected: + /*! + * @returns the child node + */ + const AbstractFormula& getChild() const { + return *child; + } + + /*! + * Sets the subtree + * @param child the new child node + */ + void setChild(AbstractFormula* child) { + this->child = child; + } + + private: - AbstractStateFormula* child; + AbstractFormula* child; uint_fast64_t bound; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_BOUNDEDUNTIL_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_BOUNDEDEVENTUALLY_H_ */ diff --git a/src/formula/abstract/BoundedNaryUntil.h b/src/formula/abstract/BoundedNaryUntil.h index 9f83df869..63594ff0e 100644 --- a/src/formula/abstract/BoundedNaryUntil.h +++ b/src/formula/abstract/BoundedNaryUntil.h @@ -5,11 +5,10 @@ * Author: Thomas Heinemann */ -#ifndef STORM_FORMULA_BOUNDEDNARYUNTIL_H_ -#define STORM_FORMULA_BOUNDEDNARYUNTIL_H_ +#ifndef STORM_FORMULA_ABSTRACT_BOUNDEDNARYUNTIL_H_ +#define STORM_FORMULA_ABSTRACT_BOUNDEDNARYUNTIL_H_ -#include "src/formula/AbstractPathFormula.h" -#include "src/formula/AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "boost/integer/integer_mask.hpp" #include #include @@ -19,26 +18,7 @@ namespace storm { namespace formula { - -template class BoundedNaryUntil; - -/*! - * @brief Interface class for model checkers that support BoundedNaryUntil. - * - * All model checkers that support the formula class BoundedNaryUntil must inherit - * this pure virtual class. - */ -template -class IBoundedNaryUntilModelChecker { - public: - /*! - * @brief Evaluates BoundedNaryUntil formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual std::vector* checkBoundedNaryUntil(const BoundedNaryUntil& obj, bool qualitative) const = 0; -}; +namespace abstract { /*! * @brief @@ -56,11 +36,11 @@ class IBoundedNaryUntilModelChecker { * The subtrees are seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to NULL before deletion) * - * @see AbstractPathFormula + * @see AbstractFormula * @see AbstractFormula */ template -class BoundedNaryUntil : public AbstractPathFormula { +class BoundedNaryUntil : public AbstractFormula { public: /*! @@ -68,7 +48,7 @@ public: */ BoundedNaryUntil() { this->left = nullptr; - this->right = new std::vector*,T,T>>(); + this->right = new std::vector*,T,T>>(); } /*! @@ -77,7 +57,7 @@ public: * @param left The left formula subtree * @param right The left formula subtree */ - BoundedNaryUntil(AbstractStateFormula* left, std::vector*,T,T>>* right) { + BoundedNaryUntil(AbstractFormula* left, std::vector*,T,T>>* right) { this->left = left; this->right = right; } @@ -97,16 +77,44 @@ public: } } + /*! + * @returns a string representation of the formula + */ + virtual std::string toString() const { + std::stringstream result; + result << "( " << left->toString(); + for (auto it = this->right->begin(); it != this->right->end(); ++it) { + result << " U[" << std::get<1>(*it) << "," << std::get<2>(*it) << "] " << std::get<0>(*it)->toString(); + } + result << ")"; + return result.str(); + } + + /*! + * @brief Checks if all subtrees conform to some logic. + * + * @param checker Formula checker object. + * @return true iff all subtrees conform to some logic. + */ + virtual bool conforms(const AbstractFormulaChecker& checker) const { + bool res = checker.conforms(this->left); + for (auto it = this->right->begin(); it != this->right->end(); ++it) { + res &= checker.conforms(std::get<0>(*it)); + } + return res; + } + +protected: /*! * Sets the left child node. * * @param newLeft the new left child. */ - void setLeft(AbstractStateFormula* newLeft) { + void setLeft(AbstractFormula* newLeft) { left = newLeft; } - void setRight(std::vector*,T,T>>* newRight) { + void setRight(std::vector*,T,T>>* newRight) { right = newRight; } @@ -116,93 +124,32 @@ public: * * @param newRight the new right child. */ - void addRight(AbstractStateFormula* newRight, T upperBound, T lowerBound) { - this->right->push_back(std::tuple*,T,T>(newRight, upperBound, lowerBound)); + void addRight(AbstractFormula* newRight, T upperBound, T lowerBound) { + this->right->push_back(std::tuple*,T,T>(newRight, upperBound, lowerBound)); } /*! * @returns a pointer to the left child node */ - const AbstractStateFormula& getLeft() const { + const AbstractFormula& getLeft() const { return *left; } /*! * @returns a pointer to the right child nodes. */ - const std::vector*,T,T>>& getRight() const { + const std::vector*,T,T>>& getRight() const { return *right; } - /*! - * @returns a string representation of the formula - */ - virtual std::string toString() const { - std::stringstream result; - result << "( " << left->toString(); - for (auto it = this->right->begin(); it != this->right->end(); ++it) { - result << " U[" << std::get<1>(*it) << "," << std::get<2>(*it) << "] " << std::get<0>(*it)->toString(); - } - result << ")"; - return result.str(); - } - - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new BoundedNaryUntil-object that is identical the called object. - */ - virtual AbstractPathFormula* clone() const { - BoundedNaryUntil* result = new BoundedNaryUntil(); - if (left != NULL) { - result->setLeft(left->clone()); - } - if (right != NULL) { - std::vector*,T,T>>* newright = new std::vector*,T,T>>(); - for (auto it = this->right->begin(); it != this->right->end(); ++it) { - newright->push_back(std::tuple*,T,T>(std::get<0>(*it)->clone(), std::get<1>(*it), std::get<2>(*it))); - } - result->setRight(newright); - } - return result; - } - - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A vector indicating the probability that the formula holds for each state. - */ - virtual std::vector *check(const storm::modelchecker::AbstractModelChecker& modelChecker, bool qualitative) const { - return modelChecker.template as()->checkBoundedNaryUntil(*this, qualitative); - } - - /*! - * @brief Checks if all subtrees conform to some logic. - * - * @param checker Formula checker object. - * @return true iff all subtrees conform to some logic. - */ - virtual bool conforms(const AbstractFormulaChecker& checker) const { - bool res = checker.conforms(this->left); - for (auto it = this->right->begin(); it != this->right->end(); ++it) { - res &= checker.conforms(std::get<0>(*it)); - } - return res; - } private: - AbstractStateFormula* left; - std::vector*,T,T>>* right; + AbstractFormula* left; + std::vector*,T,T>>* right; }; +} //namespace abstract } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_BOUNDEDNARYUNTIL_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_BOUNDEDNARYUNTIL_H_ */ diff --git a/src/formula/abstract/BoundedUntil.h b/src/formula/abstract/BoundedUntil.h index 685b1bfe1..1c57a7271 100644 --- a/src/formula/abstract/BoundedUntil.h +++ b/src/formula/abstract/BoundedUntil.h @@ -5,37 +5,17 @@ * Author: Thomas Heinemann */ -#ifndef STORM_FORMULA_BOUNDEDUNTIL_H_ -#define STORM_FORMULA_BOUNDEDUNTIL_H_ +#ifndef STORM_FORMULA_ABSTRACT_BOUNDEDUNTIL_H_ +#define STORM_FORMULA_ABSTRACT_BOUNDEDUNTIL_H_ -#include "src/formula/AbstractPathFormula.h" -#include "src/formula/AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "boost/integer/integer_mask.hpp" #include #include "src/modelchecker/ForwardDeclarations.h" namespace storm { namespace formula { - -template class BoundedUntil; - -/*! - * @brief Interface class for model checkers that support BoundedUntil. - * - * All model checkers that support the formula class BoundedUntil must inherit - * this pure virtual class. - */ -template -class IBoundedUntilModelChecker { - public: - /*! - * @brief Evaluates BoundedUntil formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual std::vector* checkBoundedUntil(const BoundedUntil& obj, bool qualitative) const = 0; -}; +namespace abstract { /*! * @brief @@ -50,11 +30,11 @@ class IBoundedUntilModelChecker { * The subtrees are seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to NULL before deletion) * - * @see AbstractPathFormula + * @see AbstractFormula * @see AbstractFormula */ template -class BoundedUntil : public AbstractPathFormula { +class BoundedUntil : public AbstractFormula { public: /*! @@ -73,7 +53,7 @@ public: * @param right The left formula subtree * @param bound The maximal number of steps */ - BoundedUntil(AbstractStateFormula* left, AbstractStateFormula* right, + BoundedUntil(AbstractFormula* left, AbstractFormula* right, uint_fast64_t bound) { this->left = left; this->right = right; @@ -95,38 +75,6 @@ public: } } - /*! - * Sets the left child node. - * - * @param newLeft the new left child. - */ - void setLeft(AbstractStateFormula* newLeft) { - left = newLeft; - } - - /*! - * Sets the right child node. - * - * @param newRight the new right child. - */ - void setRight(AbstractStateFormula* newRight) { - right = newRight; - } - - /*! - * @returns a pointer to the left child node - */ - const AbstractStateFormula& getLeft() const { - return *left; - } - - /*! - * @returns a pointer to the right child node - */ - const AbstractStateFormula& getRight() const { - return *right; - } - /*! * @returns the maximally allowed number of steps for the bounded until operator */ @@ -154,58 +102,60 @@ public: result += right->toString(); return result; } + + /*! + * @brief Checks if all subtrees conform to some logic. + * + * @param checker Formula checker object. + * @return true iff all subtrees conform to some logic. + */ + virtual bool conforms(const AbstractFormulaChecker& checker) const { + return checker.conforms(this->left) && checker.conforms(this->right); + } +protected: /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones + * Sets the left child node. * - * @returns a new BoundedUntil-object that is identical the called object. + * @param newLeft the new left child. */ - virtual AbstractPathFormula* clone() const { - BoundedUntil* result = new BoundedUntil(); - result->setBound(bound); - if (left != NULL) { - result->setLeft(left->clone()); - } - if (right != NULL) { - result->setRight(right->clone()); - } - return result; + void setLeft(AbstractFormula* newLeft) { + left = newLeft; } - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. + * Sets the right child node. * - * @returns A vector indicating the probability that the formula holds for each state. + * @param newRight the new right child. */ - virtual std::vector *check(const storm::modelchecker::AbstractModelChecker& modelChecker, bool qualitative) const { - return modelChecker.template as()->checkBoundedUntil(*this, qualitative); + void setRight(AbstractFormula* newRight) { + right = newRight; } - + /*! - * @brief Checks if all subtrees conform to some logic. - * - * @param checker Formula checker object. - * @return true iff all subtrees conform to some logic. - */ - virtual bool conforms(const AbstractFormulaChecker& checker) const { - return checker.conforms(this->left) && checker.conforms(this->right); + * @returns a pointer to the left child node + */ + const AbstractFormula& getLeft() const { + return *left; + } + + /*! + * @returns a pointer to the right child node + */ + const AbstractFormula& getRight() const { + return *right; } private: - AbstractStateFormula* left; - AbstractStateFormula* right; + AbstractFormula* left; + AbstractFormula* right; uint_fast64_t bound; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_BOUNDEDUNTIL_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_BOUNDEDUNTIL_H_ */ diff --git a/src/formula/abstract/Eventually.h b/src/formula/abstract/Eventually.h index 8db4f1b01..88be7de95 100644 --- a/src/formula/abstract/Eventually.h +++ b/src/formula/abstract/Eventually.h @@ -5,36 +5,17 @@ * Author: Christian Dehnert */ -#ifndef STORM_FORMULA_EVENTUALLY_H_ -#define STORM_FORMULA_EVENTUALLY_H_ +#ifndef STORM_FORMULA_ABSTRACT_EVENTUALLY_H_ +#define STORM_FORMULA_ABSTRACT_EVENTUALLY_H_ -#include "src/formula/AbstractPathFormula.h" -#include "src/formula/AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/modelchecker/ForwardDeclarations.h" namespace storm { namespace formula { -template class Eventually; - -/*! - * @brief Interface class for model checkers that support Eventually. - * - * All model checkers that support the formula class Eventually must inherit - * this pure virtual class. - */ -template -class IEventuallyModelChecker { - public: - /*! - * @brief Evaluates Eventually formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual std::vector* checkEventually(const Eventually& obj, bool qualitative) const = 0; -}; +namespace abstract { /*! * @brief @@ -48,11 +29,11 @@ class IEventuallyModelChecker { * The subtree is seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to nullptr before deletion) * - * @see AbstractPathFormula + * @see AbstractFormula * @see AbstractFormula */ template -class Eventually : public AbstractPathFormula { +class Eventually : public AbstractFormula { public: /*! @@ -67,7 +48,7 @@ public: * * @param child The child node */ - Eventually(AbstractStateFormula* child) { + Eventually(AbstractFormula* child) { this->child = child; } @@ -83,21 +64,6 @@ public: } } - /*! - * @returns the child node - */ - const AbstractStateFormula& getChild() const { - return *child; - } - - /*! - * Sets the subtree - * @param child the new child node - */ - void setChild(AbstractStateFormula* child) { - this->child = child; - } - /*! * @returns a string representation of the formula */ @@ -106,34 +72,6 @@ public: result += child->toString(); return result; } - - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new Eventually-object that is identical the called object. - */ - virtual AbstractPathFormula* clone() const { - Eventually* result = new Eventually(); - if (child != nullptr) { - result->setChild(child); - } - return result; - } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A vector indicating the probability that the formula holds for each state. - */ - virtual std::vector *check(const storm::modelchecker::AbstractModelChecker& modelChecker, bool qualitative) const { - return modelChecker.template as()->checkEventually(*this, qualitative); - } /*! * @brief Checks if the subtree conforms to some logic. @@ -145,12 +83,30 @@ public: return checker.conforms(this->child); } +protected: + /*! + * @returns the child node + */ + const AbstractFormula& getChild() const { + return *child; + } + + /*! + * Sets the subtree + * @param child the new child node + */ + void setChild(AbstractFormula* child) { + this->child = child; + } + private: - AbstractStateFormula* child; + AbstractFormula* child; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_EVENTUALLY_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_EVENTUALLY_H_ */ diff --git a/src/formula/abstract/Globally.h b/src/formula/abstract/Globally.h index 31d06bd05..adaac0d85 100644 --- a/src/formula/abstract/Globally.h +++ b/src/formula/abstract/Globally.h @@ -5,11 +5,10 @@ * Author: Christian Dehnert */ -#ifndef STORM_FORMULA_GLOBALLY_H_ -#define STORM_FORMULA_GLOBALLY_H_ +#ifndef STORM_FORMULA_ABSTRACT_GLOBALLY_H_ +#define STORM_FORMULA_ABSTRACT_GLOBALLY_H_ -#include "AbstractPathFormula.h" -#include "AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" #include "src/modelchecker/ForwardDeclarations.h" @@ -17,25 +16,7 @@ namespace storm { namespace formula { -template class Globally; - -/*! - * @brief Interface class for model checkers that support Globally. - * - * All model checkers that support the formula class Globally must inherit - * this pure virtual class. - */ -template -class IGloballyModelChecker { - public: - /*! - * @brief Evaluates Globally formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual std::vector* checkGlobally(const Globally& obj, bool qualitative) const = 0; -}; +namespace abstract { /*! * @brief @@ -49,11 +30,11 @@ class IGloballyModelChecker { * The subtree is seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to nullptr before deletion) * - * @see AbstractPathFormula + * @see AbstractFormula * @see AbstractFormula */ template -class Globally : public AbstractPathFormula { +class Globally : public AbstractFormula { public: /*! @@ -68,7 +49,7 @@ public: * * @param child The child node */ - Globally(AbstractStateFormula* child) { + Globally(AbstractFormula* child) { this->child = child; } @@ -84,21 +65,6 @@ public: } } - /*! - * @returns the child node - */ - const AbstractStateFormula& getChild() const { - return *child; - } - - /*! - * Sets the subtree - * @param child the new child node - */ - void setChild(AbstractStateFormula* child) { - this->child = child; - } - /*! * @returns a string representation of the formula */ @@ -107,34 +73,6 @@ public: result += child->toString(); return result; } - - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new Globally-object that is identical the called object. - */ - virtual AbstractPathFormula* clone() const { - Next* result = new Next(); - if (child != nullptr) { - result->setChild(child); - } - return result; - } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A vector indicating the probability that the formula holds for each state. - */ - virtual std::vector *check(const storm::modelchecker::AbstractModelChecker& modelChecker, bool qualitative) const { - return modelChecker.template as()->checkGlobally(*this, qualitative); - } /*! * @brief Checks if the subtree conforms to some logic. @@ -146,12 +84,30 @@ public: return checker.conforms(this->child); } +protected: + /*! + * @returns the child node + */ + const AbstractFormula& getChild() const { + return *child; + } + + /*! + * Sets the subtree + * @param child the new child node + */ + void setChild(AbstractFormula* child) { + this->child = child; + } + private: - AbstractStateFormula* child; + AbstractFormula* child; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_GLOBALLY_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_GLOBALLY_H_ */ diff --git a/src/formula/abstract/Next.h b/src/formula/abstract/Next.h index 5f36b053e..9f2247f81 100644 --- a/src/formula/abstract/Next.h +++ b/src/formula/abstract/Next.h @@ -5,36 +5,17 @@ * Author: Thomas Heinemann */ -#ifndef STORM_FORMULA_NEXT_H_ -#define STORM_FORMULA_NEXT_H_ +#ifndef STORM_FORMULA_ABSTRACT_NEXT_H_ +#define STORM_FORMULA_ABSTRACT_NEXT_H_ -#include "AbstractPathFormula.h" -#include "AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" namespace storm { namespace formula { -template class Next; - -/*! - * @brief Interface class for model checkers that support Next. - * - * All model checkers that support the formula class Next must inherit - * this pure virtual class. - */ -template -class INextModelChecker { - public: - /*! - * @brief Evaluates Next formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual std::vector* checkNext(const Next& obj, bool qualitative) const = 0; -}; +namespace abstract { /*! * @brief @@ -48,11 +29,11 @@ class INextModelChecker { * The subtree is seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to NULL before deletion) * - * @see AbstractPathFormula + * @see AbstractFormula * @see AbstractFormula */ template -class Next : public AbstractPathFormula { +class Next : public AbstractFormula { public: /*! @@ -67,7 +48,7 @@ public: * * @param child The child node */ - Next(AbstractStateFormula* child) { + Next(AbstractFormula* child) { this->child = child; } @@ -83,21 +64,6 @@ public: } } - /*! - * @returns the child node - */ - const AbstractStateFormula& getChild() const { - return *child; - } - - /*! - * Sets the subtree - * @param child the new child node - */ - void setChild(AbstractStateFormula* child) { - this->child = child; - } - /*! * @returns a string representation of the formula */ @@ -108,34 +74,6 @@ public: result += ")"; return result; } - - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new BoundedUntil-object that is identical the called object. - */ - virtual AbstractPathFormula* clone() const { - Next* result = new Next(); - if (child != NULL) { - result->setChild(child); - } - return result; - } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A vector indicating the probability that the formula holds for each state. - */ - virtual std::vector *check(const storm::modelchecker::AbstractModelChecker& modelChecker, bool qualitative) const { - return modelChecker.template as()->checkNext(*this, qualitative); - } /*! * @brief Checks if the subtree conforms to some logic. @@ -147,12 +85,30 @@ public: return checker.conforms(this->child); } +protected: + /*! + * @returns the child node + */ + const AbstractFormula& getChild() const { + return *child; + } + + /*! + * Sets the subtree + * @param child the new child node + */ + void setChild(AbstractFormula* child) { + this->child = child; + } + private: - AbstractStateFormula* child; + AbstractFormula* child; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_NEXT_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_NEXT_H_ */ diff --git a/src/formula/abstract/Not.h b/src/formula/abstract/Not.h index dde509ec8..4bbc3be7c 100644 --- a/src/formula/abstract/Not.h +++ b/src/formula/abstract/Not.h @@ -5,10 +5,10 @@ * Author: Thomas Heinemann */ -#ifndef STORM_FORMULA_NOT_H_ -#define STORM_FORMULA_NOT_H_ +#ifndef STORM_FORMULA_ABSTRACT_NOT_H_ +#define STORM_FORMULA_ABSTRACT_NOT_H_ -#include "AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" #include "src/modelchecker/ForwardDeclarations.h" @@ -16,25 +16,7 @@ namespace storm { namespace formula { -template class Not; - -/*! - * @brief Interface class for model checkers that support Not. - * - * All model checkers that support the formula class Not must inherit - * this pure virtual class. - */ -template -class INotModelChecker { - public: - /*! - * @brief Evaluates Not formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual storm::storage::BitVector* checkNot(const Not& obj) const = 0; -}; +namespace abstract { /*! * @brief @@ -45,11 +27,11 @@ class INotModelChecker { * The subtree is seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to NULL before deletion) * - * @see AbstractStateFormula + * @see AbstractFormula * @see AbstractFormula */ template -class Not : public AbstractStateFormula { +class Not : public AbstractFormula { public: /*! @@ -63,7 +45,7 @@ public: * Constructor * @param child The child node */ - Not(AbstractStateFormula* child) { + Not(AbstractFormula* child) { this->child = child; } @@ -79,21 +61,6 @@ public: } } - /*! - * @returns The child node - */ - const AbstractStateFormula& getChild() const { - return *child; - } - - /*! - * Sets the subtree - * @param child the new child node - */ - void setChild(AbstractStateFormula* child) { - this->child = child; - } - /*! * @returns a string representation of the formula */ @@ -102,34 +69,6 @@ public: result += child->toString(); return result; } - - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new AND-object that is identical the called object. - */ - virtual AbstractStateFormula* clone() const { - Not* result = new Not(); - if (child != NULL) { - result->setChild(child->clone()); - } - return result; - } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A bit vector indicating all states that satisfy the formula represented by the called object. - */ - virtual storm::storage::BitVector *check(const storm::modelchecker::AbstractModelChecker& modelChecker) const { - return modelChecker.template as()->checkNot(*this); - } /*! * @brief Checks if the subtree conforms to some logic. @@ -141,12 +80,30 @@ public: return checker.conforms(this->child); } +protected: + /*! + * @returns The child node + */ + const AbstractFormula& getChild() const { + return *child; + } + + /*! + * Sets the subtree + * @param child the new child node + */ + void setChild(AbstractFormula* child) { + this->child = child; + } + private: - AbstractStateFormula* child; + AbstractFormula* child; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_NOT_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_NOT_H_ */ diff --git a/src/formula/abstract/OptimizingOperator.h b/src/formula/abstract/OptimizingOperator.h index 030655fce..ed08644a1 100644 --- a/src/formula/abstract/OptimizingOperator.h +++ b/src/formula/abstract/OptimizingOperator.h @@ -1,10 +1,12 @@ -#ifndef STORM_FORMULA_OPTIMIZINGOPERATOR_H_ -#define STORM_FORMULA_OPTIMIZINGOPERATOR_H_ +#ifndef STORM_FORMULA_ABSTRACT_OPTIMIZINGOPERATOR_H_ +#define STORM_FORMULA_ABSTRACT_OPTIMIZINGOPERATOR_H_ namespace storm { namespace formula { +namespace abstract { + class OptimizingOperator { public: /*! @@ -49,8 +51,10 @@ private: bool minimumOperator; }; -} /* namespace formula */ +} //namespace abstract + +} //namespace formula -} /* namespace storm */ +} //namespace storm -#endif /* STORM_FORMULA_OPTIMIZINGOPERATOR_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_OPTIMIZINGOPERATOR_H_ */ diff --git a/src/formula/abstract/Or.h b/src/formula/abstract/Or.h index bb91bfa59..42e86c198 100644 --- a/src/formula/abstract/Or.h +++ b/src/formula/abstract/Or.h @@ -5,34 +5,15 @@ * Author: Thomas Heinemann */ -#ifndef STORM_FORMULA_OR_H_ -#define STORM_FORMULA_OR_H_ +#ifndef STORM_FORMULA_ABSTRACT_OR_H_ +#define STORM_FORMULA_ABSTRACT_OR_H_ -#include "src/formula/AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" namespace storm { namespace formula { - -template class Or; - -/*! - * @brief Interface class for model checkers that support Or. - * - * All model checkers that support the formula class Or must inherit - * this pure virtual class. - */ -template -class IOrModelChecker { - public: - /*! - * @brief Evaluates Or formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual storm::storage::BitVector* checkOr(const Or& obj) const = 0; -}; +namespace abstract { /*! * @brief @@ -46,11 +27,11 @@ class IOrModelChecker { * The subtrees are seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to NULL before deletion) * - * @see AbstractStateFormula + * @see AbstractFormula * @see AbstractFormula */ template -class Or : public AbstractStateFormula { +class Or : public AbstractFormula { public: /*! @@ -69,7 +50,7 @@ public: * @param left The left sub formula * @param right The right sub formula */ - Or(AbstractStateFormula* left, AbstractStateFormula* right) { + Or(AbstractFormula* left, AbstractFormula* right) { this->left = left; this->right = right; } @@ -89,12 +70,35 @@ public: } } + /*! + * @returns a string representation of the formula + */ + virtual std::string toString() const { + std::string result = "("; + result += left->toString(); + result += " | "; + result += right->toString(); + result += ")"; + return result; + } + + /*! + * @brief Checks if all subtrees conform to some logic. + * + * @param checker Formula checker object. + * @return true iff all subtrees conform to some logic. + */ + virtual bool conforms(const AbstractFormulaChecker& checker) const { + return checker.conforms(this->left) && checker.conforms(this->right); + } + +protected: /*! * Sets the left child node. * * @param newLeft the new left child. */ - void setLeft(AbstractStateFormula* newLeft) { + void setLeft(AbstractFormula* newLeft) { left = newLeft; } @@ -103,84 +107,33 @@ public: * * @param newRight the new right child. */ - void setRight(AbstractStateFormula* newRight) { + void setRight(AbstractFormula* newRight) { right = newRight; } /*! * @returns a pointer to the left child node */ - const AbstractStateFormula& getLeft() const { + const AbstractFormula& getLeft() const { return *left; } /*! * @returns a pointer to the right child node */ - const AbstractStateFormula& getRight() const { + const AbstractFormula& getRight() const { return *right; } - /*! - * @returns a string representation of the formula - */ - virtual std::string toString() const { - std::string result = "("; - result += left->toString(); - result += " | "; - result += right->toString(); - result += ")"; - return result; - } - - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new AND-object that is identical the called object. - */ - virtual AbstractStateFormula* clone() const { - Or* result = new Or(); - if (this->left != NULL) { - result->setLeft(left->clone()); - } - if (this->right != NULL) { - result->setRight(right->clone()); - } - return result; - } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A bit vector indicating all states that satisfy the formula represented by the called object. - */ - virtual storm::storage::BitVector *check(const storm::modelchecker::AbstractModelChecker& modelChecker) const { - return modelChecker.template as()->checkOr(*this); - } - - /*! - * @brief Checks if all subtrees conform to some logic. - * - * @param checker Formula checker object. - * @return true iff all subtrees conform to some logic. - */ - virtual bool conforms(const AbstractFormulaChecker& checker) const { - return checker.conforms(this->left) && checker.conforms(this->right); - } - private: - AbstractStateFormula* left; - AbstractStateFormula* right; + AbstractFormula* left; + AbstractFormula* right; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_OR_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_OR_H_ */ diff --git a/src/formula/abstract/PathBoundOperator.h b/src/formula/abstract/PathBoundOperator.h index 2bece5c61..fa65cbe6d 100644 --- a/src/formula/abstract/PathBoundOperator.h +++ b/src/formula/abstract/PathBoundOperator.h @@ -5,14 +5,14 @@ * Author: Christian Dehnert */ -#ifndef STORM_FORMULA_PATHBOUNDOPERATOR_H_ -#define STORM_FORMULA_PATHBOUNDOPERATOR_H_ +#ifndef STORM_FORMULA_ABSTRACT_PATHBOUNDOPERATOR_H_ +#define STORM_FORMULA_ABSTRACT_PATHBOUNDOPERATOR_H_ -#include "src/formula/AbstractStateFormula.h" -#include "src/formula/AbstractPathFormula.h" +#include "src/formula/abstract/AbstractFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" -#include "src/formula/OptimizingOperator.h" +#include "src/formula/abstract/OptimizingOperator.h" #include "src/modelchecker/ForwardDeclarations.h" #include "src/utility/ConstTemplates.h" @@ -21,6 +21,8 @@ namespace storm { namespace formula { +namespace abstract { + template class PathBoundOperator; /*! @@ -38,14 +40,14 @@ template class PathBoundOperator; * (this behavior can be prevented by setting them to NULL before deletion) * * - * @see AbstractStateFormula - * @see AbstractPathFormula + * @see AbstractFormula + * @see AbstractFormula * @see ProbabilisticOperator * @see ProbabilisticNoBoundsOperator * @see AbstractFormula */ template -class PathBoundOperator : public AbstractStateFormula, public OptimizingOperator { +class PathBoundOperator : public AbstractFormula, public OptimizingOperator { public: enum ComparisonType { LESS, LESS_EQUAL, GREATER, GREATER_EQUAL }; @@ -57,7 +59,7 @@ public: * @param bound The bound for the probability * @param pathFormula The child node */ - PathBoundOperator(ComparisonType comparisonOperator, T bound, AbstractPathFormula* pathFormula) + PathBoundOperator(ComparisonType comparisonOperator, T bound, AbstractFormula* pathFormula) : comparisonOperator(comparisonOperator), bound(bound), pathFormula(pathFormula) { // Intentionally left empty } @@ -70,7 +72,7 @@ public: * @param pathFormula The child node * @param minimumOperator Indicator, if operator should be minimum or maximum operator. */ - PathBoundOperator(ComparisonType comparisonOperator, T bound, AbstractPathFormula* pathFormula, bool minimumOperator) + PathBoundOperator(ComparisonType comparisonOperator, T bound, AbstractFormula* pathFormula, bool minimumOperator) : comparisonOperator(comparisonOperator), bound(bound), pathFormula(pathFormula), OptimizingOperator(minimumOperator) { // Intentionally left empty } @@ -87,22 +89,6 @@ public: } } - /*! - * @returns the child node (representation of a Abstract path formula) - */ - const AbstractPathFormula& getPathFormula () const { - return *pathFormula; - } - - /*! - * Sets the child node - * - * @param pathFormula the path formula that becomes the new child node - */ - void setPathFormula(AbstractPathFormula* pathFormula) { - this->pathFormula = pathFormula; - } - /*! * @returns the comparison relation */ @@ -159,15 +145,6 @@ public: } } - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new AND-object that is identical the called object. - */ - virtual AbstractStateFormula* clone() const = 0; - /*! * @brief Checks if the subtree conforms to some logic. * @@ -178,14 +155,34 @@ public: return checker.conforms(this->pathFormula); } +protected: + /*! + * @returns the child node (representation of a Abstract path formula) + */ + const AbstractFormula& getPathFormula () const { + return *pathFormula; + } + + /*! + * Sets the child node + * + * @param pathFormula the path formula that becomes the new child node + */ + void setPathFormula(AbstractFormula* pathFormula) { + this->pathFormula = pathFormula; + } + + private: ComparisonType comparisonOperator; T bound; - AbstractPathFormula* pathFormula; + AbstractFormula* pathFormula; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_PATHBOUNDOPERATOR_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_PATHBOUNDOPERATOR_H_ */ diff --git a/src/formula/abstract/PathNoBoundOperator.h b/src/formula/abstract/PathNoBoundOperator.h index f562ecc91..68da9ba40 100644 --- a/src/formula/abstract/PathNoBoundOperator.h +++ b/src/formula/abstract/PathNoBoundOperator.h @@ -5,13 +5,13 @@ * Author: Christian Dehnert */ -#ifndef STORM_FORMULA_NOBOUNDOPERATOR_H_ -#define STORM_FORMULA_NOBOUNDOPERATOR_H_ +#ifndef STORM_FORMULA_ABSTRACT_NOBOUNDOPERATOR_H_ +#define STORM_FORMULA_ABSTRACT_NOBOUNDOPERATOR_H_ -#include "src/formula/AbstractFormula.h" -#include "src/formula/AbstractPathFormula.h" +#include "src/formula/abstract/AbstractFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" -#include "src/formula/OptimizingOperator.h" +#include "src/formula/abstract/OptimizingOperator.h" #include "src/modelchecker/ForwardDeclarations.h" @@ -19,26 +19,7 @@ namespace storm { namespace formula { -template class PathNoBoundOperator; - -/*! - * @brief Interface class for model checkers that support PathNoBoundOperator. - * - * All model checkers that support the formula class NoBoundOperator must inherit - * this pure virtual class. - */ -template -class IPathNoBoundOperatorModelChecker { - public: - /*! - * @brief Evaluates NoBoundOperator formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual std::vector* checkPathNoBoundOperator(const PathNoBoundOperator& obj) const = 0; -}; - +namespace abstract { /*! * @brief * Class for a Abstract formula tree with a P (probablistic) operator without declaration of probabilities @@ -63,8 +44,8 @@ class IPathNoBoundOperatorModelChecker { * (this behavior can be prevented by setting them to NULL before deletion) * * - * @see AbstractStateFormula - * @see AbstractPathFormula + * @see AbstractFormula + * @see AbstractFormula * @see ProbabilisticOperator * @see ProbabilisticIntervalOperator * @see AbstractFormula @@ -84,7 +65,7 @@ public: * * @param pathFormula The child node. */ - PathNoBoundOperator(AbstractPathFormula* pathFormula) : optimalityOperator(false), minimumOperator(false) { + PathNoBoundOperator(AbstractFormula* pathFormula) : optimalityOperator(false), minimumOperator(false) { this->pathFormula = pathFormula; } @@ -95,7 +76,7 @@ public: * @param minimumOperator A flag indicating whether this operator is a minimizing or a * maximizing operator. */ - PathNoBoundOperator(AbstractPathFormula* pathFormula, bool minimumOperator) + PathNoBoundOperator(AbstractFormula* pathFormula, bool minimumOperator) : optimalityOperator(true), minimumOperator(minimumOperator) { this->pathFormula = pathFormula; } @@ -109,37 +90,6 @@ public: } } - /*! - * @returns the child node (representation of a Abstract path formula) - */ - const AbstractPathFormula& getPathFormula () const { - return *pathFormula; - } - - /*! - * Sets the child node - * - * @param pathFormula the path formula that becomes the new child node - */ - void setPathFormula(AbstractPathFormula* pathFormula) { - this->pathFormula = pathFormula; - } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @note This function is not implemented in this class. - * - * @returns A vector indicating all states that satisfy the formula represented by the called object. - */ - virtual std::vector* check(const storm::modelchecker::AbstractModelChecker& modelChecker) const { - return modelChecker.template as()->checkPathNoBoundOperator(*this); - } - /*! * @returns a string representation of the formula */ @@ -186,8 +136,25 @@ public: return optimalityOperator && minimumOperator; } +protected: + /*! + * @returns the child node (representation of a Abstract path formula) + */ + const AbstractFormula& getPathFormula () const { + return *pathFormula; + } + + /*! + * Sets the child node + * + * @param pathFormula the path formula that becomes the new child node + */ + void setPathFormula(AbstractFormula* pathFormula) { + this->pathFormula = pathFormula; + } + private: - AbstractPathFormula* pathFormula; + AbstractFormula* pathFormula; // A flag that indicates whether this operator is meant as an optimizing (i.e. min/max) operator // over a nondeterministic model. @@ -198,8 +165,10 @@ private: bool minimumOperator; }; -} /* namespace formula */ +} //namespace abstract + +} //namespace formula -} /* namespace storm */ +} //namespace storm -#endif /* STORM_FORMULA_NOBOUNDOPERATOR_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_NOBOUNDOPERATOR_H_ */ diff --git a/src/formula/abstract/ProbabilisticBoundOperator.h b/src/formula/abstract/ProbabilisticBoundOperator.h index 8d651ef2c..30f37eeba 100644 --- a/src/formula/abstract/ProbabilisticBoundOperator.h +++ b/src/formula/abstract/ProbabilisticBoundOperator.h @@ -5,31 +5,17 @@ * Author: Thomas Heinemann */ -#ifndef STORM_FORMULA_PROBABILISTICBOUNDOPERATOR_H_ -#define STORM_FORMULA_PROBABILISTICBOUNDOPERATOR_H_ +#ifndef STORM_FORMULA_ABSTRACT_PROBABILISTICBOUNDOPERATOR_H_ +#define STORM_FORMULA_ABSTRACT_PROBABILISTICBOUNDOPERATOR_H_ -#include "AbstractStateFormula.h" -#include "AbstractPathFormula.h" -#include "src/formula/PathBoundOperator.h" -#include "src/formula/OptimizingOperator.h" +#include "src/formula/abstract/AbstractFormula.h" +#include "src/formula/abstract/PathBoundOperator.h" +#include "src/formula/abstract/OptimizingOperator.h" #include "utility/ConstTemplates.h" namespace storm { namespace formula { - -template class ProbabilisticBoundOperator; - -/*! - * @brief Interface class for model checkers that support ProbabilisticBoundOperator. - * - * All model checkers that support the formula class PathBoundOperator must inherit - * this pure virtual class. - */ -template -class IProbabilisticBoundOperatorModelChecker { - public: - virtual storm::storage::BitVector* checkProbabilisticBoundOperator(const ProbabilisticBoundOperator& obj) const = 0; -}; +namespace abstract { /*! * @brief @@ -46,8 +32,8 @@ class IProbabilisticBoundOperatorModelChecker { * (this behavior can be prevented by setting them to NULL before deletion) * * - * @see AbstractStateFormula - * @see AbstractPathFormula + * @see AbstractFormula + * @see AbstractFormula * @see ProbabilisticOperator * @see ProbabilisticNoBoundsOperator * @see AbstractFormula @@ -73,56 +59,44 @@ public: * @param pathFormula The child node */ ProbabilisticBoundOperator( - typename PathBoundOperator::ComparisonType comparisonRelation, T bound, AbstractPathFormula* pathFormula) + typename PathBoundOperator::ComparisonType comparisonRelation, T bound, AbstractFormula* pathFormula) : PathBoundOperator(comparisonRelation, bound, pathFormula) { // Intentionally left empty } + /*! + * Constructor + * + * @param comparisonRelation + * @param bound + * @param pathFormula + * @param minimumOperator + */ ProbabilisticBoundOperator( - typename PathBoundOperator::ComparisonType comparisonRelation, T bound, AbstractPathFormula* pathFormula, bool minimumOperator) + typename PathBoundOperator::ComparisonType comparisonRelation, T bound, AbstractFormula* pathFormula, bool minimumOperator) : PathBoundOperator(comparisonRelation, bound, pathFormula, minimumOperator){ // Intentionally left empty } /*! - * @returns a string representation of the formula + * Destructor */ - virtual std::string toString() const { - std::string result = "P "; - result += PathBoundOperator::toString(); - return result; + virtual ~ProbabilisticBoundOperator() { + // Intentionally left empty } /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new AND-object that is identical the called object. + * @returns a string representation of the formula */ - virtual AbstractStateFormula* clone() const { - ProbabilisticBoundOperator* result = new ProbabilisticBoundOperator(); - result->setComparisonOperator(this->getComparisonOperator()); - result->setBound(this->getBound()); - result->setPathFormula(this->getPathFormula().clone()); + virtual std::string toString() const { + std::string result = "P "; + result += PathBoundOperator::toString(); return result; } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A bit vector indicating all states that satisfy the formula represented by the called object. - */ - virtual storm::storage::BitVector* check(const storm::modelchecker::AbstractModelChecker& modelChecker) const { - return modelChecker.template as()->checkProbabilisticBoundOperator(*this); - } }; +} //namespace abstract } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_PROBABILISTICBOUNDOPERATOR_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_PROBABILISTICBOUNDOPERATOR_H_ */ diff --git a/src/formula/abstract/ProbabilisticNoBoundOperator.h b/src/formula/abstract/ProbabilisticNoBoundOperator.h index 66843d965..68e5e1bcb 100644 --- a/src/formula/abstract/ProbabilisticNoBoundOperator.h +++ b/src/formula/abstract/ProbabilisticNoBoundOperator.h @@ -5,15 +5,16 @@ * Author: thomas */ -#ifndef STORM_FORMULA_PROBABILISTICNOBOUNDOPERATOR_H_ -#define STORM_FORMULA_PROBABILISTICNOBOUNDOPERATOR_H_ +#ifndef STORM_FORMULA_ABSTRACT_PROBABILISTICNOBOUNDOPERATOR_H_ +#define STORM_FORMULA_ABSTRACT_PROBABILISTICNOBOUNDOPERATOR_H_ #include "AbstractFormula.h" -#include "AbstractPathFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "PathNoBoundOperator.h" namespace storm { namespace formula { +namespace abstract { /*! * @brief @@ -39,8 +40,8 @@ namespace formula { * (this behavior can be prevented by setting them to NULL before deletion) * * - * @see AbstractStateFormula - * @see AbstractPathFormula + * @see AbstractFormula + * @see AbstractFormula * @see ProbabilisticOperator * @see ProbabilisticIntervalOperator * @see AbstractFormula @@ -60,7 +61,14 @@ public: * * @param pathFormula The child node. */ - ProbabilisticNoBoundOperator(AbstractPathFormula* pathFormula) : PathNoBoundOperator(pathFormula) { + ProbabilisticNoBoundOperator(AbstractFormula* pathFormula) : PathNoBoundOperator(pathFormula) { + // Intentionally left empty + } + + /*! + * Destructor + */ + virtual ~ProbabilisticNoBoundOperator() { // Intentionally left empty } @@ -69,7 +77,7 @@ public: * * @param pathFormula The child node. */ - ProbabilisticNoBoundOperator(AbstractPathFormula* pathFormula, bool minimumOperator) : PathNoBoundOperator(pathFormula, minimumOperator) { + ProbabilisticNoBoundOperator(AbstractFormula* pathFormula, bool minimumOperator) : PathNoBoundOperator(pathFormula, minimumOperator) { // Intentionally left empty } @@ -83,7 +91,8 @@ public: } }; -} /* namespace formula */ -} /* namespace storm */ +} //namespace abstract +} //namespace formula +} //namespace storm -#endif /* STORM_FORMULA_PROBABILISTICNOBOUNDOPERATOR_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_PROBABILISTICNOBOUNDOPERATOR_H_ */ diff --git a/src/formula/abstract/StateBoundOperator.h b/src/formula/abstract/StateBoundOperator.h index 441c91f1d..c1f0f2ce7 100644 --- a/src/formula/abstract/StateBoundOperator.h +++ b/src/formula/abstract/StateBoundOperator.h @@ -5,31 +5,18 @@ * Author: Christian Dehnert */ -#ifndef STORM_FORMULA_STATEBOUNDOPERATOR_H_ -#define STORM_FORMULA_STATEBOUNDOPERATOR_H_ +#ifndef STORM_FORMULA_ABSTRACT_STATEBOUNDOPERATOR_H_ +#define STORM_FORMULA_ABSTRACT_STATEBOUNDOPERATOR_H_ -#include "src/formula/AbstractStateFormula.h" -#include "src/formula/AbstractPathFormula.h" +#include "src/formula/abstract/AbstractFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" #include "src/modelchecker/AbstractModelChecker.h" #include "src/utility/ConstTemplates.h" namespace storm { namespace formula { - -template class StateBoundOperator; - -/*! - * @brief Interface class for model checkers that support StateBoundOperator. - * - * All model checkers that support the formula class StateBoundOperator must inherit - * this pure virtual class. - */ -template -class IStateBoundOperatorModelChecker { - public: - virtual storm::storage::BitVector* checkStateBoundOperator(const StateBoundOperator& obj) const = 0; -}; +namespace abstract { /*! * @brief @@ -46,14 +33,14 @@ class IStateBoundOperatorModelChecker { * (this behavior can be prevented by setting them to NULL before deletion) * * - * @see AbstractStateFormula - * @see AbstractPathFormula + * @see AbstractFormula + * @see AbstractFormula * @see ProbabilisticOperator * @see ProbabilisticNoBoundsOperator * @see AbstractFormula */ template -class StateBoundOperator : public AbstractStateFormula { +class StateBoundOperator : public AbstractFormula { public: enum ComparisonType { LESS, LESS_EQUAL, GREATER, GREATER_EQUAL }; @@ -65,7 +52,7 @@ public: * @param bound The bound for the probability * @param stateFormula The child node */ - StateBoundOperator(ComparisonType comparisonOperator, T bound, AbstractStateFormula* stateFormula) + StateBoundOperator(ComparisonType comparisonOperator, T bound, AbstractFormula* stateFormula) : comparisonOperator(comparisonOperator), bound(bound), stateFormula(stateFormula) { // Intentionally left empty } @@ -82,22 +69,6 @@ public: } } - /*! - * @returns the child node (representation of a Abstract state formula) - */ - const AbstractStateFormula& getStateFormula () const { - return *stateFormula; - } - - /*! - * Sets the child node - * - * @param stateFormula the state formula that becomes the new child node - */ - void setStateFormula(AbstractStateFormula* stateFormula) { - this->stateFormula = stateFormula; - } - /*! * @returns the comparison relation */ @@ -153,28 +124,6 @@ public: } } - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new AND-object that is identical the called object. - */ - virtual AbstractStateFormula* clone() const = 0; - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A bit vector indicating all states that satisfy the formula represented by the called object. - */ - virtual storm::storage::BitVector *check(const storm::modelchecker::AbstractModelChecker& modelChecker) const { - return modelChecker.template as()->checkStateBoundOperator(*this); - } - /*! * @brief Checks if the subtree conforms to some logic. * @@ -185,13 +134,31 @@ public: return checker.conforms(this->stateFormula); } +protected: + /*! + * @returns the child node (representation of a Abstract state formula) + */ + const AbstractFormula& getStateFormula () const { + return *stateFormula; + } + + /*! + * Sets the child node + * + * @param stateFormula the state formula that becomes the new child node + */ + void setStateFormula(AbstractFormula* stateFormula) { + this->stateFormula = stateFormula; + } + private: ComparisonType comparisonOperator; T bound; - AbstractStateFormula* stateFormula; + AbstractFormula* stateFormula; }; +} //namespace abstract } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_STATEBOUNDOPERATOR_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_STATEBOUNDOPERATOR_H_ */ diff --git a/src/formula/abstract/StateNoBoundOperator.h b/src/formula/abstract/StateNoBoundOperator.h index 23e6b816e..d2a4fe369 100644 --- a/src/formula/abstract/StateNoBoundOperator.h +++ b/src/formula/abstract/StateNoBoundOperator.h @@ -5,38 +5,17 @@ * Author: Thomas Heinemann */ -#ifndef STORM_FORMULA_STATENOBOUNDOPERATOR_H_ -#define STORM_FORMULA_STATENOBOUNDOPERATOR_H_ +#ifndef STORM_FORMULA_ABSTRACT_STATENOBOUNDOPERATOR_H_ +#define STORM_FORMULA_ABSTRACT_STATENOBOUNDOPERATOR_H_ -#include "src/formula/AbstractFormula.h" -#include "src/formula/AbstractPathFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" #include "src/modelchecker/ForwardDeclarations.h" namespace storm { namespace formula { - -template class StateNoBoundOperator; - -/*! - * @brief Interface class for model checkers that support PathNoBoundOperator. - * - * All model checkers that support the formula class NoBoundOperator must inherit - * this pure virtual class. - */ -template -class IStateNoBoundOperatorModelChecker { - public: - /*! - * @brief Evaluates NoBoundOperator formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual std::vector* checkStateNoBoundOperator(const StateNoBoundOperator& obj) const = 0; -}; - +namespace abstract { /*! * @brief @@ -62,8 +41,8 @@ class IStateNoBoundOperatorModelChecker { * (this behavior can be prevented by setting them to NULL before deletion) * * - * @see AbstractStateFormula - * @see AbstractPathFormula + * @see AbstractFormula + * @see AbstractFormula * @see SteadyStateNoBoundOperator * @see AbstractFormula */ @@ -80,7 +59,7 @@ public: /*! * Constructor */ - StateNoBoundOperator(AbstractStateFormula* stateFormula) { + StateNoBoundOperator(AbstractFormula* stateFormula) { this->stateFormula = stateFormula; } @@ -95,14 +74,6 @@ public: } } - const AbstractStateFormula& getStateFormula() const { - return *(this->stateFormula); - } - - void setStateFormula(AbstractStateFormula* stateFormula) { - this->stateFormula = stateFormula; - } - /*! * Calls the model checker to check this formula. * Needed to infer the correct type of formula class. @@ -139,10 +110,20 @@ public: return checker.conforms(this->stateFormula); } +protected: + const AbstractFormula& getStateFormula() const { + return *(this->stateFormula); + } + + void setStateFormula(AbstractFormula* stateFormula) { + this->stateFormula = stateFormula; + } + private: - AbstractStateFormula* stateFormula; + AbstractFormula* stateFormula; }; -} /* namespace formula */ -} /* namespace storm */ -#endif /* STORM_FORMULA_STATENOBOUNDOPERATOR_H_ */ +} //namespace abstract +} //namespace formula +} //namespace storm +#endif /* STORM_FORMULA_ABSTRACT_STATENOBOUNDOPERATOR_H_ */ diff --git a/src/formula/abstract/TimeBoundedOperator.h b/src/formula/abstract/TimeBoundedOperator.h index f0f443f97..9dea94ef0 100644 --- a/src/formula/abstract/TimeBoundedOperator.h +++ b/src/formula/abstract/TimeBoundedOperator.h @@ -5,16 +5,17 @@ * Author: thomas */ -#ifndef TIMEBOUNDEDOPERATOR_H_ -#define TIMEBOUNDEDOPERATOR_H_ +#ifndef STORM_FORMULA_ABSTRACT_TIMEBOUNDEDOPERATOR_H_ +#define STORM_FORMULA_ABSTRACT_TIMEBOUNDEDOPERATOR_H_ #include -#include "AbstractPathFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "exceptions/InvalidArgumentException.h" namespace storm { namespace formula { +namespace abstract { /*! * @brief @@ -24,12 +25,12 @@ namespace formula { * This class does not provide support for sub formulas; this has to be done in concretizations of this abstract class. * * - * @see AbstractStateFormula - * @see AbstractPathFormula + * @see AbstractFormula + * @see AbstractFormula * @see AbstractFormula */ template -class TimeBoundedOperator: public storm::formula::AbstractPathFormula { +class TimeBoundedOperator: public storm::formula::AbstractFormula { public: /** * Constructor @@ -104,6 +105,8 @@ private: T lowerBound, upperBound; }; -} /* namespace formula */ -} /* namespace storm */ -#endif /* TIMEBOUNDEDOPERATOR_H_ */ +} //namespace abstract +} //namespace formula +} //namespace storm + +#endif /* STORM_FORMULA_ABSTRACT_TIMEBOUNDEDOPERATOR_H_ */ diff --git a/src/formula/abstract/Until.h b/src/formula/abstract/Until.h index b2efe6f45..03b55c460 100644 --- a/src/formula/abstract/Until.h +++ b/src/formula/abstract/Until.h @@ -5,35 +5,16 @@ * Author: Thomas Heinemann */ -#ifndef STORM_FORMULA_UNTIL_H_ -#define STORM_FORMULA_UNTIL_H_ +#ifndef STORM_FORMULA_ABSTRACT_UNTIL_H_ +#define STORM_FORMULA_ABSTRACT_UNTIL_H_ -#include "AbstractPathFormula.h" -#include "AbstractStateFormula.h" +#include "src/formula/abstract/AbstractFormula.h" +#include "src/formula/abstract/AbstractFormula.h" #include "src/formula/AbstractFormulaChecker.h" namespace storm { namespace formula { - -template class Until; - -/*! - * @brief Interface class for model checkers that support Until. - * - * All model checkers that support the formula class Until must inherit - * this pure virtual class. - */ -template -class IUntilModelChecker { - public: - /*! - * @brief Evaluates Until formula within a model checker. - * - * @param obj Formula object with subformulas. - * @return Result of the formula for every node. - */ - virtual std::vector* checkUntil(const Until& obj, bool qualitative) const = 0; -}; +namespace abstract { /*! * @brief @@ -48,11 +29,11 @@ class IUntilModelChecker { * The subtrees are seen as part of the object and deleted with the object * (this behavior can be prevented by setting them to NULL before deletion) * - * @see AbstractPathFormula + * @see AbstractFormula * @see AbstractFormula */ template -class Until : public AbstractPathFormula { +class Until : public AbstractFormula { public: /*! @@ -69,7 +50,7 @@ public: * @param left The left formula subtree * @param right The left formula subtree */ - Until(AbstractStateFormula* left, AbstractStateFormula* right) { + Until(AbstractFormula* left, AbstractFormula* right) { this->left = left; this->right = right; } @@ -89,12 +70,33 @@ public: } } + /*! + * @returns a string representation of the formula + */ + virtual std::string toString() const { + std::string result = left->toString(); + result += " U "; + result += right->toString(); + return result; + } + + /*! + * @brief Checks if all subtrees conform to some logic. + * + * @param checker Formula checker object. + * @return true iff all subtrees conform to some logic. + */ + virtual bool conforms(const AbstractFormulaChecker& checker) const { + return checker.conforms(this->left) && checker.conforms(this->right); + } + +protected: /*! * Sets the left child node. * * @param newLeft the new left child. */ - void setLeft(AbstractStateFormula* newLeft) { + void setLeft(AbstractFormula* newLeft) { left = newLeft; } @@ -103,82 +105,33 @@ public: * * @param newRight the new right child. */ - void setRight(AbstractStateFormula* newRight) { + void setRight(AbstractFormula* newRight) { right = newRight; } /*! * @returns a pointer to the left child node */ - const AbstractStateFormula& getLeft() const { + const AbstractFormula& getLeft() const { return *left; } /*! * @returns a pointer to the right child node */ - const AbstractStateFormula& getRight() const { + const AbstractFormula& getRight() const { return *right; } - /*! - * @returns a string representation of the formula - */ - virtual std::string toString() const { - std::string result = left->toString(); - result += " U "; - result += right->toString(); - return result; - } - - /*! - * Clones the called object. - * - * Performs a "deep copy", i.e. the subtrees of the new object are clones of the original ones - * - * @returns a new BoundedUntil-object that is identical the called object. - */ - virtual AbstractPathFormula* clone() const { - Until* result = new Until(); - if (left != NULL) { - result->setLeft(left->clone()); - } - if (right != NULL) { - result->setRight(right->clone()); - } - return result; - } - - /*! - * Calls the model checker to check this formula. - * Needed to infer the correct type of formula class. - * - * @note This function should only be called in a generic check function of a model checker class. For other uses, - * the methods of the model checker should be used. - * - * @returns A vector indicating the probability that the formula holds for each state. - */ - virtual std::vector *check(const storm::modelchecker::AbstractModelChecker& modelChecker, bool qualitative) const { - return modelChecker.template as()->checkUntil(*this, qualitative); - } - - /*! - * @brief Checks if all subtrees conform to some logic. - * - * @param checker Formula checker object. - * @return true iff all subtrees conform to some logic. - */ - virtual bool conforms(const AbstractFormulaChecker& checker) const { - return checker.conforms(this->left) && checker.conforms(this->right); - } - private: - AbstractStateFormula* left; - AbstractStateFormula* right; + AbstractFormula* left; + AbstractFormula* right; }; +} //namespace abstract + } //namespace formula } //namespace storm -#endif /* STORM_FORMULA_UNTIL_H_ */ +#endif /* STORM_FORMULA_ABSTRACT_UNTIL_H_ */