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 params (self)
 
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 __deepcopy__ (self, memo={})
 
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 3071 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 3096 of file z3py.py.

3096  def __add__(self, other):
3097  """Create the Z3 expression `self + other`.
3098 
3099  >>> x = BitVec('x', 32)
3100  >>> y = BitVec('y', 32)
3101  >>> x + y
3102  x + y
3103  >>> (x + y).sort()
3104  BitVec(32)
3105  """
3106  a, b = _coerce_exprs(self, other)
3107  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3108 
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 3188 of file z3py.py.

3188  def __and__(self, other):
3189  """Create the Z3 expression bitwise-and `self & other`.
3190 
3191  >>> x = BitVec('x', 32)
3192  >>> y = BitVec('y', 32)
3193  >>> x & y
3194  x & y
3195  >>> (x & y).sort()
3196  BitVec(32)
3197  """
3198  a, b = _coerce_exprs(self, other)
3199  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3200 
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 3265 of file z3py.py.

3265  def __div__(self, other):
3266  """Create the Z3 expression (signed) division `self / other`.
3267 
3268  Use the function UDiv() for unsigned division.
3269 
3270  >>> x = BitVec('x', 32)
3271  >>> y = BitVec('y', 32)
3272  >>> x / y
3273  x/y
3274  >>> (x / y).sort()
3275  BitVec(32)
3276  >>> (x / y).sexpr()
3277  '(bvsdiv x y)'
3278  >>> UDiv(x, y).sexpr()
3279  '(bvudiv x y)'
3280  """
3281  a, b = _coerce_exprs(self, other)
3282  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3283 
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 3395 of file z3py.py.

3395  def __ge__(self, other):
3396  """Create the Z3 expression (signed) `other >= self`.
3397 
3398  Use the function UGE() for unsigned greater than or equal to.
3399 
3400  >>> x, y = BitVecs('x y', 32)
3401  >>> x >= y
3402  x >= y
3403  >>> (x >= y).sexpr()
3404  '(bvsge x y)'
3405  >>> UGE(x, y).sexpr()
3406  '(bvuge x y)'
3407  """
3408  a, b = _coerce_exprs(self, other)
3409  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3410 
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 3379 of file z3py.py.

3379  def __gt__(self, other):
3380  """Create the Z3 expression (signed) `other > self`.
3381 
3382  Use the function UGT() for unsigned greater than.
3383 
3384  >>> x, y = BitVecs('x y', 32)
3385  >>> x > y
3386  x > y
3387  >>> (x > y).sexpr()
3388  '(bvsgt x y)'
3389  >>> UGT(x, y).sexpr()
3390  '(bvugt x y)'
3391  """
3392  a, b = _coerce_exprs(self, other)
3393  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3394 
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 3254 of file z3py.py.

3254  def __invert__(self):
3255  """Create the Z3 expression bitwise-not `~self`.
3256 
3257  >>> x = BitVec('x', 32)
3258  >>> ~x
3259  ~x
3260  >>> simplify(~(~x))
3261  x
3262  """
3263  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3264 
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 3347 of file z3py.py.

3347  def __le__(self, other):
3348  """Create the Z3 expression (signed) `other <= self`.
3349 
3350  Use the function ULE() for unsigned less than or equal to.
3351 
3352  >>> x, y = BitVecs('x y', 32)
3353  >>> x <= y
3354  x <= y
3355  >>> (x <= y).sexpr()
3356  '(bvsle x y)'
3357  >>> ULE(x, y).sexpr()
3358  '(bvule x y)'
3359  """
3360  a, b = _coerce_exprs(self, other)
3361  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3362 
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 3441 of file z3py.py.

3441  def __lshift__(self, other):
3442  """Create the Z3 expression left shift `self << other`
3443 
3444  >>> x, y = BitVecs('x y', 32)
3445  >>> x << y
3446  x << y
3447  >>> (x << y).sexpr()
3448  '(bvshl x y)'
3449  >>> simplify(BitVecVal(2, 3) << 1)
3450  4
3451  """
3452  a, b = _coerce_exprs(self, other)
3453  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3454 
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 3363 of file z3py.py.

3363  def __lt__(self, other):
3364  """Create the Z3 expression (signed) `other < self`.
3365 
3366  Use the function ULT() for unsigned less than.
3367 
3368  >>> x, y = BitVecs('x y', 32)
3369  >>> x < y
3370  x < y
3371  >>> (x < y).sexpr()
3372  '(bvslt x y)'
3373  >>> ULT(x, y).sexpr()
3374  '(bvult x y)'
3375  """
3376  a, b = _coerce_exprs(self, other)
3377  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3378 
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 3308 of file z3py.py.

