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 __copy__ (self)
 
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 3085 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 3110 of file z3py.py.

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

3202  def __and__(self, other):
3203  """Create the Z3 expression bitwise-and `self & other`.
3204 
3205  >>> x = BitVec('x', 32)
3206  >>> y = BitVec('y', 32)
3207  >>> x & y
3208  x & y
3209  >>> (x & y).sort()
3210  BitVec(32)
3211  """
3212  a, b = _coerce_exprs(self, other)
3213  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3214 
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 3279 of file z3py.py.

3279  def __div__(self, other):
3280  """Create the Z3 expression (signed) division `self / other`.
3281 
3282  Use the function UDiv() for unsigned division.
3283 
3284  >>> x = BitVec('x', 32)
3285  >>> y = BitVec('y', 32)
3286  >>> x / y
3287  x/y
3288  >>> (x / y).sort()
3289  BitVec(32)
3290  >>> (x / y).sexpr()
3291  '(bvsdiv x y)'
3292  >>> UDiv(x, y).sexpr()
3293  '(bvudiv x y)'
3294  """
3295  a, b = _coerce_exprs(self, other)
3296  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3297 
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 3409 of file z3py.py.

3409  def __ge__(self, other):
3410  """Create the Z3 expression (signed) `other >= self`.
3411 
3412  Use the function UGE() for unsigned greater than or equal to.
3413 
3414  >>> x, y = BitVecs('x y', 32)
3415  >>> x >= y
3416  x >= y
3417  >>> (x >= y).sexpr()
3418  '(bvsge x y)'
3419  >>> UGE(x, y).sexpr()
3420  '(bvuge x y)'
3421  """
3422  a, b = _coerce_exprs(self, other)
3423  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3424 
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 3393 of file z3py.py.

3393  def __gt__(self, other):
3394  """Create the Z3 expression (signed) `other > self`.
3395 
3396  Use the function UGT() for unsigned greater than.
3397 
3398  >>> x, y = BitVecs('x y', 32)
3399  >>> x > y
3400  x > y
3401  >>> (x > y).sexpr()
3402  '(bvsgt x y)'
3403  >>> UGT(x, y).sexpr()
3404  '(bvugt x y)'
3405  """
3406  a, b = _coerce_exprs(self, other)
3407  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3408 
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 3268 of file z3py.py.

3268  def __invert__(self):
3269  """Create the Z3 expression bitwise-not `~self`.
3270 
3271  >>> x = BitVec('x', 32)
3272  >>> ~x
3273  ~x
3274  >>> simplify(~(~x))
3275  x
3276  """
3277  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3278 
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 3361 of file z3py.py.

3361  def __le__(self, other):
3362  """Create the Z3 expression (signed) `other <= self`.
3363 
3364  Use the function ULE() for unsigned less than or equal to.
3365 
3366  >>> x, y = BitVecs('x y', 32)
3367  >>> x <= y
3368  x <= y
3369  >>> (x <= y).sexpr()
3370  '(bvsle x y)'
3371  >>> ULE(x, y).sexpr()
3372  '(bvule x y)'
3373  """
3374  a, b = _coerce_exprs(self, other)
3375  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3376 
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 3455 of file z3py.py.

3455  def __lshift__(self, other):
3456  """Create the Z3 expression left shift `self << other`
3457 
3458  >>> x, y = BitVecs('x y', 32)
3459  >>> x << y
3460  x << y
3461  >>> (x << y).sexpr()
3462  '(bvshl x y)'
3463  >>> simplify(BitVecVal(2, 3) << 1)
3464  4
3465  """
3466  a, b = _coerce_exprs(self, other)
3467  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3468 
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 3377 of file z3py.py.

3377  def __lt__(self, other):
3378  """Create the Z3 expression (signed) `other < self`.
3379 
3380  Use the function ULT() for unsigned less than.
3381 
3382  >>> x, y = BitVecs('x y', 32)
3383  >>> x < y
3384  x < y
3385  >>> (x < y).sexpr()
3386  '(bvslt x y)'
3387  >>> ULT(x, y).sexpr()
3388  '(bvult x y)'
3389  """
3390  a, b = _coerce_exprs(self, other)
3391  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3392 
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 3322 of file z3py.py.

3322  def __mod__(self, other):
3323  """Create the Z3 expression (signed) mod `self % other`.
3324 
3325  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3326 
3327  >>> x = BitVec('x', 32)
3328  >>> y = BitVec('y', 32)
3329  >>> x % y
3330  x%y
3331  >>> (x % y).sort()
3332  BitVec(32)
3333  >>> (x % y).sexpr()
3334  '(bvsmod x y)'
3335  >>> URem(x, y).sexpr()
3336  '(bvurem x y)'
3337  >>> SRem(x, y).sexpr()
3338  '(bvsrem x y)'
3339  """
3340  a, b = _coerce_exprs(self, other)
3341  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3342 
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 3133 of file z3py.py.

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

3257  def __neg__(self):
3258  """Return an expression representing `-self`.
3259 
3260  >>> x = BitVec('x', 32)
3261  >>> -x
3262  -x
3263  >>> simplify(-(-x))
3264  x
3265  """
3266  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3267 
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 3179 of file z3py.py.

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

3248  def __pos__(self):
3249  """Return `self`.
3250 
3251  >>> x = BitVec('x', 32)
3252  >>> +x
3253  x
3254  """
3255  return self
3256 

§ __radd__()

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

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

Definition at line 3123 of file z3py.py.

3123  def __radd__(self, other):
3124  """Create the Z3 expression `other + self`.
3125 
3126  >>> x = BitVec('x', 32)
3127  >>> 10 + x
3128  10 + x
3129  """
3130  a, b = _coerce_exprs(self, other)
3131  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3132 
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 3215 of file z3py.py.

