Skip to content

Commit

Permalink
Check whether abduct option is enabled (#7418)
Browse files Browse the repository at this point in the history
This addresses one of the issues related to #6605.
  • Loading branch information
ajreynol committed Oct 20, 2021
1 parent 68fc65d commit 221f8b4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/api/cpp/cvc5.cpp
Expand Up @@ -7205,7 +7205,7 @@ std::string Solver::getProof(void) const
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_CHECK(d_slv->getOptions().smt.produceProofs)
<< "Cannot get proof explicitly enabled (try --produce-proofs)";
<< "Cannot get proof unless proofs are enabled (try --produce-proofs)";
CVC5_API_RECOVERABLE_CHECK(d_slv->getSmtMode() == SmtMode::UNSAT)
<< "Cannot get proof unless in unsat mode.";
return d_slv->getProof();
Expand Down Expand Up @@ -7456,6 +7456,8 @@ bool Solver::getAbduct(const Term& conj, Term& output) const
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_SOLVER_CHECK_TERM(conj);
CVC5_API_CHECK(d_slv->getOptions().smt.produceAbducts)
<< "Cannot get abduct unless abducts are enabled (try --produce-abducts)";
//////// all checks before this line
Node result;
bool success = d_slv->getAbduct(*conj.d_node, result);
Expand All @@ -7472,6 +7474,8 @@ bool Solver::getAbduct(const Term& conj, Grammar& grammar, Term& output) const
{
CVC5_API_TRY_CATCH_BEGIN;
CVC5_API_SOLVER_CHECK_TERM(conj);
CVC5_API_CHECK(d_slv->getOptions().smt.produceAbducts)
<< "Cannot get abduct unless abducts are enabled (try --produce-abducts)";
//////// all checks before this line
Node result;
bool success =
Expand Down
17 changes: 17 additions & 0 deletions test/unit/api/solver_black.cpp
Expand Up @@ -1225,6 +1225,23 @@ TEST_F(TestApiBlackSolver, getAbduct)
ASSERT_EQ(output2, truen);
}

TEST_F(TestApiBlackSolver, getAbduct2)
{
d_solver.setLogic("QF_LIA");
d_solver.setOption("incremental", "false");
Sort intSort = d_solver.getIntegerSort();
Term zero = d_solver.mkInteger(0);
Term x = d_solver.mkConst(intSort, "x");
Term y = d_solver.mkConst(intSort, "y");
// Assumptions for abduction: x > 0
d_solver.assertFormula(d_solver.mkTerm(GT, x, zero));
// Conjecture for abduction: y > 0
Term conj = d_solver.mkTerm(GT, y, zero);
Term output;
// Fails due to option not set
ASSERT_THROW(d_solver.getAbduct(conj, output), CVC5ApiException);
}

TEST_F(TestApiBlackSolver, getInterpolant)
{
d_solver.setLogic("QF_LIA");
Expand Down

0 comments on commit 221f8b4

Please sign in to comment.