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)
 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 9739 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 9785 of file z3py.py.

9785 def __add__(self, other):
9786 """Create the Z3 expression `self + other`.
9787
9788 >>> x = FP('x', FPSort(8, 24))
9789 >>> y = FP('y', FPSort(8, 24))
9790 >>> x + y
9791 x + y
9792 >>> (x + y).sort()
9793 FPSort(8, 24)
9794 """
9795 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9796 return fpAdd(_dflt_rm(), a, b, self.ctx)
9797

◆ __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 9872 of file z3py.py.

9872 def __div__(self, other):
9873 """Create the Z3 expression `self / other`.
9874
9875 >>> x = FP('x', FPSort(8, 24))
9876 >>> y = FP('y', FPSort(8, 24))
9877 >>> x / y
9878 x / y
9879 >>> (x / y).sort()
9880 FPSort(8, 24)
9881 >>> 10 / y
9882 1.25*(2**3) / y
9883 """
9884 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9885 return fpDiv(_dflt_rm(), a, b, self.ctx)
9886

◆ __ge__()

__ge__ ( self,
other )

Definition at line 9779 of file z3py.py.

9779 def __ge__(self, other):
9780 return fpGEQ(self, other, self.ctx)
9781

◆ __gt__()

__gt__ ( self,
other )

Definition at line 9782 of file z3py.py.

9782 def __gt__(self, other):
9783 return fpGT(self, other, self.ctx)
9784

◆ __le__()

__le__ ( self,
other )

Definition at line 9773 of file z3py.py.

9773 def __le__(self, other):
9774 return fpLEQ(self, other, self.ctx)
9775

◆ __lt__()

__lt__ ( self,
other )

Definition at line 9776 of file z3py.py.

9776 def __lt__(self, other):
9777 return fpLT(self, other, self.ctx)
9778

◆ __mod__()

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

Definition at line 9908 of file z3py.py.

9908 def __mod__(self, other):
9909 """Create the Z3 expression mod `self % other`."""
9910 return fpRem(self, other)
9911

◆ __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 9831 of file z3py.py.

9831 def __mul__(self, other):
9832 """Create the Z3 expression `self * other`.
9833
9834 >>> x = FP('x', FPSort(8, 24))
9835 >>> y = FP('y', FPSort(8, 24))
9836 >>> x * y
9837 x * y
9838 >>> (x * y).sort()
9839 FPSort(8, 24)
9840 >>> 10 * y
9841 1.25*(2**3) * y
9842 """
9843 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9844 return fpMul(_dflt_rm(), a, b, self.ctx)
9845

◆ __neg__()

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

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

Definition at line 9863 of file z3py.py.

9863 def __neg__(self):
9864 """Create the Z3 expression `-self`.
9865
9866 >>> x = FP('x', Float32())
9867 >>> -x
9868 -x
9869 """
9870 return fpNeg(self)
9871

◆ __pos__()

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

Definition at line 9859 of file z3py.py.

9859 def __pos__(self):
9860 """Create the Z3 expression `+self`."""
9861 return self
9862

◆ __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 9798 of file z3py.py.

9798 def __radd__(self, other):
9799 """Create the Z3 expression `other + self`.
9800
9801 >>> x = FP('x', FPSort(8, 24))
9802 >>> 10 + x
9803 1.25*(2**3) + x
9804 """
9805 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9806 return fpAdd(_dflt_rm(), a, b, self.ctx)
9807

◆ __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 9887 of file z3py.py.

9887 def __rdiv__(self, other):
9888 """Create the Z3 expression `other / self`.
9889
9890 >>> x = FP('x', FPSort(8, 24))
9891 >>> y = FP('y', FPSort(8, 24))
9892 >>> x / y
9893 x / y
9894 >>> x / 10
9895 x / 1.25*(2**3)
9896 """
9897 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9898 return fpDiv(_dflt_rm(), a, b, self.ctx)
9899

◆ __rmod__()

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

Definition at line 9912 of file z3py.py.

9912 def __rmod__(self, other):
9913 """Create the Z3 expression mod `other % self`."""
9914 return fpRem(other, self)
9915
9916

◆ __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 9846 of file z3py.py.

9846 def __rmul__(self, other):
9847 """Create the Z3 expression `other * self`.
9848
9849 >>> x = FP('x', FPSort(8, 24))
9850 >>> y = FP('y', FPSort(8, 24))
9851 >>> x * y
9852 x * y
9853 >>> x * 10
9854 x * 1.25*(2**3)
9855 """
9856 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9857 return fpMul(_dflt_rm(), a, b, self.ctx)
9858

◆ __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 9821 of file z3py.py.

9821 def __rsub__(self, other):
9822 """Create the Z3 expression `other - self`.
9823
9824 >>> x = FP('x', FPSort(8, 24))
9825 >>> 10 - x
9826 1.25*(2**3) - x
9827 """
9828 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9829 return fpSub(_dflt_rm(), a, b, self.ctx)
9830

◆ __rtruediv__()

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

Definition at line 9904 of file z3py.py.

9904 def __rtruediv__(self, other):
9905 """Create the Z3 expression division `other / self`."""
9906 return self.__rdiv__(other)
9907

◆ __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 9808 of file z3py.py.

9808 def __sub__(self, other):
9809 """Create the Z3 expression `self - other`.
9810
9811 >>> x = FP('x', FPSort(8, 24))
9812 >>> y = FP('y', FPSort(8, 24))
9813 >>> x - y
9814 x - y
9815 >>> (x - y).sort()
9816 FPSort(8, 24)
9817 """
9818 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9819 return fpSub(_dflt_rm(), a, b, self.ctx)
9820

◆ __truediv__()

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

Definition at line 9900 of file z3py.py.

9900 def __truediv__(self, other):
9901 """Create the Z3 expression division `self / other`."""
9902 return self.__div__(other)
9903

◆ as_string()

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

Reimplemented in FPNumRef.

Definition at line 9769 of file z3py.py.

9769 def as_string(self):
9770 """Return a Z3 floating point expression as a Python string."""
9771 return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
9772
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 9753 of file z3py.py.

9753 def ebits(self):
9754 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9755 >>> b = FPSort(8, 24)
9756 >>> b.ebits()
9757 8
9758 """
9759 return self.sort().ebits()
9760

◆ 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 9761 of file z3py.py.

9761 def sbits(self):
9762 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9763 >>> b = FPSort(8, 24)
9764 >>> b.sbits()
9765 24
9766 """
9767 return self.sort().sbits()
9768

◆ 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 9742 of file z3py.py.

9742 def sort(self):
9743 """Return the sort of the floating-point expression `self`.
9744
9745 >>> x = FP('1.0', FPSort(8, 24))
9746 >>> x.sort()
9747 FPSort(8, 24)
9748 >>> x.sort() == FPSort(8, 24)
9749 True
9750 """
9751 return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
9752
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.