7 std::unordered_set<FormulaT> toProcess;
14 toProcess.insert(lit);
30 if (iter->isPropagating()) {
32 if (toProcess.find(iter->impliedTseitinLiteral().negated()) == toProcess.end()) {
37 toProcess.erase(iter->impliedTseitinLiteral().negated());
40 if (iter->clause().is_nary()) {
41 for (
const auto& lit : iter->clause().subformulas()) {
42 if (lit != iter->impliedTseitinLiteral()) {
44 toProcess.insert(lit);
52 if (toProcess.empty()) {
57 assert(toProcess.empty());
65 fs.push_back(link.clause());
71 switch(formula.type()) {
72 case carl::FormulaType::TRUE:
73 case carl::FormulaType::FALSE:
74 case carl::FormulaType::CONSTRAINT:
75 case carl::FormulaType::VARCOMPARE:
76 case carl::FormulaType::VARASSIGN:
84 if (!withEquivalences || outermost) {
86 for (
const auto& sub : formula.subformulas()) {
88 newFormula.push_back(std::move(sub_result));
94 for (
const auto& sub : formula.subformulas()) {
96 newFormula.push_back(std::move(sub_result));
97 const auto& lit = newFormula.back();
101 newFormula.push_back(tseitinVar.negated());
113 for (
const auto& sub : formula.subformulas()) {
115 carl::ModelValue<Rational,Poly> eval =
carl::evaluate(sub, model);
116 assert(eval.isBool());
117 if (!eval.asBool()) {
123 return FormulaT(carl::FormulaType::TRUE);
127 for (
const auto& sub : formula.subformulas()) {
129 newFormula.push_back(std::move(sub_result));
130 const auto& lit = newFormula.back();
132 carl::ModelValue<Rational,Poly> eval =
carl::evaluate(sub, model);
133 assert(eval.isBool());
134 if (!eval.asBool()) {
141 if (withEquivalences) {
144 std::transform (newFormula.begin(), newFormula.end(), std::back_inserter(tmp), [](
const FormulaT& f) ->
FormulaT { return f.negated(); } );
145 tmp.push_back(tseitinVar);
163 if (!conflictingClause.is_true()) {
164 chain.appendConflicting(std::move(conflictingClause));
An explanation is either a single clause or a chain of clauses, satisfying the following properties:
static ClauseChain from_formula(const FormulaT &f, const Model &model, bool with_equivalence)
Transforms a given Boolean conjunction over AND and OR to CNF via Tseitin-Transformation so that,...
FormulaT to_formula() const
Transforms the clause chain into a formula (containing Tseitin variables).
FormulaT resolve() const
Performs resolution on the chain.
void appendConflicting(const FormulaT &&clause)
Append a conflicting clause (regarding the current assignment).
FormulaT createTseitinVar(const FormulaT &formula)
Create a Tseitin variable for the given formula.
bool isTseitinVar(const FormulaT &var) const
void appendPropagating(const FormulaT &&clause, const FormulaT &&impliedTseitinLiteral)
Append a clause that implies impliedTseitinLiteral under the current assignment.
std::vector< Link > mClauseChain
const std::vector< Link > & chain() const
void appendOptional(const FormulaT &&clause)
Append an additional clause which is neither propagating nor conflicting.
Rational evaluate(carl::Variable v, const Poly &p, const Rational &r)
FormulaT _transformToImplicationChain(const FormulaT &formula, const Model &model, ClauseChain &chain, bool outermost, bool withEquivalences)
carl::Formula< Poly > FormulaT
carl::Model< Rational, Poly > Model
carl::Formulas< Poly > FormulasT
#define SMTRAT_LOG_WARN(channel, msg)