return true;
}
-
-void ProofArith::toStream(std::ostream& out) {
+void ProofArith::toStream(std::ostream& out) const
+{
Trace("theory-proof-debug") << "; Print Arith proof..." << std::endl;
//AJR : carry this further?
ProofLetMap map;
toStreamLFSC(out, ProofManager::getArithProof(), *d_proof, map);
}
-void ProofArith::toStreamLFSC(std::ostream& out, TheoryProof* tp,
+void ProofArith::toStreamLFSC(std::ostream& out,
+ TheoryProof* tp,
const theory::eq::EqProof& pf,
- const ProofLetMap& map) {
+ const ProofLetMap& map)
+{
Debug("lfsc-arith") << "Printing arith proof in LFSC : " << std::endl;
pf.debug_print("lfsc-arith");
Debug("lfsc-arith") << std::endl;
toStreamRecLFSC(out, tp, pf, 0, map);
}
-Node ProofArith::toStreamRecLFSC(std::ostream& out, TheoryProof* tp,
- const theory::eq::EqProof& pf, unsigned tb,
- const ProofLetMap& map) {
+Node ProofArith::toStreamRecLFSC(std::ostream& out,
+ TheoryProof* tp,
+ const theory::eq::EqProof& pf,
+ unsigned tb,
+ const ProofLetMap& map)
+{
Debug("pf::arith") << std::endl
<< std::endl
<< "toStreamRecLFSC called. tb = " << tb
class ProofArith : public Proof {
public:
ProofArith(std::shared_ptr<theory::eq::EqProof> pf) : d_proof(pf) {}
- void toStream(std::ostream& out) override;
+ void toStream(std::ostream& out) const override;
+
private:
static void toStreamLFSC(std::ostream& out, TheoryProof* tp,
const theory::eq::EqProof& pf,
return true;
}
-ProofArray::ProofArray(std::shared_ptr<theory::eq::EqProof> pf, unsigned row,
- unsigned row1, unsigned ext)
- : d_proof(pf), d_reasonRow(row), d_reasonRow1(row1), d_reasonExt(ext) {}
+ProofArray::ProofArray(std::shared_ptr<theory::eq::EqProof> pf,
+ unsigned row,
+ unsigned row1,
+ unsigned ext)
+ : d_proof(pf), d_reasonRow(row), d_reasonRow1(row1), d_reasonExt(ext)
+{
+}
-void ProofArray::toStream(std::ostream& out) {
+void ProofArray::toStream(std::ostream& out) const
+{
ProofLetMap map;
toStream(out, map);
}
-void ProofArray::toStream(std::ostream& out, const ProofLetMap& map) {
+void ProofArray::toStream(std::ostream& out, const ProofLetMap& map) const
+{
Trace("pf::array") << "; Print Array proof..." << std::endl;
toStreamLFSC(out, ProofManager::getArrayProof(), *d_proof, map);
Debug("pf::array") << "; Print Array proof done!" << std::endl;
}
-void ProofArray::toStreamLFSC(std::ostream& out, TheoryProof* tp,
+void ProofArray::toStreamLFSC(std::ostream& out,
+ TheoryProof* tp,
const theory::eq::EqProof& pf,
- const ProofLetMap& map) {
+ const ProofLetMap& map) const
+{
Debug("pf::array") << "Printing array proof in LFSC : " << std::endl;
ArrayProofPrinter proofPrinter(d_reasonRow, d_reasonRow1, d_reasonExt);
pf.debug_print("pf::array", 0, &proofPrinter);
Debug("pf::array") << "Printing array proof in LFSC DONE" << std::endl;
}
-Node ProofArray::toStreamRecLFSC(std::ostream& out, TheoryProof* tp,
- const theory::eq::EqProof& pf, unsigned tb,
- const ProofLetMap& map) {
+Node ProofArray::toStreamRecLFSC(std::ostream& out,
+ TheoryProof* tp,
+ const theory::eq::EqProof& pf,
+ unsigned tb,
+ const ProofLetMap& map) const
+{
Debug("pf::array") << std::endl
<< std::endl
<< "toStreamRecLFSC called. tb = " << tb
void registerSkolem(Node equality, Node skolem);
- void toStream(std::ostream& out);
- void toStream(std::ostream& out, const ProofLetMap& map);
- private:
- void toStreamLFSC(std::ostream& out, TheoryProof* tp,
- const theory::eq::EqProof& pf, const ProofLetMap& map);
+ void toStream(std::ostream& out) const override;
+ void toStream(std::ostream& out, const ProofLetMap& map) const override;
- Node toStreamRecLFSC(std::ostream& out, TheoryProof* tp,
- const theory::eq::EqProof& pf, unsigned tb,
- const ProofLetMap& map);
+ private:
+ void toStreamLFSC(std::ostream& out,
+ TheoryProof* tp,
+ const theory::eq::EqProof& pf,
+ const ProofLetMap& map) const;
+
+ Node toStreamRecLFSC(std::ostream& out,
+ TheoryProof* tp,
+ const theory::eq::EqProof& pf,
+ unsigned tb,
+ const ProofLetMap& map) const;
// It is simply an equality engine proof.
std::shared_ptr<theory::eq::EqProof> d_proof;
return os.str();
}
-ProofManager::ProofManager(context::Context* context, ProofFormat format):
- d_context(context),
- d_satProof(NULL),
- d_cnfProof(NULL),
- d_theoryProof(NULL),
- d_inputFormulas(),
- d_inputCoreFormulas(context),
- d_outputCoreFormulas(context),
- d_nextId(0),
- d_fullProof(NULL),
- d_format(format),
- d_deps(context)
+ProofManager::ProofManager(context::Context* context, ProofFormat format)
+ : d_context(context),
+ d_satProof(NULL),
+ d_cnfProof(NULL),
+ d_theoryProof(NULL),
+ d_inputFormulas(),
+ d_inputCoreFormulas(context),
+ d_outputCoreFormulas(context),
+ d_nextId(0),
+ d_fullProof(),
+ d_format(format),
+ d_deps(context)
{
}
if (d_satProof) delete d_satProof;
if (d_cnfProof) delete d_cnfProof;
if (d_theoryProof) delete d_theoryProof;
- if (d_fullProof) delete d_fullProof;
}
ProofManager* ProofManager::currentPM() {
return smt::currentProofManager();
}
-
-Proof* ProofManager::getProof(SmtEngine* smt) {
- if (currentPM()->d_fullProof != NULL) {
- return currentPM()->d_fullProof;
+const Proof& ProofManager::getProof(SmtEngine* smt)
+{
+ if (!currentPM()->d_fullProof)
+ {
+ Assert(currentPM()->d_format == LFSC);
+ currentPM()->d_fullProof.reset(new LFSCProof(
+ smt,
+ static_cast<LFSCCoreSatProof*>(getSatProof()),
+ static_cast<LFSCCnfProof*>(getCnfProof()),
+ static_cast<LFSCTheoryProofEngine*>(getTheoryProofEngine())));
}
- Assert (currentPM()->d_format == LFSC);
-
- currentPM()->d_fullProof = new LFSCProof(smt,
- (LFSCCoreSatProof*)getSatProof(),
- (LFSCCnfProof*)getCnfProof(),
- (LFSCTheoryProofEngine*)getTheoryProofEngine());
- return currentPM()->d_fullProof;
+ return *(currentPM()->d_fullProof);
}
CoreSatProof* ProofManager::getSatProof() {
, d_smtEngine(smtEngine)
{}
-void LFSCProof::toStream(std::ostream& out, const ProofLetMap& map) {
+void LFSCProof::toStream(std::ostream& out, const ProofLetMap& map) const
+{
Unreachable();
}
-void LFSCProof::toStream(std::ostream& out) {
-
+void LFSCProof::toStream(std::ostream& out) const
+{
Assert(options::bitblastMode() != theory::bv::BITBLAST_MODE_EAGER);
Assert(!d_satProof->proofConstructed());
void LFSCProof::printPreprocessedAssertions(const NodeSet& assertions,
std::ostream& os,
std::ostream& paren,
- ProofLetMap& globalLetMap) {
+ ProofLetMap& globalLetMap) const
+{
os << "\n ;; In the preprocessor we trust \n";
NodeSet::const_iterator it = assertions.begin();
NodeSet::const_iterator end = assertions.end();
os << "\n";
}
-void LFSCProof::checkUnrewrittenAssertion(const NodeSet& rewrites) {
+void LFSCProof::checkUnrewrittenAssertion(const NodeSet& rewrites) const
+{
Debug("pf::pm") << "LFSCProof::checkUnrewrittenAssertion starting" << std::endl;
NodeSet::const_iterator rewrite;
#define __CVC4__PROOF_MANAGER_H
#include <iosfwd>
+#include <memory>
#include <unordered_map>
#include <unordered_set>
const ClauseId ClauseIdUndef(-2);
const ClauseId ClauseIdError(-3);
-class Proof;
template <class Solver> class TSatProof;
typedef TSatProof< CVC4::Minisat::Solver> CoreSatProof;
int d_nextId;
- Proof* d_fullProof;
+ std::unique_ptr<Proof> d_fullProof;
ProofFormat d_format; // used for now only in debug builds
CDNodeToNodes d_deps;
static void initTheoryProofEngine();
// getting various proofs
- static Proof* getProof(SmtEngine* smt);
+ static const Proof& getProof(SmtEngine* smt);
static CoreSatProof* getSatProof();
static CnfProof* getCnfProof();
static TheoryProofEngine* getTheoryProofEngine();
std::set<Node> satClauseToNodeSet(prop::SatClause* clause);
};/* class ProofManager */
-class LFSCProof : public Proof {
- LFSCCoreSatProof* d_satProof;
- LFSCCnfProof* d_cnfProof;
- LFSCTheoryProofEngine* d_theoryProof;
- SmtEngine* d_smtEngine;
+class LFSCProof : public Proof
+{
+ public:
+ LFSCProof(SmtEngine* smtEngine,
+ LFSCCoreSatProof* sat,
+ LFSCCnfProof* cnf,
+ LFSCTheoryProofEngine* theory);
+ ~LFSCProof() override {}
+ void toStream(std::ostream& out) const override;
+ void toStream(std::ostream& out, const ProofLetMap& map) const override;
+ private:
// FIXME: hack until we get preprocessing
void printPreprocessedAssertions(const NodeSet& assertions,
std::ostream& os,
std::ostream& paren,
- ProofLetMap& globalLetMap);
+ ProofLetMap& globalLetMap) const;
- void checkUnrewrittenAssertion(const NodeSet& assertions);
+ void checkUnrewrittenAssertion(const NodeSet& assertions) const;
-public:
- LFSCProof(SmtEngine* smtEngine,
- LFSCCoreSatProof* sat,
- LFSCCnfProof* cnf,
- LFSCTheoryProofEngine* theory);
- virtual void toStream(std::ostream& out);
- virtual void toStream(std::ostream& out, const ProofLetMap& map);
- virtual ~LFSCProof() {}
-};/* class LFSCProof */
+ LFSCCoreSatProof* d_satProof;
+ LFSCCnfProof* d_cnfProof;
+ LFSCTheoryProofEngine* d_theoryProof;
+ SmtEngine* d_smtEngine;
+}; /* class LFSCProof */
std::ostream& operator<<(std::ostream& out, CVC4::ProofRule k);
}/* CVC4 namespace */
namespace CVC4 {
ProofOutputChannel::ProofOutputChannel() : d_conflict(), d_proof(nullptr) {}
-
-Proof* ProofOutputChannel::getConflictProof() {
+const Proof& ProofOutputChannel::getConflictProof() const
+{
Assert(hasConflict());
- return d_proof;
+ return *d_proof;
}
-void ProofOutputChannel::conflict(TNode n, Proof* pf) {
+void ProofOutputChannel::conflict(TNode n, std::unique_ptr<Proof> pf)
+{
Trace("pf::tp") << "ProofOutputChannel: CONFLICT: " << n << std::endl;
Assert(!hasConflict());
Assert(!d_proof);
d_conflict = n;
- d_proof = pf;
+ d_proof = std::move(pf);
Assert(hasConflict());
Assert(d_proof);
}
#ifndef __CVC4__PROOF_OUTPUT_CHANNEL_H
#define __CVC4__PROOF_OUTPUT_CHANNEL_H
+#include <memory>
#include <set>
#include <unordered_set>
#include "expr/node.h"
-#include "util/proof.h"
#include "theory/output_channel.h"
#include "theory/theory.h"
+#include "util/proof.h"
namespace CVC4 {
* This may be called at most once per ProofOutputChannel.
* Requires that `n` and `pf` are non-null.
*/
- void conflict(TNode n, Proof* pf) override;
+ void conflict(TNode n, std::unique_ptr<Proof> pf) override;
bool propagate(TNode x) override;
theory::LemmaStatus lemma(TNode n, ProofRule rule, bool, bool, bool) override;
theory::LemmaStatus splitLemma(TNode, bool) override;
* Returns the proof passed into the conflict() call.
* Requires hasConflict() to hold.
*/
- Proof* getConflictProof();
+ const Proof& getConflictProof() const;
Node getLastLemma() const { return d_lemma; }
private:
Node d_conflict;
- Proof* d_proof;
+ std::unique_ptr<Proof> d_proof;
Node d_lemma;
std::set<Node> d_propagations;
}; /* class ProofOutputChannel */
th->check(theory::Theory::EFFORT_FULL);
} else {
Debug("pf::tp") << "Calling oc.d_proof->toStream(os)" << std::endl;
- oc.getConflictProof()->toStream(os, map);
+ oc.getConflictProof().toStream(os, map);
Debug("pf::tp") << "Calling oc.d_proof->toStream(os) -- DONE!" << std::endl;
}
return true;
}
-
-void ProofUF::toStream(std::ostream& out) {
+void ProofUF::toStream(std::ostream& out) const
+{
ProofLetMap map;
toStream(out, map);
}
-void ProofUF::toStream(std::ostream& out, const ProofLetMap& map) {
+void ProofUF::toStream(std::ostream& out, const ProofLetMap& map) const
+{
Trace("theory-proof-debug") << "; Print UF proof..." << std::endl;
//AJR : carry this further?
toStreamLFSC(out, ProofManager::getUfProof(), *d_proof, map);
}
-void ProofUF::toStreamLFSC(std::ostream& out, TheoryProof* tp,
+void ProofUF::toStreamLFSC(std::ostream& out,
+ TheoryProof* tp,
const theory::eq::EqProof& pf,
- const ProofLetMap& map) {
+ const ProofLetMap& map)
+{
Debug("pf::uf") << "ProofUF::toStreamLFSC starting" << std::endl;
Debug("lfsc-uf") << "Printing uf proof in LFSC : " << std::endl;
pf.debug_print("lfsc-uf");
toStreamRecLFSC( out, tp, pf, 0, map );
}
-Node ProofUF::toStreamRecLFSC(std::ostream& out, TheoryProof* tp,
+Node ProofUF::toStreamRecLFSC(std::ostream& out,
+ TheoryProof* tp,
const theory::eq::EqProof& pf,
- unsigned tb, const ProofLetMap& map) {
+ unsigned tb,
+ const ProofLetMap& map)
+{
Debug("pf::uf") << std::endl
<< std::endl
<< "toStreamRecLFSC called. tb = " << tb
namespace CVC4 {
// proof object outputted by TheoryUF
-class ProofUF : public Proof {
+class ProofUF : public Proof
+{
public:
ProofUF(std::shared_ptr<theory::eq::EqProof> pf) : d_proof(pf) {}
- void toStream(std::ostream& out) override;
- void toStream(std::ostream& out, const ProofLetMap& map) override;
+ void toStream(std::ostream& out) const override;
+ void toStream(std::ostream& out, const ProofLetMap& map) const override;
private:
static void toStreamLFSC(std::ostream& out, TheoryProof* tp,
/* class GetProofCommand */
GetProofCommand::GetProofCommand() throw()
- : d_result(nullptr), d_smtEngine(nullptr) {}
+ : d_smtEngine(nullptr), d_result(nullptr) {}
void GetProofCommand::invoke(SmtEngine* smtEngine) {
try {
d_smtEngine = smtEngine;
- d_result = smtEngine->getProof();
+ d_result = &smtEngine->getProof();
d_commandStatus = CommandSuccess::instance();
} catch (RecoverableModalException& e) {
d_commandStatus = new CommandRecoverableFailure(e.what());
}
}
-Proof* GetProofCommand::getResult() const throw() {
- return d_result;
-}
-
+const Proof& GetProofCommand::getResult() const throw() { return *d_result; }
void GetProofCommand::printResult(std::ostream& out, uint32_t verbosity) const {
if(! ok()) {
this->Command::printResult(out, verbosity);
GetProofCommand() throw();
~GetProofCommand() throw() {}
void invoke(SmtEngine* smtEngine);
- Proof* getResult() const throw();
+ const Proof& getResult() const throw();
void printResult(std::ostream& out, uint32_t verbosity = 2) const;
Command* exportTo(ExprManager* exprManager,
ExprManagerMapCollection& variableMap);
std::string getCommandName() const throw();
protected:
- Proof* d_result;
SmtEngine* d_smtEngine;
+ // d_result is owned by d_smtEngine.
+ const Proof* d_result;
}; /* class GetProofCommand */
class CVC4_PUBLIC GetInstantiationsCommand : public Command {
}
// TODO(#1108): Simplify the error reporting of this method.
-Proof* SmtEngine::getProof() {
+const Proof& SmtEngine::getProof()
+{
Trace("smt") << "SMT getProof()" << endl;
SmtScope smts(this);
finalOptionsAreSet();
* Get the last proof (only if immediately preceded by an UNSAT
* or VALID query). Only permitted if CVC4 was built with proof
* support and produce-proofs is on.
+ *
+ * The Proof object is owned by this SmtEngine until the SmtEngine is
+ * destroyed.
*/
- Proof* getProof();
+ const Proof& getProof();
/**
* Print all instantiations made by the quantifiers module.
#include "base/cvc4_assert.h"
#include "base/output.h"
#include "smt/smt_engine.h"
+#include "util/proof.h"
#include "util/statistics_registry.h"
#if (IS_LFSC_BUILD && IS_PROOFS_BUILD)
Chat() << "generating proof..." << endl;
- Proof* pf = getProof();
+ const Proof& pf = getProof();
Chat() << "checking proof..." << endl;
ofstream pfStream(pfFile);
pfStream << proof::plf_signatures << endl;
- pf->toStream(pfStream);
+ pf.toStream(pfStream);
pfStream.close();
lfscc_init();
lfscc_check_file(pfFile, false, false, false, false, false, false, false);
d_conflictNode = explain(a.eqNode(b), proof.get());
if (!d_inCheckModel) {
- ProofArray* proof_array = NULL;
+ std::unique_ptr<ProofArray> proof_array;
if (d_proofsEnabled) {
proof->debug_print("pf::array");
- proof_array = new ProofArray(proof, /*row=*/d_reasonRow,
- /*row1=*/d_reasonRow1, /*ext=*/d_reasonExt);
+ proof_array.reset(new ProofArray(proof,
+ /*row=*/d_reasonRow,
+ /*row1=*/d_reasonRow1,
+ /*ext=*/d_reasonExt));
}
- d_out->conflict(d_conflictNode, proof_array);
+ d_out->conflict(d_conflictNode, std::move(proof_array));
}
d_conflict = true;
#ifndef __CVC4__THEORY__OUTPUT_CHANNEL_H
#define __CVC4__THEORY__OUTPUT_CHANNEL_H
+#include <memory>
+
#include "base/cvc4_assert.h"
#include "proof/proof_manager.h"
#include "smt/logic_exception.h"
* @param pf - a proof of the conflict. This is only non-null if proofs
* are enabled.
*/
- virtual void conflict(TNode n, Proof* pf = nullptr) = 0;
+ virtual void conflict(TNode n, std::unique_ptr<Proof> pf = nullptr) = 0;
/**
* Propagate a theory literal.
}
void TheoryEngine::EngineOutputChannel::conflict(TNode conflictNode,
- Proof* proof) {
+ std::unique_ptr<Proof> proof)
+{
Trace("theory::conflict")
<< "EngineOutputChannel<" << d_theory << ">::conflict(" << conflictNode
<< ")" << std::endl;
#define __CVC4__THEORY_ENGINE_H
#include <deque>
+#include <memory>
#include <set>
#include <unordered_map>
#include <vector>
}
}
- void conflict(TNode conflictNode, Proof* pf = nullptr) override;
+ void conflict(TNode conflictNode,
+ std::unique_ptr<Proof> pf = nullptr) override;
bool propagate(TNode literal) override;
theory::LemmaStatus lemma(TNode lemma, ProofRule rule,
#define __CVC4__THEORY__THEORY_TEST_UTILS_H
#include <iostream>
+#include <memory>
#include <utility>
#include <vector>
#include "expr/node.h"
#include "theory/interrupted.h"
#include "theory/output_channel.h"
+#include "util/proof.h"
#include "util/unsafe_interrupt_exception.h"
namespace CVC4 {
~TestOutputChannel() override {}
void safePoint(uint64_t amount) override {}
-
- void conflict(TNode n, Proof* pf = nullptr) override {
+ void conflict(TNode n, std::unique_ptr<Proof> pf) override
+ {
push(CONFLICT, n);
}
std::shared_ptr<eq::EqProof> pf =
d_proofsEnabled ? std::make_shared<eq::EqProof>() : nullptr;
d_conflictNode = explain(a.eqNode(b), pf.get());
- ProofUF* puf = d_proofsEnabled ? new ProofUF( pf ) : NULL;
- d_out->conflict(d_conflictNode, puf);
+ std::unique_ptr<ProofUF> puf(d_proofsEnabled ? new ProofUF(pf) : nullptr);
+ d_out->conflict(d_conflictNode, std::move(puf));
d_conflict = true;
}
typedef std::unordered_map<Expr, ProofLetCount, ExprHashFunction> ProofLetMap;
-class CVC4_PUBLIC Proof {
-public:
- virtual ~Proof() { }
- virtual void toStream(std::ostream& out) = 0;
- virtual void toStream(std::ostream& out, const ProofLetMap& map) = 0;
+class CVC4_PUBLIC Proof
+{
+ public:
+ virtual ~Proof() {}
+ virtual void toStream(std::ostream& out) const = 0;
+ virtual void toStream(std::ostream& out, const ProofLetMap& map) const = 0;
};/* class Proof */
}/* CVC4 namespace */
#include <deque>
#include <iostream>
+#include <memory>
#include <string>
#include "base/cvc4_assert.h"
#include "theory/theory_engine.h"
#include "theory/valuation.h"
#include "util/integer.h"
+#include "util/proof.h"
#include "util/rational.h"
using namespace CVC4;
using namespace std;
class FakeOutputChannel : public OutputChannel {
- void conflict(TNode n, Proof* pf) override { Unimplemented(); }
+ void conflict(TNode n, std::unique_ptr<Proof> pf) override
+ {
+ Unimplemented();
+ }
bool propagate(TNode n) override { Unimplemented(); }
LemmaStatus lemma(TNode n, ProofRule rule, bool removable, bool preprocess,
bool sendAtoms) override {
**/
#include <cxxtest/TestSuite.h>
+#include <memory>
#include <vector>
-// taking: Add include for Proof*.
#include "context/context.h"
#include "expr/node.h"
#include "expr/node_manager.h"
#include "smt/smt_engine_scope.h"
#include "theory/theory.h"
#include "theory/theory_engine.h"
-
+#include "util/proof.h"
using namespace CVC4;
using namespace CVC4::theory;
~TestOutputChannel() override {}
void safePoint(uint64_t amount) override {}
-
- void conflict(TNode n, Proof* pf = nullptr) override {
+ void conflict(TNode n, std::unique_ptr<Proof> pf) override
+ {
push(CONFLICT, n);
}