Browse Source

Added test for interpolation to MathSat tests.

Former-commit-id: ac94857726
tempestpy_adaptions
dehnert 10 years ago
parent
commit
7ff3dcecfb
  1. 8
      src/solver/MathSatSmtSolver.cpp
  2. 1
      src/solver/MathSatSmtSolver.h
  3. 36
      test/functional/solver/MathSatSmtSolverTest.cpp
  4. 1
      test/functional/solver/Z3SmtSolverTest.cpp

8
src/solver/MathSatSmtSolver.cpp

@ -14,7 +14,7 @@ namespace storm {
#endif
{
#ifdef STORM_HAVE_MSAT
m_cfg = msat_create_config();
msat_config m_cfg = msat_create_config();
if (static_cast<int>(options)& static_cast<int>(Options::InterpolantComputation)) {
msat_set_option(m_cfg, "interpolation", "true");
@ -23,13 +23,15 @@ namespace storm {
msat_set_option(m_cfg, "model_generation", "true");
m_env = msat_create_env(m_cfg);
STORM_LOG_THROW(!MSAT_ERROR_ENV(m_env), storm::exceptions::UnexpectedException, "Unable to create Mathsat environment.");
msat_destroy_config(m_cfg);
m_adapter = new storm::adapters::MathSatExpressionAdapter(m_env, variableToDeclMap);
#endif
}
MathSatSmtSolver::~MathSatSmtSolver() {
msat_destroy_env(m_env);
msat_destroy_config(m_cfg);
};
void MathSatSmtSolver::push()
@ -356,6 +358,8 @@ namespace storm {
}
msat_term interpolant = msat_get_interpolant(m_env, msatInterpolationGroupsA.data(), msatInterpolationGroupsA.size());
STORM_LOG_THROW(!MSAT_ERROR_TERM(interpolant), storm::exceptions::UnexpectedException, "Unable to retrieve an interpolant.");
return this->m_adapter->translateTerm(interpolant);
#else
STORM_LOG_THROW(false, storm::exceptions::NotImplementedException, "StoRM is compiled without MathSat support.");

1
src/solver/MathSatSmtSolver.h

@ -72,7 +72,6 @@ namespace storm {
private:
#ifdef STORM_HAVE_MSAT
msat_config m_cfg;
msat_env m_env;
storm::adapters::MathSatExpressionAdapter *m_adapter;

36
test/functional/solver/MathSatSmtSolverTest.cpp

@ -220,4 +220,40 @@ TEST(MathSatSmtSolver, UnsatAssumptions) {
ASSERT_STREQ("f2", unsatCore[0].getIdentifier().c_str());
}
TEST(MathSatSmtSolver, InterpolationTest) {
storm::solver::MathSatSmtSolver s(storm::solver::SmtSolver::Options::InterpolantComputation);
storm::solver::SmtSolver::CheckResult result = storm::solver::SmtSolver::CheckResult::UNKNOWN;
storm::expressions::Expression a = storm::expressions::Expression::createIntegerVariable("a");
storm::expressions::Expression b = storm::expressions::Expression::createIntegerVariable("b");
storm::expressions::Expression c = storm::expressions::Expression::createIntegerVariable("c");
storm::expressions::Expression exprFormula = a > b;
storm::expressions::Expression exprFormula2 = b > c;
storm::expressions::Expression exprFormula3 = c > a;
s.setInterpolationGroup(0);
s.assertExpression(exprFormula);
s.setInterpolationGroup(1);
s.assertExpression(exprFormula2);
s.setInterpolationGroup(2);
s.assertExpression(exprFormula3);
ASSERT_NO_THROW(result = s.check());
ASSERT_TRUE(result == storm::solver::SmtSolver::CheckResult::UNSAT);
storm::expressions::Expression interpol;
ASSERT_NO_THROW(interpol = s.getInterpolant({0, 1}));
storm::solver::MathSatSmtSolver s2;
ASSERT_NO_THROW(s2.assertExpression(!(exprFormula && exprFormula2).implies(interpol)));
ASSERT_NO_THROW(result = s2.check());
ASSERT_TRUE(result == storm::solver::SmtSolver::CheckResult::UNSAT);
ASSERT_NO_THROW(s2.reset());
ASSERT_NO_THROW(s2.assertExpression(interpol && exprFormula3));
ASSERT_NO_THROW(result = s2.check());
ASSERT_TRUE(result == storm::solver::SmtSolver::CheckResult::UNSAT);
}
#endif

1
test/functional/solver/Z3SmtSolverTest.cpp

@ -223,4 +223,5 @@ TEST(Z3SmtSolver, UnsatAssumptions) {
ASSERT_TRUE(unsatCore[0].isVariable());
ASSERT_STREQ("f2", unsatCore[0].getIdentifier().c_str());
}
#endif
Loading…
Cancel
Save