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

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

3754 def __and__(self, other):
3755 """Create the Z3 expression bitwise-and `self & other`.
3756
3757 >>> x = BitVec('x', 32)
3758 >>> y = BitVec('y', 32)
3759 >>> x & y
3760 x & y
3761 >>> (x & y).sort()
3762 BitVec(32)
3763 """
3764 a, b = _coerce_exprs(self, other)
3765 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3766
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 3831 of file z3py.py.

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

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

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

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

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

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

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

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

3685 def __mul__(self, other):
3686 """Create the Z3 expression `self * other`.
3687
3688 >>> x = BitVec('x', 32)
3689 >>> y = BitVec('y', 32)
3690 >>> x * y
3691 x*y
3692 >>> (x * y).sort()
3693 BitVec(32)
3694 """
3695 a, b = _coerce_exprs(self, other)
3696 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3697
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 3809 of file z3py.py.

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

3731 def __or__(self, other):
3732 """Create the Z3 expression bitwise-or `self | other`.
3733
3734 >>> x = BitVec('x', 32)
3735 >>> y = BitVec('y', 32)
3736 >>> x | y
3737 x | y
3738 >>> (x | y).sort()
3739 BitVec(32)
3740 """
3741 a, b = _coerce_exprs(self, other)
3742 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3743
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 3800 of file z3py.py.

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

◆ __radd__()

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

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

Definition at line 3675 of file z3py.py.

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

◆ __rand__()

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

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

Definition at line 3767 of file z3py.py.

3767 def __rand__(self, other):
3768 """Create the Z3 expression bitwise-or `other & self`.
3769
3770 >>> x = BitVec('x', 32)
3771 >>> 10 & x
3772 10 & x
3773 """
3774 a, b = _coerce_exprs(self, other)
3775 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3776

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

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

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

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

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

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

◆ __rmul__()

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

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

Definition at line 3698 of file z3py.py.

3698 def __rmul__(self, other):
3699 """Create the Z3 expression `other * self`.
3700
3701 >>> x = BitVec('x', 32)
3702 >>> 10 * x
3703 10*x
3704 """
3705 a, b = _coerce_exprs(self, other)
3706 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3707

◆ __ror__()

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

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

Definition at line 3744 of file z3py.py.

3744 def __ror__(self, other):
3745 """Create the Z3 expression bitwise-or `other | self`.
3746
3747 >>> x = BitVec('x', 32)
3748 >>> 10 | x
3749 10 | x
3750 """
3751 a, b = _coerce_exprs(self, other)
3752 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3753

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

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

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

◆ __rsub__()

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

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

Definition at line 3721 of file z3py.py.

3721 def __rsub__(self, other):
3722 """Create the Z3 expression `other - self`.
3723
3724 >>> x = BitVec('x', 32)
3725 >>> 10 - x
3726 10 - x
3727 """
3728 a, b = _coerce_exprs(self, other)
3729 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3730
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 3870 of file z3py.py.

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

◆ __rxor__()

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

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

Definition at line 3790 of file z3py.py.

3790 def __rxor__(self, other):
3791 """Create the Z3 expression bitwise-xor `other ^ self`.
3792
3793 >>> x = BitVec('x', 32)
3794 >>> 10 ^ x
3795 10 ^ x
3796 """
3797 a, b = _coerce_exprs(self, other)
3798 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3799
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 3708 of file z3py.py.

3708 def __sub__(self, other):
3709 """Create the Z3 expression `self - other`.
3710
3711 >>> x = BitVec('x', 32)
3712 >>> y = BitVec('y', 32)
3713 >>> x - y
3714 x - y
3715 >>> (x - y).sort()
3716 BitVec(32)
3717 """
3718 a, b = _coerce_exprs(self, other)
3719 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3720

◆ __truediv__()

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

Definition at line 3850 of file z3py.py.

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

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

3777 def __xor__(self, other):
3778 """Create the Z3 expression bitwise-xor `self ^ other`.
3779
3780 >>> x = BitVec('x', 32)
3781 >>> y = BitVec('y', 32)
3782 >>> x ^ y
3783 x ^ y
3784 >>> (x ^ y).sort()
3785 BitVec(32)
3786 """
3787 a, b = _coerce_exprs(self, other)
3788 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3789

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

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

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

3640 def sort(self):
3641 """Return the sort of the bit-vector expression `self`.
3642
3643 >>> x = BitVec('x', 32)
3644 >>> x.sort()
3645 BitVec(32)
3646 >>> x.sort() == BitVecSort(32)
3647 True
3648 """
3649 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3650
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 3649 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(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().