3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-05-30 21:57:46 +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

@ -354,7 +354,7 @@ namespace sat {
bool found_conflict = false;
unsigned i = 0, sz = c.size();
s.push();
for (i = 0; !found_conflict && i < sz; i++) {
for (i = 0; !found_conflict && i < sz; ++i) {
if (i == flip_index) continue;
found_conflict = propagate_literal(c, ~c[i]);
}
@ -369,7 +369,7 @@ namespace sat {
bool asymm_branch::cleanup(scoped_detach& scoped_d, clause& c, unsigned skip_idx, unsigned new_sz) {
unsigned j = 0;
for (unsigned i = 0; i < new_sz; i++) {
for (unsigned i = 0; i < new_sz; ++i) {
if (skip_idx == i) continue;
literal l = c[i];
switch (s.value(l)) {
@ -441,7 +441,7 @@ namespace sat {
SASSERT(sz > 0);
unsigned i;
// check if the clause is already satisfied
for (i = 0; i < sz; i++) {
for (i = 0; i < sz; ++i) {
if (s.value(c[i]) == l_true) {
s.detach_clause(c);
s.del_clause(c);

View file

@ -32,7 +32,7 @@ namespace sat {
literal_vector lits, r;
SASSERT(num_lits == m_dag.size() && num_lits == m_roots.size());
size_t_map<bool> seen_idx;
for (unsigned l_idx = 0; l_idx < num_lits; l_idx++) {
for (unsigned l_idx = 0; l_idx < num_lits; ++l_idx) {
literal u = to_literal(l_idx);
if (s.was_eliminated(u.var()))
continue;
@ -122,7 +122,7 @@ namespace sat {
}
svector<pframe> todo;
// retrieve literals that have no predecessors
for (unsigned l_idx = 0; l_idx < num_lits; l_idx++) {
for (unsigned l_idx = 0; l_idx < num_lits; ++l_idx) {
literal u(to_literal(l_idx));
if (m_roots[u.index()]) {
todo.push_back(pframe(null_literal, u));

View file

@ -42,7 +42,7 @@ namespace sat {
var_approx_set clause::approx(unsigned num, literal const * lits) {
var_approx_set r;
for (unsigned i = 0; i < num; i++)
for (unsigned i = 0; i < num; ++i)
r.insert(lits[i].var());
return r;
}
@ -75,12 +75,12 @@ namespace sat {
void clause::elim(literal l) {
unsigned i;
for (i = 0; i < m_size; i++)
for (i = 0; i < m_size; ++i)
if (m_lits[i] == l)
break;
SASSERT(i < m_size);
i++;
for (; i < m_size; i++)
for (; i < m_size; ++i)
m_lits[i-1] = m_lits[i];
m_lits[m_size-1] = l;
m_size--;
@ -151,7 +151,7 @@ namespace sat {
memcpy(m_clause->m_lits, lits, sizeof(literal) * num_lits);
}
SASSERT(m_clause->m_size <= m_clause->m_capacity);
for (unsigned i = 0; i < num_lits; i++) {
for (unsigned i = 0; i < num_lits; ++i) {
SASSERT((*m_clause)[i] == lits[i]);
}
}
@ -205,7 +205,7 @@ namespace sat {
std::ostream & operator<<(std::ostream & out, clause const & c) {
out << "(";
for (unsigned i = 0; i < c.size(); i++) {
for (unsigned i = 0; i < c.size(); ++i) {
if (i > 0) out << " ";
out << c[i];
}
@ -225,7 +225,7 @@ namespace sat {
bool clause_wrapper::contains(literal l) const {
unsigned sz = size();
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
if (operator[](i) == l)
return true;
return false;
@ -233,7 +233,7 @@ namespace sat {
bool clause_wrapper::contains(bool_var v) const {
unsigned sz = size();
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
if (operator[](i).var() == v)
return true;
return false;

View file

@ -87,12 +87,12 @@ namespace sat {
for (; it != end; ++it) {
clause & c = *(*it);
TRACE(sat_cleaner_bug, tout << "cleaning: " << c << "\n";
for (unsigned i = 0; i < c.size(); i++) tout << c[i] << ": " << s.value(c[i]) << "\n";);
for (unsigned i = 0; i < c.size(); ++i) tout << c[i] << ": " << s.value(c[i]) << "\n";);
CTRACE(sat_cleaner_frozen, c.frozen(), tout << c << "\n";);
unsigned sz = c.size();
unsigned i = 0, j = 0;
m_cleanup_counter += sz;
for (; i < sz; i++) {
for (; i < sz; ++i) {
switch (s.value(c[i])) {
case l_true:
goto end_loop;

View file

@ -104,7 +104,7 @@ namespace sat {
TRACE(sats, tout << "processing: " << c << "\n";);
unsigned sz = c.size();
unsigned i;
for (i = 0; i < sz; i++) {
for (i = 0; i < sz; ++i) {
literal l = c[i];
literal r = norm(roots, l);
if (l != r)
@ -127,7 +127,7 @@ namespace sat {
}
// apply substitution
for (i = 0; i < sz; i++) {
for (i = 0; i < sz; ++i) {
literal lit = c[i];
c[i] = norm(roots, lit);
VERIFY(c[i] == norm(roots, c[i]));
@ -145,7 +145,7 @@ namespace sat {
// remove duplicates, and check if it is a tautology
unsigned j = 0;
literal l_prev = null_literal;
for (i = 0; i < sz; i++) {
for (i = 0; i < sz; ++i) {
literal l = c[i];
if (l == ~l_prev) {
break;

View file

@ -161,7 +161,7 @@ namespace sat {
unsigned sz = m_learned.size();
unsigned new_sz = sz/2; // std::min(sz/2, m_clauses.size()*2);
unsigned j = new_sz;
for (unsigned i = new_sz; i < sz; i++) {
for (unsigned i = new_sz; i < sz; ++i) {
clause & c = *(m_learned[i]);
if (can_delete(c)) {
detach_clause(c);
@ -200,7 +200,7 @@ namespace sat {
// d_tk
unsigned h = 0;
unsigned V_tk = 0;
for (bool_var v = 0; v < num_vars(); v++) {
for (bool_var v = 0; v < num_vars(); ++v) {
if (m_assigned_since_gc[v]) {
V_tk++;
m_assigned_since_gc[v] = false;
@ -289,7 +289,7 @@ namespace sat {
// do some cleanup
unsigned sz = c.size();
unsigned j = 0;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = c[i];
switch (value(l)) {
case l_true:

View file

@ -57,7 +57,7 @@ namespace sat {
bool integrity_checker::check_clause(clause const & c) const {
CTRACE(sat_bug, c.was_removed(), s.display(tout << "c: " << c.id() << ": " << c << "\n"));
SASSERT(!c.was_removed());
for (unsigned i = 0; i < c.size(); i++) {
for (unsigned i = 0; i < c.size(); ++i) {
VERIFY(c[i].var() <= s.num_vars());
CTRACE(sat_bug, s.was_eliminated(c[i].var()),
tout << "l: " << c[i].var() << "\n";
@ -74,7 +74,7 @@ namespace sat {
{
if (s.value(c[0]) == l_false || s.value(c[1]) == l_false) {
bool on_prop_stack = false;
for (unsigned i = s.m_qhead; i < s.m_trail.size(); i++) {
for (unsigned i = s.m_qhead; i < s.m_trail.size(); ++i) {
if (s.m_trail[i].var() == c[0].var() ||
s.m_trail[i].var() == c[1].var()) {
on_prop_stack = true;
@ -83,10 +83,10 @@ namespace sat {
}
// the clause has been satisfied or all other literals are assigned to false.
if (!on_prop_stack && s.status(c) != l_true) {
for (unsigned i = 2; i < c.size(); i++) {
for (unsigned i = 2; i < c.size(); ++i) {
CTRACE(sat_bug, s.value(c[i]) != l_false,
tout << c << " status: " << s.status(c) << "\n";
for (unsigned i = 0; i < c.size(); i++) tout << "val(" << i << "): " << s.value(c[i]) << "\n";);
for (unsigned i = 0; i < c.size(); ++i) tout << "val(" << i << "): " << s.value(c[i]) << "\n";);
VERIFY(s.value(c[i]) == l_false);
}
}
@ -133,7 +133,7 @@ namespace sat {
VERIFY(s.m_phase.size() == s.num_vars());
VERIFY(s.m_prev_phase.size() == s.num_vars());
VERIFY(s.m_assigned_since_gc.size() == s.num_vars());
for (bool_var v = 0; v < s.num_vars(); v++) {
for (bool_var v = 0; v < s.num_vars(); ++v) {
if (s.was_eliminated(v)) {
VERIFY(s.get_wlist(literal(v, false)).empty());
VERIFY(s.get_wlist(literal(v, true)).empty());

View file

@ -52,7 +52,7 @@ namespace sat {
entry.m_available = true;
entry.m_lits.reset();
unsigned tr_sz = s.m_trail.size();
for (unsigned i = old_tr_sz; i < tr_sz; i++) {
for (unsigned i = old_tr_sz; i < tr_sz; ++i) {
entry.m_lits.push_back(s.m_trail[i]);
if (s.m_config.m_drat) {
s.m_drat.add(~l, s.m_trail[i], status::redundant());
@ -98,7 +98,7 @@ namespace sat {
}
// collect literals that were assigned after assigning l
unsigned tr_sz = s.m_trail.size();
for (unsigned i = old_tr_sz; i < tr_sz; i++) {
for (unsigned i = old_tr_sz; i < tr_sz; ++i) {
if (m_assigned.contains(s.m_trail[i])) {
m_to_assert.push_back(s.m_trail[i]);
}
@ -145,7 +145,7 @@ namespace sat {
// collect literals that were assigned after assigning l
m_assigned.reset();
unsigned tr_sz = s.m_trail.size();
for (unsigned i = old_tr_sz; i < tr_sz; i++) {
for (unsigned i = old_tr_sz; i < tr_sz; ++i) {
literal lit = s.m_trail[i];
m_assigned.insert(lit);
@ -246,7 +246,7 @@ namespace sat {
int limit = -static_cast<int>(m_probing_limit);
unsigned i;
unsigned num = s.num_vars();
for (i = 0; i < num; i++) {
for (i = 0; i < num; ++i) {
bool_var v = (m_stopped_at + i) % num;
if (m_counter < limit) {
m_stopped_at = v;

View file

@ -81,7 +81,7 @@ namespace sat {
unsigned next_index = 0;
svector<frame> frames;
for (unsigned l_idx = 0; l_idx < num_lits; l_idx++) {
for (unsigned l_idx = 0; l_idx < num_lits; ++l_idx) {
if (index[l_idx] != UINT_MAX)
continue;
if (m_solver.was_eliminated(to_literal(l_idx).var()))
@ -234,7 +234,7 @@ namespace sat {
bool_var_vector to_elim;
if (!extract_roots(roots, to_elim))
return 0;
TRACE(scc, for (unsigned i = 0; i < roots.size(); i++) { tout << i << " -> " << roots[i] << "\n"; }
TRACE(scc, for (unsigned i = 0; i < roots.size(); ++i) { tout << i << " -> " << roots[i] << "\n"; }
tout << "to_elim: "; for (unsigned v : to_elim) tout << v << " "; tout << "\n";);
m_num_elim += to_elim.size();
elim_eqs eliminator(m_solver);

View file

@ -316,7 +316,7 @@ namespace sat {
if (learned && vars_eliminated) {
unsigned sz = c.size();
unsigned i;
for (i = 0; i < sz; i++) {
for (i = 0; i < sz; ++i) {
if (was_eliminated(c[i].var()))
break;
}
@ -585,7 +585,7 @@ namespace sat {
bool r = false;
unsigned sz = c.size();
unsigned j = 0;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = c[i];
switch (value(l)) {
case l_undef:
@ -625,7 +625,7 @@ namespace sat {
bool simplifier::cleanup_clause(literal_vector & c) {
unsigned sz = c.size();
unsigned j = 0;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = c[i];
switch (value(l)) {
case l_undef:
@ -653,7 +653,7 @@ namespace sat {
return;
m_use_list.reserve(s.num_vars());
unsigned new_trail_sz = s.m_trail.size();
for (unsigned i = old_trail_sz; i < new_trail_sz; i++) {
for (unsigned i = old_trail_sz; i < new_trail_sz; ++i) {
literal l = s.m_trail[i];
// put clauses with literals assigned to false back into todo-list
for (auto it = m_use_list.get(~l).mk_iterator(); !it.at_end(); it.next()) {
@ -727,12 +727,12 @@ namespace sat {
bool simplifier::subsume_with_binaries() {
unsigned init = s.m_rand(); // start in a random place, since subsumption can be aborted
unsigned num_lits = s.m_watches.size();
for (unsigned i = 0; i < num_lits; i++) {
for (unsigned i = 0; i < num_lits; ++i) {
unsigned l_idx = (i + init) % num_lits;
watch_list & wlist = get_wlist(to_literal(l_idx));
literal l = ~to_literal(l_idx);
// should not traverse wlist using iterators, since back_subsumption1 may add new binary clauses there
for (unsigned j = 0; j < wlist.size(); j++) {
for (unsigned j = 0; j < wlist.size(); ++j) {
watched w = wlist[j];
if (w.is_binary_non_learned_clause()) {
literal l2 = w.get_literal();
@ -1072,7 +1072,7 @@ namespace sat {
void insert_queue() {
m_queue.reset();
unsigned num_vars = s.s.num_vars();
for (bool_var v = 0; v < num_vars; v++) {
for (bool_var v = 0; v < num_vars; ++v) {
if (process_var(v)) {
insert(literal(v, false));
insert(literal(v, true));
@ -1656,7 +1656,7 @@ namespace sat {
m_counter -= c.size();
unsigned sz = c.size();
unsigned i;
for (i = 0; i < sz; i++) {
for (i = 0; i < sz; ++i) {
if (s.is_marked(~c[i]))
break;
}

View file

@ -151,7 +151,7 @@ namespace sat {
}
// create new vars
for (bool_var v = num_vars(); v < src.num_vars(); v++) {
for (bool_var v = num_vars(); v < src.num_vars(); ++v) {
bool ext = src.m_external[v];
bool dvar = src.m_decision[v];
VERIFY(v == mk_var(ext, dvar));
@ -344,7 +344,7 @@ namespace sat {
DEBUG_CODE({
for (unsigned i = 0; i < num_lits; i++) {
for (unsigned i = 0; i < num_lits; ++i) {
CTRACE(sat, was_eliminated(lits[i]), tout << lits[i] << " was eliminated\n";);
SASSERT(!was_eliminated(lits[i]));
}
@ -760,7 +760,7 @@ namespace sat {
unsigned max_false_idx = UINT_MAX;
unsigned unknown_idx = UINT_MAX;
unsigned n = cls.size();
for (unsigned i = starting_at; i < n; i++) {
for (unsigned i = starting_at; i < n; ++i) {
literal l = cls[i];
switch(value(l)) {
case l_false:
@ -799,7 +799,7 @@ namespace sat {
SASSERT(cls.size() >= 2);
unsigned max_false_idx = UINT_MAX;
unsigned num_lits = cls.size();
for (unsigned i = 1; i < num_lits; i++) {
for (unsigned i = 1; i < num_lits; ++i) {
literal l = cls[i];
CTRACE(sat, value(l) != l_false, tout << l << ":=" << value(l););
SASSERT(value(l) == l_false);
@ -815,7 +815,7 @@ namespace sat {
literal prev = null_literal;
unsigned i = 0;
unsigned j = 0;
for (; i < num_lits; i++) {
for (; i < num_lits; ++i) {
literal curr = lits[i];
lbool val = value(curr);
if (!lvl0 && lvl(curr) > 0)
@ -2140,7 +2140,7 @@ namespace sat {
m_model_is_current = true;
unsigned num = num_vars();
m_model.resize(num, l_undef);
for (bool_var v = 0; v < num; v++) {
for (bool_var v = 0; v < num; ++v) {
if (!was_eliminated(v)) {
m_model[v] = value(v);
m_phase[v] = value(v) == l_true;
@ -2150,7 +2150,7 @@ namespace sat {
TRACE(sat_mc_bug, m_mc.display(tout););
#if 0
IF_VERBOSE(2, for (bool_var v = 0; v < num; v++) verbose_stream() << v << ": " << m_model[v] << "\n";);
IF_VERBOSE(2, for (bool_var v = 0; v < num; ++v) verbose_stream() << v << ": " << m_model[v] << "\n";);
for (auto p : big::s_del_bin) {
if (value(p.first) != l_true && value(p.second) != l_true) {
IF_VERBOSE(2, verbose_stream() << "binary violation: " << p.first << " " << p.second << "\n");
@ -2174,12 +2174,12 @@ namespace sat {
if (m_clone && !check_clauses(m_model)) {
IF_VERBOSE(1, verbose_stream() << "failure checking clauses on transformed model\n";);
IF_VERBOSE(10, m_mc.display(verbose_stream()));
IF_VERBOSE(1, for (bool_var v = 0; v < num; v++) verbose_stream() << v << ": " << m_model[v] << "\n";);
IF_VERBOSE(1, for (bool_var v = 0; v < num; ++v) verbose_stream() << v << ": " << m_model[v] << "\n";);
throw solver_exception("check model failed");
}
TRACE(sat, for (bool_var v = 0; v < num; v++) tout << v << ": " << m_model[v] << "\n";);
TRACE(sat, for (bool_var v = 0; v < num; ++v) tout << v << ": " << m_model[v] << "\n";);
if (m_clone) {
IF_VERBOSE(1, verbose_stream() << "\"checking model (on original set of clauses)\"\n";);
@ -2529,7 +2529,7 @@ namespace sat {
}
}
unsigned sz = c.size();
for (; i < sz; i++)
for (; i < sz; ++i)
process_antecedent(~c[i], num_marks);
break;
}
@ -2699,7 +2699,7 @@ namespace sat {
}
}
unsigned sz = c.size();
for (; i < sz; i++)
for (; i < sz; ++i)
process_antecedent_for_unsat_core(~c[i]);
break;
}
@ -2910,7 +2910,7 @@ namespace sat {
unsigned from_lvl = m_conflict_lvl;
unsigned head = from_lvl == 0 ? 0 : m_scopes[from_lvl - 1].m_trail_lim;
unsigned sz = m_trail.size();
for (unsigned i = head; i < sz; i++) {
for (unsigned i = head; i < sz; ++i) {
bool_var v = m_trail[i].var();
TRACE(forget_phase, tout << "forgetting phase of v" << v << "\n";);
m_phase[v] = m_rand() % 2 == 0;
@ -3079,7 +3079,7 @@ namespace sat {
unsigned solver::num_diff_levels(unsigned num, literal const * lits) {
m_diff_levels.reserve(scope_lvl() + 1, false);
unsigned r = 0;
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
SASSERT(value(lits[i]) != l_undef);
unsigned lit_lvl = lvl(lits[i]);
if (!m_diff_levels[lit_lvl]) {
@ -3088,7 +3088,7 @@ namespace sat {
}
}
// reset m_diff_levels.
for (unsigned i = 0; i < num; i++)
for (unsigned i = 0; i < num; ++i)
m_diff_levels[lvl(lits[i])] = false;
return r;
}
@ -3097,7 +3097,7 @@ namespace sat {
m_diff_levels.reserve(scope_lvl() + 1, false);
glue = 0;
unsigned i = 0;
for (; i < num && glue < max_glue; i++) {
for (; i < num && glue < max_glue; ++i) {
SASSERT(value(lits[i]) != l_undef);
unsigned lit_lvl = lvl(lits[i]);
if (!m_diff_levels[lit_lvl]) {
@ -3115,7 +3115,7 @@ namespace sat {
m_diff_levels.reserve(scope_lvl() + 1, false);
glue = 0;
unsigned i = 0;
for (; i < num && glue < max_glue; i++) {
for (; i < num && glue < max_glue; ++i) {
if (value(lits[i]) == l_false) {
unsigned lit_lvl = lvl(lits[i]);
if (!m_diff_levels[lit_lvl]) {
@ -3201,7 +3201,7 @@ namespace sat {
i = 2;
}
unsigned sz = c.size();
for (; i < sz; i++) {
for (; i < sz; ++i) {
if (!process_antecedent_for_minimization(~c[i])) {
reset_unmark(old_size);
return false;
@ -3236,7 +3236,7 @@ namespace sat {
*/
void solver::reset_unmark(unsigned old_size) {
unsigned curr_size = m_unmark.size();
for(unsigned i = old_size; i < curr_size; i++)
for(unsigned i = old_size; i < curr_size; ++i)
reset_mark(m_unmark[i]);
m_unmark.shrink(old_size);
}
@ -3296,7 +3296,7 @@ namespace sat {
unsigned sz = m_lemma.size();
unsigned i = 1; // the first literal is the FUIP
unsigned j = 1;
for (; i < sz; i++) {
for (; i < sz; ++i) {
literal l = m_lemma[i];
if (implied_by_marked(l)) {
m_unmark.push_back(l.var());
@ -3380,7 +3380,7 @@ namespace sat {
*/
bool solver::dyn_sub_res() {
unsigned sz = m_lemma.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
mark_lit(m_lemma[i]);
}
@ -3390,7 +3390,7 @@ namespace sat {
// In the following loop, we use unmark_lit(l) to remove a
// literal from m_lemma.
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = m_lemma[i];
if (!is_marked_lit(l))
continue; // literal was eliminated
@ -3466,7 +3466,7 @@ namespace sat {
SASSERT(is_marked_lit(m_lemma[0]));
unsigned j = 0;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = m_lemma[i];
if (is_marked_lit(l)) {
unmark_lit(l);
@ -3664,7 +3664,7 @@ namespace sat {
unsigned sz = m_clauses_to_reinit.size();
SASSERT(old_sz <= sz);
unsigned j = old_sz;
for (unsigned i = old_sz; i < sz; i++) {
for (unsigned i = old_sz; i < sz; ++i) {
clause_wrapper cw = m_clauses_to_reinit[i];
bool reinit = false;
if (cw.is_binary()) {
@ -3836,7 +3836,7 @@ namespace sat {
void solver::collect_bin_clauses(svector<bin_clause> & r, bool redundant, bool learned_only) const {
SASSERT(redundant || !learned_only);
unsigned sz = m_watches.size();
for (unsigned l_idx = 0; l_idx < sz; l_idx++) {
for (unsigned l_idx = 0; l_idx < sz; ++l_idx) {
literal l = to_literal(l_idx);
l.neg();
for (watched const& w : m_watches[l_idx]) {
@ -3872,7 +3872,7 @@ namespace sat {
}
bool solver::check_marks() const {
for (bool_var v = 0; v < num_vars(); v++) {
for (bool_var v = 0; v < num_vars(); ++v) {
SASSERT(!is_marked(v));
}
return true;
@ -3880,7 +3880,7 @@ namespace sat {
std::ostream& solver::display_model(std::ostream& out) const {
unsigned num = num_vars();
for (bool_var v = 0; v < num; v++) {
for (bool_var v = 0; v < num; ++v) {
out << v << ": " << m_model[v] << "\n";
}
return out;
@ -3888,7 +3888,7 @@ namespace sat {
void solver::display_binary(std::ostream & out) const {
unsigned sz = m_watches.size();
for (unsigned l_idx = 0; l_idx < sz; l_idx++) {
for (unsigned l_idx = 0; l_idx < sz; ++l_idx) {
literal l = to_literal(l_idx);
l.neg();
for (watched const& w : m_watches[l_idx]) {
@ -4002,7 +4002,7 @@ namespace sat {
}
}
clause_vector const * vs[2] = { &m_clauses, &m_learned };
for (unsigned i = 0; i < 2; i++) {
for (unsigned i = 0; i < 2; ++i) {
clause_vector const & cs = *(vs[i]);
for (auto cp : cs) {
for (literal l : *cp) {
@ -4037,7 +4037,7 @@ namespace sat {
++l_idx;
}
clause_vector const * vs[2] = { &m_clauses, &m_learned };
for (unsigned i = 0; i < 2; i++) {
for (unsigned i = 0; i < 2; ++i) {
clause_vector const & cs = *(vs[i]);
for (clause const* cp : cs) {
clause const & c = *cp;
@ -4704,14 +4704,14 @@ namespace sat {
}
}
unsigned num_elim = 0;
for (bool_var v = 0; v < num_vars(); v++) {
for (bool_var v = 0; v < num_vars(); ++v) {
if (m_eliminated[v])
num_elim++;
}
unsigned num_ter = 0;
unsigned num_cls = 0;
clause_vector const * vs[2] = { &m_clauses, &m_learned };
for (unsigned i = 0; i < 2; i++) {
for (unsigned i = 0; i < 2; ++i) {
clause_vector const & cs = *(vs[i]);
for (clause* cp : cs) {
clause & c = *cp;

View file

@ -70,7 +70,7 @@ namespace sat {
inline std::ostream & operator<<(std::ostream & out, model const & m) {
bool first = true;
for (bool_var v = 0; v < m.size(); v++) {
for (bool_var v = 0; v < m.size(); ++v) {
if (m[v] == l_undef) continue;
if (first) first = false; else out << " ";
if (m[v] == l_true) out << v; else out << "-" << v;

View file

@ -157,7 +157,7 @@ namespace array {
unsigned num_args = select->get_num_args();
bool has_diff = false;
for (unsigned i = 1; i < num_args; i++)
for (unsigned i = 1; i < num_args; ++i)
has_diff |= expr2enode(select->get_arg(i))->get_root() != expr2enode(store->get_arg(i))->get_root();
if (!has_diff)
return false;
@ -165,7 +165,7 @@ namespace array {
sel1_args.push_back(store);
sel2_args.push_back(store->get_arg(0));
for (unsigned i = 1; i < num_args; i++) {
for (unsigned i = 1; i < num_args; ++i) {
sel1_args.push_back(select->get_arg(i));
sel2_args.push_back(select->get_arg(i));
}
@ -204,7 +204,7 @@ namespace array {
return s().value(sel_eq) != l_true;
};
for (unsigned i = 1; i < num_args; i++) {
for (unsigned i = 1; i < num_args; ++i) {
expr* idx1 = store->get_arg(i);
expr* idx2 = select->get_arg(i);
euf::enode* r1 = expr2enode(idx1);
@ -482,7 +482,7 @@ namespace array {
args2.push_back(e2);
svector<symbol> names;
sort_ref_vector sorts(m);
for (unsigned i = 0; i < dimension; i++) {
for (unsigned i = 0; i < dimension; ++i) {
sort * asrt = get_array_domain(srt, i);
sorts.push_back(asrt);
names.push_back(symbol(i));
@ -547,7 +547,7 @@ namespace array {
return false;
unsigned num_vars = get_num_vars();
bool change = false;
for (unsigned v = 0; v < num_vars; v++) {
for (unsigned v = 0; v < num_vars; ++v) {
auto& d = get_var_data(v);
if (!d.m_prop_upward)
continue;
@ -634,7 +634,7 @@ namespace array {
void solver::collect_shared_vars(sbuffer<theory_var>& roots) {
ptr_buffer<euf::enode> to_unmark;
unsigned num_vars = get_num_vars();
for (unsigned i = 0; i < num_vars; i++) {
for (unsigned i = 0; i < num_vars; ++i) {
euf::enode * n = var2enode(i);
if (!is_array(n))
continue;
@ -663,7 +663,7 @@ namespace array {
*/
bool solver::check_lambdas() {
unsigned num_vars = get_num_vars();
for (unsigned i = 0; i < num_vars; i++) {
for (unsigned i = 0; i < num_vars; ++i) {
auto* n = var2enode(i);
if (a.is_as_array(n->get_expr()) || is_lambda(n->get_expr()))
for (euf::enode* p : euf::enode_parents(n))

View file

@ -211,13 +211,13 @@ namespace array {
unsigned num_args = parent->num_args();
if (a.is_store(p)) {
set_array(parent->get_arg(0));
for (unsigned i = 1; i < num_args - 1; i++)
for (unsigned i = 1; i < num_args - 1; ++i)
set_index(parent->get_arg(i));
set_value(parent->get_arg(num_args - 1));
}
else if (a.is_select(p)) {
set_array(parent->get_arg(0));
for (unsigned i = 1; i < num_args - 1; i++)
for (unsigned i = 1; i < num_args - 1; ++i)
set_index(parent->get_arg(i));
}
else if (a.is_const(p)) {

View file

@ -166,7 +166,7 @@ namespace array {
bool solver::sel_eq::operator()(euf::enode * n1, euf::enode * n2) const {
SASSERT(n1->num_args() == n2->num_args());
unsigned num_args = n1->num_args();
for (unsigned i = 1; i < num_args; i++)
for (unsigned i = 1; i < num_args; ++i)
if (n1->get_arg(i)->get_root() != n2->get_arg(i)->get_root())
return false;
return true;
@ -199,7 +199,7 @@ namespace array {
for (euf::enode * r : m_selects_domain)
for (euf::enode* sel : *get_select_set(r))
propagate_select_to_store_parents(r, sel, todo);
for (unsigned qhead = 0; qhead < todo.size(); qhead++) {
for (unsigned qhead = 0; qhead < todo.size(); ++qhead) {
euf::enode_pair & pair = todo[qhead];
euf::enode * r = pair.first;
euf::enode * sel = pair.second;
@ -229,7 +229,7 @@ namespace array {
// check whether the sel idx was overwritten by the store
unsigned num_args = sel->num_args();
unsigned i = 1;
for (; i < num_args; i++) {
for (; i < num_args; ++i) {
if (sel->get_arg(i)->get_root() != parent->get_arg(i)->get_root())
break;
}

View file

@ -83,7 +83,7 @@ struct collect_boolean_interface_proc {
decl_kind k = to_app(t)->get_decl_kind();
if (k == OP_OR || k == OP_NOT || ((k == OP_EQ || k == OP_ITE) && m.is_bool(to_app(t)->get_arg(1)))) {
unsigned num = to_app(t)->get_num_args();
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
expr * arg = to_app(t)->get_arg(i);
if (fvisited.is_marked(arg))
continue;
@ -102,7 +102,7 @@ struct collect_boolean_interface_proc {
void operator()(T const & g) {
unsigned sz = g.size();
ptr_vector<expr> deps, all_deps;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (g.dep(i)) {
deps.reset();
m.linearize(g.dep(i), deps);
@ -110,17 +110,17 @@ struct collect_boolean_interface_proc {
}
}
for (unsigned i = 0; i < all_deps.size(); i++) {
for (unsigned i = 0; i < all_deps.size(); ++i) {
quick_for_each_expr(proc, tvisited, all_deps[i]);
}
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
process(g.form(i));
}
}
void operator()(unsigned sz, expr * const * fs) {
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
process(fs[i]);
}
};

View file

@ -244,7 +244,7 @@ namespace bv {
expr* e = var2expr(v);
unsigned bv_size = get_bv_size(v);
m_bits[v].reset();
for (unsigned i = 0; i < bv_size; i++) {
for (unsigned i = 0; i < bv_size; ++i) {
expr_ref b2b(bv.mk_bit2bool(e, i), m);
m_bits[v].push_back(sat::null_literal);
sat::literal lit = ctx.internalize(b2b, false, false);
@ -390,7 +390,7 @@ namespace bv {
SASSERT(bits.size() == sz);
SASSERT(m_bits[v].empty());
sat::literal true_literal = mk_true();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
expr* l = bits.get(i);
SASSERT(m.is_true(l) || m.is_false(l));
m_bits[v].push_back(m.is_true(l) ? true_literal : ~true_literal);

View file

@ -74,7 +74,7 @@ namespace bv {
theory_var curr = v;
do {
literal_vector const& lits = m_bits[curr];
for (unsigned i = 0; i < lits.size(); i++) {
for (unsigned i = 0; i < lits.size(); ++i) {
literal l = lits[i];
if (l.var() == mk_true().var()) {
assigned.push_back(l);

View file

@ -733,7 +733,7 @@ namespace bv {
unsigned num_vars = get_num_vars();
if (num_vars > 0)
out << "bv-solver:\n";
for (unsigned v = 0; v < num_vars; v++)
for (unsigned v = 0; v < num_vars; ++v)
out << pp(v);
return out;
}
@ -896,7 +896,7 @@ namespace bv {
unsigned sz = m_bits[v1].size();
if (sz == 1)
return;
for (unsigned idx = 0; !s().inconsistent() && idx < sz; idx++) {
for (unsigned idx = 0; !s().inconsistent() && idx < sz; ++idx) {
literal bit1 = m_bits[v1][idx];
literal bit2 = m_bits[v2][idx];
CTRACE(bv, bit1 == ~bit2, tout << pp(v1) << pp(v2) << "idx: " << idx << "\n";);
@ -1025,7 +1025,7 @@ namespace bv {
};
scoped_reset _sr(*this, bits1);
DEBUG_CODE(for (unsigned i = 0; i < bv_size; i++) SASSERT(m_merge_aux[0][i] == euf::null_theory_var || m_merge_aux[1][i] == euf::null_theory_var););
DEBUG_CODE(for (unsigned i = 0; i < bv_size; ++i) SASSERT(m_merge_aux[0][i] == euf::null_theory_var || m_merge_aux[1][i] == euf::null_theory_var););
// save info about bits1
for (auto& zo : bits1)
@ -1046,7 +1046,7 @@ namespace bv {
bits1.push_back(zo);
}
// reset m_merge_aux vector
DEBUG_CODE(for (unsigned i = 0; i < bv_size; i++) { SASSERT(m_merge_aux[0][i] == euf::null_theory_var || m_merge_aux[1][i] == euf::null_theory_var); });
DEBUG_CODE(for (unsigned i = 0; i < bv_size; ++i) { SASSERT(m_merge_aux[0][i] == euf::null_theory_var || m_merge_aux[1][i] == euf::null_theory_var); });
return true;
}

View file

@ -727,7 +727,7 @@ namespace dt {
sat::check_result r = sat::check_result::CR_DONE;
final_check_st _guard(*this);
int start = s().rand()();
for (int i = 0; i < num_vars; i++) {
for (int i = 0; i < num_vars; ++i) {
theory_var v = (i + start) % num_vars;
if (v != static_cast<int>(m_find.find(v)))
continue;
@ -881,7 +881,7 @@ namespace dt {
unsigned num_vars = get_num_vars();
if (num_vars > 0)
out << "Theory datatype:\n";
for (unsigned v = 0; v < num_vars; v++)
for (unsigned v = 0; v < num_vars; ++v)
display_var(out, v);
return out;
}

View file

@ -429,12 +429,12 @@ namespace fpa {
for (func_decl* f : seen)
mdl.unregister_decl(f);
for (unsigned i = 0; i < new_model.get_num_constants(); i++) {
for (unsigned i = 0; i < new_model.get_num_constants(); ++i) {
func_decl* f = new_model.get_constant(i);
mdl.register_decl(f, new_model.get_const_interp(f));
}
for (unsigned i = 0; i < new_model.get_num_functions(); i++) {
for (unsigned i = 0; i < new_model.get_num_functions(); ++i) {
func_decl* f = new_model.get_function(i);
func_interp* fi = new_model.get_func_interp(f)->copy();
mdl.register_decl(f, fi);

View file

@ -704,7 +704,7 @@ namespace pb {
}
}
unsigned sz = c.size();
for (; i < sz; i++)
for (; i < sz; ++i)
process_antecedent(c[i], offset);
break;
}
@ -1022,7 +1022,7 @@ namespace pb {
}
inc_bound(1);
unsigned sz = c.size();
for (; i < sz; i++)
for (; i < sz; ++i)
process_antecedent(c[i]);
break;
}
@ -1872,7 +1872,7 @@ namespace pb {
unsigned sz = m_learned.size();
unsigned new_sz = sz/2;
unsigned removed = 0;
for (unsigned i = new_sz; i < sz; i++) {
for (unsigned i = new_sz; i < sz; ++i) {
constraint* c = m_learned[i];
if (!m_constraint_to_reinit.contains(c)) {
remove_constraint(*c, "gc");

View file

@ -93,7 +93,7 @@ namespace q {
void ematch::ensure_ground_enodes(clause const& c) {
quantifier* q = c.q();
unsigned num_patterns = q->get_num_patterns();
for (unsigned i = 0; i < num_patterns; i++)
for (unsigned i = 0; i < num_patterns; ++i)
ensure_ground_enodes(q->get_pattern(i));
for (auto const& lit : c.m_lits) {
ensure_ground_enodes(lit.lhs);
@ -589,12 +589,12 @@ namespace q {
bool has_unary_pattern = false;
unsigned num_patterns = q->get_num_patterns();
for (unsigned i = 0; i < num_patterns && !has_unary_pattern; i++)
for (unsigned i = 0; i < num_patterns && !has_unary_pattern; ++i)
has_unary_pattern = (1 == to_app(q->get_pattern(i))->get_num_args());
unsigned num_eager_multi_patterns = ctx.get_config().m_qi_max_eager_multipatterns;
if (!has_unary_pattern)
num_eager_multi_patterns++;
for (unsigned i = 0, j = 0; i < num_patterns; i++) {
for (unsigned i = 0, j = 0; i < num_patterns; ++i) {
app * mp = to_app(q->get_pattern(i));
SASSERT(m.is_pattern(mp));
bool unary = (mp->get_num_args() == 1);

View file

@ -105,7 +105,7 @@ namespace q {
m_vals[SCOPE] = static_cast<float>(ctx.s().num_scopes());
m_vals[NESTED_QUANTIFIERS] = static_cast<float>(stat->get_num_nested_quantifiers());
m_vals[CS_FACTOR] = static_cast<float>(stat->get_case_split_factor());
TRACE(q_detail, for (unsigned i = 0; i < m_vals.size(); i++) { tout << m_vals[i] << " "; } tout << "\n";);
TRACE(q_detail, for (unsigned i = 0; i < m_vals.size(); ++i) { tout << m_vals[i] << " "; } tout << "\n";);
}
float queue::get_cost(binding& f) {

View file

@ -144,7 +144,7 @@ struct goal2sat::imp : public sat::sat_internalizer {
}
void mk_clause(unsigned n, sat::literal * lits, euf::th_proof_hint* ph) {
TRACE(goal2sat, tout << "mk_clause: "; for (unsigned i = 0; i < n; i++) tout << lits[i] << " "; tout << "\n";);
TRACE(goal2sat, tout << "mk_clause: "; for (unsigned i = 0; i < n; ++i) tout << lits[i] << " "; tout << "\n";);
if (relevancy_enabled())
ensure_euf()->add_aux(n, lits);
m_solver.add_clause(n, lits, mk_status(ph));
@ -166,7 +166,7 @@ struct goal2sat::imp : public sat::sat_internalizer {
}
void mk_root_clause(unsigned n, sat::literal * lits, euf::th_proof_hint* ph = nullptr) {
TRACE(goal2sat, tout << "mk_root_clause: "; for (unsigned i = 0; i < n; i++) tout << lits[i] << " "; tout << "\n";);
TRACE(goal2sat, tout << "mk_root_clause: "; for (unsigned i = 0; i < n; ++i) tout << lits[i] << " "; tout << "\n";);
if (relevancy_enabled())
ensure_euf()->add_root(n, lits);
m_solver.add_clause(n, lits, ph ? mk_status(ph) : sat::status::input());
@ -410,7 +410,7 @@ struct goal2sat::imp : public sat::sat_internalizer {
SASSERT(num == m_result_stack.size());
if (sign) {
// this case should not really happen.
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
sat::literal l = m_result_stack[i];
l.neg();
mk_root_clause(l);
@ -429,7 +429,7 @@ struct goal2sat::imp : public sat::sat_internalizer {
sat::literal l(k, false);
cache(t, l);
sat::literal * lits = m_result_stack.end() - num;
for (unsigned i = 0; i < num; i++)
for (unsigned i = 0; i < num; ++i)
mk_clause(~lits[i], l, mk_tseitin(~lits[i], l));
m_result_stack.push_back(~l);
@ -477,7 +477,7 @@ struct goal2sat::imp : public sat::sat_internalizer {
sat::literal * lits = m_result_stack.end() - num;
// l => /\ lits
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
mk_clause(~l, lits[i], mk_tseitin(~l, lits[i]));
}
// /\ lits => l
@ -933,7 +933,7 @@ struct goal2sat::imp : public sat::sat_internalizer {
expr_ref_vector fmls(m);
if (m_euf)
ensure_euf();
for (unsigned idx = 0; idx < size; idx++) {
for (unsigned idx = 0; idx < size; ++idx) {
f = g.form(idx);
// Add assumptions.
if (g.dep(idx)) {

View file

@ -112,7 +112,7 @@ class sat_tactic : public tactic {
if (produce_models) {
model_ref md = alloc(model, m);
sat::model const & ll_m = m_solver->get_model();
TRACE(sat_tactic, for (unsigned i = 0; i < ll_m.size(); i++) tout << i << ":" << ll_m[i] << " "; tout << "\n";);
TRACE(sat_tactic, for (unsigned i = 0; i < ll_m.size(); ++i) tout << i << ":" << ll_m[i] << " "; tout << "\n";);
for (auto const& kv : map) {
expr * n = kv.m_key;
sat::bool_var v = kv.m_value;