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 update (self, args)
 
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 3649 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 3674 of file z3py.py.

3674  def __add__(self, other):
3675  """Create the Z3 expression `self + other`.
3676 
3677  >>> x = BitVec('x', 32)
3678  >>> y = BitVec('y', 32)
3679  >>> x + y
3680  x + y
3681  >>> (x + y).sort()
3682  BitVec(32)
3683  """
3684  a, b = _coerce_exprs(self, other)
3685  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3686 
def __add__(self, other)
Definition: z3py.py:3674
def ctx_ref(self)
Definition: z3py.py:427
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 3766 of file z3py.py.

3766  def __and__(self, other):
3767  """Create the Z3 expression bitwise-and `self & other`.
3768 
3769  >>> x = BitVec('x', 32)
3770  >>> y = BitVec('y', 32)
3771  >>> x & y
3772  x & y
3773  >>> (x & y).sort()
3774  BitVec(32)
3775  """
3776  a, b = _coerce_exprs(self, other)
3777  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3778 
def __and__(self, other)
Definition: z3py.py:3766
def ctx_ref(self)
Definition: z3py.py:427
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 3843 of file z3py.py.

3843  def __div__(self, other):
3844  """Create the Z3 expression (signed) division `self / other`.
3845 
3846  Use the function UDiv() for unsigned division.
3847 
3848  >>> x = BitVec('x', 32)
3849  >>> y = BitVec('y', 32)
3850  >>> x / y
3851  x/y
3852  >>> (x / y).sort()
3853  BitVec(32)
3854  >>> (x / y).sexpr()
3855  '(bvsdiv x y)'
3856  >>> UDiv(x, y).sexpr()
3857  '(bvudiv x y)'
3858  """
3859  a, b = _coerce_exprs(self, other)
3860  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3861 
def __div__(self, other)
Definition: z3py.py:3843
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:427
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 3973 of file z3py.py.

3973  def __ge__(self, other):
3974  """Create the Z3 expression (signed) `other >= self`.
3975 
3976  Use the function UGE() for unsigned greater than or equal to.
3977 
3978  >>> x, y = BitVecs('x y', 32)
3979  >>> x >= y
3980  x >= y
3981  >>> (x >= y).sexpr()
3982  '(bvsge x y)'
3983  >>> UGE(x, y).sexpr()
3984  '(bvuge x y)'
3985  """
3986  a, b = _coerce_exprs(self, other)
3987  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3988 
def __ge__(self, other)
Definition: z3py.py:3973
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:427
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 3957 of file z3py.py.

3957  def __gt__(self, other):
3958  """Create the Z3 expression (signed) `other > self`.
3959 
3960  Use the function UGT() for unsigned greater than.
3961 
3962  >>> x, y = BitVecs('x y', 32)
3963  >>> x > y
3964  x > y
3965  >>> (x > y).sexpr()
3966  '(bvsgt x y)'
3967  >>> UGT(x, y).sexpr()
3968  '(bvugt x y)'
3969  """
3970  a, b = _coerce_exprs(self, other)
3971  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3972 
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:3957
def ctx_ref(self)
Definition: z3py.py:427
def __invert__ (   self)
Create the Z3 expression bitwise-not `~self`.

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

Definition at line 3832 of file z3py.py.

3832  def __invert__(self):
3833  """Create the Z3 expression bitwise-not `~self`.
3834 
3835  >>> x = BitVec('x', 32)
3836  >>> ~x
3837  ~x
3838  >>> simplify(~(~x))
3839  x
3840  """
3841  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3842 
def as_ast(self)
Definition: z3py.py:419
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.
def ctx_ref(self)
Definition: z3py.py:427
def __invert__(self)
Definition: z3py.py:3832
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 3925 of file z3py.py.

3925  def __le__(self, other):
3926  """Create the Z3 expression (signed) `other <= self`.
3927 
3928  Use the function ULE() for unsigned less than or equal to.
3929 
3930  >>> x, y = BitVecs('x y', 32)
3931  >>> x <= y
3932  x <= y
3933  >>> (x <= y).sexpr()
3934  '(bvsle x y)'
3935  >>> ULE(x, y).sexpr()
3936  '(bvule x y)'
3937  """
3938  a, b = _coerce_exprs(self, other)
3939  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3940 
def __le__(self, other)
Definition: z3py.py:3925
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:427
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 4019 of file z3py.py.

4019  def __lshift__(self, other):
4020  """Create the Z3 expression left shift `self << other`
4021 
4022  >>> x, y = BitVecs('x y', 32)
4023  >>> x << y
4024  x << y
4025  >>> (x << y).sexpr()
4026  '(bvshl x y)'
4027  >>> simplify(BitVecVal(2, 3) << 1)
4028  4
4029  """
4030  a, b = _coerce_exprs(self, other)
4031  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4032 
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:427
def __lshift__(self, other)
Definition: z3py.py:4019
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 3941 of file z3py.py.

3941  def __lt__(self, other):
3942  """Create the Z3 expression (signed) `other < self`.
3943 
3944  Use the function ULT() for unsigned less than.
3945 
3946  >>> x, y = BitVecs('x y', 32)
3947  >>> x < y
3948  x < y
3949  >>> (x < y).sexpr()
3950  '(bvslt x y)'
3951  >>> ULT(x, y).sexpr()
3952  '(bvult x y)'
3953  """
3954  a, b = _coerce_exprs(self, other)
3955  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3956 
def __lt__(self, other)
Definition: z3py.py:3941
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:427
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 3886 of file z3py.py.

3886  def __mod__(self, other):
3887  """Create the Z3 expression (signed) mod `self % other`.
3888 
3889  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3890 
3891  >>> x = BitVec('x', 32)
3892  >>> y = BitVec('y', 32)
3893  >>> x % y
3894  x%y
3895  >>> (x % y).sort()
3896  BitVec(32)
3897  >>> (x % y).sexpr()
3898  '(bvsmod x y)'
3899  >>> URem(x, y).sexpr()
3900  '(bvurem x y)'
3901  >>> SRem(x, y).sexpr()
3902  '(bvsrem x y)'
3903  """
3904  a, b = _coerce_exprs(self, other)
3905  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3906 
def __mod__(self, other)
Definition: z3py.py:3886
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:427
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 3697 of file z3py.py.

3697  def __mul__(self, other):
3698  """Create the Z3 expression `self * other`.
3699 
3700  >>> x = BitVec('x', 32)
3701  >>> y = BitVec('y', 32)
3702  >>> x * y
3703  x*y
3704  >>> (x * y).sort()
3705  BitVec(32)
3706  """
3707  a, b = _coerce_exprs(self, other)
3708  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3709 
def __mul__(self, other)
Definition: z3py.py:3697
def ctx_ref(self)
Definition: z3py.py:427
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 3821 of file z3py.py.

3821  def __neg__(self):
3822  """Return an expression representing `-self`.
3823 
3824  >>> x = BitVec('x', 32)
3825  >>> -x
3826  -x
3827  >>> simplify(-(-x))
3828  x
3829  """
3830  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3831 
def as_ast(self)
Definition: z3py.py:419
def __neg__(self)
Definition: z3py.py:3821
def ctx_ref(self)
Definition: z3py.py:427
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 3743 of file z3py.py.

3743  def __or__(self, other):
3744  """Create the Z3 expression bitwise-or `self | other`.
3745 
3746  >>> x = BitVec('x', 32)
3747  >>> y = BitVec('y', 32)
3748  >>> x | y
3749  x | y
3750  >>> (x | y).sort()
3751  BitVec(32)
3752  """
3753  a, b = _coerce_exprs(self, other)
3754  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3755 
def __or__(self, other)
Definition: z3py.py:3743
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:427
def __pos__ (   self)
Return `self`.

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

Definition at line 3812 of file z3py.py.

3812  def __pos__(self):
3813  """Return `self`.
3814 
3815  >>> x = BitVec('x', 32)
3816  >>> +x
3817  x
3818  """
3819  return self
3820 
def __pos__(self)
Definition: z3py.py:3812
def __radd__ (   self,
  other 
)
Create the Z3 expression `other + self`.

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

Definition at line 3687 of file z3py.py.

3687  def __radd__(self, other):
3688  """Create the Z3 expression `other + self`.
3689 
3690  >>> x = BitVec('x', 32)
3691  >>> 10 + x
3692  10 + x
3693  """
3694  a, b = _coerce_exprs(self, other)
3695  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3696 
def __radd__(self, other)
Definition: z3py.py:3687
def ctx_ref(self)
Definition: z3py.py:427
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 3779 of file z3py.py.

