diff --git a/src/ast/rewriter/arith_rewriter.cpp b/src/ast/rewriter/arith_rewriter.cpp index 7e0304cfd..02f2e1321 100644 --- a/src/ast/rewriter/arith_rewriter.cpp +++ b/src/ast/rewriter/arith_rewriter.cpp @@ -770,6 +770,18 @@ br_status arith_rewriter::mk_le_ge_eq_core(expr * arg1, expr * arg2, op_kind kin return BR_REWRITE3; } } + if (m_util.is_idiv(arg1, t, e) && is_numeral(e, a1) && a1 > 0) { + + // e > 0 => t div e ~ arg2 <=> e * (t div e) ~ e * arg2 <=> t - mod t e ~ e * arg2 + if (is_numeral(arg2, a2) && a2 == 0 && (kind == LE || kind == GE)) { + switch (kind) { + case LE: result = m_util.mk_le(result, m_util.mk_mul(e, arg2)); return BR_REWRITE3; + case GE: result = m_util.mk_ge(result, m_util.mk_mul(e, arg2)); return BR_REWRITE3; + case EQ: result = m.mk_eq(result, m_util.mk_mul(e, arg2)); return BR_REWRITE3; + } + } + // generally: result = m_util.mk_sub(t, m_util.mk_mod(t, e)); + } if ((m_arith_lhs || m_arith_ineq_lhs) && is_numeral(arg2, a2) && is_neg_poly(arg1, new_arg1)) { a2.neg(); new_arg2 = m_util.mk_numeral(a2, m_util.is_int(new_arg1));