summaryrefslogtreecommitdiff
path: root/src/proof
diff options
context:
space:
mode:
authorlianah <lianahady@gmail.com>2013-10-09 13:48:26 -0400
committerlianah <lianahady@gmail.com>2013-10-09 13:48:26 -0400
commit08c8433e4ab849024930a8c4dbe8756e13d08099 (patch)
tree2515d746c9b190e8770c5c690046410449900d7a /src/proof
parent000f574406c29df4c60947169ef527ee5316beb7 (diff)
fixed uf proof bug: now storing deleted theory lemmas
Diffstat (limited to 'src/proof')
-rw-r--r--src/proof/sat_proof.cpp89
-rw-r--r--src/proof/sat_proof.h10
-rw-r--r--src/proof/theory_proof.cpp34
3 files changed, 44 insertions, 89 deletions
diff --git a/src/proof/sat_proof.cpp b/src/proof/sat_proof.cpp
index e8c63bb74..e1534a635 100644
--- a/src/proof/sat_proof.cpp
+++ b/src/proof/sat_proof.cpp
@@ -621,32 +621,20 @@ void SatProof::markDeleted(CRef clause) {
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)) {
@@ -671,6 +659,14 @@ void SatProof::addClauseToCnfProof(ClauseId id, ClauseKind kind) {
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();
@@ -748,54 +744,6 @@ void LFSCSatProof::printResolution(ClauseId id, std::ostream& out, std::ostream&
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) {
@@ -805,13 +753,6 @@ void LFSCSatProof::printResolutions(std::ostream& out, std::ostream& paren) {
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 */
diff --git a/src/proof/sat_proof.h b/src/proof/sat_proof.h
index 5a1fa4680..c4936fd88 100644
--- a/src/proof/sat_proof.h
+++ b/src/proof/sat_proof.h
@@ -81,14 +81,14 @@ public:
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;
@@ -116,11 +116,12 @@ class SatProof {
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
@@ -136,7 +137,7 @@ protected:
// temporary map for updating CRefs
ClauseIdMap d_temp_clauseId;
- IdClauseMap d_temp_idClause;
+ IdCRefMap d_temp_idClause;
// unit conflict
ClauseId d_unitConflictId;
@@ -223,6 +224,7 @@ public:
* @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
diff --git a/src/proof/theory_proof.cpp b/src/proof/theory_proof.cpp
index ecd9f9810..5b5a2ae15 100644
--- a/src/proof/theory_proof.cpp
+++ b/src/proof/theory_proof.cpp
@@ -65,19 +65,17 @@ void LFSCTheoryProof::printTerm(Expr term, std::ostream& os) {
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) {
@@ -95,7 +93,7 @@ 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) {
@@ -106,6 +104,13 @@ void LFSCTheoryProof::printFormula(Expr atom, std::ostream& os) {
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 ||
@@ -134,8 +139,15 @@ void LFSCTheoryProof::printFormula(Expr atom, std::ostream& os) {
}
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");
}
}
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback