19 for (
const auto&
var : var_order) {
20 if (ass.find(
var) == ass.end())
return var;
23 return carl::Variable();
27 for (
const auto&
var : var_order) {
28 if (ass.find(
var) == ass.end())
return false;
43 auto deriv = cadcells::datastructures::make_derivation<typename op::PropertiesSet>(proj, ass, ass.size()).sampled_ref();
44 for (
const auto& c : implicant) {
45 if (carl::is_strict(c.relation)) {
51 if (!op::project_basic_properties(*deriv))
return std::nullopt;
52 op::delineate_properties(*deriv);
53 deriv->delineate_cell();
54 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got cell " << deriv->cell() <<
" w.r.t. delineation " << deriv->delin());
58 template<
typename op,
typename FE>
62 auto implicants = f.compute_implicants();
65 std::vector<Interval<typename op::PropertiesSet>> results;
66 for (
const auto& implicant : implicants) {
68 auto interval = get_enclosing_interval<op>(proj, implicant, ass);
69 if (interval) results.emplace_back(*interval);
75 template<
typename op, cadcells::representation::CoveringHeuristic covering_heuristic>
78 std::vector<Interval<typename op::PropertiesSet>> derivations(intervals.begin(), intervals.end());
80 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got representation " << representation);
82 auto cell_derivs = representation.sampled_derivations();
84 if (!op::project_covering_properties(representation))
return std::nullopt;
86 if (!op::project_basic_properties(*new_deriv))
return std::nullopt;
87 op::delineate_properties(*new_deriv);
88 new_deriv->delineate_cell();
89 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got interval " << new_deriv->cell());
90 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Polynomials: " << new_deriv->polys());
92 return std::make_pair(new_deriv, representation);
95 template<
typename op, cadcells::representation::CellHeuristic cell_heuristic>
101 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got representation " << representation);
102 assert((interval->level() > 1));
103 if (!op::project_cell_properties(representation))
return std::nullopt;
105 if (!op::project_basic_properties(*new_deriv))
return std::nullopt;
106 op::delineate_properties(*new_deriv);
107 new_deriv->delineate_cell();
108 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got interval " << new_deriv->cell());
109 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Polynomials: " << new_deriv->polys());
111 return std::make_pair(new_deriv, representation);
117 template<
typename op,
typename FE, cadcells::representation::CoveringHeuristic covering_heuristic, smtrat::covering_ng::SamplingAlgorithm sampling_algorithm, smtrat::cadcells::representation::CellHeuristic cell_heuristic>
120 template<
typename op,
typename FE, cadcells::representation::CoveringHeuristic covering_heuristic, smtrat::covering_ng::SamplingAlgorithm sampling_algorithm, smtrat::cadcells::representation::CellHeuristic cell_heuristic>
123 template<
typename op,
typename FE, cadcells::representation::CoveringHeuristic covering_heuristic, smtrat::covering_ng::SamplingAlgorithm sampling_algorithm, smtrat::cadcells::representation::CellHeuristic cell_heuristic>
128 const auto quantificationType = quantification.
var_type(variable);
131 return exists<op, FE, covering_heuristic, sampling_algorithm, cell_heuristic>(proj, f, ass, quantification, characterize_sat, characterize_unsat);
134 return forall<op, FE, covering_heuristic, sampling_algorithm, cell_heuristic>(proj, f, ass, quantification, characterize_sat, characterize_unsat);
138 template<
typename op,
typename FE, cadcells::representation::CoveringHeuristic covering_heuristic, smtrat::covering_ng::SamplingAlgorithm sampling_algorithm, smtrat::cadcells::representation::CellHeuristic cell_heuristic>
144 std::optional<cadcells::RAN> sample;
145 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Current Var: " << variable <<
" of level: " << ass.size() <<
"/" << proj.
polys().var_order().size());
147 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got sample " << variable <<
" = " << sample);
148 ass.emplace(variable, sample.value());
150 f.extend_valuation(ass);
154 SMTRAT_LOG_DEBUG(
"smtrat.covering_ng",
"Failed due to incomplete propagation");
157 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got evaluation: " << f.root_valuation());
160 auto new_intervals = get_enclosing_intervals<op, FE>(proj, f, ass);
161 if (new_intervals.size() > 0) {
164 SMTRAT_LOG_DEBUG(
"smtrat.covering_ng",
"Failed due to incomplete projection");
170 res = recurse<op, FE, covering_heuristic, sampling_algorithm, cell_heuristic>(proj, f, ass, quantification, characterize_sat,
true);
172 std::optional<cadcells::Assignment> sat_sample;
173 if (quantification.
var_type(variable) == carl::Quantifier::FREE && res.
is_sat()) {
177 sat_sample = *res.
sample();
181 f.revert_valuation(ass);
184 }
else if (res.
is_sat()) {
185 if (ass.empty() || !characterize_sat) {
186 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Skip computation of characterization.");
189 std::vector<Interval<typename op::PropertiesSet>> new_intervals;
192 auto new_interval = characterize_interval<op, cell_heuristic>(interval);
194 new_intervals.push_back(new_interval->first);
196 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Failed due to incomplete projection");
207 if (ass.empty() || !characterize_unsat) {
208 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Skip computation of characterization.");
211 auto new_interval = characterize_covering<op, covering_heuristic>(unsat_intervals);
215 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Failed due to incomplete projection");
221 template<
typename op,
typename FE, cadcells::representation::CoveringHeuristic covering_heuristic, smtrat::covering_ng::SamplingAlgorithm sampling_algorithm, smtrat::cadcells::representation::CellHeuristic cell_heuristic>
227 std::optional<cadcells::RAN> sample;
229 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Current Var: " << variable <<
" of level: " << ass.size() <<
"/" << proj.
polys().var_order().size());
231 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got sample: " << variable <<
" = " << sample);
232 ass.emplace(variable, sample.value());
234 f.extend_valuation(ass);
238 SMTRAT_LOG_DEBUG(
"smtrat.covering_ng",
"Failed due to incomplete propagation");
241 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got evaluation: " << f.root_valuation());
244 auto new_intervals = get_enclosing_intervals<op, FE>(proj, f, ass);
245 if (new_intervals.size() > 0) {
248 SMTRAT_LOG_DEBUG(
"smtrat.covering_ng",
"Failed due to incomplete projection");
254 res = recurse<op, FE, covering_heuristic, sampling_algorithm, cell_heuristic>(proj, f, ass, quantification,
true, characterize_unsat);
257 f.revert_valuation(ass);
261 if (ass.empty() || !characterize_unsat) {
262 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Skip computation of characterization.");
265 std::vector<Interval<typename op::PropertiesSet>> new_intervals;
268 auto new_interval = characterize_interval<op, cell_heuristic>(interval) ;
270 new_intervals.push_back(new_interval->first);
272 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Failed due to incomplete projection");
283 if (ass.empty() ||!characterize_sat) {
284 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Skip computation of characterization.");
287 auto new_interval = characterize_covering<op, covering_heuristic>(sat_intervals);
291 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Failed due to incomplete projection");
297 template<
typename op,
typename FE, cadcells::representation::CoveringHeuristic covering_heuristic, smtrat::covering_ng::SamplingAlgorithm sampling_algorithm, smtrat::cadcells::representation::CellHeuristic cell_heuristic>
302 boost::container::flat_map<Interval<typename op::PropertiesSet>, std::vector<ParameterTree>> interval_data;
304 std::optional<cadcells::RAN> sample;
306 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got sample " << variable <<
" = " << sample);
307 ass.emplace(variable, *sample);
309 f.extend_valuation(ass);
313 SMTRAT_LOG_DEBUG(
"smtrat.covering_ng",
"Failed due to incomplete propagation");
316 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got evaluation: " << f.root_valuation());
319 auto new_intervals = get_enclosing_intervals<op, FE>(proj, f, ass);
320 for (
const auto& i : new_intervals) {
321 interval_data.emplace(i, std::vector<ParameterTree>({
ParameterTree(
false)}));
323 if (new_intervals.size() > 0) {
326 SMTRAT_LOG_DEBUG(
"smtrat.covering_ng",
"Failed due to incomplete projection");
330 auto new_intervals = get_enclosing_intervals<op, FE>(proj, f, ass);
331 for (
const auto& i : new_intervals) {
332 interval_data.emplace(i, std::vector<ParameterTree>({
ParameterTree(
true)}));
334 if (new_intervals.size() > 0) {
337 SMTRAT_LOG_DEBUG(
"smtrat.covering_ng",
"Failed due to incomplete projection");
344 std::vector<ParameterTree> higher_tree;
345 std::tie(res, higher_tree) = parameter<op, FE, covering_heuristic, sampling_algorithm, cell_heuristic>(proj, f, ass, quantification);
347 interval_data.emplace(i, higher_tree);
350 res = recurse<op, FE, covering_heuristic, sampling_algorithm, cell_heuristic>(proj, f, ass, quantification,
true,
true);
353 interval_data.emplace(i, std::vector<ParameterTree>({
ParameterTree(
true)}));
357 interval_data.emplace(i, std::vector<ParameterTree>({
ParameterTree(
false)}));
362 f.revert_valuation(ass);
371 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Skip computation of characterization.");
372 std::vector<Interval<typename op::PropertiesSet>> derivations(intervals.begin(), intervals.end());
374 SMTRAT_LOG_TRACE(
"smtrat.covering_ng",
"Got representation " << representation);
375 std::vector<ParameterTree> tree;
376 for (
const auto& cell : representation.cells) {
377 tree.emplace_back(variable, cell.description, cell.derivation->sample(), std::move(interval_data[cell.derivation]));
381 auto new_interval = characterize_covering<op, covering_heuristic>(intervals);
383 std::vector<ParameterTree> tree;
384 for (
const auto& cell : new_interval->second.cells) {
385 tree.emplace_back(variable, cell.description, cell.derivation->sample(), std::move(interval_data[cell.derivation]));
387 std::vector<Interval<typename op::PropertiesSet>> new_intervals({new_interval->first});
390 SMTRAT_LOG_INFO(
"smtrat.covering_ng",
"Failed due to incomplete projection");
396 template<
typename op,
typename FE, cadcells::representation::CoveringHeuristic covering_heuristic, smtrat::covering_ng::SamplingAlgorithm sampling_algorithm, smtrat::cadcells::representation::CellHeuristic cell_heuristic>
398 if (quantification.
var_type(proj.
polys().var_order().front()) == carl::Quantifier::FREE) {
399 auto [res, tree] = parameter<op, FE, covering_heuristic, sampling_algorithm, cell_heuristic>(proj, f, ass, quantification);
402 auto res = recurse<op, FE, covering_heuristic, sampling_algorithm, cell_heuristic>(proj, f, ass, quantification);
405 }
else if (res.is_unsat()) {
Encapsulates all computations on polynomials.
carl::Quantifier var_type(const carl::Variable &var) const
Returns the type of the given variable.
void merge_underlying(std::vector< SampledDerivationRef< Properties >> &derivations)
Merges the underlying derivations of a set of sampled derivations.
std::vector< carl::Variable > VariableOrdering
carl::Assignment< RAN > Assignment
std::pair< CoveringResult< typename op::PropertiesSet >, std::vector< ParameterTree > > parameter(cadcells::datastructures::Projections &proj, FE &f, cadcells::Assignment ass, const VariableQuantification &quantification)
std::set< Interval< PropertiesSet >, IntervalCompare< PropertiesSet > > IntervalSet
carl::Variable first_unassigned_var(const cadcells::Assignment &ass, const cadcells::VariableOrdering &var_order)
CoveringResult< typename op::PropertiesSet > forall(cadcells::datastructures::Projections &proj, FE &f, cadcells::Assignment ass, const VariableQuantification &quantification, bool characterize_sat, bool characterize_unsat)
bool is_full_sample(const cadcells::Assignment &ass, const cadcells::VariableOrdering &var_order)
std::optional< std::pair< Interval< typename op::PropertiesSet >, cadcells::datastructures::CoveringRepresentation< typename op::PropertiesSet > > > characterize_covering(const IntervalSet< typename op::PropertiesSet > &intervals)
std::vector< Interval< typename op::PropertiesSet > > get_enclosing_intervals(cadcells::datastructures::Projections &proj, FE &f, const cadcells::Assignment &ass)
std::optional< std::pair< Interval< typename op::PropertiesSet >, cadcells::datastructures::CellRepresentation< typename op::PropertiesSet > > > characterize_interval(Interval< typename op::PropertiesSet > &interval)
std::optional< Interval< typename op::PropertiesSet > > get_enclosing_interval(cadcells::datastructures::Projections &proj, const boost::container::flat_set< cadcells::datastructures::PolyConstraint > &implicant, const cadcells::Assignment &ass)
CoveringResult< typename op::PropertiesSet > recurse(cadcells::datastructures::Projections &proj, FE &f, cadcells::Assignment &ass, const VariableQuantification &quantification, bool characterize_sat=false, bool characterize_unsat=false)
cadcells::datastructures::SampledDerivationRef< PropertiesSet > Interval
std::pair< CoveringResult< typename op::PropertiesSet >, ParameterTree > recurse_qe(cadcells::datastructures::Projections &proj, FE &f, cadcells::Assignment ass, const VariableQuantification &quantification)
CoveringResult< typename op::PropertiesSet > exists(cadcells::datastructures::Projections &proj, FE &f, cadcells::Assignment ass, const VariableQuantification &quantification, bool characterize_sat, bool characterize_unsat)
#define SMTRAT_LOG_TRACE(channel, msg)
#define SMTRAT_LOG_INFO(channel, msg)
#define SMTRAT_LOG_FUNC(channel, args)
#define SMTRAT_LOG_DEBUG(channel, msg)
#define SMTRAT_STATISTICS_CALL(function)
Represents a covering over a cell.
std::size_t level() const
static datastructures::CellRepresentation< T > compute(datastructures::SampledDerivationRef< T > &der)
static datastructures::CoveringRepresentation< T > compute(const std::vector< datastructures::SampledDerivationRef< T >> &ders)
const auto & sample() const
const auto & intervals() const