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 9706 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 9752 of file z3py.py.

9752 def __add__(self, other):
9753 """Create the Z3 expression `self + other`.
9754
9755 >>> x = FP('x', FPSort(8, 24))
9756 >>> y = FP('y', FPSort(8, 24))
9757 >>> x + y
9758 x + y
9759 >>> (x + y).sort()
9760 FPSort(8, 24)
9761 """
9762 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9763 return fpAdd(_dflt_rm(), a, b, self.ctx)
9764

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

9839 def __div__(self, other):
9840 """Create the Z3 expression `self / other`.
9841
9842 >>> x = FP('x', FPSort(8, 24))
9843 >>> y = FP('y', FPSort(8, 24))
9844 >>> x / y
9845 x / y
9846 >>> (x / y).sort()
9847 FPSort(8, 24)
9848 >>> 10 / y
9849 1.25*(2**3) / y
9850 """
9851 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9852 return fpDiv(_dflt_rm(), a, b, self.ctx)
9853

◆ __ge__()

__ge__ ( self,
other )

Definition at line 9746 of file z3py.py.

9746 def __ge__(self, other):
9747 return fpGEQ(self, other, self.ctx)
9748

◆ __gt__()

__gt__ ( self,
other )

Definition at line 9749 of file z3py.py.

9749 def __gt__(self, other):
9750 return fpGT(self, other, self.ctx)
9751

◆ __le__()

__le__ ( self,
other )

Definition at line 9740 of file z3py.py.

9740 def __le__(self, other):
9741 return fpLEQ(self, other, self.ctx)
9742

◆ __lt__()

__lt__ ( self,
other )

Definition at line 9743 of file z3py.py.

9743 def __lt__(self, other):
9744 return fpLT(self, other, self.ctx)
9745

◆ __mod__()

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

Definition at line 9875 of file z3py.py.

9875 def __mod__(self, other):
9876 """Create the Z3 expression mod `self % other`."""
9877 return fpRem(self, other)
9878

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

9798 def __mul__(self, other):
9799 """Create the Z3 expression `self * other`.
9800
9801 >>> x = FP('x', FPSort(8, 24))
9802 >>> y = FP('y', FPSort(8, 24))
9803 >>> x * y
9804 x * y
9805 >>> (x * y).sort()
9806 FPSort(8, 24)
9807 >>> 10 * y
9808 1.25*(2**3) * y
9809 """
9810 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9811 return fpMul(_dflt_rm(), a, b, self.ctx)
9812

◆ __neg__()

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

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

Definition at line 9830 of file z3py.py.

9830 def __neg__(self):
9831 """Create the Z3 expression `-self`.
9832
9833 >>> x = FP('x', Float32())
9834 >>> -x
9835 -x
9836 """
9837 return fpNeg(self)
9838

◆ __pos__()

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

Definition at line 9826 of file z3py.py.

9826 def __pos__(self):
9827 """Create the Z3 expression `+self`."""
9828 return self
9829

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

9765 def __radd__(self, other):
9766 """Create the Z3 expression `other + self`.
9767
9768 >>> x = FP('x', FPSort(8, 24))
9769 >>> 10 + x
9770 1.25*(2**3) + x
9771 """
9772 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9773 return fpAdd(_dflt_rm(), a, b, self.ctx)
9774

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

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

◆ __rmod__()

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

Definition at line 9879 of file z3py.py.

9879 def __rmod__(self, other):
9880 """Create the Z3 expression mod `other % self`."""
9881 return fpRem(other, self)
9882
9883

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

9813 def __rmul__(self, other):
9814 """Create the Z3 expression `other * self`.
9815
9816 >>> x = FP('x', FPSort(8, 24))
9817 >>> y = FP('y', FPSort(8, 24))
9818 >>> x * y
9819 x * y
9820 >>> x * 10
9821 x * 1.25*(2**3)
9822 """
9823 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9824 return fpMul(_dflt_rm(), a, b, self.ctx)
9825

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

9788 def __rsub__(self, other):
9789 """Create the Z3 expression `other - self`.
9790
9791 >>> x = FP('x', FPSort(8, 24))
9792 >>> 10 - x
9793 1.25*(2**3) - x
9794 """
9795 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9796 return fpSub(_dflt_rm(), a, b, self.ctx)
9797

◆ __rtruediv__()

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

Definition at line 9871 of file z3py.py.

9871 def __rtruediv__(self, other):
9872 """Create the Z3 expression division `other / self`."""
9873 return self.__rdiv__(other)
9874

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

9775 def __sub__(self, other):
9776 """Create the Z3 expression `self - other`.
9777
9778 >>> x = FP('x', FPSort(8, 24))
9779 >>> y = FP('y', FPSort(8, 24))
9780 >>> x - y
9781 x - y
9782 >>> (x - y).sort()
9783 FPSort(8, 24)
9784 """
9785 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9786 return fpSub(_dflt_rm(), a, b, self.ctx)
9787

◆ __truediv__()

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

Definition at line 9867 of file z3py.py.

9867 def __truediv__(self, other):
9868 """Create the Z3 expression division `self / other`."""
9869 return self.__div__(other)
9870

◆ as_string()

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

Reimplemented in FPNumRef.

Definition at line 9736 of file z3py.py.

9736 def as_string(self):
9737 """Return a Z3 floating point expression as a Python string."""
9738 return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
9739
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 9720 of file z3py.py.

9720 def ebits(self):
9721 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9722 >>> b = FPSort(8, 24)
9723 >>> b.ebits()
9724 8
9725 """
9726 return self.sort().ebits()
9727

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

9728 def sbits(self):
9729 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9730 >>> b = FPSort(8, 24)
9731 >>> b.sbits()
9732 24
9733 """
9734 return self.sort().sbits()
9735

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

9709 def sort(self):
9710 """Return the sort of the floating-point expression `self`.
9711
9712 >>> x = FP('1.0', FPSort(8, 24))
9713 >>> x.sort()
9714 FPSort(8, 24)
9715 >>> x.sort() == FPSort(8, 24)
9716 True
9717 """
9718 return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
9719
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.