summaryrefslogtreecommitdiff
path: root/src/theory/arith/nl/cad/cdcac.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/theory/arith/nl/cad/cdcac.cpp')
-rw-r--r--src/theory/arith/nl/cad/cdcac.cpp75
1 files changed, 71 insertions, 4 deletions
diff --git a/src/theory/arith/nl/cad/cdcac.cpp b/src/theory/arith/nl/cad/cdcac.cpp
index d076438f5..df3ba37f3 100644
--- a/src/theory/arith/nl/cad/cdcac.cpp
+++ b/src/theory/arith/nl/cad/cdcac.cpp
@@ -39,11 +39,15 @@ namespace arith {
namespace nl {
namespace cad {
-CDCAC::CDCAC() {}
-
-CDCAC::CDCAC(const std::vector<poly::Variable>& ordering)
+CDCAC::CDCAC(context::Context* ctx,
+ ProofNodeManager* pnm,
+ const std::vector<poly::Variable>& ordering)
: d_variableOrdering(ordering)
{
+ if (pnm != nullptr)
+ {
+ d_proof.reset(new CADProofGenerator(ctx, pnm));
+ }
}
void CDCAC::reset()
@@ -120,6 +124,17 @@ std::vector<CACInterval> CDCAC::getUnsatIntervals(std::size_t cur_variable)
if (!is_minus_infinity(get_lower(i))) l = m;
if (!is_plus_infinity(get_upper(i))) u = m;
res.emplace_back(CACInterval{i, l, u, m, d, {n}});
+ if (isProofEnabled())
+ {
+ d_proof->addDirect(
+ d_constraints.varMapper()(d_variableOrdering[cur_variable]),
+ d_constraints.varMapper(),
+ p,
+ d_assignment,
+ sc,
+ i,
+ n);
+ }
}
}
pruneRedundantIntervals(res);
@@ -335,6 +350,10 @@ CACInterval CDCAC::intervalFromCharacterization(
std::vector<CACInterval> CDCAC::getUnsatCover(std::size_t curVariable,
bool returnFirstInterval)
{
+ if (isProofEnabled())
+ {
+ d_proof->startRecursive();
+ }
Trace("cdcac") << "Looking for unsat cover for "
<< d_variableOrdering[curVariable] << std::endl;
std::vector<CACInterval> intervals = getUnsatIntervals(curVariable);
@@ -373,6 +392,10 @@ std::vector<CACInterval> CDCAC::getUnsatCover(std::size_t curVariable,
Trace("cdcac") << "Found full assignment: " << d_assignment << std::endl;
return {};
}
+ if (isProofEnabled())
+ {
+ d_proof->startScope();
+ }
// Recurse to next variable
auto cov = getUnsatCover(curVariable + 1);
if (cov.empty())
@@ -391,6 +414,16 @@ std::vector<CACInterval> CDCAC::getUnsatCover(std::size_t curVariable,
intervalFromCharacterization(characterization, curVariable, sample);
newInterval.d_origins = collectConstraints(cov);
intervals.emplace_back(newInterval);
+ if (isProofEnabled())
+ {
+ auto cell = d_proof->constructCell(
+ d_constraints.varMapper()(d_variableOrdering[curVariable]),
+ newInterval,
+ d_assignment,
+ sample,
+ d_constraints.varMapper());
+ d_proof->endScope(cell);
+ }
if (returnFirstInterval)
{
@@ -421,9 +454,31 @@ std::vector<CACInterval> CDCAC::getUnsatCover(std::size_t curVariable,
Trace("cdcac") << "-> " << i.d_interval << std::endl;
}
}
+ if (isProofEnabled())
+ {
+ d_proof->endRecursive();
+ }
return intervals;
}
+void CDCAC::startNewProof()
+{
+ if (isProofEnabled())
+ {
+ d_proof->startNewProof();
+ }
+}
+
+ProofGenerator* CDCAC::closeProof(const std::vector<Node>& assertions)
+{
+ if (isProofEnabled())
+ {
+ d_proof->endScope(assertions);
+ return d_proof->getProofGenerator();
+ }
+ return nullptr;
+}
+
bool CDCAC::checkIntegrality(std::size_t cur_variable, const poly::Value& value)
{
Node var = d_constraints.varMapper()(d_variableOrdering[cur_variable]);
@@ -470,7 +525,19 @@ bool CDCAC::hasRootBelow(const poly::Polynomial& p,
void CDCAC::pruneRedundantIntervals(std::vector<CACInterval>& intervals)
{
- cleanIntervals(intervals);
+ if (isProofEnabled())
+ {
+ std::vector<CACInterval> allIntervals = intervals;
+ cleanIntervals(intervals);
+ d_proof->pruneChildren([&allIntervals, &intervals](std::size_t i) {
+ return std::find(intervals.begin(), intervals.end(), allIntervals[i])
+ != intervals.end();
+ });
+ }
+ else
+ {
+ cleanIntervals(intervals);
+ }
}
} // namespace cad
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback