SMT-RAT  24.02
Toolbox for Strategic and Parallel Satisfiability-Modulo-Theories Solving
rules_null.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "properties.h"
4 #include "../datastructures/derivation.h"
5 
7 
8 template<typename P>
10  SMTRAT_LOG_TRACE("smtrat.cadcells.operators.rules", "ord_inv(" << poly << "), " << poly << " nullified");
11  assert(deriv.proj().is_nullified(deriv.underlying_sample(), poly));
12 
13  boost::container::flat_set<datastructures::PolyRef> polys({poly});
14  boost::container::flat_set<datastructures::PolyRef> poly_derivative;
15  std::optional<datastructures::PolyRef> poly_nonzero_derivative_of_order;
16  //std::size_t order = 1;
17 
18  while (true) {
19  for (const auto& p : polys) {
20  if (deriv.proj().is_const(p)) continue;
21  for (const auto v: deriv.proj().variables(p)) {
22  auto d = deriv.proj().derivative(p, v);
23  if (!deriv.proj().is_zero(deriv.sample(), d)) {
24  poly_nonzero_derivative_of_order = d;
25  poly_derivative.clear();
26  } else {
27  poly_derivative.insert(d);
28  }
29 
30  if (poly_nonzero_derivative_of_order) break;
31  }
32  if (poly_nonzero_derivative_of_order) break;
33  }
34  if (poly_nonzero_derivative_of_order) break;
35  //else order++;
36  assert(!poly_derivative.empty()); // because order is finite
37  polys = std::move(poly_derivative);
38  poly_derivative = boost::container::flat_set<datastructures::PolyRef>();
39  }
40 
42  assert(*poly_nonzero_derivative_of_order != poly);
43  deriv.insert(properties::poly_sgn_inv{ *poly_nonzero_derivative_of_order });
44  for (const auto& p : polys) {
45  deriv.insert(properties::poly_sgn_inv{ p });
46  }
47 }
48 
49 template<typename P>
51  SMTRAT_LOG_TRACE("smtrat.cadcells.operators.rules", "ord_inv(" << poly << ")");
52  if (deriv.proj().is_const(poly)) {
53  SMTRAT_LOG_TRACE("smtrat.cadcells.operators.rules", "-> ord_inv(" << poly << ") <= " << poly << " const");
54  } else {
55  auto factors = deriv.proj().factors_nonconst(poly);
56  SMTRAT_LOG_TRACE("smtrat.cadcells.operators.rules", "-> ord_inv(" << poly << ") <= ord_inv(factors(" << poly << ")) <=> ord_inv(" << factors << ")");
57  for (const auto& factor : factors) {
58  if (deriv.proj().is_nullified(deriv.underlying_sample(), factor)) {
60  } else {
61  poly_irreducible_ord_inv(deriv, factor);
62  }
63  }
64  }
65 }
66 
67 }
const std::vector< PolyRef > & factors_nonconst(PolyRef p)
Definition: projections.h:238
PolyRef derivative(PolyRef p, carl::Variable var)
Definition: projections.h:381
bool is_nullified(const Assignment &sample, PolyRef p)
Definition: projections.h:309
std::vector< carl::Variable > variables(PolyRef p)
Definition: projections.h:377
bool is_zero(const Assignment &sample, PolyRef p)
Definition: projections.h:250
A SampledDerivation is a DelineatedDerivation with a sample and an DelineationInterval w....
Definition: derivation.h:299
Implementation of derivation rules.
Definition: rules.h:13
void poly_irreducible_ord_inv(datastructures::SampledDerivation< P > &deriv, datastructures::PolyRef poly)
Definition: rules.h:54
void poly_irreducible_ord_inv_nullified(datastructures::SampledDerivation< P > &deriv, const datastructures::PolyRef &poly)
Definition: rules_null.h:9
void poly_ord_inv_maybe_null(datastructures::SampledDerivation< P > &deriv, datastructures::PolyRef poly)
Definition: rules_null.h:50
#define SMTRAT_LOG_TRACE(channel, msg)
Definition: logging.h:36
level_t level
The level of the polynomial.
Definition: polynomials.h:18