SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
Explanation.cpp
Go to the documentation of this file.
1 #include "Explanation.h"
2 
3 #include "ExplanationGenerator.h"
4 
5 #include "NLSATStatistics.h"
6 
7 namespace smtrat {
8 namespace mcsat {
9 namespace nlsat {
10 
11 std::optional<mcsat::Explanation> Explanation::operator()(const mcsat::Bookkeeping& data, carl::Variable var, const FormulasT& reason, bool) const {
12 #ifdef SMTRAT_DEVOPTION_Statistics
13  mStatistics.explanationCalled();
14 #endif
15  SMTRAT_LOG_DEBUG("smtrat.mcsat.nlsat", "Explain conflict " << reason);
16 
17  // compute compatible complete variable ordering
18  std::vector variableOrdering(data.assignedVariables());
19  for (const auto& v : data.variables()) {
20  if (std::find(data.assignedVariables().begin(), data.assignedVariables().end(), v) == data.assignedVariables().end()) {
21  variableOrdering.push_back(v);
22  }
23  }
24 
25  // 'variableOrder' is ordered 'x0,.., xk, .., xn', the relevant variables that appear in the
26  // reason and implication end at 'var'=xk, so the relevant prefix is 'x0 ... xk'
27  // where CAD would start its variable elimination from back ('xk') to front ('x0').
28  // However, the CAD implementation starts eliminating at the front:
29  std::vector<carl::Variable> orderedVars(variableOrdering);
30  std::reverse(orderedVars.begin(), orderedVars.end());
31  SMTRAT_LOG_DEBUG("smtrat.mcsat.nlsat", "Ascending variable order " << variableOrdering << " and eliminating down from " << var);
32 
33  SMTRAT_LOG_DEBUG("smtrat.mcsat.nlsat", "Bookkeep: " << data);
34  ExplanationGenerator eg(reason, orderedVars, var, data.model());
35 #ifdef SMTRAT_DEVOPTION_Statistics
36  mStatistics.explanationSuccess();
37 #endif
38  return eg.getExplanation(FormulaT(carl::FormulaType::FALSE));
39 }
40 
41 }
42 }
43 }
Represent the trail, i.e.
Definition: Bookkeeping.h:19
const auto & assignedVariables() const
Definition: Bookkeeping.h:37
const auto & variables() const
Definition: Bookkeeping.h:49
const auto & model() const
Definition: Bookkeeping.h:34
mcsat::Explanation getExplanation(const FormulaT &impliedAtom) const
Compute explanation in clausal form.
int var(Lit p)
Definition: SolverTypes.h:64
static bool find(V &ts, const T &t)
Definition: Alg.h:47
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
Definition: types.h:37
carl::Formulas< Poly > FormulasT
Definition: types.h:39
#define SMTRAT_LOG_DEBUG(channel, msg)
Definition: logging.h:35
std::optional< mcsat::Explanation > operator()(const mcsat::Bookkeeping &data, carl::Variable var, const FormulasT &reason, bool) const
We construct a formula 'E -> I', i.e.
Definition: Explanation.cpp:11