1 /********************* */
2 /*! \file cnf_proof.cpp
4 ** Original author: Liana Hadarean
5 ** Major contributors: Morgan Deters
6 ** Minor contributors (to current version): none
7 ** This file is part of the CVC4 project.
8 ** Copyright (c) 2009-2014 New York University and The University of Iowa
9 ** See the file COPYING in the top-level source directory for licensing
10 ** information.\endverbatim
12 ** \brief [[ Add one-line brief description here ]]
14 ** [[ Add lengthier description here ]]
15 ** \todo document this file
18 #include "proof/cnf_proof.h"
19 #include "proof/theory_proof.h"
20 #include "proof/proof_manager.h"
21 #include "prop/sat_solver_types.h"
22 #include "prop/minisat/minisat.h"
23 #include "prop/cnf_stream.h"
25 using namespace CVC4::prop
;
29 CnfProof::CnfProof(CnfStream
* stream
)
34 Expr
CnfProof::getAtom(prop::SatVariable var
) {
35 prop::SatLiteral
lit (var
);
36 Node node
= d_cnfStream
->getNode(lit
);
37 Expr atom
= node
.toExpr();
41 CnfProof::~CnfProof() {
44 LFSCCnfProof::iterator
LFSCCnfProof::begin_atom_mapping() {
45 return iterator(*this, ProofManager::currentPM()->begin_vars());
48 LFSCCnfProof::iterator
LFSCCnfProof::end_atom_mapping() {
49 return iterator(*this, ProofManager::currentPM()->end_vars());
52 void LFSCCnfProof::printAtomMapping(std::ostream
& os
, std::ostream
& paren
) {
53 ProofManager::var_iterator it
= ProofManager::currentPM()->begin_vars();
54 ProofManager::var_iterator end
= ProofManager::currentPM()->end_vars();
56 for (;it
!= end
; ++it
) {
59 if (ProofManager::currentPM()->getLogic().compare("QF_UF") == 0) {
60 Expr atom
= getAtom(*it
);
61 LFSCTheoryProof::printTerm(atom
, os
);
63 // print fake atoms for all other logics
67 os
<< " (\\ " << ProofManager::getVarName(*it
) << " (\\ " << ProofManager::getAtomName(*it
) << "\n";
72 void LFSCCnfProof::printClauses(std::ostream
& os
, std::ostream
& paren
) {
73 printInputClauses(os
, paren
);
74 printTheoryLemmas(os
, paren
);
77 void LFSCCnfProof::printInputClauses(std::ostream
& os
, std::ostream
& paren
) {
78 os
<< " ;; Input Clauses \n";
79 ProofManager::clause_iterator it
= ProofManager::currentPM()->begin_input_clauses();
80 ProofManager::clause_iterator end
= ProofManager::currentPM()->end_input_clauses();
82 for (; it
!= end
; ++it
) {
83 ClauseId id
= it
->first
;
84 const prop::SatClause
* clause
= it
->second
;
86 std::ostringstream clause_paren
;
87 printClause(*clause
, os
, clause_paren
);
88 os
<< " (clausify_false trust)" << clause_paren
.str();
89 os
<< "( \\ " << ProofManager::getInputClauseName(id
) << "\n";
95 void LFSCCnfProof::printTheoryLemmas(std::ostream
& os
, std::ostream
& paren
) {
96 os
<< " ;; Theory Lemmas \n";
97 ProofManager::clause_iterator it
= ProofManager::currentPM()->begin_lemmas();
98 ProofManager::clause_iterator end
= ProofManager::currentPM()->end_lemmas();
100 for (; it
!= end
; ++it
) {
101 ClauseId id
= it
->first
;
102 const prop::SatClause
* clause
= it
->second
;
103 os
<< "(satlem _ _ ";
104 std::ostringstream clause_paren
;
105 printClause(*clause
, os
, clause_paren
);
106 os
<< " (clausify_false trust)" << clause_paren
.str();
107 os
<< "( \\ " << ProofManager::getLemmaClauseName(id
) <<"\n";
112 void LFSCCnfProof::printClause(const prop::SatClause
& clause
, std::ostream
& os
, std::ostream
& paren
) {
113 for (unsigned i
= 0; i
< clause
.size(); ++i
) {
114 prop::SatLiteral lit
= clause
[i
];
115 prop::SatVariable var
= lit
.getSatVariable();
116 if (lit
.isNegated()) {
117 os
<< "(ast _ _ _ " << ProofManager::getAtomName(var
) <<" (\\ " << ProofManager::getLitName(lit
) << " ";
120 os
<< "(asf _ _ _ " << ProofManager::getAtomName(var
) <<" (\\ " << ProofManager::getLitName(lit
) << " ";
126 } /* CVC4 namespace */