Z3
Public Member Functions
BitVecRef Class Reference
+ Inheritance diagram for BitVecRef:

Public Member Functions

def sort (self)
 
def size (self)
 
def __add__ (self, other)
 
def __radd__ (self, other)
 
def __mul__ (self, other)
 
def __rmul__ (self, other)
 
def __sub__ (self, other)
 
def __rsub__ (self, other)
 
def __or__ (self, other)
 
def __ror__ (self, other)
 
def __and__ (self, other)
 
def __rand__ (self, other)
 
def __xor__ (self, other)
 
def __rxor__ (self, other)
 
def __pos__ (self)
 
def __neg__ (self)
 
def __invert__ (self)
 
def __div__ (self, other)
 
def __truediv__ (self, other)
 
def __rdiv__ (self, other)
 
def __rtruediv__ (self, other)
 
def __mod__ (self, other)
 
def __rmod__ (self, other)
 
def __le__ (self, other)
 
def __lt__ (self, other)
 
def __gt__ (self, other)
 
def __ge__ (self, other)
 
def __rshift__ (self, other)
 
def __lshift__ (self, other)
 
def __rrshift__ (self, other)
 
def __rlshift__ (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

Bit-vector expressions.

Definition at line 3269 of file z3py.py.

Member Function Documentation

◆ __add__()

def __add__ (   self,
  other 
)
Create the Z3 expression `self + other`.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> x + y
x + y
>>> (x + y).sort()
BitVec(32)

Definition at line 3294 of file z3py.py.

3294  def __add__(self, other):
3295  """Create the Z3 expression `self + other`.
3296 
3297  >>> x = BitVec('x', 32)
3298  >>> y = BitVec('y', 32)
3299  >>> x + y
3300  x + y
3301  >>> (x + y).sort()
3302  BitVec(32)
3303  """
3304  a, b = _coerce_exprs(self, other)
3305  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3306 

◆ __and__()

def __and__ (   self,
  other 
)
Create the Z3 expression bitwise-and `self & other`.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> x & y
x & y
>>> (x & y).sort()
BitVec(32)

Definition at line 3386 of file z3py.py.

3386  def __and__(self, other):
3387  """Create the Z3 expression bitwise-and `self & other`.
3388 
3389  >>> x = BitVec('x', 32)
3390  >>> y = BitVec('y', 32)
3391  >>> x & y
3392  x & y
3393  >>> (x & y).sort()
3394  BitVec(32)
3395  """
3396  a, b = _coerce_exprs(self, other)
3397  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3398 

◆ __div__()

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

Use the function UDiv() for unsigned division.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> x / y
x/y
>>> (x / y).sort()
BitVec(32)
>>> (x / y).sexpr()
'(bvsdiv x y)'
>>> UDiv(x, y).sexpr()
'(bvudiv x y)'

Definition at line 3463 of file z3py.py.

3463  def __div__(self, other):
3464  """Create the Z3 expression (signed) division `self / other`.
3465 
3466  Use the function UDiv() for unsigned division.
3467 
3468  >>> x = BitVec('x', 32)
3469  >>> y = BitVec('y', 32)
3470  >>> x / y
3471  x/y
3472  >>> (x / y).sort()
3473  BitVec(32)
3474  >>> (x / y).sexpr()
3475  '(bvsdiv x y)'
3476  >>> UDiv(x, y).sexpr()
3477  '(bvudiv x y)'
3478  """
3479  a, b = _coerce_exprs(self, other)
3480  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3481 

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

◆ __ge__()

def __ge__ (   self,
  other 
)
Create the Z3 expression (signed) `other >= self`.

Use the function UGE() for unsigned greater than or equal to.

>>> x, y = BitVecs('x y', 32)
>>> x >= y
x >= y
>>> (x >= y).sexpr()
'(bvsge x y)'
>>> UGE(x, y).sexpr()
'(bvuge x y)'

Definition at line 3593 of file z3py.py.

3593  def __ge__(self, other):
3594  """Create the Z3 expression (signed) `other >= self`.
3595 
3596  Use the function UGE() for unsigned greater than or equal to.
3597 
3598  >>> x, y = BitVecs('x y', 32)
3599  >>> x >= y
3600  x >= y
3601  >>> (x >= y).sexpr()
3602  '(bvsge x y)'
3603  >>> UGE(x, y).sexpr()
3604  '(bvuge x y)'
3605  """
3606  a, b = _coerce_exprs(self, other)
3607  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3608 

◆ __gt__()

def __gt__ (   self,
  other 
)
Create the Z3 expression (signed) `other > self`.

Use the function UGT() for unsigned greater than.

>>> x, y = BitVecs('x y', 32)
>>> x > y
x > y
>>> (x > y).sexpr()
'(bvsgt x y)'
>>> UGT(x, y).sexpr()
'(bvugt x y)'

Definition at line 3577 of file z3py.py.

3577  def __gt__(self, other):
3578  """Create the Z3 expression (signed) `other > self`.
3579 
3580  Use the function UGT() for unsigned greater than.
3581 
3582  >>> x, y = BitVecs('x y', 32)
3583  >>> x > y
3584  x > y
3585  >>> (x > y).sexpr()
3586  '(bvsgt x y)'
3587  >>> UGT(x, y).sexpr()
3588  '(bvugt x y)'
3589  """
3590  a, b = _coerce_exprs(self, other)
3591  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3592 

◆ __invert__()

def __invert__ (   self)
Create the Z3 expression bitwise-not `~self`.

>>> x = BitVec('x', 32)
>>> ~x
~x
>>> simplify(~(~x))
x

Definition at line 3452 of file z3py.py.

3452  def __invert__(self):
3453  """Create the Z3 expression bitwise-not `~self`.
3454 
3455  >>> x = BitVec('x', 32)
3456  >>> ~x
3457  ~x
3458  >>> simplify(~(~x))
3459  x
3460  """
3461  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3462 

◆ __le__()

def __le__ (   self,
  other 
)
Create the Z3 expression (signed) `other <= self`.

Use the function ULE() for unsigned less than or equal to.

>>> x, y = BitVecs('x y', 32)
>>> x <= y
x <= y
>>> (x <= y).sexpr()
'(bvsle x y)'
>>> ULE(x, y).sexpr()
'(bvule x y)'

Definition at line 3545 of file z3py.py.

3545  def __le__(self, other):
3546  """Create the Z3 expression (signed) `other <= self`.
3547 
3548  Use the function ULE() for unsigned less than or equal to.
3549 
3550  >>> x, y = BitVecs('x y', 32)
3551  >>> x <= y
3552  x <= y
3553  >>> (x <= y).sexpr()
3554  '(bvsle x y)'
3555  >>> ULE(x, y).sexpr()
3556  '(bvule x y)'
3557  """
3558  a, b = _coerce_exprs(self, other)
3559  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3560 

◆ __lshift__()

def __lshift__ (   self,
  other 
)
Create the Z3 expression left shift `self << other`

>>> x, y = BitVecs('x y', 32)
>>> x << y
x << y
>>> (x << y).sexpr()
'(bvshl x y)'
>>> simplify(BitVecVal(2, 3) << 1)
4

Definition at line 3639 of file z3py.py.

3639  def __lshift__(self, other):
3640  """Create the Z3 expression left shift `self << other`
3641 
3642  >>> x, y = BitVecs('x y', 32)
3643  >>> x << y
3644  x << y
3645  >>> (x << y).sexpr()
3646  '(bvshl x y)'
3647  >>> simplify(BitVecVal(2, 3) << 1)
3648  4
3649  """
3650  a, b = _coerce_exprs(self, other)
3651  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3652 

◆ __lt__()

def __lt__ (   self,
  other 
)
Create the Z3 expression (signed) `other < self`.

Use the function ULT() for unsigned less than.

>>> x, y = BitVecs('x y', 32)
>>> x < y
x < y
>>> (x < y).sexpr()
'(bvslt x y)'
>>> ULT(x, y).sexpr()
'(bvult x y)'

Definition at line 3561 of file z3py.py.

3561  def __lt__(self, other):
3562  """Create the Z3 expression (signed) `other < self`.
3563 
3564  Use the function ULT() for unsigned less than.
3565 
3566  >>> x, y = BitVecs('x y', 32)
3567  >>> x < y
3568  x < y
3569  >>> (x < y).sexpr()
3570  '(bvslt x y)'
3571  >>> ULT(x, y).sexpr()
3572  '(bvult x y)'
3573  """
3574  a, b = _coerce_exprs(self, other)
3575  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3576 

◆ __mod__()

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

Use the function URem() for unsigned remainder, and SRem() for signed remainder.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> x % y
x%y
>>> (x % y).sort()
BitVec(32)
>>> (x % y).sexpr()
'(bvsmod x y)'
>>> URem(x, y).sexpr()
'(bvurem x y)'
>>> SRem(x, y).sexpr()
'(bvsrem x y)'

Definition at line 3506 of file z3py.py.

3506  def __mod__(self, other):
3507  """Create the Z3 expression (signed) mod `self % other`.
3508 
3509  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3510 
3511  >>> x = BitVec('x', 32)
3512  >>> y = BitVec('y', 32)
3513  >>> x % y
3514  x%y
3515  >>> (x % y).sort()
3516  BitVec(32)
3517  >>> (x % y).sexpr()
3518  '(bvsmod x y)'
3519  >>> URem(x, y).sexpr()
3520  '(bvurem x y)'
3521  >>> SRem(x, y).sexpr()
3522  '(bvsrem x y)'
3523  """
3524  a, b = _coerce_exprs(self, other)
3525  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3526 

◆ __mul__()

def __mul__ (   self,
  other 
)
Create the Z3 expression `self * other`.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> x * y
x*y
>>> (x * y).sort()
BitVec(32)

Definition at line 3317 of file z3py.py.

3317  def __mul__(self, other):
3318  """Create the Z3 expression `self * other`.
3319 
3320  >>> x = BitVec('x', 32)
3321  >>> y = BitVec('y', 32)
3322  >>> x * y
3323  x*y
3324  >>> (x * y).sort()
3325  BitVec(32)
3326  """
3327  a, b = _coerce_exprs(self, other)
3328  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3329 

◆ __neg__()

def __neg__ (   self)
Return an expression representing `-self`.

>>> x = BitVec('x', 32)
>>> -x
-x
>>> simplify(-(-x))
x

Definition at line 3441 of file z3py.py.

3441  def __neg__(self):
3442  """Return an expression representing `-self`.
3443 
3444  >>> x = BitVec('x', 32)
3445  >>> -x
3446  -x
3447  >>> simplify(-(-x))
3448  x
3449  """
3450  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3451 

◆ __or__()

def __or__ (   self,
  other 
)
Create the Z3 expression bitwise-or `self | other`.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> x | y
x | y
>>> (x | y).sort()
BitVec(32)

Definition at line 3363 of file z3py.py.

3363  def __or__(self, other):
3364  """Create the Z3 expression bitwise-or `self | other`.
3365 
3366  >>> x = BitVec('x', 32)
3367  >>> y = BitVec('y', 32)
3368  >>> x | y
3369  x | y
3370  >>> (x | y).sort()
3371  BitVec(32)
3372  """
3373  a, b = _coerce_exprs(self, other)
3374  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3375 

◆ __pos__()

def __pos__ (   self)
Return `self`.

>>> x = BitVec('x', 32)
>>> +x
x

Definition at line 3432 of file z3py.py.

3432  def __pos__(self):
3433  """Return `self`.
3434 
3435  >>> x = BitVec('x', 32)
3436  >>> +x
3437  x
3438  """
3439  return self
3440 

◆ __radd__()

def __radd__ (   self,
  other 
)
Create the Z3 expression `other + self`.

>>> x = BitVec('x', 32)
>>> 10 + x
10 + x

Definition at line 3307 of file z3py.py.

3307  def __radd__(self, other):
3308  """Create the Z3 expression `other + self`.
3309 
3310  >>> x = BitVec('x', 32)
3311  >>> 10 + x
3312  10 + x
3313  """
3314  a, b = _coerce_exprs(self, other)
3315  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3316 

◆ __rand__()

def __rand__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other & self`.

>>> x = BitVec('x', 32)
>>> 10 & x
10 & x

Definition at line 3399 of file z3py.py.

3399  def __rand__(self, other):
3400  """Create the Z3 expression bitwise-or `other & self`.
3401 
3402  >>> x = BitVec('x', 32)
3403  >>> 10 & x
3404  10 & x
3405  """
3406  a, b = _coerce_exprs(self, other)
3407  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3408 

◆ __rdiv__()

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

Use the function UDiv() for unsigned division.

>>> x = BitVec('x', 32)
>>> 10 / x
10/x
>>> (10 / x).sexpr()
'(bvsdiv #x0000000a x)'
>>> UDiv(10, x).sexpr()
'(bvudiv #x0000000a x)'

Definition at line 3486 of file z3py.py.

3486  def __rdiv__(self, other):
3487  """Create the Z3 expression (signed) division `other / self`.
3488 
3489  Use the function UDiv() for unsigned division.
3490 
3491  >>> x = BitVec('x', 32)
3492  >>> 10 / x
3493  10/x
3494  >>> (10 / x).sexpr()
3495  '(bvsdiv #x0000000a x)'
3496  >>> UDiv(10, x).sexpr()
3497  '(bvudiv #x0000000a x)'
3498  """
3499  a, b = _coerce_exprs(self, other)
3500  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3501 

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

◆ __rlshift__()

def __rlshift__ (   self,
  other 
)
Create the Z3 expression left shift `other << self`.

Use the function LShR() for the right logical shift

>>> x = BitVec('x', 32)
>>> 10 << x
10 << x
>>> (10 << x).sexpr()
'(bvshl #x0000000a x)'

Definition at line 3667 of file z3py.py.

3667  def __rlshift__(self, other):
3668  """Create the Z3 expression left shift `other << self`.
3669 
3670  Use the function LShR() for the right logical shift
3671 
3672  >>> x = BitVec('x', 32)
3673  >>> 10 << x
3674  10 << x
3675  >>> (10 << x).sexpr()
3676  '(bvshl #x0000000a x)'
3677  """
3678  a, b = _coerce_exprs(self, other)
3679  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3680 

◆ __rmod__()

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

Use the function URem() for unsigned remainder, and SRem() for signed remainder.

>>> x = BitVec('x', 32)
>>> 10 % x
10%x
>>> (10 % x).sexpr()
'(bvsmod #x0000000a x)'
>>> URem(10, x).sexpr()
'(bvurem #x0000000a x)'
>>> SRem(10, x).sexpr()
'(bvsrem #x0000000a x)'

Definition at line 3527 of file z3py.py.

3527  def __rmod__(self, other):
3528  """Create the Z3 expression (signed) mod `other % self`.
3529 
3530  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3531 
3532  >>> x = BitVec('x', 32)
3533  >>> 10 % x
3534  10%x
3535  >>> (10 % x).sexpr()
3536  '(bvsmod #x0000000a x)'
3537  >>> URem(10, x).sexpr()
3538  '(bvurem #x0000000a x)'
3539  >>> SRem(10, x).sexpr()
3540  '(bvsrem #x0000000a x)'
3541  """
3542  a, b = _coerce_exprs(self, other)
3543  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3544 

◆ __rmul__()

def __rmul__ (   self,
  other 
)
Create the Z3 expression `other * self`.

>>> x = BitVec('x', 32)
>>> 10 * x
10*x

Definition at line 3330 of file z3py.py.

3330  def __rmul__(self, other):
3331  """Create the Z3 expression `other * self`.
3332 
3333  >>> x = BitVec('x', 32)
3334  >>> 10 * x
3335  10*x
3336  """
3337  a, b = _coerce_exprs(self, other)
3338  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3339 

◆ __ror__()

def __ror__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other | self`.

>>> x = BitVec('x', 32)
>>> 10 | x
10 | x

Definition at line 3376 of file z3py.py.

3376  def __ror__(self, other):
3377  """Create the Z3 expression bitwise-or `other | self`.
3378 
3379  >>> x = BitVec('x', 32)
3380  >>> 10 | x
3381  10 | x
3382  """
3383  a, b = _coerce_exprs(self, other)
3384  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3385 

◆ __rrshift__()

def __rrshift__ (   self,
  other 
)
Create the Z3 expression (arithmetical) right shift `other` >> `self`.

Use the function LShR() for the right logical shift

>>> x = BitVec('x', 32)
>>> 10 >> x
10 >> x
>>> (10 >> x).sexpr()
'(bvashr #x0000000a x)'

Definition at line 3653 of file z3py.py.

3653  def __rrshift__(self, other):
3654  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3655 
3656  Use the function LShR() for the right logical shift
3657 
3658  >>> x = BitVec('x', 32)
3659  >>> 10 >> x
3660  10 >> x
3661  >>> (10 >> x).sexpr()
3662  '(bvashr #x0000000a x)'
3663  """
3664  a, b = _coerce_exprs(self, other)
3665  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3666 

◆ __rshift__()

def __rshift__ (   self,
  other 
)
Create the Z3 expression (arithmetical) right shift `self >> other`

Use the function LShR() for the right logical shift

>>> x, y = BitVecs('x y', 32)
>>> x >> y
x >> y
>>> (x >> y).sexpr()
'(bvashr x y)'
>>> LShR(x, y).sexpr()
'(bvlshr x y)'
>>> BitVecVal(4, 3)
4
>>> BitVecVal(4, 3).as_signed_long()
-4
>>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
-2
>>> simplify(BitVecVal(4, 3) >> 1)
6
>>> simplify(LShR(BitVecVal(4, 3), 1))
2
>>> simplify(BitVecVal(2, 3) >> 1)
1
>>> simplify(LShR(BitVecVal(2, 3), 1))
1

Definition at line 3609 of file z3py.py.

3609  def __rshift__(self, other):
3610  """Create the Z3 expression (arithmetical) right shift `self >> other`
3611 
3612  Use the function LShR() for the right logical shift
3613 
3614  >>> x, y = BitVecs('x y', 32)
3615  >>> x >> y
3616  x >> y
3617  >>> (x >> y).sexpr()
3618  '(bvashr x y)'
3619  >>> LShR(x, y).sexpr()
3620  '(bvlshr x y)'
3621  >>> BitVecVal(4, 3)
3622  4
3623  >>> BitVecVal(4, 3).as_signed_long()
3624  -4
3625  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3626  -2
3627  >>> simplify(BitVecVal(4, 3) >> 1)
3628  6
3629  >>> simplify(LShR(BitVecVal(4, 3), 1))
3630  2
3631  >>> simplify(BitVecVal(2, 3) >> 1)
3632  1
3633  >>> simplify(LShR(BitVecVal(2, 3), 1))
3634  1
3635  """
3636  a, b = _coerce_exprs(self, other)
3637  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3638 

◆ __rsub__()

def __rsub__ (   self,
  other 
)
Create the Z3 expression `other - self`.

>>> x = BitVec('x', 32)
>>> 10 - x
10 - x

Definition at line 3353 of file z3py.py.

3353  def __rsub__(self, other):
3354  """Create the Z3 expression `other - self`.
3355 
3356  >>> x = BitVec('x', 32)
3357  >>> 10 - x
3358  10 - x
3359  """
3360  a, b = _coerce_exprs(self, other)
3361  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3362 

◆ __rtruediv__()

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

Definition at line 3502 of file z3py.py.

3502  def __rtruediv__(self, other):
3503  """Create the Z3 expression (signed) division `other / self`."""
3504  return self.__rdiv__(other)
3505 

◆ __rxor__()

def __rxor__ (   self,
  other 
)
Create the Z3 expression bitwise-xor `other ^ self`.

>>> x = BitVec('x', 32)
>>> 10 ^ x
10 ^ x

Definition at line 3422 of file z3py.py.

3422  def __rxor__(self, other):
3423  """Create the Z3 expression bitwise-xor `other ^ self`.
3424 
3425  >>> x = BitVec('x', 32)
3426  >>> 10 ^ x
3427  10 ^ x
3428  """
3429  a, b = _coerce_exprs(self, other)
3430  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3431 

◆ __sub__()

def __sub__ (   self,
  other 
)
Create the Z3 expression `self - other`.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> x - y
x - y
>>> (x - y).sort()
BitVec(32)

Definition at line 3340 of file z3py.py.

3340  def __sub__(self, other):
3341  """Create the Z3 expression `self - other`.
3342 
3343  >>> x = BitVec('x', 32)
3344  >>> y = BitVec('y', 32)
3345  >>> x - y
3346  x - y
3347  >>> (x - y).sort()
3348  BitVec(32)
3349  """
3350  a, b = _coerce_exprs(self, other)
3351  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3352 

◆ __truediv__()

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

Definition at line 3482 of file z3py.py.

3482  def __truediv__(self, other):
3483  """Create the Z3 expression (signed) division `self / other`."""
3484  return self.__div__(other)
3485 

◆ __xor__()

def __xor__ (   self,
  other 
)
Create the Z3 expression bitwise-xor `self ^ other`.

>>> x = BitVec('x', 32)
>>> y = BitVec('y', 32)
>>> x ^ y
x ^ y
>>> (x ^ y).sort()
BitVec(32)

Definition at line 3409 of file z3py.py.

3409  def __xor__(self, other):
3410  """Create the Z3 expression bitwise-xor `self ^ other`.
3411 
3412  >>> x = BitVec('x', 32)
3413  >>> y = BitVec('y', 32)
3414  >>> x ^ y
3415  x ^ y
3416  >>> (x ^ y).sort()
3417  BitVec(32)
3418  """
3419  a, b = _coerce_exprs(self, other)
3420  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3421 

◆ size()

def size (   self)
Return the number of bits of the bit-vector expression `self`.

>>> x = BitVec('x', 32)
>>> (x + 1).size()
32
>>> Concat(x, x).size()
64

Definition at line 3283 of file z3py.py.

3283  def size(self):
3284  """Return the number of bits of the bit-vector expression `self`.
3285 
3286  >>> x = BitVec('x', 32)
3287  >>> (x + 1).size()
3288  32
3289  >>> Concat(x, x).size()
3290  64
3291  """
3292  return self.sort().size()
3293 

Referenced by ParamDescrsRef.__len__(), Goal.__len__(), and BitVecNumRef.as_signed_long().

◆ sort()

def sort (   self)
Return the sort of the bit-vector expression `self`.

>>> x = BitVec('x', 32)
>>> x.sort()
BitVec(32)
>>> x.sort() == BitVecSort(32)
True

Reimplemented from ExprRef.

Definition at line 3272 of file z3py.py.

3272  def sort(self):
3273  """Return the sort of the bit-vector expression `self`.
3274 
3275  >>> x = BitVec('x', 32)
3276  >>> x.sort()
3277  BitVec(32)
3278  >>> x.sort() == BitVecSort(32)
3279  True
3280  """
3281  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3282 
Z3_mk_bvshl
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.
Z3_mk_bvslt
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than.
Z3_mk_bvmul
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.
Z3_mk_bvnot
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.
Z3_mk_bvsge
Z3_ast Z3_API Z3_mk_bvsge(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than or equal to.
Z3_mk_bvadd
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.
Z3_mk_bvneg
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two's complement unary minus.
Z3_mk_bvashr
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.
Z3_mk_bvsmod
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows divisor).
Z3_mk_bvsle
Z3_ast Z3_API Z3_mk_bvsle(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than or equal to.
Z3_mk_bvsdiv
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.
Z3_mk_bvsub
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.
Z3_mk_bvand
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.
Z3_mk_bvxor
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.
Z3_get_sort
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.
Z3_mk_bvsgt
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.
Z3_mk_bvor
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.