Browse Source

implemented SMT-Lib export SmtSolver interface

tempestpy_adaptions
TimQu 7 years ago
parent
commit
b44870dc09
  1. 5
      src/storm/solver/SmtSolver.cpp
  2. 18
      src/storm/solver/SmtSolver.h
  3. 9
      src/storm/solver/Z3SmtSolver.cpp
  4. 2
      src/storm/solver/Z3SmtSolver.h

5
src/storm/solver/SmtSolver.cpp

@ -91,6 +91,11 @@ namespace storm {
bool SmtSolver::unsetTimeout() { bool SmtSolver::unsetTimeout() {
return false; return false;
} }
std::string SmtSolver::getSmtLibString() const {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "This solver does not support exporting the assertions in the SMT-LIB format.");
return "ERROR";
}
} // namespace solver } // namespace solver
} // namespace storm } // namespace storm

18
src/storm/solver/SmtSolver.h

@ -71,15 +71,10 @@ namespace storm {
SmtSolver(SmtSolver const& other) = default; SmtSolver(SmtSolver const& other) = default;
#ifndef WINDOWS
SmtSolver(SmtSolver&& other) = default; SmtSolver(SmtSolver&& other) = default;
#endif
SmtSolver& operator=(SmtSolver const& other) = default; SmtSolver& operator=(SmtSolver const& other) = default;
#ifndef WINDOWS
SmtSolver& operator=(SmtSolver&& other) = default; SmtSolver& operator=(SmtSolver&& other) = default;
#endif
/*! /*!
* Pushes a backtracking point on the solver's stack. A following call to pop() deletes exactly those * Pushes a backtracking point on the solver's stack. A following call to pop() deletes exactly those
* assertions from the solver's stack that were added after this call. * assertions from the solver's stack that were added after this call.
@ -153,10 +148,8 @@ namespace storm {
* @return Sat if the conjunction of the asserted expressions together with the provided assumptions is * @return Sat if the conjunction of the asserted expressions together with the provided assumptions is
* satisfiable, Unsat if it is unsatisfiable and Unknown if the solver could not determine satisfiability. * satisfiable, Unsat if it is unsatisfiable and Unknown if the solver could not determine satisfiability.
*/ */
#ifndef WINDOWS
virtual CheckResult checkWithAssumptions(std::initializer_list<storm::expressions::Expression> const& assumptions) = 0; virtual CheckResult checkWithAssumptions(std::initializer_list<storm::expressions::Expression> const& assumptions) = 0;
#endif
/*! /*!
* If the last call to check() or checkWithAssumptions() returned Sat, this method retrieves a model that * If the last call to check() or checkWithAssumptions() returned Sat, this method retrieves a model that
* satisfies all assertions on the solver's stack (as well as provided assumptions), provided that the * satisfies all assertions on the solver's stack (as well as provided assumptions), provided that the
@ -292,6 +285,13 @@ namespace storm {
*/ */
virtual bool unsetTimeout(); virtual bool unsetTimeout();
/*!
* If supported by the solver, this function returns the current assertions in the SMT-LIB format.
*
* @return the current assertions in the SMT-LIB format.
*/
virtual std::string getSmtLibString() const;
private: private:
// The manager responsible for the expressions that interact with this solver. // The manager responsible for the expressions that interact with this solver.
storm::expressions::ExpressionManager& manager; storm::expressions::ExpressionManager& manager;

9
src/storm/solver/Z3SmtSolver.cpp

@ -360,6 +360,15 @@ namespace storm {
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Storm is compiled without Z3 support."); STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Storm is compiled without Z3 support.");
#endif #endif
} }
std::string Z3SmtSolver::getSmtLibString() const {
#ifdef STORM_HAVE_Z3
return solver->to_smt2();
#else
STORM_LOG_THROW(false, storm::exceptions::NotSupportedException, "Storm is compiled without Z3 support.");
#endif
}
} }
} }

2
src/storm/solver/Z3SmtSolver.h

@ -70,6 +70,8 @@ namespace storm {
virtual bool setTimeout(uint_fast64_t milliseconds) override; virtual bool setTimeout(uint_fast64_t milliseconds) override;
virtual bool unsetTimeout() override; virtual bool unsetTimeout() override;
virtual std::string getSmtLibString() const override;
private: private:
#ifdef STORM_HAVE_Z3 #ifdef STORM_HAVE_Z3

Loading…
Cancel
Save