Z3
Public Member Functions
FPRef Class Reference

FP Expressions. More...

+ Inheritance diagram for FPRef:

Public Member Functions

def sort (self)
 
def ebits (self)
 
def sbits (self)
 
def as_string (self)
 
def __le__ (self, other)
 
def __lt__ (self, other)
 
def __ge__ (self, other)
 
def __gt__ (self, other)
 
def __add__ (self, other)
 
def __radd__ (self, other)
 
def __sub__ (self, other)
 
def __rsub__ (self, other)
 
def __mul__ (self, other)
 
def __rmul__ (self, other)
 
def __pos__ (self)
 
def __neg__ (self)
 
def __div__ (self, other)
 
def __rdiv__ (self, other)
 
def __truediv__ (self, other)
 
def __rtruediv__ (self, other)
 
def __mod__ (self, other)
 
def __rmod__ (self, other)
 
- Public Member Functions inherited from ExprRef
def as_ast (self)
 
def get_id (self)
 
def sort (self)
 
def sort_kind (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __ne__ (self, other)
 
def params (self)
 
def decl (self)
 
def num_args (self)
 
def arg (self, idx)
 
def children (self)
 
- Public Member Functions inherited from AstRef
def __init__ (self, ast, ctx=None)
 
def __del__ (self)
 
def __deepcopy__ (self, memo={})
 
def __str__ (self)
 
def __repr__ (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __nonzero__ (self)
 
def __bool__ (self)
 
def sexpr (self)
 
def as_ast (self)
 
def get_id (self)
 
def ctx_ref (self)
 
def eq (self, other)
 
def translate (self, target)
 
def __copy__ (self)
 
def hash (self)
 
- Public Member Functions inherited from Z3PPObject
def use_pp (self)
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

FP Expressions.

Floating-point expressions.

Definition at line 8687 of file z3py.py.

Member Function Documentation

◆ __add__()

def __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 8733 of file z3py.py.

8733  def __add__(self, other):
8734  """Create the Z3 expression `self + other`.
8735 
8736  >>> x = FP('x', FPSort(8, 24))
8737  >>> y = FP('y', FPSort(8, 24))
8738  >>> x + y
8739  x + y
8740  >>> (x + y).sort()
8741  FPSort(8, 24)
8742  """
8743  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8744  return fpAdd(_dflt_rm(), a, b, self.ctx)
8745 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9367

◆ __div__()

def __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 8820 of file z3py.py.

8820  def __div__(self, other):
8821  """Create the Z3 expression `self / other`.
8822 
8823  >>> x = FP('x', FPSort(8, 24))
8824  >>> y = FP('y', FPSort(8, 24))
8825  >>> x / y
8826  x / y
8827  >>> (x / y).sort()
8828  FPSort(8, 24)
8829  >>> 10 / y
8830  1.25*(2**3) / y
8831  """
8832  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8833  return fpDiv(_dflt_rm(), a, b, self.ctx)
8834 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9411

◆ __ge__()

def __ge__ (   self,
  other 
)

Definition at line 8727 of file z3py.py.

8727  def __ge__(self, other):
8728  return fpGEQ(self, other, self.ctx)
8729 
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:9565

◆ __gt__()

def __gt__ (   self,
  other 
)

Definition at line 8730 of file z3py.py.

8730  def __gt__(self, other):
8731  return fpGT(self, other, self.ctx)
8732 
def fpGT(a, b, ctx=None)
Definition: z3py.py:9554

◆ __le__()

def __le__ (   self,
  other 
)

Definition at line 8721 of file z3py.py.

8721  def __le__(self, other):
8722  return fpLEQ(self, other, self.ctx)
8723 
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:9543

◆ __lt__()

def __lt__ (   self,
  other 
)

Definition at line 8724 of file z3py.py.

8724  def __lt__(self, other):
8725  return fpLT(self, other, self.ctx)
8726 
def fpLT(a, b, ctx=None)
Definition: z3py.py:9532

◆ __mod__()

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

Definition at line 8857 of file z3py.py.

8857  def __mod__(self, other):
8858  """Create the Z3 expression mod `self % other`."""
8859  return fpRem(self, other)
8860 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9425

◆ __mul__()

def __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 8779 of file z3py.py.

8779  def __mul__(self, other):
8780  """Create the Z3 expression `self * other`.
8781 
8782  >>> x = FP('x', FPSort(8, 24))
8783  >>> y = FP('y', FPSort(8, 24))
8784  >>> x * y
8785  x * y
8786  >>> (x * y).sort()
8787  FPSort(8, 24)
8788  >>> 10 * y
8789  1.25*(2**3) * y
8790  """
8791  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8792  return fpMul(_dflt_rm(), a, b, self.ctx)
8793 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9397

◆ __neg__()

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

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

Definition at line 8811 of file z3py.py.

8811  def __neg__(self):
8812  """Create the Z3 expression `-self`.
8813 
8814  >>> x = FP('x', Float32())
8815  >>> -x
8816  -x
8817  """
8818  return fpNeg(self)
8819 
def fpNeg(a, ctx=None)
Definition: z3py.py:9300

◆ __pos__()

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

Definition at line 8807 of file z3py.py.

8807  def __pos__(self):
8808  """Create the Z3 expression `+self`."""
8809  return self
8810 

◆ __radd__()

def __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 8746 of file z3py.py.

8746  def __radd__(self, other):
8747  """Create the Z3 expression `other + self`.
8748 
8749  >>> x = FP('x', FPSort(8, 24))
8750  >>> 10 + x
8751  1.25*(2**3) + x
8752  """
8753  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8754  return fpAdd(_dflt_rm(), a, b, self.ctx)
8755 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9367

◆ __rdiv__()

def __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 8835 of file z3py.py.

8835  def __rdiv__(self, other):
8836  """Create the Z3 expression `other / self`.
8837 
8838  >>> x = FP('x', FPSort(8, 24))
8839  >>> y = FP('y', FPSort(8, 24))
8840  >>> x / y
8841  x / y
8842  >>> x / 10
8843  x / 1.25*(2**3)
8844  """
8845  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8846  return fpDiv(_dflt_rm(), a, b, self.ctx)
8847 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9411

◆ __rmod__()

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

Definition at line 8861 of file z3py.py.

8861  def __rmod__(self, other):
8862  """Create the Z3 expression mod `other % self`."""
8863  return fpRem(other, self)
8864 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9425

◆ __rmul__()

def __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 8794 of file z3py.py.

8794  def __rmul__(self, other):
8795  """Create the Z3 expression `other * self`.
8796 
8797  >>> x = FP('x', FPSort(8, 24))
8798  >>> y = FP('y', FPSort(8, 24))
8799  >>> x * y
8800  x * y
8801  >>> x * 10
8802  x * 1.25*(2**3)
8803  """
8804  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8805  return fpMul(_dflt_rm(), a, b, self.ctx)
8806 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9397

◆ __rsub__()

def __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 8769 of file z3py.py.

8769  def __rsub__(self, other):
8770  """Create the Z3 expression `other - self`.
8771 
8772  >>> x = FP('x', FPSort(8, 24))
8773  >>> 10 - x
8774  1.25*(2**3) - x
8775  """
8776  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8777  return fpSub(_dflt_rm(), a, b, self.ctx)
8778 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9383

◆ __rtruediv__()

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

Definition at line 8853 of file z3py.py.

8853  def __rtruediv__(self, other):
8854  """Create the Z3 expression division `other / self`."""
8855  return self.__rdiv__(other)
8856 

◆ __sub__()

def __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 8756 of file z3py.py.

8756  def __sub__(self, other):
8757  """Create the Z3 expression `self - other`.
8758 
8759  >>> x = FP('x', FPSort(8, 24))
8760  >>> y = FP('y', FPSort(8, 24))
8761  >>> x - y
8762  x - y
8763  >>> (x - y).sort()
8764  FPSort(8, 24)
8765  """
8766  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8767  return fpSub(_dflt_rm(), a, b, self.ctx)
8768 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9383

◆ __truediv__()

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

Definition at line 8849 of file z3py.py.

8849  def __truediv__(self, other):
8850  """Create the Z3 expression division `self / other`."""
8851  return self.__div__(other)
8852 

◆ as_string()

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

Definition at line 8717 of file z3py.py.

8717  def as_string(self):
8718  """Return a Z3 floating point expression as a Python string."""
8719  return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
8720 
Z3_string Z3_API Z3_ast_to_string(Z3_context c, Z3_ast a)
Convert the given AST node into a string.

◆ ebits()

def 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 8701 of file z3py.py.

8701  def ebits(self):
8702  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8703  >>> b = FPSort(8, 24)
8704  >>> b.ebits()
8705  8
8706  """
8707  return self.sort().ebits();
8708 

◆ sbits()

def 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 8709 of file z3py.py.

8709  def sbits(self):
8710  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8711  >>> b = FPSort(8, 24)
8712  >>> b.sbits()
8713  24
8714  """
8715  return self.sort().sbits();
8716 

◆ sort()

def 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

Definition at line 8690 of file z3py.py.

Referenced by FPRef.__add__(), FPRef.__div__(), FPRef.__mul__(), and FPRef.__sub__().

8690  def sort(self):
8691  """Return the sort of the floating-point expression `self`.
8692 
8693  >>> x = FP('1.0', FPSort(8, 24))
8694  >>> x.sort()
8695  FPSort(8, 24)
8696  >>> x.sort() == FPSort(8, 24)
8697  True
8698  """
8699  return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
8700 
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.