5 #include <carl-arith/core/Common.h>
6 #include <carl-formula/model/evaluation/ModelEvaluation.h>
7 #include <carl-vs/substitute.h>
8 #include <carl-vs/zeros.h>
19 if (f.type() == carl::FormulaType::CONSTRAINT || f.type() == carl::FormulaType::VARCOMPARE) {
23 }
else if (f.is_nary()) {
24 for (
const auto& sub : f.subformulas()) {
27 }
else if (f.type() == carl::FormulaType::TRUE || f.type() == carl::FormulaType::FALSE) {
39 for (
const auto& conjunction : docc) {
41 for (
const auto& constraint : conjunction) {
42 constraintConjunction.emplace_back(constraint);
55 std::vector<carl::vs::zero<Poly>> res;
57 if (formula.type()==carl::FormulaType::CONSTRAINT) {
58 if (!carl::vs::gather_zeros(formula.constraint(), eliminationVar, res)) {
62 }
else if (formula.type()==carl::FormulaType::TRUE || formula.type()==carl::FormulaType::FALSE) {
64 }
else if (formula.type()==carl::FormulaType::VARCOMPARE) {
65 if (!carl::vs::gather_zeros(formula.variable_comparison(), eliminationVar, res)) {
76 yield_result(std::move(z.sqrt_ex), std::move(z.side_condition));
94 if(!(
std::find(results.begin(), results.end(), newSubstitution) != results.end())) {
95 results.push_back(newSubstitution);
106 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Generating test candidates for " << constraints <<
" and variable " << eliminationVar);
110 results.emplace_back(minf);
113 for (
const auto& constraint : constraints) {
115 assert(constraint.type() == carl::FormulaType::CONSTRAINT || constraint.type() == carl::FormulaType::TRUE || constraint.type() == carl::FormulaType::FALSE || constraint.type() == carl::FormulaType::VARCOMPARE);
116 bool isConstraint = constraint.type() == carl::FormulaType::CONSTRAINT || constraint.type() == carl::FormulaType::TRUE || constraint.type() == carl::FormulaType::FALSE;
117 const carl::Relation& relation = isConstraint ? constraint.constraint().relation() : constraint.variable_comparison().relation();
118 bool weakConstraint = (relation ==
carl::Relation::EQ || relation == carl::Relation::LEQ || relation == carl::Relation::GEQ);
123 TestCandidate sub({carl::vs::Term<Poly>(subType, sqrtExpression), std::move(sideConditions)});
124 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Generated test candidate " << sub.term);
129 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Could not generate zeros of " << eliminationVar <<
" in " << constraint);
134 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Generated test candidates successfully");
139 if (constr.type() == carl::FormulaType::CONSTRAINT) {
149 }
else if (constr.type() == carl::FormulaType::VARCOMPARE) {
155 if (std::holds_alternative<carl::vs::CaseDistinction<Poly>>(*subres)) {
165 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.vs",
"Formula type " << constr.type() <<
" not supported for substitution");
static bool find(V &ts, const T &t)
auto get(const It &it, level)
static bool generateZeros(const FormulaT &formula, const carl::Variable &eliminationVar, std::function< void(SqrtEx &&sqrtExpression, ConstraintsT &&sideConditions)> yield_result)
Get zeros with side conditions of the given constraint.
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)
static bool addOrMergeTestCandidate(std::vector< TestCandidate > &results, const TestCandidate &newSubstitution)
Adds a new substitution to the given list of substitutions or merges it to an existing one.
FormulaT to_formula(const carl::vs::CaseDistinction< Poly > &docc)
Converts a DisjunctionOfConstraintConjunctions to a regular Formula.
Class to create the formulas for axioms.
carl::Constraints< Poly > ConstraintsT
carl::FormulaSet< Poly > FormulaSetT
carl::Formula< Poly > FormulaT
carl::SqrtEx< Poly > SqrtEx
carl::Formulas< Poly > FormulasT
#define SMTRAT_LOG_DEBUG(channel, msg)
bool operator==(const TestCandidate &other) const
carl::vs::Term< Poly > term
ConstraintsT side_condition