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

3504 def __add__(self, other):
3505 """Create the Z3 expression `self + other`.
3506
3507 >>> x = BitVec('x', 32)
3508 >>> y = BitVec('y', 32)
3509 >>> x + y
3510 x + y
3511 >>> (x + y).sort()
3512 BitVec(32)
3513 """
3514 a, b = _coerce_exprs(self, other)
3515 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3516
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 3596 of file z3py.py.

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

3673 def __div__(self, other):
3674 """Create the Z3 expression (signed) division `self / other`.
3675
3676 Use the function UDiv() for unsigned division.
3677
3678 >>> x = BitVec('x', 32)
3679 >>> y = BitVec('y', 32)
3680 >>> x / y
3681 x/y
3682 >>> (x / y).sort()
3683 BitVec(32)
3684 >>> (x / y).sexpr()
3685 '(bvsdiv x y)'
3686 >>> UDiv(x, y).sexpr()
3687 '(bvudiv x y)'
3688 """
3689 a, b = _coerce_exprs(self, other)
3690 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3691
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 3803 of file z3py.py.

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

3787 def __gt__(self, other):
3788 """Create the Z3 expression (signed) `other > self`.
3789
3790 Use the function UGT() for unsigned greater than.
3791
3792 >>> x, y = BitVecs('x y', 32)
3793 >>> x > y
3794 x > y
3795 >>> (x > y).sexpr()
3796 '(bvsgt x y)'
3797 >>> UGT(x, y).sexpr()
3798 '(bvugt x y)'
3799 """
3800 a, b = _coerce_exprs(self, other)
3801 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3802
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 3662 of file z3py.py.

3662 def __invert__(self):
3663 """Create the Z3 expression bitwise-not `~self`.
3664
3665 >>> x = BitVec('x', 32)
3666 >>> ~x
3667 ~x
3668 >>> simplify(~(~x))
3669 x
3670 """
3671 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3672
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 3755 of file z3py.py.

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

3849 def __lshift__(self, other):
3850 """Create the Z3 expression left shift `self << other`
3851
3852 >>> x, y = BitVecs('x y', 32)
3853 >>> x << y
3854 x << y
3855 >>> (x << y).sexpr()
3856 '(bvshl x y)'
3857 >>> simplify(BitVecVal(2, 3) << 1)
3858 4
3859 """
3860 a, b = _coerce_exprs(self, other)
3861 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3862
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 3771 of file z3py.py.

3771 def __lt__(self, other):
3772 """Create the Z3 expression (signed) `other < self`.
3773
3774 Use the function ULT() for unsigned less than.
3775
3776 >>> x, y = BitVecs('x y', 32)
3777 >>> x < y
3778 x < y
3779 >>> (x < y).sexpr()
3780 '(bvslt x y)'
3781 >>> ULT(x, y).sexpr()
3782 '(bvult x y)'
3783 """
3784 a, b = _coerce_exprs(self, other)
3785 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3786
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 3716 of file z3py.py.

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

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

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

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

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

◆ __radd__()

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

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

Definition at line 3517 of file z3py.py.

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

◆ __rand__()

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

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

Definition at line 3609 of file z3py.py.

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

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

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

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

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

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

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

◆ __rmul__()

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

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

Definition at line 3540 of file z3py.py.

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

◆ __ror__()

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

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

Definition at line 3586 of file z3py.py.

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

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

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

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

◆ __rsub__()

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

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

Definition at line 3563 of file z3py.py.

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

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

◆ __rxor__()

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

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

Definition at line 3632 of file z3py.py.

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

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

◆ __truediv__()

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

Definition at line 3692 of file z3py.py.

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

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

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

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

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

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

3482 def sort(self):
3483 """Return the sort of the bit-vector expression `self`.
3484
3485 >>> x = BitVec('x', 32)
3486 >>> x.sort()
3487 BitVec(32)
3488 >>> x.sort() == BitVecSort(32)
3489 True
3490 """
3491 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3492
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().