3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-06 06:03:23 +00:00

Cleaned up FP predicates in the Python API. Fixes #2323.

This commit is contained in:
Christoph M. Wintersteiger 2019-07-03 12:32:28 +01:00
parent e0dc05c97e
commit df4065536f
No known key found for this signature in database
GPG key ID: BCF6360F86294467

View file

@ -9390,18 +9390,11 @@ def _mk_fp_unary(f, rm, a, ctx):
_z3_assert(is_fp(a), "Second argument must be a Z3 floating-point expression")
return FPRef(f(ctx.ref(), rm.as_ast(), a.as_ast()), ctx)
def _mk_fp_unary_norm(f, a, ctx):
ctx = _get_ctx(ctx)
[a] = _coerce_fp_expr_list([a], ctx)
if z3_debug():
_z3_assert(is_fp(a), "First argument must be a Z3 floating-point expression")
return BoolRef(f(ctx.ref(), a.as_ast()), ctx)
def _mk_fp_unary_pred(f, a, ctx):
ctx = _get_ctx(ctx)
[a] = _coerce_fp_expr_list([a], ctx)
if z3_debug():
_z3_assert(is_fp(a) or is_fp(b), "Second or third argument must be a Z3 floating-point expression")
_z3_assert(is_fp(a), "First argument must be a Z3 floating-point expression")
return BoolRef(f(ctx.ref(), a.as_ast()), ctx)
def _mk_fp_bin(f, rm, a, b, ctx):
@ -9557,7 +9550,7 @@ def fpIsNaN(a, ctx=None):
>>> fpIsNaN(x)
fpIsNaN(x)
"""
return _mk_fp_unary_norm(Z3_mk_fpa_is_nan, a, ctx)
return _mk_fp_unary_pred(Z3_mk_fpa_is_nan, a, ctx)
def fpIsInf(a, ctx=None):
"""Create a Z3 floating-point isInfinite expression.
@ -9567,33 +9560,32 @@ def fpIsInf(a, ctx=None):
>>> fpIsInf(x)
fpIsInf(x)
"""
return _mk_fp_unary_norm(Z3_mk_fpa_is_infinite, a, ctx)
return _mk_fp_unary_pred(Z3_mk_fpa_is_infinite, a, ctx)
def fpIsZero(a, ctx=None):
"""Create a Z3 floating-point isZero expression.
"""
return _mk_fp_unary_norm(Z3_mk_fpa_is_zero, a, ctx)
return _mk_fp_unary_pred(Z3_mk_fpa_is_zero, a, ctx)
def fpIsNormal(a, ctx=None):
"""Create a Z3 floating-point isNormal expression.
"""
return _mk_fp_unary_norm(Z3_mk_fpa_is_normal, a, ctx)
return _mk_fp_unary_pred(Z3_mk_fpa_is_normal, a, ctx)
def fpIsSubnormal(a, ctx=None):
"""Create a Z3 floating-point isSubnormal expression.
"""
return _mk_fp_unary_norm(Z3_mk_fpa_is_subnormal, a, ctx)
return _mk_fp_unary_pred(Z3_mk_fpa_is_subnormal, a, ctx)
def fpIsNegative(a, ctx=None):
"""Create a Z3 floating-point isNegative expression.
"""
return _mk_fp_unary_norm(Z3_mk_fpa_is_negative, a, ctx)
return _mk_fp_unary_pred(Z3_mk_fpa_is_negative, a, ctx)
def fpIsPositive(a, ctx=None):
"""Create a Z3 floating-point isPositive expression.
"""
return _mk_fp_unary_norm(Z3_mk_fpa_is_positive, a, ctx)
return FPRef(Z3_mk_fpa_is_positive(a.ctx_ref(), a.as_ast()), a.ctx)
return _mk_fp_unary_pred(Z3_mk_fpa_is_positive, a, ctx)
def _check_fp_args(a, b):
if z3_debug():
@ -10414,4 +10406,3 @@ def TransitiveClosure(f):
The transitive closure R+ is a new relation.
"""
return FuncDeclRef(Z3_mk_transitive_closure(f.ctx_ref(), f.ast), f.ctx)