ProofManager::ProofManager(context::Context* context, ProofFormat format)
: d_context(context),
- d_satProof(NULL),
- d_cnfProof(NULL),
- d_theoryProof(NULL),
+ d_satProof(nullptr),
+ d_cnfProof(nullptr),
+ d_theoryProof(nullptr),
d_inputFormulas(),
d_inputCoreFormulas(context),
d_outputCoreFormulas(context),
{
}
-ProofManager::~ProofManager() {
- if (d_satProof) delete d_satProof;
- if (d_cnfProof) delete d_cnfProof;
- if (d_theoryProof) delete d_theoryProof;
-}
+ProofManager::~ProofManager() {}
ProofManager* ProofManager::currentPM() {
return smt::currentProofManager();
Assert(currentPM()->d_format == LFSC);
currentPM()->d_fullProof.reset(new LFSCProof(
smt,
- static_cast<CoreSatProof*>(getSatProof()),
+ getSatProof(),
static_cast<LFSCCnfProof*>(getCnfProof()),
static_cast<LFSCTheoryProofEngine*>(getTheoryProofEngine())));
}
return *(currentPM()->d_fullProof);
}
-CoreSatProof* ProofManager::getSatProof() {
+CoreSatProof* ProofManager::getSatProof()
+{
Assert(currentPM()->d_satProof);
- return currentPM()->d_satProof;
+ return currentPM()->d_satProof.get();
}
-CnfProof* ProofManager::getCnfProof() {
+CnfProof* ProofManager::getCnfProof()
+{
Assert(currentPM()->d_cnfProof);
- return currentPM()->d_cnfProof;
+ return currentPM()->d_cnfProof.get();
}
-TheoryProofEngine* ProofManager::getTheoryProofEngine() {
+TheoryProofEngine* ProofManager::getTheoryProofEngine()
+{
Assert(currentPM()->d_theoryProof != NULL);
- return currentPM()->d_theoryProof;
+ return currentPM()->d_theoryProof.get();
}
UFProof* ProofManager::getUfProof() {
return &(currentPM()->d_skolemizationManager);
}
-void ProofManager::initSatProof(Minisat::Solver* solver) {
- Assert(currentPM()->d_satProof == NULL);
- Assert(currentPM()->d_format == LFSC);
- currentPM()->d_satProof = new CoreSatProof(solver, d_context, "");
+void ProofManager::initSatProof(Minisat::Solver* solver)
+{
+ Assert(d_format == LFSC);
+ // Destroy old instance before initializing new one to avoid issues with
+ // registering stats
+ d_satProof.reset();
+ d_satProof.reset(new CoreSatProof(solver, d_context, ""));
}
void ProofManager::initCnfProof(prop::CnfStream* cnfStream,
- context::Context* ctx) {
- ProofManager* pm = currentPM();
- Assert(pm->d_satProof != NULL);
- Assert(pm->d_cnfProof == NULL);
- Assert(pm->d_format == LFSC);
- CnfProof* cnf = new LFSCCnfProof(cnfStream, ctx, "");
- pm->d_cnfProof = cnf;
+ context::Context* ctx)
+{
+ Assert(d_satProof != nullptr);
+ Assert(d_format == LFSC);
+
+ d_cnfProof.reset(new LFSCCnfProof(cnfStream, ctx, ""));
// true and false have to be setup in a special way
Node true_node = NodeManager::currentNM()->mkConst<bool>(true);
Node false_node = NodeManager::currentNM()->mkConst<bool>(false).notNode();
- pm->d_cnfProof->pushCurrentAssertion(true_node);
- pm->d_cnfProof->pushCurrentDefinition(true_node);
- pm->d_cnfProof->registerConvertedClause(pm->d_satProof->getTrueUnit());
- pm->d_cnfProof->popCurrentAssertion();
- pm->d_cnfProof->popCurrentDefinition();
-
- pm->d_cnfProof->pushCurrentAssertion(false_node);
- pm->d_cnfProof->pushCurrentDefinition(false_node);
- pm->d_cnfProof->registerConvertedClause(pm->d_satProof->getFalseUnit());
- pm->d_cnfProof->popCurrentAssertion();
- pm->d_cnfProof->popCurrentDefinition();
+ d_cnfProof->pushCurrentAssertion(true_node);
+ d_cnfProof->pushCurrentDefinition(true_node);
+ d_cnfProof->registerConvertedClause(d_satProof->getTrueUnit());
+ d_cnfProof->popCurrentAssertion();
+ d_cnfProof->popCurrentDefinition();
+ d_cnfProof->pushCurrentAssertion(false_node);
+ d_cnfProof->pushCurrentDefinition(false_node);
+ d_cnfProof->registerConvertedClause(d_satProof->getFalseUnit());
+ d_cnfProof->popCurrentAssertion();
+ d_cnfProof->popCurrentDefinition();
}
-void ProofManager::initTheoryProofEngine() {
- Assert(currentPM()->d_theoryProof == NULL);
- Assert(currentPM()->d_format == LFSC);
- currentPM()->d_theoryProof = new LFSCTheoryProofEngine();
+void ProofManager::initTheoryProofEngine()
+{
+ Assert(d_theoryProof == NULL);
+ Assert(d_format == LFSC);
+ d_theoryProof.reset(new LFSCTheoryProofEngine());
}
std::string ProofManager::getInputClauseName(ClauseId id,
class ProofManager {
context::Context* d_context;
- CoreSatProof* d_satProof;
- CnfProof* d_cnfProof;
- TheoryProofEngine* d_theoryProof;
+ std::unique_ptr<CoreSatProof> d_satProof;
+ std::unique_ptr<CnfProof> d_cnfProof;
+ std::unique_ptr<TheoryProofEngine> d_theoryProof;
// information that will need to be shared across proofs
ExprSet d_inputFormulas;
static ProofManager* currentPM();
// initialization
- void initSatProof(Minisat::Solver* solver);
- static void initCnfProof(CVC4::prop::CnfStream* cnfStream,
- context::Context* ctx);
- static void initTheoryProofEngine();
+ void initSatProof(Minisat::Solver* solver);
+ void initCnfProof(CVC4::prop::CnfStream* cnfStream, context::Context* ctx);
+ void initTheoryProofEngine();
// getting various proofs
static const Proof& getProof(SmtEngine* smt);