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 (self)
 
def sort_kind (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __ne__ (self, other)
 
def params (self)
 
def decl (self)
 
def kind (self)
 
def num_args (self)
 
def arg (self, idx)
 
def children (self)
 
def from_string (self, s)
 
def serialize (self)
 
- Public Member Functions inherited from AstRef
def __init__
 
def __del__ (self)
 
def __deepcopy__
 
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)
 
def py_value (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 3572 of file z3py.py.

Member Function Documentation

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

3597  def __add__(self, other):
3598  """Create the Z3 expression `self + other`.
3599 
3600  >>> x = BitVec('x', 32)
3601  >>> y = BitVec('y', 32)
3602  >>> x + y
3603  x + y
3604  >>> (x + y).sort()
3605  BitVec(32)
3606  """
3607  a, b = _coerce_exprs(self, other)
3608  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3609 
def __add__(self, other)
Definition: z3py.py:3597
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.
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 3689 of file z3py.py.

3689  def __and__(self, other):
3690  """Create the Z3 expression bitwise-and `self & other`.
3691 
3692  >>> x = BitVec('x', 32)
3693  >>> y = BitVec('y', 32)
3694  >>> x & y
3695  x & y
3696  >>> (x & y).sort()
3697  BitVec(32)
3698  """
3699  a, b = _coerce_exprs(self, other)
3700  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3701 
def __and__(self, other)
Definition: z3py.py:3689
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.
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 3766 of file z3py.py.

3766  def __div__(self, other):
3767  """Create the Z3 expression (signed) division `self / other`.
3768 
3769  Use the function UDiv() for unsigned division.
3770 
3771  >>> x = BitVec('x', 32)
3772  >>> y = BitVec('y', 32)
3773  >>> x / y
3774  x/y
3775  >>> (x / y).sort()
3776  BitVec(32)
3777  >>> (x / y).sexpr()
3778  '(bvsdiv x y)'
3779  >>> UDiv(x, y).sexpr()
3780  '(bvudiv x y)'
3781  """
3782  a, b = _coerce_exprs(self, other)
3783  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3784 
def __div__(self, other)
Definition: z3py.py:3766
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.
def ctx_ref(self)
Definition: z3py.py:410
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 3896 of file z3py.py.

3896  def __ge__(self, other):
3897  """Create the Z3 expression (signed) `other >= self`.
3898 
3899  Use the function UGE() for unsigned greater than or equal to.
3900 
3901  >>> x, y = BitVecs('x y', 32)
3902  >>> x >= y
3903  x >= y
3904  >>> (x >= y).sexpr()
3905  '(bvsge x y)'
3906  >>> UGE(x, y).sexpr()
3907  '(bvuge x y)'
3908  """
3909  a, b = _coerce_exprs(self, other)
3910  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3911 
def __ge__(self, other)
Definition: z3py.py:3896
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.
def ctx_ref(self)
Definition: z3py.py:410
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 3880 of file z3py.py.

3880  def __gt__(self, other):
3881  """Create the Z3 expression (signed) `other > self`.
3882 
3883  Use the function UGT() for unsigned greater than.
3884 
3885  >>> x, y = BitVecs('x y', 32)
3886  >>> x > y
3887  x > y
3888  >>> (x > y).sexpr()
3889  '(bvsgt x y)'
3890  >>> UGT(x, y).sexpr()
3891  '(bvugt x y)'
3892  """
3893  a, b = _coerce_exprs(self, other)
3894  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3895 
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.
def __gt__(self, other)
Definition: z3py.py:3880
def ctx_ref(self)
Definition: z3py.py:410
def __invert__ (   self)
Create the Z3 expression bitwise-not `~self`.

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

Definition at line 3755 of file z3py.py.

3755  def __invert__(self):
3756  """Create the Z3 expression bitwise-not `~self`.
3757 
3758  >>> x = BitVec('x', 32)
3759  >>> ~x
3760  ~x
3761  >>> simplify(~(~x))
3762  x
3763  """
3764  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3765 
def as_ast(self)
Definition: z3py.py:402
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.
def ctx_ref(self)
Definition: z3py.py:410
def __invert__(self)
Definition: z3py.py:3755
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 3848 of file z3py.py.

3848  def __le__(self, other):
3849  """Create the Z3 expression (signed) `other <= self`.
3850 
3851  Use the function ULE() for unsigned less than or equal to.
3852 
3853  >>> x, y = BitVecs('x y', 32)
3854  >>> x <= y
3855  x <= y
3856  >>> (x <= y).sexpr()
3857  '(bvsle x y)'
3858  >>> ULE(x, y).sexpr()
3859  '(bvule x y)'
3860  """
3861  a, b = _coerce_exprs(self, other)
3862  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3863 
def __le__(self, other)
Definition: z3py.py:3848
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.
def ctx_ref(self)
Definition: z3py.py:410
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 3942 of file z3py.py.

3942  def __lshift__(self, other):
3943  """Create the Z3 expression left shift `self << other`
3944 
3945  >>> x, y = BitVecs('x y', 32)
3946  >>> x << y
3947  x << y
3948  >>> (x << y).sexpr()
3949  '(bvshl x y)'
3950  >>> simplify(BitVecVal(2, 3) << 1)
3951  4
3952  """
3953  a, b = _coerce_exprs(self, other)
3954  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3955 
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.
def ctx_ref(self)
Definition: z3py.py:410
def __lshift__(self, other)
Definition: z3py.py:3942
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 3864 of file z3py.py.

3864  def __lt__(self, other):
3865  """Create the Z3 expression (signed) `other < self`.
3866 
3867  Use the function ULT() for unsigned less than.
3868 
3869  >>> x, y = BitVecs('x y', 32)
3870  >>> x < y
3871  x < y
3872  >>> (x < y).sexpr()
3873  '(bvslt x y)'
3874  >>> ULT(x, y).sexpr()
3875  '(bvult x y)'
3876  """
3877  a, b = _coerce_exprs(self, other)
3878  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3879 
def __lt__(self, other)
Definition: z3py.py:3864
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than.
def ctx_ref(self)
Definition: z3py.py:410
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 3809 of file z3py.py.

3809  def __mod__(self, other):
3810  """Create the Z3 expression (signed) mod `self % other`.
3811 
3812  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3813 
3814  >>> x = BitVec('x', 32)
3815  >>> y = BitVec('y', 32)
3816  >>> x % y
3817  x%y
3818  >>> (x % y).sort()
3819  BitVec(32)
3820  >>> (x % y).sexpr()
3821  '(bvsmod x y)'
3822  >>> URem(x, y).sexpr()
3823  '(bvurem x y)'
3824  >>> SRem(x, y).sexpr()
3825  '(bvsrem x y)'
3826  """
3827  a, b = _coerce_exprs(self, other)
3828  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3829 
def __mod__(self, other)
Definition: z3py.py:3809
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows divisor).
def ctx_ref(self)
Definition: z3py.py:410
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 3620 of file z3py.py.

3620  def __mul__(self, other):
3621  """Create the Z3 expression `self * other`.
3622 
3623  >>> x = BitVec('x', 32)
3624  >>> y = BitVec('y', 32)
3625  >>> x * y
3626  x*y
3627  >>> (x * y).sort()
3628  BitVec(32)
3629  """
3630  a, b = _coerce_exprs(self, other)
3631  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3632 
def __mul__(self, other)
Definition: z3py.py:3620
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.
def __neg__ (   self)
Return an expression representing `-self`.

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

Definition at line 3744 of file z3py.py.

3744  def __neg__(self):
3745  """Return an expression representing `-self`.
3746 
3747  >>> x = BitVec('x', 32)
3748  >>> -x
3749  -x
3750  >>> simplify(-(-x))
3751  x
3752  """
3753  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3754 
def as_ast(self)
Definition: z3py.py:402
def __neg__(self)
Definition: z3py.py:3744
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two's complement unary minus.
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 3666 of file z3py.py.

3666  def __or__(self, other):
3667  """Create the Z3 expression bitwise-or `self | other`.
3668 
3669  >>> x = BitVec('x', 32)
3670  >>> y = BitVec('y', 32)
3671  >>> x | y
3672  x | y
3673  >>> (x | y).sort()
3674  BitVec(32)
3675  """
3676  a, b = _coerce_exprs(self, other)
3677  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3678 
def __or__(self, other)
Definition: z3py.py:3666
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.
def ctx_ref(self)
Definition: z3py.py:410
def __pos__ (   self)
Return `self`.

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

Definition at line 3735 of file z3py.py.

3735  def __pos__(self):
3736  """Return `self`.
3737 
3738  >>> x = BitVec('x', 32)
3739  >>> +x
3740  x
3741  """
3742  return self
3743 
def __pos__(self)
Definition: z3py.py:3735
def __radd__ (   self,
  other 
)
Create the Z3 expression `other + self`.

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

Definition at line 3610 of file z3py.py.

3610  def __radd__(self, other):
3611  """Create the Z3 expression `other + self`.
3612 
3613  >>> x = BitVec('x', 32)
3614  >>> 10 + x
3615  10 + x
3616  """
3617  a, b = _coerce_exprs(self, other)
3618  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3619 
def __radd__(self, other)
Definition: z3py.py:3610
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.
def __rand__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other & self`.

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

Definition at line 3702 of file z3py.py.

3702  def __rand__(self, other):
3703  """Create the Z3 expression bitwise-or `other & self`.
3704 
3705  >>> x = BitVec('x', 32)
3706  >>> 10 & x
3707  10 & x
3708  """
3709  a, b = _coerce_exprs(self, other)
3710  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3711 
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.
def __rand__(self, other)
Definition: z3py.py:3702
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 3789 of file z3py.py.

3789  def __rdiv__(self, other):
3790  """Create the Z3 expression (signed) division `other / self`.
3791 
3792  Use the function UDiv() for unsigned division.
3793 
3794  >>> x = BitVec('x', 32)
3795  >>> 10 / x
3796  10/x
3797  >>> (10 / x).sexpr()
3798  '(bvsdiv #x0000000a x)'
3799  >>> UDiv(10, x).sexpr()
3800  '(bvudiv #x0000000a x)'
3801  """
3802  a, b = _coerce_exprs(self, other)
3803  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3804 
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.
def __rdiv__(self, other)
Definition: z3py.py:3789
def ctx_ref(self)
Definition: z3py.py:410
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 3970 of file z3py.py.

3970  def __rlshift__(self, other):
3971  """Create the Z3 expression left shift `other << self`.
3972 
3973  Use the function LShR() for the right logical shift
3974 
3975  >>> x = BitVec('x', 32)
3976  >>> 10 << x
3977  10 << x
3978  >>> (10 << x).sexpr()
3979  '(bvshl #x0000000a x)'
3980  """
3981  a, b = _coerce_exprs(self, other)
3982  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3983 
3984 
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.
def ctx_ref(self)
Definition: z3py.py:410
def __rlshift__(self, other)
Definition: z3py.py:3970
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 3830 of file z3py.py.

3830  def __rmod__(self, other):
3831  """Create the Z3 expression (signed) mod `other % self`.
3832 
3833  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3834 
3835  >>> x = BitVec('x', 32)
3836  >>> 10 % x
3837  10%x
3838  >>> (10 % x).sexpr()
3839  '(bvsmod #x0000000a x)'
3840  >>> URem(10, x).sexpr()
3841  '(bvurem #x0000000a x)'
3842  >>> SRem(10, x).sexpr()
3843  '(bvsrem #x0000000a x)'
3844  """
3845  a, b = _coerce_exprs(self, other)
3846  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3847 
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows divisor).
def ctx_ref(self)
Definition: z3py.py:410
def __rmod__(self, other)
Definition: z3py.py:3830
def __rmul__ (   self,
  other 
)
Create the Z3 expression `other * self`.

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

Definition at line 3633 of file z3py.py.

3633  def __rmul__(self, other):
3634  """Create the Z3 expression `other * self`.
3635 
3636  >>> x = BitVec('x', 32)
3637  >>> 10 * x
3638  10*x
3639  """
3640  a, b = _coerce_exprs(self, other)
3641  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3642 
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.
def __rmul__(self, other)
Definition: z3py.py:3633
def __ror__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other | self`.

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

Definition at line 3679 of file z3py.py.

3679  def __ror__(self, other):
3680  """Create the Z3 expression bitwise-or `other | self`.
3681 
3682  >>> x = BitVec('x', 32)
3683  >>> 10 | x
3684  10 | x
3685  """
3686  a, b = _coerce_exprs(self, other)
3687  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3688 
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.
def ctx_ref(self)
Definition: z3py.py:410
def __ror__(self, other)
Definition: z3py.py:3679
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 3956 of file z3py.py.

