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)
 
 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 3563 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 3588 of file z3py.py.

3588 def __add__(self, other):
3589 """Create the Z3 expression `self + other`.
3590
3591 >>> x = BitVec('x', 32)
3592 >>> y = BitVec('y', 32)
3593 >>> x + y
3594 x + y
3595 >>> (x + y).sort()
3596 BitVec(32)
3597 """
3598 a, b = _coerce_exprs(self, other)
3599 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3600
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 3680 of file z3py.py.

3680 def __and__(self, other):
3681 """Create the Z3 expression bitwise-and `self & other`.
3682
3683 >>> x = BitVec('x', 32)
3684 >>> y = BitVec('y', 32)
3685 >>> x & y
3686 x & y
3687 >>> (x & y).sort()
3688 BitVec(32)
3689 """
3690 a, b = _coerce_exprs(self, other)
3691 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3692
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 3757 of file z3py.py.

3757 def __div__(self, other):
3758 """Create the Z3 expression (signed) division `self / other`.
3759
3760 Use the function UDiv() for unsigned division.
3761
3762 >>> x = BitVec('x', 32)
3763 >>> y = BitVec('y', 32)
3764 >>> x / y
3765 x/y
3766 >>> (x / y).sort()
3767 BitVec(32)
3768 >>> (x / y).sexpr()
3769 '(bvsdiv x y)'
3770 >>> UDiv(x, y).sexpr()
3771 '(bvudiv x y)'
3772 """
3773 a, b = _coerce_exprs(self, other)
3774 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3775
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 3887 of file z3py.py.

3887 def __ge__(self, other):
3888 """Create the Z3 expression (signed) `other >= self`.
3889
3890 Use the function UGE() for unsigned greater than or equal to.
3891
3892 >>> x, y = BitVecs('x y', 32)
3893 >>> x >= y
3894 x >= y
3895 >>> (x >= y).sexpr()
3896 '(bvsge x y)'
3897 >>> UGE(x, y).sexpr()
3898 '(bvuge x y)'
3899 """
3900 a, b = _coerce_exprs(self, other)
3901 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3902
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 3871 of file z3py.py.

3871 def __gt__(self, other):
3872 """Create the Z3 expression (signed) `other > self`.
3873
3874 Use the function UGT() for unsigned greater than.
3875
3876 >>> x, y = BitVecs('x y', 32)
3877 >>> x > y
3878 x > y
3879 >>> (x > y).sexpr()
3880 '(bvsgt x y)'
3881 >>> UGT(x, y).sexpr()
3882 '(bvugt x y)'
3883 """
3884 a, b = _coerce_exprs(self, other)
3885 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3886
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 3746 of file z3py.py.

3746 def __invert__(self):
3747 """Create the Z3 expression bitwise-not `~self`.
3748
3749 >>> x = BitVec('x', 32)
3750 >>> ~x
3751 ~x
3752 >>> simplify(~(~x))
3753 x
3754 """
3755 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3756
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 3839 of file z3py.py.

3839 def __le__(self, other):
3840 """Create the Z3 expression (signed) `other <= self`.
3841
3842 Use the function ULE() for unsigned less than or equal to.
3843
3844 >>> x, y = BitVecs('x y', 32)
3845 >>> x <= y
3846 x <= y
3847 >>> (x <= y).sexpr()
3848 '(bvsle x y)'
3849 >>> ULE(x, y).sexpr()
3850 '(bvule x y)'
3851 """
3852 a, b = _coerce_exprs(self, other)
3853 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3854
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 3933 of file z3py.py.

3933 def __lshift__(self, other):
3934 """Create the Z3 expression left shift `self << other`
3935
3936 >>> x, y = BitVecs('x y', 32)
3937 >>> x << y
3938 x << y
3939 >>> (x << y).sexpr()
3940 '(bvshl x y)'
3941 >>> simplify(BitVecVal(2, 3) << 1)
3942 4
3943 """
3944 a, b = _coerce_exprs(self, other)
3945 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3946
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 3855 of file z3py.py.

3855 def __lt__(self, other):
3856 """Create the Z3 expression (signed) `other < self`.
3857
3858 Use the function ULT() for unsigned less than.
3859
3860 >>> x, y = BitVecs('x y', 32)
3861 >>> x < y
3862 x < y
3863 >>> (x < y).sexpr()
3864 '(bvslt x y)'
3865 >>> ULT(x, y).sexpr()
3866 '(bvult x y)'
3867 """
3868 a, b = _coerce_exprs(self, other)
3869 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3870
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 3800 of file z3py.py.

