mirror of
https://github.com/Z3Prover/z3
synced 2025-05-05 23:05:46 +00:00
Add support for abs (absolute value) function in theory arith (it is part of the SMT-LIB 2.0 standard)
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
490905e320
commit
c4f762028f
6 changed files with 31 additions and 0 deletions
|
@ -70,6 +70,7 @@ br_status arith_rewriter::mk_app_core(func_decl * f, unsigned num_args, expr * c
|
|||
case OP_TO_INT: SASSERT(num_args == 1); st = mk_to_int_core(args[0], result); break;
|
||||
case OP_IS_INT: SASSERT(num_args == 1); st = mk_is_int(args[0], result); break;
|
||||
case OP_POWER: SASSERT(num_args == 2); st = mk_power_core(args[0], args[1], result); break;
|
||||
case OP_ABS: SASSERT(num_args == 1); st = mk_abs_core(args[0], result); break;
|
||||
case OP_SIN: SASSERT(num_args == 1); st = mk_sin_core(args[0], result); break;
|
||||
case OP_COS: SASSERT(num_args == 1); st = mk_cos_core(args[0], result); break;
|
||||
case OP_TAN: SASSERT(num_args == 1); st = mk_tan_core(args[0], result); break;
|
||||
|
@ -1024,6 +1025,11 @@ br_status arith_rewriter::mk_is_int(expr * arg, expr_ref & result) {
|
|||
}
|
||||
}
|
||||
|
||||
br_status arith_rewriter::mk_abs_core(expr * arg, expr_ref & result) {
|
||||
result = m().mk_ite(m_util.mk_ge(arg, m_util.mk_numeral(rational(0), m_util.is_int(arg))), arg, m_util.mk_uminus(arg));
|
||||
return BR_REWRITE2;
|
||||
}
|
||||
|
||||
void arith_rewriter::set_cancel(bool f) {
|
||||
m_util.set_cancel(f);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue