Skip to content

Commit 1ab0962

Browse files
partial fix to make computed term integer well-formed for solve_for functionality
1 parent bcb61ee commit 1ab0962

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/math/lp/lar_solver.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -619,13 +619,15 @@ namespace lp {
619619

620620
bool lar_solver::solve_for(unsigned j, lar_term& t, mpq& coeff) {
621621
t.clear();
622+
IF_VERBOSE(10, verbose_stream() << column_is_fixed(j) << " " << is_base(j) << "\n");
622623
if (column_is_fixed(j)) {
623624
coeff = get_value(j);
624625
return true;
625626
}
626627
if (!is_base(j)) {
627628
for (const auto & c : A_r().m_columns[j]) {
628629
lpvar basic_in_row = r_basis()[c.var()];
630+
IF_VERBOSE(10, verbose_stream() << "c.var() = " << c.var() << " basic_in_row = " << basic_in_row << "\n");
629631
pivot(j, basic_in_row);
630632
break;
631633
}

src/smt/theory_lra.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -3638,9 +3638,21 @@ class theory_lra::imp {
36383638
rational coeff;
36393639
if (!lp().solve_for(vi, t, coeff))
36403640
return false;
3641+
rational lc(1);
3642+
if (is_int(v)) {
3643+
lc = denominator(coeff);
3644+
for (auto const& cv : t)
3645+
lc = lcm(denominator(cv.coeff()), lc);
3646+
if (lc != 1) {
3647+
coeff *= lc;
3648+
t *= lc;
3649+
}
3650+
}
36413651
term = mk_term(t, is_int(v));
36423652
if (coeff != 0)
36433653
term = a.mk_add(a.mk_numeral(coeff, is_int(v)), term);
3654+
if (lc != 1)
3655+
term = a.mk_idiv(term, a.mk_numeral(lc, true));
36443656
return true;
36453657
}
36463658

0 commit comments

Comments
 (0)