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 3449 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 3474 of file z3py.py.

3474  def __add__(self, other):
3475  """Create the Z3 expression `self + other`.
3476 
3477  >>> x = BitVec('x', 32)
3478  >>> y = BitVec('y', 32)
3479  >>> x + y
3480  x + y
3481  >>> (x + y).sort()
3482  BitVec(32)
3483  """
3484  a, b = _coerce_exprs(self, other)
3485  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3486 
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.

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

3566  def __and__(self, other):
3567  """Create the Z3 expression bitwise-and `self & other`.
3568 
3569  >>> x = BitVec('x', 32)
3570  >>> y = BitVec('y', 32)
3571  >>> x & y
3572  x & y
3573  >>> (x & y).sort()
3574  BitVec(32)
3575  """
3576  a, b = _coerce_exprs(self, other)
3577  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3578 
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.

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

3643  def __div__(self, other):
3644  """Create the Z3 expression (signed) division `self / other`.
3645 
3646  Use the function UDiv() for unsigned division.
3647 
3648  >>> x = BitVec('x', 32)
3649  >>> y = BitVec('y', 32)
3650  >>> x / y
3651  x/y
3652  >>> (x / y).sort()
3653  BitVec(32)
3654  >>> (x / y).sexpr()
3655  '(bvsdiv x y)'
3656  >>> UDiv(x, y).sexpr()
3657  '(bvudiv x y)'
3658  """
3659  a, b = _coerce_exprs(self, other)
3660  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3661 
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.

Referenced by ArithRef.__truediv__(), 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 3773 of file z3py.py.

3773  def __ge__(self, other):
3774  """Create the Z3 expression (signed) `other >= self`.
3775 
3776  Use the function UGE() for unsigned greater than or equal to.
3777 
3778  >>> x, y = BitVecs('x y', 32)
3779  >>> x >= y
3780  x >= y
3781  >>> (x >= y).sexpr()
3782  '(bvsge x y)'
3783  >>> UGE(x, y).sexpr()
3784  '(bvuge x y)'
3785  """
3786  a, b = _coerce_exprs(self, other)
3787  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3788 
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.

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

3757  def __gt__(self, other):
3758  """Create the Z3 expression (signed) `other > self`.
3759 
3760  Use the function UGT() for unsigned greater than.
3761 
3762  >>> x, y = BitVecs('x y', 32)
3763  >>> x > y
3764  x > y
3765  >>> (x > y).sexpr()
3766  '(bvsgt x y)'
3767  >>> UGT(x, y).sexpr()
3768  '(bvugt x y)'
3769  """
3770  a, b = _coerce_exprs(self, other)
3771  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3772 
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.

◆ __invert__()

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

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

Definition at line 3632 of file z3py.py.

3632  def __invert__(self):
3633  """Create the Z3 expression bitwise-not `~self`.
3634 
3635  >>> x = BitVec('x', 32)
3636  >>> ~x
3637  ~x
3638  >>> simplify(~(~x))
3639  x
3640  """
3641  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3642 
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.

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

3725  def __le__(self, other):
3726  """Create the Z3 expression (signed) `other <= self`.
3727 
3728  Use the function ULE() for unsigned less than or equal to.
3729 
3730  >>> x, y = BitVecs('x y', 32)
3731  >>> x <= y
3732  x <= y
3733  >>> (x <= y).sexpr()
3734  '(bvsle x y)'
3735  >>> ULE(x, y).sexpr()
3736  '(bvule x y)'
3737  """
3738  a, b = _coerce_exprs(self, other)
3739  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3740 
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.

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

3819  def __lshift__(self, other):
3820  """Create the Z3 expression left shift `self << other`
3821 
3822  >>> x, y = BitVecs('x y', 32)
3823  >>> x << y
3824  x << y
3825  >>> (x << y).sexpr()
3826  '(bvshl x y)'
3827  >>> simplify(BitVecVal(2, 3) << 1)
3828  4
3829  """
3830  a, b = _coerce_exprs(self, other)
3831  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3832 
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.

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

3741  def __lt__(self, other):
3742  """Create the Z3 expression (signed) `other < self`.
3743 
3744  Use the function ULT() for unsigned less than.
3745 
3746  >>> x, y = BitVecs('x y', 32)
3747  >>> x < y
3748  x < y
3749  >>> (x < y).sexpr()
3750  '(bvslt x y)'
3751  >>> ULT(x, y).sexpr()
3752  '(bvult x y)'
3753  """
3754  a, b = _coerce_exprs(self, other)
3755  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3756 
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than.

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

3686  def __mod__(self, other):
3687  """Create the Z3 expression (signed) mod `self % other`.
3688 
3689  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3690 
3691  >>> x = BitVec('x', 32)
3692  >>> y = BitVec('y', 32)
3693  >>> x % y
3694  x%y
3695  >>> (x % y).sort()
3696  BitVec(32)
3697  >>> (x % y).sexpr()
3698  '(bvsmod x y)'
3699  >>> URem(x, y).sexpr()
3700  '(bvurem x y)'
3701  >>> SRem(x, y).sexpr()
3702  '(bvsrem x y)'
3703  """
3704  a, b = _coerce_exprs(self, other)
3705  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3706 
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows divisor).

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

3497  def __mul__(self, other):
3498  """Create the Z3 expression `self * other`.
3499 
3500  >>> x = BitVec('x', 32)
3501  >>> y = BitVec('y', 32)
3502  >>> x * y
3503  x*y
3504  >>> (x * y).sort()
3505  BitVec(32)
3506  """
3507  a, b = _coerce_exprs(self, other)
3508  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3509 
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.

◆ __neg__()

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

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

Definition at line 3621 of file z3py.py.

3621  def __neg__(self):
3622  """Return an expression representing `-self`.
3623 
3624  >>> x = BitVec('x', 32)
3625  >>> -x
3626  -x
3627  >>> simplify(-(-x))
3628  x
3629  """
3630  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3631 
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two's complement unary minus.

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

3543  def __or__(self, other):
3544  """Create the Z3 expression bitwise-or `self | other`.
3545 
3546  >>> x = BitVec('x', 32)
3547  >>> y = BitVec('y', 32)
3548  >>> x | y
3549  x | y
3550  >>> (x | y).sort()
3551  BitVec(32)
3552  """
3553  a, b = _coerce_exprs(self, other)
3554  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3555 
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.

◆ __pos__()

def __pos__ (   self)
Return `self`.

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

Definition at line 3612 of file z3py.py.

3612  def __pos__(self):
3613  """Return `self`.
3614 
3615  >>> x = BitVec('x', 32)
3616  >>> +x
3617  x
3618  """
3619  return self
3620 

◆ __radd__()

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

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

Definition at line 3487 of file z3py.py.

3487  def __radd__(self, other):
3488  """Create the Z3 expression `other + self`.
3489 
3490  >>> x = BitVec('x', 32)
3491  >>> 10 + x
3492  10 + x
3493  """
3494  a, b = _coerce_exprs(self, other)
3495  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3496 

◆ __rand__()

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

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

Definition at line 3579 of file z3py.py.

3579  def __rand__(self, other):
3580  """Create the Z3 expression bitwise-or `other & self`.
3581 
3582  >>> x = BitVec('x', 32)
3583  >>> 10 & x
3584  10 & x
3585  """
3586  a, b = _coerce_exprs(self, other)
3587  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3588 

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

3666  def __rdiv__(self, other):
3667  """Create the Z3 expression (signed) division `other / self`.
3668 
3669  Use the function UDiv() for unsigned division.
3670 
3671  >>> x = BitVec('x', 32)
3672  >>> 10 / x
3673  10/x
3674  >>> (10 / x).sexpr()
3675  '(bvsdiv #x0000000a x)'
3676  >>> UDiv(10, x).sexpr()
3677  '(bvudiv #x0000000a x)'
3678  """
3679  a, b = _coerce_exprs(self, other)
3680  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3681 

Referenced by ArithRef.__rtruediv__(), 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 3847 of file z3py.py.

3847  def __rlshift__(self, other):
3848  """Create the Z3 expression left shift `other << self`.
3849 
3850  Use the function LShR() for the right logical shift
3851 
3852  >>> x = BitVec('x', 32)
3853  >>> 10 << x
3854  10 << x
3855  >>> (10 << x).sexpr()
3856  '(bvshl #x0000000a x)'
3857  """
3858  a, b = _coerce_exprs(self, other)
3859  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3860 
3861 

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

3707  def __rmod__(self, other):
3708  """Create the Z3 expression (signed) mod `other % self`.
3709 
3710  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3711 
3712  >>> x = BitVec('x', 32)
3713  >>> 10 % x
3714  10%x
3715  >>> (10 % x).sexpr()
3716  '(bvsmod #x0000000a x)'
3717  >>> URem(10, x).sexpr()
3718  '(bvurem #x0000000a x)'
3719  >>> SRem(10, x).sexpr()
3720  '(bvsrem #x0000000a x)'
3721  """
3722  a, b = _coerce_exprs(self, other)
3723  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3724 

◆ __rmul__()

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

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

Definition at line 3510 of file z3py.py.

3510  def __rmul__(self, other):
3511  """Create the Z3 expression `other * self`.
3512 
3513  >>> x = BitVec('x', 32)
3514  >>> 10 * x
3515  10*x
3516  """
3517  a, b = _coerce_exprs(self, other)
3518  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3519 

◆ __ror__()

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

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

Definition at line 3556 of file z3py.py.

3556  def __ror__(self, other):
3557  """Create the Z3 expression bitwise-or `other | self`.
3558 
3559  >>> x = BitVec('x', 32)
3560  >>> 10 | x
3561  10 | x
3562  """
3563  a, b = _coerce_exprs(self, other)
3564  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3565 

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

3833  def __rrshift__(self, other):
3834  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3835 
3836  Use the function LShR() for the right logical shift
3837 
3838  >>> x = BitVec('x', 32)
3839  >>> 10 >> x
3840  10 >> x
3841  >>> (10 >> x).sexpr()
3842  '(bvashr #x0000000a x)'
3843  """
3844  a, b = _coerce_exprs(self, other)
3845  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3846 
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.

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

3789  def __rshift__(self, other):
3790  """Create the Z3 expression (arithmetical) right shift `self >> other`
3791 
3792  Use the function LShR() for the right logical shift
3793 
3794  >>> x, y = BitVecs('x y', 32)
3795  >>> x >> y
3796  x >> y
3797  >>> (x >> y).sexpr()
3798  '(bvashr x y)'
3799  >>> LShR(x, y).sexpr()
3800  '(bvlshr x y)'
3801  >>> BitVecVal(4, 3)
3802  4
3803  >>> BitVecVal(4, 3).as_signed_long()
3804  -4
3805  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3806  -2
3807  >>> simplify(BitVecVal(4, 3) >> 1)
3808  6
3809  >>> simplify(LShR(BitVecVal(4, 3), 1))
3810  2
3811  >>> simplify(BitVecVal(2, 3) >> 1)
3812  1
3813  >>> simplify(LShR(BitVecVal(2, 3), 1))
3814  1
3815  """
3816  a, b = _coerce_exprs(self, other)
3817  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3818 

◆ __rsub__()

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

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

Definition at line 3533 of file z3py.py.

3533  def __rsub__(self, other):
3534  """Create the Z3 expression `other - self`.
3535 
3536  >>> x = BitVec('x', 32)
3537  >>> 10 - x
3538  10 - x
3539  """
3540  a, b = _coerce_exprs(self, other)
3541  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3542 
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.

◆ __rtruediv__()

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

Definition at line 3682 of file z3py.py.

3682  def __rtruediv__(self, other):
3683  """Create the Z3 expression (signed) division `other / self`."""
3684  return self.__rdiv__(other)
3685 

◆ __rxor__()

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

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

Definition at line 3602 of file z3py.py.

3602  def __rxor__(self, other):
3603  """Create the Z3 expression bitwise-xor `other ^ self`.
3604 
3605  >>> x = BitVec('x', 32)
3606  >>> 10 ^ x
3607  10 ^ x
3608  """
3609  a, b = _coerce_exprs(self, other)
3610  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3611 
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.

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

3520  def __sub__(self, other):
3521  """Create the Z3 expression `self - other`.
3522 
3523  >>> x = BitVec('x', 32)
3524  >>> y = BitVec('y', 32)
3525  >>> x - y
3526  x - y
3527  >>> (x - y).sort()
3528  BitVec(32)
3529  """
3530  a, b = _coerce_exprs(self, other)
3531  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3532 

◆ __truediv__()

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

Definition at line 3662 of file z3py.py.

3662  def __truediv__(self, other):
3663  """Create the Z3 expression (signed) division `self / other`."""
3664  return self.__div__(other)
3665 

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

3589  def __xor__(self, other):
3590  """Create the Z3 expression bitwise-xor `self ^ other`.
3591 
3592  >>> x = BitVec('x', 32)
3593  >>> y = BitVec('y', 32)
3594  >>> x ^ y
3595  x ^ y
3596  >>> (x ^ y).sort()
3597  BitVec(32)
3598  """
3599  a, b = _coerce_exprs(self, other)
3600  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3601 

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

3463  def size(self):
3464  """Return the number of bits of the bit-vector expression `self`.
3465 
3466  >>> x = BitVec('x', 32)
3467  >>> (x + 1).size()
3468  32
3469  >>> Concat(x, x).size()
3470  64
3471  """
3472  return self.sort().size()
3473 

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

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

3452  def sort(self):
3453  """Return the sort of the bit-vector expression `self`.
3454 
3455  >>> x = BitVec('x', 32)
3456  >>> x.sort()
3457  BitVec(32)
3458  >>> x.sort() == BitVecSort(32)
3459  True
3460  """
3461  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3462 
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.

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