summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorAndrew Reynolds <andrew.j.reynolds@gmail.com>2021-04-20 22:02:31 -0500
committerGitHub <noreply@github.com>2021-04-21 03:02:31 +0000
commit4e9cef3063ca0155d4d97714d288ab7d88df5c30 (patch)
treee844fc638a19b85afa2b43da6ebf14eb85d18b8e /test
parentfafde0249bec12df91370119f35fc020ec81c935 (diff)
Add unit test for abduction (#6400)
Diffstat (limited to 'test')
-rw-r--r--test/unit/api/solver_black.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/test/unit/api/solver_black.cpp b/test/unit/api/solver_black.cpp
index db950dd7e..5240d8020 100644
--- a/test/unit/api/solver_black.cpp
+++ b/test/unit/api/solver_black.cpp
@@ -1270,6 +1270,41 @@ TEST_F(TestApiBlackSolver, getInfo)
ASSERT_THROW(d_solver.getInfo("asdf"), CVC5ApiException);
}
+TEST_F(TestApiBlackSolver, getAbduct)
+{
+ d_solver.setLogic("QF_LIA");
+ d_solver.setOption("produce-abducts", "true");
+ 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;
+ // Call the abduction api, while the resulting abduct is the output
+ ASSERT_TRUE(d_solver.getAbduct(conj, output));
+ // We expect the resulting output to be a boolean formula
+ ASSERT_TRUE(!output.isNull() && output.getSort().isBoolean());
+
+ // try with a grammar, a simple grammar admitting true
+ Sort boolean = d_solver.getBooleanSort();
+ Term truen = d_solver.mkBoolean(true);
+ Term start = d_solver.mkVar(boolean);
+ Term output2;
+ Grammar g = d_solver.mkSygusGrammar({}, {start});
+ Term conj2 = d_solver.mkTerm(GT, x, zero);
+ ASSERT_NO_THROW(g.addRule(start, truen));
+ // Call the abduction api, while the resulting abduct is the output
+ ASSERT_TRUE(d_solver.getAbduct(conj2, g, output2));
+ // abduct must be true
+ ASSERT_EQ(output2, truen);
+}
+
TEST_F(TestApiBlackSolver, getInterpolant)
{
d_solver.setLogic("QF_LIA");
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback