3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-05-07 07:45:46 +00:00

add bit shorthand

This commit is contained in:
Nikolaj Bjorner 2021-12-09 15:25:44 -08:00
parent a4fc63c542
commit bf258ee29d
3 changed files with 13 additions and 1 deletions

View file

@ -202,6 +202,17 @@ namespace polysat {
return ~ule(b, a);
}
/**
* encode that the i'th bit of p is 1.
* It holds if p << (K - i - 1) >= 2^{K-1}, where K is the bit-width.
*/
signed_constraint constraint_manager::bit(pdd const& p, unsigned i) {
unsigned K = p.manager().power_of_2();
pdd q = p * rational::power_of_two(K - i - 1);
rational msb = rational::power_of_two(K - 1);
return ule(p.manager().mk_val(msb), q);
}
signed_constraint constraint_manager::mul_ovfl(pdd const& a, pdd const& b) {
return { dedup(alloc(mul_ovfl_constraint, *this, a, b)), true };
}