if (d_clauseId.find(clause) != d_clauseId.end()) {
ClauseId id = getClauseId(clause);
Assert (d_deleted.find(id) == d_deleted.end());
- d_deleted.insert(id);
+ d_deleted.insert(id);
+ if (isLemmaClause(id)) {
+ const Clause& minisat_cl = getClause(clause);
+ SatClause* sat_cl = new SatClause();
+ MinisatSatSolver::toSatClause(minisat_cl, *sat_cl);
+ d_deletedTheoryLemmas.insert(std::make_pair(id, sat_cl));
+ }
}
}
void SatProof::constructProof() {
- // if (isLemmaClause(d_conflictId)) {
- // addClauseToCnfProof(d_emptyClauseId, THEORY_LEMMA);
- // }
- // if (isInputClause(d_emptyClauseId)) {
- // addClauseToCnfProof(d_emptyClauseId, INPUT);
- // }
collectClauses(d_emptyClauseId);
}
-// std::string SatProof::varName(::Minisat::Lit lit) {
-// ostringstream os;
-// if (sign(lit)) {
-// os << "(neg "<< ProofManager::getVarPrefix() <<var(lit) << ")" ;
-// }
-// else {
-// os << "(pos "<< ProofManager::getVarPrefix() <<var(lit) << ")";
-// }
-// return os.str();
-// }
-
-
std::string SatProof::clauseName(ClauseId id) {
ostringstream os;
if (isInputClause(id)) {
getCnfProof()->addClause(id, clause, kind);
return;
}
+
+ if (isDeleted(id)) {
+ Assert (kind == THEORY_LEMMA);
+ SatClause* clause = d_deletedTheoryLemmas.find(id)->second;
+ getCnfProof()->addClause(id, clause, kind);
+ return;
+ }
+
CRef ref = getClauseRef(id);
const Clause& minisat_cl = getClause(ref);
SatClause* clause = new SatClause();
paren << "))"; // closing parethesis for lemma binding and satlem
}
-
-// void LFSCSatProof::printInputClause(ClauseId id) {
-// if (isUnit(id)) {
-// ::Minisat::Lit lit = getUnit(id);
-// d_clauseSS << "(% " << clauseName(id) << " (holds (clc ";
-// d_clauseSS << varName(lit) << "cln ))";
-// d_paren << ")";
-// return;
-// }
-
-// ostringstream os;
-// CRef ref = getClauseRef(id);
-// Assert (ref != CRef_Undef);
-// Clause& c = getClause(ref);
-
-// d_clauseSS << "(% " << clauseName(id) << " (holds ";
-// os << ")"; // closing paren for holds
-// d_paren << ")"; // closing paren for (%
-
-// for(int i = 0; i < c.size(); i++) {
-// d_clauseSS << " (clc " << varName(c[i]) <<" ";
-// os <<")";
-// d_seenVars.insert(var(c[i]));
-// }
-// d_clauseSS << "cln";
-// d_clauseSS << os.str() << "\n";
-// }
-
-
-// void LFSCSatProof::printInputClauses() {
-// for (IdHashSet::iterator it = d_seenInput.begin(); it!= d_seenInput.end(); ++it) {
-// printInputClause(*it);
-// }
-// }
-
-
-// void LFSCSatProof::flush(std::ostream& out) {
-// out << "(check \n";
-// d_paren <<")";
-// out << d_varSS.str();
-// out << d_clauseSS.str();
-// out << "(: (holds cln) \n";
-// out << d_learntSS.str();
-// d_paren << "))";
-// out << d_paren.str();
-// out << "\n";
-// }
-
void LFSCSatProof::printResolutions(std::ostream& out, std::ostream& paren) {
for(IdSet::iterator it = d_seenLearnt.begin(); it!= d_seenLearnt.end(); ++it) {
if(*it != d_emptyClauseId) {
printResolution(d_emptyClauseId, out, paren);
}
-// void LFSCSatProof::printVariables(std::ostream& out, std::ostream& paren) {
-// for (VarSet::iterator it = d_seenVars.begin(); it != d_seenVars.end(); ++it) {
-// out << "(% " << ProofManager::getVarPrefix() << *it <<" var \n";
-// paren << ")";
-// }
-// }
-
} /* CVC4 namespace */
LitSet* getRedundant() { return d_redundantLits; }
};/* class ResChain */
-typedef std::hash_map < ClauseId, ::Minisat::CRef > IdClauseMap;
+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;
protected:
::Minisat::Solver* d_solver;
// clauses
- IdClauseMap d_idClause;
+ IdCRefMap d_idClause;
ClauseIdMap d_clauseId;
IdUnitMap d_idUnit;
UnitIdMap d_unitId;
IdHashSet d_deleted;
+ IdToSatClause d_deletedTheoryLemmas;
IdHashSet d_inputClauses;
IdHashSet d_lemmaClauses;
// resolutions
// temporary map for updating CRefs
ClauseIdMap d_temp_clauseId;
- IdClauseMap d_temp_idClause;
+ IdCRefMap d_temp_idClause;
// unit conflict
ClauseId d_unitConflictId;
* @param 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
os << term;
return;
}
- std::ostringstream paren;
+
Assert (term.getKind() == kind::APPLY_UF);
Expr func = term.getOperator();
- os << "(apply _ _ " << func << " ";
+ for (unsigned i = 0; i < term.getNumChildren(); ++i) {
+ os<< "(apply _ _ ";
+ }
+ os << func << " ";
for (unsigned i = 0; i < term.getNumChildren(); ++i) {
printTerm(term[i], os);
- if (i < term.getNumChildren() - 1) {
- os << "(apply _ _ " << func << " ";
- paren << ")";
- }
- os << ")" ;
+ os << ")";
}
- os << paren.str();
}
std::string toLFSCKind(Kind kind) {
void LFSCTheoryProof::printFormula(Expr atom, std::ostream& os) {
// should make this more general and overall sane
- Assert (atom.getType().isBoolean());
+ Assert (atom.getType().isBoolean() && "Only printing booleans." );
Kind kind = atom.getKind();
// this is the only predicate we have
if (kind == kind::EQUAL) {
os <<" ";
printTerm(atom[1], os);
os <<")";
+ } else if ( kind == kind::DISTINCT) {
+ os <<"(not (= ";
+ os << atom[0].getType() <<" ";
+ printTerm(atom[0], os);
+ os <<" ";
+ printTerm(atom[1], os);
+ os <<"))";
} else if ( kind == kind::OR ||
kind == kind::AND ||
kind == kind::XOR ||
}
os <<")";
}
- } else {
- Assert (false);
+ } else if (kind == kind::CONST_BOOLEAN) {
+ if (atom.getConst<bool>())
+ os << "true";
+ else
+ os << "false";
+ }
+ else {
+ std::cout << kind << "\n";
+ Assert (false && "Unsupported kind");
}
}
void Solver::detachClause(CRef cr, bool strict) {
- PROOF( ProofManager::getSatProof()->markDeleted(cr); )
-
const Clause& c = ca[cr];
+ PROOF( ProofManager::getSatProof()->markDeleted(cr); )
Debug("minisat") << "Solver::detachClause(" << c << ")" << std::endl;
assert(c.size() > 1);
Result SmtEngine::checkSat(const Expr& ex) throw(TypeCheckingException, ModalException, LogicException) {
Assert(ex.isNull() || ex.getExprManager() == d_exprManager);
- // PROOF (
- ProofManager* pm = ProofManager::currentPM();
- TheoryProof* pf = pm->getTheoryProof();
- pf->assertFormula(ex);
- // );
+#ifdef CVC4_PROOF
+ // if (options::proof()) { <-- SEGFAULT!!
+ ProofManager::currentPM()->getTheoryProof()->assertFormula(ex);
+ //}
+#endif
SmtScope smts(this);
finalOptionsAreSet();
doPendingPops();
Result SmtEngine::assertFormula(const Expr& ex) throw(TypeCheckingException, LogicException) {
Assert(ex.getExprManager() == d_exprManager);
- //PROOF (
- ProofManager::currentPM()->getTheoryProof()->assertFormula(ex); //);
+#ifdef CVC4_PROOF
+ // if (options::proof()) { <-- SEGFAULT!!!
+ ProofManager::currentPM()->getTheoryProof()->assertFormula(ex);
+ // }
+#endif
SmtScope smts(this);
finalOptionsAreSet();
doPendingPops();