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

3280  def __add__(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_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3292 

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

3372  def __and__(self, other):
3373  """Create the Z3 expression bitwise-and `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_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3384 

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

3449  def __div__(self, other):
3450  """Create the Z3 expression (signed) division `self / other`.
3451 
3452  Use the function UDiv() for unsigned division.
3453 
3454  >>> x = BitVec('x', 32)
3455  >>> y = BitVec('y', 32)
3456  >>> x / y
3457  x/y
3458  >>> (x / y).sort()
3459  BitVec(32)
3460  >>> (x / y).sexpr()
3461  '(bvsdiv x y)'
3462  >>> UDiv(x, y).sexpr()
3463  '(bvudiv x y)'
3464  """
3465  a, b = _coerce_exprs(self, other)
3466  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3467 

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

3579  def __ge__(self, other):
3580  """Create the Z3 expression (signed) `other >= self`.
3581 
3582  Use the function UGE() for unsigned greater than or equal to.
3583 
3584  >>> x, y = BitVecs('x y', 32)
3585  >>> x >= y
3586  x >= y
3587  >>> (x >= y).sexpr()
3588  '(bvsge x y)'
3589  >>> UGE(x, y).sexpr()
3590  '(bvuge x y)'
3591  """
3592  a, b = _coerce_exprs(self, other)
3593  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3594 

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

3563  def __gt__(self, other):
3564  """Create the Z3 expression (signed) `other > self`.
3565 
3566  Use the function UGT() for unsigned greater than.
3567 
3568  >>> x, y = BitVecs('x y', 32)
3569  >>> x > y
3570  x > y
3571  >>> (x > y).sexpr()
3572  '(bvsgt x y)'
3573  >>> UGT(x, y).sexpr()
3574  '(bvugt x y)'
3575  """
3576  a, b = _coerce_exprs(self, other)
3577  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3578 

◆ __invert__()

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

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

Definition at line 3438 of file z3py.py.

3438  def __invert__(self):
3439  """Create the Z3 expression bitwise-not `~self`.
3440 
3441  >>> x = BitVec('x', 32)
3442  >>> ~x
3443  ~x
3444  >>> simplify(~(~x))
3445  x
3446  """
3447  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3448 

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

3531  def __le__(self, other):
3532  """Create the Z3 expression (signed) `other <= self`.
3533 
3534  Use the function ULE() for unsigned less than or equal to.
3535 
3536  >>> x, y = BitVecs('x y', 32)
3537  >>> x <= y
3538  x <= y
3539  >>> (x <= y).sexpr()
3540  '(bvsle x y)'
3541  >>> ULE(x, y).sexpr()
3542  '(bvule x y)'
3543  """
3544  a, b = _coerce_exprs(self, other)
3545  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3546 

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

3625  def __lshift__(self, other):
3626  """Create the Z3 expression left shift `self << other`
3627 
3628  >>> x, y = BitVecs('x y', 32)
3629  >>> x << y
3630  x << y
3631  >>> (x << y).sexpr()
3632  '(bvshl x y)'
3633  >>> simplify(BitVecVal(2, 3) << 1)
3634  4
3635  """
3636  a, b = _coerce_exprs(self, other)
3637  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3638 

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

3547  def __lt__(self, other):
3548  """Create the Z3 expression (signed) `other < self`.
3549 
3550  Use the function ULT() for unsigned less than.
3551 
3552  >>> x, y = BitVecs('x y', 32)
3553  >>> x < y
3554  x < y
3555  >>> (x < y).sexpr()
3556  '(bvslt x y)'
3557  >>> ULT(x, y).sexpr()
3558  '(bvult x y)'
3559  """
3560  a, b = _coerce_exprs(self, other)
3561  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3562 

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

3492  def __mod__(self, other):
3493  """Create the Z3 expression (signed) mod `self % other`.
3494 
3495  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3496 
3497  >>> x = BitVec('x', 32)
3498  >>> y = BitVec('y', 32)
3499  >>> x % y
3500  x%y
3501  >>> (x % y).sort()
3502  BitVec(32)
3503  >>> (x % y).sexpr()
3504  '(bvsmod x y)'
3505  >>> URem(x, y).sexpr()
3506  '(bvurem x y)'
3507  >>> SRem(x, y).sexpr()
3508  '(bvsrem x y)'
3509  """
3510  a, b = _coerce_exprs(self, other)
3511  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3512 

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

3303  def __mul__(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_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3315 

◆ __neg__()

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

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

Definition at line 3427 of file z3py.py.

3427  def __neg__(self):
3428  """Return an expression representing `-self`.
3429 
3430  >>> x = BitVec('x', 32)
3431  >>> -x
3432  -x
3433  >>> simplify(-(-x))
3434  x
3435  """
3436  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3437 

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

3349  def __or__(self, other):
3350  """Create the Z3 expression bitwise-or `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_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3361 

◆ __pos__()

def __pos__ (   self)
Return `self`.

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

Definition at line 3418 of file z3py.py.

3418  def __pos__(self):
3419  """Return `self`.
3420 
3421  >>> x = BitVec('x', 32)
3422  >>> +x
3423  x
3424  """
3425  return self
3426 

◆ __radd__()

def __radd__ (   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 __radd__(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_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3302 

◆ __rand__()

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

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

Definition at line 3385 of file z3py.py.

3385  def __rand__(self, other):
3386  """Create the Z3 expression bitwise-or `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_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3394 

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

3472  def __rdiv__(self, other):
3473  """Create the Z3 expression (signed) division `other / self`.
3474 
3475  Use the function UDiv() for unsigned division.
3476 
3477  >>> x = BitVec('x', 32)
3478  >>> 10 / x
3479  10/x
3480  >>> (10 / x).sexpr()
3481  '(bvsdiv #x0000000a x)'
3482  >>> UDiv(10, x).sexpr()
3483  '(bvudiv #x0000000a x)'
3484  """
3485  a, b = _coerce_exprs(self, other)
3486  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3487 

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

3653  def __rlshift__(self, other):
3654  """Create the Z3 expression left shift `other << self`.
3655 
3656  Use the function LShR() for the right logical shift
3657 
3658  >>> x = BitVec('x', 32)
3659  >>> 10 << x
3660  10 << x
3661  >>> (10 << x).sexpr()
3662  '(bvshl #x0000000a x)'
3663  """
3664  a, b = _coerce_exprs(self, other)
3665  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3666 

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

3513  def __rmod__(self, other):
3514  """Create the Z3 expression (signed) mod `other % self`.
3515 
3516  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3517 
3518  >>> x = BitVec('x', 32)
3519  >>> 10 % x
3520  10%x
3521  >>> (10 % x).sexpr()
3522  '(bvsmod #x0000000a x)'
3523  >>> URem(10, x).sexpr()
3524  '(bvurem #x0000000a x)'
3525  >>> SRem(10, x).sexpr()
3526  '(bvsrem #x0000000a x)'
3527  """
3528  a, b = _coerce_exprs(self, other)
3529  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3530 

◆ __rmul__()

def __rmul__ (   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 __rmul__(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_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3325 

◆ __ror__()

def __ror__ (   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 __ror__(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_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3371 

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

3639  def __rrshift__(self, other):
3640  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3641 
3642  Use the function LShR() for the right logical shift
3643 
3644  >>> x = BitVec('x', 32)
3645  >>> 10 >> x
3646  10 >> x
3647  >>> (10 >> x).sexpr()
3648  '(bvashr #x0000000a x)'
3649  """
3650  a, b = _coerce_exprs(self, other)
3651  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3652 

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

3595  def __rshift__(self, other):
3596  """Create the Z3 expression (arithmetical) right shift `self >> other`
3597 
3598  Use the function LShR() for the right logical shift
3599 
3600  >>> x, y = BitVecs('x y', 32)
3601  >>> x >> y
3602  x >> y
3603  >>> (x >> y).sexpr()
3604  '(bvashr x y)'
3605  >>> LShR(x, y).sexpr()
3606  '(bvlshr x y)'
3607  >>> BitVecVal(4, 3)
3608  4
3609  >>> BitVecVal(4, 3).as_signed_long()
3610  -4
3611  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3612  -2
3613  >>> simplify(BitVecVal(4, 3) >> 1)
3614  6
3615  >>> simplify(LShR(BitVecVal(4, 3), 1))
3616  2
3617  >>> simplify(BitVecVal(2, 3) >> 1)
3618  1
3619  >>> simplify(LShR(BitVecVal(2, 3), 1))
3620  1
3621  """
3622  a, b = _coerce_exprs(self, other)
3623  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3624 

◆ __rsub__()

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

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

Definition at line 3339 of file z3py.py.

3339  def __rsub__(self, other):
3340  """Create the Z3 expression `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_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3348 

◆ __rtruediv__()

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

Definition at line 3488 of file z3py.py.

3488  def __rtruediv__(self, other):
3489  """Create the Z3 expression (signed) division `other / self`."""
3490  return self.__rdiv__(other)
3491 

◆ __rxor__()

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

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

Definition at line 3408 of file z3py.py.

3408  def __rxor__(self, other):
3409  """Create the Z3 expression bitwise-xor `other ^ self`.
3410 
3411  >>> x = BitVec('x', 32)
3412  >>> 10 ^ x
3413  10 ^ x
3414  """
3415  a, b = _coerce_exprs(self, other)
3416  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3417 

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

3326  def __sub__(self, other):
3327  """Create the Z3 expression `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_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3338 

◆ __truediv__()

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

Definition at line 3468 of file z3py.py.

3468  def __truediv__(self, other):
3469  """Create the Z3 expression (signed) division `self / other`."""
3470  return self.__div__(other)
3471 

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

3395  def __xor__(self, other):
3396  """Create the Z3 expression bitwise-xor `self ^ other`.
3397 
3398  >>> x = BitVec('x', 32)
3399  >>> y = BitVec('y', 32)
3400  >>> x ^ y
3401  x ^ y
3402  >>> (x ^ y).sort()
3403  BitVec(32)
3404  """
3405  a, b = _coerce_exprs(self, other)
3406  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3407 

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

3269  def size(self):
3270  """Return the number of bits of the bit-vector expression `self`.
3271 
3272  >>> x = BitVec('x', 32)
3273  >>> (x + 1).size()
3274  32
3275  >>> Concat(x, x).size()
3276  64
3277  """
3278  return self.sort().size()
3279 

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

3258  def sort(self):
3259  """Return the sort of the bit-vector expression `self`.
3260 
3261  >>> x = BitVec('x', 32)
3262  >>> x.sort()
3263  BitVec(32)
3264  >>> x.sort() == BitVecSort(32)
3265  True
3266  """
3267  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3268 
Z3_mk_bvshl
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.
Z3_mk_bvslt
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than.
Z3_mk_bvmul
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.
Z3_mk_bvnot
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.
Z3_mk_bvsge
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.
Z3_mk_bvadd
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.
Z3_mk_bvneg
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two's complement unary minus.
Z3_mk_bvashr
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.
Z3_mk_bvsmod
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows divisor).
Z3_mk_bvsle
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.
Z3_mk_bvsdiv
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.
Z3_mk_bvsub
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.
Z3_mk_bvand
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.
Z3_mk_bvxor
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.
Z3_get_sort
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.
Z3_mk_bvsgt
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.
Z3_mk_bvor
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.