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

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

3776 def __and__(self, other):
3777 """Create the Z3 expression bitwise-and `self & other`.
3778
3779 >>> x = BitVec('x', 32)
3780 >>> y = BitVec('y', 32)
3781 >>> x & y
3782 x & y
3783 >>> (x & y).sort()
3784 BitVec(32)
3785 """
3786 a, b = _coerce_exprs(self, other)
3787 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3788
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 3853 of file z3py.py.

3853 def __div__(self, other):
3854 """Create the Z3 expression (signed) division `self / other`.
3855
3856 Use the function UDiv() for unsigned division.
3857
3858 >>> x = BitVec('x', 32)
3859 >>> y = BitVec('y', 32)
3860 >>> x / y
3861 x/y
3862 >>> (x / y).sort()
3863 BitVec(32)
3864 >>> (x / y).sexpr()
3865 '(bvsdiv x y)'
3866 >>> UDiv(x, y).sexpr()
3867 '(bvudiv x y)'
3868 """
3869 a, b = _coerce_exprs(self, other)
3870 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3871
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 3983 of file z3py.py.

3983 def __ge__(self, other):
3984 """Create the Z3 expression (signed) `other >= self`.
3985
3986 Use the function UGE() for unsigned greater than or equal to.
3987
3988 >>> x, y = BitVecs('x y', 32)
3989 >>> x >= y
3990 x >= y
3991 >>> (x >= y).sexpr()
3992 '(bvsge x y)'
3993 >>> UGE(x, y).sexpr()
3994 '(bvuge x y)'
3995 """
3996 a, b = _coerce_exprs(self, other)
3997 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3998
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 3967 of file z3py.py.

3967 def __gt__(self, other):
3968 """Create the Z3 expression (signed) `other > self`.
3969
3970 Use the function UGT() for unsigned greater than.
3971
3972 >>> x, y = BitVecs('x y', 32)
3973 >>> x > y
3974 x > y
3975 >>> (x > y).sexpr()
3976 '(bvsgt x y)'
3977 >>> UGT(x, y).sexpr()
3978 '(bvugt x y)'
3979 """
3980 a, b = _coerce_exprs(self, other)
3981 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3982
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 3842 of file z3py.py.

3842 def __invert__(self):
3843 """Create the Z3 expression bitwise-not `~self`.
3844
3845 >>> x = BitVec('x', 32)
3846 >>> ~x
3847 ~x
3848 >>> simplify(~(~x))
3849 x
3850 """
3851 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3852
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 3935 of file z3py.py.

3935 def __le__(self, other):
3936 """Create the Z3 expression (signed) `other <= self`.
3937
3938 Use the function ULE() for unsigned less than or equal to.
3939
3940 >>> x, y = BitVecs('x y', 32)
3941 >>> x <= y
3942 x <= y
3943 >>> (x <= y).sexpr()
3944 '(bvsle x y)'
3945 >>> ULE(x, y).sexpr()
3946 '(bvule x y)'
3947 """
3948 a, b = _coerce_exprs(self, other)
3949 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3950
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 4029 of file z3py.py.

4029 def __lshift__(self, other):
4030 """Create the Z3 expression left shift `self << other`
4031
4032 >>> x, y = BitVecs('x y', 32)
4033 >>> x << y
4034 x << y
4035 >>> (x << y).sexpr()
4036 '(bvshl x y)'
4037 >>> simplify(BitVecVal(2, 3) << 1)
4038 4
4039 """
4040 a, b = _coerce_exprs(self, other)
4041 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4042
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 3951 of file z3py.py.

3951 def __lt__(self, other):
3952 """Create the Z3 expression (signed) `other < self`.
3953
3954 Use the function ULT() for unsigned less than.
3955
3956 >>> x, y = BitVecs('x y', 32)
3957 >>> x < y
3958 x < y
3959 >>> (x < y).sexpr()
3960 '(bvslt x y)'
3961 >>> ULT(x, y).sexpr()
3962 '(bvult x y)'
3963 """
3964 a, b = _coerce_exprs(self, other)
3965 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3966
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 3896 of file z3py.py.

3896 def __mod__(self, other):
3897 """Create the Z3 expression (signed) mod `self % other`.
3898
3899 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3900
3901 >>> x = BitVec('x', 32)
3902 >>> y = BitVec('y', 32)
3903 >>> x % y
3904 x%y
3905 >>> (x % y).sort()
3906 BitVec(32)
3907 >>> (x % y).sexpr()
3908 '(bvsmod x y)'
3909 >>> URem(x, y).sexpr()
3910 '(bvurem x y)'
3911 >>> SRem(x, y).sexpr()
3912 '(bvsrem x y)'
3913 """
3914 a, b = _coerce_exprs(self, other)
3915 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3916
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 3707 of file z3py.py.

3707 def __mul__(self, other):
3708 """Create the Z3 expression `self * other`.
3709
3710 >>> x = BitVec('x', 32)
3711 >>> y = BitVec('y', 32)
3712 >>> x * y
3713 x*y
3714 >>> (x * y).sort()
3715 BitVec(32)
3716 """
3717 a, b = _coerce_exprs(self, other)
3718 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3719
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 3831 of file z3py.py.

3831 def __neg__(self):
3832 """Return an expression representing `-self`.
3833
3834 >>> x = BitVec('x', 32)
3835 >>> -x
3836 -x
3837 >>> simplify(-(-x))
3838 x
3839 """
3840 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3841
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 3753 of file z3py.py.

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

3822 def __pos__(self):
3823 """Return `self`.
3824
3825 >>> x = BitVec('x', 32)
3826 >>> +x
3827 x
3828 """
3829 return self
3830

◆ __radd__()

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

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

Definition at line 3697 of file z3py.py.

3697 def __radd__(self, other):
3698 """Create the Z3 expression `other + self`.
3699
3700 >>> x = BitVec('x', 32)
3701 >>> 10 + x
3702 10 + x
3703 """
3704 a, b = _coerce_exprs(self, other)
3705 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3706

◆ __rand__()

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

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

Definition at line 3789 of file z3py.py.

3789 def __rand__(self, other):
3790 """Create the Z3 expression bitwise-or `other & self`.
3791
3792 >>> x = BitVec('x', 32)
3793 >>> 10 & x
3794 10 & x
3795 """
3796 a, b = _coerce_exprs(self, other)
3797 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3798

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

3876 def __rdiv__(self, other):
3877 """Create the Z3 expression (signed) division `other / self`.
3878
3879 Use the function UDiv() for unsigned division.
3880
3881 >>> x = BitVec('x', 32)
3882 >>> 10 / x
3883 10/x
3884 >>> (10 / x).sexpr()
3885 '(bvsdiv #x0000000a x)'
3886 >>> UDiv(10, x).sexpr()
3887 '(bvudiv #x0000000a x)'
3888 """
3889 a, b = _coerce_exprs(self, other)
3890 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3891

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

4057 def __rlshift__(self, other):
4058 """Create the Z3 expression left shift `other << self`.
4059
4060 Use the function LShR() for the right logical shift
4061
4062 >>> x = BitVec('x', 32)
4063 >>> 10 << x
4064 10 << x
4065 >>> (10 << x).sexpr()
4066 '(bvshl #x0000000a x)'
4067 """
4068 a, b = _coerce_exprs(self, other)
4069 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4070
4071

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

3917 def __rmod__(self, other):
3918 """Create the Z3 expression (signed) mod `other % self`.
3919
3920 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3921
3922 >>> x = BitVec('x', 32)
3923 >>> 10 % x
3924 10%x
3925 >>> (10 % x).sexpr()
3926 '(bvsmod #x0000000a x)'
3927 >>> URem(10, x).sexpr()
3928 '(bvurem #x0000000a x)'
3929 >>> SRem(10, x).sexpr()
3930 '(bvsrem #x0000000a x)'
3931 """
3932 a, b = _coerce_exprs(self, other)
3933 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3934

◆ __rmul__()

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

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

Definition at line 3720 of file z3py.py.

3720 def __rmul__(self, other):
3721 """Create the Z3 expression `other * self`.
3722
3723 >>> x = BitVec('x', 32)
3724 >>> 10 * x
3725 10*x
3726 """
3727 a, b = _coerce_exprs(self, other)
3728 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3729

