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

3661 def __add__(self, other):
3662 """Create the Z3 expression `self + other`.
3663
3664 >>> x = BitVec('x', 32)
3665 >>> y = BitVec('y', 32)
3666 >>> x + y
3667 x + y
3668 >>> (x + y).sort()
3669 BitVec(32)
3670 """
3671 a, b = _coerce_exprs(self, other)
3672 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3673
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 3753 of file z3py.py.

3753 def __and__(self, other):
3754 """Create the Z3 expression bitwise-and `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_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3765
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 3830 of file z3py.py.

3830 def __div__(self, other):
3831 """Create the Z3 expression (signed) division `self / other`.
3832
3833 Use the function UDiv() for unsigned division.
3834
3835 >>> x = BitVec('x', 32)
3836 >>> y = BitVec('y', 32)
3837 >>> x / y
3838 x/y
3839 >>> (x / y).sort()
3840 BitVec(32)
3841 >>> (x / y).sexpr()
3842 '(bvsdiv x y)'
3843 >>> UDiv(x, y).sexpr()
3844 '(bvudiv x y)'
3845 """
3846 a, b = _coerce_exprs(self, other)
3847 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3848
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 3960 of file z3py.py.

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

3944 def __gt__(self, other):
3945 """Create the Z3 expression (signed) `other > self`.
3946
3947 Use the function UGT() for unsigned greater than.
3948
3949 >>> x, y = BitVecs('x y', 32)
3950 >>> x > y
3951 x > y
3952 >>> (x > y).sexpr()
3953 '(bvsgt x y)'
3954 >>> UGT(x, y).sexpr()
3955 '(bvugt x y)'
3956 """
3957 a, b = _coerce_exprs(self, other)
3958 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3959
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 3819 of file z3py.py.

3819 def __invert__(self):
3820 """Create the Z3 expression bitwise-not `~self`.
3821
3822 >>> x = BitVec('x', 32)
3823 >>> ~x
3824 ~x
3825 >>> simplify(~(~x))
3826 x
3827 """
3828 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3829
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 3912 of file z3py.py.

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

4006 def __lshift__(self, other):
4007 """Create the Z3 expression left shift `self << other`
4008
4009 >>> x, y = BitVecs('x y', 32)
4010 >>> x << y
4011 x << y
4012 >>> (x << y).sexpr()
4013 '(bvshl x y)'
4014 >>> simplify(BitVecVal(2, 3) << 1)
4015 4
4016 """
4017 a, b = _coerce_exprs(self, other)
4018 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4019
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 3928 of file z3py.py.

3928 def __lt__(self, other):
3929 """Create the Z3 expression (signed) `other < self`.
3930
3931 Use the function ULT() for unsigned less than.
3932
3933 >>> x, y = BitVecs('x y', 32)
3934 >>> x < y
3935 x < y
3936 >>> (x < y).sexpr()
3937 '(bvslt x y)'
3938 >>> ULT(x, y).sexpr()
3939 '(bvult x y)'
3940 """
3941 a, b = _coerce_exprs(self, other)
3942 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3943
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 3873 of file z3py.py.

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

3684 def __mul__(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_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3696
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 3808 of file z3py.py.

3808 def __neg__(self):
3809 """Return an expression representing `-self`.
3810
3811 >>> x = BitVec('x', 32)
3812 >>> -x
3813 -x
3814 >>> simplify(-(-x))
3815 x
3816 """
3817 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3818
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 3730 of file z3py.py.

3730 def __or__(self, other):
3731 """Create the Z3 expression bitwise-or `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_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3742
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 3799 of file z3py.py.

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

◆ __radd__()

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

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

Definition at line 3674 of file z3py.py.

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

◆ __rand__()

__rand__ ( 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 __rand__(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_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3775

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

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

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

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

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

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

◆ __rmul__()

__rmul__ ( 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 __rmul__(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_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3706

◆ __ror__()

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

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

Definition at line 3743 of file z3py.py.

3743 def __ror__(self, other):
3744 """Create the Z3 expression bitwise-or `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_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3752

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

4020 def __rrshift__(self, other):
4021 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
4022
4023 Use the function LShR() for the right logical shift
4024
4025 >>> x = BitVec('x', 32)
4026 >>> 10 >> x
4027 10 >> x
4028 >>> (10 >> x).sexpr()
4029 '(bvashr #x0000000a x)'
4030 """
4031 a, b = _coerce_exprs(self, other)
4032 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4033
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 3976 of file z3py.py.

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

◆ __rsub__()

__rsub__ ( 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 __rsub__(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_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3729
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 3869 of file z3py.py.

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

◆ __rxor__()

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

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

Definition at line 3789 of file z3py.py.

3789 def __rxor__(self, other):
3790 """Create the Z3 expression bitwise-xor `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_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3798
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 3707 of file z3py.py.

3707 def __sub__(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_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3719

◆ __truediv__()

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

Definition at line 3849 of file z3py.py.

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

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

3776 def __xor__(self, other):
3777 """Create the Z3 expression bitwise-xor `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_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3788

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

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

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

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