Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 0b3ef82

Browse files
committedMar 16, 2025·
add systematic way to combine lia_move results
Signed-off-by: Nikolaj Bjorner <[email protected]>
1 parent beee218 commit 0b3ef82

File tree

2 files changed

+40
-26
lines changed

2 files changed

+40
-26
lines changed
 

Diff for: ‎src/math/lp/dioph_eq.cpp

+15-26
Original file line numberDiff line numberDiff line change
@@ -1247,6 +1247,7 @@ namespace lp {
12471247
[k](const auto& c) {
12481248
return c.var() == k;
12491249
});
1250+
SASSERT(it != e_row.end());
12501251
const mpq& k_coeff_in_e = it->coeff();
12511252
bool is_one = k_coeff_in_e.is_one();
12521253
SASSERT(is_one || k_coeff_in_e.is_minus_one());
@@ -1281,24 +1282,20 @@ namespace lp {
12811282
lia_move subs_front_with_S_and_fresh(protected_queue& q, unsigned j) {
12821283
process_fixed_in_espace();
12831284
auto r = tighten_on_espace(j);
1284-
if (r == lia_move::conflict) return lia_move::conflict;
1285+
if (r == lia_move::conflict)
1286+
return lia_move::conflict;
12851287
unsigned k = q.pop_front();
12861288
if (!m_espace.has(k))
12871289
return lia_move::undef;
12881290
// we might substitute with a term from S or a fresh term
12891291

12901292
SASSERT(can_substitute(k));
12911293
lia_move ret;
1292-
if (is_substituted_by_fresh(k)) {
1294+
if (is_substituted_by_fresh(k))
12931295
ret = subs_qfront_by_fresh(k, q, j);
1294-
}
1295-
else {
1296+
else
12961297
ret = subs_qfront_by_S(k, q, j);
1297-
}
1298-
if (ret == lia_move::conflict)
1299-
return lia_move::conflict;
1300-
if (r == lia_move::continue_with_check) return r;
1301-
return ret;
1298+
return join(ret, r);
13021299
}
13031300

13041301
lar_term l_term_from_row(unsigned k) const {
@@ -1369,11 +1366,9 @@ namespace lp {
13691366

13701367
lia_move subs_with_S_and_fresh(protected_queue& q, unsigned j) {
13711368
lia_move r = lia_move::undef;
1372-
while (!q.empty()) {
1369+
while (!q.empty() && r != lia_move::conflict) {
13731370
lia_move ret = subs_front_with_S_and_fresh(q, j);
1374-
if (ret == lia_move::conflict) return lia_move::conflict;
1375-
if (ret == lia_move::continue_with_check)
1376-
r = ret;
1371+
r = join(ret, r);
13771372
}
13781373
return r;
13791374
}
@@ -1423,15 +1418,10 @@ namespace lp {
14231418
);
14241419
for (unsigned j : sorted_changed_terms) {
14251420
m_terms_to_tighten.remove(j);
1426-
auto r0 = tighten_bounds_for_term_column(j);
1427-
if (r0 == lia_move::conflict) {
1428-
r = r0;
1421+
auto ret = tighten_bounds_for_term_column(j);
1422+
r = join(ret, r);
1423+
if (r == lia_move::conflict)
14291424
break;
1430-
}
1431-
else if (r0 == lia_move::continue_with_check)
1432-
r = r0;
1433-
else if (r0 == lia_move::branch && r == lia_move::undef)
1434-
r = r0;
14351425
}
14361426
for (unsigned j : processed_terms)
14371427
m_terms_to_tighten.remove(j);
@@ -1783,14 +1773,13 @@ namespace lp {
17831773
lia_move r;
17841774
do {
17851775
r = rewrite_eqs(f_vector);
1786-
if (lra.settings().get_cancel_flag()) {
1776+
if (lra.settings().get_cancel_flag())
17871777
return lia_move::undef;
1788-
}
1789-
if (r == lia_move::conflict || r == lia_move::undef) {
1778+
if (r == lia_move::conflict || r == lia_move::undef)
17901779
break;
1791-
}
17921780
SASSERT(m_changed_columns.size() == 0);
1793-
} while (f_vector.size());
1781+
}
1782+
while (f_vector.size());
17941783

17951784
if (r == lia_move::conflict) {
17961785
if (m_conflict_index != UINT_MAX) {

Diff for: ‎src/math/lp/lia_move.h

+25
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,31 @@ namespace lp {
5353
return "strange";
5454
}
5555

56+
inline lia_move join(lia_move r1, lia_move r2) {
57+
if (r1 == r2)
58+
return r1;
59+
if (r1 == lia_move::undef)
60+
return r2;
61+
if (r2 == lia_move::undef)
62+
return r1;
63+
if (r1 == lia_move::conflict || r2 == lia_move::conflict)
64+
return lia_move::conflict;
65+
if (r1 == lia_move::unsat || r2 == lia_move::unsat)
66+
return lia_move::unsat;
67+
if (r1 == lia_move::cancelled || r2 == lia_move::cancelled)
68+
return lia_move::cancelled;
69+
if (r1 == lia_move::sat || r2 == lia_move::sat)
70+
return lia_move::sat;
71+
if (r1 == lia_move::continue_with_check || r2 == lia_move::continue_with_check)
72+
return lia_move::continue_with_check;
73+
if (r1 == lia_move::cut || r2 == lia_move::cut)
74+
return lia_move::cut;
75+
if (r1 == lia_move::branch || r2 == lia_move::branch)
76+
return lia_move::branch;
77+
UNREACHABLE();
78+
return r1;
79+
}
80+
5681
inline std::ostream& operator<<(std::ostream& out, lia_move const& m) {
5782
return out << lia_move_to_string(m);
5883
}

0 commit comments

Comments
 (0)
Please sign in to comment.