3956  def __rrshift__(self, other):
3957  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3958 
3959  Use the function LShR() for the right logical shift
3960 
3961  >>> x = BitVec('x', 32)
3962  >>> 10 >> x
3963  10 >> x
3964  >>> (10 >> x).sexpr()
3965  '(bvashr #x0000000a x)'
3966  """
3967  a, b = _coerce_exprs(self, other)
3968  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3969 
def __rrshift__(self, other)
Definition: z3py.py:3956
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.
def ctx_ref(self)
Definition: z3py.py:410
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 3912 of file z3py.py.

3912  def __rshift__(self, other):
3913  """Create the Z3 expression (arithmetical) right shift `self >> other`
3914 
3915  Use the function LShR() for the right logical shift
3916 
3917  >>> x, y = BitVecs('x y', 32)
3918  >>> x >> y
3919  x >> y
3920  >>> (x >> y).sexpr()
3921  '(bvashr x y)'
3922  >>> LShR(x, y).sexpr()
3923  '(bvlshr x y)'
3924  >>> BitVecVal(4, 3)
3925  4
3926  >>> BitVecVal(4, 3).as_signed_long()
3927  -4
3928  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3929  -2
3930  >>> simplify(BitVecVal(4, 3) >> 1)
3931  6
3932  >>> simplify(LShR(BitVecVal(4, 3), 1))
3933  2
3934  >>> simplify(BitVecVal(2, 3) >> 1)
3935  1
3936  >>> simplify(LShR(BitVecVal(2, 3), 1))
3937  1
3938  """
3939  a, b = _coerce_exprs(self, other)
3940  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3941 
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.
def __rshift__(self, other)
Definition: z3py.py:3912
def ctx_ref(self)
Definition: z3py.py:410
def __rsub__ (   self,
  other 
)
Create the Z3 expression `other - self`.

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

Definition at line 3656 of file z3py.py.

3656  def __rsub__(self, other):
3657  """Create the Z3 expression `other - self`.
3658 
3659  >>> x = BitVec('x', 32)
3660  >>> 10 - x
3661  10 - x
3662  """
3663  a, b = _coerce_exprs(self, other)
3664  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3665 
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.
def __rsub__(self, other)
Definition: z3py.py:3656
def __rtruediv__ (   self,
  other 
)
Create the Z3 expression (signed) division `other / self`.

Definition at line 3805 of file z3py.py.

3805  def __rtruediv__(self, other):
3806  """Create the Z3 expression (signed) division `other / self`."""
3807  return self.__rdiv__(other)
3808 
def __rdiv__(self, other)
Definition: z3py.py:3789
def __rtruediv__(self, other)
Definition: z3py.py:3805
def __rxor__ (   self,
  other 
)
Create the Z3 expression bitwise-xor `other ^ self`.

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

Definition at line 3725 of file z3py.py.

3725  def __rxor__(self, other):
3726  """Create the Z3 expression bitwise-xor `other ^ self`.
3727 
3728  >>> x = BitVec('x', 32)
3729  >>> 10 ^ x
3730  10 ^ x
3731  """
3732  a, b = _coerce_exprs(self, other)
3733  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3734 
def __rxor__(self, other)
Definition: z3py.py:3725
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.
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 3643 of file z3py.py.

3643  def __sub__(self, other):
3644  """Create the Z3 expression `self - other`.
3645 
3646  >>> x = BitVec('x', 32)
3647  >>> y = BitVec('y', 32)
3648  >>> x - y
3649  x - y
3650  >>> (x - y).sort()
3651  BitVec(32)
3652  """
3653  a, b = _coerce_exprs(self, other)
3654  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3655 
def __sub__(self, other)
Definition: z3py.py:3643
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.
def __truediv__ (   self,
  other 
)
Create the Z3 expression (signed) division `self / other`.

Definition at line 3785 of file z3py.py.

3785  def __truediv__(self, other):
3786  """Create the Z3 expression (signed) division `self / other`."""
3787  return self.__div__(other)
3788 
def __div__(self, other)
Definition: z3py.py:3766
def __truediv__(self, other)
Definition: z3py.py:3785
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 3712 of file z3py.py.

3712  def __xor__(self, other):
3713  """Create the Z3 expression bitwise-xor `self ^ other`.
3714 
3715  >>> x = BitVec('x', 32)
3716  >>> y = BitVec('y', 32)
3717  >>> x ^ y
3718  x ^ y
3719  >>> (x ^ y).sort()
3720  BitVec(32)
3721  """
3722  a, b = _coerce_exprs(self, other)
3723  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3724 
def __xor__(self, other)
Definition: z3py.py:3712
def ctx_ref(self)
Definition: z3py.py:410
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.
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 3586 of file z3py.py.

Referenced by BitVecNumRef.as_signed_long().

3586  def size(self):
3587  """Return the number of bits of the bit-vector expression `self`.
3588 
3589  >>> x = BitVec('x', 32)
3590  >>> (x + 1).size()
3591  32
3592  >>> Concat(x, x).size()
3593  64
3594  """
3595  return self.sort().size()
3596 
def sort(self)
Definition: z3py.py:1014
def size(self)
Definition: z3py.py:3586
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

Definition at line 3575 of file z3py.py.

Referenced by BitVecRef.__add__(), BitVecRef.__and__(), BitVecRef.__div__(), BitVecRef.__mod__(), BitVecRef.__mul__(), BitVecRef.__or__(), BitVecRef.__sub__(), and BitVecRef.__xor__().

3575  def sort(self):
3576  """Return the sort of the bit-vector expression `self`.
3577 
3578  >>> x = BitVec('x', 32)
3579  >>> x.sort()
3580  BitVec(32)
3581  >>> x.sort() == BitVecSort(32)
3582  True
3583  """
3584  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3585 
def as_ast(self)
Definition: z3py.py:402
Bit-Vectors.
Definition: z3py.py:3528
def sort(self)
Definition: z3py.py:3575
def ctx_ref(self)
Definition: z3py.py:410
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.