Z3
 
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
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)
 
 __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)
 

Data Fields

 ctx
 
- Data Fields inherited from ExprRef
 ctx
 
 ast
 
- Data Fields inherited from AstRef
 ast
 
 ctx
 

Additional Inherited Members

- Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)
 

Detailed Description

Bit-vector expressions.

Definition at line 3649 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 3674 of file z3py.py.

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

3766 def __and__(self, other):
3767 """Create the Z3 expression bitwise-and `self & other`.
3768
3769 >>> x = BitVec('x', 32)
3770 >>> y = BitVec('y', 32)
3771 >>> x & y
3772 x & y
3773 >>> (x & y).sort()
3774 BitVec(32)
3775 """
3776 a, b = _coerce_exprs(self, other)
3777 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3778
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 3843 of file z3py.py.

3843 def __div__(self, other):
3844 """Create the Z3 expression (signed) division `self / other`.
3845
3846 Use the function UDiv() for unsigned division.
3847
3848 >>> x = BitVec('x', 32)
3849 >>> y = BitVec('y', 32)
3850 >>> x / y
3851 x/y
3852 >>> (x / y).sort()
3853 BitVec(32)
3854 >>> (x / y).sexpr()
3855 '(bvsdiv x y)'
3856 >>> UDiv(x, y).sexpr()
3857 '(bvudiv x y)'
3858 """
3859 a, b = _coerce_exprs(self, other)
3860 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3861
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.

Referenced by ArithRef.__truediv__(), and BitVecRef.__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 3973 of file z3py.py.

3973 def __ge__(self, other):
3974 """Create the Z3 expression (signed) `other >= self`.
3975
3976 Use the function UGE() for unsigned greater than or equal to.
3977
3978 >>> x, y = BitVecs('x y', 32)
3979 >>> x >= y
3980 x >= y
3981 >>> (x >= y).sexpr()
3982 '(bvsge x y)'
3983 >>> UGE(x, y).sexpr()
3984 '(bvuge x y)'
3985 """
3986 a, b = _coerce_exprs(self, other)
3987 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3988
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 3957 of file z3py.py.

3957 def __gt__(self, other):
3958 """Create the Z3 expression (signed) `other > self`.
3959
3960 Use the function UGT() for unsigned greater than.
3961
3962 >>> x, y = BitVecs('x y', 32)
3963 >>> x > y
3964 x > y
3965 >>> (x > y).sexpr()
3966 '(bvsgt x y)'
3967 >>> UGT(x, y).sexpr()
3968 '(bvugt x y)'
3969 """
3970 a, b = _coerce_exprs(self, other)
3971 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3972
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 3832 of file z3py.py.

3832 def __invert__(self):
3833 """Create the Z3 expression bitwise-not `~self`.
3834
3835 >>> x = BitVec('x', 32)
3836 >>> ~x
3837 ~x
3838 >>> simplify(~(~x))
3839 x
3840 """
3841 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3842
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 3925 of file z3py.py.

3925 def __le__(self, other):
3926 """Create the Z3 expression (signed) `other <= self`.
3927
3928 Use the function ULE() for unsigned less than or equal to.
3929
3930 >>> x, y = BitVecs('x y', 32)
3931 >>> x <= y
3932 x <= y
3933 >>> (x <= y).sexpr()
3934 '(bvsle x y)'
3935 >>> ULE(x, y).sexpr()
3936 '(bvule x y)'
3937 """
3938 a, b = _coerce_exprs(self, other)
3939 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3940
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 4019 of file z3py.py.

4019 def __lshift__(self, other):
4020 """Create the Z3 expression left shift `self << other`
4021
4022 >>> x, y = BitVecs('x y', 32)
4023 >>> x << y
4024 x << y
4025 >>> (x << y).sexpr()
4026 '(bvshl x y)'
4027 >>> simplify(BitVecVal(2, 3) << 1)
4028 4
4029 """
4030 a, b = _coerce_exprs(self, other)
4031 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4032
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 3941 of file z3py.py.

3941 def __lt__(self, other):
3942 """Create the Z3 expression (signed) `other < self`.
3943
3944 Use the function ULT() for unsigned less than.
3945
3946 >>> x, y = BitVecs('x y', 32)
3947 >>> x < y
3948 x < y
3949 >>> (x < y).sexpr()
3950 '(bvslt x y)'
3951 >>> ULT(x, y).sexpr()
3952 '(bvult x y)'
3953 """
3954 a, b = _coerce_exprs(self, other)
3955 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3956
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 3886 of file z3py.py.

3886 def __mod__(self, other):
3887 """Create the Z3 expression (signed) mod `self % other`.
3888
3889 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3890
3891 >>> x = BitVec('x', 32)
3892 >>> y = BitVec('y', 32)
3893 >>> x % y
3894 x%y
3895 >>> (x % y).sort()
3896 BitVec(32)
3897 >>> (x % y).sexpr()
3898 '(bvsmod x y)'
3899 >>> URem(x, y).sexpr()
3900 '(bvurem x y)'
3901 >>> SRem(x, y).sexpr()
3902 '(bvsrem x y)'
3903 """
3904 a, b = _coerce_exprs(self, other)
3905 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3906
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 3697 of file z3py.py.

3697 def __mul__(self, other):
3698 """Create the Z3 expression `self * other`.
3699
3700 >>> x = BitVec('x', 32)
3701 >>> y = BitVec('y', 32)
3702 >>> x * y
3703 x*y
3704 >>> (x * y).sort()
3705 BitVec(32)
3706 """
3707 a, b = _coerce_exprs(self, other)
3708 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3709
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 3821 of file z3py.py.

3821 def __neg__(self):
3822 """Return an expression representing `-self`.
3823
3824 >>> x = BitVec('x', 32)
3825 >>> -x
3826 -x
3827 >>> simplify(-(-x))
3828 x
3829 """
3830 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3831
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 3743 of file z3py.py.

3743 def __or__(self, other):
3744 """Create the Z3 expression bitwise-or `self | other`.
3745
3746 >>> x = BitVec('x', 32)
3747 >>> y = BitVec('y', 32)
3748 >>> x | y
3749 x | y
3750 >>> (x | y).sort()
3751 BitVec(32)
3752 """
3753 a, b = _coerce_exprs(self, other)
3754 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3755
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 3812 of file z3py.py.

3812 def __pos__(self):
3813 """Return `self`.
3814
3815 >>> x = BitVec('x', 32)
3816 >>> +x
3817 x
3818 """
3819 return self
3820

◆ __radd__()

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

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

Definition at line 3687 of file z3py.py.

3687 def __radd__(self, other):
3688 """Create the Z3 expression `other + self`.
3689
3690 >>> x = BitVec('x', 32)
3691 >>> 10 + x
3692 10 + x
3693 """
3694 a, b = _coerce_exprs(self, other)
3695 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3696

◆ __rand__()

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

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

Definition at line 3779 of file z3py.py.

3779 def __rand__(self, other):
3780 """Create the Z3 expression bitwise-or `other & self`.
3781
3782 >>> x = BitVec('x', 32)
3783 >>> 10 & x
3784 10 & x
3785 """
3786 a, b = _coerce_exprs(self, other)
3787 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3788

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

3866 def __rdiv__(self, other):
3867 """Create the Z3 expression (signed) division `other / self`.
3868
3869 Use the function UDiv() for unsigned division.
3870
3871 >>> x = BitVec('x', 32)
3872 >>> 10 / x
3873 10/x
3874 >>> (10 / x).sexpr()
3875 '(bvsdiv #x0000000a x)'
3876 >>> UDiv(10, x).sexpr()
3877 '(bvudiv #x0000000a x)'
3878 """
3879 a, b = _coerce_exprs(self, other)
3880 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3881

Referenced by ArithRef.__rtruediv__(), and BitVecRef.__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 4047 of file z3py.py.

4047 def __rlshift__(self, other):
4048 """Create the Z3 expression left shift `other << self`.
4049
4050 Use the function LShR() for the right logical shift
4051
4052 >>> x = BitVec('x', 32)
4053 >>> 10 << x
4054 10 << x
4055 >>> (10 << x).sexpr()
4056 '(bvshl #x0000000a x)'
4057 """
4058 a, b = _coerce_exprs(self, other)
4059 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4060
4061

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

3907 def __rmod__(self, other):
3908 """Create the Z3 expression (signed) mod `other % self`.
3909
3910 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3911
3912 >>> x = BitVec('x', 32)
3913 >>> 10 % x
3914 10%x
3915 >>> (10 % x).sexpr()
3916 '(bvsmod #x0000000a x)'
3917 >>> URem(10, x).sexpr()
3918 '(bvurem #x0000000a x)'
3919 >>> SRem(10, x).sexpr()
3920 '(bvsrem #x0000000a x)'
3921 """
3922 a, b = _coerce_exprs(self, other)
3923 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3924

◆ __rmul__()

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

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

Definition at line 3710 of file z3py.py.

3710 def __rmul__(self, other):
3711 """Create the Z3 expression `other * self`.
3712
3713 >>> x = BitVec('x', 32)
3714 >>> 10 * x
3715 10*x
3716 """
3717 a, b = _coerce_exprs(self, other)
3718 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3719

◆ __ror__()

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

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

Definition at line 3756 of file z3py.py.

