Browse Source

implemented formula checker

tempestpy_adaptions
gereon 12 years ago
parent
commit
8449c5ee11
  1. 3
      src/formula/AbstractFormula.h
  2. 18
      src/formula/AbstractFormulaChecker.h
  3. 7
      src/formula/Ap.h
  4. 9
      src/formula/BoundedUntil.h
  5. 4
      src/formula/Eventually.h
  6. 5
      src/formula/NoBoundOperator.h
  7. 5
      src/formula/Not.h
  8. 35
      src/formula/PrctlFormulaChecker.h
  9. 5
      src/formula/ReachabilityReward.h
  10. 5
      src/formula/Until.h

3
src/formula/AbstractFormula.h

@ -15,6 +15,7 @@ template <class T> class AbstractFormula;
}}
#include "src/modelChecker/AbstractModelChecker.h"
#include "src/formula/AbstractFormulaChecker.h"
namespace storm {
namespace formula {
@ -44,6 +45,8 @@ public:
* @returns a string representation of the formula
*/
virtual std::string toString() const = 0;
virtual bool conforms(const AbstractFormulaChecker<T>& checker) const = 0;
};
} //namespace formula

18
src/formula/AbstractFormulaChecker.h

@ -0,0 +1,18 @@
#ifndef STORM_FORMULA_ABSTRACTFORMULACHECKER_H_
#define STORM_FORMULA_ABSTRACTFORMULACHECKER_H_
#include "src/formula/AbstractFormula.h"
namespace storm {
namespace formula {
template <class T>
class AbstractFormulaChecker {
public:
virtual bool conforms(const AbstractFormula<T>* formula) const = 0;
};
}
}
#endif

7
src/formula/Ap.h

@ -8,7 +8,8 @@
#ifndef STORM_FORMULA_AP_H_
#define STORM_FORMULA_AP_H_
#include "AbstractStateFormula.h"
#include "src/formula/AbstractStateFormula.h"
#include "src/formula/AbstractFormulaChecker.h"
#include "src/modelChecker/AbstractModelChecker.h"
namespace storm {
@ -89,6 +90,10 @@ public:
virtual storm::storage::BitVector *check(const storm::modelChecker::AbstractModelChecker<T>& modelChecker) const {
return modelChecker.template as<IApModelChecker>()->checkAp(*this);
}
virtual bool conforms(const AbstractFormulaChecker<T>& checker) const {
return true;
}
private:
std::string ap;

9
src/formula/BoundedUntil.h

@ -8,11 +8,12 @@
#ifndef STORM_FORMULA_BOUNDEDUNTIL_H_
#define STORM_FORMULA_BOUNDEDUNTIL_H_
#include "AbstractPathFormula.h"
#include "AbstractStateFormula.h"
#include "src/formula/AbstractPathFormula.h"
#include "src/formula/AbstractStateFormula.h"
#include "src/modelChecker/AbstractModelChecker.h"
#include "boost/integer/integer_mask.hpp"
#include <string>
#include "src/formula/AbstractFormulaChecker.h"
namespace storm {
@ -178,6 +179,10 @@ public:
virtual std::vector<T> *check(const storm::modelChecker::AbstractModelChecker<T>& modelChecker) const {
return modelChecker.template as<IBoundedUntilModelChecker>()->checkBoundedUntil(*this);
}
virtual bool conforms(const AbstractFormulaChecker<T>& checker) const {
return checker.conforms(this->left) && checker.conforms(this->right);
}
private:
AbstractStateFormula<T>* left;

4
src/formula/Eventually.h

@ -122,6 +122,10 @@ public:
virtual std::vector<T> *check(const storm::modelChecker::AbstractModelChecker<T>& modelChecker) const {
return modelChecker.template as<IEventuallyModelChecker>()->checkEventually(*this);
}
virtual bool conforms(const AbstractFormulaChecker<T>& checker) const {
return checker.conforms(this->child);
}
private:
AbstractStateFormula<T>* child;

5
src/formula/NoBoundOperator.h

@ -10,6 +10,7 @@
#include "AbstractFormula.h"
#include "AbstractPathFormula.h"
#include "src/formula/AbstractFormulaChecker.h"
namespace storm {
@ -116,6 +117,10 @@ public:
* @returns a string representation of the formula
*/
virtual std::string toString() const = 0;
virtual bool conforms(const AbstractFormulaChecker<T>& checker) const {
return checker.conforms(this->pathFormula);
}
private:
AbstractPathFormula<T>* pathFormula;

5
src/formula/Not.h

@ -9,6 +9,7 @@
#define STORM_FORMULA_NOT_H_
#include "AbstractStateFormula.h"
#include "src/formula/AbstractFormulaChecker.h"
#include "src/modelChecker/AbstractModelChecker.h"
namespace storm {
@ -117,6 +118,10 @@ public:
virtual storm::storage::BitVector *check(const storm::modelChecker::AbstractModelChecker<T>& modelChecker) const {
return modelChecker.template as<INotModelChecker>()->checkNot(*this);
}
virtual bool conforms(const AbstractFormulaChecker<T>& checker) const {
return checker.conforms(this->child);
}
private:
AbstractStateFormula<T>* child;

35
src/formula/PrctlFormulaChecker.h

@ -0,0 +1,35 @@
#ifndef STORM_FORMULA_PRCTLFORMULACHECKER_H_
#define STORM_FORMULA_PRCTLFORMULACHECKER_H_
#include "src/formula/AbstractFormulaChecker.h"
#include "src/formula/Formulas.h"
#include <iostream>
namespace storm {
namespace formula {
template <class T>
class PrctlFormulaChecker : public AbstractFormulaChecker<T> {
public:
virtual bool conforms(const AbstractFormula<T>* formula) const {
if (
dynamic_cast<const And<T>*>(formula) ||
dynamic_cast<const Ap<T>*>(formula) ||
dynamic_cast<const Eventually<T>*>(formula) ||
dynamic_cast<const Not<T>*>(formula) ||
dynamic_cast<const Or<T>*>(formula) ||
dynamic_cast<const ProbabilisticNoBoundOperator<T>*>(formula)
) {
return formula->conforms(*this);
}
return false;
}
private:
};
}
}
#endif

5
src/formula/ReachabilityReward.h

@ -10,6 +10,7 @@
#include "src/formula/AbstractPathFormula.h"
#include "src/formula/AbstractStateFormula.h"
#include "src/formula/AbstractFormulaChecker.h"
#include "src/modelChecker/AbstractModelChecker.h"
namespace storm {
@ -119,6 +120,10 @@ public:
virtual std::vector<T> *check(const storm::modelChecker::AbstractModelChecker<T>& modelChecker) const {
return modelChecker.template as<IReachabilityRewardModelChecker>()->checkReachabilityReward(*this);
}
virtual bool conforms(const AbstractFormulaChecker<T>& checker) const {
return checker.conforms(this->child);
}
private:
AbstractStateFormula<T>* child;

5
src/formula/Until.h

@ -10,6 +10,7 @@
#include "AbstractPathFormula.h"
#include "AbstractStateFormula.h"
#include "src/formula/AbstractFormulaChecker.h"
namespace storm {
@ -151,6 +152,10 @@ public:
virtual std::vector<T> *check(const storm::modelChecker::AbstractModelChecker<T>& modelChecker) const {
return modelChecker.template as<IUntilModelChecker>()->checkUntil(*this);
}
virtual bool conforms(const AbstractFormulaChecker<T>& checker) const {
return checker.conforms(this->left) && checker.conforms(this->right);
}
private:
AbstractStateFormula<T>* left;

Loading…
Cancel
Save