Skip to content

Commit

Permalink
fix #6676 get rid of rem0 declare it to be mod0 semantics to simplify…
Browse files Browse the repository at this point in the history
… code paths
  • Loading branch information
NikolajBjorner committed Apr 11, 2023
1 parent 58a2a9c commit 0b5c38d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 14 deletions.
7 changes: 2 additions & 5 deletions src/ast/arith_decl_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ inline func_decl * arith_decl_plugin::mk_func_decl(decl_kind k, bool is_real) {
case OP_MOD: return m_i_mod_decl;
case OP_DIV0: return m_manager->mk_func_decl(symbol("/0"), m_real_decl, m_real_decl, m_real_decl, func_decl_info(m_family_id, OP_DIV0));
case OP_IDIV0: return m_manager->mk_func_decl(symbol("div0"), m_int_decl, m_int_decl, m_int_decl, func_decl_info(m_family_id, OP_IDIV0));
case OP_REM0: return m_manager->mk_func_decl(symbol("rem0"), m_int_decl, m_int_decl, m_int_decl, func_decl_info(m_family_id, OP_REM0));
case OP_MOD0: return m_manager->mk_func_decl(symbol("mod0"), m_int_decl, m_int_decl, m_int_decl, func_decl_info(m_family_id, OP_MOD0));
case OP_POWER0:
if (is_real) {
Expand Down Expand Up @@ -612,7 +611,6 @@ void arith_decl_plugin::get_op_names(svector<builtin_name>& op_names, symbol con
op_names.push_back(builtin_name("euler", OP_E));
op_names.push_back(builtin_name("/0",OP_DIV0));
op_names.push_back(builtin_name("div0",OP_IDIV0));
op_names.push_back(builtin_name("rem0",OP_REM0));
op_names.push_back(builtin_name("mod0",OP_MOD0));
}
}
Expand Down Expand Up @@ -821,7 +819,7 @@ bool arith_util::is_considered_uninterpreted(func_decl* f, unsigned n, expr* con
}
if (is_decl_of(f, arith_family_id, OP_REM) && n == 2 && is_numeral(args[1], r) && r.is_zero()) {
sort* rs[2] = { mk_int(), mk_int() };
f_out = m_manager.mk_func_decl(arith_family_id, OP_REM0, 0, nullptr, 2, rs, mk_int());
f_out = m_manager.mk_func_decl(arith_family_id, OP_MOD0, 0, nullptr, 2, rs, mk_int());
return true;
}
if (is_decl_of(f, arith_family_id, OP_POWER) && n == 2 && is_numeral(args[1], r) && r.is_zero() && is_numeral(args[0], r) && r.is_zero()) {
Expand Down Expand Up @@ -857,7 +855,7 @@ func_decl* arith_util::mk_idiv0() {

func_decl* arith_util::mk_rem0() {
sort* rs[2] = { mk_int(), mk_int() };
return m_manager.mk_func_decl(arith_family_id, OP_REM0, 0, nullptr, 2, rs, mk_int());
return m_manager.mk_func_decl(arith_family_id, OP_MOD0, 0, nullptr, 2, rs, mk_int());
}

func_decl* arith_util::mk_mod0() {
Expand Down Expand Up @@ -942,7 +940,6 @@ bool arith_util::is_underspecified(expr* e) const {
case OP_MOD:
case OP_DIV0:
case OP_IDIV0:
case OP_REM0:
case OP_MOD0:
return true;
default:
Expand Down
10 changes: 4 additions & 6 deletions src/ast/arith_decl_plugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ enum arith_op_kind {
OP_IDIVIDES,
OP_REM,
OP_MOD,
OP_REM0,
OP_MOD0,
OP_TO_REAL,
OP_TO_INT,
Expand Down Expand Up @@ -216,7 +215,6 @@ class arith_decl_plugin : public decl_plugin {
case OP_U_ACOS:
case OP_DIV0:
case OP_IDIV0:
case OP_REM0:
case OP_MOD0:
case OP_POWER0:
return true;
Expand Down Expand Up @@ -270,7 +268,7 @@ class arith_recognizers {

bool is_div0(func_decl const * n) const { return is_decl_of(n, arith_family_id, OP_DIV0); }
bool is_idiv0(func_decl const * n) const { return is_decl_of(n, arith_family_id, OP_IDIV0); }
bool is_rem0(func_decl const * n) const { return is_decl_of(n, arith_family_id, OP_REM0); }
bool is_rem0(func_decl const * n) const { return is_decl_of(n, arith_family_id, OP_MOD0); }
bool is_mod0(func_decl const * n) const { return is_decl_of(n, arith_family_id, OP_MOD0); }
bool is_power0(func_decl const * n) const { return is_decl_of(n, arith_family_id, OP_POWER0); }
bool is_power(func_decl const * n) const { return is_decl_of(n, arith_family_id, OP_POWER); }
Expand All @@ -296,7 +294,7 @@ class arith_recognizers {
bool is_mod(expr const * n) const { return is_app_of(n, arith_family_id, OP_MOD); }
bool is_rem(expr const * n) const { return is_app_of(n, arith_family_id, OP_REM); }
bool is_mod0(expr const * n) const { return is_app_of(n, arith_family_id, OP_MOD0); }
bool is_rem0(expr const * n) const { return is_app_of(n, arith_family_id, OP_REM0); }
bool is_rem0(expr const * n) const { return is_app_of(n, arith_family_id, OP_MOD0); }
bool is_to_real(expr const * n) const { return is_app_of(n, arith_family_id, OP_TO_REAL); }
bool is_to_int(expr const * n) const { return is_app_of(n, arith_family_id, OP_TO_INT); }
bool is_is_int(expr const * n) const { return is_app_of(n, arith_family_id, OP_IS_INT); }
Expand Down Expand Up @@ -355,7 +353,7 @@ class arith_recognizers {
MATCH_BINARY(is_div);
MATCH_BINARY(is_idiv);
MATCH_BINARY(is_mod0);
MATCH_BINARY(is_rem0);
// MATCH_BINARY(is_rem0);
MATCH_BINARY(is_div0);
MATCH_BINARY(is_idiv0);
MATCH_BINARY(is_power);
Expand Down Expand Up @@ -465,7 +463,7 @@ class arith_util : public arith_recognizers {
app * mk_mod(expr * arg1, expr * arg2) { return m_manager.mk_app(arith_family_id, OP_MOD, arg1, arg2); }
app * mk_div0(expr * arg1, expr * arg2) { return m_manager.mk_app(arith_family_id, OP_DIV0, arg1, arg2); }
app * mk_idiv0(expr * arg1, expr * arg2) { return m_manager.mk_app(arith_family_id, OP_IDIV0, arg1, arg2); }
app * mk_rem0(expr * arg1, expr * arg2) { return m_manager.mk_app(arith_family_id, OP_REM0, arg1, arg2); }
app * mk_rem0(expr * arg1, expr * arg2) { return m_manager.mk_app(arith_family_id, OP_MOD0, arg1, arg2); }
app * mk_mod0(expr * arg1, expr * arg2) { return m_manager.mk_app(arith_family_id, OP_MOD0, arg1, arg2); }
app * mk_to_real(expr * arg1) { return m_manager.mk_app(arith_family_id, OP_TO_REAL, arg1); }
app * mk_to_int(expr * arg1) { return m_manager.mk_app(arith_family_id, OP_TO_INT, arg1); }
Expand Down
1 change: 0 additions & 1 deletion src/math/subpaving/tactic/expr2subpaving.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,6 @@ struct expr2subpaving::imp {
case OP_REM:
case OP_IRRATIONAL_ALGEBRAIC_NUM:
case OP_DIV0:
case OP_REM0:
case OP_MOD0:
case OP_IDIV0:
throw default_exception("you must apply arithmetic purifier before internalizing expressions into the subpaving module.");
Expand Down
1 change: 0 additions & 1 deletion src/smt/theory_arith_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ namespace smt {
case OP_MOD:
case OP_DIV0:
case OP_IDIV0:
case OP_REM0:
case OP_MOD0:
return true;
default:
Expand Down
2 changes: 1 addition & 1 deletion src/smt/theory_lra.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ class theory_lra::imp {
st.to_ensure_var().push_back(n1);
st.to_ensure_var().push_back(n2);
}
else if (a.is_idiv0(n, n1, n2) || a.is_mod0(n, n1, n2) || a.is_rem0(n, n1, n2)) {
else if (a.is_idiv0(n, n1, n2) || a.is_mod0(n, n1, n2)) {
st.to_ensure_var().push_back(n1);
st.to_ensure_var().push_back(n2);
}
Expand Down

0 comments on commit 0b5c38d

Please sign in to comment.