std::string Solver::getInstantiations() const
{
CVC5_API_TRY_CATCH_BEGIN;
+ CVC5_API_RECOVERABLE_CHECK(d_slv->getSmtMode() == internal::SmtMode::UNSAT
+ || d_slv->getSmtMode() == internal::SmtMode::SAT
+ || d_slv->getSmtMode()
+ == internal::SmtMode::SAT_UNKNOWN)
+ << "Cannot get instantiations unless after a UNSAT, SAT or UNKNOWN "
+ "response.";
//////// all checks before this line
std::stringstream ss;
d_slv->printInstantiations(ss);
ASSERT_NO_THROW(d_solver.blockModelValues({x}));
}
+TEST_F(TestApiBlackSolver, getInstantiations)
+{
+ Sort iSort = d_solver.getIntegerSort();
+ Sort boolSort = d_solver.getBooleanSort();
+ Term p = d_solver.declareFun("p", {iSort}, boolSort);
+ Term x = d_solver.mkVar(iSort, "x");
+ Term bvl = d_solver.mkTerm(VARIABLE_LIST, {x});
+ Term app = d_solver.mkTerm(APPLY_UF, {p, x});
+ Term q = d_solver.mkTerm(FORALL, {bvl, app});
+ d_solver.assertFormula(q);
+ Term five = d_solver.mkInteger(5);
+ Term app2 = d_solver.mkTerm(NOT, {d_solver.mkTerm(APPLY_UF, {p, five})});
+ d_solver.assertFormula(app2);
+ ASSERT_THROW(d_solver.getInstantiations(), CVC5ApiException);
+ d_solver.checkSat();
+ ASSERT_NO_THROW(d_solver.getInstantiations());
+}
+
TEST_F(TestApiBlackSolver, setInfo)
{
ASSERT_THROW(d_solver.setInfo("cvc5-lagic", "QF_BV"), CVC5ApiException);
assertDoesNotThrow(() -> d_solver.blockModelValues(new Term[] {x}));
}
+ @Test
+ void getInstantiations() throws CVC5ApiException
+ {
+ Sort iSort = d_solver.getIntegerSort();
+ Sort boolSort = d_solver.getBooleanSort();
+ Term p = d_solver.declareFun("p", new Sort[] {iSort}, boolSort);
+ Term x = d_solver.mkVar(iSort, "x");
+ Term bvl = d_solver.mkTerm(VARIABLE_LIST, new Term[] {x});
+ Term app = d_solver.mkTerm(APPLY_UF, new Term[] {p, x});
+ Term q = d_solver.mkTerm(FORALL, new Term[] {bvl, app});
+ d_solver.assertFormula(q);
+ Term five = d_solver.mkInteger(5);
+ Term app2 = d_solver.mkTerm(NOT, new Term[] {d_solver.mkTerm(APPLY_UF, new Term[] {p, five})});
+ d_solver.assertFormula(app2);
+ assertThrows(CVC5ApiException.class, () -> d_solver.getInstantiations());
+ d_solver.checkSat();
+ assertDoesNotThrow(() -> d_solver.getInstantiations());
+ }
+
@Test
void setInfo() throws CVC5ApiException
{
solver.checkSat()
solver.blockModelValues([x])
+def getInstantiations():
+ iSort = solver.getIntegerSort()
+ boolSort = solver.getBooleanSort()
+ p = solver.declareFun("p", [iSort], boolSort)
+ x = solver.mkVar(iSort, "x")
+ bvl = solver.mkTerm(Kind.VARIABLE_LIST, [x])
+ app = solver.mkTerm(Kind.APPLY_UF, [p, x])
+ q = solver.mkTerm(Kind.FORALL, [bvl, app]);
+ solver.assertFormula(q)
+ five = solver.mkInteger(5)
+ app2 = solver.mkTerm(Kind.NOT, [solver.mkTerm(Kind.APPLY_UF, [p, five])])
+ solver.assertFormula(app2)
+ with pytest.raises(RuntimeError):
+ solver.getInstantiations()
+ solver.checkSat()
+ solver.getInstantiations()
+
def test_get_statistics(solver):
intSort = solver.getIntegerSort()
x = solver.mkConst(intSort, "x")