mirror of
				https://github.com/Z3Prover/z3
				synced 2025-10-31 19:52:29 +00:00 
			
		
		
		
	Cleaned up FP predicates in the Python API. Fixes #2323.
This commit is contained in:
		
							parent
							
								
									e0dc05c97e
								
							
						
					
					
						commit
						df4065536f
					
				
					 1 changed files with 55 additions and 64 deletions
				
			
		|  | @ -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) | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue