mirror of
https://github.com/Z3Prover/z3
synced 2025-06-23 14:23:40 +00:00
prepare for diseq_lin viable
This commit is contained in:
parent
651b41f8c0
commit
8c2735e68b
3 changed files with 30 additions and 9 deletions
|
@ -20,10 +20,11 @@ Author:
|
||||||
|
|
||||||
namespace polysat {
|
namespace polysat {
|
||||||
|
|
||||||
/** Precondition: all variables other than v are assigned.
|
/**
|
||||||
*
|
*
|
||||||
* \param[out] out_interval The forbidden interval for this constraint
|
* \param[in] c Original constraint
|
||||||
* \param[out] out_neg_cond Negation of the side condition (the side condition is true when the forbidden interval is trivial). May be NULL if the condition is constant.
|
* \param[in] v Variable that is bounded by constraint
|
||||||
|
* \param[out] fi "forbidden interval" record that captures values not allowed for v
|
||||||
* \returns True iff a forbidden interval exists and the output parameters were set.
|
* \returns True iff a forbidden interval exists and the output parameters were set.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ namespace polysat {
|
||||||
SASSERT(b2.is_val());
|
SASSERT(b2.is_val());
|
||||||
|
|
||||||
// TBD: use fi.coeff = -1 to tell caller to treat it as a diseq_lin.
|
// TBD: use fi.coeff = -1 to tell caller to treat it as a diseq_lin.
|
||||||
// record a1, a2, b1, b2 for fast access and add side conditions on b1, b2?
|
// record a1, a2, b1, b2 for fast access, add non_unit side conditions on b1 = e1, b2 = e2?
|
||||||
if (a1 != a2 && !a1.is_zero() && !a2.is_zero())
|
if (a1 != a2 && !a1.is_zero() && !a2.is_zero())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -224,7 +225,9 @@ namespace polysat {
|
||||||
void forbidden_intervals::add_non_unit_side_conds(fi_record& fi, pdd const& b1, pdd const& e1, pdd const& b2, pdd const& e2) {
|
void forbidden_intervals::add_non_unit_side_conds(fi_record& fi, pdd const& b1, pdd const& e1, pdd const& b2, pdd const& e2) {
|
||||||
if (fi.coeff == 1)
|
if (fi.coeff == 1)
|
||||||
return;
|
return;
|
||||||
fi.side_cond.push_back(s.eq(b1, e1));
|
if (b1 != e1)
|
||||||
fi.side_cond.push_back(s.eq(b2, e2));
|
fi.side_cond.push_back(s.eq(b1, e1));
|
||||||
|
if (b2 != e2)
|
||||||
|
fi.side_cond.push_back(s.eq(b2, e2));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -178,6 +178,10 @@ namespace polysat {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool viable::refine_viable(pvar v, rational const& val) {
|
||||||
|
return refine_equal_lin(v, val) && refine_disequal_lin(v, val);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Traverse all interval constraints with coefficients to check whether current value 'val' for
|
* Traverse all interval constraints with coefficients to check whether current value 'val' for
|
||||||
* 'v' is feasible. If not, extract a (maximal) interval to block 'v' from being assigned val.
|
* 'v' is feasible. If not, extract a (maximal) interval to block 'v' from being assigned val.
|
||||||
|
@ -187,7 +191,7 @@ namespace polysat {
|
||||||
* be precisely the assigned values. This is to ensure that lo/hi that are computed based on lo_val
|
* be precisely the assigned values. This is to ensure that lo/hi that are computed based on lo_val
|
||||||
* and division with coeff are valid. Is there a more relaxed scheme?
|
* and division with coeff are valid. Is there a more relaxed scheme?
|
||||||
*/
|
*/
|
||||||
bool viable::refine_viable(pvar v, rational const& val) {
|
bool viable::refine_equal_lin(pvar v, rational const& val) {
|
||||||
auto* e = m_equal_lin[v];
|
auto* e = m_equal_lin[v];
|
||||||
if (!e)
|
if (!e)
|
||||||
return true;
|
return true;
|
||||||
|
@ -268,6 +272,14 @@ namespace polysat {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool viable::refine_disequal_lin(pvar v, rational const& val) {
|
||||||
|
auto* e = m_diseq_lin[v];
|
||||||
|
if (!e)
|
||||||
|
return true;
|
||||||
|
LOG("refine-disequal-lin is TBD");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool viable::has_viable(pvar v) {
|
bool viable::has_viable(pvar v) {
|
||||||
refined:
|
refined:
|
||||||
auto* e = m_units[v];
|
auto* e = m_units[v];
|
||||||
|
@ -460,6 +472,7 @@ namespace polysat {
|
||||||
while (e != first);
|
while (e != first);
|
||||||
|
|
||||||
// core.set_bailout();
|
// core.set_bailout();
|
||||||
|
// TODO - review this; c is true under current assignment?
|
||||||
for (auto c : core) {
|
for (auto c : core) {
|
||||||
if (c.bvalue(s) == l_false) {
|
if (c.bvalue(s) == l_false) {
|
||||||
core.reset();
|
core.reset();
|
||||||
|
@ -506,6 +519,7 @@ namespace polysat {
|
||||||
std::ostream& viable::display(std::ostream& out, pvar v) const {
|
std::ostream& viable::display(std::ostream& out, pvar v) const {
|
||||||
display(out, v, m_units[v]);
|
display(out, v, m_units[v]);
|
||||||
display(out, v, m_equal_lin[v]);
|
display(out, v, m_equal_lin[v]);
|
||||||
|
display(out, v, m_diseq_lin[v]);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,10 @@ namespace polysat {
|
||||||
|
|
||||||
bool refine_viable(pvar v, rational const& val);
|
bool refine_viable(pvar v, rational const& val);
|
||||||
|
|
||||||
|
bool refine_equal_lin(pvar v, rational const& val);
|
||||||
|
|
||||||
|
bool refine_disequal_lin(pvar v, rational const& val);
|
||||||
|
|
||||||
std::ostream& display(std::ostream& out, pvar v, entry* e) const;
|
std::ostream& display(std::ostream& out, pvar v, entry* e) const;
|
||||||
|
|
||||||
void insert(entry* e, pvar v, ptr_vector<entry>& entries, entry_kind k);
|
void insert(entry* e, pvar v, ptr_vector<entry>& entries, entry_kind k);
|
||||||
|
@ -60,9 +64,9 @@ namespace polysat {
|
||||||
~viable();
|
~viable();
|
||||||
|
|
||||||
// declare and remove var
|
// declare and remove var
|
||||||
void push(unsigned) { m_units.push_back(nullptr); m_equal_lin.push_back(nullptr); }
|
void push(unsigned) { m_units.push_back(nullptr); m_equal_lin.push_back(nullptr); m_diseq_lin.push_back(nullptr); }
|
||||||
|
|
||||||
void pop() { m_units.pop_back(); m_equal_lin.pop_back(); }
|
void pop() { m_units.pop_back(); m_equal_lin.pop_back(); m_diseq_lin.pop_back(); }
|
||||||
|
|
||||||
void pop_viable();
|
void pop_viable();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue