18 #include <carl-arith/constraint/Conversion.h>
24 template<
typename Pol>
26 auto poly_variables = carl::variables(poly).as_set();
27 if (poly_variables.empty()) {
30 for (std::size_t level = 1; level <= order.size(); ++level) {
31 poly_variables.erase(order[level-1]);
32 if (poly_variables.empty())
return level;
34 assert(
false &&
"Poly contains variable not found in order");
40 template<
typename Settings>
43 using op =
typename Settings::op;
44 using PropSet =
typename op::PropertiesSet;
48 std::shared_ptr<cadcells::Polynomial::ContextType>
mContext;
57 std::shared_ptr<datastructures::PolyPool>
mPool;
78 void init(std::vector<carl::Variable>& varOrdering) {
79 mContext = std::make_shared<cadcells::Polynomial::ContextType>(varOrdering);
82 mPool = std::make_shared<datastructures::PolyPool>(*
mContext);
92 return mContext->variable_ordering().size();
95 std::shared_ptr<cadcells::Polynomial::ContextType>
getContext() {
116 auto conv_constraint = carl::convert<Poly>(infeasibleConstraint);
119 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"getInfeasibleSubset done: " << infeasibleSubset);
120 return infeasibleSubset;
127 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Adding Constraint : " << constraint <<
" on level " << level);
128 auto conv_constraint = carl::convert<cadcells::Polynomial>(*
mContext, constraint.constr()) ;
133 void addConstraint(
const size_t level,
const std::vector<ConstraintT>&& constraints) {
134 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Adding Constraints : " << constraints <<
" on level " << level);
135 for (
const auto& constraint : constraints) {
137 auto conv_constraint = carl::convert<cadcells::Polynomial>(*
mContext, constraint.constr()) ;
167 for (std::size_t i = level; i <
dimension(); i++) {
187 auto conv_constraint = carl::convert<cadcells::Polynomial>(*
mContext, constraint.constr()) ;
190 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Removing Constraint : " << conv_constraint <<
" on level " << level);
198 for (std::size_t cur_level = 0; cur_level <= level; cur_level++) {
203 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Constraint to remove was in unknown constraints");
208 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Constraint to remove was not in known constraints");
215 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Constraint to remove was in known constraints");
217 for (std::size_t cur_level = 0; cur_level <= level; cur_level++) {
235 for (std::size_t i = level; i <
dimension(); i++) {
245 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Need to prune the assignment: " << prune_assignment);
248 std::vector<datastructures::SampledDerivationRef<PropSet>> intervals;
249 if (prune_assignment) {
253 carl::Assignment<cadcells::RAN> assignment;
254 for (std::size_t i = 0; i < level; i++) {
257 intervals = algorithms::get_unsat_intervals<op>(constraint, *
mProjections, assignment);
259 for (
const auto& interval : intervals) {
260 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Found UNSAT Interval: " << interval->cell() <<
" from constraint: " << constraint);
287 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Computed Covering invalidates all higher levels as the underlying sample point changed");
291 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Current variable " <<
mContext->variable_ordering()[level] <<
" is assigned, skipping processing of new constraints and computing covering representation");
294 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Covering was invalidated, recomputing covering representation and processing all unknown constraints");
298 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Computed Covering invalidates all higher levels as the underlying sample point changed");
324 return nextLevelAnswer;
329 if (!new_derivation.has_value()) {
334 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Found new derivation: " << new_derivation.value()->cell());
335 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Adding new derivation to Covering Information");
350 SMTRAT_LOG_DEBUG(
"smtrat.covering",
"Computed Covering invalidates all higher levels as the underlying sample point changed");
auto & getUnknownConstraints(std::size_t &level)
std::vector< LevelWiseInformation< Settings > > mCoveringInformation
void addConstraint(const size_t level, const std::vector< ConstraintT > &&constraints)
void updateAssignment(std::size_t level)
std::shared_ptr< cadcells::Polynomial::ContextType > mContext
std::shared_ptr< datastructures::Projections > mProjections
void resetStoredData(std::size_t level)
typename op::PropertiesSet PropSet
void removeConstraint(const ConstraintT &constraint)
std::vector< boost::container::flat_set< cadcells::Constraint > > mUnknownConstraints
void processUnknownConstraints(const std::size_t &level, const bool prune_assignment)
auto & getKnownConstraints(std::size_t &level)
const carl::Assignment< cadcells::RAN > & getCurrentAssignment()
std::map< datastructures::SampledDerivationRef< PropSet >, std::vector< cadcells::Constraint > > mDerivationToConstraint
void setConstraintsUnknown(const std::size_t &level)
void init(std::vector< carl::Variable > &varOrdering)
std::vector< boost::container::flat_set< cadcells::Constraint > > mKnownConstraints
auto & getCoveringInformation()
void setConstraintsKnown(const std::size_t &level)
auto & getKnownConstraints()
void resetDerivationToConstraintMap()
Answer getUnsatCover(const std::size_t level)
auto & getUnknownConstraints()
std::shared_ptr< cadcells::Polynomial::ContextType > getContext()
std::shared_ptr< datastructures::PolyPool > mPool
void addConstraint(const ConstraintT &constraint)
carl::Assignment< cadcells::RAN > mCurrentAssignment
FormulaSetT getInfeasibleSubset()
static bool find(V &ts, const T &t)
std::vector< carl::Variable > VariableOrdering
carl::BasicConstraint< Polynomial > Constraint
static size_t level_of(const VariableOrdering &order, const Pol &poly)
Class to create the formulas for axioms.
carl::FormulaSet< Poly > FormulaSetT
carl::Formula< Poly > FormulaT
Answer
An enum with the possible answers a Module can give.
carl::Constraint< Poly > ConstraintT
#define SMTRAT_LOG_DEBUG(channel, msg)