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 9834 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 9880 of file z3py.py.

9880 def __add__(self, other):
9881 """Create the Z3 expression `self + other`.
9882
9883 >>> x = FP('x', FPSort(8, 24))
9884 >>> y = FP('y', FPSort(8, 24))
9885 >>> x + y
9886 x + y
9887 >>> (x + y).sort()
9888 FPSort(8, 24)
9889 """
9890 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9891 return fpAdd(_dflt_rm(), a, b, self.ctx)
9892

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

9967 def __div__(self, other):
9968 """Create the Z3 expression `self / other`.
9969
9970 >>> x = FP('x', FPSort(8, 24))
9971 >>> y = FP('y', FPSort(8, 24))
9972 >>> x / y
9973 x / y
9974 >>> (x / y).sort()
9975 FPSort(8, 24)
9976 >>> 10 / y
9977 1.25*(2**3) / y
9978 """
9979 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9980 return fpDiv(_dflt_rm(), a, b, self.ctx)
9981

◆ __ge__()

__ge__ ( self,
other )

Definition at line 9874 of file z3py.py.

9874 def __ge__(self, other):
9875 return fpGEQ(self, other, self.ctx)
9876

◆ __gt__()

__gt__ ( self,
other )

Definition at line 9877 of file z3py.py.

9877 def __gt__(self, other):
9878 return fpGT(self, other, self.ctx)
9879

◆ __le__()

__le__ ( self,
other )

Definition at line 9868 of file z3py.py.

9868 def __le__(self, other):
9869 return fpLEQ(self, other, self.ctx)
9870

◆ __lt__()

__lt__ ( self,
other )

Definition at line 9871 of file z3py.py.

9871 def __lt__(self, other):
9872 return fpLT(self, other, self.ctx)
9873

◆ __mod__()

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

Definition at line 10003 of file z3py.py.

10003 def __mod__(self, other):
10004 """Create the Z3 expression mod `self % other`."""
10005 return fpRem(self, other)
10006

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

9926 def __mul__(self, other):
9927 """Create the Z3 expression `self * other`.
9928
9929 >>> x = FP('x', FPSort(8, 24))
9930 >>> y = FP('y', FPSort(8, 24))
9931 >>> x * y
9932 x * y
9933 >>> (x * y).sort()
9934 FPSort(8, 24)
9935 >>> 10 * y
9936 1.25*(2**3) * y
9937 """
9938 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9939 return fpMul(_dflt_rm(), a, b, self.ctx)
9940

◆ __neg__()

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

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

Definition at line 9958 of file z3py.py.

9958 def __neg__(self):
9959 """Create the Z3 expression `-self`.
9960
9961 >>> x = FP('x', Float32())
9962 >>> -x
9963 -x
9964 """
9965 return fpNeg(self)
9966

◆ __pos__()

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

Definition at line 9954 of file z3py.py.

9954 def __pos__(self):
9955 """Create the Z3 expression `+self`."""
9956 return self
9957

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

9893 def __radd__(self, other):
9894 """Create the Z3 expression `other + self`.
9895
9896 >>> x = FP('x', FPSort(8, 24))
9897 >>> 10 + x
9898 1.25*(2**3) + x
9899 """
9900 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9901 return fpAdd(_dflt_rm(), a, b, self.ctx)
9902

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

9982 def __rdiv__(self, other):
9983 """Create the Z3 expression `other / self`.
9984
9985 >>> x = FP('x', FPSort(8, 24))
9986 >>> y = FP('y', FPSort(8, 24))
9987 >>> x / y
9988 x / y
9989 >>> x / 10
9990 x / 1.25*(2**3)
9991 """
9992 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9993 return fpDiv(_dflt_rm(), a, b, self.ctx)
9994

◆ __rmod__()

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

Definition at line 10007 of file z3py.py.

10007 def __rmod__(self, other):
10008 """Create the Z3 expression mod `other % self`."""
10009 return fpRem(other, self)
10010
10011

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

9941 def __rmul__(self, other):
9942 """Create the Z3 expression `other * self`.
9943
9944 >>> x = FP('x', FPSort(8, 24))
9945 >>> y = FP('y', FPSort(8, 24))
9946 >>> x * y
9947 x * y
9948 >>> x * 10
9949 x * 1.25*(2**3)
9950 """
9951 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9952 return fpMul(_dflt_rm(), a, b, self.ctx)
9953

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

9916 def __rsub__(self, other):
9917 """Create the Z3 expression `other - self`.
9918
9919 >>> x = FP('x', FPSort(8, 24))
9920 >>> 10 - x
9921 1.25*(2**3) - x
9922 """
9923 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9924 return fpSub(_dflt_rm(), a, b, self.ctx)
9925

◆ __rtruediv__()

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

Definition at line 9999 of file z3py.py.

9999 def __rtruediv__(self, other):
10000 """Create the Z3 expression division `other / self`."""
10001 return self.__rdiv__(other)
10002

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

9903 def __sub__(self, other):
9904 """Create the Z3 expression `self - other`.
9905
9906 >>> x = FP('x', FPSort(8, 24))
9907 >>> y = FP('y', FPSort(8, 24))
9908 >>> x - y
9909 x - y
9910 >>> (x - y).sort()
9911 FPSort(8, 24)
9912 """
9913 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9914 return fpSub(_dflt_rm(), a, b, self.ctx)
9915

◆ __truediv__()

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

Definition at line 9995 of file z3py.py.

9995 def __truediv__(self, other):
9996 """Create the Z3 expression division `self / other`."""
9997 return self.__div__(other)
9998

◆ as_string()

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

Reimplemented in FPNumRef.

Definition at line 9864 of file z3py.py.

9864 def as_string(self):
9865 """Return a Z3 floating point expression as a Python string."""
9866 return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
9867
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 9848 of file z3py.py.

9848 def ebits(self):
9849 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9850 >>> b = FPSort(8, 24)
9851 >>> b.ebits()
9852 8
9853 """
9854 return self.sort().ebits()
9855

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

9856 def sbits(self):
9857 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9858 >>> b = FPSort(8, 24)
9859 >>> b.sbits()
9860 24
9861 """
9862 return self.sort().sbits()
9863

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

9837 def sort(self):
9838 """Return the sort of the floating-point expression `self`.
9839
9840 >>> x = FP('1.0', FPSort(8, 24))
9841 >>> x.sort()
9842 FPSort(8, 24)
9843 >>> x.sort() == FPSort(8, 24)
9844 True
9845 """
9846 return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
9847
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.