3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-28 17:08:45 +00:00
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2022-02-02 08:40:44 -08:00
parent 4c4f916917
commit 57d3abbf64

View file

@ -1197,52 +1197,55 @@ namespace polysat {
return true; return true;
} }
public: public:
static void exhaustive(unsigned bw = 0) { static void exhaustive(unsigned bw = 0) {
if (bw == 0) { if (bw == 0) {
exhaustive(1); exhaustive(1);
exhaustive(2); exhaustive(2);
exhaustive(3); exhaustive(3);
exhaustive(4); exhaustive(4);
exhaustive(5); exhaustive(5);
} else { }
std::cout << "test_fi::exhaustive for bw=" << bw << std::endl; else {
rational const m = rational::power_of_two(bw); std::cout << "test_fi::exhaustive for bw=" << bw << std::endl;
for (rational p(1); p < m; ++p) { rational const m = rational::power_of_two(bw);
for (rational r(1); r < m; ++r) { for (rational p(1); p < m; ++p) {
// TODO: remove this condition to test the cases other than disequal_lin! (also start p,q from 0) for (rational r(1); r < m; ++r) {
if (p == r) // TODO: remove this condition to test the cases other than disequal_lin! (also start p,q from 0)
continue; if (p == r)
for (rational q(0); q < m; ++q) continue;
for (rational s(0); s < m; ++s) for (rational q(0); q < m; ++q)
for (rational v(0); v < m; ++v) for (rational s(0); s < m; ++s)
for (bool negated : {true, false}) for (rational v(0); v < m; ++v)
check_one(p, q, r, s, v, negated, bw); for (bool negated : {true, false})
check_one(p, q, r, s, v, negated, bw);
}
} }
} }
} }
static void randomized(unsigned num_rounds = 100'000, unsigned bw = 16) { static void randomized(unsigned num_rounds = 100000, unsigned bw = 16) {
std::cout << "test_fi::randomized for bw=" << bw << " (" << num_rounds << " rounds)" << std::endl; std::cout << "test_fi::randomized for bw=" << bw << " (" << num_rounds << " rounds)" << std::endl;
rational const m = rational::power_of_two(bw); rational const m = rational::power_of_two(bw);
VERIFY(bw <= 32 && "random_gen generates 32-bit numbers"); VERIFY(bw <= 32 && "random_gen generates 32-bit numbers");
random_gen rng; random_gen rng;
unsigned round = num_rounds; unsigned round = num_rounds;
while (round) { while (round) {
// rational a1 = (rational(rng()) % (m - 1)) + 1; // rational a1 = (rational(rng()) % (m - 1)) + 1;
// rational a2 = (rational(rng()) % (m - 1)) + 1; // rational a2 = (rational(rng()) % (m - 1)) + 1;
rational a1 = rational(rng()) % m; rational a1 = rational(rng()) % m;
rational a2 = rational(rng()) % m; rational a2 = rational(rng()) % m;
if (a1.is_zero() || a2.is_zero() || a1 == a2) if (a1.is_zero() || a2.is_zero() || a1 == a2)
continue; continue;
rational b1 = rational(rng()) % m; rational b1 = rational(rng()) % m;
rational b2 = rational(rng()) % m; rational b2 = rational(rng()) % m;
rational val = rational(rng()) % m; rational val = rational(rng()) % m;
bool useful = bool useful =
check_one(a1, b1, a2, b2, val, true, bw) check_one(a1, b1, a2, b2, val, true, bw)
|| check_one(a1, b1, a2, b2, val, false, bw); || check_one(a1, b1, a2, b2, val, false, bw);
if (useful) if (useful)
round--; round--;
}
} }
}; // class test_fi }; // class test_fi