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 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 __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 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 8211 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 8257 of file z3py.py.

8257  def __add__(self, other):
8258  """Create the Z3 expression `self + other`.
8259 
8260  >>> x = FP('x', FPSort(8, 24))
8261  >>> y = FP('y', FPSort(8, 24))
8262  >>> x + y
8263  x + y
8264  >>> (x + y).sort()
8265  FPSort(8, 24)
8266  """
8267  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8268  return fpAdd(_dflt_rm(), a, b, self.ctx)
8269 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:8847

§ __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 8344 of file z3py.py.

8344  def __div__(self, other):
8345  """Create the Z3 expression `self / other`.
8346 
8347  >>> x = FP('x', FPSort(8, 24))
8348  >>> y = FP('y', FPSort(8, 24))
8349  >>> x / y
8350  x / y
8351  >>> (x / y).sort()
8352  FPSort(8, 24)
8353  >>> 10 / y
8354  1.25*(2**3) / y
8355  """
8356  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8357  return fpDiv(_dflt_rm(), a, b, self.ctx)
8358 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:8891

§ __ge__()

def __ge__ (   self,
  other 
)

Definition at line 8251 of file z3py.py.

8251  def __ge__(self, other):
8252  return fpGEQ(self, other, self.ctx)
8253 
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:9045

§ __gt__()

def __gt__ (   self,
  other 
)

Definition at line 8254 of file z3py.py.

8254  def __gt__(self, other):
8255  return fpGT(self, other, self.ctx)
8256 
def fpGT(a, b, ctx=None)
Definition: z3py.py:9034

§ __le__()

def __le__ (   self,
  other 
)

Definition at line 8245 of file z3py.py.

8245  def __le__(self, other):
8246  return fpLEQ(self, other, self.ctx)
8247 
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:9023

§ __lt__()

def __lt__ (   self,
  other 
)

Definition at line 8248 of file z3py.py.

8248  def __lt__(self, other):
8249  return fpLT(self, other, self.ctx)
8250 
def fpLT(a, b, ctx=None)
Definition: z3py.py:9012

§ __mod__()

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

Definition at line 8381 of file z3py.py.

8381  def __mod__(self, other):
8382  """Create the Z3 expression mod `self % other`."""
8383  return fpRem(self, other)
8384 
def fpRem(a, b, ctx=None)
Definition: z3py.py:8905

§ __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 8303 of file z3py.py.

8303  def __mul__(self, other):
8304  """Create the Z3 expression `self * other`.
8305 
8306  >>> x = FP('x', FPSort(8, 24))
8307  >>> y = FP('y', FPSort(8, 24))
8308  >>> x * y
8309  x * y
8310  >>> (x * y).sort()
8311  FPSort(8, 24)
8312  >>> 10 * y
8313  1.25*(2**3) * y
8314  """
8315  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8316  return fpMul(_dflt_rm(), a, b, self.ctx)
8317 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:8877

§ __neg__()

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

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

Definition at line 8335 of file z3py.py.

8335  def __neg__(self):
8336  """Create the Z3 expression `-self`.
8337 
8338  >>> x = FP('x', Float32())
8339  >>> -x
8340  -x
8341  """
8342  return fpNeg(self)
8343 
def fpNeg(a, ctx=None)
Definition: z3py.py:8780

§ __pos__()

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

Definition at line 8331 of file z3py.py.

8331  def __pos__(self):
8332  """Create the Z3 expression `+self`."""
8333  return self
8334 

§ __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 8270 of file z3py.py.

8270  def __radd__(self, other):
8271  """Create the Z3 expression `other + self`.
8272 
8273  >>> x = FP('x', FPSort(8, 24))
8274  >>> 10 + x
8275  1.25*(2**3) + x
8276  """
8277  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8278  return fpAdd(_dflt_rm(), a, b, self.ctx)
8279 
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:8847

§ __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 8359 of file z3py.py.

8359  def __rdiv__(self, other):
8360  """Create the Z3 expression `other / self`.
8361 
8362  >>> x = FP('x', FPSort(8, 24))
8363  >>> y = FP('y', FPSort(8, 24))
8364  >>> x / y
8365  x / y
8366  >>> x / 10
8367  x / 1.25*(2**3)
8368  """
8369  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8370  return fpDiv(_dflt_rm(), a, b, self.ctx)
8371 
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:8891

§ __rmod__()

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

Definition at line 8385 of file z3py.py.

8385  def __rmod__(self, other):
8386  """Create the Z3 expression mod `other % self`."""
8387  return fpRem(other, self)
8388 
def fpRem(a, b, ctx=None)
Definition: z3py.py:8905

§ __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 8318 of file z3py.py.

8318  def __rmul__(self, other):
8319  """Create the Z3 expression `other * self`.
8320 
8321  >>> x = FP('x', FPSort(8, 24))
8322  >>> y = FP('y', FPSort(8, 24))
8323  >>> x * y
8324  x * y
8325  >>> x * 10
8326  x * 1.25*(2**3)
8327  """
8328  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8329  return fpMul(_dflt_rm(), a, b, self.ctx)
8330 
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:8877

§ __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 8293 of file z3py.py.

8293  def __rsub__(self, other):
8294  """Create the Z3 expression `other - self`.
8295 
8296  >>> x = FP('x', FPSort(8, 24))
8297  >>> 10 - x
8298  1.25*(2**3) - x
8299  """
8300  [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
8301  return fpSub(_dflt_rm(), a, b, self.ctx)
8302 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:8863

§ __rtruediv__()

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

Definition at line 8377 of file z3py.py.

8377  def __rtruediv__(self, other):
8378  """Create the Z3 expression division `other / self`."""
8379  return self.__rdiv__(other)
8380 

§ __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 8280 of file z3py.py.

8280  def __sub__(self, other):
8281  """Create the Z3 expression `self - other`.
8282 
8283  >>> x = FP('x', FPSort(8, 24))
8284  >>> y = FP('y', FPSort(8, 24))
8285  >>> x - y
8286  x - y
8287  >>> (x - y).sort()
8288  FPSort(8, 24)
8289  """
8290  [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
8291  return fpSub(_dflt_rm(), a, b, self.ctx)
8292 
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:8863

§ __truediv__()

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

Definition at line 8373 of file z3py.py.

8373  def __truediv__(self, other):
8374  """Create the Z3 expression division `self / other`."""
8375  return self.__div__(other)
8376 

§ as_string()

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

Definition at line 8241 of file z3py.py.

8241  def as_string(self):
8242  """Return a Z3 floating point expression as a Python string."""
8243  return Z3_ast_to_string(self.ctx_ref(), self.as_ast())
8244 
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 8225 of file z3py.py.

8225  def ebits(self):
8226  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8227  >>> b = FPSort(8, 24)
8228  >>> b.ebits()
8229  8
8230  """
8231  return self.sort().ebits();
8232 

§ 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 8233 of file z3py.py.

8233  def sbits(self):
8234  """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
8235  >>> b = FPSort(8, 24)
8236  >>> b.sbits()
8237  24
8238  """
8239  return self.sort().sbits();
8240 

§ 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 8214 of file z3py.py.

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

8214  def sort(self):
8215  """Return the sort of the floating-point expression `self`.
8216 
8217  >>> x = FP('1.0', FPSort(8, 24))
8218  >>> x.sort()
8219  FPSort(8, 24)
8220  >>> x.sort() == FPSort(8, 24)
8221  True
8222  """
8223  return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
8224