3308  def __mod__(self, other):
3309  """Create the Z3 expression (signed) mod `self % other`.
3310 
3311  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3312 
3313  >>> x = BitVec('x', 32)
3314  >>> y = BitVec('y', 32)
3315  >>> x % y
3316  x%y
3317  >>> (x % y).sort()
3318  BitVec(32)
3319  >>> (x % y).sexpr()
3320  '(bvsmod x y)'
3321  >>> URem(x, y).sexpr()
3322  '(bvurem x y)'
3323  >>> SRem(x, y).sexpr()
3324  '(bvsrem x y)'
3325  """
3326  a, b = _coerce_exprs(self, other)
3327  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3328 
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 3119 of file z3py.py.

3119  def __mul__(self, other):
3120  """Create the Z3 expression `self * other`.
3121 
3122  >>> x = BitVec('x', 32)
3123  >>> y = BitVec('y', 32)
3124  >>> x * y
3125  x*y
3126  >>> (x * y).sort()
3127  BitVec(32)
3128  """
3129  a, b = _coerce_exprs(self, other)
3130  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3131 
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 3243 of file z3py.py.

3243  def __neg__(self):
3244  """Return an expression representing `-self`.
3245 
3246  >>> x = BitVec('x', 32)
3247  >>> -x
3248  -x
3249  >>> simplify(-(-x))
3250  x
3251  """
3252  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3253 
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 3165 of file z3py.py.

3165  def __or__(self, other):
3166  """Create the Z3 expression bitwise-or `self | other`.
3167 
3168  >>> x = BitVec('x', 32)
3169  >>> y = BitVec('y', 32)
3170  >>> x | y
3171  x | y
3172  >>> (x | y).sort()
3173  BitVec(32)
3174  """
3175  a, b = _coerce_exprs(self, other)
3176  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3177 
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 3234 of file z3py.py.

3234  def __pos__(self):
3235  """Return `self`.
3236 
3237  >>> x = BitVec('x', 32)
3238  >>> +x
3239  x
3240  """
3241  return self
3242 

§ __radd__()

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

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

Definition at line 3109 of file z3py.py.

3109  def __radd__(self, other):
3110  """Create the Z3 expression `other + self`.
3111 
3112  >>> x = BitVec('x', 32)
3113  >>> 10 + x
3114  10 + x
3115  """
3116  a, b = _coerce_exprs(self, other)
3117  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3118 
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 3201 of file z3py.py.

3201  def __rand__(self, other):
3202  """Create the Z3 expression bitwise-or `other & self`.
3203 
3204  >>> x = BitVec('x', 32)
3205  >>> 10 & x
3206  10 & x
3207  """
3208  a, b = _coerce_exprs(self, other)
3209  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3210 
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 3288 of file z3py.py.

3288  def __rdiv__(self, other):
3289  """Create the Z3 expression (signed) division `other / self`.
3290 
3291  Use the function UDiv() for unsigned division.
3292 
3293  >>> x = BitVec('x', 32)
3294  >>> 10 / x
3295  10/x
3296  >>> (10 / x).sexpr()
3297  '(bvsdiv #x0000000a x)'
3298  >>> UDiv(10, x).sexpr()
3299  '(bvudiv #x0000000a x)'
3300  """
3301  a, b = _coerce_exprs(self, other)
3302  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3303 
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 3469 of file z3py.py.

3469  def __rlshift__(self, other):
3470  """Create the Z3 expression left shift `other << self`.
3471 
3472  Use the function LShR() for the right logical shift
3473 
3474  >>> x = BitVec('x', 32)
3475  >>> 10 << x
3476  10 << x
3477  >>> (10 << x).sexpr()
3478  '(bvshl #x0000000a x)'
3479  """
3480  a, b = _coerce_exprs(self, other)
3481  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3482 
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 3329 of file z3py.py.

3329  def __rmod__(self, other):
3330  """Create the Z3 expression (signed) mod `other % self`.
3331 
3332  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3333 
3334  >>> x = BitVec('x', 32)
3335  >>> 10 % x
3336  10%x
3337  >>> (10 % x).sexpr()
3338  '(bvsmod #x0000000a x)'
3339  >>> URem(10, x).sexpr()
3340  '(bvurem #x0000000a x)'
3341  >>> SRem(10, x).sexpr()
3342  '(bvsrem #x0000000a x)'
3343  """
3344  a, b = _coerce_exprs(self, other)
3345  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3346 
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 3132 of file z3py.py.