3800 def __mod__(self, other):
3801 """Create the Z3 expression (signed) mod `self % other`.
3802
3803 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3804
3805 >>> x = BitVec('x', 32)
3806 >>> y = BitVec('y', 32)
3807 >>> x % y
3808 x%y
3809 >>> (x % y).sort()
3810 BitVec(32)
3811 >>> (x % y).sexpr()
3812 '(bvsmod x y)'
3813 >>> URem(x, y).sexpr()
3814 '(bvurem x y)'
3815 >>> SRem(x, y).sexpr()
3816 '(bvsrem x y)'
3817 """
3818 a, b = _coerce_exprs(self, other)
3819 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3820
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 3611 of file z3py.py.

3611 def __mul__(self, other):
3612 """Create the Z3 expression `self * other`.
3613
3614 >>> x = BitVec('x', 32)
3615 >>> y = BitVec('y', 32)
3616 >>> x * y
3617 x*y
3618 >>> (x * y).sort()
3619 BitVec(32)
3620 """
3621 a, b = _coerce_exprs(self, other)
3622 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3623
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 3735 of file z3py.py.

3735 def __neg__(self):
3736 """Return an expression representing `-self`.
3737
3738 >>> x = BitVec('x', 32)
3739 >>> -x
3740 -x
3741 >>> simplify(-(-x))
3742 x
3743 """
3744 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3745
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 3657 of file z3py.py.

3657 def __or__(self, other):
3658 """Create the Z3 expression bitwise-or `self | other`.
3659
3660 >>> x = BitVec('x', 32)
3661 >>> y = BitVec('y', 32)
3662 >>> x | y
3663 x | y
3664 >>> (x | y).sort()
3665 BitVec(32)
3666 """
3667 a, b = _coerce_exprs(self, other)
3668 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3669
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 3726 of file z3py.py.

3726 def __pos__(self):
3727 """Return `self`.
3728
3729 >>> x = BitVec('x', 32)
3730 >>> +x
3731 x
3732 """
3733 return self
3734

◆ __radd__()

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

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

Definition at line 3601 of file z3py.py.

3601 def __radd__(self, other):
3602 """Create the Z3 expression `other + self`.
3603
3604 >>> x = BitVec('x', 32)
3605 >>> 10 + x
3606 10 + x
3607 """
3608 a, b = _coerce_exprs(self, other)
3609 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3610

◆ __rand__()

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

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

Definition at line 3693 of file z3py.py.

3693 def __rand__(self, other):
3694 """Create the Z3 expression bitwise-or `other & self`.
3695
3696 >>> x = BitVec('x', 32)
3697 >>> 10 & x
3698 10 & x
3699 """
3700 a, b = _coerce_exprs(self, other)
3701 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3702

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

3780 def __rdiv__(self, other):
3781 """Create the Z3 expression (signed) division `other / self`.
3782
3783 Use the function UDiv() for unsigned division.
3784
3785 >>> x = BitVec('x', 32)
3786 >>> 10 / x
3787 10/x
3788 >>> (10 / x).sexpr()
3789 '(bvsdiv #x0000000a x)'
3790 >>> UDiv(10, x).sexpr()
3791 '(bvudiv #x0000000a x)'
3792 """
3793 a, b = _coerce_exprs(self, other)
3794 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3795

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

3961 def __rlshift__(self, other):
3962 """Create the Z3 expression left shift `other << self`.
3963
3964 Use the function LShR() for the right logical shift
3965
3966 >>> x = BitVec('x', 32)
3967 >>> 10 << x
3968 10 << x
3969 >>> (10 << x).sexpr()
3970 '(bvshl #x0000000a x)'
3971 """
3972 a, b = _coerce_exprs(self, other)
3973 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3974
3975

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

3821 def __rmod__(self, other):
3822 """Create the Z3 expression (signed) mod `other % self`.
3823
3824 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3825
3826 >>> x = BitVec('x', 32)
3827 >>> 10 % x
3828 10%x
3829 >>> (10 % x).sexpr()
3830 '(bvsmod #x0000000a x)'
3831 >>> URem(10, x).sexpr()
3832 '(bvurem #x0000000a x)'
3833 >>> SRem(10, x).sexpr()
3834 '(bvsrem #x0000000a x)'
3835 """
3836 a, b = _coerce_exprs(self, other)
3837 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3838

◆ __rmul__()

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

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

Definition at line 3624 of file z3py.py.

3624 def __rmul__(self, other):
3625 """Create the Z3 expression `other * self`.
3626
3627 >>> x = BitVec('x', 32)
3628 >>> 10 * x
3629 10*x
3630 """
3631 a, b = _coerce_exprs(self, other)
3632 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3633

◆ __ror__()

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

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

Definition at line 3670 of file z3py.py.

3670 def __ror__(self, other):
3671 """Create the Z3 expression bitwise-or `other | self`.
3672
3673 >>> x = BitVec('x', 32)
3674 >>> 10 | x
3675 10 | x
3676 """
3677 a, b = _coerce_exprs(self, other)
3678 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3679

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

3947 def __rrshift__(self, other):
3948 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3949
3950 Use the function LShR() for the right logical shift
3951
3952 >>> x = BitVec('x', 32)
3953 >>> 10 >> x
3954 10 >> x
3955 >>> (10 >> x).sexpr()
3956 '(bvashr #x0000000a x)'
3957 """
3958 a, b = _coerce_exprs(self, other)
3959 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3960
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 3903 of file z3py.py.

3903 def __rshift__(self, other):
3904 """Create the Z3 expression (arithmetical) right shift `self >> other`
3905
3906 Use the function LShR() for the right logical shift
3907
3908 >>> x, y = BitVecs('x y', 32)
3909 >>> x >> y
3910 x >> y
3911 >>> (x >> y).sexpr()
3912 '(bvashr x y)'
3913 >>> LShR(x, y).sexpr()
3914 '(bvlshr x y)'
3915 >>> BitVecVal(4, 3)
3916 4
3917 >>> BitVecVal(4, 3).as_signed_long()
3918 -4
3919 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3920 -2
3921 >>> simplify(BitVecVal(4, 3) >> 1)
3922 6
3923 >>> simplify(LShR(BitVecVal(4, 3), 1))
3924 2
3925 >>> simplify(BitVecVal(2, 3) >> 1)
3926 1
3927 >>> simplify(LShR(BitVecVal(2, 3), 1))
3928 1
3929 """
3930 a, b = _coerce_exprs(self, other)
3931 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3932

◆ __rsub__()

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

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

Definition at line 3647 of file z3py.py.

3647 def __rsub__(self, other):
3648 """Create the Z3 expression `other - self`.
3649
3650 >>> x = BitVec('x', 32)
3651 >>> 10 - x
3652 10 - x
3653 """
3654 a, b = _coerce_exprs(self, other)
3655 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3656
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 3796 of file z3py.py.

3796 def __rtruediv__(self, other):
3797 """Create the Z3 expression (signed) division `other / self`."""
3798 return self.__rdiv__(other)
3799

◆ __rxor__()

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

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

Definition at line 3716 of file z3py.py.

3716 def __rxor__(self, other):
3717 """Create the Z3 expression bitwise-xor `other ^ self`.
3718
3719 >>> x = BitVec('x', 32)
3720 >>> 10 ^ x
3721 10 ^ x
3722 """
3723 a, b = _coerce_exprs(self, other)
3724 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3725
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 3634 of file z3py.py.

3634 def __sub__(self, other):
3635 """Create the Z3 expression `self - other`.
3636
3637 >>> x = BitVec('x', 32)
3638 >>> y = BitVec('y', 32)
3639 >>> x - y
3640 x - y
3641 >>> (x - y).sort()
3642 BitVec(32)
3643 """
3644 a, b = _coerce_exprs(self, other)
3645 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3646

◆ __truediv__()

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

Definition at line 3776 of file z3py.py.

3776 def __truediv__(self, other):
3777 """Create the Z3 expression (signed) division `self / other`."""
3778 return self.__div__(other)
3779

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

3703 def __xor__(self, other):
3704 """Create the Z3 expression bitwise-xor `self ^ other`.
3705
3706 >>> x = BitVec('x', 32)
3707 >>> y = BitVec('y', 32)
3708 >>> x ^ y
3709 x ^ y
3710 >>> (x ^ y).sort()
3711 BitVec(32)
3712 """
3713 a, b = _coerce_exprs(self, other)
3714 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3715

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

3577 def size(self):
3578 """Return the number of bits of the bit-vector expression `self`.
3579
3580 >>> x = BitVec('x', 32)
3581 >>> (x + 1).size()
3582 32
3583 >>> Concat(x, x).size()
3584 64
3585 """
3586 return self.sort().size()
3587

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

3566 def sort(self):
3567 """Return the sort of the bit-vector expression `self`.
3568
3569 >>> x = BitVec('x', 32)
3570 >>> x.sort()
3571 BitVec(32)
3572 >>> x.sort() == BitVecSort(32)
3573 True
3574 """
3575 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3576
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.