mirror of
https://github.com/Z3Prover/z3
synced 2026-02-23 16:57:51 +00:00
Standardize for-loop increments to prefix form (++i) (#8199)
* Initial plan * Convert postfix to prefix increment in for loops Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Fix member variable increment conversion bug Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> * Update API generator to produce prefix increments Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
parent
851b8ea31c
commit
317dd92105
475 changed files with 3237 additions and 3237 deletions
|
|
@ -189,7 +189,7 @@ void bound_propagator::init_eq(linear_equation * eq) {
|
|||
new_c.m_counter = 0;
|
||||
new_c.m_eq = eq;
|
||||
unsigned sz = eq->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m_watches[eq->x(i)].push_back(c_idx);
|
||||
}
|
||||
if (propagate(c_idx) && scope_lvl() > 0)
|
||||
|
|
@ -248,7 +248,7 @@ void bound_propagator::pop(unsigned num_scopes) {
|
|||
unsigned i = reinit_stack_sz;
|
||||
unsigned j = reinit_stack_sz;
|
||||
unsigned sz = m_reinit_stack.size();
|
||||
for (; i < sz; i++) {
|
||||
for (; i < sz; ++i) {
|
||||
unsigned c_idx = m_reinit_stack[i];
|
||||
bool p = propagate(c_idx);
|
||||
if (new_lvl > 0 && p) {
|
||||
|
|
@ -520,7 +520,7 @@ bool bound_propagator::propagate_eq(unsigned c_idx) {
|
|||
double ll = 0.0;
|
||||
double uu = 0.0;
|
||||
unsigned sz = eq->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x_i = eq->x(i);
|
||||
double a_i = eq->approx_a(i);
|
||||
bound * l_i = m_lowers[x_i];
|
||||
|
|
@ -583,7 +583,7 @@ bool bound_propagator::propagate_eq(unsigned c_idx) {
|
|||
|
||||
SASSERT(!ll_failed || !uu_failed);
|
||||
if (ll_i == UINT_MAX || uu_i == UINT_MAX) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x_i = eq->x(i);
|
||||
double a_i = eq->approx_a(i);
|
||||
bound * l_i = m_lowers[x_i];
|
||||
|
|
@ -672,7 +672,7 @@ bool bound_propagator::propagate_lower(unsigned c_idx, unsigned i) {
|
|||
mpq k;
|
||||
bool strict = false;
|
||||
bool neg_a_i = m.is_neg(a_i);
|
||||
for (unsigned j = 0; j < sz; j++) {
|
||||
for (unsigned j = 0; j < sz; ++j) {
|
||||
if (i == j)
|
||||
continue;
|
||||
var x_j = eq->x(j);
|
||||
|
|
@ -709,7 +709,7 @@ bool bound_propagator::propagate_upper(unsigned c_idx, unsigned i) {
|
|||
mpq k;
|
||||
bool strict = false;
|
||||
bool neg_a_i = m.is_neg(a_i);
|
||||
for (unsigned j = 0; j < sz; j++) {
|
||||
for (unsigned j = 0; j < sz; ++j) {
|
||||
if (i == j)
|
||||
continue;
|
||||
var x_j = eq->x(j);
|
||||
|
|
@ -821,7 +821,7 @@ void bound_propagator::explain(var x, bound * b, unsigned ts, assumption_vector
|
|||
if (!is_a_i_pos(*eq, x))
|
||||
is_lower = !is_lower;
|
||||
unsigned sz = eq->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x_i = eq->x(i);
|
||||
if (x_i == x)
|
||||
continue;
|
||||
|
|
@ -854,7 +854,7 @@ template<bool LOWER, typename Numeral>
|
|||
bool bound_propagator::get_bound(unsigned sz, Numeral const * as, var const * xs, mpq & r, bool & st) const {
|
||||
st = false;
|
||||
m.reset(r);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x_i = xs[i];
|
||||
Numeral const & a_i = as[i];
|
||||
if (m.is_zero(a_i))
|
||||
|
|
@ -880,7 +880,7 @@ bool bound_propagator::upper(unsigned sz, mpq const * as, var const * xs, mpq &
|
|||
}
|
||||
|
||||
void bound_propagator::display_bounds_of(std::ostream & out, linear_equation const & eq) const {
|
||||
for (unsigned i = 0; i < eq.size(); i++) {
|
||||
for (unsigned i = 0; i < eq.size(); ++i) {
|
||||
display_var_bounds(out, eq.x(i));
|
||||
out << "\n";
|
||||
}
|
||||
|
|
@ -916,7 +916,7 @@ void bound_propagator::display_var_bounds(std::ostream & out, var x, bool approx
|
|||
|
||||
void bound_propagator::display_bounds(std::ostream & out, bool approx, bool precise) const {
|
||||
unsigned num_vars = m_dead.size();
|
||||
for (unsigned x = 0; x < num_vars; x++) {
|
||||
for (unsigned x = 0; x < num_vars; ++x) {
|
||||
if (!is_dead(x)) {
|
||||
display_var_bounds(out, x, approx, precise);
|
||||
out << "\n";
|
||||
|
|
|
|||
|
|
@ -489,7 +489,7 @@ void bound_simplifier::restore_bounds() {
|
|||
m_fmls.add(dependent_expr(m, tmp, nullptr, nullptr));
|
||||
};
|
||||
|
||||
for (unsigned x = 0; x < sz; x++) {
|
||||
for (unsigned x = 0; x < sz; ++x) {
|
||||
expr* p = m_var2expr.get(x);
|
||||
has_l = bp.lower(x, l, strict_l, ts);
|
||||
has_u = bp.upper(x, u, strict_u, ts);
|
||||
|
|
@ -641,7 +641,7 @@ void find_ite_bounds(expr* root) {
|
|||
|
||||
void find_ite_bounds() {
|
||||
unsigned sz = m_new_goal->size();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
expr* f = m_new_goal->form(i);
|
||||
if (m.is_ite(f))
|
||||
find_ite_bounds(to_app(f));
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ Author:
|
|||
unsigned dependent_expr_state::num_exprs() {
|
||||
expr_fast_mark1 visited;
|
||||
unsigned r = 0;
|
||||
for (unsigned i = 0; i < qtail(); i++)
|
||||
for (unsigned i = 0; i < qtail(); ++i)
|
||||
r += get_num_exprs((*this)[i].fml(), visited);
|
||||
return r;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -322,7 +322,7 @@ void eliminate_predicates::insert_macro(app* head, expr* def, expr_dependency* d
|
|||
ptr_buffer<expr> vars, subst_args;
|
||||
subst_args.resize(num, nullptr);
|
||||
vars.resize(num, nullptr);
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
for (unsigned i = 0; i < num; ++i) {
|
||||
var* v = to_var(head->get_arg(i));
|
||||
var* w = m.mk_var(i, v->get_sort());
|
||||
unsigned idx = v->get_idx();
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ unsigned linear_equation::pos(unsigned x_i) const {
|
|||
|
||||
void linear_equation_manager::display(std::ostream & out, linear_equation const & eq) const {
|
||||
unsigned sz = eq.m_size;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
if (i > 0)
|
||||
out << " + ";
|
||||
out << m.to_string(eq.m_as[i]) << "*x" << eq.m_xs[i];
|
||||
|
|
@ -63,7 +63,7 @@ linear_equation * linear_equation_manager::mk(unsigned sz, mpq * as, var * xs, b
|
|||
mpz l;
|
||||
mpz r;
|
||||
m.set(l, as[0].denominator());
|
||||
for (unsigned i = 1; i < sz; i++) {
|
||||
for (unsigned i = 1; i < sz; ++i) {
|
||||
m.set(r, as[i].denominator());
|
||||
m.lcm(r, l, l);
|
||||
}
|
||||
|
|
@ -72,7 +72,7 @@ linear_equation * linear_equation_manager::mk(unsigned sz, mpq * as, var * xs, b
|
|||
|
||||
// copy l * as to m_int_buffer.
|
||||
m_int_buffer.reset();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
TRACE(linear_equation_mk, tout << "before as[" << i << "]: " << m.to_string(as[i]) << "\n";);
|
||||
m.mul(l, as[i], as[i]);
|
||||
TRACE(linear_equation_mk, tout << "after as[" << i << "]: " << m.to_string(as[i]) << "\n";);
|
||||
|
|
@ -91,16 +91,16 @@ linear_equation * linear_equation_manager::mk(unsigned sz, mpq * as, var * xs, b
|
|||
linear_equation * linear_equation_manager::mk_core(unsigned sz, mpz * as, var * xs) {
|
||||
SASSERT(sz > 0);
|
||||
DEBUG_CODE({
|
||||
for (unsigned i = 1; i < sz; i++) {
|
||||
for (unsigned i = 1; i < sz; ++i) {
|
||||
SASSERT(xs[i-1] < xs[i]);
|
||||
}
|
||||
});
|
||||
|
||||
TRACE(linear_equation_bug, for (unsigned i = 0; i < sz; i++) tout << m.to_string(as[i]) << "*x" << xs[i] << " "; tout << "\n";);
|
||||
TRACE(linear_equation_bug, for (unsigned i = 0; i < sz; ++i) tout << m.to_string(as[i]) << "*x" << xs[i] << " "; tout << "\n";);
|
||||
|
||||
mpz g;
|
||||
m.set(g, as[0]);
|
||||
for (unsigned i = 1; i < sz; i++) {
|
||||
for (unsigned i = 1; i < sz; ++i) {
|
||||
if (m.is_one(g))
|
||||
break;
|
||||
if (m.is_neg(as[i])) {
|
||||
|
|
@ -113,14 +113,14 @@ linear_equation * linear_equation_manager::mk_core(unsigned sz, mpz * as, var *
|
|||
}
|
||||
}
|
||||
if (!m.is_one(g)) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
m.div(as[i], g, as[i]);
|
||||
}
|
||||
}
|
||||
|
||||
TRACE(linear_equation_bug,
|
||||
tout << "g: " << m.to_string(g) << "\n";
|
||||
for (unsigned i = 0; i < sz; i++) tout << m.to_string(as[i]) << "*x" << xs[i] << " "; tout << "\n";);
|
||||
for (unsigned i = 0; i < sz; ++i) tout << m.to_string(as[i]) << "*x" << xs[i] << " "; tout << "\n";);
|
||||
|
||||
m.del(g);
|
||||
|
||||
|
|
@ -130,7 +130,7 @@ linear_equation * linear_equation_manager::mk_core(unsigned sz, mpz * as, var *
|
|||
mpz * new_as = reinterpret_cast<mpz*>(reinterpret_cast<char*>(new_eq) + sizeof(linear_equation));
|
||||
double * new_app_as = reinterpret_cast<double*>(reinterpret_cast<char*>(new_as) + sz * sizeof(mpz));
|
||||
var * new_xs = reinterpret_cast<var *>(reinterpret_cast<char*>(new_app_as) + sz * sizeof(double));
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
new (new_as + i) mpz();
|
||||
m.set(new_as[i], as[i]);
|
||||
new_app_as[i] = m.get_double(as[i]);
|
||||
|
|
@ -146,7 +146,7 @@ linear_equation * linear_equation_manager::mk_core(unsigned sz, mpz * as, var *
|
|||
|
||||
linear_equation * linear_equation_manager::mk(unsigned sz, mpz * as, var * xs, bool normalized) {
|
||||
if (!normalized) {
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = xs[i];
|
||||
m_mark.reserve(x+1, false);
|
||||
m_val_buffer.reserve(x+1);
|
||||
|
|
@ -161,7 +161,7 @@ linear_equation * linear_equation_manager::mk(unsigned sz, mpz * as, var * xs, b
|
|||
}
|
||||
|
||||
unsigned j = 0;
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = xs[i];
|
||||
if (m_mark[x]) {
|
||||
if (!m.is_zero(m_val_buffer[x])) {
|
||||
|
|
@ -178,26 +178,26 @@ linear_equation * linear_equation_manager::mk(unsigned sz, mpz * as, var * xs, b
|
|||
}
|
||||
else {
|
||||
DEBUG_CODE({
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = xs[i];
|
||||
m_mark.reserve(x+1, false);
|
||||
SASSERT(!m_mark[x]);
|
||||
m_mark[x] = true;
|
||||
}
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = xs[i];
|
||||
m_mark[x] = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = xs[i];
|
||||
m_val_buffer.reserve(x+1);
|
||||
m.swap(m_val_buffer[x], as[i]);
|
||||
}
|
||||
std::sort(xs, xs+sz);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
var x = xs[i];
|
||||
m.swap(as[i], m_val_buffer[x]);
|
||||
}
|
||||
|
|
@ -270,7 +270,7 @@ linear_equation * linear_equation_manager::mk(mpz const & b1, linear_equation co
|
|||
}
|
||||
|
||||
void linear_equation_manager::del(linear_equation * eq) {
|
||||
for (unsigned i = 0; i < eq->m_size; i++) {
|
||||
for (unsigned i = 0; i < eq->m_size; ++i) {
|
||||
m.del(eq->m_as[i]);
|
||||
}
|
||||
unsigned obj_sz = linear_equation::get_obj_size(eq->m_size);
|
||||
|
|
|
|||
|
|
@ -213,7 +213,7 @@ class reduce_args_simplifier : public dependent_expr_simplifier {
|
|||
// compute the hash-code using only the arguments where m_bv is true.
|
||||
unsigned a = 0x9e3779b9;
|
||||
unsigned num_args = n->get_num_args();
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
if (!m_bv.get(i))
|
||||
continue; // ignore argument
|
||||
a = hash_u_u(a, n->get_arg(i)->get_id());
|
||||
|
|
@ -230,7 +230,7 @@ class reduce_args_simplifier : public dependent_expr_simplifier {
|
|||
// compare only the arguments where m_bv is true
|
||||
SASSERT(n1->get_num_args() == n2->get_num_args());
|
||||
unsigned num_args = n1->get_num_args();
|
||||
for (unsigned i = 0; i < num_args; i++) {
|
||||
for (unsigned i = 0; i < num_args; ++i) {
|
||||
if (!m_bv.get(i))
|
||||
continue; // ignore argument
|
||||
if (n1->get_arg(i) != n2->get_arg(i))
|
||||
|
|
@ -306,7 +306,7 @@ class reduce_args_simplifier : public dependent_expr_simplifier {
|
|||
}
|
||||
|
||||
ptr_buffer<expr> new_args;
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
for (unsigned i = 0; i < num; ++i) {
|
||||
if (!bv.get(i))
|
||||
new_args.push_back(args[i]);
|
||||
}
|
||||
|
|
@ -339,7 +339,7 @@ class reduce_args_simplifier : public dependent_expr_simplifier {
|
|||
bit_vector & bv = decl2args.find(f);
|
||||
new_vars.reset();
|
||||
new_args.reset();
|
||||
for (unsigned i = 0; i < f->get_arity(); i++) {
|
||||
for (unsigned i = 0; i < f->get_arity(); ++i) {
|
||||
new_vars.push_back(m.mk_var(i, f->get_domain(i)));
|
||||
if (!bv.get(i))
|
||||
new_args.push_back(new_vars.back());
|
||||
|
|
@ -352,7 +352,7 @@ class reduce_args_simplifier : public dependent_expr_simplifier {
|
|||
}
|
||||
else {
|
||||
new_eqs.reset();
|
||||
for (unsigned i = 0; i < f->get_arity(); i++)
|
||||
for (unsigned i = 0; i < f->get_arity(); ++i)
|
||||
if (bv.get(i))
|
||||
new_eqs.push_back(m.mk_eq(new_vars.get(i), t->get_arg(i)));
|
||||
SASSERT(new_eqs.size() > 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue