Z3
Public Member Functions
FPRef Class Reference
+ 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

Floating-point expressions.

Definition at line 9306 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 9352 of file z3py.py.

9352 def __add__(self, other):
9353 """Create the Z3 expression `self + other`.
9354
9355 >>> x = FP('x', FPSort(8, 24))
9356 >>> y = FP('y', FPSort(8, 24))
9357 >>> x + y
9358 x + y
9359 >>> (x + y).sort()
9360 FPSort(8, 24)
9361 """
9362 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9363 return fpAdd(_dflt_rm(), a, b, self.ctx)
9364
def fpAdd(rm, a, b, ctx=None)
Definition: z3py.py:10032
def FP(name, fpsort, ctx=None)
Definition: z3py.py:9898
def FPSort(ebits, sbits, ctx=None)
Definition: z3py.py:9727

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

9439 def __div__(self, other):
9440 """Create the Z3 expression `self / other`.
9441
9442 >>> x = FP('x', FPSort(8, 24))
9443 >>> y = FP('y', FPSort(8, 24))
9444 >>> x / y
9445 x / y
9446 >>> (x / y).sort()
9447 FPSort(8, 24)
9448 >>> 10 / y
9449 1.25*(2**3) / y
9450 """
9451 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9452 return fpDiv(_dflt_rm(), a, b, self.ctx)
9453
def fpDiv(rm, a, b, ctx=None)
Definition: z3py.py:10079

Referenced by ArithRef.__truediv__(), BitVecRef.__truediv__(), and FPRef.__truediv__().

◆ __ge__()

def __ge__ (   self,
  other 
)

Definition at line 9346 of file z3py.py.

9346 def __ge__(self, other):
9347 return fpGEQ(self, other, self.ctx)
9348
def fpGEQ(a, b, ctx=None)
Definition: z3py.py:10250

◆ __gt__()

def __gt__ (   self,
  other 
)

Definition at line 9349 of file z3py.py.

9349 def __gt__(self, other):
9350 return fpGT(self, other, self.ctx)
9351
def fpGT(a, b, ctx=None)
Definition: z3py.py:10238

◆ __le__()

def __le__ (   self,
  other 
)

Definition at line 9340 of file z3py.py.

9340 def __le__(self, other):
9341 return fpLEQ(self, other, self.ctx)
9342
def fpLEQ(a, b, ctx=None)
Definition: z3py.py:10226

◆ __lt__()

def __lt__ (   self,
  other 
)

Definition at line 9343 of file z3py.py.

9343 def __lt__(self, other):
9344 return fpLT(self, other, self.ctx)
9345
def fpLT(a, b, ctx=None)
Definition: z3py.py:10214

◆ __mod__()

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

Definition at line 9475 of file z3py.py.

9475 def __mod__(self, other):
9476 """Create the Z3 expression mod `self % other`."""
9477 return fpRem(self, other)
9478
def fpRem(a, b, ctx=None)
Definition: z3py.py:10094

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

9398 def __mul__(self, other):
9399 """Create the Z3 expression `self * other`.
9400
9401 >>> x = FP('x', FPSort(8, 24))
9402 >>> y = FP('y', FPSort(8, 24))
9403 >>> x * y
9404 x * y
9405 >>> (x * y).sort()
9406 FPSort(8, 24)
9407 >>> 10 * y
9408 1.25*(2**3) * y
9409 """
9410 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9411 return fpMul(_dflt_rm(), a, b, self.ctx)
9412
def fpMul(rm, a, b, ctx=None)
Definition: z3py.py:10064

◆ __neg__()

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

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

Definition at line 9430 of file z3py.py.

9430 def __neg__(self):
9431 """Create the Z3 expression `-self`.
9432
9433 >>> x = FP('x', Float32())
9434 >>> -x
9435 -x
9436 """
9437 return fpNeg(self)
9438
def Float32(ctx=None)
Definition: z3py.py:9242
def fpNeg(a, ctx=None)
Definition: z3py.py:9964

◆ __pos__()

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

Definition at line 9426 of file z3py.py.

9426 def __pos__(self):
9427 """Create the Z3 expression `+self`."""
9428 return self
9429

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

9365 def __radd__(self, other):
9366 """Create the Z3 expression `other + self`.
9367
9368 >>> x = FP('x', FPSort(8, 24))
9369 >>> 10 + x
9370 1.25*(2**3) + x
9371 """
9372 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9373 return fpAdd(_dflt_rm(), a, b, self.ctx)
9374

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

9454 def __rdiv__(self, other):
9455 """Create the Z3 expression `other / self`.
9456
9457 >>> x = FP('x', FPSort(8, 24))
9458 >>> y = FP('y', FPSort(8, 24))
9459 >>> x / y
9460 x / y
9461 >>> x / 10
9462 x / 1.25*(2**3)
9463 """
9464 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9465 return fpDiv(_dflt_rm(), a, b, self.ctx)
9466

Referenced by ArithRef.__rtruediv__(), BitVecRef.__rtruediv__(), and FPRef.__rtruediv__().

◆ __rmod__()

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

Definition at line 9479 of file z3py.py.

9479 def __rmod__(self, other):
9480 """Create the Z3 expression mod `other % self`."""
9481 return fpRem(other, self)
9482
9483

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

9413 def __rmul__(self, other):
9414 """Create the Z3 expression `other * self`.
9415
9416 >>> x = FP('x', FPSort(8, 24))
9417 >>> y = FP('y', FPSort(8, 24))
9418 >>> x * y
9419 x * y
9420 >>> x * 10
9421 x * 1.25*(2**3)
9422 """
9423 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9424 return fpMul(_dflt_rm(), a, b, self.ctx)
9425

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

9388 def __rsub__(self, other):
9389 """Create the Z3 expression `other - self`.
9390
9391 >>> x = FP('x', FPSort(8, 24))
9392 >>> 10 - x
9393 1.25*(2**3) - x
9394 """
9395 [a, b] = _coerce_fp_expr_list([other, self], self.ctx)
9396 return fpSub(_dflt_rm(), a, b, self.ctx)
9397
def fpSub(rm, a, b, ctx=None)
Definition: z3py.py:10049

◆ __rtruediv__()

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

Definition at line 9471 of file z3py.py.

9471 def __rtruediv__(self, other):
9472 """Create the Z3 expression division `other / self`."""
9473 return self.__rdiv__(other)
9474

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

9375 def __sub__(self, other):
9376 """Create the Z3 expression `self - other`.
9377
9378 >>> x = FP('x', FPSort(8, 24))
9379 >>> y = FP('y', FPSort(8, 24))
9380 >>> x - y
9381 x - y
9382 >>> (x - y).sort()
9383 FPSort(8, 24)
9384 """
9385 [a, b] = _coerce_fp_expr_list([self, other], self.ctx)
9386 return fpSub(_dflt_rm(), a, b, self.ctx)
9387

◆ __truediv__()

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

Definition at line 9467 of file z3py.py.

9467 def __truediv__(self, other):
9468 """Create the Z3 expression division `self / other`."""
9469 return self.__div__(other)
9470

◆ as_string()

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

Reimplemented in FPNumRef.

Definition at line 9336 of file z3py.py.

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

Referenced by IntNumRef.as_long(), BitVecNumRef.as_long(), and FiniteDomainNumRef.as_long().

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

9320 def ebits(self):
9321 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9322 >>> b = FPSort(8, 24)
9323 >>> b.ebits()
9324 8
9325 """
9326 return self.sort().ebits()
9327

Referenced by FPRef.ebits().

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

9328 def sbits(self):
9329 """Retrieves the number of bits reserved for the exponent in the FloatingPoint expression `self`.
9330 >>> b = FPSort(8, 24)
9331 >>> b.sbits()
9332 24
9333 """
9334 return self.sort().sbits()
9335

Referenced by FPRef.sbits().

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

9309 def sort(self):
9310 """Return the sort of the floating-point expression `self`.
9311
9312 >>> x = FP('1.0', FPSort(8, 24))
9313 >>> x.sort()
9314 FPSort(8, 24)
9315 >>> x.sort() == FPSort(8, 24)
9316 True
9317 """
9318 return FPSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
9319
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.

Referenced by FPRef.__add__(), FPRef.__div__(), QuantifierRef.__getitem__(), FPRef.__mul__(), FPRef.__sub__(), FPNumRef.as_string(), ArrayRef.domain(), FPRef.ebits(), ArithRef.is_int(), ArithRef.is_real(), ArrayRef.range(), FPRef.sbits(), BitVecRef.size(), and ExprRef.sort_kind().