diff options
author | Alex Ozdemir <aozdemir@hmc.edu> | 2018-12-03 11:56:47 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-03 11:56:47 -0800 |
commit | aa0a875dfd40bd9dfa810238327db51498b74677 (patch) | |
tree | 5606b1214ef8388b86e964213ed3b9c67254317f /src/proof/resolution_bitvector_proof.h | |
parent | 2a19474cdb6761fd4c9aeb0165e661c531ba3e38 (diff) |
Bit vector proof superclass (#2599)
* Split BitvectorProof into a sub/superclass
The superclass contains general printing knowledge.
The subclass contains CNF or Resolution-specific knowledge.
* Renames & code moves
* Nits cleaned in prep for PR
* Moved CNF-proof from ResolutionBitVectorProof to BitVectorProof
Since DRAT BV proofs will also contain a CNF-proof, the CNF proof should
be stored in `BitVectorProof`.
* Unique pointers, comments, and code movement.
Adjusted the distribution of code between BVP and RBVP.
Notably, put the CNF proof in BVP because it isn't
resolution-specific.
Added comments to the headers of both files -- mostly BVP.
Changed two owned pointers into unique_ptr.
BVP's pointer to a CNF proof
RBVP's pointer to a resolution proof
BVP: `BitVectorProof`
RBVP: `ResolutionBitVectorProof`
* clang-format
* Undo manual copyright modification
* s/superclass/base class/
Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* make LFSCBitVectorProof::printOwnedSort public
* Andres's Comments
Mostly cleaning up (or trying to clean up) includes.
* Cleaned up one header cycle
However, this only allowed me to move the forward-decl, not eliminate
it, because there were actually two underlying include cycles that the
forward-decl solved.
* Added single _s to header gaurds
* Fix Class name in debug output
Credits to Andres
Co-Authored-By: alex-ozdemir <aozdemir@hmc.edu>
* Reordered methods in BitVectorProof per original ordering
Diffstat (limited to 'src/proof/resolution_bitvector_proof.h')
-rw-r--r-- | src/proof/resolution_bitvector_proof.h | 132 |
1 files changed, 132 insertions, 0 deletions
diff --git a/src/proof/resolution_bitvector_proof.h b/src/proof/resolution_bitvector_proof.h new file mode 100644 index 000000000..a54d72d3f --- /dev/null +++ b/src/proof/resolution_bitvector_proof.h @@ -0,0 +1,132 @@ +/********************* */ +/*! \file resolution_bitvector_proof.h + ** \verbatim + ** Top contributors (to current version): + ** Liana Hadarean, Mathias Preiner, Guy Katz + ** This file is part of the CVC4 project. + ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS + ** in the top-level source directory) and their institutional affiliations. + ** All rights reserved. See the file COPYING in the top-level source + ** directory for licensing information.\endverbatim + ** + ** \brief Bitvector proof + ** + ** Bitvector proof + **/ + +#include "cvc4_private.h" + +#ifndef __CVC4__PROOF__RESOLUTION_BITVECTOR_PROOF_H +#define __CVC4__PROOF__RESOLUTION_BITVECTOR_PROOF_H + +#include <iosfwd> + +#include "context/context.h" +#include "expr/expr.h" +#include "proof/bitvector_proof.h" +#include "proof/theory_proof.h" +#include "prop/bvminisat/core/Solver.h" + +namespace CVC4 { + +namespace theory { +namespace bv { +class TheoryBV; +template <class T> +class TBitblaster; +} // namespace bv +} // namespace theory + +// TODO(aozdemir) break the sat_solver - resolution_bitvectorproof - cnf_stream +// header cycle and remove this. +namespace prop { +class CnfStream; +} + +} /* namespace CVC4 */ + + +namespace CVC4 { + +template <class Solver> +class TSatProof; +typedef TSatProof<CVC4::BVMinisat::Solver> BVSatProof; + +namespace proof { + +/** + * Represents a bitvector proof which is backed by + * (a) bitblasting and + * (b) a resolution unsat proof. + * + * Contains tools for constructing BV conflicts + */ +class ResolutionBitVectorProof : public BitVectorProof +{ + public: + ResolutionBitVectorProof(theory::bv::TheoryBV* bv, + TheoryProofEngine* proofEngine); + + /** + * Create an (internal) SAT proof object + * Must be invoked before manipulating BV conflicts, + * or initializing a BNF proof + */ + void initSatProof(CVC4::BVMinisat::Solver* solver); + + BVSatProof* getSatProof(); + + /** + * Kind of a mess. + * In eager mode this must be invoked before printing a proof of the empty + * clause. In lazy mode the behavior is ??? + * TODO(aozdemir) clean this up. + */ + void finalizeConflicts(std::vector<Expr>& conflicts); + + void startBVConflict(CVC4::BVMinisat::Solver::TCRef cr); + void startBVConflict(CVC4::BVMinisat::Solver::TLit lit); + void endBVConflict(const BVMinisat::Solver::TLitVec& confl); + + void markAssumptionConflict() { d_isAssumptionConflict = true; } + bool isAssumptionConflict() const { return d_isAssumptionConflict; } + + virtual void printResolutionProof(std::ostream& os, + std::ostream& paren, + ProofLetMap& letMap) = 0; + + void initCnfProof(prop::CnfStream* cnfStream, context::Context* cnf) override; + + protected: + // The CNF formula that results from bit-blasting will need a proof. + // This is that proof. + std::unique_ptr<BVSatProof> d_resolutionProof; + + bool d_isAssumptionConflict; + + theory::TheoryId getTheoryId() override; + context::Context d_fakeContext; +}; + +class LFSCBitVectorProof : public ResolutionBitVectorProof +{ + public: + LFSCBitVectorProof(theory::bv::TheoryBV* bv, TheoryProofEngine* proofEngine) + : ResolutionBitVectorProof(bv, proofEngine) + { + } + void printTheoryLemmaProof(std::vector<Expr>& lemma, + std::ostream& os, + std::ostream& paren, + const ProofLetMap& map) override; + void printResolutionProof(std::ostream& os, + std::ostream& paren, + ProofLetMap& letMap) override; + void calculateAtomsInBitblastingProof() override; +}; + +} // namespace proof + +} // namespace CVC4 + +#endif /* __CVC4__PROOF__RESOLUTIONBITVECTORPROOF_H */ |