#include "prop/minisat/minisat.h"
using namespace std;
-using namespace Minisat;
+using namespace CVC4::Minisat;
using namespace CVC4::prop;
namespace CVC4 {
/// helper methods
-ClauseId SatProof::getClauseId(::Minisat::CRef ref) {
+ClauseId SatProof::getClauseId(Minisat::CRef ref) {
if(d_clauseId.find(ref) == d_clauseId.end()) {
Debug("proof:sat") << "Missing clause \n";
}
}
-ClauseId SatProof::getClauseId(::Minisat::Lit lit) {
+ClauseId SatProof::getClauseId(Minisat::Lit lit) {
Assert(d_unitId.find(toInt(lit)) != d_unitId.end());
return d_unitId[toInt(lit)];
}
return d_idUnit.find(id) != d_idUnit.end();
}
-bool SatProof::isUnit(::Minisat::Lit lit) {
+bool SatProof::isUnit(Minisat::Lit lit) {
return d_unitId.find(toInt(lit)) != d_unitId.end();
}
-ClauseId SatProof::getUnitId(::Minisat::Lit lit) {
+ClauseId SatProof::getUnitId(Minisat::Lit lit) {
Assert(isUnit(lit));
return d_unitId[toInt(lit)];
}
/// registration methods
-ClauseId SatProof::registerClause(::Minisat::CRef clause, ClauseKind kind, uint64_t proof_id) {
+ClauseId SatProof::registerClause(Minisat::CRef clause, ClauseKind kind, uint64_t proof_id) {
Debug("cores") << "registerClause " << proof_id << std::endl;
Assert(clause != CRef_Undef);
ClauseIdMap::iterator it = d_clauseId.find(clause);
return d_clauseId[clause];
}
-ClauseId SatProof::registerUnitClause(::Minisat::Lit lit, ClauseKind kind, uint64_t proof_id) {
+ClauseId SatProof::registerUnitClause(Minisat::Lit lit, ClauseKind kind, uint64_t proof_id) {
Debug("cores") << "registerUnitClause " << kind << " " << proof_id << std::endl;
UnitIdMap::iterator it = d_unitId.find(toInt(lit));
if (it == d_unitId.end()) {
return d_unitId[toInt(lit)];
}
-void SatProof::removedDfs(::Minisat::Lit lit, LitSet* removedSet, LitVector& removeStack, LitSet& inClause, LitSet& seen) {
+void SatProof::removedDfs(Minisat::Lit lit, LitSet* removedSet, LitVector& removeStack, LitSet& inClause, LitSet& seen) {
// if we already added the literal return
if (seen.count(lit)) {
return;
/// recording resolutions
-void SatProof::startResChain(::Minisat::CRef start) {
+void SatProof::startResChain(Minisat::CRef start) {
ClauseId id = getClauseId(start);
ResChain* res = new ResChain(id);
d_resStack.push_back(res);
}
-void SatProof::addResolutionStep(::Minisat::Lit lit, ::Minisat::CRef clause, bool sign) {
+void SatProof::addResolutionStep(Minisat::Lit lit, Minisat::CRef clause, bool sign) {
ClauseId id = registerClause(clause, LEARNT, uint64_t(-1));
ResChain* res = d_resStack.back();
res->addStep(lit, id, sign);
}
-void SatProof::endResChain(::Minisat::Lit lit) {
+void SatProof::endResChain(Minisat::Lit lit) {
Assert(d_resStack.size() > 0);
ClauseId id = registerUnitClause(lit, LEARNT, uint64_t(-1));
ResChain* res = d_resStack.back();
d_resStack.pop_back();
}
-void SatProof::storeLitRedundant(::Minisat::Lit lit) {
+void SatProof::storeLitRedundant(Minisat::Lit lit) {
Assert(d_resStack.size() > 0);
ResChain* res = d_resStack.back();
res->addRedundantLit(lit);
/// constructing resolutions
-void SatProof::resolveOutUnit(::Minisat::Lit lit) {
+void SatProof::resolveOutUnit(Minisat::Lit lit) {
ClauseId id = resolveUnit(~lit);
ResChain* res = d_resStack.back();
res->addStep(lit, id, !sign(lit));
}
-void SatProof::storeUnitResolution(::Minisat::Lit lit) {
+void SatProof::storeUnitResolution(Minisat::Lit lit) {
Debug("cores") << "STORE UNIT RESOLUTION" << std::endl;
resolveUnit(lit);
}
-ClauseId SatProof::resolveUnit(::Minisat::Lit lit) {
+ClauseId SatProof::resolveUnit(Minisat::Lit lit) {
// first check if we already have a resolution for lit
if(isUnit(lit)) {
ClauseId id = getClauseId(lit);
Unimplemented("native proof printing not supported yet");
}
-void SatProof::storeUnitConflict(::Minisat::Lit conflict_lit, ClauseKind kind, uint64_t proof_id) {
+void SatProof::storeUnitConflict(Minisat::Lit conflict_lit, ClauseKind kind, uint64_t proof_id) {
Debug("cores") << "STORE UNIT CONFLICT" << std::endl;
Assert(!d_storedUnitConflict);
d_unitConflictId = registerUnitClause(conflict_lit, kind, proof_id);
Debug("proof:sat:detailed") << "storeUnitConflict " << d_unitConflictId << "\n";
}
-void SatProof::finalizeProof(::Minisat::CRef conflict_ref) {
+void SatProof::finalizeProof(Minisat::CRef conflict_ref) {
Assert(d_resStack.size() == 0);
- Assert(conflict_ref != ::Minisat::CRef_Undef);
+ Assert(conflict_ref != Minisat::CRef_Undef);
ClauseId conflict_id;
- if (conflict_ref == ::Minisat::CRef_Lazy) {
+ if (conflict_ref == Minisat::CRef_Lazy) {
Assert(d_storedUnitConflict);
conflict_id = d_unitConflictId;
/// CRef manager
-void SatProof::updateCRef(::Minisat::CRef oldref, ::Minisat::CRef newref) {
+void SatProof::updateCRef(Minisat::CRef oldref, Minisat::CRef newref) {
if (d_clauseId.find(oldref) == d_clauseId.end()) {
return;
}
#include "expr/expr.h"
#include "proof/proof_manager.h"
+namespace CVC4 {
namespace Minisat {
class Solver;
typedef uint32_t CRef;
}/* Minisat namespace */
+}
#include "prop/minisat/core/SolverTypes.h"
#include "util/proof.h"
/**
* Helper debugging functions
*/
-void printDebug(::Minisat::Lit l);
-void printDebug(::Minisat::Clause& c);
+void printDebug(Minisat::Lit l);
+void printDebug(Minisat::Clause& c);
struct ResStep {
- ::Minisat::Lit lit;
+ Minisat::Lit lit;
ClauseId id;
bool sign;
- ResStep(::Minisat::Lit l, ClauseId i, bool s) :
+ ResStep(Minisat::Lit l, ClauseId i, bool s) :
lit(l),
id(i),
sign(s)
};/* struct ResStep */
typedef std::vector< ResStep > ResSteps;
-typedef std::set < ::Minisat::Lit> LitSet;
+typedef std::set < Minisat::Lit> LitSet;
class ResChain {
private:
LitSet* d_redundantLits;
public:
ResChain(ClauseId start);
- void addStep(::Minisat::Lit, ClauseId, bool);
+ void addStep(Minisat::Lit, ClauseId, bool);
bool redundantRemoved() { return (d_redundantLits == NULL || d_redundantLits->empty()); }
- void addRedundantLit(::Minisat::Lit lit);
+ void addRedundantLit(Minisat::Lit lit);
~ResChain();
// accessor methods
ClauseId getStart() { return d_start; }
LitSet* getRedundant() { return d_redundantLits; }
};/* class ResChain */
-typedef std::hash_map < ClauseId, ::Minisat::CRef > IdCRefMap;
-typedef std::hash_map < ::Minisat::CRef, ClauseId > ClauseIdMap;
-typedef std::hash_map < ClauseId, ::Minisat::Lit> IdUnitMap;
+typedef std::hash_map < ClauseId, Minisat::CRef > IdCRefMap;
+typedef std::hash_map < Minisat::CRef, ClauseId > ClauseIdMap;
+typedef std::hash_map < ClauseId, Minisat::Lit> IdUnitMap;
typedef std::hash_map < int, ClauseId> UnitIdMap; //FIXME
typedef std::hash_map < ClauseId, ResChain*> IdResMap;
typedef std::hash_set < ClauseId > IdHashSet;
typedef std::vector < ResChain* > ResStack;
typedef std::hash_map <ClauseId, prop::SatClause* > IdToSatClause;
typedef std::set < ClauseId > IdSet;
-typedef std::vector < ::Minisat::Lit > LitVector;
-typedef __gnu_cxx::hash_map<ClauseId, ::Minisat::Clause& > IdToMinisatClause;
+typedef std::vector < Minisat::Lit > LitVector;
+typedef __gnu_cxx::hash_map<ClauseId, Minisat::Clause& > IdToMinisatClause;
class SatProof;
SatProof* d_proof;
public:
ProofProxy(SatProof* pf);
- void updateCRef(::Minisat::CRef oldref, ::Minisat::CRef newref);
+ void updateCRef(Minisat::CRef oldref, Minisat::CRef newref);
};/* class ProofProxy */
class SatProof {
protected:
- ::Minisat::Solver* d_solver;
+ Minisat::Solver* d_solver;
// clauses
IdCRefMap d_idClause;
ClauseIdMap d_clauseId;
ClauseId d_unitConflictId;
bool d_storedUnitConflict;
public:
- SatProof(::Minisat::Solver* solver, bool checkRes = false);
+ SatProof(Minisat::Solver* solver, bool checkRes = false);
virtual ~SatProof();
protected:
void print(ClauseId id);
bool isTheoryConflict(ClauseId id);
bool isLemmaClause(ClauseId id);
bool isUnit(ClauseId id);
- bool isUnit(::Minisat::Lit lit);
+ bool isUnit(Minisat::Lit lit);
bool hasResolution(ClauseId id);
void createLitSet(ClauseId id, LitSet& set);
void registerResolution(ClauseId id, ResChain* res);
- ClauseId getClauseId(::Minisat::CRef clause);
- ClauseId getClauseId(::Minisat::Lit lit);
- ::Minisat::CRef getClauseRef(ClauseId id);
- ::Minisat::Lit getUnit(ClauseId id);
- ClauseId getUnitId(::Minisat::Lit lit);
- ::Minisat::Clause& getClause(::Minisat::CRef ref);
+ ClauseId getClauseId(Minisat::CRef clause);
+ ClauseId getClauseId(Minisat::Lit lit);
+ Minisat::CRef getClauseRef(ClauseId id);
+ Minisat::Lit getUnit(ClauseId id);
+ ClauseId getUnitId(Minisat::Lit lit);
+ Minisat::Clause& getClause(Minisat::CRef ref);
virtual void toStream(std::ostream& out);
bool checkResolution(ClauseId id);
*
* @return
*/
- ClauseId resolveUnit(::Minisat::Lit lit);
+ ClauseId resolveUnit(Minisat::Lit lit);
/**
* Does a depth first search on removed literals and adds the literals
* to be removed in the proper order to the stack.
* @param removedSet the previously computed set of redundant literals
* @param removeStack the stack of literals in reverse order of resolution
*/
- void removedDfs(::Minisat::Lit lit, LitSet* removedSet, LitVector& removeStack, LitSet& inClause, LitSet& seen);
+ void removedDfs(Minisat::Lit lit, LitSet* removedSet, LitVector& removeStack, LitSet& inClause, LitSet& seen);
void removeRedundantFromRes(ResChain* res, ClauseId id);
public:
- void startResChain(::Minisat::CRef start);
- void addResolutionStep(::Minisat::Lit lit, ::Minisat::CRef clause, bool sign);
+ void startResChain(Minisat::CRef start);
+ void addResolutionStep(Minisat::Lit lit, Minisat::CRef clause, bool sign);
/**
* Pops the current resolution of the stack and stores it
* in the resolution map. Also registers the 'clause' parameter
* @param clause the clause the resolution is proving
*/
- void endResChain(::Minisat::CRef clause);
- void endResChain(::Minisat::Lit lit);
+ void endResChain(Minisat::CRef clause);
+ void endResChain(Minisat::Lit lit);
/**
* Stores in the current derivation the redundant literals that were
* eliminated from the conflict clause during conflict clause minimization.
* @param lit the eliminated literal
*/
- void storeLitRedundant(::Minisat::Lit lit);
+ void storeLitRedundant(Minisat::Lit lit);
/// update the CRef Id maps when Minisat does memory reallocation x
- void updateCRef(::Minisat::CRef old_ref, ::Minisat::CRef new_ref);
+ void updateCRef(Minisat::CRef old_ref, Minisat::CRef new_ref);
void finishUpdateCRef();
/**
*
* @param conflict
*/
- void finalizeProof(::Minisat::CRef conflict);
+ void finalizeProof(Minisat::CRef conflict);
/// clause registration methods
- ClauseId registerClause(const ::Minisat::CRef clause, ClauseKind kind, uint64_t proof_id);
- ClauseId registerUnitClause(const ::Minisat::Lit lit, ClauseKind kind, uint64_t proof_id);
+ ClauseId registerClause(const Minisat::CRef clause, ClauseKind kind, uint64_t proof_id);
+ ClauseId registerUnitClause(const Minisat::Lit lit, ClauseKind kind, uint64_t proof_id);
- void storeUnitConflict(::Minisat::Lit lit, ClauseKind kind, uint64_t proof_id);
+ void storeUnitConflict(Minisat::Lit lit, ClauseKind kind, uint64_t proof_id);
/**
* Marks the deleted clauses as deleted. Note we may still use them in the final
* resolution.
* @param clause
*/
- void markDeleted(::Minisat::CRef clause);
+ void markDeleted(Minisat::CRef clause);
bool isDeleted(ClauseId id) { return d_deleted.find(id) != d_deleted.end(); }
/**
* Constructs the resolution of ~q and resolves it with the current
* resolution thus eliminating q from the current clause
* @param q the literal to be resolved out
*/
- void resolveOutUnit(::Minisat::Lit q);
+ void resolveOutUnit(Minisat::Lit q);
/**
* Constructs the resolution of the literal lit. Called when a clause
* containing lit becomes satisfied and is removed.
* @param lit
*/
- void storeUnitResolution(::Minisat::Lit lit);
+ void storeUnitResolution(Minisat::Lit lit);
ProofProxy* getProxy() {return d_proxy; }
IdHashSet d_seenTheoryConflicts;
IdHashSet d_seenLemmas;
- inline std::string varName(::Minisat::Lit lit);
+ inline std::string varName(Minisat::Lit lit);
inline std::string clauseName(ClauseId id);
void collectClauses(ClauseId id);
private:
void printResolution(ClauseId id, std::ostream& out, std::ostream& paren);
public:
- LFSCSatProof(::Minisat::Solver* solver, bool checkRes = false)
+ LFSCSatProof(Minisat::Solver* solver, bool checkRes = false)
: SatProof(solver, checkRes)
{}
virtual void printResolutions(std::ostream& out, std::ostream& paren);