(! f1 formula
(! f2 formula
formula)))
-
+
(define formula_op3
(! f1 formula
(! f2 formula
(! f3 formula
formula))))
-
+
(declare not formula_op1)
(declare and formula_op2)
(declare or formula_op2)
(! u (th_holds (not (p_app x)))
(th_holds (= Bool x t_false)))))
+(declare f_to_b
+ (! f formula
+ (term Bool)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; CNF Clausification
(! vbv (bvatom v bv_v)
(holds cln))))))
(holds cln))))
-
-
+
+
; clausify a formula directly
(declare clausify_form
(! f formula
(! a (atom v f)
(! u (th_holds f)
(holds (clc (pos v) cln)))))))
-
+
(declare clausify_form_not
(! f formula
(! v var
(! a (atom v f)
(! u (th_holds (not f))
(holds (clc (neg v) cln)))))))
-
+
(declare clausify_false
(! u (th_holds false)
(holds cln)))
(! u2 (! v (th_holds f) (holds cln))
(holds cln)))))
-
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;
; Natural deduction rules : used for CNF
(! f2 formula
(! u2 (th_holds (not (or f1 f2)))
(th_holds (and (not f1) (not f2)))))))
-
+
;; and elimination
(declare and_elim_1
(! f2 formula
(! u2 (th_holds (not (and f1 f2)))
(th_holds (or (not f1) (not f2)))))))
-
+
;; impl elimination
(declare impl_intro (! f1 formula
(! f2 formula
(! u (th_holds (not (impl f1 f2)))
(th_holds (and f1 (not f2)))))))
-
+
;; iff elimination
(declare iff_elim_1
(! u (! o (holds (clc (neg bv_v) cln)) ;; l binding to be used in proof
(holds C))
(holds (clc (pos v) C))))))))))
-
+
(declare bv_ast
(! v var
- (! bv_v var
+ (! bv_v var
(! f formula
(! C clause
(! r (atom v f) ; this is specified
;; ...
;; (or_elim_1 _ _ l2
;; (or_elim_1 _ _ l1 A))))) ln)
-;;
+;;
;;))))))) (\ C
;;
;; We now have the free variable C, which should be the clause (v1 V ... V vn).
;; (contra _ l3
;; (or_elim_1 _ _ l2
;; (or_elim_1 _ _ (not_not_intro l1) A))))
-;;
+;;
;;))))))) (\ C
;;
;; C should be the clause (~v1 V v2 V ~v3 )
-
-
Assert ((term.getKind() == kind::SELECT) || (term.getKind() == kind::PARTIAL_SELECT_0) || (term.getKind() == kind::PARTIAL_SELECT_1) || (term.getKind() == kind::STORE));
switch (term.getKind()) {
- case kind::SELECT:
+ case kind::SELECT: {
Assert(term.getNumChildren() == 2);
+
+ bool convertToBool = (term[1].getType().isBoolean() && !d_proofEngine->printsAsBool(term[1]));
+
os << "(apply _ _ (apply _ _ (read ";
printSort(ArrayType(term[0].getType()).getIndexType(), os);
os << " ";
os << ") ";
printTerm(term[0], os, map);
os << ") ";
+ if (convertToBool) os << "(f_to_b ";
printTerm(term[1], os, map);
+ if (convertToBool) os << ")";
os << ") ";
return;
+ }
case kind::PARTIAL_SELECT_0:
Assert(term.getNumChildren() == 1);
}
void LFSCArrayProof::printAliasingDeclarations(std::ostream& os, std::ostream& paren, const ProofLetMap &globalLetMap) {
- // Nothing to do here at this point.
+ // Nothing to do here at this point.
+}
+
+bool LFSCArrayProof::printsAsBool(const Node &n)
+{
+ if (n.getKind() == kind::SELECT)
+ return true;
+
+ return false;
}
} /* CVC4 namespace */
virtual void printTermDeclarations(std::ostream& os, std::ostream& paren);
virtual void printDeferredDeclarations(std::ostream& os, std::ostream& paren);
virtual void printAliasingDeclarations(std::ostream& os, std::ostream& paren, const ProofLetMap &globalLetMap);
+
+ bool printsAsBool(const Node &n);
};
prop::SatVariable var = getLiteral(atom).getSatVariable();
//FIXME hideous
LFSCTheoryProofEngine* pe = (LFSCTheoryProofEngine*)ProofManager::currentPM()->getTheoryProofEngine();
- // pe->printLetTerm(atom.toExpr(), os);
+ if (pe->printsAsBool(atom.toExpr())) os << "(p_app ";
pe->printBoundTerm(atom.toExpr(), os, letMap);
+ if (pe->printsAsBool(atom.toExpr())) os << ")";
os << " (\\ " << ProofManager::getVarName(var, d_name);
os << " (\\ " << ProofManager::getAtomName(var, d_name) << "\n";
Debug("pf::pm") << "\t assertion = " << *it3 << std::endl;
std::set<Node> atoms;
+
NodePairSet rewrites;
// collects the atoms in the clauses
d_cnfProof->collectAtomsAndRewritesForLemmas(used_lemmas, atoms, rewrites);
//TODO
os << "(trust_f ";
+ if (ProofManager::currentPM()->getTheoryProofEngine()->printsAsBool(*it)) os << "(p_app ";
ProofManager::currentPM()->getTheoryProofEngine()->printTheoryTerm((*it).toExpr(), os, globalLetMap);
+ if (ProofManager::currentPM()->getTheoryProofEngine()->printsAsBool(*it)) os << ")";
os << ") ";
os << "(\\ "<< ProofManager::getPreprocessedAssertionName(*it, "") << "\n";
}
}
-void LFSCTheoryProofEngine::treatBoolsAsFormulas(bool value) {
- TheoryProofTable::const_iterator it = d_theoryProofTable.begin();
- TheoryProofTable::const_iterator end = d_theoryProofTable.end();
- for (; it != end; ++it) {
- it->second->treatBoolsAsFormulas(value);
- }
-}
-
void LFSCTheoryProofEngine::registerTermsFromAssertions() {
ProofManager::assertions_iterator it = ProofManager::currentPM()->begin_assertions();
ProofManager::assertions_iterator end = ProofManager::currentPM()->end_assertions();
// Assertions appear before the global let map, so we use a dummpMap to avoid letification here.
ProofLetMap dummyMap;
+
+ bool convertFromBool = (it->getType().isBoolean() && printsAsBool(*it));
+ if (convertFromBool) os << "(p_app ";
printBoundTerm(*it, os, dummyMap);
+ if (convertFromBool) os << ")";
os << ")\n";
paren << ")";
Kind k = term.getKind();
switch(k) {
- case kind::ITE:
+ case kind::ITE: {
os << (term.getType().isBoolean() ? "(ifte ": "(ite _ ");
+ bool booleanCase = term[0].getType().isBoolean();
+ if (booleanCase && printsAsBool(term[0])) os << "(p_app ";
printBoundTerm(term[0], os, map);
+ if (booleanCase && printsAsBool(term[0])) os << ")";
+
os << " ";
printBoundTerm(term[1], os, map);
os << " ";
printBoundTerm(term[2], os, map);
os << ")";
return;
+ }
+
+ case kind::EQUAL: {
+ bool booleanCase = term[0].getType().isBoolean();
- case kind::EQUAL:
os << "(";
- if( term[0].getType().isBoolean() ){
+ if (booleanCase) {
os << "iff ";
- }else{
+ } else {
os << "= ";
printSort(term[0].getType(), os);
os << " ";
}
+
+ if (booleanCase && printsAsBool(term[0])) os << "(p_app ";
printBoundTerm(term[0], os, map);
+ if (booleanCase && printsAsBool(term[0])) os << ")";
+
os << " ";
+
+ if (booleanCase && printsAsBool(term[1])) os << "(p_app ";
printBoundTerm(term[1], os, map);
+ if (booleanCase && printsAsBool(term[1])) os << ") ";
os << ")";
+
return;
+ }
case kind::DISTINCT:
// Distinct nodes can have any number of chidlren.
// arguments, so we have to flatten chained operators, like =.
Kind op = term.getOperator().getConst<Chain>().getOperator();
std::string op_str;
- if( op==kind::EQUAL && term[0].getType().isBoolean() ){
+ bool booleanCase;
+ if (op==kind::EQUAL && term[0].getType().isBoolean()) {
+ booleanCase = term[0].getType().isBoolean();
op_str = "iff";
- }else{
+ } else {
op_str = utils::toLFSCKind(op);
}
size_t n = term.getNumChildren();
paren << ")";
}
os << "(" << op_str << " ";
+ if (booleanCase && printsAsBool(term[i - 1])) os << "(p_app ";
printBoundTerm(term[i - 1], os, map);
+ if (booleanCase && printsAsBool(term[i - 1])) os << ")";
os << " ";
+ if (booleanCase && printsAsBool(term[i])) os << "(p_app ";
printBoundTerm(term[i], os, map);
+ if (booleanCase && printsAsBool(term[i])) os << ")";
os << ")";
if(i + 1 < n) {
os << " ";
id == theory::THEORY_BOOL);
}
+bool TheoryProofEngine::printsAsBool(const Node &n) {
+ if (!n.getType().isBoolean()) {
+ return false;
+ }
+
+ theory::TheoryId theory_id = theory::Theory::theoryOf(n);
+ return getTheoryProof(theory_id)->printsAsBool(n);
+}
+
BooleanProof::BooleanProof(TheoryProofEngine* proofEngine)
: TheoryProof(NULL, proofEngine)
{}
void LFSCBooleanProof::printOwnedTerm(Expr term, std::ostream& os, const ProofLetMap& map) {
Assert (term.getType().isBoolean());
if (term.isVariable()) {
- if (d_treatBoolsAsFormulas)
- os << "(p_app " << ProofManager::sanitize(term) <<")";
- else
- os << ProofManager::sanitize(term);
+ os << ProofManager::sanitize(term);
return;
}
std::ostringstream paren;
os << " ";
for (unsigned i = 0; i < term.getNumChildren(); ++i) {
+
+ if (printsAsBool(term[i])) os << "(p_app ";
d_proofEngine->printBoundTerm(term[i], os, map);
+ if (printsAsBool(term[i])) os << ")";
+
os << " ";
if(i < term.getNumChildren() - 2) {
os << "(" << utils::toLFSCKind(k) << " ";
// this is for binary and unary operators
for (unsigned i = 0; i < term.getNumChildren(); ++i) {
os << " ";
+ if (printsAsBool(term[i])) os << "(p_app ";
d_proofEngine->printBoundTerm(term[i], os, map);
+ if (printsAsBool(term[i])) os << ")";
}
os << ")";
}
return;
case kind::CONST_BOOLEAN:
- if (d_treatBoolsAsFormulas)
- os << (term.getConst<bool>() ? "true" : "false");
- else
- os << (term.getConst<bool>() ? "t_true" : "t_false");
+ os << (term.getConst<bool>() ? "true" : "false");
return;
default:
Unreachable("No boolean lemmas yet!");
}
+bool LFSCBooleanProof::printsAsBool(const Node &n)
+{
+ Kind k = n.getKind();
+ switch (k) {
+ case kind::BOOLEAN_TERM_VARIABLE:
+ case kind::VARIABLE:
+ return true;
+
+ default:
+ return false;
+ }
+}
+
void TheoryProof::printConstantDisequalityProof(std::ostream& os, Expr c1, Expr c2, const ProofLetMap &globalLetMap) {
// By default, we just print a trust statement. Specific theories can implement
// better proofs.
void printConstantDisequalityProof(std::ostream& os, Expr c1, Expr c2, const ProofLetMap &globalLetMap);
- virtual void treatBoolsAsFormulas(bool value) {};
-
virtual void printTheoryTerm(Expr term, std::ostream& os, const ProofLetMap& map) = 0;
+
+ bool printsAsBool(const Node &n);
};
class LFSCTheoryProofEngine : public TheoryProofEngine {
void performExtraRegistrations();
- void treatBoolsAsFormulas(bool value);
void finalizeBvConflicts(const IdToSatClause& lemmas, std::ostream& os);
private:
*/
virtual void printRewriteProof(std::ostream& os, const Node &n1, const Node &n2);
- virtual void treatBoolsAsFormulas(bool value) {}
+ // Return true if node prints as bool, false if it prints as a formula.
+ virtual bool printsAsBool(const Node &n) {
+ // Most nodes print as formulas, so this is the default.
+ return false;
+ }
};
class BooleanProof : public TheoryProof {
class LFSCBooleanProof : public BooleanProof {
public:
LFSCBooleanProof(TheoryProofEngine* proofEngine)
- : BooleanProof(proofEngine), d_treatBoolsAsFormulas(true)
+ : BooleanProof(proofEngine)
{}
virtual void printOwnedTerm(Expr term, std::ostream& os, const ProofLetMap& map);
virtual void printOwnedSort(Type type, std::ostream& os);
virtual void printDeferredDeclarations(std::ostream& os, std::ostream& paren);
virtual void printAliasingDeclarations(std::ostream& os, std::ostream& paren, const ProofLetMap &globalLetMap);
- void treatBoolsAsFormulas(bool value) {
- d_treatBoolsAsFormulas = value;
- }
-
-private:
- bool d_treatBoolsAsFormulas;
+ bool printsAsBool(const Node &n);
};
} /* CVC4 namespace */
Assert (theory::Theory::theoryOf(term) == theory::THEORY_UF);
if (term.getKind() == kind::VARIABLE ||
- term.getKind() == kind::SKOLEM) {
+ term.getKind() == kind::SKOLEM ||
+ term.getKind() == kind::BOOLEAN_TERM_VARIABLE) {
os << term;
return;
}
- if (term.getKind() == kind::BOOLEAN_TERM_VARIABLE) {
- os << "(p_app " << term << ")";
- return;
- }
Assert (term.getKind() == kind::APPLY_UF);
- d_proofEngine->treatBoolsAsFormulas(false);
if(term.getType().isBoolean()) {
os << "(p_app ";
}
os << func << " ";
for (unsigned i = 0; i < term.getNumChildren(); ++i) {
+ bool convertToBool = (term[i].getType().isBoolean() && !d_proofEngine->printsAsBool(term[i]));
+ if (convertToBool) os << "(f_to_b ";
d_proofEngine->printBoundTerm(term[i], os, map);
+ if (convertToBool) os << ")";
os << ")";
}
if(term.getType().isBoolean()) {
os << ")";
}
- d_proofEngine->treatBoolsAsFormulas(true);
}
void LFSCUFProof::printOwnedSort(Type type, std::ostream& os) {
// Nothing to do here at this point.
}
+bool LFSCUFProof::printsAsBool(const Node &n)
+{
+ Debug("gk::temp") << "\nUF printsAsBool: " << n << std::endl;
+ if (n.getKind() == kind::BOOLEAN_TERM_VARIABLE)
+ return true;
+
+ return false;
+}
+
} /* namespace CVC4 */
virtual void printTermDeclarations(std::ostream& os, std::ostream& paren);
virtual void printDeferredDeclarations(std::ostream& os, std::ostream& paren);
virtual void printAliasingDeclarations(std::ostream& os, std::ostream& paren, const ProofLetMap &globalLetMap);
+
+ bool printsAsBool(const Node &n);
};
-; COMMAND-LINE: --no-check-proofs
; EXPECT: unsat
(set-logic QF_UF)
(set-info :smt-lib-version 2.0)
-; COMMAND-LINE: --no-check-proofs
; EXPECT: unsat
(set-logic QF_UF)
(set-info :smt-lib-version 2.0)
-; COMMAND-LINE: --no-check-proofs
; EXPECT: unsat
(set-logic QF_UF)
(set-info :status unsat)