Z3
 
Loading...
Searching...
No Matches
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
 
- Protected Member Functions inherited from Z3PPObject
def _repr_html_ (self)
 

Detailed Description

Bit-vector expressions.

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

3512 def __add__(self, other):
3513 """Create the Z3 expression `self + other`.
3514
3515 >>> x = BitVec('x', 32)
3516 >>> y = BitVec('y', 32)
3517 >>> x + y
3518 x + y
3519 >>> (x + y).sort()
3520 BitVec(32)
3521 """
3522 a, b = _coerce_exprs(self, other)
3523 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3524
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 3604 of file z3py.py.

3604 def __and__(self, other):
3605 """Create the Z3 expression bitwise-and `self & other`.
3606
3607 >>> x = BitVec('x', 32)
3608 >>> y = BitVec('y', 32)
3609 >>> x & y
3610 x & y
3611 >>> (x & y).sort()
3612 BitVec(32)
3613 """
3614 a, b = _coerce_exprs(self, other)
3615 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3616
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 3681 of file z3py.py.

3681 def __div__(self, other):
3682 """Create the Z3 expression (signed) division `self / other`.
3683
3684 Use the function UDiv() for unsigned division.
3685
3686 >>> x = BitVec('x', 32)
3687 >>> y = BitVec('y', 32)
3688 >>> x / y
3689 x/y
3690 >>> (x / y).sort()
3691 BitVec(32)
3692 >>> (x / y).sexpr()
3693 '(bvsdiv x y)'
3694 >>> UDiv(x, y).sexpr()
3695 '(bvudiv x y)'
3696 """
3697 a, b = _coerce_exprs(self, other)
3698 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3699
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 3811 of file z3py.py.

3811 def __ge__(self, other):
3812 """Create the Z3 expression (signed) `other >= self`.
3813
3814 Use the function UGE() for unsigned greater than or equal to.
3815
3816 >>> x, y = BitVecs('x y', 32)
3817 >>> x >= y
3818 x >= y
3819 >>> (x >= y).sexpr()
3820 '(bvsge x y)'
3821 >>> UGE(x, y).sexpr()
3822 '(bvuge x y)'
3823 """
3824 a, b = _coerce_exprs(self, other)
3825 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3826
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 3795 of file z3py.py.

3795 def __gt__(self, other):
3796 """Create the Z3 expression (signed) `other > self`.
3797
3798 Use the function UGT() for unsigned greater than.
3799
3800 >>> x, y = BitVecs('x y', 32)
3801 >>> x > y
3802 x > y
3803 >>> (x > y).sexpr()
3804 '(bvsgt x y)'
3805 >>> UGT(x, y).sexpr()
3806 '(bvugt x y)'
3807 """
3808 a, b = _coerce_exprs(self, other)
3809 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3810
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 3670 of file z3py.py.

3670 def __invert__(self):
3671 """Create the Z3 expression bitwise-not `~self`.
3672
3673 >>> x = BitVec('x', 32)
3674 >>> ~x
3675 ~x
3676 >>> simplify(~(~x))
3677 x
3678 """
3679 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3680
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 3763 of file z3py.py.

3763 def __le__(self, other):
3764 """Create the Z3 expression (signed) `other <= self`.
3765
3766 Use the function ULE() for unsigned less than or equal to.
3767
3768 >>> x, y = BitVecs('x y', 32)
3769 >>> x <= y
3770 x <= y
3771 >>> (x <= y).sexpr()
3772 '(bvsle x y)'
3773 >>> ULE(x, y).sexpr()
3774 '(bvule x y)'
3775 """
3776 a, b = _coerce_exprs(self, other)
3777 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3778
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 3857 of file z3py.py.

3857 def __lshift__(self, other):
3858 """Create the Z3 expression left shift `self << other`
3859
3860 >>> x, y = BitVecs('x y', 32)
3861 >>> x << y
3862 x << y
3863 >>> (x << y).sexpr()
3864 '(bvshl x y)'
3865 >>> simplify(BitVecVal(2, 3) << 1)
3866 4
3867 """
3868 a, b = _coerce_exprs(self, other)
3869 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3870
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 3779 of file z3py.py.

3779 def __lt__(self, other):
3780 """Create the Z3 expression (signed) `other < self`.
3781
3782 Use the function ULT() for unsigned less than.
3783
3784 >>> x, y = BitVecs('x y', 32)
3785 >>> x < y
3786 x < y
3787 >>> (x < y).sexpr()
3788 '(bvslt x y)'
3789 >>> ULT(x, y).sexpr()
3790 '(bvult x y)'
3791 """
3792 a, b = _coerce_exprs(self, other)
3793 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3794
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 3724 of file z3py.py.

3724 def __mod__(self, other):
3725 """Create the Z3 expression (signed) mod `self % other`.
3726
3727 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3728
3729 >>> x = BitVec('x', 32)
3730 >>> y = BitVec('y', 32)
3731 >>> x % y
3732 x%y
3733 >>> (x % y).sort()
3734 BitVec(32)
3735 >>> (x % y).sexpr()
3736 '(bvsmod x y)'
3737 >>> URem(x, y).sexpr()
3738 '(bvurem x y)'
3739 >>> SRem(x, y).sexpr()
3740 '(bvsrem x y)'
3741 """
3742 a, b = _coerce_exprs(self, other)
3743 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3744
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 3535 of file z3py.py.

3535 def __mul__(self, other):
3536 """Create the Z3 expression `self * other`.
3537
3538 >>> x = BitVec('x', 32)
3539 >>> y = BitVec('y', 32)
3540 >>> x * y
3541 x*y
3542 >>> (x * y).sort()
3543 BitVec(32)
3544 """
3545 a, b = _coerce_exprs(self, other)
3546 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3547
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 3659 of file z3py.py.

3659 def __neg__(self):
3660 """Return an expression representing `-self`.
3661
3662 >>> x = BitVec('x', 32)
3663 >>> -x
3664 -x
3665 >>> simplify(-(-x))
3666 x
3667 """
3668 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3669
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 3581 of file z3py.py.

3581 def __or__(self, other):
3582 """Create the Z3 expression bitwise-or `self | other`.
3583
3584 >>> x = BitVec('x', 32)
3585 >>> y = BitVec('y', 32)
3586 >>> x | y
3587 x | y
3588 >>> (x | y).sort()
3589 BitVec(32)
3590 """
3591 a, b = _coerce_exprs(self, other)
3592 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3593
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 3650 of file z3py.py.

3650 def __pos__(self):
3651 """Return `self`.
3652
3653 >>> x = BitVec('x', 32)
3654 >>> +x
3655 x
3656 """
3657 return self
3658

◆ __radd__()

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

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

Definition at line 3525 of file z3py.py.

3525 def __radd__(self, other):
3526 """Create the Z3 expression `other + self`.
3527
3528 >>> x = BitVec('x', 32)
3529 >>> 10 + x
3530 10 + x
3531 """
3532 a, b = _coerce_exprs(self, other)
3533 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3534

◆ __rand__()

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

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

Definition at line 3617 of file z3py.py.

3617 def __rand__(self, other):
3618 """Create the Z3 expression bitwise-or `other & self`.
3619
3620 >>> x = BitVec('x', 32)
3621 >>> 10 & x
3622 10 & x
3623 """
3624 a, b = _coerce_exprs(self, other)
3625 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3626

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

3704 def __rdiv__(self, other):
3705 """Create the Z3 expression (signed) division `other / self`.
3706
3707 Use the function UDiv() for unsigned division.
3708
3709 >>> x = BitVec('x', 32)
3710 >>> 10 / x
3711 10/x
3712 >>> (10 / x).sexpr()
3713 '(bvsdiv #x0000000a x)'
3714 >>> UDiv(10, x).sexpr()
3715 '(bvudiv #x0000000a x)'
3716 """
3717 a, b = _coerce_exprs(self, other)
3718 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3719

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

3885 def __rlshift__(self, other):
3886 """Create the Z3 expression left shift `other << self`.
3887
3888 Use the function LShR() for the right logical shift
3889
3890 >>> x = BitVec('x', 32)
3891 >>> 10 << x
3892 10 << x
3893 >>> (10 << x).sexpr()
3894 '(bvshl #x0000000a x)'
3895 """
3896 a, b = _coerce_exprs(self, other)
3897 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3898
3899

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

