mirror of
https://github.com/Z3Prover/z3
synced 2026-02-19 23:14:40 +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
|
|
@ -27,7 +27,7 @@ func_decl * mk_aux_decl_for_array_sort(ast_manager & m, sort * s) {
|
|||
ptr_buffer<sort> domain;
|
||||
sort * range = get_array_range(s);
|
||||
unsigned arity = get_array_arity(s);
|
||||
for (unsigned i = 0; i < arity; i++) {
|
||||
for (unsigned i = 0; i < arity; ++i) {
|
||||
domain.push_back(get_array_domain(s, i));
|
||||
}
|
||||
return m.mk_fresh_func_decl(symbol::null, symbol::null, arity, domain.data(), range);
|
||||
|
|
@ -53,7 +53,7 @@ expr * array_factory::mk_array_interp(sort * s, func_interp * & fi) {
|
|||
|
||||
void array_factory::get_some_args_for(sort * s, ptr_buffer<expr> & args) {
|
||||
unsigned arity = get_array_arity(s);
|
||||
for (unsigned i = 0; i < arity; i++) {
|
||||
for (unsigned i = 0; i < arity; ++i) {
|
||||
sort * d = get_array_domain(s, i);
|
||||
expr * a = m_model.get_some_value(d);
|
||||
args.push_back(a);
|
||||
|
|
@ -162,7 +162,7 @@ expr * array_factory::get_fresh_value(sort * s) {
|
|||
ptr_buffer<expr> args2;
|
||||
bool found = false;
|
||||
unsigned arity = get_array_arity(s);
|
||||
for (unsigned i = 0; i < arity; i++) {
|
||||
for (unsigned i = 0; i < arity; ++i) {
|
||||
sort * d = get_array_domain(s, i);
|
||||
if (!found) {
|
||||
expr * arg1 = m_model.get_fresh_value(d);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ expr * datatype_factory::get_some_value(sort * s) {
|
|||
func_decl * c = m_util.get_non_rec_constructor(s);
|
||||
ptr_vector<expr> args;
|
||||
unsigned num = c->get_arity();
|
||||
for (unsigned i = 0; i < num; i++)
|
||||
for (unsigned i = 0; i < num; ++i)
|
||||
args.push_back(m_model.get_some_value(c->get_domain(i)));
|
||||
expr * r = m_manager.mk_app(c, args);
|
||||
register_value(r);
|
||||
|
|
@ -95,7 +95,7 @@ expr * datatype_factory::get_almost_fresh_value(sort * s) {
|
|||
bool found_fresh_arg = false;
|
||||
bool recursive = false;
|
||||
unsigned num = constructor->get_arity();
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
for (unsigned i = 0; i < num; ++i) {
|
||||
sort * s_arg = constructor->get_domain(i);
|
||||
if (!found_fresh_arg && (!m_util.is_datatype(s_arg) || !m_util.are_siblings(s, s_arg))) {
|
||||
expr * new_arg = m_model.get_fresh_value(s_arg);
|
||||
|
|
@ -163,7 +163,7 @@ expr * datatype_factory::get_fresh_value(sort * s) {
|
|||
expr_ref new_value(m_manager);
|
||||
bool found_fresh_arg = false;
|
||||
unsigned num = constructor->get_arity();
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
for (unsigned i = 0; i < num; ++i) {
|
||||
sort * s_arg = constructor->get_domain(i);
|
||||
if (!found_fresh_arg &&
|
||||
!m_util.is_recursive_nested(s_arg) &&
|
||||
|
|
@ -204,7 +204,7 @@ expr * datatype_factory::get_fresh_value(sort * s) {
|
|||
bool found_sibling = false;
|
||||
unsigned num = constructor->get_arity();
|
||||
TRACE(datatype, tout << "checking constructor: " << constructor->get_name() << "\n";);
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
for (unsigned i = 0; i < num; ++i) {
|
||||
sort * s_arg = constructor->get_domain(i);
|
||||
TRACE(datatype, tout << mk_pp(s, m_manager) << " "
|
||||
<< mk_pp(s_arg, m_manager) << " are_siblings "
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ func_entry::func_entry(ast_manager & m, unsigned arity, expr * const * args, exp
|
|||
m_result(result) {
|
||||
//SASSERT(is_ground(result));
|
||||
m.inc_ref(result);
|
||||
for (unsigned i = 0; i < arity; i++) {
|
||||
for (unsigned i = 0; i < arity; ++i) {
|
||||
expr * arg = args[i];
|
||||
//SASSERT(is_ground(arg));
|
||||
if (arg && !m.is_value(arg))
|
||||
|
|
@ -53,7 +53,7 @@ void func_entry::set_result(ast_manager & m, expr * r) {
|
|||
|
||||
bool func_entry::eq_args(ast_manager & m, unsigned arity, expr * const * args) const {
|
||||
unsigned i = 0;
|
||||
for (; i < arity; i++) {
|
||||
for (; i < arity; ++i) {
|
||||
if (!m.are_equal(m_args[i], args[i]))
|
||||
return false;
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ bool func_entry::eq_args(ast_manager & m, unsigned arity, expr * const * args) c
|
|||
}
|
||||
|
||||
void func_entry::deallocate(ast_manager & m, unsigned arity) {
|
||||
for (unsigned i = 0; i < arity; i++) {
|
||||
for (unsigned i = 0; i < arity; ++i) {
|
||||
m.dec_ref(m_args[i]);
|
||||
}
|
||||
m.dec_ref(m_result);
|
||||
|
|
@ -123,7 +123,7 @@ bool func_interp::is_fi_entry_expr(expr * e, ptr_vector<expr> & args) {
|
|||
return false;
|
||||
|
||||
args.resize(m_arity);
|
||||
for (unsigned i = 0; i < m_arity; i++) {
|
||||
for (unsigned i = 0; i < m_arity; ++i) {
|
||||
expr * ci = (m_arity == 1 && i == 0) ? c : to_app(c)->get_arg(i);
|
||||
|
||||
if (!m().is_eq(ci, a0, a1))
|
||||
|
|
@ -215,12 +215,12 @@ void func_interp::insert_new_entry(expr * const * args, expr * r) {
|
|||
CTRACE(func_interp_bug, get_entry(args) != 0,
|
||||
tout << "Old: " << mk_ismt2_pp(get_entry(args)->m_result, m()) << "\n";
|
||||
tout << "Args:";
|
||||
for (unsigned i = 0; i < m_arity; i++) {
|
||||
for (unsigned i = 0; i < m_arity; ++i) {
|
||||
tout << mk_ismt2_pp(get_entry(args)->get_arg(i), m()) << "\n";
|
||||
}
|
||||
tout << "New: " << mk_ismt2_pp(r, m()) << "\n";
|
||||
tout << "Args:";
|
||||
for (unsigned i = 0; i < m_arity; i++) {
|
||||
for (unsigned i = 0; i < m_arity; ++i) {
|
||||
tout << mk_ismt2_pp(args[i], m()) << "\n";
|
||||
}
|
||||
tout << "Old: " << mk_ismt2_pp(get_entry(args)->get_result(), m()) << "\n";
|
||||
|
|
@ -373,10 +373,10 @@ expr * func_interp::get_interp_core() const {
|
|||
if (m_else == curr->get_result())
|
||||
continue;
|
||||
if (vars.empty())
|
||||
for (unsigned i = 0; i < m_arity; i++)
|
||||
for (unsigned i = 0; i < m_arity; ++i)
|
||||
vars.push_back(m().mk_var(i, curr->get_arg(i)->get_sort()));
|
||||
ptr_buffer<expr> eqs;
|
||||
for (unsigned i = 0; i < m_arity; i++) {
|
||||
for (unsigned i = 0; i < m_arity; ++i) {
|
||||
eqs.push_back(m().mk_eq(vars[i], curr->get_arg(i)));
|
||||
}
|
||||
SASSERT(eqs.size() == m_arity);
|
||||
|
|
@ -407,7 +407,7 @@ expr_ref func_interp::get_array_interp_core(func_decl * f) const {
|
|||
bool ground = is_ground(m_else);
|
||||
for (func_entry * curr : m_entries) {
|
||||
ground &= is_ground(curr->get_result());
|
||||
for (unsigned i = 0; i < m_arity; i++)
|
||||
for (unsigned i = 0; i < m_arity; ++i)
|
||||
ground &= is_ground(curr->get_arg(i));
|
||||
}
|
||||
if (!ground) {
|
||||
|
|
@ -439,7 +439,7 @@ expr_ref func_interp::get_array_interp_core(func_decl * f) const {
|
|||
}
|
||||
args.reset();
|
||||
args.push_back(r);
|
||||
for (unsigned i = 0; i < m_arity; i++) {
|
||||
for (unsigned i = 0; i < m_arity; ++i) {
|
||||
args.push_back(curr->get_arg(i));
|
||||
}
|
||||
args.push_back(res);
|
||||
|
|
@ -476,7 +476,7 @@ func_interp * func_interp::translate(ast_translation & translator) const {
|
|||
|
||||
for (func_entry * curr : m_entries) {
|
||||
ptr_buffer<expr> new_args;
|
||||
for (unsigned i = 0; i < m_arity; i++)
|
||||
for (unsigned i = 0; i < m_arity; ++i)
|
||||
new_args.push_back(translator(curr->get_arg(i)));
|
||||
new_fi->insert_new_entry(new_args.data(), translator(curr->get_result()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -116,7 +116,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
|
|||
func_interp * fi = m_model.get_func_interp(f);
|
||||
bool r = (fi != nullptr) && eval_fi(fi, num, args, result);
|
||||
CTRACE(model_evaluator, r, tout << "reduce_app " << f->get_name() << "\n";
|
||||
for (unsigned i = 0; i < num; i++) tout << mk_ismt2_pp(args[i], m) << "\n";
|
||||
for (unsigned i = 0; i < num; ++i) tout << mk_ismt2_pp(args[i], m) << "\n";
|
||||
tout << "---->\n" << mk_ismt2_pp(result, m) << "\n";);
|
||||
return r;
|
||||
}
|
||||
|
|
@ -130,7 +130,7 @@ struct evaluator_cfg : public default_rewriter_cfg {
|
|||
|
||||
bool actuals_are_values = true;
|
||||
|
||||
for (unsigned i = 0; actuals_are_values && i < num; i++)
|
||||
for (unsigned i = 0; actuals_are_values && i < num; ++i)
|
||||
actuals_are_values = m.is_value(args[i]);
|
||||
|
||||
if (!actuals_are_values)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ void model_implicant::setup_model(model_ref& model) {
|
|||
m_model = model;
|
||||
rational r;
|
||||
unsigned sz = model->get_num_constants();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
func_decl * d = model->get_constant(i);
|
||||
expr* val = model->get_const_interp(d);
|
||||
expr* e = m.mk_const(d);
|
||||
|
|
@ -294,7 +294,7 @@ expr_ref_vector model_implicant::prune_by_cone_of_influence(ptr_vector<expr> con
|
|||
unsigned sz = m_model->get_num_constants();
|
||||
expr_ref e(m), eq(m), val(m);
|
||||
expr_ref_vector model(m);
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
e = m.mk_const(m_model->get_constant(i));
|
||||
if (m_visited.is_marked(e)) {
|
||||
val = eval(m_model, e);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ Revision History:
|
|||
static void display_uninterp_sorts(std::ostream & out, model_core const & md) {
|
||||
ast_manager & m = md.get_manager();
|
||||
unsigned sz = md.get_num_uninterpreted_sorts();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
sort * s = md.get_uninterpreted_sort(i);
|
||||
out << "(define-sort " << mk_pp(s, m);
|
||||
for (expr* e : md.get_universe(s)) {
|
||||
|
|
@ -40,7 +40,7 @@ static void display_uninterp_sorts(std::ostream & out, model_core const & md) {
|
|||
static void display_constants(std::ostream & out, model_core const & md) {
|
||||
ast_manager & m = md.get_manager();
|
||||
unsigned sz = md.get_num_constants();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
func_decl * c = md.get_constant(i);
|
||||
char const * d = "(define ";
|
||||
std::string n = c->get_name().str();
|
||||
|
|
@ -52,23 +52,23 @@ static void display_constants(std::ostream & out, model_core const & md) {
|
|||
static void display_functions(std::ostream & out, model_core const & md) {
|
||||
ast_manager & m = md.get_manager();
|
||||
unsigned sz = md.get_num_functions();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
func_decl * f = md.get_function(i);
|
||||
out << "(define (" << f->get_name();
|
||||
unsigned arity = f->get_arity();
|
||||
func_interp * fi = md.get_func_interp(f);
|
||||
for (unsigned j = 0; j < arity; j++) {
|
||||
for (unsigned j = 0; j < arity; ++j) {
|
||||
out << " " << "x!" << j;
|
||||
}
|
||||
out << ")\n";
|
||||
|
||||
unsigned num_entries = fi->num_entries();
|
||||
for (unsigned j = 0; j < num_entries; j++) {
|
||||
for (unsigned j = 0; j < num_entries; ++j) {
|
||||
func_entry const * curr = fi->get_entry(j);
|
||||
out << " (if ";
|
||||
if (arity > 1)
|
||||
out << "(and ";
|
||||
for (unsigned j = 0; j < arity; j++) {
|
||||
for (unsigned j = 0; j < arity; ++j) {
|
||||
out << "(= x!" << j << " " << mk_ismt2_pp(curr->get_arg(j), m) << ")";
|
||||
if (j + 1 < arity)
|
||||
out << " ";
|
||||
|
|
@ -84,7 +84,7 @@ static void display_functions(std::ostream & out, model_core const & md) {
|
|||
else {
|
||||
out << " " << mk_ismt2_pp(fi->get_else(), m, params_ref(), 5, arity, "x");
|
||||
}
|
||||
for (unsigned j = 0; j < num_entries; j++)
|
||||
for (unsigned j = 0; j < num_entries; ++j)
|
||||
out << ")";
|
||||
out << ")\n";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ Revision History:
|
|||
using namespace format_ns;
|
||||
|
||||
static void pp_indent(std::ostream & out, unsigned indent) {
|
||||
for (unsigned i = 0; i < indent; i++)
|
||||
for (unsigned i = 0; i < indent; ++i)
|
||||
out << " ";
|
||||
}
|
||||
|
||||
|
|
@ -58,7 +58,7 @@ static void pp_uninterp_sorts(std::ostream & out, ast_printer_context & ctx, mod
|
|||
ast_manager & m = ctx.get_ast_manager();
|
||||
ptr_buffer<format> f_conds;
|
||||
unsigned num = md.get_num_uninterpreted_sorts();
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
for (unsigned i = 0; i < num; ++i) {
|
||||
sort * s = md.get_uninterpreted_sort(i);
|
||||
ptr_vector<expr> const & u = md.get_universe(s);
|
||||
std::ostringstream buffer;
|
||||
|
|
@ -77,7 +77,7 @@ static void pp_uninterp_sorts(std::ostream & out, ast_printer_context & ctx, mod
|
|||
unsigned len = static_cast<unsigned>(buffer_str.length());
|
||||
pp_indent(out, indent);
|
||||
out << ";; ";
|
||||
for (unsigned i = 0; i < len; i++) {
|
||||
for (unsigned i = 0; i < len; ++i) {
|
||||
char c = buffer_str[i];
|
||||
if (c == '\n') {
|
||||
out << "\n";
|
||||
|
|
@ -139,7 +139,7 @@ static void pp_uninterp_sorts(std::ostream & out, ast_printer_context & ctx, mod
|
|||
|
||||
static void pp_consts(std::ostream & out, ast_printer_context & ctx, model_core const & md, unsigned indent) {
|
||||
unsigned num = md.get_num_constants();
|
||||
for (unsigned i = 0; i < num; i++) {
|
||||
for (unsigned i = 0; i < num; ++i) {
|
||||
func_decl * c = md.get_constant(i);
|
||||
expr * c_i = md.get_const_interp(c);
|
||||
pp_indent(out, indent);
|
||||
|
|
@ -158,7 +158,7 @@ void sort_fun_decls(ast_manager & m, model_core const & md, ptr_buffer<func_decl
|
|||
func_decl_set visited;
|
||||
ptr_vector<func_decl> todo;
|
||||
unsigned sz = md.get_num_functions();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
func_decl * f = md.get_function(i);
|
||||
if (visited.contains(f))
|
||||
continue;
|
||||
|
|
@ -210,19 +210,19 @@ static void pp_funs(std::ostream & out, ast_printer_context & ctx, model_core co
|
|||
var_names.reset();
|
||||
if (f_i->is_partial()) {
|
||||
body = mk_string(m, "#unspecified");
|
||||
for (unsigned j = 0; j < f->get_arity(); j++) {
|
||||
for (unsigned j = 0; j < f->get_arity(); ++j) {
|
||||
var_names.push_back(symbol("x!" + std::to_string(j+1)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
ctx.pp(f_i->get_else(), f->get_arity(), "x", body, var_names);
|
||||
}
|
||||
TRACE(model_smt2_pp, for (unsigned i = 0; i < var_names.size(); i++) tout << var_names[i] << "\n";);
|
||||
TRACE(model_smt2_pp, for (unsigned i = 0; i < var_names.size(); ++i) tout << var_names[i] << "\n";);
|
||||
f_var_names.reset();
|
||||
for (auto const& vn : var_names)
|
||||
f_var_names.push_back(mk_string(m, vn.bare_str()));
|
||||
f_arg_decls.reset();
|
||||
for (unsigned i = 0; i < f->get_arity(); i++) {
|
||||
for (unsigned i = 0; i < f->get_arity(); ++i) {
|
||||
format_ref f_domain(fm(m));
|
||||
ctx.pp(f->get_domain(i), f_domain);
|
||||
format * args[2] = { f_var_names[i], f_domain.get() };
|
||||
|
|
@ -233,10 +233,10 @@ static void pp_funs(std::ostream & out, ast_printer_context & ctx, model_core co
|
|||
ctx.pp(f->get_range(), f_range);
|
||||
if (f_i->num_entries() > 0) {
|
||||
f_entries.reset();
|
||||
for (unsigned i = 0; i < f_i->num_entries(); i++) {
|
||||
for (unsigned i = 0; i < f_i->num_entries(); ++i) {
|
||||
func_entry const * e = f_i->get_entry(i);
|
||||
f_entry_conds.reset();
|
||||
for (unsigned j = 0; j < f->get_arity(); j++) {
|
||||
for (unsigned j = 0; j < f->get_arity(); ++j) {
|
||||
format_ref f_arg(fm(m));
|
||||
ctx.pp(e->get_arg(j), f_arg);
|
||||
format * eq_args[2] = { f_var_names[j], f_arg.get() };
|
||||
|
|
@ -262,7 +262,7 @@ static void pp_funs(std::ostream & out, ast_printer_context & ctx, model_core co
|
|||
f_entries.push_back(mk_indent(m, TAB_SZ, mk_compose(m,
|
||||
mk_line_break(m),
|
||||
body.get())));
|
||||
for (unsigned i = 0; i < f_i->num_entries(); i++)
|
||||
for (unsigned i = 0; i < f_i->num_entries(); ++i)
|
||||
f_entries.push_back(mk_string(m, ")"));
|
||||
body = mk_compose(m, f_entries.size(), f_entries.data());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,10 +28,10 @@ static void display_function(std::ostream & out, model_core const & md, func_dec
|
|||
unsigned arity = g->get_arity();
|
||||
char const * else_str = num_entries == 0 ? " " : " else -> ";
|
||||
unsigned else_indent = static_cast<unsigned>(strlen(else_str));
|
||||
for (unsigned i = 0; i < num_entries; i++) {
|
||||
for (unsigned i = 0; i < num_entries; ++i) {
|
||||
func_entry const * entry = g->get_entry(i);
|
||||
out << " ";
|
||||
for (unsigned j = 0; j < arity; j++) {
|
||||
for (unsigned j = 0; j < arity; ++j) {
|
||||
expr * arg = entry->get_arg(j);
|
||||
out << mk_pp(arg, m);
|
||||
out << " ";
|
||||
|
|
@ -57,14 +57,14 @@ static void display_function(std::ostream & out, model_core const & md, func_dec
|
|||
|
||||
static void display_functions(std::ostream & out, model_core const & md, bool partial) {
|
||||
unsigned sz = md.get_num_functions();
|
||||
for (unsigned i = 0; i < sz; i++)
|
||||
for (unsigned i = 0; i < sz; ++i)
|
||||
display_function(out, md, md.get_function(i), partial);
|
||||
}
|
||||
|
||||
static void display_constants(std::ostream & out, model_core const & md) {
|
||||
ast_manager & m = md.get_manager();
|
||||
unsigned sz = md.get_num_constants();
|
||||
for (unsigned i = 0; i < sz; i++) {
|
||||
for (unsigned i = 0; i < sz; ++i) {
|
||||
func_decl * d = md.get_constant(i);
|
||||
|
||||
std::string name = d->get_name().str();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue