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 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__ (self, ast, ctx=None)
 
def __del__ (self)
 
def __deepcopy__ (self, memo={})
 
def __str__ (self)
 
def __repr__ (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __nonzero__ (self)
 
def __bool__ (self)
 
def sexpr (self)
 
def as_ast (self)
 
def get_id (self)
 
def ctx_ref (self)
 
def eq (self, other)
 
def translate (self, target)
 
def __copy__ (self)
 
def hash (self)
 
- Public Member Functions inherited from Z3PPObject
def use_pp (self)
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

Bit-vector expressions.

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

3503 def __add__(self, other):
3504 """Create the Z3 expression `self + other`.
3505
3506 >>> x = BitVec('x', 32)
3507 >>> y = BitVec('y', 32)
3508 >>> x + y
3509 x + y
3510 >>> (x + y).sort()
3511 BitVec(32)
3512 """
3513 a, b = _coerce_exprs(self, other)
3514 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3515
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.
def BitVec(name, bv, ctx=None)
Definition: z3py.py:4028

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

3595 def __and__(self, other):
3596 """Create the Z3 expression bitwise-and `self & other`.
3597
3598 >>> x = BitVec('x', 32)
3599 >>> y = BitVec('y', 32)
3600 >>> x & y
3601 x & y
3602 >>> (x & y).sort()
3603 BitVec(32)
3604 """
3605 a, b = _coerce_exprs(self, other)
3606 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3607
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 3672 of file z3py.py.

3672 def __div__(self, other):
3673 """Create the Z3 expression (signed) division `self / other`.
3674
3675 Use the function UDiv() for unsigned division.
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 >>> (x / y).sexpr()
3684 '(bvsdiv x y)'
3685 >>> UDiv(x, y).sexpr()
3686 '(bvudiv x y)'
3687 """
3688 a, b = _coerce_exprs(self, other)
3689 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3690
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.
def UDiv(a, b)
Definition: z3py.py:4227

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

3802 def __ge__(self, other):
3803 """Create the Z3 expression (signed) `other >= self`.
3804
3805 Use the function UGE() for unsigned greater than or equal to.
3806
3807 >>> x, y = BitVecs('x y', 32)
3808 >>> x >= y
3809 x >= y
3810 >>> (x >= y).sexpr()
3811 '(bvsge x y)'
3812 >>> UGE(x, y).sexpr()
3813 '(bvuge x y)'
3814 """
3815 a, b = _coerce_exprs(self, other)
3816 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3817
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 UGE(a, b)
Definition: z3py.py:4191
def BitVecs(names, bv, ctx=None)
Definition: z3py.py:4052

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

3786 def __gt__(self, other):
3787 """Create the Z3 expression (signed) `other > self`.
3788
3789 Use the function UGT() for unsigned greater than.
3790
3791 >>> x, y = BitVecs('x y', 32)
3792 >>> x > y
3793 x > y
3794 >>> (x > y).sexpr()
3795 '(bvsgt x y)'
3796 >>> UGT(x, y).sexpr()
3797 '(bvugt x y)'
3798 """
3799 a, b = _coerce_exprs(self, other)
3800 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3801
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.
def UGT(a, b)
Definition: z3py.py:4209

◆ __invert__()

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

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

Definition at line 3661 of file z3py.py.

3661 def __invert__(self):
3662 """Create the Z3 expression bitwise-not `~self`.
3663
3664 >>> x = BitVec('x', 32)
3665 >>> ~x
3666 ~x
3667 >>> simplify(~(~x))
3668 x
3669 """
3670 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3671
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.
def simplify(a, *arguments, **keywords)
Utils.
Definition: z3py.py:8746

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

3754 def __le__(self, other):
3755 """Create the Z3 expression (signed) `other <= self`.
3756
3757 Use the function ULE() for unsigned less than or equal to.
3758
3759 >>> x, y = BitVecs('x y', 32)
3760 >>> x <= y
3761 x <= y
3762 >>> (x <= y).sexpr()
3763 '(bvsle x y)'
3764 >>> ULE(x, y).sexpr()
3765 '(bvule x y)'
3766 """
3767 a, b = _coerce_exprs(self, other)
3768 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3769
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 ULE(a, b)
Definition: z3py.py:4155

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

3848 def __lshift__(self, other):
3849 """Create the Z3 expression left shift `self << other`
3850
3851 >>> x, y = BitVecs('x y', 32)
3852 >>> x << y
3853 x << y
3854 >>> (x << y).sexpr()
3855 '(bvshl x y)'
3856 >>> simplify(BitVecVal(2, 3) << 1)
3857 4
3858 """
3859 a, b = _coerce_exprs(self, other)
3860 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3861
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.
def BitVecVal(val, bv, ctx=None)
Definition: z3py.py:4011

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

3770 def __lt__(self, other):
3771 """Create the Z3 expression (signed) `other < self`.
3772
3773 Use the function ULT() for unsigned less than.
3774
3775 >>> x, y = BitVecs('x y', 32)
3776 >>> x < y
3777 x < y
3778 >>> (x < y).sexpr()
3779 '(bvslt x y)'
3780 >>> ULT(x, y).sexpr()
3781 '(bvult x y)'
3782 """
3783 a, b = _coerce_exprs(self, other)
3784 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3785
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than.
def ULT(a, b)
Definition: z3py.py:4173

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

3715 def __mod__(self, other):
3716 """Create the Z3 expression (signed) mod `self % other`.
3717
3718 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3719
3720 >>> x = BitVec('x', 32)
3721 >>> y = BitVec('y', 32)
3722 >>> x % y
3723 x%y
3724 >>> (x % y).sort()
3725 BitVec(32)
3726 >>> (x % y).sexpr()
3727 '(bvsmod x y)'
3728 >>> URem(x, y).sexpr()
3729 '(bvurem x y)'
3730 >>> SRem(x, y).sexpr()
3731 '(bvsrem x y)'
3732 """
3733 a, b = _coerce_exprs(self, other)
3734 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3735
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 SRem(a, b)
Definition: z3py.py:4269
def URem(a, b)
Definition: z3py.py:4248

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

3526 def __mul__(self, other):
3527 """Create the Z3 expression `self * other`.
3528
3529 >>> x = BitVec('x', 32)
3530 >>> y = BitVec('y', 32)
3531 >>> x * y
3532 x*y
3533 >>> (x * y).sort()
3534 BitVec(32)
3535 """
3536 a, b = _coerce_exprs(self, other)
3537 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3538
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 3650 of file z3py.py.

3650 def __neg__(self):
3651 """Return an expression representing `-self`.
3652
3653 >>> x = BitVec('x', 32)
3654 >>> -x
3655 -x
3656 >>> simplify(-(-x))
3657 x
3658 """
3659 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3660
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 3572 of file z3py.py.

3572 def __or__(self, other):
3573 """Create the Z3 expression bitwise-or `self | other`.
3574
3575 >>> x = BitVec('x', 32)
3576 >>> y = BitVec('y', 32)
3577 >>> x | y
3578 x | y
3579 >>> (x | y).sort()
3580 BitVec(32)
3581 """
3582 a, b = _coerce_exprs(self, other)
3583 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3584
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 3641 of file z3py.py.

3641 def __pos__(self):
3642 """Return `self`.
3643
3644 >>> x = BitVec('x', 32)
3645 >>> +x
3646 x
3647 """
3648 return self
3649

◆ __radd__()

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

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

Definition at line 3516 of file z3py.py.

3516 def __radd__(self, other):
3517 """Create the Z3 expression `other + self`.
3518
3519 >>> x = BitVec('x', 32)
3520 >>> 10 + x
3521 10 + x
3522 """
3523 a, b = _coerce_exprs(self, other)
3524 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3525

◆ __rand__()

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

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

Definition at line 3608 of file z3py.py.

3608 def __rand__(self, other):
3609 """Create the Z3 expression bitwise-or `other & self`.
3610
3611 >>> x = BitVec('x', 32)
3612 >>> 10 & x
3613 10 & x
3614 """
3615 a, b = _coerce_exprs(self, other)
3616 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3617

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

3695 def __rdiv__(self, other):
3696 """Create the Z3 expression (signed) division `other / self`.
3697
3698 Use the function UDiv() for unsigned division.
3699
3700 >>> x = BitVec('x', 32)
3701 >>> 10 / x
3702 10/x
3703 >>> (10 / x).sexpr()
3704 '(bvsdiv #x0000000a x)'
3705 >>> UDiv(10, x).sexpr()
3706 '(bvudiv #x0000000a x)'
3707 """
3708 a, b = _coerce_exprs(self, other)
3709 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3710

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

3876 def __rlshift__(self, other):
3877 """Create the Z3 expression left shift `other << self`.
3878
3879 Use the function LShR() for the right logical shift
3880
3881 >>> x = BitVec('x', 32)
3882 >>> 10 << x
3883 10 << x
3884 >>> (10 << x).sexpr()
3885 '(bvshl #x0000000a x)'
3886 """
3887 a, b = _coerce_exprs(self, other)
3888 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3889
3890
def LShR(a, b)
Definition: z3py.py:4290

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

3736 def __rmod__(self, other):
3737 """Create the Z3 expression (signed) mod `other % self`.
3738
3739 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3740
3741 >>> x = BitVec('x', 32)
3742 >>> 10 % x
3743 10%x
3744 >>> (10 % x).sexpr()
3745 '(bvsmod #x0000000a x)'
3746 >>> URem(10, x).sexpr()
3747 '(bvurem #x0000000a x)'
3748 >>> SRem(10, x).sexpr()
3749 '(bvsrem #x0000000a x)'
3750 """
3751 a, b = _coerce_exprs(self, other)
3752 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3753

◆ __rmul__()

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

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

Definition at line 3539 of file z3py.py.

3539 def __rmul__(self, other):
3540 """Create the Z3 expression `other * self`.
3541
3542 >>> x = BitVec('x', 32)
3543 >>> 10 * x
3544 10*x
3545 """
3546 a, b = _coerce_exprs(self, other)
3547 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3548

◆ __ror__()

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

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

Definition at line 3585 of file z3py.py.

3585 def __ror__(self, other):
3586 """Create the Z3 expression bitwise-or `other | self`.
3587
3588 >>> x = BitVec('x', 32)
3589 >>> 10 | x
3590 10 | x
3591 """
3592 a, b = _coerce_exprs(self, other)
3593 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3594

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

3862 def __rrshift__(self, other):
3863 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3864
3865 Use the function LShR() for the right logical shift
3866
3867 >>> x = BitVec('x', 32)
3868 >>> 10 >> x
3869 10 >> x
3870 >>> (10 >> x).sexpr()
3871 '(bvashr #x0000000a x)'
3872 """
3873 a, b = _coerce_exprs(self, other)
3874 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3875
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 3818 of file z3py.py.

3818 def __rshift__(self, other):
3819 """Create the Z3 expression (arithmetical) right shift `self >> other`
3820
3821 Use the function LShR() for the right logical shift
3822
3823 >>> x, y = BitVecs('x y', 32)
3824 >>> x >> y
3825 x >> y
3826 >>> (x >> y).sexpr()
3827 '(bvashr x y)'
3828 >>> LShR(x, y).sexpr()
3829 '(bvlshr x y)'
3830 >>> BitVecVal(4, 3)
3831 4
3832 >>> BitVecVal(4, 3).as_signed_long()
3833 -4
3834 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3835 -2
3836 >>> simplify(BitVecVal(4, 3) >> 1)
3837 6
3838 >>> simplify(LShR(BitVecVal(4, 3), 1))
3839 2
3840 >>> simplify(BitVecVal(2, 3) >> 1)
3841 1
3842 >>> simplify(LShR(BitVecVal(2, 3), 1))
3843 1
3844 """
3845 a, b = _coerce_exprs(self, other)
3846 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3847

◆ __rsub__()

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

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

Definition at line 3562 of file z3py.py.

3562 def __rsub__(self, other):
3563 """Create the Z3 expression `other - self`.
3564
3565 >>> x = BitVec('x', 32)
3566 >>> 10 - x
3567 10 - x
3568 """
3569 a, b = _coerce_exprs(self, other)
3570 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3571
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 3711 of file z3py.py.

3711 def __rtruediv__(self, other):
3712 """Create the Z3 expression (signed) division `other / self`."""
3713 return self.__rdiv__(other)
3714

◆ __rxor__()

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

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

Definition at line 3631 of file z3py.py.

3631 def __rxor__(self, other):
3632 """Create the Z3 expression bitwise-xor `other ^ self`.
3633
3634 >>> x = BitVec('x', 32)
3635 >>> 10 ^ x
3636 10 ^ x
3637 """
3638 a, b = _coerce_exprs(self, other)
3639 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3640
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 3549 of file z3py.py.

3549 def __sub__(self, other):
3550 """Create the Z3 expression `self - other`.
3551
3552 >>> x = BitVec('x', 32)
3553 >>> y = BitVec('y', 32)
3554 >>> x - y
3555 x - y
3556 >>> (x - y).sort()
3557 BitVec(32)
3558 """
3559 a, b = _coerce_exprs(self, other)
3560 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3561

◆ __truediv__()

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

Definition at line 3691 of file z3py.py.

3691 def __truediv__(self, other):
3692 """Create the Z3 expression (signed) division `self / other`."""
3693 return self.__div__(other)
3694

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

3618 def __xor__(self, other):
3619 """Create the Z3 expression bitwise-xor `self ^ other`.
3620
3621 >>> x = BitVec('x', 32)
3622 >>> y = BitVec('y', 32)
3623 >>> x ^ y
3624 x ^ y
3625 >>> (x ^ y).sort()
3626 BitVec(32)
3627 """
3628 a, b = _coerce_exprs(self, other)
3629 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3630

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

3492 def size(self):
3493 """Return the number of bits of the bit-vector expression `self`.
3494
3495 >>> x = BitVec('x', 32)
3496 >>> (x + 1).size()
3497 32
3498 >>> Concat(x, x).size()
3499 64
3500 """
3501 return self.sort().size()
3502
def Concat(*args)
Definition: z3py.py:4073

Referenced by ParamDescrsRef.__len__(), Goal.__len__(), BitVecNumRef.as_signed_long(), BitVecRef.size(), 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 3481 of file z3py.py.

3481 def sort(self):
3482 """Return the sort of the bit-vector expression `self`.
3483
3484 >>> x = BitVec('x', 32)
3485 >>> x.sort()
3486 BitVec(32)
3487 >>> x.sort() == BitVecSort(32)
3488 True
3489 """
3490 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3491
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.
def BitVecSort(sz, ctx=None)
Definition: z3py.py:3996

Referenced by BitVecRef.__add__(), BitVecRef.__and__(), BitVecRef.__div__(), BitVecRef.__mod__(), BitVecRef.__mul__(), BitVecRef.__or__(), BitVecRef.__sub__(), BitVecRef.__xor__(), FPNumRef.as_string(), ArrayRef.domain(), ArrayRef.domain_n(), FPRef.ebits(), ArithRef.is_int(), ArithRef.is_real(), ArrayRef.range(), FPRef.sbits(), BitVecRef.size(), and ExprRef.sort_kind().