mirror of
https://github.com/Z3Prover/z3
synced 2025-04-28 11:25:51 +00:00
simplify inequality propagation
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
commit
6af314c6d9
6 changed files with 126 additions and 209 deletions
|
@ -59,7 +59,10 @@ public:
|
|||
bool is_empty() const { return emp; }
|
||||
bool is_singleton() const { return !is_empty() && (lo + 1 == hi || (hi == 0 && is_max(lo))); }
|
||||
bool contains(Numeral const& n) const;
|
||||
bool contains(mod_interval const& other) const;
|
||||
virtual bool is_max(Numeral const& n) const { return (Numeral)(n + 1) == 0; }
|
||||
Numeral max() const;
|
||||
Numeral min() const;
|
||||
|
||||
void set_free() { lo = hi = 0; emp = false; }
|
||||
void set_bounds(Numeral const& l, Numeral const& h) { lo = l; hi = h; }
|
||||
|
|
|
@ -32,6 +32,27 @@ bool mod_interval<Numeral>::contains(Numeral const& n) const {
|
|||
return lo <= n || n < hi;
|
||||
}
|
||||
|
||||
template<typename Numeral>
|
||||
bool mod_interval<Numeral>::contains(mod_interval const& other) const {
|
||||
if (is_empty())
|
||||
return other.is_empty();
|
||||
if (is_free())
|
||||
return true;
|
||||
if (hi == 0)
|
||||
return lo <= other.lo && (other.lo < other.hi || other.hi == 0);
|
||||
if (lo < hi)
|
||||
return lo <= other.lo && other.hi <= hi;
|
||||
if (other.lo < other.hi && other.hi <= hi)
|
||||
return true;
|
||||
if (other.lo < other.hi && lo <= other.lo)
|
||||
return true;
|
||||
if (other.hi == 0)
|
||||
return lo <= other.lo;
|
||||
SASSERT(other.hi < other.lo && other.hi != 0);
|
||||
SASSERT(hi < lo && hi != 0);
|
||||
return lo <= other.lo && other.hi <= hi;
|
||||
}
|
||||
|
||||
template<typename Numeral>
|
||||
mod_interval<Numeral> mod_interval<Numeral>::operator+(mod_interval<Numeral> const& other) const {
|
||||
if (is_empty())
|
||||
|
@ -137,6 +158,23 @@ mod_interval<Numeral> mod_interval<Numeral>::operator&(mod_interval const& other
|
|||
|
||||
}
|
||||
|
||||
template<typename Numeral>
|
||||
Numeral mod_interval<Numeral>::max() const {
|
||||
if (lo < hi)
|
||||
return hi - 1;
|
||||
else
|
||||
return Numeral(0) - 1;
|
||||
}
|
||||
|
||||
template<typename Numeral>
|
||||
Numeral mod_interval<Numeral>::min() const {
|
||||
if (lo < hi || hi == 0)
|
||||
return lo;
|
||||
else
|
||||
return Numeral(0);
|
||||
}
|
||||
|
||||
|
||||
template<typename Numeral>
|
||||
Numeral mod_interval<Numeral>::closest_value(Numeral const& n) const {
|
||||
if (contains(n))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue