4 #include <carl-formula/formula/functions/Substitution.h>
17 template<
class Settings>
26 ExplanationGenerator(
const std::vector<FormulaT>& constraints,
const std::vector<carl::Variable>& variableOrdering,
const carl::Variable& targetVar,
const Model& model):
35 std::pair<std::vector<carl::Variable>::const_iterator, std::vector<carl::Variable>::const_iterator>
getUnassignedVariables()
const {
36 std::unordered_set<carl::Variable> freeVariables;
38 auto vars = carl::variables(constr);
39 freeVariables.insert(
vars.begin(),
vars.end());
44 auto lastVar = firstVar;
46 if (freeVariables.find(*iter) != freeVariables.end()) {
53 return std::make_pair(firstVar, lastVar);
57 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Eliminating variable " <<
var <<
" in " << inputFormula);
64 std::vector<helper::TestCandidate> testCandidates;
67 res.reserve(testCandidates.size());
68 for (
const auto& tc : testCandidates) {
69 FormulaT branchResult = inputFormula;
72 for (
const auto& constr : atoms) {
75 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Substituting " << tc.term <<
" for " <<
var <<
" into " << constr);
85 if (Settings::reduceConflictConstraints) {
88 if (!eval.isBool() || !eval.asBool()) {
89 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Use constraint " << constr <<
" for explanation");
92 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Ignore constraint " << constr <<
" because it is not part of the conflict");
93 substitutionResult =
FormulaT(carl::FormulaType::TRUE);
104 branch.push_back(std::move(branchResult));
105 for (
const auto& sc : tc.side_condition) {
106 branch.emplace_back(sc);
110 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Substitution of " << tc.term <<
" into formula obtained " << res.back());
111 assert(res.back() !=
FormulaT(carl::FormulaType::TRUE));
126 for (
auto iter = unassignedVariables.first; iter != unassignedVariables.second; iter++) {
131 assert(res->variables().find(*iter) == res->variables().end());
136 assert(evalRes.isBool());
137 assert(!evalRes.asBool());
142 expl.push_back(std::move(*res));
144 expl.emplace_back(c.negated());
#define SMTRAT_VALIDATION_ADD(channel, name, formula, consistent)
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,...
std::optional< FormulaT > eliminateVariable(const FormulaT &inputFormula, const carl::Variable &var) const
std::pair< std::vector< carl::Variable >::const_iterator, std::vector< carl::Variable >::const_iterator > getUnassignedVariables() const
std::optional< FormulaT > eliminateVariables() const
const std::vector< carl::Variable > & mVariableOrdering
ExplanationGenerator(const std::vector< FormulaT > &constraints, const std::vector< carl::Variable > &variableOrdering, const carl::Variable &targetVar, const Model &model)
std::optional< mcsat::Explanation > getExplanation() const
const std::vector< FormulaT > & mConstraints
const carl::Variable & mTargetVar
static bool find(V &ts, const T &t)
Rational evaluate(carl::Variable v, const Poly &p, const Rational &r)
bool substitute(const FormulaT &constr, const carl::Variable var, const carl::vs::Term< Poly > &term, FormulaT &result)
static bool generateTestCandidates(std::vector< TestCandidate > &results, const carl::Variable &eliminationVar, const FormulaSetT &constraints)
Generate all test candidates according to "vanilla" virtual substitution.
void getFormulaAtoms(const FormulaT &f, FormulaSetT &result)
std::variant< FormulaT, ClauseChain > Explanation
std::vector< carl::Variable > vars(const std::pair< QuantifierType, std::vector< carl::Variable >> &p)
Class to create the formulas for axioms.
carl::FormulaSet< Poly > FormulaSetT
carl::Formula< Poly > FormulaT
carl::Model< Rational, Poly > Model
carl::Formulas< Poly > FormulasT
#define SMTRAT_LOG_DEBUG(channel, msg)
static const bool clause_chain_with_equivalences
static const bool reduceConflictConstraints