Z3
Public Member Functions
BitVecRef Class Reference
+ Inheritance diagram for BitVecRef:

Public Member Functions

def sort (self)
 
def size (self)
 
def __add__ (self, other)
 
def __radd__ (self, other)
 
def __mul__ (self, other)
 
def __rmul__ (self, other)
 
def __sub__ (self, other)
 
def __rsub__ (self, other)
 
def __or__ (self, other)
 
def __ror__ (self, other)
 
def __and__ (self, other)
 
def __rand__ (self, other)
 
def __xor__ (self, other)
 
def __rxor__ (self, other)
 
def __pos__ (self)
 
def __neg__ (self)
 
def __invert__ (self)
 
def __div__ (self, other)
 
def __truediv__ (self, other)
 
def __rdiv__ (self, other)
 
def __rtruediv__ (self, other)
 
def __mod__ (self, other)
 
def __rmod__ (self, other)
 
def __le__ (self, other)
 
def __lt__ (self, other)
 
def __gt__ (self, other)
 
def __ge__ (self, other)
 
def __rshift__ (self, other)
 
def __lshift__ (self, other)
 
def __rrshift__ (self, other)
 
def __rlshift__ (self, other)
 
- Public Member Functions inherited from ExprRef
def as_ast (self)
 
def get_id (self)
 
def sort (self)
 
def sort_kind (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __ne__ (self, other)
 
def decl (self)
 
def num_args (self)
 
def arg (self, idx)
 
def children (self)
 
- Public Member Functions inherited from AstRef
def __init__ (self, ast, ctx=None)
 
def __del__ (self)
 
def __str__ (self)
 
def __repr__ (self)
 
def __eq__ (self, other)
 
def __hash__ (self)
 
def __nonzero__ (self)
 
def __bool__ (self)
 
def sexpr (self)
 
def as_ast (self)
 
def get_id (self)
 
def ctx_ref (self)
 
def eq (self, other)
 
def translate (self, target)
 
def hash (self)
 
- Public Member Functions inherited from Z3PPObject
def use_pp (self)
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

Bit-vector expressions.

Definition at line 3030 of file z3py.py.

Member Function Documentation

§ __add__()

def __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 3055 of file z3py.py.

3055  def __add__(self, other):
3056  """Create the Z3 expression `self + other`.
3057 
3058  >>> x = BitVec('x', 32)
3059  >>> y = BitVec('y', 32)
3060  >>> x + y
3061  x + y
3062  >>> (x + y).sort()
3063  BitVec(32)
3064  """
3065  a, b = _coerce_exprs(self, other)
3066  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3067 
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.

§ __and__()

def __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 3147 of file z3py.py.

3147  def __and__(self, other):
3148  """Create the Z3 expression bitwise-and `self & other`.
3149 
3150  >>> x = BitVec('x', 32)
3151  >>> y = BitVec('y', 32)
3152  >>> x & y
3153  x & y
3154  >>> (x & y).sort()
3155  BitVec(32)
3156  """
3157  a, b = _coerce_exprs(self, other)
3158  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3159 
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.

§ __div__()

def __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 3224 of file z3py.py.

3224  def __div__(self, other):
3225  """Create the Z3 expression (signed) division `self / other`.
3226 
3227  Use the function UDiv() for unsigned division.
3228 
3229  >>> x = BitVec('x', 32)
3230  >>> y = BitVec('y', 32)
3231  >>> x / y
3232  x/y
3233  >>> (x / y).sort()
3234  BitVec(32)
3235  >>> (x / y).sexpr()
3236  '(bvsdiv x y)'
3237  >>> UDiv(x, y).sexpr()
3238  '(bvudiv x y)'
3239  """
3240  a, b = _coerce_exprs(self, other)
3241  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3242 
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.

§ __ge__()

def __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 3354 of file z3py.py.

3354  def __ge__(self, other):
3355  """Create the Z3 expression (signed) `other >= self`.
3356 
3357  Use the function UGE() for unsigned greater than or equal to.
3358 
3359  >>> x, y = BitVecs('x y', 32)
3360  >>> x >= y
3361  x >= y
3362  >>> (x >= y).sexpr()
3363  '(bvsge x y)'
3364  >>> UGE(x, y).sexpr()
3365  '(bvuge x y)'
3366  """
3367  a, b = _coerce_exprs(self, other)
3368  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3369 
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__()

def __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 3338 of file z3py.py.

3338  def __gt__(self, other):
3339  """Create the Z3 expression (signed) `other > self`.
3340 
3341  Use the function UGT() for unsigned greater than.
3342 
3343  >>> x, y = BitVecs('x y', 32)
3344  >>> x > y
3345  x > y
3346  >>> (x > y).sexpr()
3347  '(bvsgt x y)'
3348  >>> UGT(x, y).sexpr()
3349  '(bvugt x y)'
3350  """
3351  a, b = _coerce_exprs(self, other)
3352  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3353 
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.

§ __invert__()

def __invert__ (   self)
Create the Z3 expression bitwise-not `~self`.

>>> x = BitVec('x', 32)
>>> ~x
~x
>>> simplify(~(~x))
x

Definition at line 3213 of file z3py.py.

3213  def __invert__(self):
3214  """Create the Z3 expression bitwise-not `~self`.
3215 
3216  >>> x = BitVec('x', 32)
3217  >>> ~x
3218  ~x
3219  >>> simplify(~(~x))
3220  x
3221  """
3222  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3223 
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.

§ __le__()

def __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 3306 of file z3py.py.

3306  def __le__(self, other):
3307  """Create the Z3 expression (signed) `other <= self`.
3308 
3309  Use the function ULE() for unsigned less than or equal to.
3310 
3311  >>> x, y = BitVecs('x y', 32)
3312  >>> x <= y
3313  x <= y
3314  >>> (x <= y).sexpr()
3315  '(bvsle x y)'
3316  >>> ULE(x, y).sexpr()
3317  '(bvule x y)'
3318  """
3319  a, b = _coerce_exprs(self, other)
3320  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3321 
Z3_ast Z3_API Z3_mk_bvsle(Z3_context c, Z3_ast t1, Z3_ast t2)
Two&#39;s complement signed less than or equal to.

§ __lshift__()

def __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 3400 of file z3py.py.

3400  def __lshift__(self, other):
3401  """Create the Z3 expression left shift `self << other`
3402 
3403  >>> x, y = BitVecs('x y', 32)
3404  >>> x << y
3405  x << y
3406  >>> (x << y).sexpr()
3407  '(bvshl x y)'
3408  >>> simplify(BitVecVal(2, 3) << 1)
3409  4
3410  """
3411  a, b = _coerce_exprs(self, other)
3412  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3413 
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.

§ __lt__()

def __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 3322 of file z3py.py.

3322  def __lt__(self, other):
3323  """Create the Z3 expression (signed) `other < self`.
3324 
3325  Use the function ULT() for unsigned less than.
3326 
3327  >>> x, y = BitVecs('x y', 32)
3328  >>> x < y
3329  x < y
3330  >>> (x < y).sexpr()
3331  '(bvslt x y)'
3332  >>> ULT(x, y).sexpr()
3333  '(bvult x y)'
3334  """
3335  a, b = _coerce_exprs(self, other)
3336  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3337 
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two&#39;s complement signed less than.

§ __mod__()

def __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 3267 of file z3py.py.

3267  def __mod__(self, other):
3268  """Create the Z3 expression (signed) mod `self % other`.
3269 
3270  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3271 
3272  >>> x = BitVec('x', 32)
3273  >>> y = BitVec('y', 32)
3274  >>> x % y
3275  x%y
3276  >>> (x % y).sort()
3277  BitVec(32)
3278  >>> (x % y).sexpr()
3279  '(bvsmod x y)'
3280  >>> URem(x, y).sexpr()
3281  '(bvurem x y)'
3282  >>> SRem(x, y).sexpr()
3283  '(bvsrem x y)'
3284  """
3285  a, b = _coerce_exprs(self, other)
3286  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3287 
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two&#39;s complement signed remainder (sign follows divisor).

§ __mul__()

def __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 3078 of file z3py.py.

3078  def __mul__(self, other):
3079  """Create the Z3 expression `self * other`.
3080 
3081  >>> x = BitVec('x', 32)
3082  >>> y = BitVec('y', 32)
3083  >>> x * y
3084  x*y
3085  >>> (x * y).sort()
3086  BitVec(32)
3087  """
3088  a, b = _coerce_exprs(self, other)
3089  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3090 
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement multiplication.

§ __neg__()

def __neg__ (   self)
Return an expression representing `-self`.

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

Definition at line 3202 of file z3py.py.

3202  def __neg__(self):
3203  """Return an expression representing `-self`.
3204 
3205  >>> x = BitVec('x', 32)
3206  >>> -x
3207  -x
3208  >>> simplify(-(-x))
3209  x
3210  """
3211  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3212 
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two&#39;s complement unary minus.

§ __or__()

def __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 3124 of file z3py.py.

3124  def __or__(self, other):
3125  """Create the Z3 expression bitwise-or `self | other`.
3126 
3127  >>> x = BitVec('x', 32)
3128  >>> y = BitVec('y', 32)
3129  >>> x | y
3130  x | y
3131  >>> (x | y).sort()
3132  BitVec(32)
3133  """
3134  a, b = _coerce_exprs(self, other)
3135  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3136 
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.

§ __pos__()

def __pos__ (   self)
Return `self`.

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

Definition at line 3193 of file z3py.py.

3193  def __pos__(self):
3194  """Return `self`.
3195 
3196  >>> x = BitVec('x', 32)
3197  >>> +x
3198  x
3199  """
3200  return self
3201 

§ __radd__()

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

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

Definition at line 3068 of file z3py.py.

3068  def __radd__(self, other):
3069  """Create the Z3 expression `other + self`.
3070 
3071  >>> x = BitVec('x', 32)
3072  >>> 10 + x
3073  10 + x
3074  """
3075  a, b = _coerce_exprs(self, other)
3076  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3077 
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement addition.

§ __rand__()

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

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

Definition at line 3160 of file z3py.py.

3160  def __rand__(self, other):
3161  """Create the Z3 expression bitwise-or `other & self`.
3162 
3163  >>> x = BitVec('x', 32)
3164  >>> 10 & x
3165  10 & x
3166  """
3167  a, b = _coerce_exprs(self, other)
3168  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3169 
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.

§ __rdiv__()

def __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 3247 of file z3py.py.

3247  def __rdiv__(self, other):
3248  """Create the Z3 expression (signed) division `other / self`.
3249 
3250  Use the function UDiv() for unsigned division.
3251 
3252  >>> x = BitVec('x', 32)
3253  >>> 10 / x
3254  10/x
3255  >>> (10 / x).sexpr()
3256  '(bvsdiv #x0000000a x)'
3257  >>> UDiv(10, x).sexpr()
3258  '(bvudiv #x0000000a x)'
3259  """
3260  a, b = _coerce_exprs(self, other)
3261  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3262 
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two&#39;s complement signed division.

§ __rlshift__()

def __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 3428 of file z3py.py.

3428  def __rlshift__(self, other):
3429  """Create the Z3 expression left shift `other << self`.
3430 
3431  Use the function LShR() for the right logical shift
3432 
3433  >>> x = BitVec('x', 32)
3434  >>> 10 << x
3435  10 << x
3436  >>> (10 << x).sexpr()
3437  '(bvshl #x0000000a x)'
3438  """
3439  a, b = _coerce_exprs(self, other)
3440  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3441 
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.

§ __rmod__()

def __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 3288 of file z3py.py.

3288  def __rmod__(self, other):
3289  """Create the Z3 expression (signed) mod `other % self`.
3290 
3291  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3292 
3293  >>> x = BitVec('x', 32)
3294  >>> 10 % x
3295  10%x
3296  >>> (10 % x).sexpr()
3297  '(bvsmod #x0000000a x)'
3298  >>> URem(10, x).sexpr()
3299  '(bvurem #x0000000a x)'
3300  >>> SRem(10, x).sexpr()
3301  '(bvsrem #x0000000a x)'
3302  """
3303  a, b = _coerce_exprs(self, other)
3304  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3305 
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two&#39;s complement signed remainder (sign follows divisor).

§ __rmul__()

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

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

Definition at line 3091 of file z3py.py.

3091  def __rmul__(self, other):
3092  """Create the Z3 expression `other * self`.
3093 
3094  >>> x = BitVec('x', 32)
3095  >>> 10 * x
3096  10*x
3097  """
3098  a, b = _coerce_exprs(self, other)
3099  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3100 
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement multiplication.

§ __ror__()

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

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

Definition at line 3137 of file z3py.py.

3137  def __ror__(self, other):
3138  """Create the Z3 expression bitwise-or `other | self`.
3139 
3140  >>> x = BitVec('x', 32)
3141  >>> 10 | x
3142  10 | x
3143  """
3144  a, b = _coerce_exprs(self, other)
3145  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3146 
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.

§ __rrshift__()

def __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 3414 of file z3py.py.

3414  def __rrshift__(self, other):
3415  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3416 
3417  Use the function LShR() for the right logical shift
3418 
3419  >>> x = BitVec('x', 32)
3420  >>> 10 >> x
3421  10 >> x
3422  >>> (10 >> x).sexpr()
3423  '(bvashr #x0000000a x)'
3424  """
3425  a, b = _coerce_exprs(self, other)
3426  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3427 
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.

§ __rshift__()

def __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 3370 of file z3py.py.

3370  def __rshift__(self, other):
3371  """Create the Z3 expression (arithmetical) right shift `self >> other`
3372 
3373  Use the function LShR() for the right logical shift
3374 
3375  >>> x, y = BitVecs('x y', 32)
3376  >>> x >> y
3377  x >> y
3378  >>> (x >> y).sexpr()
3379  '(bvashr x y)'
3380  >>> LShR(x, y).sexpr()
3381  '(bvlshr x y)'
3382  >>> BitVecVal(4, 3)
3383  4
3384  >>> BitVecVal(4, 3).as_signed_long()
3385  -4
3386  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3387  -2
3388  >>> simplify(BitVecVal(4, 3) >> 1)
3389  6
3390  >>> simplify(LShR(BitVecVal(4, 3), 1))
3391  2
3392  >>> simplify(BitVecVal(2, 3) >> 1)
3393  1
3394  >>> simplify(LShR(BitVecVal(2, 3), 1))
3395  1
3396  """
3397  a, b = _coerce_exprs(self, other)
3398  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3399 
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.

§ __rsub__()

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

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

Definition at line 3114 of file z3py.py.

3114  def __rsub__(self, other):
3115  """Create the Z3 expression `other - self`.
3116 
3117  >>> x = BitVec('x', 32)
3118  >>> 10 - x
3119  10 - x
3120  """
3121  a, b = _coerce_exprs(self, other)
3122  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3123 
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement subtraction.

§ __rtruediv__()

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

Definition at line 3263 of file z3py.py.

3263  def __rtruediv__(self, other):
3264  """Create the Z3 expression (signed) division `other / self`."""
3265  return self.__rdiv__(other)
3266 

§ __rxor__()

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

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

Definition at line 3183 of file z3py.py.

3183  def __rxor__(self, other):
3184  """Create the Z3 expression bitwise-xor `other ^ self`.
3185 
3186  >>> x = BitVec('x', 32)
3187  >>> 10 ^ x
3188  10 ^ x
3189  """
3190  a, b = _coerce_exprs(self, other)
3191  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3192 
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.

§ __sub__()

def __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 3101 of file z3py.py.

3101  def __sub__(self, other):
3102  """Create the Z3 expression `self - other`.
3103 
3104  >>> x = BitVec('x', 32)
3105  >>> y = BitVec('y', 32)
3106  >>> x - y
3107  x - y
3108  >>> (x - y).sort()
3109  BitVec(32)
3110  """
3111  a, b = _coerce_exprs(self, other)
3112  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3113 
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement subtraction.

§ __truediv__()

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

Definition at line 3243 of file z3py.py.

3243  def __truediv__(self, other):
3244  """Create the Z3 expression (signed) division `self / other`."""
3245  return self.__div__(other)
3246 

§ __xor__()

def __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 3170 of file z3py.py.

3170  def __xor__(self, other):
3171  """Create the Z3 expression bitwise-xor `self ^ other`.
3172 
3173  >>> x = BitVec('x', 32)
3174  >>> y = BitVec('y', 32)
3175  >>> x ^ y
3176  x ^ y
3177  >>> (x ^ y).sort()
3178  BitVec(32)
3179  """
3180  a, b = _coerce_exprs(self, other)
3181  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3182 
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.

§ size()

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

3044  def size(self):
3045  """Return the number of bits of the bit-vector expression `self`.
3046 
3047  >>> x = BitVec('x', 32)
3048  >>> (x + 1).size()
3049  32
3050  >>> Concat(x, x).size()
3051  64
3052  """
3053  return self.sort().size()
3054 

§ sort()

def sort (   self)
Return the sort of the bit-vector expression `self`.

>>> x = BitVec('x', 32)
>>> x.sort()
BitVec(32)
>>> x.sort() == BitVecSort(32)
True

Definition at line 3033 of file z3py.py.

Referenced by BitVecRef.__add__(), BitVecRef.__and__(), BitVecRef.__div__(), BitVecRef.__mod__(), BitVecRef.__mul__(), BitVecRef.__or__(), BitVecRef.__sub__(), and BitVecRef.__xor__().

3033  def sort(self):
3034  """Return the sort of the bit-vector expression `self`.
3035 
3036  >>> x = BitVec('x', 32)
3037  >>> x.sort()
3038  BitVec(32)
3039  >>> x.sort() == BitVecSort(32)
3040  True
3041  """
3042  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3043