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

8802  def __add__(self, other):
8803  """Create the Z3 expression `self + other`.
8804 
8805  >>> x = FP('x', FPSort(8, 24))
8806  >>> y = FP('y', FPSort(8, 24))
8807  >>> x + y
8808  x + y
8809  >>> (x + y).sort()
8810  FPSort(8, 24)
8811  """
8812  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8813  return fpAdd(_dflt_rm(), a, b, self.ctx)
8814 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9436

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

8889  def __div__(self, other):
8890  """Create the Z3 expression `self / other`.
8891 
8892  >>> x = FP('x', FPSort(8, 24))
8893  >>> y = FP('y', FPSort(8, 24))
8894  >>> x / y
8895  x / y
8896  >>> (x / y).sort()
8897  FPSort(8, 24)
8898  >>> 10 / y
8899  1.25*(2**3) / y
8900  """
8901  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8902  return fpDiv(_dflt_rm(), a, b, self.ctx)
8903 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9480

◆ __ge__()

def __ge__ (   self,
  other 
)

Definition at line 8796 of file z3py.py.

8796  def __ge__(self, other):
8797  return fpGEQ(self, other, self.ctx)
8798 
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:9634

◆ __gt__()

def __gt__ (   self,
  other 
)

Definition at line 8799 of file z3py.py.

8799  def __gt__(self, other):
8800  return fpGT(self, other, self.ctx)
8801 
def fpGT(a, b, ctx=None)
Definition: z3py.py:9623

◆ __le__()

def __le__ (   self,
  other 
)

Definition at line 8790 of file z3py.py.

8790  def __le__(self, other):
8791  return fpLEQ(self, other, self.ctx)
8792 
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:9612

◆ __lt__()

def __lt__ (   self,
  other 
)

Definition at line 8793 of file z3py.py.

8793  def __lt__(self, other):
8794  return fpLT(self, other, self.ctx)
8795 
def fpLT(a, b, ctx=None)
Definition: z3py.py:9601

◆ __mod__()

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

Definition at line 8926 of file z3py.py.

8926  def __mod__(self, other):
8927  """Create the Z3 expression mod `self % other`."""
8928  return fpRem(self, other)
8929 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9494

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

8848  def __mul__(self, other):
8849  """Create the Z3 expression `self * other`.
8850 
8851  >>> x = FP('x', FPSort(8, 24))
8852  >>> y = FP('y', FPSort(8, 24))
8853  >>> x * y
8854  x * y
8855  >>> (x * y).sort()
8856  FPSort(8, 24)
8857  >>> 10 * y
8858  1.25*(2**3) * y
8859  """
8860  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8861  return fpMul(_dflt_rm(), a, b, self.ctx)
8862 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9466

◆ __neg__()

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

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

Definition at line 8880 of file z3py.py.

8880  def __neg__(self):
8881  """Create the Z3 expression `-self`.
8882 
8883  >>> x = FP('x', Float32())
8884  >>> -x
8885  -x
8886  """
8887  return fpNeg(self)
8888 
def fpNeg(a, ctx=None)
Definition: z3py.py:9369

◆ __pos__()

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

Definition at line 8876 of file z3py.py.

8876  def __pos__(self):
8877  """Create the Z3 expression `+self`."""
8878  return self
8879 

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

8815  def __radd__(self, other):
8816  """Create the Z3 expression `other + self`.
8817 
8818  >>> x = FP('x', FPSort(8, 24))
8819  >>> 10 + x
8820  1.25*(2**3) + x
8821  """
8822  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8823  return fpAdd(_dflt_rm(), a, b, self.ctx)
8824 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9436

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

8904  def __rdiv__(self, other):
8905  """Create the Z3 expression `other / self`.
8906 
8907  >>> x = FP('x', FPSort(8, 24))
8908  >>> y = FP('y', FPSort(8, 24))
8909  >>> x / y
8910  x / y
8911  >>> x / 10
8912  x / 1.25*(2**3)
8913  """
8914  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8915  return fpDiv(_dflt_rm(), a, b, self.ctx)
8916 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9480

◆ __rmod__()

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

Definition at line 8930 of file z3py.py.

8930  def __rmod__(self, other):
8931  """Create the Z3 expression mod `other % self`."""
8932  return fpRem(other, self)
8933 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9494

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

8863  def __rmul__(self, other):
8864  """Create the Z3 expression `other * self`.
8865 
8866  >>> x = FP('x', FPSort(8, 24))
8867  >>> y = FP('y', FPSort(8, 24))
8868  >>> x * y
8869  x * y
8870  >>> x * 10
8871  x * 1.25*(2**3)
8872  """
8873  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8874  return fpMul(_dflt_rm(), a, b, self.ctx)
8875 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9466

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

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

◆ __rtruediv__()

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

Definition at line 8922 of file z3py.py.

8922  def __rtruediv__(self, other):
8923  """Create the Z3 expression division `other / self`."""
8924  return self.__rdiv__(other)
8925 

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

8825  def __sub__(self, other):
8826  """Create the Z3 expression `self - other`.
8827 
8828  >>> x = FP('x', FPSort(8, 24))
8829  >>> y = FP('y', FPSort(8, 24))
8830  >>> x - y
8831  x - y
8832  >>> (x - y).sort()
8833  FPSort(8, 24)
8834  """
8835  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8836  return fpSub(_dflt_rm(), a, b, self.ctx)
8837 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9452

◆ __truediv__()

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

Definition at line 8918 of file z3py.py.

8918  def __truediv__(self, other):
8919  """Create the Z3 expression division `self / other`."""
8920  return self.__div__(other)
8921 

◆ as_string()

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

Definition at line 8786 of file z3py.py.

8786  def as_string(self):
8787  """Return a Z3 floating point expression as a Python string."""
8788  return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
8789 
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 8770 of file z3py.py.

8770  def ebits(self):
8771  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8772  >>> b = FPSort(8, 24)
8773  >>> b.ebits()
8774  8
8775  """
8776  return self.sort().ebits();
8777 

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

8778  def sbits(self):
8779  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8780  >>> b = FPSort(8, 24)
8781  >>> b.sbits()
8782  24
8783  """
8784  return self.sort().sbits();
8785 

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

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

8759  def sort(self):
8760  """Return the sort of the floating-point expression `self`.
8761 
8762  >>> x = FP('1.0', FPSort(8, 24))
8763  >>> x.sort()
8764  FPSort(8, 24)
8765  >>> x.sort() == FPSort(8, 24)
8766  True
8767  """
8768  return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
8769 
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.