3745 def __rmod__(self, other):
3746 """Create the Z3 expression (signed) mod `other % self`.
3747
3748 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3749
3750 >>> x = BitVec('x', 32)
3751 >>> 10 % x
3752 10%x
3753 >>> (10 % x).sexpr()
3754 '(bvsmod #x0000000a x)'
3755 >>> URem(10, x).sexpr()
3756 '(bvurem #x0000000a x)'
3757 >>> SRem(10, x).sexpr()
3758 '(bvsrem #x0000000a x)'
3759 """
3760 a, b = _coerce_exprs(self, other)
3761 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3762

◆ __rmul__()

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

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

Definition at line 3548 of file z3py.py.

3548 def __rmul__(self, other):
3549 """Create the Z3 expression `other * self`.
3550
3551 >>> x = BitVec('x', 32)
3552 >>> 10 * x
3553 10*x
3554 """
3555 a, b = _coerce_exprs(self, other)
3556 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3557

◆ __ror__()

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

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

Definition at line 3594 of file z3py.py.

3594 def __ror__(self, other):
3595 """Create the Z3 expression bitwise-or `other | self`.
3596
3597 >>> x = BitVec('x', 32)
3598 >>> 10 | x
3599 10 | x
3600 """
3601 a, b = _coerce_exprs(self, other)
3602 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3603

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

3871 def __rrshift__(self, other):
3872 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3873
3874 Use the function LShR() for the right logical shift
3875
3876 >>> x = BitVec('x', 32)
3877 >>> 10 >> x
3878 10 >> x
3879 >>> (10 >> x).sexpr()
3880 '(bvashr #x0000000a x)'
3881 """
3882 a, b = _coerce_exprs(self, other)
3883 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3884
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 3827 of file z3py.py.

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

◆ __rsub__()

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

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

Definition at line 3571 of file z3py.py.

3571 def __rsub__(self, other):
3572 """Create the Z3 expression `other - self`.
3573
3574 >>> x = BitVec('x', 32)
3575 >>> 10 - x
3576 10 - x
3577 """
3578 a, b = _coerce_exprs(self, other)
3579 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3580
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 3720 of file z3py.py.

3720 def __rtruediv__(self, other):
3721 """Create the Z3 expression (signed) division `other / self`."""
3722 return self.__rdiv__(other)
3723

◆ __rxor__()

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

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

Definition at line 3640 of file z3py.py.

3640 def __rxor__(self, other):
3641 """Create the Z3 expression bitwise-xor `other ^ self`.
3642
3643 >>> x = BitVec('x', 32)
3644 >>> 10 ^ x
3645 10 ^ x
3646 """
3647 a, b = _coerce_exprs(self, other)
3648 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3649
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 3558 of file z3py.py.

3558 def __sub__(self, other):
3559 """Create the Z3 expression `self - other`.
3560
3561 >>> x = BitVec('x', 32)
3562 >>> y = BitVec('y', 32)
3563 >>> x - y
3564 x - y
3565 >>> (x - y).sort()
3566 BitVec(32)
3567 """
3568 a, b = _coerce_exprs(self, other)
3569 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3570

◆ __truediv__()

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

Definition at line 3700 of file z3py.py.

3700 def __truediv__(self, other):
3701 """Create the Z3 expression (signed) division `self / other`."""
3702 return self.__div__(other)
3703

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

3627 def __xor__(self, other):
3628 """Create the Z3 expression bitwise-xor `self ^ other`.
3629
3630 >>> x = BitVec('x', 32)
3631 >>> y = BitVec('y', 32)
3632 >>> x ^ y
3633 x ^ y
3634 >>> (x ^ y).sort()
3635 BitVec(32)
3636 """
3637 a, b = _coerce_exprs(self, other)
3638 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3639

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

3501 def size(self):
3502 """Return the number of bits of the bit-vector expression `self`.
3503
3504 >>> x = BitVec('x', 32)
3505 >>> (x + 1).size()
3506 32
3507 >>> Concat(x, x).size()
3508 64
3509 """
3510 return self.sort().size()
3511

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

3490 def sort(self):
3491 """Return the sort of the bit-vector expression `self`.
3492
3493 >>> x = BitVec('x', 32)
3494 >>> x.sort()
3495 BitVec(32)
3496 >>> x.sort() == BitVecSort(32)
3497 True
3498 """
3499 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3500
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.

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().