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

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

3887 def __and__(self, other):
3888 """Create the Z3 expression bitwise-and `self & other`.
3889
3890 >>> x = BitVec('x', 32)
3891 >>> y = BitVec('y', 32)
3892 >>> x & y
3893 x & y
3894 >>> (x & y).sort()
3895 BitVec(32)
3896 """
3897 a, b = _coerce_exprs(self, other)
3898 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3899
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 3964 of file z3py.py.

3964 def __div__(self, other):
3965 """Create the Z3 expression (signed) division `self / other`.
3966
3967 Use the function UDiv() for unsigned division.
3968
3969 >>> x = BitVec('x', 32)
3970 >>> y = BitVec('y', 32)
3971 >>> x / y
3972 x/y
3973 >>> (x / y).sort()
3974 BitVec(32)
3975 >>> (x / y).sexpr()
3976 '(bvsdiv x y)'
3977 >>> UDiv(x, y).sexpr()
3978 '(bvudiv x y)'
3979 """
3980 a, b = _coerce_exprs(self, other)
3981 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3982
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 4094 of file z3py.py.

4094 def __ge__(self, other):
4095 """Create the Z3 expression (signed) `other >= self`.
4096
4097 Use the function UGE() for unsigned greater than or equal to.
4098
4099 >>> x, y = BitVecs('x y', 32)
4100 >>> x >= y
4101 x >= y
4102 >>> (x >= y).sexpr()
4103 '(bvsge x y)'
4104 >>> UGE(x, y).sexpr()
4105 '(bvuge x y)'
4106 """
4107 a, b = _coerce_exprs(self, other)
4108 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4109
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 4078 of file z3py.py.

4078 def __gt__(self, other):
4079 """Create the Z3 expression (signed) `other > self`.
4080
4081 Use the function UGT() for unsigned greater than.
4082
4083 >>> x, y = BitVecs('x y', 32)
4084 >>> x > y
4085 x > y
4086 >>> (x > y).sexpr()
4087 '(bvsgt x y)'
4088 >>> UGT(x, y).sexpr()
4089 '(bvugt x y)'
4090 """
4091 a, b = _coerce_exprs(self, other)
4092 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4093
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 3953 of file z3py.py.

3953 def __invert__(self):
3954 """Create the Z3 expression bitwise-not `~self`.
3955
3956 >>> x = BitVec('x', 32)
3957 >>> ~x
3958 ~x
3959 >>> simplify(~(~x))
3960 x
3961 """
3962 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3963
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 4046 of file z3py.py.

4046 def __le__(self, other):
4047 """Create the Z3 expression (signed) `other <= self`.
4048
4049 Use the function ULE() for unsigned less than or equal to.
4050
4051 >>> x, y = BitVecs('x y', 32)
4052 >>> x <= y
4053 x <= y
4054 >>> (x <= y).sexpr()
4055 '(bvsle x y)'
4056 >>> ULE(x, y).sexpr()
4057 '(bvule x y)'
4058 """
4059 a, b = _coerce_exprs(self, other)
4060 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4061
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 4140 of file z3py.py.

4140 def __lshift__(self, other):
4141 """Create the Z3 expression left shift `self << other`
4142
4143 >>> x, y = BitVecs('x y', 32)
4144 >>> x << y
4145 x << y
4146 >>> (x << y).sexpr()
4147 '(bvshl x y)'
4148 >>> simplify(BitVecVal(2, 3) << 1)
4149 4
4150 """
4151 a, b = _coerce_exprs(self, other)
4152 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4153
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 4062 of file z3py.py.

4062 def __lt__(self, other):
4063 """Create the Z3 expression (signed) `other < self`.
4064
4065 Use the function ULT() for unsigned less than.
4066
4067 >>> x, y = BitVecs('x y', 32)
4068 >>> x < y
4069 x < y
4070 >>> (x < y).sexpr()
4071 '(bvslt x y)'
4072 >>> ULT(x, y).sexpr()
4073 '(bvult x y)'
4074 """
4075 a, b = _coerce_exprs(self, other)
4076 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4077
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 4007 of file z3py.py.

4007 def __mod__(self, other):
4008 """Create the Z3 expression (signed) mod `self % other`.
4009
4010 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
4011
4012 >>> x = BitVec('x', 32)
4013 >>> y = BitVec('y', 32)
4014 >>> x % y
4015 x%y
4016 >>> (x % y).sort()
4017 BitVec(32)
4018 >>> (x % y).sexpr()
4019 '(bvsmod x y)'
4020 >>> URem(x, y).sexpr()
4021 '(bvurem x y)'
4022 >>> SRem(x, y).sexpr()
4023 '(bvsrem x y)'
4024 """
4025 a, b = _coerce_exprs(self, other)
4026 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4027
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 3818 of file z3py.py.

3818 def __mul__(self, other):
3819 """Create the Z3 expression `self * other`.
3820
3821 >>> x = BitVec('x', 32)
3822 >>> y = BitVec('y', 32)
3823 >>> x * y
3824 x*y
3825 >>> (x * y).sort()
3826 BitVec(32)
3827 """
3828 a, b = _coerce_exprs(self, other)
3829 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3830
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 3942 of file z3py.py.

3942 def __neg__(self):
3943 """Return an expression representing `-self`.
3944
3945 >>> x = BitVec('x', 32)
3946 >>> -x
3947 -x
3948 >>> simplify(-(-x))
3949 x
3950 """
3951 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3952
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 3864 of file z3py.py.

3864 def __or__(self, other):
3865 """Create the Z3 expression bitwise-or `self | other`.
3866
3867 >>> x = BitVec('x', 32)
3868 >>> y = BitVec('y', 32)
3869 >>> x | y
3870 x | y
3871 >>> (x | y).sort()
3872 BitVec(32)
3873 """
3874 a, b = _coerce_exprs(self, other)
3875 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3876
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 3933 of file z3py.py.

3933 def __pos__(self):
3934 """Return `self`.
3935
3936 >>> x = BitVec('x', 32)
3937 >>> +x
3938 x
3939 """
3940 return self
3941

◆ __radd__()

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

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

Definition at line 3808 of file z3py.py.

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

◆ __rand__()

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

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

Definition at line 3900 of file z3py.py.

3900 def __rand__(self, other):
3901 """Create the Z3 expression bitwise-or `other & self`.
3902
3903 >>> x = BitVec('x', 32)
3904 >>> 10 & x
3905 10 & x
3906 """
3907 a, b = _coerce_exprs(self, other)
3908 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3909

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

3987 def __rdiv__(self, other):
3988 """Create the Z3 expression (signed) division `other / self`.
3989
3990 Use the function UDiv() for unsigned division.
3991
3992 >>> x = BitVec('x', 32)
3993 >>> 10 / x
3994 10/x
3995 >>> (10 / x).sexpr()
3996 '(bvsdiv #x0000000a x)'
3997 >>> UDiv(10, x).sexpr()
3998 '(bvudiv #x0000000a x)'
3999 """
4000 a, b = _coerce_exprs(self, other)
4001 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4002

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

4168 def __rlshift__(self, other):
4169 """Create the Z3 expression left shift `other << self`.
4170
4171 Use the function LShR() for the right logical shift
4172
4173 >>> x = BitVec('x', 32)
4174 >>> 10 << x
4175 10 << x
4176 >>> (10 << x).sexpr()
4177 '(bvshl #x0000000a x)'
4178 """
4179 a, b = _coerce_exprs(self, other)
4180 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4181
4182

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

4028 def __rmod__(self, other):
4029 """Create the Z3 expression (signed) mod `other % self`.
4030
4031 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
4032
4033 >>> x = BitVec('x', 32)
4034 >>> 10 % x
4035 10%x
4036 >>> (10 % x).sexpr()
4037 '(bvsmod #x0000000a x)'
4038 >>> URem(10, x).sexpr()
4039 '(bvurem #x0000000a x)'
4040 >>> SRem(10, x).sexpr()
4041 '(bvsrem #x0000000a x)'
4042 """
4043 a, b = _coerce_exprs(self, other)
4044 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4045

◆ __rmul__()

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

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

Definition at line 3831 of file z3py.py.

3831 def __rmul__(self, other):
3832 """Create the Z3 expression `other * self`.
3833
3834 >>> x = BitVec('x', 32)
3835 >>> 10 * x
3836 10*x
3837 """
3838 a, b = _coerce_exprs(self, other)
3839 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3840

◆ __ror__()

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

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

Definition at line 3877 of file z3py.py.

3877 def __ror__(self, other):
3878 """Create the Z3 expression bitwise-or `other | self`.
3879
3880 >>> x = BitVec('x', 32)
3881 >>> 10 | x
3882 10 | x
3883 """
3884 a, b = _coerce_exprs(self, other)
3885 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3886

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

4154 def __rrshift__(self, other):
4155 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
4156
4157 Use the function LShR() for the right logical shift
4158
4159 >>> x = BitVec('x', 32)
4160 >>> 10 >> x
4161 10 >> x
4162 >>> (10 >> x).sexpr()
4163 '(bvashr #x0000000a x)'
4164 """
4165 a, b = _coerce_exprs(self, other)
4166 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4167
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 4110 of file z3py.py.

4110 def __rshift__(self, other):
4111 """Create the Z3 expression (arithmetical) right shift `self >> other`
4112
4113 Use the function LShR() for the right logical shift
4114
4115 >>> x, y = BitVecs('x y', 32)
4116 >>> x >> y
4117 x >> y
4118 >>> (x >> y).sexpr()
4119 '(bvashr x y)'
4120 >>> LShR(x, y).sexpr()
4121 '(bvlshr x y)'
4122 >>> BitVecVal(4, 3)
4123 4
4124 >>> BitVecVal(4, 3).as_signed_long()
4125 -4
4126 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
4127 -2
4128 >>> simplify(BitVecVal(4, 3) >> 1)
4129 6
4130 >>> simplify(LShR(BitVecVal(4, 3), 1))
4131 2
4132 >>> simplify(BitVecVal(2, 3) >> 1)
4133 1
4134 >>> simplify(LShR(BitVecVal(2, 3), 1))
4135 1
4136 """
4137 a, b = _coerce_exprs(self, other)
4138 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
4139

◆ __rsub__()

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

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

Definition at line 3854 of file z3py.py.

3854 def __rsub__(self, other):
3855 """Create the Z3 expression `other - self`.
3856
3857 >>> x = BitVec('x', 32)
3858 >>> 10 - x
3859 10 - x
3860 """
3861 a, b = _coerce_exprs(self, other)
3862 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3863
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 4003 of file z3py.py.

4003 def __rtruediv__(self, other):
4004 """Create the Z3 expression (signed) division `other / self`."""
4005 return self.__rdiv__(other)
4006

◆ __rxor__()

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

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

Definition at line 3923 of file z3py.py.

3923 def __rxor__(self, other):
3924 """Create the Z3 expression bitwise-xor `other ^ self`.
3925
3926 >>> x = BitVec('x', 32)
3927 >>> 10 ^ x
3928 10 ^ x
3929 """
3930 a, b = _coerce_exprs(self, other)
3931 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3932
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 3841 of file z3py.py.

3841 def __sub__(self, other):
3842 """Create the Z3 expression `self - other`.
3843
3844 >>> x = BitVec('x', 32)
3845 >>> y = BitVec('y', 32)
3846 >>> x - y
3847 x - y
3848 >>> (x - y).sort()
3849 BitVec(32)
3850 """
3851 a, b = _coerce_exprs(self, other)
3852 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3853

◆ __truediv__()

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

Definition at line 3983 of file z3py.py.

3983 def __truediv__(self, other):
3984 """Create the Z3 expression (signed) division `self / other`."""
3985 return self.__div__(other)
3986

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

3910 def __xor__(self, other):
3911 """Create the Z3 expression bitwise-xor `self ^ other`.
3912
3913 >>> x = BitVec('x', 32)
3914 >>> y = BitVec('y', 32)
3915 >>> x ^ y
3916 x ^ y
3917 >>> (x ^ y).sort()
3918 BitVec(32)
3919 """
3920 a, b = _coerce_exprs(self, other)
3921 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3922

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

3784 def size(self):
3785 """Return the number of bits of the bit-vector expression `self`.
3786
3787 >>> x = BitVec('x', 32)
3788 >>> (x + 1).size()
3789 32
3790 >>> Concat(x, x).size()
3791 64
3792 """
3793 return self.sort().size()
3794

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

3773 def sort(self):
3774 """Return the sort of the bit-vector expression `self`.
3775
3776 >>> x = BitVec('x', 32)
3777 >>> x.sort()
3778 BitVec(32)
3779 >>> x.sort() == BitVecSort(32)
3780 True
3781 """
3782 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3783
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 3782 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().