mirror of
https://github.com/Z3Prover/z3
synced 2025-06-02 20:31:21 +00:00
retire deprecated functionality
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
8ec5ccbb9a
commit
8db711bc3c
15 changed files with 395 additions and 1100 deletions
|
@ -22,147 +22,6 @@ Author:
|
|||
|
||||
namespace polysat {
|
||||
|
||||
/**
|
||||
* Find a sequence of intervals that covers all of Z_modulus.
|
||||
*
|
||||
* \returns true iff such a covering exists
|
||||
* \param longest_i: the longest interval (as index into 'records')
|
||||
* \param out_seq: will contain the covering (as list of indices into 'records')
|
||||
*/
|
||||
static bool find_covering_sequence(vector<fi_record> const& records, unsigned longest_i, rational modulus, unsigned_vector& out_seq) {
|
||||
rational baseline = records[longest_i].interval.hi_val();
|
||||
while (!records[longest_i].interval.currently_contains(baseline)) {
|
||||
rational best_extent = rational::zero();
|
||||
unsigned furthest_i = UINT_MAX;
|
||||
for (unsigned i = records.size(); i-- > 0; ) {
|
||||
auto const& interval = records[i].interval;
|
||||
if (interval.currently_contains(baseline)) {
|
||||
rational extent = mod(interval.hi_val() - baseline, modulus);
|
||||
if (extent > best_extent) {
|
||||
best_extent = extent;
|
||||
furthest_i = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (furthest_i == UINT_MAX) {
|
||||
// There's a hole we can't cover.
|
||||
// This can happen if a constraint didn't produce an interval
|
||||
// (but not necessarily, values may be covered by multiple constraints)
|
||||
return false;
|
||||
}
|
||||
SASSERT(best_extent > 0);
|
||||
out_seq.push_back(furthest_i);
|
||||
baseline = records[furthest_i].interval.hi_val();
|
||||
}
|
||||
SASSERT(out_seq.size() > 0);
|
||||
if (!records[out_seq[0]].interval.currently_contains(baseline))
|
||||
out_seq.push_back(longest_i);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* A single constraint implies an empty interval.
|
||||
* We assume that neg_cond is a consequence of src that
|
||||
* does not mention the variable v to be eliminated.
|
||||
*/
|
||||
void forbidden_intervals::full_interval_conflict(signed_constraint src, vector<signed_constraint> const& side_cond, conflict& core) {
|
||||
core.reset();
|
||||
for (auto c : side_cond)
|
||||
core.insert(c);
|
||||
core.insert(src);
|
||||
core.set_bailout();
|
||||
}
|
||||
|
||||
bool forbidden_intervals::perform(pvar v, vector<signed_constraint> const& just, conflict& core) {
|
||||
|
||||
// Extract forbidden intervals from conflicting constraints
|
||||
vector<fi_record> records;
|
||||
rational longest_len;
|
||||
unsigned longest_i = UINT_MAX;
|
||||
for (signed_constraint c : just) {
|
||||
LOG_H3("Computing forbidden interval for: " << c);
|
||||
eval_interval interval = eval_interval::full();
|
||||
vector<signed_constraint> side_cond;
|
||||
if (get_interval(c, v, interval, side_cond)) {
|
||||
LOG("interval: " << interval);
|
||||
LOG("neg_cond: " << side_cond);
|
||||
if (interval.is_currently_empty())
|
||||
continue;
|
||||
if (interval.is_full()) {
|
||||
// We have a single interval covering the whole domain
|
||||
// => the side conditions of that interval are enough to produce a conflict
|
||||
full_interval_conflict(c, side_cond, core);
|
||||
revert_core(core);
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
auto const len = interval.current_len();
|
||||
if (len > longest_len) {
|
||||
longest_len = len;
|
||||
longest_i = records.size();
|
||||
}
|
||||
}
|
||||
records.push_back({ std::move(interval), std::move(side_cond), c });
|
||||
}
|
||||
}
|
||||
|
||||
if (records.empty()) {
|
||||
LOG("aborted (no intervals)");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
SASSERT(longest_i != UINT_MAX);
|
||||
LOG("longest: i=" << longest_i << "; " << records[longest_i].interval);
|
||||
|
||||
rational const modulus = rational::power_of_two(s.size(v));
|
||||
|
||||
// Select a sequence of covering intervals
|
||||
unsigned_vector seq;
|
||||
if (!find_covering_sequence(records, longest_i, modulus, seq)) {
|
||||
LOG("aborted (intervals do not cover domain)");
|
||||
return false;
|
||||
}
|
||||
LOG("seq: " << seq);
|
||||
SASSERT(seq.size() >= 2); // otherwise has_full should have been true
|
||||
|
||||
// Update the conflict state
|
||||
// Idea:
|
||||
// - If the src constraints hold, and
|
||||
// - if the side conditions hold, and
|
||||
// - the upper bound of each interval is contained in the next interval,
|
||||
// then the forbidden intervals cover the whole domain and we have a conflict.
|
||||
//
|
||||
|
||||
core.reset();
|
||||
// Add side conditions and interval constraints
|
||||
for (unsigned seq_i = seq.size(); seq_i-- > 0; ) {
|
||||
unsigned const i = seq[seq_i];
|
||||
unsigned const next_i = seq[(seq_i + 1) % seq.size()];
|
||||
// Build constraint: upper bound of each interval is not contained in the next interval,
|
||||
// using the equivalence: t \in [l;h[ <=> t-l < h-l
|
||||
auto const& hi = records[i].interval.hi();
|
||||
auto const& next_lo = records[next_i].interval.lo();
|
||||
auto const& next_hi = records[next_i].interval.hi();
|
||||
auto lhs = hi - next_lo;
|
||||
auto rhs = next_hi - next_lo;
|
||||
signed_constraint c = s.m_constraints.ult(lhs, rhs);
|
||||
LOG("constraint: " << c);
|
||||
core.insert(c);
|
||||
// Side conditions
|
||||
// TODO: check whether the condition is subsumed by c? maybe at the end do a "lemma reduction" step, to try and reduce branching?
|
||||
for (auto sc : records[i].side_cond)
|
||||
core.insert(sc);
|
||||
|
||||
core.insert(records[i].src);
|
||||
}
|
||||
core.set_bailout();
|
||||
revert_core(core);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/** Precondition: all variables other than v are assigned.
|
||||
*
|
||||
* \param[out] out_interval The forbidden interval for this constraint
|
||||
|
@ -464,15 +323,4 @@ namespace polysat {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void forbidden_intervals::revert_core(conflict& core) {
|
||||
for (auto c : core) {
|
||||
if (c.bvalue(s) == l_false) {
|
||||
core.reset();
|
||||
core.set(~c);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue