Z3
Loading...
Searching...
No Matches
FPRef Class Reference
Inheritance diagram for FPRef:

Public Member Functions

 sort (self)
 ebits (self)
 sbits (self)
 as_string (self)
 __le__ (self, other)
 __lt__ (self, other)
 __ge__ (self, other)
 __gt__ (self, other)
 __add__ (self, other)
 __radd__ (self, other)
 __sub__ (self, other)
 __rsub__ (self, other)
 __mul__ (self, other)
 __rmul__ (self, other)
 __pos__ (self)
 __neg__ (self)
 __div__ (self, other)
 __rdiv__ (self, other)
 __truediv__ (self, other)
 __rtruediv__ (self, other)
 __mod__ (self, other)
 __rmod__ (self, other)
Public Member Functions inherited from ExprRef
 as_ast (self)
 get_id (self)
 sort_kind (self)
 __eq__ (self, other)
 __hash__ (self)
 __ne__ (self, other)
 params (self)
 decl (self)
 kind (self)
 num_args (self)
 arg (self, idx)
 children (self)
 update (self, *args)
 from_string (self, s)
 serialize (self)
Public Member Functions inherited from AstRef
 __init__ (self, ast, ctx=None)
 __del__ (self)
 __deepcopy__ (self, memo={})
 __str__ (self)
 __repr__ (self)
 __eq__ (self, other)
 __hash__ (self)
 __nonzero__ (self)
 __bool__ (self)
 sexpr (self)
 ctx_ref (self)
 eq (self, other)
 translate (self, target)
 __copy__ (self)
 hash (self)
 py_value (self)
Public Member Functions inherited from Z3PPObject
 use_pp (self)

Additional Inherited Members

Data Fields inherited from AstRef
 ast = ast
 ctx = _get_ctx(ctx)
Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)

Detailed Description

Floating-point expressions.

Definition at line 10303 of file z3py.py.

Member Function Documentation

◆ __add__()

__add__ ( self,
other )
Create the Z3 expression `self + other`.

>>> x = FP('x', FPSort(8, 24))
>>> y = FP('y', FPSort(8, 24))
>>> x + y
x + y
>>> (x + y).sort()
FPSort(8, 24)

Definition at line 10349 of file z3py.py.

10349 def __add__(self, other):
10350 """Create the Z3 expression `self + other`.
10351
10352 >>> x = FP('x', FPSort(8, 24))
10353 >>> y = FP('y', FPSort(8, 24))
10354 >>> x + y
10355 x + y
10356 >>> (x + y).sort()
10357 FPSort(8, 24)
10358 """
10359 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
10360 return fpAdd(_dflt_rm(), a, b, self.ctx)
10361

◆ __div__()

__div__ ( self,
other )
Create the Z3 expression `self / other`.

>>> x = FP('x', FPSort(8, 24))
>>> y = FP('y', FPSort(8, 24))
>>> x / y
x / y
>>> (x / y).sort()
FPSort(8, 24)
>>> 10 / y
1.25*(2**3) / y

Definition at line 10436 of file z3py.py.

10436 def __div__(self, other):
10437 """Create the Z3 expression `self / other`.
10438
10439 >>> x = FP('x', FPSort(8, 24))
10440 >>> y = FP('y', FPSort(8, 24))
10441 >>> x / y
10442 x / y
10443 >>> (x / y).sort()
10444 FPSort(8, 24)
10445 >>> 10 / y
10446 1.25*(2**3) / y
10447 """
10448 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
10449 return fpDiv(_dflt_rm(), a, b, self.ctx)
10450

◆ __ge__()

__ge__ ( self,
other )

Definition at line 10343 of file z3py.py.

10343 def __ge__(self, other):
10344 return fpGEQ(self, other, self.ctx)
10345

◆ __gt__()

__gt__ ( self,
other )

Definition at line 10346 of file z3py.py.

10346 def __gt__(self, other):
10347 return fpGT(self, other, self.ctx)
10348

◆ __le__()

__le__ ( self,
other )

Definition at line 10337 of file z3py.py.

10337 def __le__(self, other):
10338 return fpLEQ(self, other, self.ctx)
10339

◆ __lt__()

__lt__ ( self,
other )

Definition at line 10340 of file z3py.py.

10340 def __lt__(self, other):
10341 return fpLT(self, other, self.ctx)
10342

◆ __mod__()

__mod__ ( self,
other )
Create the Z3 expression mod `self % other`.

Definition at line 10472 of file z3py.py.

10472 def __mod__(self, other):
10473 """Create the Z3 expression mod `self % other`."""
10474 return fpRem(self, other)
10475

◆ __mul__()

__mul__ ( self,
other )
Create the Z3 expression `self * other`.

>>> x = FP('x', FPSort(8, 24))
>>> y = FP('y', FPSort(8, 24))
>>> x * y
x * y
>>> (x * y).sort()
FPSort(8, 24)
>>> 10 * y
1.25*(2**3) * y

Definition at line 10395 of file z3py.py.

10395 def __mul__(self, other):
10396 """Create the Z3 expression `self * other`.
10397
10398 >>> x = FP('x', FPSort(8, 24))
10399 >>> y = FP('y', FPSort(8, 24))
10400 >>> x * y
10401 x * y
10402 >>> (x * y).sort()
10403 FPSort(8, 24)
10404 >>> 10 * y
10405 1.25*(2**3) * y
10406 """
10407 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
10408 return fpMul(_dflt_rm(), a, b, self.ctx)
10409

◆ __neg__()

__neg__ ( self)
Create the Z3 expression `-self`.

>>> x = FP('x', Float32())
>>> -x
-x

Definition at line 10427 of file z3py.py.

10427 def __neg__(self):
10428 """Create the Z3 expression `-self`.
10429
10430 >>> x = FP('x', Float32())
10431 >>> -x
10432 -x
10433 """
10434 return fpNeg(self)
10435

◆ __pos__()

__pos__ ( self)
Create the Z3 expression `+self`.

Definition at line 10423 of file z3py.py.

10423 def __pos__(self):
10424 """Create the Z3 expression `+self`."""
10425 return self
10426

◆ __radd__()

__radd__ ( self,
other )
Create the Z3 expression `other + self`.

>>> x = FP('x', FPSort(8, 24))
>>> 10 + x
1.25*(2**3) + x

Definition at line 10362 of file z3py.py.

10362 def __radd__(self, other):
10363 """Create the Z3 expression `other + self`.
10364
10365 >>> x = FP('x', FPSort(8, 24))
10366 >>> 10 + x
10367 1.25*(2**3) + x
10368 """
10369 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
10370 return fpAdd(_dflt_rm(), a, b, self.ctx)
10371

◆ __rdiv__()

__rdiv__ ( self,
other )
Create the Z3 expression `other / self`.

>>> x = FP('x', FPSort(8, 24))
>>> y = FP('y', FPSort(8, 24))
>>> x / y
x / y
>>> x / 10
x / 1.25*(2**3)

Definition at line 10451 of file z3py.py.

10451 def __rdiv__(self, other):
10452 """Create the Z3 expression `other / self`.
10453
10454 >>> x = FP('x', FPSort(8, 24))
10455 >>> y = FP('y', FPSort(8, 24))
10456 >>> x / y
10457 x / y
10458 >>> x / 10
10459 x / 1.25*(2**3)
10460 """
10461 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
10462 return fpDiv(_dflt_rm(), a, b, self.ctx)
10463

◆ __rmod__()

__rmod__ ( self,
other )
Create the Z3 expression mod `other % self`.

Definition at line 10476 of file z3py.py.

10476 def __rmod__(self, other):
10477 """Create the Z3 expression mod `other % self`."""
10478 return fpRem(other, self)
10479
10480

◆ __rmul__()

__rmul__ ( self,
other )
Create the Z3 expression `other * self`.

>>> x = FP('x', FPSort(8, 24))
>>> y = FP('y', FPSort(8, 24))
>>> x * y
x * y
>>> x * 10
x * 1.25*(2**3)

Definition at line 10410 of file z3py.py.

