You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
173 lines
4.1 KiB
173 lines
4.1 KiB
/*
|
|
* Not.h
|
|
*
|
|
* Created on: 19.10.2012
|
|
* Author: Thomas Heinemann
|
|
*/
|
|
|
|
#ifndef STORM_FORMULA_PRCTL_NOT_H_
|
|
#define STORM_FORMULA_PRCTL_NOT_H_
|
|
|
|
#include "AbstractStateFormula.h"
|
|
#include "src/modelchecker/prctl/ForwardDeclarations.h"
|
|
|
|
namespace storm {
|
|
namespace properties {
|
|
namespace prctl {
|
|
|
|
// Forward declaration for the interface class.
|
|
template <class T> class Not;
|
|
|
|
/*!
|
|
* 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 T>
|
|
class INotModelChecker {
|
|
public:
|
|
|
|
/*!
|
|
* Empty virtual destructor.
|
|
*/
|
|
virtual ~INotModelChecker() {
|
|
// Intentionally left empty
|
|
}
|
|
|
|
/*!
|
|
* Evaluates Not formulas 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<T>& obj) const = 0;
|
|
};
|
|
|
|
/*!
|
|
* Class for an Prctl formula tree with Not node as root.
|
|
*
|
|
* Has one state formula as sub formula/tree.
|
|
*
|
|
* The object has shared ownership of its subtree. If this object is deleted and no other object has a shared
|
|
* ownership of the subtree it will be deleted as well.
|
|
*
|
|
* @see AbstractStateFormula
|
|
* @see AbstractPrctlFormula
|
|
*/
|
|
template <class T>
|
|
class Not : public AbstractStateFormula<T> {
|
|
|
|
public:
|
|
|
|
/*!
|
|
* Creates a Not node without a subnode.
|
|
* The resulting object will not represent a complete formula!
|
|
*/
|
|
Not() : child(nullptr) {
|
|
// Intentionally left empty.
|
|
}
|
|
|
|
/*!
|
|
* Creates a Not node using the given parameter.
|
|
*
|
|
* @param child The child formula subtree.
|
|
*/
|
|
Not(std::shared_ptr<AbstractStateFormula<T>> child) : child(child) {
|
|
// Intentionally left empty.
|
|
}
|
|
|
|
/*!
|
|
* Empty virtual destructor.
|
|
*/
|
|
virtual ~Not() {
|
|
// Intentionally left empty.
|
|
}
|
|
|
|
/*!
|
|
* Clones the called object.
|
|
*
|
|
* Performs a "deep copy", i.e. the subnodes of the new object are clones of the original ones.
|
|
*
|
|
* @returns A new Not object that is a deep copy of the called object.
|
|
*/
|
|
virtual std::shared_ptr<AbstractStateFormula<T>> clone() const override {
|
|
std::shared_ptr<Not<T>> result(new Not<T>());
|
|
if (this->isChildSet()) {
|
|
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(storm::modelchecker::prctl::AbstractModelChecker<T> const & modelChecker) const override {
|
|
return modelChecker.template as<INotModelChecker>()->checkNot(*this);
|
|
}
|
|
|
|
/*!
|
|
* Returns a textual representation of the formula tree with this node as root.
|
|
*
|
|
* @returns A string representing the formula tree.
|
|
*/
|
|
virtual std::string toString() const override {
|
|
std::string result = "!";
|
|
result += child->toString();
|
|
return result;
|
|
}
|
|
|
|
/*!
|
|
* Returns whether the formula is a propositional logic formula.
|
|
* That is, this formula and all its subformulas consist only of And, Or, Not and AP.
|
|
*
|
|
* @return True iff this is a propositional logic formula.
|
|
*/
|
|
virtual bool isPropositional() const override {
|
|
return child->isPropositional();
|
|
}
|
|
|
|
/*!
|
|
* Gets the child node.
|
|
*
|
|
* @returns The child node.
|
|
*/
|
|
std::shared_ptr<AbstractStateFormula<T>> const & getChild() const {
|
|
return child;
|
|
}
|
|
|
|
/*!
|
|
* Sets the subtree.
|
|
*
|
|
* @param child The new child.
|
|
*/
|
|
void setChild(std::shared_ptr<AbstractStateFormula<T>> const & child) {
|
|
this->child = child;
|
|
}
|
|
|
|
/*!
|
|
* Checks if the child is set, i.e. it does not point to null.
|
|
*
|
|
* @return True iff the child is set.
|
|
*/
|
|
bool isChildSet() const {
|
|
return child.get() != nullptr;
|
|
}
|
|
|
|
private:
|
|
|
|
// The child node.
|
|
std::shared_ptr<AbstractStateFormula<T>> child;
|
|
};
|
|
|
|
} //namespace prctl
|
|
} //namespace properties
|
|
} //namespace storm
|
|
|
|
#endif /* STORM_FORMULA_PRCTL_NOT_H_ */
|