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 9774 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 9820 of file z3py.py.

9820 def __add__(self, other):
9821 """Create the Z3 expression `self + other`.
9822
9823 >>> x = FP('x', FPSort(8, 24))
9824 >>> y = FP('y', FPSort(8, 24))
9825 >>> x + y
9826 x + y
9827 >>> (x + y).sort()
9828 FPSort(8, 24)
9829 """
9830 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9831 return fpAdd(_dflt_rm(), a, b, self.ctx)
9832

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

9907 def __div__(self, other):
9908 """Create the Z3 expression `self / other`.
9909
9910 >>> x = FP('x', FPSort(8, 24))
9911 >>> y = FP('y', FPSort(8, 24))
9912 >>> x / y
9913 x / y
9914 >>> (x / y).sort()
9915 FPSort(8, 24)
9916 >>> 10 / y
9917 1.25*(2**3) / y
9918 """
9919 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9920 return fpDiv(_dflt_rm(), a, b, self.ctx)
9921

◆ __ge__()

__ge__ ( self,
other )

Definition at line 9814 of file z3py.py.

9814 def __ge__(self, other):
9815 return fpGEQ(self, other, self.ctx)
9816

◆ __gt__()

__gt__ ( self,
other )

Definition at line 9817 of file z3py.py.

9817 def __gt__(self, other):
9818 return fpGT(self, other, self.ctx)
9819

◆ __le__()

__le__ ( self,
other )

Definition at line 9808 of file z3py.py.

9808 def __le__(self, other):
9809 return fpLEQ(self, other, self.ctx)
9810

◆ __lt__()

__lt__ ( self,
other )

Definition at line 9811 of file z3py.py.

9811 def __lt__(self, other):
9812 return fpLT(self, other, self.ctx)
9813

◆ __mod__()

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

Definition at line 9943 of file z3py.py.

9943 def __mod__(self, other):
9944 """Create the Z3 expression mod `self % other`."""
9945 return fpRem(self, other)
9946

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

9866 def __mul__(self, other):
9867 """Create the Z3 expression `self * other`.
9868
9869 >>> x = FP('x', FPSort(8, 24))
9870 >>> y = FP('y', FPSort(8, 24))
9871 >>> x * y
9872 x * y
9873 >>> (x * y).sort()
9874 FPSort(8, 24)
9875 >>> 10 * y
9876 1.25*(2**3) * y
9877 """
9878 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9879 return fpMul(_dflt_rm(), a, b, self.ctx)
9880

◆ __neg__()

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

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

Definition at line 9898 of file z3py.py.

9898 def __neg__(self):
9899 """Create the Z3 expression `-self`.
9900
9901 >>> x = FP('x', Float32())
9902 >>> -x
9903 -x
9904 """
9905 return fpNeg(self)
9906

◆ __pos__()

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

Definition at line 9894 of file z3py.py.

9894 def __pos__(self):
9895 """Create the Z3 expression `+self`."""
9896 return self
9897

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

9833 def __radd__(self, other):
9834 """Create the Z3 expression `other + self`.
9835
9836 >>> x = FP('x', FPSort(8, 24))
9837 >>> 10 + x
9838 1.25*(2**3) + x
9839 """
9840 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9841 return fpAdd(_dflt_rm(), a, b, self.ctx)
9842

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

9922 def __rdiv__(self, other):
9923 """Create the Z3 expression `other / self`.
9924
9925 >>> x = FP('x', FPSort(8, 24))
9926 >>> y = FP('y', FPSort(8, 24))
9927 >>> x / y
9928 x / y
9929 >>> x / 10
9930 x / 1.25*(2**3)
9931 """
9932 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9933 return fpDiv(_dflt_rm(), a, b, self.ctx)
9934

◆ __rmod__()

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

Definition at line 9947 of file z3py.py.

9947 def __rmod__(self, other):
9948 """Create the Z3 expression mod `other % self`."""
9949 return fpRem(other, self)
9950
9951

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

9881 def __rmul__(self, other):
9882 """Create the Z3 expression `other * self`.
9883
9884 >>> x = FP('x', FPSort(8, 24))
9885 >>> y = FP('y', FPSort(8, 24))
9886 >>> x * y
9887 x * y
9888 >>> x * 10
9889 x * 1.25*(2**3)
9890 """
9891 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9892 return fpMul(_dflt_rm(), a, b, self.ctx)
9893

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

9856 def __rsub__(self, other):
9857 """Create the Z3 expression `other - self`.
9858
9859 >>> x = FP('x', FPSort(8, 24))
9860 >>> 10 - x
9861 1.25*(2**3) - x
9862 """
9863 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9864 return fpSub(_dflt_rm(), a, b, self.ctx)
9865

◆ __rtruediv__()

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

Definition at line 9939 of file z3py.py.

9939 def __rtruediv__(self, other):
9940 """Create the Z3 expression division `other / self`."""
9941 return self.__rdiv__(other)
9942

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

9843 def __sub__(self, other):
9844 """Create the Z3 expression `self - other`.
9845
9846 >>> x = FP('x', FPSort(8, 24))
9847 >>> y = FP('y', FPSort(8, 24))
9848 >>> x - y
9849 x - y
9850 >>> (x - y).sort()
9851 FPSort(8, 24)
9852 """
9853 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9854 return fpSub(_dflt_rm(), a, b, self.ctx)
9855

◆ __truediv__()

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

Definition at line 9935 of file z3py.py.

9935 def __truediv__(self, other):
9936 """Create the Z3 expression division `self / other`."""
9937 return self.__div__(other)
9938

◆ as_string()

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

Reimplemented in FPNumRef.

Definition at line 9804 of file z3py.py.

9804 def as_string(self):
9805 """Return a Z3 floating point expression as a Python string."""
9806 return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
9807
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 9788 of file z3py.py.

9788 def ebits(self):
9789 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9790 >>> b = FPSort(8, 24)
9791 >>> b.ebits()
9792 8
9793 """
9794 return self.sort().ebits()
9795

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

9796 def sbits(self):
9797 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9798 >>> b = FPSort(8, 24)
9799 >>> b.sbits()
9800 24
9801 """
9802 return self.sort().sbits()
9803

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

9777 def sort(self):
9778 """Return the sort of the floating-point expression `self`.
9779
9780 >>> x = FP('1.0', FPSort(8, 24))
9781 >>> x.sort()
9782 FPSort(8, 24)
9783 >>> x.sort() == FPSort(8, 24)
9784 True
9785 """
9786 return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
9787
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.