3132  def __rmul__(self, other):
3133  """Create the Z3 expression `other * self`.
3134 
3135  >>> x = BitVec('x', 32)
3136  >>> 10 * x
3137  10*x
3138  """
3139  a, b = _coerce_exprs(self, other)
3140  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3141 
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 3178 of file z3py.py.

3178  def __ror__(self, other):
3179  """Create the Z3 expression bitwise-or `other | self`.
3180 
3181  >>> x = BitVec('x', 32)
3182  >>> 10 | x
3183  10 | x
3184  """
3185  a, b = _coerce_exprs(self, other)
3186  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3187 
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 3455 of file z3py.py.

3455  def __rrshift__(self, other):
3456  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3457 
3458  Use the function LShR() for the right logical shift
3459 
3460  >>> x = BitVec('x', 32)
3461  >>> 10 >> x
3462  10 >> x
3463  >>> (10 >> x).sexpr()
3464  '(bvashr #x0000000a x)'
3465  """
3466  a, b = _coerce_exprs(self, other)
3467  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3468 
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 3411 of file z3py.py.

3411  def __rshift__(self, other):
3412  """Create the Z3 expression (arithmetical) right shift `self >> other`
3413 
3414  Use the function LShR() for the right logical shift
3415 
3416  >>> x, y = BitVecs('x y', 32)
3417  >>> x >> y
3418  x >> y
3419  >>> (x >> y).sexpr()
3420  '(bvashr x y)'
3421  >>> LShR(x, y).sexpr()
3422  '(bvlshr x y)'
3423  >>> BitVecVal(4, 3)
3424  4
3425  >>> BitVecVal(4, 3).as_signed_long()
3426  -4
3427  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3428  -2
3429  >>> simplify(BitVecVal(4, 3) >> 1)
3430  6
3431  >>> simplify(LShR(BitVecVal(4, 3), 1))
3432  2
3433  >>> simplify(BitVecVal(2, 3) >> 1)
3434  1
3435  >>> simplify(LShR(BitVecVal(2, 3), 1))
3436  1
3437  """
3438  a, b = _coerce_exprs(self, other)
3439  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3440 
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 3155 of file z3py.py.

3155  def __rsub__(self, other):
3156  """Create the Z3 expression `other - self`.
3157 
3158  >>> x = BitVec('x', 32)
3159  >>> 10 - x
3160  10 - x
3161  """
3162  a, b = _coerce_exprs(self, other)
3163  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3164 
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 3304 of file z3py.py.

3304  def __rtruediv__(self, other):
3305  """Create the Z3 expression (signed) division `other / self`."""
3306  return self.__rdiv__(other)
3307 

§ __rxor__()

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

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

Definition at line 3224 of file z3py.py.

3224  def __rxor__(self, other):
3225  """Create the Z3 expression bitwise-xor `other ^ self`.
3226 
3227  >>> x = BitVec('x', 32)
3228  >>> 10 ^ x
3229  10 ^ x
3230  """
3231  a, b = _coerce_exprs(self, other)
3232  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3233 
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 3142 of file z3py.py.

3142  def __sub__(self, other):
3143  """Create the Z3 expression `self - other`.
3144 
3145  >>> x = BitVec('x', 32)
3146  >>> y = BitVec('y', 32)
3147  >>> x - y
3148  x - y
3149  >>> (x - y).sort()
3150  BitVec(32)
3151  """
3152  a, b = _coerce_exprs(self, other)
3153  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3154 
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 3284 of file z3py.py.

3284  def __truediv__(self, other):
3285  """Create the Z3 expression (signed) division `self / other`."""
3286  return self.__div__(other)
3287 

§ __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 3211 of file z3py.py.

3211  def __xor__(self, other):
3212  """Create the Z3 expression bitwise-xor `self ^ other`.
3213 
3214  >>> x = BitVec('x', 32)
3215  >>> y = BitVec('y', 32)
3216  >>> x ^ y
3217  x ^ y
3218  >>> (x ^ y).sort()
3219  BitVec(32)
3220  """
3221  a, b = _coerce_exprs(self, other)
3222  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3223 
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 3085 of file z3py.py.

3085  def size(self):
3086  """Return the number of bits of the bit-vector expression `self`.
3087 
3088  >>> x = BitVec('x', 32)
3089  >>> (x + 1).size()
3090  32
3091  >>> Concat(x, x).size()
3092  64
3093  """
3094  return self.sort().size()
3095 

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

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

3074  def sort(self):
3075  """Return the sort of the bit-vector expression `self`.
3076 
3077  >>> x = BitVec('x', 32)
3078  >>> x.sort()
3079  BitVec(32)
3080  >>> x.sort() == BitVecSort(32)
3081  True
3082  """
3083  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3084 
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.