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_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 __nonzero__ (self)
 
def __bool__ (self)
 
def sexpr (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 8797 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 8843 of file z3py.py.

8843  def __add__(self, other):
8844  """Create the Z3 expression `self + other`.
8845 
8846  >>> x = FP('x', FPSort(8, 24))
8847  >>> y = FP('y', FPSort(8, 24))
8848  >>> x + y
8849  x + y
8850  >>> (x + y).sort()
8851  FPSort(8, 24)
8852  """
8853  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8854  return fpAdd(_dflt_rm(), a, b, self.ctx)
8855 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9469

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

8930  def __div__(self, other):
8931  """Create the Z3 expression `self / other`.
8932 
8933  >>> x = FP('x', FPSort(8, 24))
8934  >>> y = FP('y', FPSort(8, 24))
8935  >>> x / y
8936  x / y
8937  >>> (x / y).sort()
8938  FPSort(8, 24)
8939  >>> 10 / y
8940  1.25*(2**3) / y
8941  """
8942  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8943  return fpDiv(_dflt_rm(), a, b, self.ctx)
8944 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9513

Referenced by FPRef.__truediv__().

◆ __ge__()

def __ge__ (   self,
  other 
)

Definition at line 8837 of file z3py.py.

8837  def __ge__(self, other):
8838  return fpGEQ(self, other, self.ctx)
8839 
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:9666

◆ __gt__()

def __gt__ (   self,
  other 
)

Definition at line 8840 of file z3py.py.

8840  def __gt__(self, other):
8841  return fpGT(self, other, self.ctx)
8842 
def fpGT(a, b, ctx=None)
Definition: z3py.py:9655

◆ __le__()

def __le__ (   self,
  other 
)

Definition at line 8831 of file z3py.py.

8831  def __le__(self, other):
8832  return fpLEQ(self, other, self.ctx)
8833 
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:9644

◆ __lt__()

def __lt__ (   self,
  other 
)

Definition at line 8834 of file z3py.py.

8834  def __lt__(self, other):
8835  return fpLT(self, other, self.ctx)
8836 
def fpLT(a, b, ctx=None)
Definition: z3py.py:9633

◆ __mod__()

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

Definition at line 8966 of file z3py.py.

8966  def __mod__(self, other):
8967  """Create the Z3 expression mod `self % other`."""
8968  return fpRem(self, other)
8969 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9527

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

8889  def __mul__(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 fpMul(_dflt_rm(), a, b, self.ctx)
8903 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9499

◆ __neg__()

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

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

Definition at line 8921 of file z3py.py.

8921  def __neg__(self):
8922  """Create the Z3 expression `-self`.
8923 
8924  >>> x = FP('x', Float32())
8925  >>> -x
8926  -x
8927  """
8928  return fpNeg(self)
8929 
def fpNeg(a, ctx=None)
Definition: z3py.py:9409

◆ __pos__()

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

Definition at line 8917 of file z3py.py.

8917  def __pos__(self):
8918  """Create the Z3 expression `+self`."""
8919  return self
8920 

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

8856  def __radd__(self, other):
8857  """Create the Z3 expression `other + self`.
8858 
8859  >>> x = FP('x', FPSort(8, 24))
8860  >>> 10 + x
8861  1.25*(2**3) + x
8862  """
8863  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8864  return fpAdd(_dflt_rm(), a, b, self.ctx)
8865 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9469

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

8945  def __rdiv__(self, other):
8946  """Create the Z3 expression `other / self`.
8947 
8948  >>> x = FP('x', FPSort(8, 24))
8949  >>> y = FP('y', FPSort(8, 24))
8950  >>> x / y
8951  x / y
8952  >>> x / 10
8953  x / 1.25*(2**3)
8954  """
8955  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8956  return fpDiv(_dflt_rm(), a, b, self.ctx)
8957 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9513

Referenced by FPRef.__rtruediv__().

◆ __rmod__()

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

Definition at line 8970 of file z3py.py.

8970  def __rmod__(self, other):
8971  """Create the Z3 expression mod `other % self`."""
8972  return fpRem(other, self)
8973 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9527

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

8904  def __rmul__(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 fpMul(_dflt_rm(), a, b, self.ctx)
8916 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9499

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

8879  def __rsub__(self, other):
8880  """Create the Z3 expression `other - self`.
8881 
8882  >>> x = FP('x', FPSort(8, 24))
8883  >>> 10 - x
8884  1.25*(2**3) - x
8885  """
8886  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8887  return fpSub(_dflt_rm(), a, b, self.ctx)
8888 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9485

◆ __rtruediv__()

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

Definition at line 8962 of file z3py.py.

8962  def __rtruediv__(self, other):
8963  """Create the Z3 expression division `other / self`."""
8964  return self.__rdiv__(other)
8965 

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

8866  def __sub__(self, other):
8867  """Create the Z3 expression `self - other`.
8868 
8869  >>> x = FP('x', FPSort(8, 24))
8870  >>> y = FP('y', FPSort(8, 24))
8871  >>> x - y
8872  x - y
8873  >>> (x - y).sort()
8874  FPSort(8, 24)
8875  """
8876  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8877  return fpSub(_dflt_rm(), a, b, self.ctx)
8878 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9485

◆ __truediv__()

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

Definition at line 8958 of file z3py.py.

8958  def __truediv__(self, other):
8959  """Create the Z3 expression division `self / other`."""
8960  return self.__div__(other)
8961 

◆ as_string()

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

Reimplemented in FPNumRef.

Definition at line 8827 of file z3py.py.

8827  def as_string(self):
8828  """Return a Z3 floating point expression as a Python string."""
8829  return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
8830 
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 8811 of file z3py.py.

8811  def ebits(self):
8812  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8813  >>> b = FPSort(8, 24)
8814  >>> b.ebits()
8815  8
8816  """
8817  return self.sort().ebits();
8818 

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

8819  def sbits(self):
8820  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8821  >>> b = FPSort(8, 24)
8822  >>> b.sbits()
8823  24
8824  """
8825  return self.sort().sbits();
8826 

◆ 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

Reimplemented from ExprRef.

Definition at line 8800 of file z3py.py.

8800  def sort(self):
8801  """Return the sort of the floating-point expression `self`.
8802 
8803  >>> x = FP('1.0', FPSort(8, 24))
8804  >>> x.sort()
8805  FPSort(8, 24)
8806  >>> x.sort() == FPSort(8, 24)
8807  True
8808  """
8809  return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
8810 
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.