3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-25 10:05:32 +00:00

push outline of using cjust for overflow premise

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-09-09 09:56:00 +02:00
parent a5b7f9d77b
commit 611c28fc47
8 changed files with 101 additions and 15 deletions

View file

@ -332,5 +332,35 @@ namespace dd {
return true;
}
rational fdd::max(bdd b) const {
SASSERT(!b.is_false());
rational result(0);
for (unsigned i = num_bits(); i-- > 0; ) {
unsigned v = m_pos2var[i];
bdd w = m->mk_var(v);
bdd hi = b.cofactor(w);
if (!hi.is_false()) {
b = hi;
result += rational::power_of_two(i);
}
}
return result;
}
rational fdd::min(bdd b) const {
SASSERT(!b.is_false());
rational result(0);
for (unsigned i = num_bits(); i-- > 0; ) {
unsigned v = m_pos2var[i];
bdd nw = m->mk_nvar(v);
bdd lo = b.cofactor(nw);
if (lo.is_false())
result += rational::power_of_two(i);
else
b = lo;
}
return result;
}
}

View file

@ -78,26 +78,31 @@ namespace dd {
/** Like find, but returns hint if it is contained in the BDD. */
find_t find_hint(bdd b, rational const& hint, rational& out_val) const;
/*
* find largest value at lo or above such that bdd b evaluates to true
* at lo and all values between.
* dually, find smallest value below hi that evaluates b to true
* and all values between the value and hi also evaluate b to true.
* \param b - a bdd using variables from this
* \param lo/hi - bound to be traversed.
* \return false if b is false at lo/hi
* \pre variables in b are a subset of variables from the fdd
*/
bool sup(bdd const& b, bool_vector& lo) const;
/*
* find largest value at lo or above such that bdd b evaluates to true
* at lo and all values between.
* dually, find smallest value below hi that evaluates b to true
* and all values between the value and hi also evaluate b to true.
* \param b - a bdd using variables from this
* \param lo/hi - bound to be traversed.
* \return false if b is false at lo/hi
* \pre variables in b are a subset of variables from the fdd
*/
bool sup(bdd const& b, bool_vector& lo) const;
bool inf(bdd const& b, bool_vector& hi) const;
bool inf(bdd const& b, bool_vector& hi) const;
bool sup(bdd const& b, rational& lo) const;
bool inf(bdd const& b, rational& hi) const;
/*
* Find the min-max satisfying assignment.
* \pre b is not false.
*/
rational max(bdd b) const;
rational min(bdd b) const;
};
}

View file

@ -246,6 +246,7 @@ namespace dd {
inline bool is_one(PDD p) const { return p == one_pdd; }
inline bool is_val(PDD p) const { return m_nodes[p].is_val(); }
inline bool is_internal(PDD p) const { return m_nodes[p].is_internal(); }
inline bool is_var(PDD p) const { return !is_val(p) && is_zero(lo(p)) && is_one(hi(p)); }
bool is_never_zero(PDD p);
inline unsigned level(PDD p) const { return m_nodes[p].m_level; }
inline unsigned var(PDD p) const { return m_level2var[level(p)]; }
@ -388,6 +389,7 @@ namespace dd {
bool is_one() const { return m.is_one(root); }
bool is_zero() const { return m.is_zero(root); }
bool is_linear() const { return m.is_linear(root); }
bool is_var() const { return m.is_var(root); }
/** Polynomial is of the form: a * x + b */
bool is_unilinear() const { return !is_val() && lo().is_val() && hi().is_val(); }
bool is_unary() const { return !is_val() && lo().is_zero() && hi().is_val(); }