SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
McCallum_partial.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "McCallum.h"
4 #include "utils.h"
5 
6 namespace smtrat {
7 namespace cad {
8 namespace projection {
9 
10 /**
11  * Contains the implementation of an optimized version McCallums projection operator.
12  * It is based on the observation by Brown that if some coefficient does not vanish only the leading coefficient is required.
13  */
14 namespace mccallum_partial {
15 
16 template<typename Poly, typename Callback>
17 void single(const Poly& p, carl::Variable variable, Callback&& cb) {
18  SMTRAT_LOG_DEBUG("smtrat.cad.projection", "McCallum_partial_single(" << p << ")");
19  returnPoly(projection::discriminant(variable, p), cb);
20 
21  for (std::size_t i = 0; i < p.coefficients().size(); ++i) {
22  const auto& coeff = p.coefficients()[i];
23  if (projection::doesNotVanish(coeff)) {
24  if (i == p.coefficients().size()-1) {
25  SMTRAT_LOG_DEBUG("smtrat.cad.projection", "lcoeff = " << p.lcoeff() << " does not vanish. No coefficients needed.");
26  return;
27  } else {
28  SMTRAT_LOG_DEBUG("smtrat.cad.projection", "coeff " << coeff << " does not vanish. We only need the lcoeff() = " << p.lcoeff());
29  returnPoly(projection::normalize(carl::to_univariate_polynomial(p.lcoeff(), variable)), cb);
30  return;
31  }
32  }
33  }
34  SMTRAT_LOG_DEBUG("smtrat.cad.projection", "All coefficients might vanish, we need all of them.");
35  for (const auto& coeff : p.coefficients()) {
36  if (is_zero(coeff)) continue;
37  assert(!coeff.is_constant());
38  SMTRAT_LOG_DEBUG("smtrat.cad.projection", "\t-> " << coeff);
39  returnPoly(projection::normalize(carl::to_univariate_polynomial(coeff, variable)), cb);
40  }
41 }
42 
43 template<typename Poly, typename Callback>
44 void paired(const Poly& p, const UPoly& q, carl::Variable variable, Callback&& cb) {
45  SMTRAT_LOG_DEBUG("smtrat.cad.projection", "McCallum_partial_paired(" << p << ", " << q << ") -> McCallum_paired");
46  mccallum::paired(p, q, variable, std::forward<Callback>(cb));
47 }
48 
49 } // namespace mccallum_partial
50 } // namespace projection
51 } // namespace cad
52 } // namespace smtrat
void single(const Poly &p, carl::Variable variable, Callback &&cb)
void paired(const Poly &p, const UPoly &q, carl::Variable variable, Callback &&cb)
void paired(const Poly &p, const UPoly &q, carl::Variable variable, Callback &&cb)
Implements the part of McCallums projection operator from that deals with two polynomials p and q: .
Definition: McCallum.h:35
void returnPoly(const Poly &p, Callback &&cb)
Definition: utils.h:95
Poly discriminant(carl::Variable variable, const Poly &p)
Computes the discriminant of a polynomial.
Definition: utils.h:63
Poly normalize(const Poly &p)
Normalizes the given Poly by removing constant and duplicate factors.
Definition: utils.h:32
bool doesNotVanish(const Poly &p)
Tries to determine whether the given Poly vanishes for some assignment.
Definition: utils.h:19
carl::UnivariatePolynomial< Poly > UPoly
Definition: common.h:17
Class to create the formulas for axioms.
carl::MultivariatePolynomial< Rational > Poly
Definition: types.h:25
#define SMTRAT_LOG_DEBUG(channel, msg)
Definition: logging.h:35