Skip to content

Commit

Permalink
disable quadratic moves for non-integers as sqrt isn't currently defi…
Browse files Browse the repository at this point in the history
…ned for rationals
  • Loading branch information
NikolajBjorner committed Jan 29, 2025
1 parent d843081 commit fe713eb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ast/sls/sls_arith_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ namespace sls {
template<typename num_t>
static num_t sqrt(num_t d) {
if (d <= 1)
return d;
return d;
auto sq = 2*sqrt(div(d, num_t(4))) + 1;
if (sq * sq <= d)
return sq;
Expand All @@ -217,6 +217,8 @@ namespace sls {
template<typename num_t>
void arith_base<num_t>::find_quadratic_moves(ineq const& ineq, var_t x, num_t const& a, num_t const& b, num_t const& sum) {
num_t c, d;
if (!is_int(x)) // sqrt is not defined for non-integers
return;
try {
c = sum - a * value(x) * value(x) - b * value(x);
d = b * b - 4 * a * c;
Expand Down

0 comments on commit fe713eb

Please sign in to comment.