summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaniel Barbosa <hanielbbarbosa@gmail.com>2021-09-01 14:30:36 -0300
committerHaniel Barbosa <hanielbbarbosa@gmail.com>2021-09-01 14:30:36 -0300
commit6faa211510bb0bbca5525598d05ba5a2198d72ab (patch)
treeab29c29e4b42926a8823d9ab5dcfdb598f9b0155
parentf77fa45cb56c4156e5610ebd2a8ac0e791583937 (diff)
Fix lost reference to reason when processing redundant literals
Similarly to the issue when explaining literals, it's necassary to save the reference to the reason, as adding explanations to the SAT solver may change the reference.
-rw-r--r--src/prop/sat_proof_manager.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/prop/sat_proof_manager.cpp b/src/prop/sat_proof_manager.cpp
index ad23bedc9..8891016a4 100644
--- a/src/prop/sat_proof_manager.cpp
+++ b/src/prop/sat_proof_manager.cpp
@@ -305,11 +305,19 @@ void SatProofManager::processRedundantLit(
printClause(reason);
Trace("sat-proof") << "\n";
}
- // check if redundant literals in the reason. The first literal is the one we
- // will be eliminating, so we check the others
+ // Since processRedundantLit calls can reallocate memory in the SAT solver due
+ // to explaining stuff, we directly get the literals and the clause node here
+ std::vector<SatLiteral> toProcess;
for (unsigned i = 1, size = reason.size(); i < size; ++i)
{
- SatLiteral satLit = MinisatSatSolver::toSatLiteral(reason[i]);
+ toProcess.push_back(MinisatSatSolver::toSatLiteral(reason[i]));
+ }
+ Node clauseNode = getClauseNode(reason);
+ // check if redundant literals in the reason. The first literal is the one we
+ // will be eliminating, so we check the others
+ for (unsigned i = 0, size = toProcess.size(); i < size; ++i)
+ {
+ SatLiteral satLit = toProcess[i];
// if literal does not occur in the conclusion we process it as well
if (!conclusionLits.count(satLit))
{
@@ -325,7 +333,6 @@ void SatProofManager::processRedundantLit(
// reason, not only with ~lit, since the learned clause is built under the
// assumption that the redundant literal is removed via the resolution with
// the explanation of its negation
- Node clauseNode = getClauseNode(reason);
Node litNode = d_cnfStream->getNodeCache()[lit];
bool negated = lit.isNegated();
Assert(!negated || litNode.getKind() == kind::NOT);
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback