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

3680 def __add__(self, other):
3681 """Create the Z3 expression `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_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3692
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 3772 of file z3py.py.

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

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

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

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

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

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

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

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

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

3703 def __mul__(self, other):
3704 """Create the Z3 expression `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_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3715
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 3827 of file z3py.py.

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

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

3818 def __pos__(self):
3819 """Return `self`.
3820
3821 >>> x = BitVec('x', 32)
3822 >>> +x
3823 x
3824 """
3825 return self
3826

◆ __radd__()

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

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

Definition at line 3693 of file z3py.py.

3693 def __radd__(self, other):
3694 """Create the Z3 expression `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_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3702

◆ __rand__()

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

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

Definition at line 3785 of file z3py.py.

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

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

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

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

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

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

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

◆ __rmul__()

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

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

Definition at line 3716 of file z3py.py.

3716 def __rmul__(self, other):
3717 """Create the Z3 expression `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_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3725

◆ __ror__()

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

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

Definition at line 3762 of file z3py.py.

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

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

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

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

◆ __rsub__()

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

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

Definition at line 3739 of file z3py.py.

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

3888 def __rtruediv__(self, other):
3889 """Create the Z3 expression (signed) division `other / self`."""
3890 return self.__rdiv__(other)
3891

◆ __rxor__()

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

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

Definition at line 3808 of file z3py.py.

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

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

◆ __truediv__()

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

Definition at line 3868 of file z3py.py.

3868 def __truediv__(self, other):
3869 """Create the Z3 expression (signed) division `self / other`."""
3870 return self.__div__(other)
3871

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

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

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

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

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

3658 def sort(self):
3659 """Return the sort of the bit-vector expression `self`.
3660
3661 >>> x = BitVec('x', 32)
3662 >>> x.sort()
3663 BitVec(32)
3664 >>> x.sort() == BitVecSort(32)
3665 True
3666 """
3667 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3668
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 3667 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(), FiniteSetSortRef.cast(), 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().