15 addBackend<LRAModule<LRASettings1>>()
21 for (
const auto&
var : subset) {
22 if (
std::find(superset.first, superset.second,
var) == superset.second) {
32 if (model.find(*varIter) != model.end()) {
33 values.push_back(std::make_pair(*varIter, model.at(*varIter)));
40 bool lowerLevelFound =
false;
42 for (
const auto&
var : constraint.variables()) {
44 if (currentVarInOrdering ==
mVariables.second) {
46 lowerLevelFound =
true;
51 else if (highestLevel < currentVarInOrdering) {
52 highestLevel = currentVarInOrdering;
55 if (lowerLevelFound)
return false;
60 assert(f.type() == carl::FormulaType::CONSTRAINT);
63 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.smtaf",
"Constraint " << f <<
" evaluated to " << fnew);
64 if (fnew.type() == carl::FormulaType::CONSTRAINT) {
65 assert(fnew.variables().size() > 0);
66 auto lvl =
level(fnew);
67 if (std::holds_alternative<VariablePos>(lvl)) {
68 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.smtaf",
"Considering constraint " << f <<
" for level " << *std::get<VariablePos>(lvl) <<
".");
69 mConstraints[std::get<VariablePos>(lvl)].push_back(fnew);
71 mFreeConstraintVars[std::get<VariablePos>(lvl)].insert(fnew.variables().begin(), fnew.variables().end());
73 }
else if (std::get<bool>(lvl) ==
true) {
74 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.smtaf",
"Ignoring constraint " << f <<
" because it has more unassigned variables than in the current range.");
77 assert(std::get<bool>(lvl) ==
false);
78 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.smtaf",
"Constraint " << f <<
" did not fully evaluate under the current model");
79 return boost::indeterminate;
81 }
else if (fnew.is_true()) {
82 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.smtaf",
"Ignoring " << f <<
" which simplified to true.");
85 assert(fnew.is_false());
86 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.smtaf",
"Conflict: " << f <<
" simplified to false.");
93 assert(f.type() == carl::FormulaType::VARCOMPARE);
107 if (
mModel.find(f.variable_comparison().var()) !=
mModel.end()) {
111 if (fnew.is_true()) {
112 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.assignmentfinder",
"Bound evaluated to true, we can ignore it.");
114 }
else if (fnew.is_false()) {
115 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.assignmentfinder",
"Conflict: " << f <<
" simplified to false.");
121 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.assignmentfinder",
"Ignoring bound " << f <<
" of higher level");
128 if (fnew.is_true()) {
129 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.assignmentfinder",
"Bound evaluated to true, we can ignore it.");
131 }
else if (fnew.is_false()) {
132 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.assignmentfinder",
"Conflict: " << f <<
" simplified to false.");
135 assert(fnew.type() == carl::FormulaType::VARCOMPARE);
137 ModelValue value = fnew.variable_comparison().value();
138 if (value.isSubstitution()) {
139 auto res = value.asSubstitution()->evaluate(
mModel);
142 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.assignmentfinder",
"Evaluated to " << value);
144 if (value.isRational()) {
145 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.assignmentfinder",
"Value is Rational, can convert to Constraint");
146 auto rel = fnew.variable_comparison().negated() ? carl::inverse(fnew.variable_comparison().relation()) : fnew.variable_comparison().relation();
147 ConstraintT constr(
Poly(fnew.variable_comparison().var()) - value.asRational(), rel);
149 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.assignmentfinder",
"Considering constraint " << fnewnew);
155 return boost::indeterminate;
160 return boost::indeterminate;
164 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.smtaf",
"Look for assignment on level " << *(excludeVar-1));
168 bool freeVariables =
false;
169 for (
auto varIter =
mVariables.first; varIter != excludeVar; varIter++) {
171 for (
auto iter =
mVariables.first; iter != excludeVar; iter++) {
178 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.smtaf",
"Variable " << *varIter <<
" does not occur in constraint set, assigning to 0");
179 model.assign(*varIter,
Rational(0));
181 freeVariables =
true;
185 if (!freeVariables) {
186 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.smtaf",
"No free variables left, returning " << model);
192 for (
auto iter =
mVariables.first; iter != excludeVar; iter++) {
194 smtModule.
add(constraint);
202 }
else if (answer == SAT) {
203 assert(smtModule.
model().size() > 0);
204 model.update(smtModule.
model());
206 for (
auto iter =
mVariables.first; iter != excludeVar; iter++) {
207 if (model.find(*iter) == model.end()) {
213 }
else if (answer == UNSAT) {
218 for (
const auto& feval : infSubset) {
236 if (std::holds_alternative<FormulasT>(*res) || curVar ==
mVariables.second - 1) {
void push()
Pushes a backtrack point to the stack of backtrack points.
const std::vector< FormulaSetT > & infeasibleSubsets() const
void setStrategy(const std::initializer_list< BackendLink > &backends)
bool add(const FormulaT &_subformula, bool _containsUnknownConstraints=true)
Adds the given formula to the conjunction of formulas, which will be considered for the next satisfia...
Answer check(bool _full=true)
Checks the so far added formulas for satisfiability.
const Model & model() const
boost::tribool addConstraint(const FormulaT &f)
std::optional< AssignmentOrConflict > findAssignment() const
std::variant< VariablePos, bool > level(const FormulaT &constraint) const
std::map< VariablePos, FormulasT > mConstraints
std::unordered_map< FormulaT, FormulaT > mEvaluatedConstraints
boost::tribool addMVBound(const FormulaT &f)
std::map< VariablePos, carl::Variables > mFreeConstraintVars
ModelValues modelToAssignment(const Model &model) const
static bool find(V &ts, const T &t)
std::vector< carl::Variable >::const_iterator VariablePos
bool includes(const VariableRange &superset, const carl::Variables &subset)
std::pair< VariablePos, VariablePos > VariableRange
bool substitute(const FormulaT &constr, const carl::Variable var, const carl::vs::Term< Poly > &term, FormulaT &result)
std::vector< std::pair< carl::Variable, ModelValue > > ModelValues
std::variant< ModelValues, FormulasT > AssignmentOrConflict
Class to create the formulas for axioms.
carl::ModelValue< Rational, Poly > ModelValue
carl::Formula< Poly > FormulaT
carl::Model< Rational, Poly > Model
carl::MultivariatePolynomial< Rational > Poly
Answer
An enum with the possible answers a Module can give.
carl::Constraint< Poly > ConstraintT
carl::Formulas< Poly > FormulasT
#define SMTRAT_LOG_DEBUG(channel, msg)