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 8547 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 8593 of file z3py.py.

8593  def __add__(self, other):
8594  """Create the Z3 expression `self + other`.
8595 
8596  >>> x = FP('x', FPSort(8, 24))
8597  >>> y = FP('y', FPSort(8, 24))
8598  >>> x + y
8599  x + y
8600  >>> (x + y).sort()
8601  FPSort(8, 24)
8602  """
8603  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8604  return fpAdd(_dflt_rm(), a, b, self.ctx)
8605 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9224

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

8680  def __div__(self, other):
8681  """Create the Z3 expression `self / other`.
8682 
8683  >>> x = FP('x', FPSort(8, 24))
8684  >>> y = FP('y', FPSort(8, 24))
8685  >>> x / y
8686  x / y
8687  >>> (x / y).sort()
8688  FPSort(8, 24)
8689  >>> 10 / y
8690  1.25*(2**3) / y
8691  """
8692  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8693  return fpDiv(_dflt_rm(), a, b, self.ctx)
8694 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9268

◆ __ge__()

def __ge__ (   self,
  other 
)

Definition at line 8587 of file z3py.py.

8587  def __ge__(self, other):
8588  return fpGEQ(self, other, self.ctx)
8589 
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:9422

◆ __gt__()

def __gt__ (   self,
  other 
)

Definition at line 8590 of file z3py.py.

8590  def __gt__(self, other):
8591  return fpGT(self, other, self.ctx)
8592 
def fpGT(a, b, ctx=None)
Definition: z3py.py:9411

◆ __le__()

def __le__ (   self,
  other 
)

Definition at line 8581 of file z3py.py.

8581  def __le__(self, other):
8582  return fpLEQ(self, other, self.ctx)
8583 
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:9400

◆ __lt__()

def __lt__ (   self,
  other 
)

Definition at line 8584 of file z3py.py.

8584  def __lt__(self, other):
8585  return fpLT(self, other, self.ctx)
8586 
def fpLT(a, b, ctx=None)
Definition: z3py.py:9389

◆ __mod__()

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

Definition at line 8717 of file z3py.py.

8717  def __mod__(self, other):
8718  """Create the Z3 expression mod `self % other`."""
8719  return fpRem(self, other)
8720 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9282

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

8639  def __mul__(self, other):
8640  """Create the Z3 expression `self * other`.
8641 
8642  >>> x = FP('x', FPSort(8, 24))
8643  >>> y = FP('y', FPSort(8, 24))
8644  >>> x * y
8645  x * y
8646  >>> (x * y).sort()
8647  FPSort(8, 24)
8648  >>> 10 * y
8649  1.25*(2**3) * y
8650  """
8651  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8652  return fpMul(_dflt_rm(), a, b, self.ctx)
8653 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9254

◆ __neg__()

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

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

Definition at line 8671 of file z3py.py.

8671  def __neg__(self):
8672  """Create the Z3 expression `-self`.
8673 
8674  >>> x = FP('x', Float32())
8675  >>> -x
8676  -x
8677  """
8678  return fpNeg(self)
8679 
def fpNeg(a, ctx=None)
Definition: z3py.py:9157

◆ __pos__()

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

Definition at line 8667 of file z3py.py.

8667  def __pos__(self):
8668  """Create the Z3 expression `+self`."""
8669  return self
8670 

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

8606  def __radd__(self, other):
8607  """Create the Z3 expression `other + self`.
8608 
8609  >>> x = FP('x', FPSort(8, 24))
8610  >>> 10 + x
8611  1.25*(2**3) + x
8612  """
8613  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8614  return fpAdd(_dflt_rm(), a, b, self.ctx)
8615 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:9224

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

8695  def __rdiv__(self, other):
8696  """Create the Z3 expression `other / self`.
8697 
8698  >>> x = FP('x', FPSort(8, 24))
8699  >>> y = FP('y', FPSort(8, 24))
8700  >>> x / y
8701  x / y
8702  >>> x / 10
8703  x / 1.25*(2**3)
8704  """
8705  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8706  return fpDiv(_dflt_rm(), a, b, self.ctx)
8707 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:9268

◆ __rmod__()

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

Definition at line 8721 of file z3py.py.

8721  def __rmod__(self, other):
8722  """Create the Z3 expression mod `other % self`."""
8723  return fpRem(other, self)
8724 
def fpRem(a, b, ctx=None)
Definition: z3py.py:9282

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

8654  def __rmul__(self, other):
8655  """Create the Z3 expression `other * self`.
8656 
8657  >>> x = FP('x', FPSort(8, 24))
8658  >>> y = FP('y', FPSort(8, 24))
8659  >>> x * y
8660  x * y
8661  >>> x * 10
8662  x * 1.25*(2**3)
8663  """
8664  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8665  return fpMul(_dflt_rm(), a, b, self.ctx)
8666 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:9254

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

8629  def __rsub__(self, other):
8630  """Create the Z3 expression `other - self`.
8631 
8632  >>> x = FP('x', FPSort(8, 24))
8633  >>> 10 - x
8634  1.25*(2**3) - x
8635  """
8636  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8637  return fpSub(_dflt_rm(), a, b, self.ctx)
8638 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9240

◆ __rtruediv__()

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

Definition at line 8713 of file z3py.py.

8713  def __rtruediv__(self, other):
8714  """Create the Z3 expression division `other / self`."""
8715  return self.__rdiv__(other)
8716 

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

8616  def __sub__(self, other):
8617  """Create the Z3 expression `self - other`.
8618 
8619  >>> x = FP('x', FPSort(8, 24))
8620  >>> y = FP('y', FPSort(8, 24))
8621  >>> x - y
8622  x - y
8623  >>> (x - y).sort()
8624  FPSort(8, 24)
8625  """
8626  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8627  return fpSub(_dflt_rm(), a, b, self.ctx)
8628 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:9240

◆ __truediv__()

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

Definition at line 8709 of file z3py.py.

8709  def __truediv__(self, other):
8710  """Create the Z3 expression division `self / other`."""
8711  return self.__div__(other)
8712 

◆ as_string()

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

Definition at line 8577 of file z3py.py.

8577  def as_string(self):
8578  """Return a Z3 floating point expression as a Python string."""
8579  return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
8580 
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 8561 of file z3py.py.

8561  def ebits(self):
8562  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8563  >>> b = FPSort(8, 24)
8564  >>> b.ebits()
8565  8
8566  """
8567  return self.sort().ebits();
8568 

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

8569  def sbits(self):
8570  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8571  >>> b = FPSort(8, 24)
8572  >>> b.sbits()
8573  24
8574  """
8575  return self.sort().sbits();
8576 

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

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

8550  def sort(self):
8551  """Return the sort of the floating-point expression `self`.
8552 
8553  >>> x = FP('1.0', FPSort(8, 24))
8554  >>> x.sort()
8555  FPSort(8, 24)
8556  >>> x.sort() == FPSort(8, 24)
8557  True
8558  """
8559  return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
8560 
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.