namespace cvc5 {
namespace prop {
-SatProofManager::SatProofManager(Minisat::Solver* solver,
- CnfStream* cnfStream,
- context::UserContext* userContext,
- ProofNodeManager* pnm)
- : d_solver(solver),
+SatProofManager::SatProofManager(Env& env,
+ Minisat::Solver* solver,
+ CnfStream* cnfStream)
+ : EnvObj(env),
+ d_solver(solver),
d_cnfStream(cnfStream),
- d_pnm(pnm),
- d_resChains(pnm, true, userContext),
- d_resChainPg(userContext, pnm),
- d_assumptions(userContext),
- d_conflictLit(undefSatVariable)
+ d_resChains(d_env.getProofNodeManager(), true, userContext()),
+ d_resChainPg(userContext(), d_env.getProofNodeManager()),
+ d_assumptions(userContext()),
+ d_conflictLit(undefSatVariable),
+ d_optResLevels(userContext()),
+ d_optResManager(userContext(), &d_resChains, d_optResProofs)
{
d_true = NodeManager::currentNM()->mkConst(true);
d_false = NodeManager::currentNM()->mkConst(false);
<< satLit.isNegated() << "} [" << ~satLit << "] ";
printClause(clause);
Trace("sat-proof") << "\nSatProofManager::addResolutionStep:\t"
- << clauseNode << "\n";
+ << clauseNode << " - lvl " << clause.level() + 1 << "\n";
}
}
void SatProofManager::endResChain(Minisat::Lit lit)
{
SatLiteral satLit = MinisatSatSolver::toSatLiteral(lit);
+ Trace("sat-proof") << "SatProofManager::endResChain: curr user level: "
+ << userContext()->getLevel() << "\n";
Trace("sat-proof") << "SatProofManager::endResChain: chain_res for "
<< satLit;
endResChain(d_cnfStream->getNode(satLit), {satLit});
{
if (TraceIsOn("sat-proof"))
{
+ Trace("sat-proof") << "SatProofManager::endResChain: curr user level: "
+ << userContext()->getLevel() << "\n";
Trace("sat-proof") << "SatProofManager::endResChain: chain_res for ";
printClause(clause);
}
{
clauseLits.insert(MinisatSatSolver::toSatLiteral(clause[i]));
}
- endResChain(getClauseNode(clause), clauseLits);
+ Node conclusion = getClauseNode(clause);
+ int clauseLevel = clause.level() + 1;
+ if (clauseLevel < userContext()->getLevel())
+ {
+ Assert(!d_optResLevels.count(conclusion));
+ d_optResLevels[conclusion] = clauseLevel;
+ Trace("sat-proof") << "SatProofManager::endResChain: ..clause's lvl "
+ << clause.level() + 1 << " below curr user level "
+ << userContext()->getLevel() << "\n";
+ }
+ endResChain(conclusion, clauseLits);
}
void SatProofManager::endResChain(Node conclusion,
std::shared_ptr<ProofNode> pfn = d_resChains.getProofFor(d_false);
if (!pfn)
{
- pfn = d_pnm->mkAssume(d_false);
+ pfn = d_env.getProofNodeManager()->mkAssume(d_false);
}
return pfn;
}
}
}
+void SatProofManager::notifyPop()
+{
+ for (context::CDHashMap<Node, int>::const_iterator it =
+ d_optResLevels.begin();
+ it != d_optResLevels.end();
+ ++it)
+ {
+ // Save into map the proof of the resolution chain. We copy to prevent the
+ // proof node saved to be restored to suffering unintended updates. This is
+ // *necessary*.
+ std::shared_ptr<ProofNode> clauseResPf =
+ d_env.getProofNodeManager()->clone(d_resChains.getProofFor(it->first));
+ Assert(clauseResPf && clauseResPf->getRule() != PfRule::ASSUME);
+ d_optResProofs[it->second].push_back(clauseResPf);
+ }
+}
+
} // namespace prop
} // namespace cvc5
#ifndef CVC5__SAT_PROOF_MANAGER_H
#define CVC5__SAT_PROOF_MANAGER_H
+#include "context/cdhashmap.h"
#include "context/cdhashset.h"
#include "expr/node.h"
#include "proof/buffered_proof_generator.h"
#include "proof/lazy_proof_chain.h"
#include "prop/minisat/core/SolverTypes.h"
+#include "prop/opt_clauses_manager.h"
#include "prop/sat_solver_types.h"
+#include "smt/env_obj.h"
namespace Minisat {
class Solver;
* getProof
*
*/
-class SatProofManager
+class SatProofManager : protected EnvObj
{
public:
- SatProofManager(Minisat::Solver* solver,
- CnfStream* cnfStream,
- context::UserContext* userContext,
- ProofNodeManager* pnm);
+ SatProofManager(Env& env, Minisat::Solver* solver, CnfStream* cnfStream);
/** Marks the start of a resolution chain.
*
/** Register a set clause inputs. */
void registerSatAssumptions(const std::vector<Node>& assumps);
+ /** Notify this proof manager that the SAT solver has user-context popped. */
+ void notifyPop();
+
private:
/** Ends resolution chain concluding clause
*
Node getClauseNode(const Minisat::Clause& clause);
/** Prints clause, as a sequence of literals, in the "sat-proof" trace. */
void printClause(const Minisat::Clause& clause);
+
+ /** The user context */
+ context::UserContext* d_userContext;
+
+ /** User-context dependent map from resolution conclusions to their assertion
+ level. */
+ context::CDHashMap<Node, int> d_optResLevels;
+ /** Maps assertion level to proof nodes.
+ *
+ * This map is used by d_optResManager to update the internal proof of this
+ * manager when the context pops.
+ */
+ std::map<int, std::vector<std::shared_ptr<ProofNode>>> d_optResProofs;
+ /** Manager for optimized resolution conclusions inserted at assertion levels
+ * below the current user level. */
+ OptimizedClausesManager d_optResManager;
}; /* class SatProofManager */
} // namespace prop