3215  def __rand__(self, other):
3216  """Create the Z3 expression bitwise-or `other & self`.
3217 
3218  >>> x = BitVec('x', 32)
3219  >>> 10 & x
3220  10 & x
3221  """
3222  a, b = _coerce_exprs(self, other)
3223  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3224 
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 3302 of file z3py.py.

3302  def __rdiv__(self, other):
3303  """Create the Z3 expression (signed) division `other / self`.
3304 
3305  Use the function UDiv() for unsigned division.
3306 
3307  >>> x = BitVec('x', 32)
3308  >>> 10 / x
3309  10/x
3310  >>> (10 / x).sexpr()
3311  '(bvsdiv #x0000000a x)'
3312  >>> UDiv(10, x).sexpr()
3313  '(bvudiv #x0000000a x)'
3314  """
3315  a, b = _coerce_exprs(self, other)
3316  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3317 
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 3483 of file z3py.py.

3483  def __rlshift__(self, other):
3484  """Create the Z3 expression left shift `other << self`.
3485 
3486  Use the function LShR() for the right logical shift
3487 
3488  >>> x = BitVec('x', 32)
3489  >>> 10 << x
3490  10 << x
3491  >>> (10 << x).sexpr()
3492  '(bvshl #x0000000a x)'
3493  """
3494  a, b = _coerce_exprs(self, other)
3495  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3496 
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 3343 of file z3py.py.

3343  def __rmod__(self, other):
3344  """Create the Z3 expression (signed) mod `other % self`.
3345 
3346  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3347 
3348  >>> x = BitVec('x', 32)
3349  >>> 10 % x
3350  10%x
3351  >>> (10 % x).sexpr()
3352  '(bvsmod #x0000000a x)'
3353  >>> URem(10, x).sexpr()
3354  '(bvurem #x0000000a x)'
3355  >>> SRem(10, x).sexpr()
3356  '(bvsrem #x0000000a x)'
3357  """
3358  a, b = _coerce_exprs(self, other)
3359  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3360 
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 3146 of file z3py.py.

3146  def __rmul__(self, other):
3147  """Create the Z3 expression `other * self`.
3148 
3149  >>> x = BitVec('x', 32)
3150  >>> 10 * x
3151  10*x
3152  """
3153  a, b = _coerce_exprs(self, other)
3154  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3155 
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 3192 of file z3py.py.

3192  def __ror__(self, other):
3193  """Create the Z3 expression bitwise-or `other | self`.
3194 
3195  >>> x = BitVec('x', 32)
3196  >>> 10 | x
3197  10 | x
3198  """
3199  a, b = _coerce_exprs(self, other)
3200  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3201 
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 3469 of file z3py.py.

3469  def __rrshift__(self, other):
3470  """Create the Z3 expression (arithmetical) right 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  '(bvashr #x0000000a x)'
3479  """
3480  a, b = _coerce_exprs(self, other)
3481  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3482 
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 3425 of file z3py.py.

3425  def __rshift__(self, other):
3426  """Create the Z3 expression (arithmetical) right shift `self >> other`
3427 
3428  Use the function LShR() for the right logical shift
3429 
3430  >>> x, y = BitVecs('x y', 32)
3431  >>> x >> y
3432  x >> y
3433  >>> (x >> y).sexpr()
3434  '(bvashr x y)'
3435  >>> LShR(x, y).sexpr()
3436  '(bvlshr x y)'
3437  >>> BitVecVal(4, 3)
3438  4
3439  >>> BitVecVal(4, 3).as_signed_long()
3440  -4
3441  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3442  -2
3443  >>> simplify(BitVecVal(4, 3) >> 1)
3444  6
3445  >>> simplify(LShR(BitVecVal(4, 3), 1))
3446  2
3447  >>> simplify(BitVecVal(2, 3) >> 1)
3448  1
3449  >>> simplify(LShR(BitVecVal(2, 3), 1))
3450  1
3451  """
3452  a, b = _coerce_exprs(self, other)
3453  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3454 
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 3169 of file z3py.py.

3169  def __rsub__(self, other):
3170  """Create the Z3 expression `other - self`.
3171 
3172  >>> x = BitVec('x', 32)
3173  >>> 10 - x
3174  10 - x
3175  """
3176  a, b = _coerce_exprs(self, other)
3177  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3178 
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 3318 of file z3py.py.

3318  def __rtruediv__(self, other):
3319  """Create the Z3 expression (signed) division `other / self`."""
3320  return self.__rdiv__(other)
3321 

§ __rxor__()

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

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

Definition at line 3238 of file z3py.py.

3238  def __rxor__(self, other):
3239  """Create the Z3 expression bitwise-xor `other ^ self`.
3240 
3241  >>> x = BitVec('x', 32)
3242  >>> 10 ^ x
3243  10 ^ x
3244  """
3245  a, b = _coerce_exprs(self, other)
3246  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3247 
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 3156 of file z3py.py.

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

3298  def __truediv__(self, other):
3299  """Create the Z3 expression (signed) division `self / other`."""
3300  return self.__div__(other)
3301 

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

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

3099  def size(self):
3100  """Return the number of bits of the bit-vector expression `self`.
3101 
3102  >>> x = BitVec('x', 32)
3103  >>> (x + 1).size()
3104  32
3105  >>> Concat(x, x).size()
3106  64
3107  """
3108  return self.sort().size()
3109 

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

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

3088  def sort(self):
3089  """Return the sort of the bit-vector expression `self`.
3090 
3091  >>> x = BitVec('x', 32)
3092  >>> x.sort()
3093  BitVec(32)
3094  >>> x.sort() == BitVecSort(32)
3095  True
3096  """
3097  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3098 
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.