6 #include <carl-common/config.h>
10 namespace onecellcad {
13 template<
class Setting1,
class Setting2>
14 std::optional<mcsat::Explanation>
17 const FormulasT& trailLiterals,
bool)
const {
21 #ifdef SMTRAT_DEVOPTION_Statistics
22 getStatistic().explanationCalled();
25 #if not(defined USE_COCOA || defined USE_GINAC)
27 #warning OneCellCAD may be incorrect as USE_COCOA is disabled
32 varOrder.push_back(
var);
34 if (
std::find(varOrder.begin(), varOrder.end(), v) == varOrder.end()) {
35 varOrder.push_back(v);
42 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.nlsat",
" OneCellExplanation called with 0 theory-assignment");
44 for (
const auto& trailLiteral : trailLiterals)
45 explainLiterals.emplace_back(trailLiteral.negated());
54 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.nlsat",
"Ascending variable order: " << varOrder
55 <<
" and eliminate down from: " <<
var);
58 std::vector<carl::Variable> fullProjectionVarOrder = varOrder;
59 std::vector<carl::Variable> oneCellCADVarOrder;
60 for (std::size_t i = 0; i < trailVariables.size(); i++)
61 oneCellCADVarOrder.emplace_back(fullProjectionVarOrder[i]);
63 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.nlsat",
"Ascending OneCellVarOrder: " << oneCellCADVarOrder);
65 std::size_t oneCellMaxLvl = trail.
model().size() - 1;
66 std::vector<std::vector<TagPoly>> projectionLevels(fullProjectionVarOrder.size());
68 std::vector<Poly> polys;
70 polys.emplace_back(constraint.lhs());
73 for(
const auto& poly : polys){
77 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.nlsat",
"Polys at levels before full CAD projection:\n"
82 auto maxLevel = fullProjectionVarOrder.size() - 1;
83 while (projectionLevels[maxLevel].empty() && maxLevel > 0){
84 projectionLevels.erase(projectionLevels.begin() + maxLevel);
87 assert(maxLevel > 0 || !projectionLevels[0].empty());
90 for (std::size_t currentLvl = maxLevel; currentLvl > oneCellMaxLvl; currentLvl--) {
91 auto currentVar = fullProjectionVarOrder[currentLvl];
92 assert(currentLvl >= 1);
94 if(currentLvl == oneCellMaxLvl+1){
104 projectionLevels.erase(projectionLevels.begin() + currentLvl);
105 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.nlsat",
"Polys at levels after a CAD projection at level: " << currentLvl <<
":\n" << projectionLevels);
108 assert(1 <= Setting1::sectionHeuristic && Setting1::sectionHeuristic <= 3);
109 assert(1 <= Setting2::sectorHeuristic && Setting2::sectorHeuristic <= 3);
110 std::optional<CADCell> cellOpt =
117 auto cell = *cellOpt;
128 for (
const auto& trailLiteral : trailLiterals)
129 explainLiterals.emplace_back(trailLiteral.negated());
131 for (std::size_t i = 0; i < cell.size(); i++) {
132 auto& cellComponent = cell[i];
133 auto cellVariable = oneCellCADVarOrder[i];
134 if (std::holds_alternative<Section>(cellComponent)) {
135 auto section = std::get<Section>(cellComponent).boundFunction;
136 auto param = std::make_pair(section.poly(), section.k());
139 auto sectorLowBound = std::get<Sector>(cellComponent).lowBound;
140 if (sectorLowBound) {
141 auto param = std::make_pair(sectorLowBound->boundFunction.poly(), sectorLowBound->boundFunction.k());
144 auto sectorHighBound = std::get<Sector>(cellComponent).highBound;
145 if (sectorHighBound) {
146 auto param = std::make_pair(sectorHighBound->boundFunction.poly(), sectorHighBound->boundFunction.k());
155 SMTRAT_LOG_DEBUG(
"smtrat.mcsat.nlsat",
"Explain literals: " << explainLiterals);
156 #ifdef SMTRAT_DEVOPTION_Statistics
157 getStatistic().explanationSuccess();
Represent the trail, i.e.
const auto & assignedVariables() const
const auto & variables() const
const auto & model() const
std::optional< CADCell > constructCADCellEnclosingPoint(std::vector< std::vector< TagPoly >> &polys, int sectionHeuristic, int sectorHeuristic)
Construct a single CADCell that contains the given 'point' and is sign-invariant for the given polyno...
static bool find(V &ts, const T &t)
FormulaT buildEquality(carl::Variable var, const MVRootParams &mvp)
Construct an atomic formula representing a variable being equal to the given multivariate root.
std::set< ConstraintT > convertToConstraints(std::vector< FormulaT > constraintAtoms)
Transform constraints represented as atomic formualas into the easier to use objects of the Constrain...
FormulaT buildBelow(carl::Variable var, const MVRootParams &mvp)
Construct an atomic formula representing a variable being less than the given multivariate root.
FormulaT buildAbove(carl::Variable var, const MVRootParams &mvp)
Construct an atomic formula representing a variable being greater than the given multivariate root.
void appendOnCorrectLevel(const Poly &poly, InvarianceType tag, std::vector< std::vector< TagPoly >> &polys, std::vector< carl::Variable > variableOrder)
RealAlgebraicPoint< smtrat::Rational > asRANPoint(const mcsat::Bookkeeping &data)
void singleLevelFullProjection(std::vector< carl::Variable > &variableOrder, carl::Variable mainVar, size_t currentLevel, std::vector< std::vector< TagPoly >> &projectionLevels)
bool optimized_singleLevelFullProjection(carl::Variable mainVar, size_t currentLevel, std::vector< std::vector< TagPoly >> &projectionLevels, OneCellCAD &cad)
Class to create the formulas for axioms.
carl::Formula< Poly > FormulaT
carl::Formulas< Poly > FormulasT
Construct a single open CAD Cell around a given point that is sign-invariant on a given set of polyno...
#define SMTRAT_LOG_WARN(channel, msg)
#define SMTRAT_LOG_DEBUG(channel, msg)
std::optional< mcsat::Explanation > operator()(const mcsat::Bookkeeping &trail, carl::Variable var, const FormulasT &trailLiterals, bool) const