3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-15 13:28:47 +00:00

Merge pull request #1862 from kbobyrev/arith_eq_solver-cleanup

[NFC] Cleanup arith_eq_solver.(cpp|h)
This commit is contained in:
Nikolaj Bjorner 2018-10-02 08:48:49 -07:00 committed by GitHub
commit 55cc89b6bb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 78 additions and 81 deletions

View file

@ -17,9 +17,6 @@ Author:
#include "smt/arith_eq_solver.h" #include "smt/arith_eq_solver.h"
arith_eq_solver::~arith_eq_solver() {
}
arith_eq_solver::arith_eq_solver(ast_manager & m, params_ref const& p): arith_eq_solver::arith_eq_solver(ast_manager & m, params_ref const& p):
m(m), m(m),
m_params(p), m_params(p),
@ -93,9 +90,9 @@ void arith_eq_solver::gcd_normalize(vector<numeral>& values) {
if (g.is_zero() || g.is_one()) { if (g.is_zero() || g.is_one()) {
return; return;
} }
for (unsigned i = 0; i < values.size(); ++i) { for (auto &value : values) {
values[i] = values[i] / g; value /= g;
SASSERT(values[i].is_int()); SASSERT(value.is_int());
} }
} }
@ -216,8 +213,8 @@ bool arith_eq_solver::solve_integer_equation(
return true; return true;
} }
if (a.is_one()) { if (a.is_one()) {
for (unsigned i = 0; i < values.size(); ++i) { for (auto &value : values) {
values[i].neg(); value.neg();
} }
} }
is_fresh = !abs_a.is_one(); is_fresh = !abs_a.is_one();
@ -225,12 +222,12 @@ bool arith_eq_solver::solve_integer_equation(
if (is_fresh) { if (is_fresh) {
numeral m = abs_a + numeral(1); numeral m = abs_a + numeral(1);
for (unsigned i = 0; i < values.size(); ++i) { for (auto &value : values) {
values[i] = mod_hat(values[i], m); value = mod_hat(value, m);
} }
if (values[index].is_one()) { if (values[index].is_one()) {
for (unsigned i = 0; i < values.size(); ++i) { for (auto &value : values) {
values[i].neg(); value.neg();
} }
} }
SASSERT(values[index].is_minus_one()); SASSERT(values[index].is_minus_one());

View file

@ -35,7 +35,7 @@ class arith_eq_solver {
void prop_mod_const(expr * e, unsigned depth, numeral const& k, expr_ref& result); void prop_mod_const(expr * e, unsigned depth, numeral const& k, expr_ref& result);
bool gcd_test(vector<numeral>& value); bool gcd_test(vector<numeral>& values);
unsigned find_abs_min(vector<numeral>& values); unsigned find_abs_min(vector<numeral>& values);
void gcd_normalize(vector<numeral>& values); void gcd_normalize(vector<numeral>& values);
void substitute(vector<numeral>& r, vector<numeral> const& s, unsigned index); void substitute(vector<numeral>& r, vector<numeral> const& s, unsigned index);
@ -63,7 +63,7 @@ class arith_eq_solver {
public: public:
arith_eq_solver(ast_manager & m, params_ref const& p = params_ref()); arith_eq_solver(ast_manager & m, params_ref const& p = params_ref());
~arith_eq_solver(); ~arith_eq_solver() = default;
// Integer linear solver for a single equation. // Integer linear solver for a single equation.
// The array values contains integer coefficients // The array values contains integer coefficients