10410 def __rmul__(self, other):
10411 """Create the Z3 expression `other * self`.
10412
10413 >>> x = FP('x', FPSort(8, 24))
10414 >>> y = FP('y', FPSort(8, 24))
10415 >>> x * y
10416 x * y
10417 >>> x * 10
10418 x * 1.25*(2**3)
10419 """
10420 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
10421 return fpMul(_dflt_rm(), a, b, self.ctx)
10422

◆ __rsub__()

__rsub__ ( self,
other )
Create the Z3 expression `other - self`.

>>> x = FP('x', FPSort(8, 24))
>>> 10 - x
1.25*(2**3) - x

Definition at line 10385 of file z3py.py.

10385 def __rsub__(self, other):
10386 """Create the Z3 expression `other - self`.
10387
10388 >>> x = FP('x', FPSort(8, 24))
10389 >>> 10 - x
10390 1.25*(2**3) - x
10391 """
10392 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
10393 return fpSub(_dflt_rm(), a, b, self.ctx)
10394

◆ __rtruediv__()

__rtruediv__ ( self,
other )
Create the Z3 expression division `other / self`.

Definition at line 10468 of file z3py.py.

10468 def __rtruediv__(self, other):
10469 """Create the Z3 expression division `other / self`."""
10470 return self.__rdiv__(other)
10471

◆ __sub__()

__sub__ ( self,
other )
Create the Z3 expression `self - other`.

>>> x = FP('x', FPSort(8, 24))
>>> y = FP('y', FPSort(8, 24))
>>> x - y
x - y
>>> (x - y).sort()
FPSort(8, 24)

Definition at line 10372 of file z3py.py.

10372 def __sub__(self, other):
10373 """Create the Z3 expression `self - other`.
10374
10375 >>> x = FP('x', FPSort(8, 24))
10376 >>> y = FP('y', FPSort(8, 24))
10377 >>> x - y
10378 x - y
10379 >>> (x - y).sort()
10380 FPSort(8, 24)
10381 """
10382 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
10383 return fpSub(_dflt_rm(), a, b, self.ctx)
10384

◆ __truediv__()

__truediv__ ( self,
other )
Create the Z3 expression division `self / other`.

Definition at line 10464 of file z3py.py.

10464 def __truediv__(self, other):
10465 """Create the Z3 expression division `self / other`."""
10466 return self.__div__(other)
10467

◆ as_string()

as_string ( self)
Return a Z3 floating point expression as a Python string.

Reimplemented in FPNumRef.

Definition at line 10333 of file z3py.py.

10333 def as_string(self):
10334 """Return a Z3 floating point expression as a Python string."""
10335 return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
10336
Z3_string Z3_API Z3_ast_to_string(Z3_context c, Z3_ast a)
Convert the given AST node into a string.

◆ ebits()

ebits ( self)
Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
>>> b = FPSort(8, 24)
>>> b.ebits()
8

Definition at line 10317 of file z3py.py.

10317 def ebits(self):
10318 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
10319 >>> b = FPSort(8, 24)
10320 >>> b.ebits()
10321 8
10322 """
10323 return self.sort().ebits()
10324

◆ sbits()

sbits ( self)
Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
>>> b = FPSort(8, 24)
>>> b.sbits()
24

Definition at line 10325 of file z3py.py.

10325 def sbits(self):
10326 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
10327 >>> b = FPSort(8, 24)
10328 >>> b.sbits()
10329 24
10330 """
10331 return self.sort().sbits()
10332

◆ sort()

sort ( self)
Return the sort of the floating-point expression `self`.

>>> x = FP('1.0', FPSort(8, 24))
>>> x.sort()
FPSort(8, 24)
>>> x.sort() == FPSort(8, 24)
True

Reimplemented from ExprRef.

Definition at line 10306 of file z3py.py.

10306 def sort(self):
10307 """Return the sort of the floating-point expression `self`.
10308
10309 >>> x = FP('1.0', FPSort(8, 24))
10310 >>> x.sort()
10311 FPSort(8, 24)
10312 >>> x.sort() == FPSort(8, 24)
10313 True
10314 """
10315 return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
10316
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.