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

3603 def __add__(self, other):
3604 """Create the Z3 expression `self + other`.
3605
3606 >>> x = BitVec('x', 32)
3607 >>> y = BitVec('y', 32)
3608 >>> x + y
3609 x + y
3610 >>> (x + y).sort()
3611 BitVec(32)
3612 """
3613 a, b = _coerce_exprs(self, other)
3614 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3615
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 3695 of file z3py.py.

3695 def __and__(self, other):
3696 """Create the Z3 expression bitwise-and `self & other`.
3697
3698 >>> x = BitVec('x', 32)
3699 >>> y = BitVec('y', 32)
3700 >>> x & y
3701 x & y
3702 >>> (x & y).sort()
3703 BitVec(32)
3704 """
3705 a, b = _coerce_exprs(self, other)
3706 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3707
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 3772 of file z3py.py.

3772 def __div__(self, other):
3773 """Create the Z3 expression (signed) division `self / other`.
3774
3775 Use the function UDiv() for unsigned division.
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 >>> (x / y).sexpr()
3784 '(bvsdiv x y)'
3785 >>> UDiv(x, y).sexpr()
3786 '(bvudiv x y)'
3787 """
3788 a, b = _coerce_exprs(self, other)
3789 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3790
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 3902 of file z3py.py.

3902 def __ge__(self, other):
3903 """Create the Z3 expression (signed) `other >= self`.
3904
3905 Use the function UGE() for unsigned greater than or equal to.
3906
3907 >>> x, y = BitVecs('x y', 32)
3908 >>> x >= y
3909 x >= y
3910 >>> (x >= y).sexpr()
3911 '(bvsge x y)'
3912 >>> UGE(x, y).sexpr()
3913 '(bvuge x y)'
3914 """
3915 a, b = _coerce_exprs(self, other)
3916 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3917
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 3886 of file z3py.py.

3886 def __gt__(self, other):
3887 """Create the Z3 expression (signed) `other > self`.
3888
3889 Use the function UGT() for unsigned greater than.
3890
3891 >>> x, y = BitVecs('x y', 32)
3892 >>> x > y
3893 x > y
3894 >>> (x > y).sexpr()
3895 '(bvsgt x y)'
3896 >>> UGT(x, y).sexpr()
3897 '(bvugt x y)'
3898 """
3899 a, b = _coerce_exprs(self, other)
3900 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3901
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 3761 of file z3py.py.

3761 def __invert__(self):
3762 """Create the Z3 expression bitwise-not `~self`.
3763
3764 >>> x = BitVec('x', 32)
3765 >>> ~x
3766 ~x
3767 >>> simplify(~(~x))
3768 x
3769 """
3770 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3771
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 3854 of file z3py.py.

3854 def __le__(self, other):
3855 """Create the Z3 expression (signed) `other <= self`.
3856
3857 Use the function ULE() for unsigned less than or equal to.
3858
3859 >>> x, y = BitVecs('x y', 32)
3860 >>> x <= y
3861 x <= y
3862 >>> (x <= y).sexpr()
3863 '(bvsle x y)'
3864 >>> ULE(x, y).sexpr()
3865 '(bvule x y)'
3866 """
3867 a, b = _coerce_exprs(self, other)
3868 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3869
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 3948 of file z3py.py.

3948 def __lshift__(self, other):
3949 """Create the Z3 expression left shift `self << other`
3950
3951 >>> x, y = BitVecs('x y', 32)
3952 >>> x << y
3953 x << y
3954 >>> (x << y).sexpr()
3955 '(bvshl x y)'
3956 >>> simplify(BitVecVal(2, 3) << 1)
3957 4
3958 """
3959 a, b = _coerce_exprs(self, other)
3960 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3961
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 3870 of file z3py.py.

3870 def __lt__(self, other):
3871 """Create the Z3 expression (signed) `other < self`.
3872
3873 Use the function ULT() for unsigned less than.
3874
3875 >>> x, y = BitVecs('x y', 32)
3876 >>> x < y
3877 x < y
3878 >>> (x < y).sexpr()
3879 '(bvslt x y)'
3880 >>> ULT(x, y).sexpr()
3881 '(bvult x y)'
3882 """
3883 a, b = _coerce_exprs(self, other)
3884 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3885
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 3815 of file z3py.py.

3815 def __mod__(self, other):
3816 """Create the Z3 expression (signed) mod `self % other`.
3817
3818 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3819
3820 >>> x = BitVec('x', 32)
3821 >>> y = BitVec('y', 32)
3822 >>> x % y
3823 x%y
3824 >>> (x % y).sort()
3825 BitVec(32)
3826 >>> (x % y).sexpr()
3827 '(bvsmod x y)'
3828 >>> URem(x, y).sexpr()
3829 '(bvurem x y)'
3830 >>> SRem(x, y).sexpr()
3831 '(bvsrem x y)'
3832 """
3833 a, b = _coerce_exprs(self, other)
3834 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3835
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 3626 of file z3py.py.

3626 def __mul__(self, other):
3627 """Create the Z3 expression `self * other`.
3628
3629 >>> x = BitVec('x', 32)
3630 >>> y = BitVec('y', 32)
3631 >>> x * y
3632 x*y
3633 >>> (x * y).sort()
3634 BitVec(32)
3635 """
3636 a, b = _coerce_exprs(self, other)
3637 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3638
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 3750 of file z3py.py.

3750 def __neg__(self):
3751 """Return an expression representing `-self`.
3752
3753 >>> x = BitVec('x', 32)
3754 >>> -x
3755 -x
3756 >>> simplify(-(-x))
3757 x
3758 """
3759 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3760
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 3672 of file z3py.py.

3672 def __or__(self, other):
3673 """Create the Z3 expression bitwise-or `self | other`.
3674
3675 >>> x = BitVec('x', 32)
3676 >>> y = BitVec('y', 32)
3677 >>> x | y
3678 x | y
3679 >>> (x | y).sort()
3680 BitVec(32)
3681 """
3682 a, b = _coerce_exprs(self, other)
3683 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3684
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 3741 of file z3py.py.

3741 def __pos__(self):
3742 """Return `self`.
3743
3744 >>> x = BitVec('x', 32)
3745 >>> +x
3746 x
3747 """
3748 return self
3749

◆ __radd__()

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

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

Definition at line 3616 of file z3py.py.

3616 def __radd__(self, other):
3617 """Create the Z3 expression `other + self`.
3618
3619 >>> x = BitVec('x', 32)
3620 >>> 10 + x
3621 10 + x
3622 """
3623 a, b = _coerce_exprs(self, other)
3624 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3625

◆ __rand__()

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

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

Definition at line 3708 of file z3py.py.

3708 def __rand__(self, other):
3709 """Create the Z3 expression bitwise-or `other & self`.
3710
3711 >>> x = BitVec('x', 32)
3712 >>> 10 & x
3713 10 & x
3714 """
3715 a, b = _coerce_exprs(self, other)
3716 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3717

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

3795 def __rdiv__(self, other):
3796 """Create the Z3 expression (signed) division `other / self`.
3797
3798 Use the function UDiv() for unsigned division.
3799
3800 >>> x = BitVec('x', 32)
3801 >>> 10 / x
3802 10/x
3803 >>> (10 / x).sexpr()
3804 '(bvsdiv #x0000000a x)'
3805 >>> UDiv(10, x).sexpr()
3806 '(bvudiv #x0000000a x)'
3807 """
3808 a, b = _coerce_exprs(self, other)
3809 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3810

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

3976 def __rlshift__(self, other):
3977 """Create the Z3 expression left shift `other << self`.
3978
3979 Use the function LShR() for the right logical shift
3980
3981 >>> x = BitVec('x', 32)
3982 >>> 10 << x
3983 10 << x
3984 >>> (10 << x).sexpr()
3985 '(bvshl #x0000000a x)'
3986 """
3987 a, b = _coerce_exprs(self, other)
3988 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3989
3990

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

3836 def __rmod__(self, other):
3837 """Create the Z3 expression (signed) mod `other % self`.
3838
3839 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3840
3841 >>> x = BitVec('x', 32)
3842 >>> 10 % x
3843 10%x
3844 >>> (10 % x).sexpr()
3845 '(bvsmod #x0000000a x)'
3846 >>> URem(10, x).sexpr()
3847 '(bvurem #x0000000a x)'
3848 >>> SRem(10, x).sexpr()
3849 '(bvsrem #x0000000a x)'
3850 """
3851 a, b = _coerce_exprs(self, other)
3852 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3853

◆ __rmul__()

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

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

Definition at line 3639 of file z3py.py.

