e3b0f34495b6f2631b6b1e5944d0fbb680cf9f06
1 /********************* */
4 ** Original author: Dejan Jovanovic
5 ** Major contributors: Morgan Deters, Liana Hadarean
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
17 #include "cvc4_private.h"
19 #ifndef __CVC4__PROP__SAT_SOLVER_H
20 #define __CVC4__PROP__SAT_SOLVER_H
24 #include "util/statistics_registry.h"
25 #include "context/cdlist.h"
26 #include "prop/sat_solver_types.h"
27 #include "expr/node.h"
38 /** Virtual destructor */
39 virtual ~SatSolver() { }
41 /** Assert a clause in the solver. */
42 virtual void addClause(SatClause
& clause
, bool removable
, uint64_t proof_id
) = 0;
45 * Create a new boolean variable in the solver.
46 * @param isTheoryAtom is this a theory atom that needs to be asserted to theory
47 * @param preRegister whether to preregister the atom with the theory
48 * @param canErase whether the sat solver can safely eliminate this variable
51 virtual SatVariable
newVar(bool isTheoryAtom
, bool preRegister
, bool canErase
) = 0;
53 /** Create a new (or return an existing) boolean variable representing the constant true */
54 virtual SatVariable
trueVar() = 0;
56 /** Create a new (or return an existing) boolean variable representing the constant false */
57 virtual SatVariable
falseVar() = 0;
59 /** Check the satisfiability of the added clauses */
60 virtual SatValue
solve() = 0;
62 /** Check the satisfiability of the added clauses */
63 virtual SatValue
solve(long unsigned int&) = 0;
65 /** Instruct the solver that it should bump its consumed resource count. */
66 virtual void spendResource() = 0;
68 /** Interrupt the solver */
69 virtual void interrupt() = 0;
71 /** Call value() during the search.*/
72 virtual SatValue
value(SatLiteral l
) = 0;
74 /** Call modelValue() when the search is done.*/
75 virtual SatValue
modelValue(SatLiteral l
) = 0;
77 /** Get the current assertion level */
78 virtual unsigned getAssertionLevel() const = 0;
80 };/* class SatSolver */
83 class BVSatSolverInterface
: public SatSolver
{
86 /** Interface for notifications */
93 * If the notify returns false, the solver will break out of whatever it's currently doing
94 * with an "unknown" answer.
96 virtual bool notify(SatLiteral lit
) = 0;
99 * Notify about a learnt clause.
101 virtual void notify(SatClause
& clause
) = 0;
102 virtual void safePoint() = 0;
104 };/* class BVSatSolverInterface::Notify */
106 virtual void setNotify(Notify
* notify
) = 0;
108 virtual void markUnremovable(SatLiteral lit
) = 0;
110 virtual void getUnsatCore(SatClause
& unsatCore
) = 0;
112 virtual void addMarkerLiteral(SatLiteral lit
) = 0;
114 virtual SatValue
propagate() = 0;
116 virtual void explain(SatLiteral lit
, std::vector
<SatLiteral
>& explanation
) = 0;
118 virtual SatValue
assertAssumption(SatLiteral lit
, bool propagate
= false) = 0;
120 virtual void popAssumption() = 0;
122 };/* class BVSatSolverInterface */
125 class DPLLSatSolverInterface
: public SatSolver
{
127 virtual void initialize(context::Context
* context
, prop::TheoryProxy
* theoryProxy
) = 0;
129 virtual void push() = 0;
131 virtual void pop() = 0;
133 virtual bool properExplanation(SatLiteral lit
, SatLiteral expl
) const = 0;
135 virtual void requirePhase(SatLiteral lit
) = 0;
137 virtual bool flipDecision() = 0;
139 virtual bool isDecision(SatVariable decn
) const = 0;
141 };/* class DPLLSatSolverInterface */
143 inline std::ostream
& operator <<(std::ostream
& out
, prop::SatLiteral lit
) {
144 out
<< lit
.toString();
148 inline std::ostream
& operator <<(std::ostream
& out
, const prop::SatClause
& clause
) {
150 for(unsigned i
= 0; i
< clause
.size(); ++i
) {
151 out
<< " " << clause
[i
];
157 inline std::ostream
& operator <<(std::ostream
& out
, prop::SatValue val
) {
160 case prop::SAT_VALUE_UNKNOWN
:
163 case prop::SAT_VALUE_TRUE
:
166 case prop::SAT_VALUE_FALSE
:
178 }/* CVC4::prop namespace */
179 }/* CVC4 namespace */
181 #endif /* __CVC4__PROP__SAT_MODULE_H */