3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-02 23:27:53 +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

@ -30,20 +30,20 @@ namespace nlsat {
m_marked(false),
m_var_hash(0),
m_assumptions(as) {
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
m_lits[i] = lits[i];
}
}
bool clause::contains(literal l) const {
for (unsigned i = 0; i < m_size; i++)
for (unsigned i = 0; i < m_size; ++i)
if (m_lits[i] == l)
return true;
return false;
}
bool clause::contains(bool_var v) const {
for (unsigned i = 0; i < m_size; i++)
for (unsigned i = 0; i < m_size; ++i)
if (m_lits[i].var() == v)
return true;
return false;

View file

@ -64,7 +64,7 @@ namespace nlsat {
void reset() {
unsigned sz = m_sections.size();
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
m_am.del(m_sections[i].m_root);
m_sections.reset();
m_sorted_sections.reset();
@ -159,7 +159,7 @@ namespace nlsat {
// Must normalize signs since we use arithmetic operations such as *
// during evaluation.
// Without normalization, overflows may happen, and wrong results may be produced.
for (unsigned i = 0; i < num_poly_signs; i++)
for (unsigned i = 0; i < num_poly_signs; ++i)
m_poly_signs.push_back(signs[i]);
m_poly_sections.append(p_section_ids);
m_info.push_back(poly_info(roots.size(), first_section, first_sign));
@ -236,7 +236,7 @@ namespace nlsat {
unsigned num_roots = pinfo.m_num_roots;
if (num_roots < LINEAR_SEARCH_THRESHOLD) {
unsigned i = 0;
for (; i < num_roots; i++) {
for (; i < num_roots; ++i) {
unsigned section_cell_id = cell_id(pinfo, i);
if (section_cell_id == c)
return sign_zero;
@ -288,13 +288,13 @@ namespace nlsat {
bool check_invariant() const {
#ifdef Z3DEBUG
SASSERT(m_sections.size() == m_sorted_sections.size());
for (unsigned i = 0; i < m_sorted_sections.size(); i++) {
for (unsigned i = 0; i < m_sorted_sections.size(); ++i) {
SASSERT(m_sorted_sections[i] < m_sections.size());
SASSERT(m_sections[m_sorted_sections[i]].m_pos == i);
}
unsigned total_num_sections = 0;
unsigned total_num_signs = 0;
for (unsigned i = 0; i < m_info.size(); i++) {
for (unsigned i = 0; i < m_info.size(); ++i) {
SASSERT(m_info[i].m_first_section <= m_poly_sections.size());
SASSERT(m_info[i].m_num_roots == 0 || m_info[i].m_first_section < m_poly_sections.size());
SASSERT(m_info[i].m_first_sign < m_poly_signs.size());
@ -310,15 +310,15 @@ namespace nlsat {
// Display sign table for the given variable
void display(std::ostream & out) const {
out << "sections:\n ";
for (unsigned i = 0; i < m_sections.size(); i++) {
for (unsigned i = 0; i < m_sections.size(); ++i) {
if (i > 0) out << " < ";
m_am.display_decimal(out, m_sections[m_sorted_sections[i]].m_root);
}
out << "\n";
out << "sign variations:\n";
for (unsigned i = 0; i < m_info.size(); i++) {
for (unsigned i = 0; i < m_info.size(); ++i) {
out << " ";
for (unsigned j = 0; j < num_cells(); j++) {
for (unsigned j = 0; j < num_cells(); ++j) {
if (j > 0)
out << " ";
auto s = sign_at(i, j);
@ -333,21 +333,21 @@ namespace nlsat {
// Display sign table for the given variable
void display_raw(std::ostream & out) const {
out << "sections:\n ";
for (unsigned i = 0; i < m_sections.size(); i++) {
for (unsigned i = 0; i < m_sections.size(); ++i) {
if (i > 0) out << " < ";
m_am.display_decimal(out, m_sections[m_sorted_sections[i]].m_root);
}
out << "\n";
out << "poly_info:\n";
for (unsigned i = 0; i < m_info.size(); i++) {
for (unsigned i = 0; i < m_info.size(); ++i) {
out << " roots:";
poly_info const & info = m_info[i];
for (unsigned j = 0; j < info.m_num_roots; j++) {
for (unsigned j = 0; j < info.m_num_roots; ++j) {
out << " ";
out << m_poly_sections[info.m_first_section+j];
}
out << ", signs:";
for (unsigned j = 0; j < info.m_num_roots+1; j++) {
for (unsigned j = 0; j < info.m_num_roots+1; ++j) {
out << " ";
int s = m_poly_signs[info.m_first_sign+j];
if (s < 0) out << "-";
@ -407,7 +407,7 @@ namespace nlsat {
atom::kind k = a->get_kind();
unsigned sz = a->size();
int sign = 1;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
int curr_sign = eval_sign(a->p(i));
if (a->is_even(i) && curr_sign < 0)
curr_sign = 1;
@ -477,7 +477,7 @@ namespace nlsat {
sign sign_at(ineq_atom * a, sign_table const & t, unsigned c) const {
auto sign = sign_pos;
unsigned num_ps = a->size();
for (unsigned i = 0; i < num_ps; i++) {
for (unsigned i = 0; i < num_ps; ++i) {
::sign curr_sign = t.sign_at(i, c);
TRACE(nlsat_evaluator_bug, tout << "sign of i: " << i << " at cell " << c << "\n";
m_pm.display(tout, a->p(i));
@ -497,14 +497,14 @@ namespace nlsat {
TRACE(nlsat_evaluator, m_solver.display(tout, *a) << "\n";);
unsigned num_ps = a->size();
var x = a->max_var();
for (unsigned i = 0; i < num_ps; i++) {
for (unsigned i = 0; i < num_ps; ++i) {
add(a->p(i), x, table);
TRACE(nlsat_evaluator_bug, tout << "table after:\n"; m_pm.display(tout, a->p(i)); tout << "\n"; table.display_raw(tout););
}
TRACE(nlsat_evaluator,
tout << "sign table for:\n";
for (unsigned i = 0; i < num_ps; i++) { m_pm.display(tout, a->p(i)); tout << "\n"; }
for (unsigned i = 0; i < num_ps; ++i) { m_pm.display(tout, a->p(i)); tout << "\n"; }
table.display(tout););
interval_set_ref result(m_ism);
@ -519,7 +519,7 @@ namespace nlsat {
unsigned prev_root_id = UINT_MAX;
unsigned num_cells = table.num_cells();
for (unsigned c = 0; c < num_cells; c++) {
for (unsigned c = 0; c < num_cells; ++c) {
TRACE(nlsat_evaluator,
tout << "cell: " << c << "\n";
tout << "prev_sat: " << prev_sat << "\n";

View file

@ -62,7 +62,7 @@ namespace nlsat {
void reset() {
pmanager & pm = m_set.m();
unsigned sz = m_set.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
m_in_set[pm.id(m_set.get(i))] = false;
}
m_set.reset();
@ -85,7 +85,7 @@ namespace nlsat {
pmanager & pm = m_set.m();
var max = null_var;
unsigned sz = m_set.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
var x = pm.max_var(m_set.get(i));
SASSERT(x != null_var);
if (max == null_var || x > max)
@ -104,7 +104,7 @@ namespace nlsat {
pmanager & pm = m_set.m();
unsigned sz = m_set.size();
unsigned j = 0;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
poly * p = m_set.get(i);
var y = pm.max_var(p);
SASSERT(y <= x);
@ -168,7 +168,7 @@ namespace nlsat {
}
std::ostream& display(std::ostream & out, polynomial_ref_vector const & ps, char const * delim = "\n") const {
for (unsigned i = 0; i < ps.size(); i++) {
for (unsigned i = 0; i < ps.size(); ++i) {
if (i > 0)
out << delim;
m_pm.display(out, ps.get(i), m_solver.display_proc());
@ -245,12 +245,12 @@ namespace nlsat {
*/
void collect_polys(unsigned num, literal const * ls, polynomial_ref_vector & ps) {
ps.reset();
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
atom * a = m_atoms[ls[i].var()];
SASSERT(a != 0);
if (a->is_ineq_atom()) {
unsigned sz = to_ineq_atom(a)->size();
for (unsigned j = 0; j < sz; j++)
for (unsigned j = 0; j < sz; ++j)
ps.push_back(to_ineq_atom(a)->p(j));
}
else {
@ -317,7 +317,7 @@ namespace nlsat {
m_am.display_decimal(tout, y_val); tout << "\n";);
polynomial_ref p(m_pm);
unsigned sz = ps.size();
for (unsigned k = 0; k < sz; k++) {
for (unsigned k = 0; k < sz; ++k) {
p = ps.get(k);
if (max_var(p) != y)
continue;
@ -334,7 +334,7 @@ namespace nlsat {
tout << "\n";
});
bool all_lt = true;
for (unsigned i = 0; i < num_roots; i++) {
for (unsigned i = 0; i < num_roots; ++i) {
int s = m_am.compare(y_val, roots[i]);
TRACE(nlsat_explain,
m_am.display_decimal(tout << "comparing root: ", roots[i]); tout << "\n";
@ -487,7 +487,7 @@ namespace nlsat {
unsigned j = 0;
unsigned sz = ps.size();
polynomial_ref p(m_pm);
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
p = ps.get(i);
elim_vanishing(p);
if (!is_const(p)) {
@ -536,7 +536,7 @@ namespace nlsat {
int atom_sign = 1;
unsigned sz = a->size();
bool normalized = false; // true if the literal needs to be normalized
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
p = a->p(i);
if (max_var(p) == max)
elim_vanishing(p); // eliminate vanishing coefficients of max
@ -615,7 +615,7 @@ namespace nlsat {
void normalize(scoped_literal_vector & C, var max) {
unsigned sz = C.size();
unsigned j = 0;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal new_l = normalize(C[i], max);
if (new_l == true_literal)
continue;
@ -641,7 +641,7 @@ namespace nlsat {
var max = max_var(ps.get(0));
SASSERT(max != null_var); // there are no constant polynomials in ps
unsigned sz = ps.size();
for (unsigned i = 1; i < sz; i++) {
for (unsigned i = 1; i < sz; ++i) {
var curr = m_pm.max_var(ps.get(i));
SASSERT(curr != null_var);
if (curr > max)
@ -663,7 +663,7 @@ namespace nlsat {
*/
var max_var(unsigned sz, literal const * ls) {
var max = null_var;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = ls[i];
atom * a = m_atoms[l.var()];
if (a != nullptr) {
@ -682,7 +682,7 @@ namespace nlsat {
void keep_p_x(polynomial_ref_vector & ps, var x, polynomial_ref_vector & qs) {
unsigned sz = ps.size();
unsigned j = 0;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
poly * q = ps.get(i);
if (max_var(q) != x) {
qs.push_back(q);
@ -709,7 +709,7 @@ namespace nlsat {
factor(p, m_factors);
TRACE(nlsat_explain, display(tout << "adding factors of\n", p); tout << "\n" << m_factors << "\n";);
polynomial_ref f(m_pm);
for (unsigned i = 0; i < m_factors.size(); i++) {
for (unsigned i = 0; i < m_factors.size(); ++i) {
f = m_factors.get(i);
elim_vanishing(f);
if (!is_const(f)) {
@ -731,7 +731,7 @@ namespace nlsat {
polynomial_ref coeff(m_pm);
// Add the leading or all coeffs, depening on being square-free
for (unsigned i = 0; i < ps.size(); i++) {
for (unsigned i = 0; i < ps.size(); ++i) {
p = ps.get(i);
unsigned k_deg = m_pm.degree(p, x);
if (k_deg == 0) continue;
@ -752,9 +752,9 @@ namespace nlsat {
polynomial_ref q(m_pm);
SASSERT(samples.size() <= 2);
for (unsigned i = 0; i < ps.size(); i++){
for (unsigned i = 0; i < ps.size(); ++i){
p = ps.get(i);
for (unsigned j = 0; j < samples.size(); j++){
for (unsigned j = 0; j < samples.size(); ++j){
q = samples.get(j);
if (!m_pm.eq(p, q)) {
psc(p, q, x);
@ -772,7 +772,7 @@ namespace nlsat {
m_is_even.reset();
polynomial_ref f(m_pm);
bool have_zero = false;
for (unsigned i = 0; i < num_factors; i++) {
for (unsigned i = 0; i < num_factors; ++i) {
f = m_factors.get(i);
if (coeffs_are_zeroes_in_factor(f)) {
have_zero = true;
@ -784,7 +784,7 @@ namespace nlsat {
var x = max_var(f);
unsigned n = degree(f, x);
auto c = polynomial_ref(this->m_pm);
for (unsigned j = 0; j <= n; j++) {
for (unsigned j = 0; j <= n; ++j) {
c = m_pm.coeff(s, x, j);
SASSERT(sign(c) == 0);
ensure_sign(c);
@ -797,7 +797,7 @@ namespace nlsat {
var x = max_var(s);
unsigned n = degree(s, x);
auto c = polynomial_ref(this->m_pm);
for (unsigned j = 0; j <= n; j++) {
for (unsigned j = 0; j <= n; ++j) {
c = m_pm.coeff(s, x, j);
if (sign(c) != 0)
return false;
@ -820,7 +820,7 @@ namespace nlsat {
tout << "psc: " << s << "\n";
});
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
s = S.get(i);
TRACE(nlsat_explain, display(tout << "processing psc(" << i << ")\n", s) << "\n";);
if (is_zero(s)) {
@ -860,7 +860,7 @@ namespace nlsat {
polynomial_ref p(m_pm);
polynomial_ref p_prime(m_pm);
unsigned sz = ps.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
p = ps.get(i);
if (degree(p, x) < 2)
continue;
@ -881,9 +881,9 @@ namespace nlsat {
polynomial_ref p(m_pm);
polynomial_ref q(m_pm);
unsigned sz = ps.size();
for (unsigned i = 0; i < sz - 1; i++) {
for (unsigned i = 0; i < sz - 1; ++i) {
p = ps.get(i);
for (unsigned j = i + 1; j < sz; j++) {
for (unsigned j = i + 1; j < sz; ++j) {
q = ps.get(j);
psc(p, q, x);
}
@ -1090,7 +1090,7 @@ namespace nlsat {
*/
bool all_univ(polynomial_ref_vector const & ps, var x) {
unsigned sz = ps.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
poly * p = ps.get(i);
if (max_var(p) != x)
return false;
@ -1146,7 +1146,7 @@ namespace nlsat {
return;
m_todo.reset();
for (unsigned i = 0; i < ps.size(); i++) {
for (unsigned i = 0; i < ps.size(); ++i) {
polynomial_ref p(m_pm);
p = ps.get(i);
insert_fresh_factors_in_todo(p);
@ -1298,7 +1298,7 @@ namespace nlsat {
polynomial_ref_buffer new_factors(m_pm);
sbuffer<bool> new_factors_even;
polynomial_ref new_factor(m_pm);
for (unsigned s = 0; s < num_factors; s++) {
for (unsigned s = 0; s < num_factors; ++s) {
poly * f = _a->p(s);
bool is_even = _a->is_even(s);
if (m_pm.degree(f, info.m_x) < info.m_k) {
@ -1445,7 +1445,7 @@ namespace nlsat {
scoped_literal new_lit(m_solver);
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];
new_lit = null_literal;
simplify(l, info, max, new_lit);
@ -1484,7 +1484,7 @@ namespace nlsat {
poly * r = nullptr;
unsigned min_d = UINT_MAX;
unsigned sz = C.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = C[i];
if (l.sign())
continue;
@ -1526,7 +1526,7 @@ namespace nlsat {
continue; // we don't rewrite root atoms
ineq_atom * _a = to_ineq_atom(a);
unsigned num_factors = _a->size();
for (unsigned j = 0; j < num_factors; j++) {
for (unsigned j = 0; j < num_factors; ++j) {
poly * p = _a->p(j);
xs.reset();
m_pm.vars(p, xs);
@ -1627,7 +1627,7 @@ namespace nlsat {
interval_set_ref r(ism);
// Copy the union of the infeasible intervals of core into r.
unsigned sz = core.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = core[i];
atom * a = m_atoms[l.var()];
SASSERT(a != 0);
@ -1646,7 +1646,7 @@ namespace nlsat {
}
// Copy the union of the infeasible intervals of todo into r until r becomes full.
sz = todo.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = todo[i];
atom * a = m_atoms[l.var()];
SASSERT(a != 0);

View file

@ -99,7 +99,7 @@ namespace nlsat {
// Check if the intervals are valid, ordered, and are disjoint.
bool check_interval_set(anum_manager & am, unsigned sz, interval const * ints) {
#ifdef Z3DEBUG
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
interval const & curr = ints[i];
SASSERT(check_interval(am, curr));
SASSERT(i >= sz - 1 || check_no_overlap(am, curr, ints[i+1]));
@ -118,7 +118,7 @@ namespace nlsat {
return;
unsigned num = s->m_num_intervals;
unsigned obj_sz = interval_set::get_obj_size(num);
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
m_am.del(s->m_intervals[i].m_lower);
m_am.del(s->m_intervals[i].m_upper);
}
@ -473,7 +473,7 @@ namespace nlsat {
// Remark: we only combine adjacent intervals when they have the same justification
unsigned j = 0;
unsigned sz = result.size();
for (unsigned i = 1; i < sz; i++) {
for (unsigned i = 1; i < sz; ++i) {
interval & curr = result[j];
interval & next = result[i];
if (curr.m_justification == next.m_justification &&
@ -498,7 +498,7 @@ namespace nlsat {
}
}
j++;
for (unsigned i = j; i < sz; i++) {
for (unsigned i = j; i < sz; ++i) {
interval & curr = result[i];
m_am.del(curr.m_lower);
m_am.del(curr.m_upper);
@ -509,7 +509,7 @@ namespace nlsat {
SASSERT(sz >= 1);
bool found_slack = !result[0].m_lower_inf || !result[sz-1].m_upper_inf;
// Check if full
for (unsigned i = 0; i < sz - 1 && !found_slack; i++) {
for (unsigned i = 0; i < sz - 1 && !found_slack; ++i) {
if (!adjacent(m_am, result[i], result[i+1]))
found_slack = true;
}
@ -635,7 +635,7 @@ namespace nlsat {
return s1 == s2;
if (s1->m_num_intervals != s2->m_num_intervals)
return false;
for (unsigned i = 0; i < s1->m_num_intervals; i++) {
for (unsigned i = 0; i < s1->m_num_intervals; ++i) {
interval const & int1 = s1->m_intervals[i];
interval const & int2 = s2->m_intervals[i];
if (int1.m_lower_inf != int2.m_lower_inf ||
@ -654,7 +654,7 @@ namespace nlsat {
js.reset();
clauses.reset();
unsigned num = num_intervals(s);
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
literal l = s->m_intervals[i].m_justification;
unsigned lidx = l.index();
if (m_already_visited.get(lidx, false))
@ -664,7 +664,7 @@ namespace nlsat {
if (s->m_intervals[i].m_clause)
clauses.push_back(const_cast<clause*>(s->m_intervals[i].m_clause));
}
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
literal l = s->m_intervals[i].m_justification;
unsigned lidx = l.index();
m_already_visited[lidx] = false;
@ -746,7 +746,7 @@ namespace nlsat {
// Try to find a gap that is not an unit.
for (unsigned i = 1; i < num; i++) {
for (unsigned i = 1; i < num; ++i) {
if (m_am.lt(s->m_intervals[i-1].m_upper, s->m_intervals[i].m_lower)) {
n++;
if (n == 1 || m_rand()%n == 0)
@ -761,7 +761,7 @@ namespace nlsat {
// Try to find a rational
unsigned irrational_i = UINT_MAX;
for (unsigned i = 1; i < num; i++) {
for (unsigned i = 1; i < num; ++i) {
if (s->m_intervals[i-1].m_upper_open && s->m_intervals[i].m_lower_open) {
SASSERT(m_am.eq(s->m_intervals[i-1].m_upper, s->m_intervals[i].m_lower)); // otherwise we would have found it in the previous step
if (m_am.is_rational(s->m_intervals[i-1].m_upper)) {
@ -784,7 +784,7 @@ namespace nlsat {
return out;
}
out << "{";
for (unsigned i = 0; i < s->m_num_intervals; i++) {
for (unsigned i = 0; i < s->m_num_intervals; ++i) {
if (i > 0)
out << ", ";
nlsat::display(out, m_am, s->m_intervals[i]);

View file

@ -55,13 +55,13 @@ namespace nlsat {
unsigned sz = m_lits.size();
if (new_sz == sz)
return;
for (unsigned i = new_sz; i < sz; i++) {
for (unsigned i = new_sz; i < sz; ++i) {
m_solver.dec_ref(m_lits[i]);
}
m_lits.shrink(new_sz);
}
void append(unsigned sz, literal const * ls) {
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
push_back(ls[i]);
}
void append(scoped_literal_vector const& ls) {

View file

@ -427,7 +427,7 @@ namespace nlsat {
*/
var max_var(unsigned sz, literal const * cls) const {
var x = null_var;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = cls[i];
if (is_arith_literal(l)) {
var y = max_var(l);
@ -462,7 +462,7 @@ namespace nlsat {
unsigned max = 0;
unsigned sz = to_ineq_atom(a)->size();
var x = a->max_var();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
unsigned d = m_pm.degree(to_ineq_atom(a)->p(i), x);
if (d > max)
max = d;
@ -552,7 +552,7 @@ namespace nlsat {
else if (a->is_ineq_atom()) {
unsigned sz = to_ineq_atom(a)->size();
var_vector new_vs;
for (unsigned j = 0; j < sz; j++) {
for (unsigned j = 0; j < sz; ++j) {
m_found_vars.reset();
m_pm.vars(to_ineq_atom(a)->p(j), new_vs);
for (unsigned i = 0; i < new_vs.size(); ++i) {
@ -599,7 +599,7 @@ namespace nlsat {
m_ineq_atoms.erase(a);
del(a->bvar());
unsigned sz = a->size();
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
m_pm.dec_ref(a->p(i));
deallocate(a);
}
@ -637,7 +637,7 @@ namespace nlsat {
polynomial_ref p(m_pm);
ptr_buffer<poly> uniq_ps;
var max = null_var;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
p = m_pm.flip_sign_if_lm_neg(ps[i]);
if (p.get() != ps[i] && !is_even[i]) {
sign = -sign;
@ -678,7 +678,7 @@ namespace nlsat {
SASSERT(atom->max_var() == max);
is_new = (atom == tmp_atom);
if (is_new) {
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
m_pm.inc_ref(atom->p(i));
}
}
@ -804,7 +804,7 @@ namespace nlsat {
remove_clause_from_watches(*cls);
m_cid_gen.recycle(cls->id());
unsigned sz = cls->size();
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
dec_ref((*cls)[i]);
_assumption_set a = static_cast<_assumption_set>(cls->assumptions());
dec_ref(a);
@ -1130,7 +1130,7 @@ namespace nlsat {
bool_vector used_vars(num_vars(), false);
bool_vector used_bools(usize(m_atoms), false);
var_vector vars;
for (unsigned j = 0; j < n; j++) {
for (unsigned j = 0; j < n; ++j) {
literal lit = cls[j];
bool_var b = lit.var();
if (b != null_bool_var && b < used_bools.size())
@ -1162,7 +1162,7 @@ namespace nlsat {
unsigned cid = m_cid_gen.mk();
void * mem = m_allocator.allocate(clause::get_obj_size(num_lits));
clause * cls = new (mem) clause(cid, num_lits, lits, learned, a);
for (unsigned i = 0; i < num_lits; i++)
for (unsigned i = 0; i < num_lits; ++i)
inc_ref(lits[i]);
inc_ref(a);
return cls;
@ -1452,7 +1452,7 @@ namespace nlsat {
\brief Return true if the given clause is false in the current partial interpretation.
*/
bool is_inconsistent(unsigned sz, literal const * cls) {
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (value(cls[i]) != l_false) {
TRACE(is_inconsistent, tout << "literal is not false:\n"; display(tout, cls[i]); tout << "\n";);
return false;
@ -1471,7 +1471,7 @@ namespace nlsat {
unsigned num_undef = 0;
unsigned first_undef = UINT_MAX;
unsigned sz = cls.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = cls[i];
SASSERT(m_atoms[l.var()] == nullptr);
SASSERT(value(l) != l_true);
@ -1646,7 +1646,7 @@ namespace nlsat {
if (num_undef == 1) {
CTRACE(nlsat, cls.size() > 1,
tout << "num_undef=1, "; display(tout, cls) << "\n";
for (unsigned i = 0; i < cls.size(); i++) {
for (unsigned i = 0; i < cls.size(); ++i) {
tout << value(cls[i]) << ", ";
}
);
@ -1922,7 +1922,7 @@ namespace nlsat {
vector<std::pair<var, rational>> bounds;
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
if (is_int(x) && m_assignment.is_assigned(x) && !m_am.is_int(m_assignment.value(x))) {
scoped_anum v(m_am), vlo(m_am);
v = m_assignment.value(x);
@ -2209,7 +2209,7 @@ namespace nlsat {
TRACE(nlsat_proof, tout << "resolving "; if (b != null_bool_var) display_atom(tout, b) << "\n"; display(tout, sz, c); tout << "\n";);
TRACE(nlsat_proof_sk, tout << "resolving "; if (b != null_bool_var) tout << "b" << b; tout << "\n"; display_abst(tout, sz, c); tout << "\n";);
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (c[i].var() != b)
process_antecedent(c[i]);
}
@ -2224,7 +2224,7 @@ namespace nlsat {
std::ostream& print_out_as_math(std::ostream& out, lazy_justification const & jst) {
literal_vector core;
for (unsigned i = 0; i < jst.num_lits(); i++) {
for (unsigned i = 0; i < jst.num_lits(); ++i) {
core.push_back(~jst.lit(i));
}
display_mathematica_lemma(out, core.size(), core.data(), true);
@ -2313,7 +2313,7 @@ namespace nlsat {
m_lazy_clause.reset();
m_explain.main_operator(jst.num_lits(), jst.lits(), m_lazy_clause);
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
m_lazy_clause.push_back(~jst.lit(i));
// lazy clause is a valid clause
@ -2340,7 +2340,7 @@ namespace nlsat {
#ifdef Z3DEBUG
{
unsigned sz = m_lazy_clause.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = m_lazy_clause[i];
if (l.var() != b) {
if (value(l) != l_false)
@ -2369,7 +2369,7 @@ namespace nlsat {
\brief Return true if all literals in ls are from previous stages.
*/
bool only_literals_from_previous_stages(unsigned num, literal const * ls) const {
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
if (max_var(ls[i]) == m_xk)
return false;
}
@ -2383,7 +2383,7 @@ namespace nlsat {
*/
unsigned max_scope_lvl(unsigned num, literal const * ls) {
unsigned max = 0;
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
literal l = ls[i];
bool_var b = l.var();
SASSERT(value(ls[i]) == l_false);
@ -2412,7 +2412,7 @@ namespace nlsat {
TRACE(nlsat_resolve, tout << "removing literals from lvl: " << lvl << " and stage " << m_xk << "\n";);
unsigned sz = lemma.size();
unsigned j = 0;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
literal l = lemma[i];
bool_var b = l.var();
SASSERT(is_marked(b));
@ -2431,7 +2431,7 @@ namespace nlsat {
\brief Return true if it is a Boolean lemma.
*/
bool is_bool_lemma(unsigned sz, literal const * ls) const {
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (m_atoms[ls[i].var()] != nullptr)
return false;
}
@ -2448,7 +2448,7 @@ namespace nlsat {
SASSERT(!is_bool_lemma(sz, lemma));
unsigned new_lvl = 0;
bool found_lvl = false;
for (unsigned i = 0; i < sz - 1; i++) {
for (unsigned i = 0; i < sz - 1; ++i) {
literal l = lemma[i];
if (max_var(l) == m_xk) {
bool_var b = l.var();
@ -2665,10 +2665,10 @@ namespace nlsat {
bool check_watches() const {
#ifdef Z3DEBUG
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
clause_vector const & cs = m_watches[x];
unsigned sz = cs.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
SASSERT(max_var(*(cs[i])) == x);
}
}
@ -2678,10 +2678,10 @@ namespace nlsat {
bool check_bwatches() const {
#ifdef Z3DEBUG
for (bool_var b = 0; b < m_bwatches.size(); b++) {
for (bool_var b = 0; b < m_bwatches.size(); ++b) {
clause_vector const & cs = m_bwatches[b];
unsigned sz = cs.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
clause const & c = *(cs[i]);
(void)c;
SASSERT(max_var(c) == null_var);
@ -2700,7 +2700,7 @@ namespace nlsat {
bool check_satisfied(clause_vector const & cs) {
unsigned sz = cs.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
clause const & c = *(cs[i]);
if (!is_satisfied(c)) {
TRACE(nlsat, tout << "not satisfied\n"; display(tout, c); tout << "\n";);
@ -2715,14 +2715,14 @@ namespace nlsat {
unsigned num = usize(m_atoms);
if (m_bk != null_bool_var)
num = m_bk;
for (bool_var b = 0; b < num; b++) {
for (bool_var b = 0; b < num; ++b) {
if (!check_satisfied(m_bwatches[b])) {
UNREACHABLE();
return false;
}
}
if (m_xk != null_var) {
for (var x = 0; x < m_xk; x++) {
for (var x = 0; x < m_xk; ++x) {
if (!check_satisfied(m_watches[x])) {
UNREACHABLE();
return false;
@ -2777,7 +2777,7 @@ namespace nlsat {
m_vars.reset();
pm.vars(p, m_vars);
unsigned sz = m_vars.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
var x = m_vars[i];
unsigned k = pm.degree(p, x);
m_num_occs[x]++;
@ -2793,7 +2793,7 @@ namespace nlsat {
return;
if (a->is_ineq_atom()) {
unsigned sz = to_ineq_atom(a)->size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
collect(to_ineq_atom(a)->p(i));
}
}
@ -2804,19 +2804,19 @@ namespace nlsat {
void collect(clause const & c) {
unsigned sz = c.size();
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
collect(c[i]);
}
void collect(clause_vector const & cs) {
unsigned sz = cs.size();
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
collect(*(cs[i]));
}
std::ostream& display(std::ostream & out, display_var_proc const & proc) {
unsigned sz = m_num_occs.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
proc(out, i); out << " -> " << m_max_degree[i] << " : " << m_num_occs[i] << "\n";
}
return out;
@ -2850,15 +2850,15 @@ namespace nlsat {
init_shuffle(collector.m_shuffle);
TRACE(nlsat_reorder, collector.display(tout, m_display_var););
var_vector new_order;
for (var x = 0; x < num; x++)
for (var x = 0; x < num; ++x)
new_order.push_back(x);
std::sort(new_order.begin(), new_order.end(), reorder_lt(collector));
TRACE(nlsat_reorder,
tout << "new order: "; for (unsigned i = 0; i < num; i++) tout << new_order[i] << " "; tout << "\n";);
tout << "new order: "; for (unsigned i = 0; i < num; ++i) tout << new_order[i] << " "; tout << "\n";);
var_vector perm;
perm.resize(num, 0);
for (var x = 0; x < num; x++) {
for (var x = 0; x < num; ++x) {
perm[new_order[x]] = x;
}
reorder(perm.size(), perm.data());
@ -2867,7 +2867,7 @@ namespace nlsat {
void init_shuffle(var_vector& p) {
unsigned num = num_vars();
for (var x = 0; x < num; x++)
for (var x = 0; x < num; ++x)
p.push_back(x);
random_gen r(++m_random_seed);
@ -2898,7 +2898,7 @@ namespace nlsat {
TRACE(nlsat_reorder, tout << "solver before variable reorder\n"; display(tout);
display_vars(tout);
tout << "\npermutation:\n";
for (unsigned i = 0; i < sz; i++) tout << p[i] << " "; tout << "\n";
for (unsigned i = 0; i < sz; ++i) tout << p[i] << " "; tout << "\n";
);
// verbose_stream() << "\npermutation: " << p[0] << " count " << count << " " << m_rlimit.is_canceled() << "\n";
reinit_cache();
@ -2906,7 +2906,7 @@ namespace nlsat {
TRACE(nlsat_bool_assignment_bug, tout << "before reset watches\n"; display_bool_assignment(tout, false, nullptr););
reset_watches();
assignment new_assignment(m_am);
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
if (m_assignment.is_assigned(x))
new_assignment.set(p[x], m_assignment.value(x));
}
@ -2917,12 +2917,12 @@ namespace nlsat {
undo_until_stage(null_var);
m_cache.reset();
#ifdef Z3DEBUG
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
SASSERT(m_watches[x].empty());
}
#endif
// update m_perm mapping
for (unsigned ext_x = 0; ext_x < sz; ext_x++) {
for (unsigned ext_x = 0; ext_x < sz; ++ext_x) {
// p: internal -> new pos
// m_perm: internal -> external
// m_inv_perm: external -> internal
@ -2931,13 +2931,13 @@ namespace nlsat {
}
bool_vector is_int;
is_int.swap(m_is_int);
for (var x = 0; x < sz; x++) {
for (var x = 0; x < sz; ++x) {
m_is_int.setx(p[x], is_int[x], false);
SASSERT(m_infeasible[x] == 0);
}
m_inv_perm.swap(new_inv_perm);
#ifdef Z3DEBUG
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
SASSERT(x == m_inv_perm[m_perm[x]]);
SASSERT(m_watches[x].empty());
}
@ -2964,7 +2964,7 @@ namespace nlsat {
p.append(m_perm);
reorder(p.size(), p.data());
#ifdef Z3DEBUG
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
SASSERT(m_perm[x] == x);
SASSERT(m_inv_perm[x] == x);
}
@ -3028,7 +3028,7 @@ namespace nlsat {
else if (a->is_ineq_atom()) {
var max = 0;
unsigned sz = to_ineq_atom(a)->size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
poly * p = to_ineq_atom(a)->p(i);
VERIFY(m_cache.mk_unique(p) == p);
var x = m_pm.max_var(p);
@ -3046,7 +3046,7 @@ namespace nlsat {
void reset_watches() {
unsigned num = num_vars();
for (var x = 0; x < num; x++) {
for (var x = 0; x < num; ++x) {
m_watches[x].clear();
}
}
@ -3082,17 +3082,17 @@ namespace nlsat {
void sort_clauses_by_degree(unsigned sz, clause ** cs) {
if (sz <= 1)
return;
TRACE(nlsat_reorder_clauses, tout << "before:\n"; for (unsigned i = 0; i < sz; i++) { display(tout, *(cs[i])); tout << "\n"; });
TRACE(nlsat_reorder_clauses, tout << "before:\n"; for (unsigned i = 0; i < sz; ++i) { display(tout, *(cs[i])); tout << "\n"; });
m_cs_degrees.reset();
m_cs_p.reset();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
m_cs_p.push_back(i);
m_cs_degrees.push_back(degree(*(cs[i])));
}
std::sort(m_cs_p.begin(), m_cs_p.end(), degree_lt(m_cs_degrees));
TRACE(nlsat_reorder_clauses, tout << "permutation: "; ::display(tout, m_cs_p.begin(), m_cs_p.end()); tout << "\n";);
apply_permutation(sz, cs, m_cs_p.data());
TRACE(nlsat_reorder_clauses, tout << "after:\n"; for (unsigned i = 0; i < sz; i++) { display(tout, *(cs[i])); tout << "\n"; });
TRACE(nlsat_reorder_clauses, tout << "after:\n"; for (unsigned i = 0; i < sz; ++i) { display(tout, *(cs[i])); tout << "\n"; });
}
@ -3122,11 +3122,11 @@ namespace nlsat {
void sort_clauses_by_degree_lit_num(unsigned sz, clause ** cs) {
if (sz <= 1)
return;
TRACE(nlsat_reorder_clauses, tout << "before:\n"; for (unsigned i = 0; i < sz; i++) { display(tout, *(cs[i])); tout << "\n"; });
TRACE(nlsat_reorder_clauses, tout << "before:\n"; for (unsigned i = 0; i < sz; ++i) { display(tout, *(cs[i])); tout << "\n"; });
m_dl_degrees.reset();
m_dl_lit_num.reset();
m_dl_p.reset();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
m_dl_degrees.push_back(degree(*(cs[i])));
m_dl_lit_num.push_back(cs[i]->size());
m_dl_p.push_back(i);
@ -3134,12 +3134,12 @@ namespace nlsat {
std::sort(m_dl_p.begin(), m_dl_p.end(), degree_lit_num_lt(m_dl_degrees, m_dl_lit_num));
TRACE(nlsat_reorder_clauses, tout << "permutation: "; ::display(tout, m_dl_p.begin(), m_dl_p.end()); tout << "\n";);
apply_permutation(sz, cs, m_dl_p.data());
TRACE(nlsat_reorder_clauses, tout << "after:\n"; for (unsigned i = 0; i < sz; i++) { display(tout, *(cs[i])); tout << "\n"; });
TRACE(nlsat_reorder_clauses, tout << "after:\n"; for (unsigned i = 0; i < sz; ++i) { display(tout, *(cs[i])); tout << "\n"; });
}
void sort_watched_clauses() {
unsigned num = num_vars();
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
clause_vector & ws = m_watches[i];
sort_clauses_by_degree(ws.size(), ws.data());
}
@ -3358,7 +3358,7 @@ namespace nlsat {
std::ostream& display_num_assignment(std::ostream & out, display_var_proc const & proc, bool_vector const* used_vars = nullptr) const {
bool restrict = used_vars != nullptr;
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
if (restrict && (x >= used_vars->size() || !(*used_vars)[x]))
continue;
if (!m_assignment.is_assigned(x))
@ -3396,7 +3396,7 @@ namespace nlsat {
std::ostream& display_bool_assignment(std::ostream & out, bool eval_atoms = false, bool_vector const* used = nullptr) const {
unsigned sz = usize(m_atoms);
if (used != nullptr) {
for (bool_var b = 0; b < sz; b++) {
for (bool_var b = 0; b < sz; ++b) {
if (b >= used->size() || !(*used)[b])
continue;
if (m_atoms[b] != nullptr)
@ -3409,7 +3409,7 @@ namespace nlsat {
return out;
}
if (!eval_atoms) {
for (bool_var b = 0; b < sz; b++) {
for (bool_var b = 0; b < sz; ++b) {
if (m_bvalues[b] == l_undef)
continue;
if (m_atoms[b] == nullptr)
@ -3421,7 +3421,7 @@ namespace nlsat {
}
}
else { //if (eval_atoms) {
for (bool_var b = 0; b < sz; b++) {
for (bool_var b = 0; b < sz; ++b) {
if (m_atoms[b] == nullptr) continue;
lbool val = to_lbool(m_evaluator.eval(m_atoms[b], false));
out << "b" << b << " -> " << val << " ";
@ -3439,7 +3439,7 @@ namespace nlsat {
bool display_mathematica_assignment(std::ostream & out) const {
bool first = true;
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
if (m_assignment.is_assigned(x)) {
if (first)
first = false;
@ -3531,7 +3531,7 @@ namespace nlsat {
std::ostream& display_ineq(std::ostream & out, ineq_atom const & a, display_var_proc const & proc, bool use_star = false) const {
unsigned sz = a.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (use_star && i > 0)
out << "*";
bool is_even = a.is_even(i);
@ -3554,7 +3554,7 @@ namespace nlsat {
std::ostream& display_mathematica(std::ostream & out, ineq_atom const & a) const {
unsigned sz = a.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (i > 0)
out << "*";
bool is_even = a.is_even(i);
@ -3591,7 +3591,7 @@ namespace nlsat {
unsigned sz = a.size();
if (sz > 1)
out << "(* ";
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (i > 0) out << " ";
if (a.is_even(i)) {
out << "(* ";
@ -3956,7 +3956,7 @@ namespace nlsat {
}
std::ostream& display(std::ostream & out, unsigned num, literal const * ls, display_var_proc const & proc) const {
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
if (i > 0)
out << " or ";
display(out, ls[i], proc);
@ -3969,7 +3969,7 @@ namespace nlsat {
}
std::ostream& display_not(std::ostream & out, unsigned num, literal const * ls, display_var_proc const & proc) const {
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
if (i > 0)
out << " or ";
display(out, ~ls[i], proc);
@ -4002,7 +4002,7 @@ namespace nlsat {
if (m_display_eval) {
polynomial_ref q(m_pm);
q = p;
for (var x = 0; x < num_vars(); x++)
for (var x = 0; x < num_vars(); ++x)
if (m_assignment.is_assigned(x)) {
auto& a = m_assignment.value(x);
if (!m_am.is_rational(a))
@ -4034,7 +4034,7 @@ namespace nlsat {
}
else {
out << "(or";
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
out << " ";
display_smt2(out, ls[i], proc);
}
@ -4063,7 +4063,7 @@ namespace nlsat {
}
std::ostream& display_abst(std::ostream & out, unsigned num, literal const * ls) const {
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
if (i > 0)
out << " or ";
display_abst(out, ls[i]);
@ -4082,7 +4082,7 @@ namespace nlsat {
std::ostream& display_mathematica(std::ostream & out, clause const & c) const {
out << "(";
unsigned sz = c.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (i > 0)
out << " || ";
display_mathematica(out, c[i]);
@ -4097,7 +4097,7 @@ namespace nlsat {
std::ostream& display_mathematica_lemma(std::ostream & out, unsigned num, literal const * ls, bool include_assignment = false) const {
bool_vector used_vars(num_vars(), false);
var_vector vars;
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
vars.reset();
this->vars(ls[i], vars);
for (var v : vars)
@ -4105,7 +4105,7 @@ namespace nlsat {
}
if (include_assignment) {
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
if (m_assignment.is_assigned(x))
used_vars[x] = true;
}
@ -4113,7 +4113,7 @@ namespace nlsat {
out << "Resolve[ForAll[{";
bool first = true;
for (var x = 0; x < num_vars(); x++) {
for (var x = 0; x < num_vars(); ++x) {
if (used_vars[x] == false) continue;
if (!first) out << ", ";
first = false;
@ -4128,7 +4128,7 @@ namespace nlsat {
out << ") || ";
}
for (unsigned i = 0; i < num; i++) {
for (unsigned i = 0; i < num; ++i) {
if (i > 0)
out << " || ";
display_mathematica(out, ls[i]);
@ -4150,7 +4150,7 @@ namespace nlsat {
std::ostream& display_mathematica(std::ostream & out, clause_vector const & cs) const {
unsigned sz = cs.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (i > 0) out << ",\n";
display_mathematica(out << " ", *(cs[i]));
}
@ -4191,7 +4191,7 @@ namespace nlsat {
}
std::ostream& display_vars(std::ostream & out) const {
for (unsigned i = 0; i < num_vars(); i++) {
for (unsigned i = 0; i < num_vars(); ++i) {
out << i << " -> "; m_display_var(out, i); out << "\n";
}
return out;
@ -4203,7 +4203,7 @@ namespace nlsat {
std::ostream& display_smt2_arith_decls(std::ostream & out, bool_vector& used_vars) const {
unsigned sz = m_is_int.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (!used_vars[i]) continue;
out << "(declare-fun ";
m_display_var(out, i);
@ -4221,7 +4221,7 @@ namespace nlsat {
std::ostream& display_smt2_bool_decls(std::ostream & out, const bool_vector& used_bools) const {
unsigned sz = usize(m_atoms);
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (m_atoms[i] == nullptr && used_bools[i])
out << "(declare-fun b" << i << " () Bool)\n";
}

View file

@ -26,7 +26,7 @@ namespace nlsat {
ineq_atom::ineq_atom(kind k, unsigned sz, poly * const * ps, bool const * is_even, var max_var):
atom(k, max_var),
m_size(sz) {
for (unsigned i = 0; i < m_size; i++) {
for (unsigned i = 0; i < m_size; ++i) {
m_ps[i] = TAG(poly *, ps[i], is_even[i] ? 1 : 0);
}
SASSERT(is_ineq_atom());
@ -40,7 +40,7 @@ namespace nlsat {
if (a1->m_size != a2->m_size || a1->m_kind != a2->m_kind)
return false;
unsigned sz = a1->m_size;
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (a1->m_ps[i] != a2->m_ps[i])
return false;
}

View file

@ -88,7 +88,7 @@ namespace nlsat {
m_max_degree[x] = k;
if (m_vos_type == FEATURE){
for (unsigned kl = 0; kl <= k; kl++) {
for (unsigned kl = 0; kl <= k; ++kl) {
scoped_numeral curr(pm.m());
if (pm.const_coeff(p, x, kl, curr)) {
pm.m().abs(curr);
@ -115,7 +115,7 @@ namespace nlsat {
return;
if (a->is_ineq_atom()) {
unsigned sz = to_ineq_atom(a)->size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
collect(to_ineq_atom(a)->p(i));
}
}
@ -126,13 +126,13 @@ namespace nlsat {
void collect(clause const & c) {
unsigned sz = c.size();
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
collect(c[i]);
}
void collect(clause_vector const & cs) {
unsigned sz = cs.size();
for (unsigned i = 0; i < sz; i++)
for (unsigned i = 0; i < sz; ++i)
collect(*(cs[i]));
}
@ -216,7 +216,7 @@ namespace nlsat {
bool check_invariant() const {return true;} // what is the invariant
void operator()(var_vector &perm) {
var_vector new_order;
for (var x = 0; x < num_vars; x++) {
for (var x = 0; x < num_vars; ++x) {
new_order.push_back(x);
}
if (m_vos_type == BROWN) {
@ -241,12 +241,12 @@ namespace nlsat {
}
TRACE(reorder,
tout << "new order: ";
for (unsigned i = 0; i < num_vars; i++)
for (unsigned i = 0; i < num_vars; ++i)
tout << new_order[i] << " ";
tout << "\n";
);
perm.resize(num_vars, 0);
for (var x = 0; x < num_vars; x++) {
for (var x = 0; x < num_vars; ++x) {
perm[new_order[x]] = x;
}
@ -254,7 +254,7 @@ namespace nlsat {
}
// std::ostream& display(std::ostream & out, display_var_proc const & proc) {
// unsigned sz = m_num_occs.size();
// for (unsigned i = 0; i < sz; i++) {
// for (unsigned i = 0; i < sz; ++i) {
// proc(out, i); out << " -> " << m_max_degree[i] << " : " << m_num_occs[i] << "\n";
// }
// return out;

View file

@ -100,7 +100,7 @@ struct goal2nlsat::imp {
m_pm.factor(p, fs, m_fparams);
TRACE(goal2nlsat_bug, tout << "factors:\n" << fs << "\n";);
SASSERT(fs.distinct_factors() > 0);
for (unsigned i = 0; i < fs.distinct_factors(); i++) {
for (unsigned i = 0; i < fs.distinct_factors(); ++i) {
ps.push_back(fs[i]);
is_even.push_back(fs.get_degree(i) % 2 == 0);
}
@ -245,7 +245,7 @@ struct goal2nlsat::imp {
lits = &f;
}
sbuffer<nlsat::literal> ls;
for (unsigned i = 0; i < num_lits; i++) {
for (unsigned i = 0; i < num_lits; ++i) {
ls.push_back(process_literal(lits[i]));
}
m_solver.mk_clause(ls.size(), ls.data(), dep);
@ -256,7 +256,7 @@ struct goal2nlsat::imp {
if (has_term_ite(g))
throw tactic_exception("eliminate term-ite before applying nlsat");
unsigned sz = g.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
process(g.form(i), g.dep(i));
}
}

View file

@ -60,13 +60,13 @@ class nlsat_tactic : public tactic {
}
bool contains_unsupported(expr_ref_vector & b2a, expr_ref_vector & x2t) {
for (unsigned x = 0; x < x2t.size(); x++) {
for (unsigned x = 0; x < x2t.size(); ++x) {
if (!is_uninterp_const(x2t.get(x))) {
TRACE(unsupported, tout << "unsupported atom:\n" << mk_ismt2_pp(x2t.get(x), m) << "\n";);
return true;
}
}
for (unsigned b = 0; b < b2a.size(); b++) {
for (unsigned b = 0; b < b2a.size(); ++b) {
expr * a = b2a.get(b);
if (a == nullptr)
continue;
@ -82,7 +82,7 @@ class nlsat_tactic : public tactic {
bool eval_model(model& model, goal& g) {
unsigned sz = g.size();
for (unsigned i = 0; i < sz; i++) {
for (unsigned i = 0; i < sz; ++i) {
if (model.is_false(g.form(i))) {
TRACE(nlsat, tout << mk_pp(g.form(i), m) << " -> " << model(g.form(i)) << "\n";);
IF_VERBOSE(0, verbose_stream() << mk_pp(g.form(i), m) << " -> " << model(g.form(i)) << "\n";);
@ -99,7 +99,7 @@ class nlsat_tactic : public tactic {
bool ok = true;
model_ref md = alloc(model, m);
arith_util util(m);
for (unsigned x = 0; x < x2t.size(); x++) {
for (unsigned x = 0; x < x2t.size(); ++x) {
expr * t = x2t.get(x);
if (!is_uninterp_const(t))
continue;
@ -116,7 +116,7 @@ class nlsat_tactic : public tactic {
}
md->register_decl(to_app(t)->get_decl(), v);
}
for (unsigned b = 0; b < b2a.size(); b++) {
for (unsigned b = 0; b < b2a.size(); ++b) {
expr * a = b2a.get(b);
if (a == nullptr || !is_uninterp_const(a))
continue;