SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
RootExpr.h
Go to the documentation of this file.
1 #pragma once
2 
3 namespace smtrat::mcsat {
4 
5  template<typename P>
6  inline std::vector<carl::BasicConstraint<P>> constr_from_vc(const carl::VariableComparison<P>& vc, const carl::Assignment<typename P::RootType> assignment, bool tarski = false) {
7  SMTRAT_LOG_FUNC("smtrat.mcsat.utils", vc << ", " << assignment << ", " << tarski)
8  auto constraint = carl::as_constraint(vc);
9  if (constraint) {
10  SMTRAT_LOG_TRACE("smtrat.mcsat.utils", "Got " << constraint);
11  return std::vector<carl::BasicConstraint<P>>({*constraint});
12  } else if (tarski) {
13  SMTRAT_LOG_TRACE("smtrat.mcsat.utils", "Apply Thom's lemma");
14  auto poly = defining_polynomial(vc);
15  std::vector<carl::BasicConstraint<P>> constraints;
16  for (auto i = poly.degree(vc.var()); i > 0; i--) {
17  carl::BasicConstraint<P> less_constr(poly, carl::Relation::LESS);
18  auto less_eval = carl::evaluate(less_constr, assignment);
19  assert(!indeterminate(less_eval));
20  if (less_eval) {
21  constraints.emplace_back(less_constr);
22  } else {
23  carl::BasicConstraint<P> greater_constr(poly, carl::Relation::GREATER);
24  auto greater_eval = carl::evaluate(greater_constr, assignment);
25  assert(!indeterminate(greater_eval));
26  if (greater_eval) {
27  constraints.emplace_back(greater_constr);
28  } else {
29  constraints.emplace_back(carl::BasicConstraint<P>(poly, carl::Relation::EQ));
30  assert(carl::evaluate(constraints.back(), assignment));
31  }
32  }
33 
34  poly = carl::derivative(poly); //, vc.var());
35  }
36  SMTRAT_LOG_TRACE("smtrat.mcsat.utils", "Got " << constraints);
37  return constraints;
38  }
39  return std::vector<carl::BasicConstraint<P>>();
40  }
41 
42 }
Rational evaluate(carl::Variable v, const Poly &p, const Rational &r)
Definition: utils.h:11
std::vector< carl::BasicConstraint< P > > constr_from_vc(const carl::VariableComparison< P > &vc, const carl::Assignment< typename P::RootType > assignment, bool tarski=false)
Definition: RootExpr.h:6
#define SMTRAT_LOG_TRACE(channel, msg)
Definition: logging.h:36
#define SMTRAT_LOG_FUNC(channel, args)
Definition: logging.h:38