3639 def __rmul__(self, other):
3640 """Create the Z3 expression `other * self`.
3641
3642 >>> x = BitVec('x', 32)
3643 >>> 10 * x
3644 10*x
3645 """
3646 a, b = _coerce_exprs(self, other)
3647 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3648

◆ __ror__()

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

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

Definition at line 3685 of file z3py.py.

3685 def __ror__(self, other):
3686 """Create the Z3 expression bitwise-or `other | self`.
3687
3688 >>> x = BitVec('x', 32)
3689 >>> 10 | x
3690 10 | x
3691 """
3692 a, b = _coerce_exprs(self, other)
3693 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3694

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

3962 def __rrshift__(self, other):
3963 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3964
3965 Use the function LShR() for the right logical shift
3966
3967 >>> x = BitVec('x', 32)
3968 >>> 10 >> x
3969 10 >> x
3970 >>> (10 >> x).sexpr()
3971 '(bvashr #x0000000a x)'
3972 """
3973 a, b = _coerce_exprs(self, other)
3974 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3975
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 3918 of file z3py.py.

3918 def __rshift__(self, other):
3919 """Create the Z3 expression (arithmetical) right shift `self >> other`
3920
3921 Use the function LShR() for the right logical shift
3922
3923 >>> x, y = BitVecs('x y', 32)
3924 >>> x >> y
3925 x >> y
3926 >>> (x >> y).sexpr()
3927 '(bvashr x y)'
3928 >>> LShR(x, y).sexpr()
3929 '(bvlshr x y)'
3930 >>> BitVecVal(4, 3)
3931 4
3932 >>> BitVecVal(4, 3).as_signed_long()
3933 -4
3934 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3935 -2
3936 >>> simplify(BitVecVal(4, 3) >> 1)
3937 6
3938 >>> simplify(LShR(BitVecVal(4, 3), 1))
3939 2
3940 >>> simplify(BitVecVal(2, 3) >> 1)
3941 1
3942 >>> simplify(LShR(BitVecVal(2, 3), 1))
3943 1
3944 """
3945 a, b = _coerce_exprs(self, other)
3946 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3947

◆ __rsub__()

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

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

Definition at line 3662 of file z3py.py.

3662 def __rsub__(self, other):
3663 """Create the Z3 expression `other - self`.
3664
3665 >>> x = BitVec('x', 32)
3666 >>> 10 - x
3667 10 - x
3668 """
3669 a, b = _coerce_exprs(self, other)
3670 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3671
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 3811 of file z3py.py.

3811 def __rtruediv__(self, other):
3812 """Create the Z3 expression (signed) division `other / self`."""
3813 return self.__rdiv__(other)
3814

◆ __rxor__()

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

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

Definition at line 3731 of file z3py.py.

3731 def __rxor__(self, other):
3732 """Create the Z3 expression bitwise-xor `other ^ self`.
3733
3734 >>> x = BitVec('x', 32)
3735 >>> 10 ^ x
3736 10 ^ x
3737 """
3738 a, b = _coerce_exprs(self, other)
3739 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3740
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 3649 of file z3py.py.

3649 def __sub__(self, other):
3650 """Create the Z3 expression `self - other`.
3651
3652 >>> x = BitVec('x', 32)
3653 >>> y = BitVec('y', 32)
3654 >>> x - y
3655 x - y
3656 >>> (x - y).sort()
3657 BitVec(32)
3658 """
3659 a, b = _coerce_exprs(self, other)
3660 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3661

◆ __truediv__()

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

Definition at line 3791 of file z3py.py.

3791 def __truediv__(self, other):
3792 """Create the Z3 expression (signed) division `self / other`."""
3793 return self.__div__(other)
3794

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

3718 def __xor__(self, other):
3719 """Create the Z3 expression bitwise-xor `self ^ other`.
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 """
3728 a, b = _coerce_exprs(self, other)
3729 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3730

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

3592 def size(self):
3593 """Return the number of bits of the bit-vector expression `self`.
3594
3595 >>> x = BitVec('x', 32)
3596 >>> (x + 1).size()
3597 32
3598 >>> Concat(x, x).size()
3599 64
3600 """
3601 return self.sort().size()
3602

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

3581 def sort(self):
3582 """Return the sort of the bit-vector expression `self`.
3583
3584 >>> x = BitVec('x', 32)
3585 >>> x.sort()
3586 BitVec(32)
3587 >>> x.sort() == BitVecSort(32)
3588 True
3589 """
3590 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3591
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.