Z3
Loading...
Searching...
No Matches
BitVecRef Class Reference
Inheritance diagram for BitVecRef:

Public Member Functions

 sort (self)
 size (self)
 __add__ (self, other)
 __radd__ (self, other)
 __mul__ (self, other)
 __rmul__ (self, other)
 __sub__ (self, other)
 __rsub__ (self, other)
 __or__ (self, other)
 __ror__ (self, other)
 __and__ (self, other)
 __rand__ (self, other)
 __xor__ (self, other)
 __rxor__ (self, other)
 __pos__ (self)
 __neg__ (self)
 __invert__ (self)
 __div__ (self, other)
 __truediv__ (self, other)
 __rdiv__ (self, other)
 __rtruediv__ (self, other)
 __mod__ (self, other)
 __rmod__ (self, other)
 __le__ (self, other)
 __lt__ (self, other)
 __gt__ (self, other)
 __ge__ (self, other)
 __rshift__ (self, other)
 __lshift__ (self, other)
 __rrshift__ (self, other)
 __rlshift__ (self, other)
Public Member Functions inherited from ExprRef
 as_ast (self)
 get_id (self)
 sort_kind (self)
 __eq__ (self, other)
 __hash__ (self)
 __ne__ (self, other)
 params (self)
 decl (self)
 kind (self)
 num_args (self)
 arg (self, idx)
 children (self)
 update (self, *args)
 from_string (self, s)
 serialize (self)
Public Member Functions inherited from AstRef
 __init__ (self, ast, ctx=None)
 __del__ (self)
 __deepcopy__ (self, memo={})
 __str__ (self)
 __repr__ (self)
 __eq__ (self, other)
 __hash__ (self)
 __nonzero__ (self)
 __bool__ (self)
 sexpr (self)
 ctx_ref (self)
 eq (self, other)
 translate (self, target)
 __copy__ (self)
 hash (self)
 py_value (self)
Public Member Functions inherited from Z3PPObject
 use_pp (self)

Additional Inherited Members

Data Fields inherited from AstRef
 ast = ast
 ctx = _get_ctx(ctx)
Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)

Detailed Description

Bit-vector expressions.

Definition at line 3634 of file z3py.py.

Member Function Documentation

◆ __add__()

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

3659 def __add__(self, other):
3660 """Create the Z3 expression `self + other`.
3661
3662 >>> x = BitVec('x', 32)
3663 >>> y = BitVec('y', 32)
3664 >>> x + y
3665 x + y
3666 >>> (x + y).sort()
3667 BitVec(32)
3668 """
3669 a, b = _coerce_exprs(self, other)
3670 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3671
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.

◆ __and__()

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

3751 def __and__(self, other):
3752 """Create the Z3 expression bitwise-and `self & other`.
3753
3754 >>> x = BitVec('x', 32)
3755 >>> y = BitVec('y', 32)
3756 >>> x & y
3757 x & y
3758 >>> (x & y).sort()
3759 BitVec(32)
3760 """
3761 a, b = _coerce_exprs(self, other)
3762 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3763
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.

◆ __div__()

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

3828 def __div__(self, other):
3829 """Create the Z3 expression (signed) division `self / other`.
3830
3831 Use the function UDiv() for unsigned division.
3832
3833 >>> x = BitVec('x', 32)
3834 >>> y = BitVec('y', 32)
3835 >>> x / y
3836 x/y
3837 >>> (x / y).sort()
3838 BitVec(32)
3839 >>> (x / y).sexpr()
3840 '(bvsdiv x y)'
3841 >>> UDiv(x, y).sexpr()
3842 '(bvudiv x y)'
3843 """
3844 a, b = _coerce_exprs(self, other)
3845 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3846
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.

Referenced by __truediv__().

◆ __ge__()

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

3958 def __ge__(self, other):
3959 """Create the Z3 expression (signed) `other >= self`.
3960
3961 Use the function UGE() for unsigned greater than or equal to.
3962
3963 >>> x, y = BitVecs('x y', 32)
3964 >>> x >= y
3965 x >= y
3966 >>> (x >= y).sexpr()
3967 '(bvsge x y)'
3968 >>> UGE(x, y).sexpr()
3969 '(bvuge x y)'
3970 """
3971 a, b = _coerce_exprs(self, other)
3972 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
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.

◆ __gt__()

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

3942 def __gt__(self, other):
3943 """Create the Z3 expression (signed) `other > self`.
3944
3945 Use the function UGT() for unsigned greater than.
3946
3947 >>> x, y = BitVecs('x y', 32)
3948 >>> x > y
3949 x > y
3950 >>> (x > y).sexpr()
3951 '(bvsgt x y)'
3952 >>> UGT(x, y).sexpr()
3953 '(bvugt x y)'
3954 """
3955 a, b = _coerce_exprs(self, other)
3956 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3957
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.

◆ __invert__()

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

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

Definition at line 3817 of file z3py.py.

3817 def __invert__(self):
3818 """Create the Z3 expression bitwise-not `~self`.
3819
3820 >>> x = BitVec('x', 32)
3821 >>> ~x
3822 ~x
3823 >>> simplify(~(~x))
3824 x
3825 """
3826 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3827
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.

◆ __le__()

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

3910 def __le__(self, other):
3911 """Create the Z3 expression (signed) `other <= self`.
3912
3913 Use the function ULE() for unsigned less than or equal to.
3914
3915 >>> x, y = BitVecs('x y', 32)
3916 >>> x <= y
3917 x <= y
3918 >>> (x <= y).sexpr()
3919 '(bvsle x y)'
3920 >>> ULE(x, y).sexpr()
3921 '(bvule x y)'
3922 """
3923 a, b = _coerce_exprs(self, other)
3924 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
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.

◆ __lshift__()

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

4004 def __lshift__(self, other):
4005 """Create the Z3 expression left shift `self << other`
4006
4007 >>> x, y = BitVecs('x y', 32)
4008 >>> x << y
4009 x << y
4010 >>> (x << y).sexpr()
4011 '(bvshl x y)'
4012 >>> simplify(BitVecVal(2, 3) << 1)
4013 4
4014 """
4015 a, b = _coerce_exprs(self, other)
4016 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4017
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.

◆ __lt__()

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

3926 def __lt__(self, other):
3927 """Create the Z3 expression (signed) `other < self`.
3928
3929 Use the function ULT() for unsigned less than.
3930
3931 >>> x, y = BitVecs('x y', 32)
3932 >>> x < y
3933 x < y
3934 >>> (x < y).sexpr()
3935 '(bvslt x y)'
3936 >>> ULT(x, y).sexpr()
3937 '(bvult x y)'
3938 """
3939 a, b = _coerce_exprs(self, other)
3940 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3941
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than.

◆ __mod__()

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

3871 def __mod__(self, other):
3872 """Create the Z3 expression (signed) mod `self % other`.
3873
3874 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3875
3876 >>> x = BitVec('x', 32)
3877 >>> y = BitVec('y', 32)
3878 >>> x % y
3879 x%y
3880 >>> (x % y).sort()
3881 BitVec(32)
3882 >>> (x % y).sexpr()
3883 '(bvsmod x y)'
3884 >>> URem(x, y).sexpr()
3885 '(bvurem x y)'
3886 >>> SRem(x, y).sexpr()
3887 '(bvsrem x y)'
3888 """
3889 a, b = _coerce_exprs(self, other)
3890 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3891
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__()

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

3682 def __mul__(self, other):
3683 """Create the Z3 expression `self * other`.
3684
3685 >>> x = BitVec('x', 32)
3686 >>> y = BitVec('y', 32)
3687 >>> x * y
3688 x*y
3689 >>> (x * y).sort()
3690 BitVec(32)
3691 """
3692 a, b = _coerce_exprs(self, other)
3693 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3694
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.

◆ __neg__()

__neg__ ( self)
Return an expression representing `-self`.

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

Definition at line 3806 of file z3py.py.

3806 def __neg__(self):
3807 """Return an expression representing `-self`.
3808
3809 >>> x = BitVec('x', 32)
3810 >>> -x
3811 -x
3812 >>> simplify(-(-x))
3813 x
3814 """
3815 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3816
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two's complement unary minus.

◆ __or__()

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

3728 def __or__(self, other):
3729 """Create the Z3 expression bitwise-or `self | other`.
3730
3731 >>> x = BitVec('x', 32)
3732 >>> y = BitVec('y', 32)
3733 >>> x | y
3734 x | y
3735 >>> (x | y).sort()
3736 BitVec(32)
3737 """
3738 a, b = _coerce_exprs(self, other)
3739 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3740
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.

◆ __pos__()

__pos__ ( self)
Return `self`.

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

Definition at line 3797 of file z3py.py.

3797 def __pos__(self):
3798 """Return `self`.
3799
3800 >>> x = BitVec('x', 32)
3801 >>> +x
3802 x
3803 """
3804 return self
3805

◆ __radd__()

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

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

Definition at line 3672 of file z3py.py.

3672 def __radd__(self, other):
3673 """Create the Z3 expression `other + self`.
3674
3675 >>> x = BitVec('x', 32)
3676 >>> 10 + x
3677 10 + x
3678 """
3679 a, b = _coerce_exprs(self, other)
3680 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3681

◆ __rand__()

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

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

Definition at line 3764 of file z3py.py.

3764 def __rand__(self, other):
3765 """Create the Z3 expression bitwise-or `other & self`.
3766
3767 >>> x = BitVec('x', 32)
3768 >>> 10 & x
3769 10 & x
3770 """
3771 a, b = _coerce_exprs(self, other)
3772 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3773

◆ __rdiv__()

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

3851 def __rdiv__(self, other):
3852 """Create the Z3 expression (signed) division `other / self`.
3853
3854 Use the function UDiv() for unsigned division.
3855
3856 >>> x = BitVec('x', 32)
3857 >>> 10 / x
3858 10/x
3859 >>> (10 / x).sexpr()
3860 '(bvsdiv #x0000000a x)'
3861 >>> UDiv(10, x).sexpr()
3862 '(bvudiv #x0000000a x)'
3863 """
3864 a, b = _coerce_exprs(self, other)
3865 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3866

Referenced by __rtruediv__().

◆ __rlshift__()

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

4032 def __rlshift__(self, other):
4033 """Create the Z3 expression left shift `other << self`.
4034
4035 Use the function LShR() for the right logical shift
4036
4037 >>> x = BitVec('x', 32)
4038 >>> 10 << x
4039 10 << x
4040 >>> (10 << x).sexpr()
4041 '(bvshl #x0000000a x)'
4042 """
4043 a, b = _coerce_exprs(self, other)
4044 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4045
4046

◆ __rmod__()

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

3892 def __rmod__(self, other):
3893 """Create the Z3 expression (signed) mod `other % self`.
3894
3895 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3896
3897 >>> x = BitVec('x', 32)
3898 >>> 10 % x
3899 10%x
3900 >>> (10 % x).sexpr()
3901 '(bvsmod #x0000000a x)'
3902 >>> URem(10, x).sexpr()
3903 '(bvurem #x0000000a x)'
3904 >>> SRem(10, x).sexpr()
3905 '(bvsrem #x0000000a x)'
3906 """
3907 a, b = _coerce_exprs(self, other)
3908 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3909

◆ __rmul__()

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

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

Definition at line 3695 of file z3py.py.

3695 def __rmul__(self, other):
3696 """Create the Z3 expression `other * self`.
3697
3698 >>> x = BitVec('x', 32)
3699 >>> 10 * x
3700 10*x
3701 """
3702 a, b = _coerce_exprs(self, other)
3703 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3704

◆ __ror__()

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

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

Definition at line 3741 of file z3py.py.

3741 def __ror__(self, other):
3742 """Create the Z3 expression bitwise-or `other | self`.
3743
3744 >>> x = BitVec('x', 32)
3745 >>> 10 | x
3746 10 | x
3747 """
3748 a, b = _coerce_exprs(self, other)
3749 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3750

◆ __rrshift__()

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

4018 def __rrshift__(self, other):
4019 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
4020
4021 Use the function LShR() for the right logical shift
4022
4023 >>> x = BitVec('x', 32)
4024 >>> 10 >> x
4025 10 >> x
4026 >>> (10 >> x).sexpr()
4027 '(bvashr #x0000000a x)'
4028 """
4029 a, b = _coerce_exprs(self, other)
4030 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4031
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.

◆ __rshift__()

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

3974 def __rshift__(self, other):
3975 """Create the Z3 expression (arithmetical) right shift `self >> other`
3976
3977 Use the function LShR() for the right logical shift
3978
3979 >>> x, y = BitVecs('x y', 32)
3980 >>> x >> y
3981 x >> y
3982 >>> (x >> y).sexpr()
3983 '(bvashr x y)'
3984 >>> LShR(x, y).sexpr()
3985 '(bvlshr x y)'
3986 >>> BitVecVal(4, 3)
3987 4
3988 >>> BitVecVal(4, 3).as_signed_long()
3989 -4
3990 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3991 -2
3992 >>> simplify(BitVecVal(4, 3) >> 1)
3993 6
3994 >>> simplify(LShR(BitVecVal(4, 3), 1))
3995 2
3996 >>> simplify(BitVecVal(2, 3) >> 1)
3997 1
3998 >>> simplify(LShR(BitVecVal(2, 3), 1))
3999 1
4000 """
4001 a, b = _coerce_exprs(self, other)
4002 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4003

◆ __rsub__()

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

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

Definition at line 3718 of file z3py.py.

3718 def __rsub__(self, other):
3719 """Create the Z3 expression `other - self`.
3720
3721 >>> x = BitVec('x', 32)
3722 >>> 10 - x
3723 10 - x
3724 """
3725 a, b = _coerce_exprs(self, other)
3726 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3727
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.

◆ __rtruediv__()

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

Definition at line 3867 of file z3py.py.

3867 def __rtruediv__(self, other):
3868 """Create the Z3 expression (signed) division `other / self`."""
3869 return self.__rdiv__(other)
3870

◆ __rxor__()

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

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

Definition at line 3787 of file z3py.py.

3787 def __rxor__(self, other):
3788 """Create the Z3 expression bitwise-xor `other ^ self`.
3789
3790 >>> x = BitVec('x', 32)
3791 >>> 10 ^ x
3792 10 ^ x
3793 """
3794 a, b = _coerce_exprs(self, other)
3795 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3796
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.

◆ __sub__()

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

3705 def __sub__(self, other):
3706 """Create the Z3 expression `self - other`.
3707
3708 >>> x = BitVec('x', 32)
3709 >>> y = BitVec('y', 32)
3710 >>> x - y
3711 x - y
3712 >>> (x - y).sort()
3713 BitVec(32)
3714 """
3715 a, b = _coerce_exprs(self, other)
3716 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3717

◆ __truediv__()

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

Definition at line 3847 of file z3py.py.

3847 def __truediv__(self, other):
3848 """Create the Z3 expression (signed) division `self / other`."""
3849 return self.__div__(other)
3850

◆ __xor__()

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

3774 def __xor__(self, other):
3775 """Create the Z3 expression bitwise-xor `self ^ other`.
3776
3777 >>> x = BitVec('x', 32)
3778 >>> y = BitVec('y', 32)
3779 >>> x ^ y
3780 x ^ y
3781 >>> (x ^ y).sort()
3782 BitVec(32)
3783 """
3784 a, b = _coerce_exprs(self, other)
3785 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3786

◆ size()

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

3648 def size(self):
3649 """Return the number of bits of the bit-vector expression `self`.
3650
3651 >>> x = BitVec('x', 32)
3652 >>> (x + 1).size()
3653 32
3654 >>> Concat(x, x).size()
3655 64
3656 """
3657 return self.sort().size()
3658

Referenced by Goal.__len__(), ParamDescrsRef.__len__(), BitVecNumRef.as_signed_long(), and size().

◆ sort()

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

3637 def sort(self):
3638 """Return the sort of the bit-vector expression `self`.
3639
3640 >>> x = BitVec('x', 32)
3641 >>> x.sort()
3642 BitVec(32)
3643 >>> x.sort() == BitVecSort(32)
3644 True
3645 """
3646 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3647
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.