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 9844 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 9890 of file z3py.py.

9890 def __add__(self, other):
9891 """Create the Z3 expression `self + other`.
9892
9893 >>> x = FP('x', FPSort(8, 24))
9894 >>> y = FP('y', FPSort(8, 24))
9895 >>> x + y
9896 x + y
9897 >>> (x + y).sort()
9898 FPSort(8, 24)
9899 """
9900 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9901 return fpAdd(_dflt_rm(), a, b, self.ctx)
9902

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

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

◆ __ge__()

__ge__ ( self,
other )

Definition at line 9884 of file z3py.py.

9884 def __ge__(self, other):
9885 return fpGEQ(self, other, self.ctx)
9886

◆ __gt__()

__gt__ ( self,
other )

Definition at line 9887 of file z3py.py.

9887 def __gt__(self, other):
9888 return fpGT(self, other, self.ctx)
9889

◆ __le__()

__le__ ( self,
other )

Definition at line 9878 of file z3py.py.

9878 def __le__(self, other):
9879 return fpLEQ(self, other, self.ctx)
9880

◆ __lt__()

__lt__ ( self,
other )

Definition at line 9881 of file z3py.py.

9881 def __lt__(self, other):
9882 return fpLT(self, other, self.ctx)
9883

◆ __mod__()

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

Definition at line 10013 of file z3py.py.

10013 def __mod__(self, other):
10014 """Create the Z3 expression mod `self % other`."""
10015 return fpRem(self, other)
10016

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

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

◆ __neg__()

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

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

Definition at line 9968 of file z3py.py.

9968 def __neg__(self):
9969 """Create the Z3 expression `-self`.
9970
9971 >>> x = FP('x', Float32())
9972 >>> -x
9973 -x
9974 """
9975 return fpNeg(self)
9976

◆ __pos__()

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

Definition at line 9964 of file z3py.py.

9964 def __pos__(self):
9965 """Create the Z3 expression `+self`."""
9966 return self
9967

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

9903 def __radd__(self, other):
9904 """Create the Z3 expression `other + self`.
9905
9906 >>> x = FP('x', FPSort(8, 24))
9907 >>> 10 + x
9908 1.25*(2**3) + x
9909 """
9910 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9911 return fpAdd(_dflt_rm(), a, b, self.ctx)
9912

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

9992 def __rdiv__(self, other):
9993 """Create the Z3 expression `other / self`.
9994
9995 >>> x = FP('x', FPSort(8, 24))
9996 >>> y = FP('y', FPSort(8, 24))
9997 >>> x / y
9998 x / y
9999 >>> x / 10
10000 x / 1.25*(2**3)
10001 """
10002 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
10003 return fpDiv(_dflt_rm(), a, b, self.ctx)
10004

◆ __rmod__()

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

Definition at line 10017 of file z3py.py.

10017 def __rmod__(self, other):
10018 """Create the Z3 expression mod `other % self`."""
10019 return fpRem(other, self)
10020
10021

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

9951 def __rmul__(self, other):
9952 """Create the Z3 expression `other * self`.
9953
9954 >>> x = FP('x', FPSort(8, 24))
9955 >>> y = FP('y', FPSort(8, 24))
9956 >>> x * y
9957 x * y
9958 >>> x * 10
9959 x * 1.25*(2**3)
9960 """
9961 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9962 return fpMul(_dflt_rm(), a, b, self.ctx)
9963

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

9926 def __rsub__(self, other):
9927 """Create the Z3 expression `other - self`.
9928
9929 >>> x = FP('x', FPSort(8, 24))
9930 >>> 10 - x
9931 1.25*(2**3) - x
9932 """
9933 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9934 return fpSub(_dflt_rm(), a, b, self.ctx)
9935

◆ __rtruediv__()

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

Definition at line 10009 of file z3py.py.

10009 def __rtruediv__(self, other):
10010 """Create the Z3 expression division `other / self`."""
10011 return self.__rdiv__(other)
10012

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

9913 def __sub__(self, other):
9914 """Create the Z3 expression `self - other`.
9915
9916 >>> x = FP('x', FPSort(8, 24))
9917 >>> y = FP('y', FPSort(8, 24))
9918 >>> x - y
9919 x - y
9920 >>> (x - y).sort()
9921 FPSort(8, 24)
9922 """
9923 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9924 return fpSub(_dflt_rm(), a, b, self.ctx)
9925

◆ __truediv__()

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

Definition at line 10005 of file z3py.py.

10005 def __truediv__(self, other):
10006 """Create the Z3 expression division `self / other`."""
10007 return self.__div__(other)
10008

◆ as_string()

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

Reimplemented in FPNumRef.

Definition at line 9874 of file z3py.py.

9874 def as_string(self):
9875 """Return a Z3 floating point expression as a Python string."""
9876 return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
9877
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 9858 of file z3py.py.

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

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

9866 def sbits(self):
9867 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9868 >>> b = FPSort(8, 24)
9869 >>> b.sbits()
9870 24
9871 """
9872 return self.sort().sbits()
9873

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

9847 def sort(self):
9848 """Return the sort of the floating-point expression `self`.
9849
9850 >>> x = FP('1.0', FPSort(8, 24))
9851 >>> x.sort()
9852 FPSort(8, 24)
9853 >>> x.sort() == FPSort(8, 24)
9854 True
9855 """
9856 return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
9857
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.