◆ __ror__()

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

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

Definition at line 3766 of file z3py.py.

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

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

4043 def __rrshift__(self, other):
4044 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
4045
4046 Use the function LShR() for the right logical shift
4047
4048 >>> x = BitVec('x', 32)
4049 >>> 10 >> x
4050 10 >> x
4051 >>> (10 >> x).sexpr()
4052 '(bvashr #x0000000a x)'
4053 """
4054 a, b = _coerce_exprs(self, other)
4055 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4056
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 3999 of file z3py.py.

3999 def __rshift__(self, other):
4000 """Create the Z3 expression (arithmetical) right shift `self >> other`
4001
4002 Use the function LShR() for the right logical shift
4003
4004 >>> x, y = BitVecs('x y', 32)
4005 >>> x >> y
4006 x >> y
4007 >>> (x >> y).sexpr()
4008 '(bvashr x y)'
4009 >>> LShR(x, y).sexpr()
4010 '(bvlshr x y)'
4011 >>> BitVecVal(4, 3)
4012 4
4013 >>> BitVecVal(4, 3).as_signed_long()
4014 -4
4015 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
4016 -2
4017 >>> simplify(BitVecVal(4, 3) >> 1)
4018 6
4019 >>> simplify(LShR(BitVecVal(4, 3), 1))
4020 2
4021 >>> simplify(BitVecVal(2, 3) >> 1)
4022 1
4023 >>> simplify(LShR(BitVecVal(2, 3), 1))
4024 1
4025 """
4026 a, b = _coerce_exprs(self, other)
4027 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4028

◆ __rsub__()

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

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

Definition at line 3743 of file z3py.py.

3743 def __rsub__(self, other):
3744 """Create the Z3 expression `other - self`.
3745
3746 >>> x = BitVec('x', 32)
3747 >>> 10 - x
3748 10 - x
3749 """
3750 a, b = _coerce_exprs(self, other)
3751 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3752
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 3892 of file z3py.py.

3892 def __rtruediv__(self, other):
3893 """Create the Z3 expression (signed) division `other / self`."""
3894 return self.__rdiv__(other)
3895

◆ __rxor__()

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

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

Definition at line 3812 of file z3py.py.

3812 def __rxor__(self, other):
3813 """Create the Z3 expression bitwise-xor `other ^ self`.
3814
3815 >>> x = BitVec('x', 32)
3816 >>> 10 ^ x
3817 10 ^ x
3818 """
3819 a, b = _coerce_exprs(self, other)
3820 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3821
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 3730 of file z3py.py.

3730 def __sub__(self, other):
3731 """Create the Z3 expression `self - other`.
3732
3733 >>> x = BitVec('x', 32)
3734 >>> y = BitVec('y', 32)
3735 >>> x - y
3736 x - y
3737 >>> (x - y).sort()
3738 BitVec(32)
3739 """
3740 a, b = _coerce_exprs(self, other)
3741 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3742

◆ __truediv__()

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

Definition at line 3872 of file z3py.py.

3872 def __truediv__(self, other):
3873 """Create the Z3 expression (signed) division `self / other`."""
3874 return self.__div__(other)
3875

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

3799 def __xor__(self, other):
3800 """Create the Z3 expression bitwise-xor `self ^ other`.
3801
3802 >>> x = BitVec('x', 32)
3803 >>> y = BitVec('y', 32)
3804 >>> x ^ y
3805 x ^ y
3806 >>> (x ^ y).sort()
3807 BitVec(32)
3808 """
3809 a, b = _coerce_exprs(self, other)
3810 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3811

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

3673 def size(self):
3674 """Return the number of bits of the bit-vector expression `self`.
3675
3676 >>> x = BitVec('x', 32)
3677 >>> (x + 1).size()
3678 32
3679 >>> Concat(x, x).size()
3680 64
3681 """
3682 return self.sort().size()
3683

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

3662 def sort(self):
3663 """Return the sort of the bit-vector expression `self`.
3664
3665 >>> x = BitVec('x', 32)
3666 >>> x.sort()
3667 BitVec(32)
3668 >>> x.sort() == BitVecSort(32)
3669 True
3670 """
3671 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3672
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.