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_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 __nonzero__ (self)
 
def __bool__ (self)
 
def sexpr (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 3232 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 3257 of file z3py.py.

3257  def __add__(self, other):
3258  """Create the Z3 expression `self + other`.
3259 
3260  >>> x = BitVec('x', 32)
3261  >>> y = BitVec('y', 32)
3262  >>> x + y
3263  x + y
3264  >>> (x + y).sort()
3265  BitVec(32)
3266  """
3267  a, b = _coerce_exprs(self, other)
3268  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3269 
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 3349 of file z3py.py.

3349  def __and__(self, other):
3350  """Create the Z3 expression bitwise-and `self & other`.
3351 
3352  >>> x = BitVec('x', 32)
3353  >>> y = BitVec('y', 32)
3354  >>> x & y
3355  x & y
3356  >>> (x & y).sort()
3357  BitVec(32)
3358  """
3359  a, b = _coerce_exprs(self, other)
3360  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3361 
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 3426 of file z3py.py.

3426  def __div__(self, other):
3427  """Create the Z3 expression (signed) division `self / other`.
3428 
3429  Use the function UDiv() for unsigned division.
3430 
3431  >>> x = BitVec('x', 32)
3432  >>> y = BitVec('y', 32)
3433  >>> x / y
3434  x/y
3435  >>> (x / y).sort()
3436  BitVec(32)
3437  >>> (x / y).sexpr()
3438  '(bvsdiv x y)'
3439  >>> UDiv(x, y).sexpr()
3440  '(bvudiv x y)'
3441  """
3442  a, b = _coerce_exprs(self, other)
3443  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3444 
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.

Referenced by BitVecRef.__truediv__(), and FPRef.__truediv__().

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

3556  def __ge__(self, other):
3557  """Create the Z3 expression (signed) `other >= self`.
3558 
3559  Use the function UGE() for unsigned greater than or equal to.
3560 
3561  >>> x, y = BitVecs('x y', 32)
3562  >>> x >= y
3563  x >= y
3564  >>> (x >= y).sexpr()
3565  '(bvsge x y)'
3566  >>> UGE(x, y).sexpr()
3567  '(bvuge x y)'
3568  """
3569  a, b = _coerce_exprs(self, other)
3570  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3571 
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 3540 of file z3py.py.

3540  def __gt__(self, other):
3541  """Create the Z3 expression (signed) `other > self`.
3542 
3543  Use the function UGT() for unsigned greater than.
3544 
3545  >>> x, y = BitVecs('x y', 32)
3546  >>> x > y
3547  x > y
3548  >>> (x > y).sexpr()
3549  '(bvsgt x y)'
3550  >>> UGT(x, y).sexpr()
3551  '(bvugt x y)'
3552  """
3553  a, b = _coerce_exprs(self, other)
3554  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3555 
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 3415 of file z3py.py.

3415  def __invert__(self):
3416  """Create the Z3 expression bitwise-not `~self`.
3417 
3418  >>> x = BitVec('x', 32)
3419  >>> ~x
3420  ~x
3421  >>> simplify(~(~x))
3422  x
3423  """
3424  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3425 
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 3508 of file z3py.py.

3508  def __le__(self, other):
3509  """Create the Z3 expression (signed) `other <= self`.
3510 
3511  Use the function ULE() for unsigned less than or equal to.
3512 
3513  >>> x, y = BitVecs('x y', 32)
3514  >>> x <= y
3515  x <= y
3516  >>> (x <= y).sexpr()
3517  '(bvsle x y)'
3518  >>> ULE(x, y).sexpr()
3519  '(bvule x y)'
3520  """
3521  a, b = _coerce_exprs(self, other)
3522  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3523 
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__()

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

3602  def __lshift__(self, other):
3603  """Create the Z3 expression left shift `self << other`
3604 
3605  >>> x, y = BitVecs('x y', 32)
3606  >>> x << y
3607  x << y
3608  >>> (x << y).sexpr()
3609  '(bvshl x y)'
3610  >>> simplify(BitVecVal(2, 3) << 1)
3611  4
3612  """
3613  a, b = _coerce_exprs(self, other)
3614  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3615 
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 3524 of file z3py.py.

3524  def __lt__(self, other):
3525  """Create the Z3 expression (signed) `other < self`.
3526 
3527  Use the function ULT() for unsigned less than.
3528 
3529  >>> x, y = BitVecs('x y', 32)
3530  >>> x < y
3531  x < y
3532  >>> (x < y).sexpr()
3533  '(bvslt x y)'
3534  >>> ULT(x, y).sexpr()
3535  '(bvult x y)'
3536  """
3537  a, b = _coerce_exprs(self, other)
3538  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3539 
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two'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 3469 of file z3py.py.

3469  def __mod__(self, other):
3470  """Create the Z3 expression (signed) mod `self % other`.
3471 
3472  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3473 
3474  >>> x = BitVec('x', 32)
3475  >>> y = BitVec('y', 32)
3476  >>> x % y
3477  x%y
3478  >>> (x % y).sort()
3479  BitVec(32)
3480  >>> (x % y).sexpr()
3481  '(bvsmod x y)'
3482  >>> URem(x, y).sexpr()
3483  '(bvurem x y)'
3484  >>> SRem(x, y).sexpr()
3485  '(bvsrem x y)'
3486  """
3487  a, b = _coerce_exprs(self, other)
3488  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3489 
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__()

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

3280  def __mul__(self, other):
3281  """Create the Z3 expression `self * other`.
3282 
3283  >>> x = BitVec('x', 32)
3284  >>> y = BitVec('y', 32)
3285  >>> x * y
3286  x*y
3287  >>> (x * y).sort()
3288  BitVec(32)
3289  """
3290  a, b = _coerce_exprs(self, other)
3291  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3292 
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.

◆ __neg__()

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

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

Definition at line 3404 of file z3py.py.

3404  def __neg__(self):
3405  """Return an expression representing `-self`.
3406 
3407  >>> x = BitVec('x', 32)
3408  >>> -x
3409  -x
3410  >>> simplify(-(-x))
3411  x
3412  """
3413  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3414 
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two'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 3326 of file z3py.py.

3326  def __or__(self, other):
3327  """Create the Z3 expression bitwise-or `self | other`.
3328 
3329  >>> x = BitVec('x', 32)
3330  >>> y = BitVec('y', 32)
3331  >>> x | y
3332  x | y
3333  >>> (x | y).sort()
3334  BitVec(32)
3335  """
3336  a, b = _coerce_exprs(self, other)
3337  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3338 
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 3395 of file z3py.py.

3395  def __pos__(self):
3396  """Return `self`.
3397 
3398  >>> x = BitVec('x', 32)
3399  >>> +x
3400  x
3401  """
3402  return self
3403 

◆ __radd__()

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

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

Definition at line 3270 of file z3py.py.

3270  def __radd__(self, other):
3271  """Create the Z3 expression `other + self`.
3272 
3273  >>> x = BitVec('x', 32)
3274  >>> 10 + x
3275  10 + x
3276  """
3277  a, b = _coerce_exprs(self, other)
3278  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3279 
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two'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 3362 of file z3py.py.

3362  def __rand__(self, other):
3363  """Create the Z3 expression bitwise-or `other & self`.
3364 
3365  >>> x = BitVec('x', 32)
3366  >>> 10 & x
3367  10 & x
3368  """
3369  a, b = _coerce_exprs(self, other)
3370  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3371 
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 3449 of file z3py.py.

3449  def __rdiv__(self, other):
3450  """Create the Z3 expression (signed) division `other / self`.
3451 
3452  Use the function UDiv() for unsigned division.
3453 
3454  >>> x = BitVec('x', 32)
3455  >>> 10 / x
3456  10/x
3457  >>> (10 / x).sexpr()
3458  '(bvsdiv #x0000000a x)'
3459  >>> UDiv(10, x).sexpr()
3460  '(bvudiv #x0000000a x)'
3461  """
3462  a, b = _coerce_exprs(self, other)
3463  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3464 
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.

Referenced by BitVecRef.__rtruediv__(), and FPRef.__rtruediv__().

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

3630  def __rlshift__(self, other):
3631  """Create the Z3 expression left shift `other << self`.
3632 
3633  Use the function LShR() for the right logical shift
3634 
3635  >>> x = BitVec('x', 32)
3636  >>> 10 << x
3637  10 << x
3638  >>> (10 << x).sexpr()
3639  '(bvshl #x0000000a x)'
3640  """
3641  a, b = _coerce_exprs(self, other)
3642  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3643 
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 3490 of file z3py.py.

3490  def __rmod__(self, other):
3491  """Create the Z3 expression (signed) mod `other % self`.
3492 
3493  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3494 
3495  >>> x = BitVec('x', 32)
3496  >>> 10 % x
3497  10%x
3498  >>> (10 % x).sexpr()
3499  '(bvsmod #x0000000a x)'
3500  >>> URem(10, x).sexpr()
3501  '(bvurem #x0000000a x)'
3502  >>> SRem(10, x).sexpr()
3503  '(bvsrem #x0000000a x)'
3504  """
3505  a, b = _coerce_exprs(self, other)
3506  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3507 
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two'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 3293 of file z3py.py.

3293  def __rmul__(self, other):
3294  """Create the Z3 expression `other * self`.
3295 
3296  >>> x = BitVec('x', 32)
3297  >>> 10 * x
3298  10*x
3299  """
3300  a, b = _coerce_exprs(self, other)
3301  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3302 
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two'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 3339 of file z3py.py.

3339  def __ror__(self, other):
3340  """Create the Z3 expression bitwise-or `other | self`.
3341 
3342  >>> x = BitVec('x', 32)
3343  >>> 10 | x
3344  10 | x
3345  """
3346  a, b = _coerce_exprs(self, other)
3347  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3348 
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 3616 of file z3py.py.

3616  def __rrshift__(self, other):
3617  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3618 
3619  Use the function LShR() for the right logical shift
3620 
3621  >>> x = BitVec('x', 32)
3622  >>> 10 >> x
3623  10 >> x
3624  >>> (10 >> x).sexpr()
3625  '(bvashr #x0000000a x)'
3626  """
3627  a, b = _coerce_exprs(self, other)
3628  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3629 
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 3572 of file z3py.py.

3572  def __rshift__(self, other):
3573  """Create the Z3 expression (arithmetical) right shift `self >> other`
3574 
3575  Use the function LShR() for the right logical shift
3576 
3577  >>> x, y = BitVecs('x y', 32)
3578  >>> x >> y
3579  x >> y
3580  >>> (x >> y).sexpr()
3581  '(bvashr x y)'
3582  >>> LShR(x, y).sexpr()
3583  '(bvlshr x y)'
3584  >>> BitVecVal(4, 3)
3585  4
3586  >>> BitVecVal(4, 3).as_signed_long()
3587  -4
3588  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3589  -2
3590  >>> simplify(BitVecVal(4, 3) >> 1)
3591  6
3592  >>> simplify(LShR(BitVecVal(4, 3), 1))
3593  2
3594  >>> simplify(BitVecVal(2, 3) >> 1)
3595  1
3596  >>> simplify(LShR(BitVecVal(2, 3), 1))
3597  1
3598  """
3599  a, b = _coerce_exprs(self, other)
3600  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3601 
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 3316 of file z3py.py.

3316  def __rsub__(self, other):
3317  """Create the Z3 expression `other - self`.
3318 
3319  >>> x = BitVec('x', 32)
3320  >>> 10 - x
3321  10 - x
3322  """
3323  a, b = _coerce_exprs(self, other)
3324  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3325 
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.

◆ __rtruediv__()

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

Definition at line 3465 of file z3py.py.

3465  def __rtruediv__(self, other):
3466  """Create the Z3 expression (signed) division `other / self`."""
3467  return self.__rdiv__(other)
3468 

◆ __rxor__()

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

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

Definition at line 3385 of file z3py.py.

3385  def __rxor__(self, other):
3386  """Create the Z3 expression bitwise-xor `other ^ self`.
3387 
3388  >>> x = BitVec('x', 32)
3389  >>> 10 ^ x
3390  10 ^ x
3391  """
3392  a, b = _coerce_exprs(self, other)
3393  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3394 
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 3303 of file z3py.py.

3303  def __sub__(self, other):
3304  """Create the Z3 expression `self - other`.
3305 
3306  >>> x = BitVec('x', 32)
3307  >>> y = BitVec('y', 32)
3308  >>> x - y
3309  x - y
3310  >>> (x - y).sort()
3311  BitVec(32)
3312  """
3313  a, b = _coerce_exprs(self, other)
3314  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3315 
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.

◆ __truediv__()

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

Definition at line 3445 of file z3py.py.

3445  def __truediv__(self, other):
3446  """Create the Z3 expression (signed) division `self / other`."""
3447  return self.__div__(other)
3448 

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

3372  def __xor__(self, other):
3373  """Create the Z3 expression bitwise-xor `self ^ other`.
3374 
3375  >>> x = BitVec('x', 32)
3376  >>> y = BitVec('y', 32)
3377  >>> x ^ y
3378  x ^ y
3379  >>> (x ^ y).sort()
3380  BitVec(32)
3381  """
3382  a, b = _coerce_exprs(self, other)
3383  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3384 
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 3246 of file z3py.py.

3246  def size(self):
3247  """Return the number of bits of the bit-vector expression `self`.
3248 
3249  >>> x = BitVec('x', 32)
3250  >>> (x + 1).size()
3251  32
3252  >>> Concat(x, x).size()
3253  64
3254  """
3255  return self.sort().size()
3256 

Referenced by ParamDescrsRef.__len__(), Goal.__len__(), and BitVecNumRef.as_signed_long().

◆ 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

Reimplemented from ExprRef.

Definition at line 3235 of file z3py.py.

3235  def sort(self):
3236  """Return the sort of the bit-vector expression `self`.
3237 
3238  >>> x = BitVec('x', 32)
3239  >>> x.sort()
3240  BitVec(32)
3241  >>> x.sort() == BitVecSort(32)
3242  True
3243  """
3244  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3245 
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.