This PR removes more uses of Expr, mostly related to UnsatCore.
It makes UnsatCore a cvc4_private object storing Node instead of Expr.
#include "options/main_options.h"
#include "options/options.h"
#include "options/smt_options.h"
+#include "proof/unsat_core.h"
#include "smt/model.h"
#include "smt/smt_engine.h"
#include "smt/smt_mode.h"
* return std::vector<Term>(core.begin(), core.end());
* here since constructor is private */
std::vector<Term> res;
- for (const Expr& e : core)
+ for (const Node& e : core)
{
res.push_back(Term(this, e));
}
#include "printer/cvc/cvc_printer.h"
#include "printer/smt2/smt2_printer.h"
#include "printer/tptp/tptp_printer.h"
+#include "proof/unsat_core.h"
#include "smt/command.h"
#include "smt/node_command.h"
void Printer::toStream(std::ostream& out, const UnsatCore& core) const
{
for(UnsatCore::iterator i = core.begin(); i != core.end(); ++i) {
- toStreamCmdAssert(out, Node::fromExpr(*i));
+ toStreamCmdAssert(out, *i);
out << std::endl;
}
}/* Printer::toStream(UnsatCore) */
#include "options/printer_options.h"
#include "options/smt_options.h"
#include "printer/dagification_visitor.h"
+#include "proof/unsat_core.h"
#include "smt/command.h"
#include "smt/node_command.h"
#include "smt/smt_engine.h"
#include "expr/node_manager.h" // for VarNameAttr
#include "options/language.h" // for LANG_AST
#include "options/smt_options.h" // for unsat cores
+#include "proof/unsat_core.h"
#include "smt/command.h"
#include "smt/node_command.h"
#include "smt/smt_engine.h"
d_cnfProof->popCurrentAssertion();
}
-
-void ProofManager::traceDeps(TNode n, CDExprSet* coreAssertions) {
+void ProofManager::traceDeps(TNode n, CDNodeSet* coreAssertions)
+{
Debug("cores") << "trace deps " << n << std::endl;
if ((n.isConst() && n == NodeManager::currentNM()->mkConst<bool>(true)) ||
(n.getKind() == kind::NOT && n[0] == NodeManager::currentNM()->mkConst<bool>(false))) {
return;
}
- if(d_inputCoreFormulas.find(n.toExpr()) != d_inputCoreFormulas.end()) {
+ if (d_inputCoreFormulas.find(n) != d_inputCoreFormulas.end())
+ {
// originating formula was in core set
Debug("cores") << " -- IN INPUT CORE LIST!" << std::endl;
- coreAssertions->insert(n.toExpr());
+ coreAssertions->insert(n);
} else {
Debug("cores") << " -- NOT IN INPUT CORE LIST!" << std::endl;
if(d_deps.find(n) == d_deps.end()) {
return d_satProof->derivedEmptyClause();
}
-std::vector<Expr> ProofManager::extractUnsatCore() {
- std::vector<Expr> result;
+std::vector<Node> ProofManager::extractUnsatCore()
+{
+ std::vector<Node> result;
output_core_iterator it = begin_unsat_core();
output_core_iterator end = end_unsat_core();
while ( it != end ) {
}
}
-void ProofManager::addCoreAssertion(Expr formula) {
+void ProofManager::addCoreAssertion(Node formula)
+{
Debug("cores") << "assert: " << formula << std::endl;
- d_deps[Node::fromExpr(formula)]; // empty vector of deps
+ d_deps[formula]; // empty vector of deps
d_inputCoreFormulas.insert(formula);
}
}
}
-void ProofManager::addUnsatCore(Expr formula) {
+void ProofManager::addUnsatCore(Node formula)
+{
Assert(d_inputCoreFormulas.find(formula) != d_inputCoreFormulas.end());
d_outputCoreFormulas.insert(formula);
}
}/* CVC4::prop namespace */
typedef std::unordered_map<ClauseId, prop::SatClause*> IdToSatClause;
-typedef context::CDHashSet<Expr, ExprHashFunction> CDExprSet;
+typedef context::CDHashSet<Node, NodeHashFunction> CDNodeSet;
typedef context::CDHashMap<Node, std::vector<Node>, NodeHashFunction> CDNodeToNodes;
typedef std::unordered_set<ClauseId> IdHashSet;
std::unique_ptr<CnfProof> d_cnfProof;
// information that will need to be shared across proofs
- CDExprSet d_inputCoreFormulas;
- CDExprSet d_outputCoreFormulas;
+ CDNodeSet d_inputCoreFormulas;
+ CDNodeSet d_outputCoreFormulas;
int d_nextId;
static CnfProof* getCnfProof();
/** Public unsat core methods **/
- void addCoreAssertion(Expr formula);
+ void addCoreAssertion(Node formula);
void addDependence(TNode n, TNode dep);
- void addUnsatCore(Expr formula);
+ void addUnsatCore(Node formula);
// trace dependences back to unsat core
- void traceDeps(TNode n, CDExprSet* coreAssertions);
+ void traceDeps(TNode n, CDNodeSet* coreAssertions);
void traceUnsatCore();
- typedef CDExprSet::const_iterator output_core_iterator;
+ typedef CDNodeSet::const_iterator output_core_iterator;
output_core_iterator begin_unsat_core() const
{
return d_outputCoreFormulas.end();
}
size_t size_unsat_core() const { return d_outputCoreFormulas.size(); }
- std::vector<Expr> extractUnsatCore();
+ std::vector<Node> extractUnsatCore();
bool unsatCoreAvailable() const;
void getLemmasInUnsatCore(std::vector<Node>& lemmas);
** \todo document this file
**/
-#include "cvc4_public.h"
+#include "cvc4_private.h"
#ifndef CVC4__UNSAT_CORE_H
#define CVC4__UNSAT_CORE_H
#include <iosfwd>
#include <vector>
-#include "expr/expr.h"
+#include "expr/node.h"
namespace CVC4 {
class SmtEngine;
-class UnsatCore;
-
-std::ostream& operator<<(std::ostream& out, const UnsatCore& core) CVC4_PUBLIC;
-
-class CVC4_PUBLIC UnsatCore {
- friend std::ostream& operator<<(std::ostream&, const UnsatCore&);
+class UnsatCore
+{
/** The SmtEngine we're associated with */
SmtEngine* d_smt;
- std::vector<Expr> d_core;
+ std::vector<Node> d_core;
void initMessage() const;
public:
UnsatCore() : d_smt(NULL) {}
- UnsatCore(SmtEngine* smt, std::vector<Expr> core) : d_smt(smt), d_core(core) {
+ UnsatCore(SmtEngine* smt, const std::vector<Node>& core)
+ : d_smt(smt), d_core(core)
+ {
initMessage();
}
size_t size() const { return d_core.size(); }
- typedef std::vector<Expr>::const_iterator iterator;
- typedef std::vector<Expr>::const_iterator const_iterator;
+ typedef std::vector<Node>::const_iterator iterator;
+ typedef std::vector<Node>::const_iterator const_iterator;
const_iterator begin() const;
const_iterator end() const;
};/* class UnsatCore */
+/** Print the unsat core to stream out */
+std::ostream& operator<<(std::ostream& out, const UnsatCore& core);
+
}/* CVC4 namespace */
#endif /* CVC4__UNSAT_CORE_H */
#include "options/options.h"
#include "options/smt_options.h"
#include "printer/printer.h"
+#include "proof/unsat_core.h"
#include "smt/dump.h"
#include "smt/model.h"
#include "smt/smt_engine.h"
{
try
{
- d_result = UnsatCore(solver->getSmtEngine(),
- api::termVectorToExprs(solver->getUnsatCore()));
+ d_solver = solver;
+ d_result = solver->getUnsatCore();
d_commandStatus = CommandSuccess::instance();
}
}
else
{
- d_result.toStream(out);
+ UnsatCore ucr(d_solver->getSmtEngine(), api::termVectorToNodes(d_result));
+ ucr.toStream(out);
}
}
-const UnsatCore& GetUnsatCoreCommand::getUnsatCore() const
+const std::vector<api::Term>& GetUnsatCoreCommand::getUnsatCore() const
{
// of course, this will be empty if the command hasn't been invoked yet
return d_result;
Command* GetUnsatCoreCommand::clone() const
{
GetUnsatCoreCommand* c = new GetUnsatCoreCommand;
+ c->d_solver = d_solver;
c->d_result = d_result;
return c;
}
#include "api/cvc4cpp.h"
#include "expr/expr.h"
#include "expr/type.h"
-#include "expr/variable_type_map.h"
-#include "proof/unsat_core.h"
#include "util/result.h"
#include "util/sexpr.h"
class Term;
} // namespace api
+class UnsatCore;
class SmtEngine;
class Command;
class CommandStatus;
{
public:
GetUnsatCoreCommand();
- const UnsatCore& getUnsatCore() const;
+ const std::vector<api::Term>& getUnsatCore() const;
void invoke(api::Solver* solver) override;
void printResult(std::ostream& out, uint32_t verbosity = 2) const override;
OutputLanguage language = language::output::LANG_AUTO) const override;
protected:
- // the result of the unsat core call
- UnsatCore d_result;
+ /** The solver we were invoked with */
+ api::Solver* d_solver;
+ /** the result of the unsat core call */
+ std::vector<api::Term> d_result;
}; /* class GetUnsatCoreCommand */
class CVC4_PUBLIC GetAssertionsCommand : public Command
std::vector<Node>& assumps = d_asserts->getAssumptions();
for (const Node& e : assumps)
{
- if (std::find(core.begin(), core.end(), e.toExpr()) != core.end())
+ if (std::find(core.begin(), core.end(), e) != core.end())
{
res.push_back(e);
}
Notice() << "SmtEngine::checkUnsatCore(): pushing core assertions (size == " << core.size() << ")" << endl;
for(UnsatCore::iterator i = core.begin(); i != core.end(); ++i) {
- Node assertionAfterExpansion = expandDefinitions(Node::fromExpr(*i));
+ Node assertionAfterExpansion = expandDefinitions(*i);
Notice() << "SmtEngine::checkUnsatCore(): pushing core member " << *i
<< ", expanded to " << assertionAfterExpansion << "\n";
coreChecker.assertFormula(assertionAfterExpansion);
#include "expr/expr.h"
#include "expr/expr_manager.h"
#include "options/options.h"
-#include "proof/unsat_core.h"
#include "smt/logic_exception.h"
#include "smt/output_manager.h"
#include "smt/smt_mode.h"
class TheoryEngine;
class ProofManager;
+class UnsatCore;
class LogicRequest;
class StatisticsRegistry;
}
}
- /**
- * Negates an Expr, doing all the double-negation elimination that's
- * possible.
- *
- * @param e the Expr to negate (cannot be the null Expr)
- */
- static Expr negate(Expr e)
- {
- ExprManagerScope ems(e);
- return negate(Node::fromExpr(e)).toExpr();
- }
-
/**
* Simplify an OR, AND, or IMPLIES. This function is the identity
* for all other kinds.
#include "expr/expr.h"
#include "expr/expr_manager.h"
-#include "expr/variable_type_map.h"
#include "smt/smt_engine.h"
#include "theory/quantifiers/sygus_sampler.h"
bool hasQuery = false;
for (UnsatCore::const_iterator i = uc.begin(); i != uc.end(); ++i)
{
- Node uassert = Node::fromExpr(*i);
+ Node uassert = *i;
Trace("sygus-ccore-debug") << " uc " << uassert << std::endl;
if (queryAsserts.find(uassert) != queryAsserts.end())
{
#include "expr/expr_manager.h"
#include "expr/node.h"
-#include "expr/variable_type_map.h"
#include "smt/smt_engine.h"
namespace CVC4 {