* Support for `str.indexof_re(s, r, n)`, which returns the index of the first
occurrence of a regular expression `r` in a string `s` after index `n` or
-1 if `r` does not match a substring after `n`.
+* A new option to compute minimal unsat cores (`--minimal-unsat-cores`).
Improvements:
* New API: Added functions to retrieve the heap/nil term when using separation
name = "assumptions"
help = "Produce unsat cores using solving under assumptions and preprocessing proofs."
+[[option]]
+ name = "minimalUnsatCores"
+ category = "regular"
+ long = "minimal-unsat-cores"
+ type = "bool"
+ default = "false"
+ help = "if an unsat core is produced, it is reduced to a minimal unsat core"
+
[[option]]
name = "checkUnsatCores"
category = "regular"
opts.driver.dumpUnsatCores = true;
}
if (options::checkUnsatCores() || options::dumpUnsatCores()
- || options::unsatAssumptions()
+ || options::unsatAssumptions() || options::minimalUnsatCores()
|| options::unsatCoresMode() != options::UnsatCoresMode::OFF)
{
opts.smt.unsatCores = true;
std::shared_ptr<ProofNode> pfn = d_pfManager->getFinalProof(pepf, *d_asserts);
std::vector<Node> core;
d_ucManager->getUnsatCore(pfn, *d_asserts, core);
+ if (options::minimalUnsatCores())
+ {
+ core = reduceUnsatCore(core);
+ }
return UnsatCore(core);
}
+std::vector<Node> SmtEngine::reduceUnsatCore(const std::vector<Node>& core)
+{
+ Assert(options::unsatCores())
+ << "cannot reduce unsat core if unsat cores are turned off";
+
+ Notice() << "SmtEngine::reduceUnsatCore(): reducing unsat core" << endl;
+ std::unordered_set<Node> removed;
+ for (const Node& skip : core)
+ {
+ std::unique_ptr<SmtEngine> coreChecker;
+ initializeSubsolver(coreChecker);
+ coreChecker->setLogic(getLogicInfo());
+ coreChecker->getOptions().smt.checkUnsatCores = false;
+ // disable all proof options
+ coreChecker->getOptions().smt.produceProofs = false;
+ coreChecker->getOptions().smt.checkProofs = false;
+ coreChecker->getOptions().proof.proofEagerChecking = false;
+
+ for (const Node& ucAssertion : core)
+ {
+ if (ucAssertion != skip && removed.find(ucAssertion) == removed.end())
+ {
+ Node assertionAfterExpansion = expandDefinitions(ucAssertion);
+ coreChecker->assertFormula(assertionAfterExpansion);
+ }
+ }
+ Result r;
+ try
+ {
+ r = coreChecker->checkSat();
+ }
+ catch (...)
+ {
+ throw;
+ }
+
+ if (r.asSatisfiabilityResult().isSat() == Result::UNSAT)
+ {
+ removed.insert(skip);
+ }
+ else if (r.asSatisfiabilityResult().isUnknown())
+ {
+ Warning() << "SmtEngine::reduceUnsatCore(): could not reduce unsat core "
+ "due to "
+ "unknown result.";
+ }
+ }
+
+ if (removed.empty())
+ {
+ return core;
+ }
+ else
+ {
+ std::vector<Node> newUcAssertions;
+ for (const Node& n : core)
+ {
+ if (removed.find(n) == removed.end())
+ {
+ newUcAssertions.push_back(n);
+ }
+ }
+
+ return newUcAssertions;
+ }
+}
+
void SmtEngine::checkUnsatCore() {
Assert(d_env->getOptions().smt.unsatCores)
<< "cannot check unsat core if unsat cores are turned off";
/******************************************************************************
* Top contributors (to current version):
- * Andrew Reynolds, Morgan Deters, Aina Niemetz
+
*
* This file is part of the cvc5 project.
*
*/
Result assertFormula(const Node& formula, bool inUnsatCore = true);
+ /**
+ * Reduce an unsatisfiable core to make it minimal.
+ */
+ std::vector<Node> reduceUnsatCore(const std::vector<Node>& core);
+
/**
* Check if a given (set of) expression(s) is entailed with respect to the
* current set of assertions. We check this by asserting the negation of
regress1/issue5739-rtf-processed.smt2
regress1/lemmas/clocksynchro_5clocks.main_invar.base.smtv1.smt2
regress1/lemmas/pursuit-safety-8.smtv1.smt2
+ regress1/minimal_unsat_core.smt2
regress1/model-blocker-simple.smt2
regress1/model-blocker-values.smt2
regress1/nl/approx-sqrt.smt2
--- /dev/null
+; COMMAND-LINE: --minimal-unsat-cores
+(set-logic QF_NIA)
+(set-info :status unsat)
+(declare-fun n () Int)
+
+(assert (= n 0))
+(assert (= (div (div n n) n)
+ (div (div (div n n) n) n)))
+(assert (distinct (div (div n n) n)
+ (div (div (div (div (div n n) n) n) n) n)))
+
+(check-sat)