*
* Requires to enable option
* :ref:`produce-unsat-cores <lbl-option-produce-unsat-cores>`.
+ *
+ * .. note::
+ * In contrast to SMT-LIB, the API does not distinguish between named and
+ * unnamed assertions when producing an unsatisfiable core. Additionally,
+ * the API allows this option to be called after a check with assumptions.
+ * A subset of those assumptions may be included in the unsatisfiable core
+ * returned by this method.
* \endverbatim
*
* @return a set of terms representing the unsatisfiable core
* Get the unsatisfiable core.
* SMT-LIB:
* {@code
- * ( get-unsat-core )
+ * (get-unsat-core)
* }
* Requires to enable option 'produce-unsat-cores'.
+ * @apiNote In contrast to SMT-LIB, the API does not distinguish between
+ * named and unnamed assertions when producing an unsatisfiable
+ * core. Additionally, the API allows this option to be called after
+ * a check with assumptions. A subset of those assumptions may be
+ * included in the unsatisfiable core returned by this method.
* @return a set of terms representing the unsatisfiable core
*/
public Term[] getUnsatCore()
.. code-block:: smtlib
- ( get-unsat-core )
+ (get-unsat-core)
Requires to enable option :ref:`produce-unsat-cores <lbl-option-produce-unsat-cores>`.
+ .. note::
+ In contrast to SMT-LIB, the API does not distinguish between named and
+ unnamed assertions when producing an unsatisfiable core. Additionally,
+ the API allows this option to be called after a check with assumptions.
+ A subset of those assumptions may be included in the unsatisfiable core
+ returned by this method.
+
:return: a set of terms representing the unsatisfiable core
"""
core = []
Sort boolSort = d_solver.getBooleanSort();
Sort uToIntSort = d_solver.mkFunctionSort(uSort, intSort);
Sort intPredSort = d_solver.mkFunctionSort(intSort, boolSort);
- std::vector<Term> unsat_core;
+ std::vector<Term> uc;
Term x = d_solver.mkConst(uSort, "x");
Term y = d_solver.mkConst(uSort, "y");
d_solver.assertFormula(p_f_y.notTerm());
ASSERT_TRUE(d_solver.checkSat().isUnsat());
- ASSERT_NO_THROW(unsat_core = d_solver.getUnsatCore());
+ ASSERT_NO_THROW(uc = d_solver.getUnsatCore());
+ ASSERT_FALSE(uc.empty());
ASSERT_NO_THROW(d_solver.getProof());
d_solver.resetAssertions();
- for (const auto& t : unsat_core)
+ for (const auto& t : uc)
{
d_solver.assertFormula(t);
}
ASSERT_NO_FATAL_FAILURE(distinct.getOp());
}
+TEST_F(TestApiBlackSolver, proj_issue308)
+{
+ Solver slv;
+ slv.setOption("check-proofs", "true");
+ Sort s1 = slv.getBooleanSort();
+ Term t1 = slv.mkConst(s1, "_x0");
+ Term t2 = slv.mkTerm(Kind::XOR, t1, t1);
+ slv.checkSatAssuming({t2});
+ auto unsat_core = slv.getUnsatCore();
+ ASSERT_FALSE(unsat_core.empty());
+}
+
TEST_F(TestApiBlackSolver, proj_issue373)
{
Sort s1 = d_solver.getRealSort();