3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-08-09 20:50:50 +00:00

inequality propagation

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2021-08-08 13:21:15 -07:00
parent a4696a1c27
commit 6a829f831d
7 changed files with 720 additions and 56 deletions

View file

@ -90,12 +90,52 @@ static void test_interval2() {
std::cout << " < 500: " << i << " -> " << i.intersect_ult(500) << "\n";
i = mod_interval<uint32_t>(500, 10);
std::cout << " < 501: " << i << " -> " << i.intersect_ult(501) << "\n";
}
static void test_interval_intersect(unsigned i, unsigned j, unsigned k, unsigned l) {
if (i == j && i != 0)
return;
if (k == l && k != 0)
return;
mod_interval<uint8_t> x(i, j);
mod_interval<uint8_t> y(k, l);
auto r = x & y;
bool x_not_y = false, y_not_x = false;
// check that & computes a join
// it contains all elements in x, y
// it contains no elements neither in x, y
// it does not contain two elements, one in x\y the other in y\x
for (i = 0; i < 256; ++i) {
uint8_t c = (uint8_t)i;
if ((x.contains(c) && y.contains(c)) && !r.contains(c)) {
std::cout << x << " & " << y << " = " << r << "\n";
std::cout << i << " " << r.contains(c) << " " << x.contains(c) << " " << y.contains(c) << "\n";
}
VERIFY(!(x.contains(c) && y.contains(c)) || r.contains(c));
VERIFY(x.contains(c) || y.contains(c) || !r.contains(c));
if (r.contains(c) && x.contains(c) && !y.contains(c))
x_not_y = true;
if (r.contains(c) && !x.contains(c) && y.contains(c))
y_not_x = true;
}
if (x_not_y && y_not_x) {
std::cout << x << " & " << y << " = " << r << "\n";
VERIFY(!x_not_y || !y_not_x);
}
}
static void test_interval_intersect() {
unsigned bounds[8] = { 0, 1, 2, 3, 252, 253, 254, 255 };
for (unsigned i = 0; i < 8; ++i)
for (unsigned j = 0; j < 8; ++j)
for (unsigned k = 0; k < 8; ++k)
for (unsigned l = 0; l < 8; ++l)
test_interval_intersect(bounds[i], bounds[j], bounds[k], bounds[l]);
}
void tst_mod_interval() {
test_interval_intersect();
test_interval1();
test_interval2();
}