3779  def __rand__(self, other):
3780  """Create the Z3 expression bitwise-or `other & self`.
3781 
3782  >>> x = BitVec('x', 32)
3783  >>> 10 & x
3784  10 & x
3785  """
3786  a, b = _coerce_exprs(self, other)
3787  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3788 
def ctx_ref(self)
Definition: z3py.py:427
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:3779
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 3866 of file z3py.py.

3866  def __rdiv__(self, other):
3867  """Create the Z3 expression (signed) division `other / self`.
3868 
3869  Use the function UDiv() for unsigned division.
3870 
3871  >>> x = BitVec('x', 32)
3872  >>> 10 / x
3873  10/x
3874  >>> (10 / x).sexpr()
3875  '(bvsdiv #x0000000a x)'
3876  >>> UDiv(10, x).sexpr()
3877  '(bvudiv #x0000000a x)'
3878  """
3879  a, b = _coerce_exprs(self, other)
3880  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3881 
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:3866
def ctx_ref(self)
Definition: z3py.py:427
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 4047 of file z3py.py.

4047  def __rlshift__(self, other):
4048  """Create the Z3 expression left shift `other << self`.
4049 
4050  Use the function LShR() for the right logical shift
4051 
4052  >>> x = BitVec('x', 32)
4053  >>> 10 << x
4054  10 << x
4055  >>> (10 << x).sexpr()
4056  '(bvshl #x0000000a x)'
4057  """
4058  a, b = _coerce_exprs(self, other)
4059  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4060 
4061 
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:427
def __rlshift__(self, other)
Definition: z3py.py:4047
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 3907 of file z3py.py.

3907  def __rmod__(self, other):
3908  """Create the Z3 expression (signed) mod `other % self`.
3909 
3910  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3911 
3912  >>> x = BitVec('x', 32)
3913  >>> 10 % x
3914  10%x
3915  >>> (10 % x).sexpr()
3916  '(bvsmod #x0000000a x)'
3917  >>> URem(10, x).sexpr()
3918  '(bvurem #x0000000a x)'
3919  >>> SRem(10, x).sexpr()
3920  '(bvsrem #x0000000a x)'
3921  """
3922  a, b = _coerce_exprs(self, other)
3923  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3924 
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:427
def __rmod__(self, other)
Definition: z3py.py:3907
def __rmul__ (   self,
  other 
)
Create the Z3 expression `other * self`.

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

Definition at line 3710 of file z3py.py.

3710  def __rmul__(self, other):
3711  """Create the Z3 expression `other * self`.
3712 
3713  >>> x = BitVec('x', 32)
3714  >>> 10 * x
3715  10*x
3716  """
3717  a, b = _coerce_exprs(self, other)
3718  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3719 
def ctx_ref(self)
Definition: z3py.py:427
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:3710
def __ror__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other | self`.

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

Definition at line 3756 of file z3py.py.

3756  def __ror__(self, other):
3757  """Create the Z3 expression bitwise-or `other | self`.
3758 
3759  >>> x = BitVec('x', 32)
3760  >>> 10 | x
3761  10 | x
3762  """
3763  a, b = _coerce_exprs(self, other)
3764  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3765 
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:427
def __ror__(self, other)
Definition: z3py.py:3756
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 4033 of file z3py.py.

4033  def __rrshift__(self, other):
4034  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
4035 
4036  Use the function LShR() for the right logical shift
4037 
4038  >>> x = BitVec('x', 32)
4039  >>> 10 >> x
4040  10 >> x
4041  >>> (10 >> x).sexpr()
4042  '(bvashr #x0000000a x)'
4043  """
4044  a, b = _coerce_exprs(self, other)
4045  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4046 
def __rrshift__(self, other)
Definition: z3py.py:4033
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:427
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 3989 of file z3py.py.

3989  def __rshift__(self, other):
3990  """Create the Z3 expression (arithmetical) right shift `self >> other`
3991 
3992  Use the function LShR() for the right logical shift
3993 
3994  >>> x, y = BitVecs('x y', 32)
3995  >>> x >> y
3996  x >> y
3997  >>> (x >> y).sexpr()
3998  '(bvashr x y)'
3999  >>> LShR(x, y).sexpr()
4000  '(bvlshr x y)'
4001  >>> BitVecVal(4, 3)
4002  4
4003  >>> BitVecVal(4, 3).as_signed_long()
4004  -4
4005  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
4006  -2
4007  >>> simplify(BitVecVal(4, 3) >> 1)
4008  6
4009  >>> simplify(LShR(BitVecVal(4, 3), 1))
4010  2
4011  >>> simplify(BitVecVal(2, 3) >> 1)
4012  1
4013  >>> simplify(LShR(BitVecVal(2, 3), 1))
4014  1
4015  """
4016  a, b = _coerce_exprs(self, other)
4017  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4018 
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:3989
def ctx_ref(self)
Definition: z3py.py:427
def __rsub__ (   self,
  other 
)
Create the Z3 expression `other - self`.

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

Definition at line 3733 of file z3py.py.

3733  def __rsub__(self, other):
3734  """Create the Z3 expression `other - self`.
3735 
3736  >>> x = BitVec('x', 32)
3737  >>> 10 - x
3738  10 - x
3739  """
3740  a, b = _coerce_exprs(self, other)
3741  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3742 
def ctx_ref(self)
Definition: z3py.py:427
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:3733
def __rtruediv__ (   self,
  other 
)
Create the Z3 expression (signed) division `other / self`.

Definition at line 3882 of file z3py.py.

3882  def __rtruediv__(self, other):
3883  """Create the Z3 expression (signed) division `other / self`."""
3884  return self.__rdiv__(other)
3885 
def __rdiv__(self, other)
Definition: z3py.py:3866
def __rtruediv__(self, other)
Definition: z3py.py:3882
def __rxor__ (   self,
  other 
)
Create the Z3 expression bitwise-xor `other ^ self`.

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

Definition at line 3802 of file z3py.py.

3802  def __rxor__(self, other):
3803  """Create the Z3 expression bitwise-xor `other ^ self`.
3804 
3805  >>> x = BitVec('x', 32)
3806  >>> 10 ^ x
3807  10 ^ x
3808  """
3809  a, b = _coerce_exprs(self, other)
3810  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3811 
def __rxor__(self, other)
Definition: z3py.py:3802
def ctx_ref(self)
Definition: z3py.py:427
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 3720 of file z3py.py.

3720  def __sub__(self, other):
3721  """Create the Z3 expression `self - other`.
3722 
3723  >>> x = BitVec('x', 32)
3724  >>> y = BitVec('y', 32)
3725  >>> x - y
3726  x - y
3727  >>> (x - y).sort()
3728  BitVec(32)
3729  """
3730  a, b = _coerce_exprs(self, other)
3731  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3732 
def __sub__(self, other)
Definition: z3py.py:3720
def ctx_ref(self)
Definition: z3py.py:427
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 3862 of file z3py.py.

3862  def __truediv__(self, other):
3863  """Create the Z3 expression (signed) division `self / other`."""
3864  return self.__div__(other)
3865 
def __div__(self, other)
Definition: z3py.py:3843
def __truediv__(self, other)
Definition: z3py.py:3862
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 3789 of file z3py.py.

3789  def __xor__(self, other):
3790  """Create the Z3 expression bitwise-xor `self ^ other`.
3791 
3792  >>> x = BitVec('x', 32)
3793  >>> y = BitVec('y', 32)
3794  >>> x ^ y
3795  x ^ y
3796  >>> (x ^ y).sort()
3797  BitVec(32)
3798  """
3799  a, b = _coerce_exprs(self, other)
3800  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3801 
def __xor__(self, other)
Definition: z3py.py:3789
def ctx_ref(self)
Definition: z3py.py:427
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 3663 of file z3py.py.

Referenced by BitVecNumRef.as_signed_long().

3663  def size(self):
3664  """Return the number of bits of the bit-vector expression `self`.
3665 
3666  >>> x = BitVec('x', 32)
3667  >>> (x + 1).size()
3668  32
3669  >>> Concat(x, x).size()
3670  64
3671  """
3672  return self.sort().size()
3673 
def sort(self)
Definition: z3py.py:1035
def size(self)
Definition: z3py.py:3663
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 3652 of file z3py.py.

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

3652  def sort(self):
3653  """Return the sort of the bit-vector expression `self`.
3654 
3655  >>> x = BitVec('x', 32)
3656  >>> x.sort()
3657  BitVec(32)
3658  >>> x.sort() == BitVecSort(32)
3659  True
3660  """
3661  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3662 
def as_ast(self)
Definition: z3py.py:419
Bit-Vectors.
Definition: z3py.py:3605
def sort(self)
Definition: z3py.py:3652
def ctx_ref(self)
Definition: z3py.py:427
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.