3756 def __ror__(self, other):
3757 """Create the Z3 expression bitwise-or `other | self`.
3758
3759 >>> x = BitVec('x', 32)
3760 >>> 10 | x
3761 10 | x
3762 """
3763 a, b = _coerce_exprs(self, other)
3764 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3765

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

4033 def __rrshift__(self, other):
4034 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
4035
4036 Use the function LShR() for the right logical shift
4037
4038 >>> x = BitVec('x', 32)
4039 >>> 10 >> x
4040 10 >> x
4041 >>> (10 >> x).sexpr()
4042 '(bvashr #x0000000a x)'
4043 """
4044 a, b = _coerce_exprs(self, other)
4045 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4046
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 3989 of file z3py.py.

3989 def __rshift__(self, other):
3990 """Create the Z3 expression (arithmetical) right shift `self >> other`
3991
3992 Use the function LShR() for the right logical shift
3993
3994 >>> x, y = BitVecs('x y', 32)
3995 >>> x >> y
3996 x >> y
3997 >>> (x >> y).sexpr()
3998 '(bvashr x y)'
3999 >>> LShR(x, y).sexpr()
4000 '(bvlshr x y)'
4001 >>> BitVecVal(4, 3)
4002 4
4003 >>> BitVecVal(4, 3).as_signed_long()
4004 -4
4005 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
4006 -2
4007 >>> simplify(BitVecVal(4, 3) >> 1)
4008 6
4009 >>> simplify(LShR(BitVecVal(4, 3), 1))
4010 2
4011 >>> simplify(BitVecVal(2, 3) >> 1)
4012 1
4013 >>> simplify(LShR(BitVecVal(2, 3), 1))
4014 1
4015 """
4016 a, b = _coerce_exprs(self, other)
4017 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4018

◆ __rsub__()

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

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

Definition at line 3733 of file z3py.py.

3733 def __rsub__(self, other):
3734 """Create the Z3 expression `other - self`.
3735
3736 >>> x = BitVec('x', 32)
3737 >>> 10 - x
3738 10 - x
3739 """
3740 a, b = _coerce_exprs(self, other)
3741 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3742
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 3882 of file z3py.py.

3882 def __rtruediv__(self, other):
3883 """Create the Z3 expression (signed) division `other / self`."""
3884 return self.__rdiv__(other)
3885

◆ __rxor__()

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

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

Definition at line 3802 of file z3py.py.

3802 def __rxor__(self, other):
3803 """Create the Z3 expression bitwise-xor `other ^ self`.
3804
3805 >>> x = BitVec('x', 32)
3806 >>> 10 ^ x
3807 10 ^ x
3808 """
3809 a, b = _coerce_exprs(self, other)
3810 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3811
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 3720 of file z3py.py.

3720 def __sub__(self, other):
3721 """Create the Z3 expression `self - other`.
3722
3723 >>> x = BitVec('x', 32)
3724 >>> y = BitVec('y', 32)
3725 >>> x - y
3726 x - y
3727 >>> (x - y).sort()
3728 BitVec(32)
3729 """
3730 a, b = _coerce_exprs(self, other)
3731 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3732

◆ __truediv__()

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

Definition at line 3862 of file z3py.py.

3862 def __truediv__(self, other):
3863 """Create the Z3 expression (signed) division `self / other`."""
3864 return self.__div__(other)
3865

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

3789 def __xor__(self, other):
3790 """Create the Z3 expression bitwise-xor `self ^ other`.
3791
3792 >>> x = BitVec('x', 32)
3793 >>> y = BitVec('y', 32)
3794 >>> x ^ y
3795 x ^ y
3796 >>> (x ^ y).sort()
3797 BitVec(32)
3798 """
3799 a, b = _coerce_exprs(self, other)
3800 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3801

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

3663 def size(self):
3664 """Return the number of bits of the bit-vector expression `self`.
3665
3666 >>> x = BitVec('x', 32)
3667 >>> (x + 1).size()
3668 32
3669 >>> Concat(x, x).size()
3670 64
3671 """
3672 return self.sort().size()
3673

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

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

3652 def sort(self):
3653 """Return the sort of the bit-vector expression `self`.
3654
3655 >>> x = BitVec('x', 32)
3656 >>> x.sort()
3657 BitVec(32)
3658 >>> x.sort() == BitVecSort(32)
3659 True
3660 """
3661 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3662
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.

Referenced by ArrayRef.domain(), ArrayRef.domain_n(), ArithRef.is_int(), ArithRef.is_real(), ArrayRef.range(), BitVecRef.size(), and ExprRef.sort_kind().

Field Documentation

◆ ctx

ctx

Definition at line 3661 of file z3py.py.

Referenced by ArithRef.__add__(), BitVecRef.__add__(), BitVecRef.__and__(), FuncDeclRef.__call__(), AstMap.__contains__(), AstRef.__copy__(), Goal.__copy__(), AstVector.__copy__(), FuncInterp.__copy__(), ModelRef.__copy__(), AstRef.__deepcopy__(), Datatype.__deepcopy__(), ParamsRef.__deepcopy__(), ParamDescrsRef.__deepcopy__(), Goal.__deepcopy__(), AstVector.__deepcopy__(), AstMap.__deepcopy__(), FuncEntry.__deepcopy__(), FuncInterp.__deepcopy__(), ModelRef.__deepcopy__(), Statistics.__deepcopy__(), Context.__del__(), AstRef.__del__(), ScopedConstructor.__del__(), ScopedConstructorList.__del__(), ParamsRef.__del__(), ParamDescrsRef.__del__(), Goal.__del__(), AstVector.__del__(), AstMap.__del__(), FuncEntry.__del__(), FuncInterp.__del__(), ModelRef.__del__(), Statistics.__del__(), Solver.__del__(), ArithRef.__div__(), BitVecRef.__div__(), ExprRef.__eq__(), ArithRef.__ge__(), BitVecRef.__ge__(), AstVector.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), AstMap.__getitem__(), ArithRef.__gt__(), BitVecRef.__gt__(), BitVecRef.__invert__(), ArithRef.__le__(), BitVecRef.__le__(), AstVector.__len__(), AstMap.__len__(), ModelRef.__len__(), Statistics.__len__(), BitVecRef.__lshift__(), ArithRef.__lt__(), BitVecRef.__lt__(), ArithRef.__mod__(), BitVecRef.__mod__(), BoolRef.__mul__(), ArithRef.__mul__(), BitVecRef.__mul__(), ExprRef.__ne__(), ArithRef.__neg__(), BitVecRef.__neg__(), BitVecRef.__or__(), ArithRef.__pow__(), ArithRef.__radd__(), BitVecRef.__radd__(), BitVecRef.__rand__(), ArithRef.__rdiv__(), BitVecRef.__rdiv__(), ParamsRef.__repr__(), ParamDescrsRef.__repr__(), AstMap.__repr__(), Statistics.__repr__(), BitVecRef.__rlshift__(), ArithRef.__rmod__(), BitVecRef.__rmod__(), ArithRef.__rmul__(), BitVecRef.__rmul__(), BitVecRef.__ror__(), ArithRef.__rpow__(), BitVecRef.__rrshift__(), BitVecRef.__rshift__(), ArithRef.__rsub__(), BitVecRef.__rsub__(), BitVecRef.__rxor__(), AstVector.__setitem__(), AstMap.__setitem__(), ArithRef.__sub__(), BitVecRef.__sub__(), BitVecRef.__xor__(), DatatypeSortRef.accessor(), ExprRef.arg(), FuncEntry.arg_value(), FuncInterp.arity(), Goal.as_expr(), Solver.assert_and_track(), Goal.assert_exprs(), Solver.assert_exprs(), QuantifierRef.body(), Solver.check(), Goal.convert_model(), AstRef.ctx_ref(), ExprRef.decl(), ModelRef.decls(), ArrayRef.default(), RatNumRef.denominator(), Goal.depth(), Goal.dimacs(), FuncDeclRef.domain(), ArraySortRef.domain_n(), FuncInterp.else_value(), FuncInterp.entry(), AstMap.erase(), ModelRef.eval(), Goal.get(), ParamDescrsRef.get_documentation(), ModelRef.get_interp(), Statistics.get_key_value(), ParamDescrsRef.get_kind(), ParamDescrsRef.get_name(), ModelRef.get_sort(), ModelRef.get_universe(), Goal.inconsistent(), AstMap.keys(), Statistics.keys(), Solver.model(), SortRef.name(), QuantifierRef.no_pattern(), FuncEntry.num_args(), FuncInterp.num_entries(), Solver.num_scopes(), ModelRef.num_sorts(), FuncDeclRef.params(), QuantifierRef.pattern(), AlgebraicNumRef.poly(), Solver.pop(), Goal.prec(), ModelRef.project(), ModelRef.project_with_witness(), Solver.push(), AstVector.push(), QuantifierRef.qid(), FuncDeclRef.range(), ArraySortRef.range(), DatatypeSortRef.recognizer(), Context.ref(), AstMap.reset(), Solver.reset(), AstVector.resize(), Solver.set(), ParamsRef.set(), Goal.sexpr(), AstVector.sexpr(), ModelRef.sexpr(), ParamDescrsRef.size(), Goal.size(), QuantifierRef.skolem_id(), AstVector.translate(), AstRef.translate(), Goal.translate(), ModelRef.translate(), ExprRef.update(), DatatypeRef.update_field(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().