3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-09 10:30:59 +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:
Copilot 2026-01-14 19:55:31 -08:00 committed by GitHub
parent 1bf463d77a
commit 2436943794
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
475 changed files with 3237 additions and 3237 deletions

View file

@ -242,7 +242,7 @@ bv2fpa_converter::array_model bv2fpa_converter::convert_array_func_interp(model_
if (as_arr_mdl == 0) return am;
TRACE(bv2fpa, tout << "arity=0 func_interp for " << mk_ismt2_pp(f, m) << " := " << mk_ismt2_pp(as_arr_mdl, m) << std::endl;);
SASSERT(arr_util.is_as_array(as_arr_mdl));
for (unsigned i = 0; i < arity; i++)
for (unsigned i = 0; i < arity; ++i)
array_domain.push_back(to_sort(f->get_range()->get_parameter(i).get_ast()));
sort * rng = to_sort(f->get_range()->get_parameter(arity).get_ast());
@ -268,12 +268,12 @@ func_interp * bv2fpa_converter::convert_func_interp(model_core * mc, func_decl *
if (bv_fi) {
fpa_rewriter rw(m);
for (unsigned i = 0; i < bv_fi->num_entries(); i++) {
for (unsigned i = 0; i < bv_fi->num_entries(); ++i) {
func_entry const * bv_fe = bv_fi->get_entry(i);
expr * const * bv_args = bv_fe->get_args();
expr_ref_buffer new_args(m);
for (unsigned j = 0; j < arity; j++) {
for (unsigned j = 0; j < arity; ++j) {
sort * ft_dj = dmn[j];
expr * bv_aj = bv_args[j];
expr_ref ai = rebuild_floats(mc, ft_dj, to_app(bv_aj));
@ -288,12 +288,12 @@ func_interp * bv2fpa_converter::convert_func_interp(model_core * mc, func_decl *
TRACE(bv2fpa,
tout << "func_interp entry #" << i << ":" << std::endl;
tout << "(" << bv_f->get_name();
for (unsigned i = 0; i < bv_f->get_arity(); i++)
for (unsigned i = 0; i < bv_f->get_arity(); ++i)
tout << " " << mk_ismt2_pp(bv_args[i], m);
tout << ") = " << mk_ismt2_pp(bv_fres, m) << std::endl;
tout << " --> " << std::endl;
tout << "(" << f->get_name();
for (unsigned i = 0; i < new_args.size(); i++)
for (unsigned i = 0; i < new_args.size(); ++i)
tout << " " << mk_ismt2_pp(new_args[i], m);
tout << ") = " << mk_ismt2_pp(ft_fres, m) << std::endl;);
func_entry * fe = result->get_entry(new_args.data());

View file

@ -135,8 +135,8 @@ void fpa2bv_converter::mk_distinct(func_decl * f, unsigned num, expr * const * a
// equal, thus (distinct NaN NaN) is false, even if the two NaNs have
// different bitwise representations (see also mk_eq).
result = m.mk_true();
for (unsigned i = 0; i < num; i++) {
for (unsigned j = i+1; j < num; j++) {
for (unsigned i = 0; i < num; ++i) {
for (unsigned j = i+1; j < num; ++j) {
expr_ref eq(m), neq(m);
mk_eq(args[i], args[j], eq);
neq = m.mk_not(eq);
@ -260,7 +260,7 @@ expr_ref fpa2bv_converter::extra_quantify(expr * e) {
subst_map.resize(nv);
unsigned j = 0;
for (unsigned i = 0; i < nv; i++) {
for (unsigned i = 0; i < nv; ++i) {
if (uv.contains(i)) {
TRACE(fpa2bv, tout << "uv[" << i << "] = " << mk_ismt2_pp(uv.get(i), m) << std::endl; );
sort * s = uv.get(i);
@ -1900,7 +1900,7 @@ void fpa2bv_converter::mk_sqrt(func_decl * f, unsigned num, expr * const * args,
R = m_bv_util.mk_bv_sub(m_bv_util.mk_concat(sig_prime, m_bv_util.mk_numeral(0, 4)), Q);
S = Q;
for (unsigned i = 0; i < sbits + 3; i++) {
for (unsigned i = 0; i < sbits + 3; ++i) {
dbg_decouple("fpa2bv_sqrt_Q", Q);
dbg_decouple("fpa2bv_sqrt_R", R);
@ -2437,7 +2437,7 @@ void fpa2bv_converter::mk_is_positive(func_decl * f, unsigned num, expr * const
}
void fpa2bv_converter::mk_to_fp(func_decl * f, unsigned num, expr * const * args, expr_ref & result) {
TRACE(fpa2bv_to_fp, for (unsigned i=0; i < num; i++)
TRACE(fpa2bv_to_fp, for (unsigned i=0; i < num; ++i)
tout << "arg" << i << " = " << mk_ismt2_pp(args[i], m) << std::endl; );
if (num == 1 &&
@ -2910,7 +2910,7 @@ void fpa2bv_converter::mk_to_fp_real_int(func_decl * f, unsigned num, expr * con
}
void fpa2bv_converter::mk_to_real(func_decl * f, unsigned num, expr * const * args, expr_ref & result) {
TRACE(fpa2bv_to_real, for (unsigned i = 0; i < num; i++)
TRACE(fpa2bv_to_real, for (unsigned i = 0; i < num; ++i)
tout << "arg" << i << " = " << mk_ismt2_pp(args[i], m) << std::endl;);
SASSERT(num == 1);
SASSERT(f->get_num_parameters() == 0);
@ -3003,7 +3003,7 @@ void fpa2bv_converter::mk_to_real(func_decl * f, unsigned num, expr * const * ar
}
void fpa2bv_converter::mk_to_fp_signed(func_decl * f, unsigned num, expr * const * args, expr_ref & result) {
TRACE(fpa2bv_to_fp_signed, for (unsigned i = 0; i < num; i++)
TRACE(fpa2bv_to_fp_signed, for (unsigned i = 0; i < num; ++i)
tout << "arg" << i << " = " << mk_ismt2_pp(args[i], m) << std::endl;);
// This is a conversion from signed bitvector to float:
@ -3146,7 +3146,7 @@ void fpa2bv_converter::mk_to_fp_signed(func_decl * f, unsigned num, expr * const
}
void fpa2bv_converter::mk_to_fp_unsigned(func_decl * f, unsigned num, expr * const * args, expr_ref & result) {
TRACE(fpa2bv_to_fp_unsigned, for (unsigned i = 0; i < num; i++)
TRACE(fpa2bv_to_fp_unsigned, for (unsigned i = 0; i < num; ++i)
tout << "arg" << i << " = " << mk_ismt2_pp(args[i], m) << std::endl;);
// This is a conversion from unsigned bitvector to float:
@ -3333,7 +3333,7 @@ void fpa2bv_converter::mk_to_ieee_bv_i(func_decl * f, unsigned num, expr * const
}
void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args, bool is_signed, expr_ref & result) {
TRACE(fpa2bv_to_bv, for (unsigned i = 0; i < num; i++)
TRACE(fpa2bv_to_bv, for (unsigned i = 0; i < num; ++i)
tout << "arg" << i << " = " << mk_ismt2_pp(args[i], m) << std::endl;);
SASSERT(num == 2);
@ -3503,13 +3503,13 @@ void fpa2bv_converter::mk_to_bv(func_decl * f, unsigned num, expr * const * args
}
void fpa2bv_converter::mk_to_ubv(func_decl * f, unsigned num, expr * const * args, expr_ref & result) {
TRACE(fpa2bv_to_ubv, for (unsigned i = 0; i < num; i++)
TRACE(fpa2bv_to_ubv, for (unsigned i = 0; i < num; ++i)
tout << "arg" << i << " = " << mk_ismt2_pp(args[i], m) << std::endl;);
mk_to_bv(f, num, args, false, result);
}
void fpa2bv_converter::mk_to_sbv(func_decl * f, unsigned num, expr * const * args, expr_ref & result) {
TRACE(fpa2bv_to_sbv, for (unsigned i = 0; i < num; i++)
TRACE(fpa2bv_to_sbv, for (unsigned i = 0; i < num; ++i)
tout << "arg" << i << " = " << mk_ismt2_pp(args[i], m) << std::endl;);
mk_to_bv(f, num, args, true, result);
}

View file

@ -56,7 +56,7 @@ bool fpa2bv_rewriter_cfg::max_steps_exceeded(unsigned num_steps) const {
br_status fpa2bv_rewriter_cfg::reduce_app(func_decl * f, unsigned num, expr * const * args, expr_ref & result, proof_ref & result_pr) {
TRACE(fpa2bv_rw, tout << "func: " << f->get_name() << std::endl;
tout << "args: " << std::endl;
for (unsigned i = 0; i < num; i++)
for (unsigned i = 0; i < num; ++i)
tout << mk_ismt2_pp(args[i], m()) << std::endl;);
if (num == 0 && f->get_family_id() == null_family_id && m_conv.is_float(f->get_range())) {
@ -159,7 +159,7 @@ br_status fpa2bv_rewriter_cfg::reduce_app(func_decl * f, unsigned num, expr * co
default:
TRACE(fpa2bv, tout << "unsupported operator: " << f->get_name() << "\n";
for (unsigned i = 0; i < num; i++) tout << mk_ismt2_pp(args[i], m()) << std::endl;);
for (unsigned i = 0; i < num; ++i) tout << mk_ismt2_pp(args[i], m()) << std::endl;);
NOT_IMPLEMENTED_YET();
}
}
@ -183,7 +183,7 @@ bool fpa2bv_rewriter_cfg::pre_visit(expr * t)
quantifier * q = to_quantifier(t);
TRACE(fpa2bv, tout << "pre_visit quantifier [" << q->get_id() << "]: " << mk_ismt2_pp(q->get_expr(), m()) << std::endl;);
sort_ref_vector new_bindings(m_manager);
for (unsigned i = 0 ; i < q->get_num_decls(); i++)
for (unsigned i = 0 ; i < q->get_num_decls(); ++i)
new_bindings.push_back(q->get_decl_sort(i));
SASSERT(new_bindings.size() == q->get_num_decls());
m_bindings.append(new_bindings);
@ -209,7 +209,7 @@ bool fpa2bv_rewriter_cfg::reduce_quantifier(
string_buffer<> name_buffer;
ptr_buffer<sort> new_decl_sorts;
sbuffer<symbol> new_decl_names;
for (unsigned i = 0; i < num_decls; i++) {
for (unsigned i = 0; i < num_decls; ++i) {
symbol const & n = old_q->get_decl_name(i);
sort * s = old_q->get_decl_sort(i);
if (m_conv.is_float(s)) {