Z3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions
BitVecRef Class Reference
+ Inheritance diagram for BitVecRef:

Public Member Functions

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

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

Bit-vector expressions.

Definition at line 2964 of file z3py.py.

Member Function Documentation

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

2990  def __add__(self, other):
2991  """Create the Z3 expression `self + other`.
2992 
2993  >>> x = BitVec('x', 32)
2994  >>> y = BitVec('y', 32)
2995  >>> x + y
2996  x + y
2997  >>> (x + y).sort()
2998  BitVec(32)
2999  """
3000  a, b = _coerce_exprs(self, other)
3001  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
def __add__
Definition: z3py.py:2989
def ctx_ref
Definition: z3py.py:304
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.
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 3081 of file z3py.py.

3082  def __and__(self, other):
3083  """Create the Z3 expression bitwise-and `self & other`.
3084 
3085  >>> x = BitVec('x', 32)
3086  >>> y = BitVec('y', 32)
3087  >>> x & y
3088  x & y
3089  >>> (x & y).sort()
3090  BitVec(32)
3091  """
3092  a, b = _coerce_exprs(self, other)
3093  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
def __and__
Definition: z3py.py:3081
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.
def ctx_ref
Definition: z3py.py:304
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 3158 of file z3py.py.

3159  def __div__(self, other):
3160  """Create the Z3 expression (signed) division `self / other`.
3161 
3162  Use the function UDiv() for unsigned division.
3163 
3164  >>> x = BitVec('x', 32)
3165  >>> y = BitVec('y', 32)
3166  >>> x / y
3167  x/y
3168  >>> (x / y).sort()
3169  BitVec(32)
3170  >>> (x / y).sexpr()
3171  '(bvsdiv x y)'
3172  >>> UDiv(x, y).sexpr()
3173  '(bvudiv x y)'
3174  """
3175  a, b = _coerce_exprs(self, other)
3176  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
def __div__
Definition: z3py.py:3158
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.
def ctx_ref
Definition: z3py.py:304
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 3288 of file z3py.py.

3289  def __ge__(self, other):
3290  """Create the Z3 expression (signed) `other >= self`.
3291 
3292  Use the function UGE() for unsigned greater than or equal to.
3293 
3294  >>> x, y = BitVecs('x y', 32)
3295  >>> x >= y
3296  x >= y
3297  >>> (x >= y).sexpr()
3298  '(bvsge x y)'
3299  >>> UGE(x, y).sexpr()
3300  '(bvuge x y)'
3301  """
3302  a, b = _coerce_exprs(self, other)
3303  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
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.
def ctx_ref
Definition: z3py.py:304
def __ge__
Definition: z3py.py:3288
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 3272 of file z3py.py.

3273  def __gt__(self, other):
3274  """Create the Z3 expression (signed) `other > self`.
3275 
3276  Use the function UGT() for unsigned greater than.
3277 
3278  >>> x, y = BitVecs('x y', 32)
3279  >>> x > y
3280  x > y
3281  >>> (x > y).sexpr()
3282  '(bvsgt x y)'
3283  >>> UGT(x, y).sexpr()
3284  '(bvugt x y)'
3285  """
3286  a, b = _coerce_exprs(self, other)
3287  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.
def __gt__
Definition: z3py.py:3272
def ctx_ref
Definition: z3py.py:304
def __invert__ (   self)
Create the Z3 expression bitwise-not `~self`.

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

Definition at line 3147 of file z3py.py.

3148  def __invert__(self):
3149  """Create the Z3 expression bitwise-not `~self`.
3150 
3151  >>> x = BitVec('x', 32)
3152  >>> ~x
3153  ~x
3154  >>> simplify(~(~x))
3155  x
3156  """
3157  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
def __invert__
Definition: z3py.py:3147
def as_ast
Definition: z3py.py:296
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.
def ctx_ref
Definition: z3py.py:304
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 3240 of file z3py.py.

3241  def __le__(self, other):
3242  """Create the Z3 expression (signed) `other <= self`.
3243 
3244  Use the function ULE() for unsigned less than or equal to.
3245 
3246  >>> x, y = BitVecs('x y', 32)
3247  >>> x <= y
3248  x <= y
3249  >>> (x <= y).sexpr()
3250  '(bvsle x y)'
3251  >>> ULE(x, y).sexpr()
3252  '(bvule x y)'
3253  """
3254  a, b = _coerce_exprs(self, other)
3255  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
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.
def __le__
Definition: z3py.py:3240
def ctx_ref
Definition: z3py.py:304
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 3334 of file z3py.py.

3335  def __lshift__(self, other):
3336  """Create the Z3 expression left shift `self << other`
3337 
3338  >>> x, y = BitVecs('x y', 32)
3339  >>> x << y
3340  x << y
3341  >>> (x << y).sexpr()
3342  '(bvshl x y)'
3343  >>> simplify(BitVecVal(2, 3) << 1)
3344  4
3345  """
3346  a, b = _coerce_exprs(self, other)
3347  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.
def __lshift__
Definition: z3py.py:3334
def ctx_ref
Definition: z3py.py:304
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 3256 of file z3py.py.

3257  def __lt__(self, other):
3258  """Create the Z3 expression (signed) `other < self`.
3259 
3260  Use the function ULT() for unsigned less than.
3261 
3262  >>> x, y = BitVecs('x y', 32)
3263  >>> x < y
3264  x < y
3265  >>> (x < y).sexpr()
3266  '(bvslt x y)'
3267  >>> ULT(x, y).sexpr()
3268  '(bvult x y)'
3269  """
3270  a, b = _coerce_exprs(self, other)
3271  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
def __lt__
Definition: z3py.py:3256
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two&#39;s complement signed less than.
def ctx_ref
Definition: z3py.py:304
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 3201 of file z3py.py.

3202  def __mod__(self, other):
3203  """Create the Z3 expression (signed) mod `self % other`.
3204 
3205  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3206 
3207  >>> x = BitVec('x', 32)
3208  >>> y = BitVec('y', 32)
3209  >>> x % y
3210  x%y
3211  >>> (x % y).sort()
3212  BitVec(32)
3213  >>> (x % y).sexpr()
3214  '(bvsmod x y)'
3215  >>> URem(x, y).sexpr()
3216  '(bvurem x y)'
3217  >>> SRem(x, y).sexpr()
3218  '(bvsrem x y)'
3219  """
3220  a, b = _coerce_exprs(self, other)
3221  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
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).
def ctx_ref
Definition: z3py.py:304
def __mod__
Definition: z3py.py:3201
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 3012 of file z3py.py.

3013  def __mul__(self, other):
3014  """Create the Z3 expression `self * other`.
3015 
3016  >>> x = BitVec('x', 32)
3017  >>> y = BitVec('y', 32)
3018  >>> x * y
3019  x*y
3020  >>> (x * y).sort()
3021  BitVec(32)
3022  """
3023  a, b = _coerce_exprs(self, other)
3024  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
def __mul__
Definition: z3py.py:3012
def ctx_ref
Definition: z3py.py:304
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement multiplication.
def __neg__ (   self)
Return an expression representing `-self`.

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

Definition at line 3136 of file z3py.py.

3137  def __neg__(self):
3138  """Return an expression representing `-self`.
3139 
3140  >>> x = BitVec('x', 32)
3141  >>> -x
3142  -x
3143  >>> simplify(-(-x))
3144  x
3145  """
3146  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
def as_ast
Definition: z3py.py:296
def ctx_ref
Definition: z3py.py:304
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two&#39;s complement unary minus.
def __neg__
Definition: z3py.py:3136
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 3058 of file z3py.py.

3059  def __or__(self, other):
3060  """Create the Z3 expression bitwise-or `self | other`.
3061 
3062  >>> x = BitVec('x', 32)
3063  >>> y = BitVec('y', 32)
3064  >>> x | y
3065  x | y
3066  >>> (x | y).sort()
3067  BitVec(32)
3068  """
3069  a, b = _coerce_exprs(self, other)
3070  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.
def ctx_ref
Definition: z3py.py:304
def __or__
Definition: z3py.py:3058
def __pos__ (   self)
Return `self`.

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

Definition at line 3127 of file z3py.py.

3128  def __pos__(self):
3129  """Return `self`.
3130 
3131  >>> x = BitVec('x', 32)
3132  >>> +x
3133  x
3134  """
3135  return self
def __pos__
Definition: z3py.py:3127
def __radd__ (   self,
  other 
)
Create the Z3 expression `other + self`.

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

Definition at line 3002 of file z3py.py.

3003  def __radd__(self, other):
3004  """Create the Z3 expression `other + self`.
3005 
3006  >>> x = BitVec('x', 32)
3007  >>> 10 + x
3008  10 + x
3009  """
3010  a, b = _coerce_exprs(self, other)
3011  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
def __radd__
Definition: z3py.py:3002
def ctx_ref
Definition: z3py.py:304
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement addition.
def __rand__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other & self`.

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

Definition at line 3094 of file z3py.py.

3095  def __rand__(self, other):
3096  """Create the Z3 expression bitwise-or `other & self`.
3097 
3098  >>> x = BitVec('x', 32)
3099  >>> 10 & x
3100  10 & x
3101  """
3102  a, b = _coerce_exprs(self, other)
3103  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
def __rand__
Definition: z3py.py:3094
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.
def ctx_ref
Definition: z3py.py:304
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 3181 of file z3py.py.

3182  def __rdiv__(self, other):
3183  """Create the Z3 expression (signed) division `other / self`.
3184 
3185  Use the function UDiv() for unsigned division.
3186 
3187  >>> x = BitVec('x', 32)
3188  >>> 10 / x
3189  10/x
3190  >>> (10 / x).sexpr()
3191  '(bvsdiv #x0000000a x)'
3192  >>> UDiv(10, x).sexpr()
3193  '(bvudiv #x0000000a x)'
3194  """
3195  a, b = _coerce_exprs(self, other)
3196  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two&#39;s complement signed division.
def __rdiv__
Definition: z3py.py:3181
def ctx_ref
Definition: z3py.py:304
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 3362 of file z3py.py.

3363  def __rlshift__(self, other):
3364  """Create the Z3 expression left shift `other << self`.
3365 
3366  Use the function LShR() for the right logical shift
3367 
3368  >>> x = BitVec('x', 32)
3369  >>> 10 << x
3370  10 << x
3371  >>> (10 << x).sexpr()
3372  '(bvshl #x0000000a x)'
3373  """
3374  a, b = _coerce_exprs(self, other)
3375  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.
def __rlshift__
Definition: z3py.py:3362
def ctx_ref
Definition: z3py.py:304
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 3222 of file z3py.py.

3223  def __rmod__(self, other):
3224  """Create the Z3 expression (signed) mod `other % self`.
3225 
3226  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3227 
3228  >>> x = BitVec('x', 32)
3229  >>> 10 % x
3230  10%x
3231  >>> (10 % x).sexpr()
3232  '(bvsmod #x0000000a x)'
3233  >>> URem(10, x).sexpr()
3234  '(bvurem #x0000000a x)'
3235  >>> SRem(10, x).sexpr()
3236  '(bvsrem #x0000000a x)'
3237  """
3238  a, b = _coerce_exprs(self, other)
3239  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
def __rmod__
Definition: z3py.py:3222
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).
def ctx_ref
Definition: z3py.py:304
def __rmul__ (   self,
  other 
)
Create the Z3 expression `other * self`.

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

Definition at line 3025 of file z3py.py.

3026  def __rmul__(self, other):
3027  """Create the Z3 expression `other * self`.
3028 
3029  >>> x = BitVec('x', 32)
3030  >>> 10 * x
3031  10*x
3032  """
3033  a, b = _coerce_exprs(self, other)
3034  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
def __rmul__
Definition: z3py.py:3025
def ctx_ref
Definition: z3py.py:304
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement multiplication.
def __ror__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other | self`.

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

Definition at line 3071 of file z3py.py.

3072  def __ror__(self, other):
3073  """Create the Z3 expression bitwise-or `other | self`.
3074 
3075  >>> x = BitVec('x', 32)
3076  >>> 10 | x
3077  10 | x
3078  """
3079  a, b = _coerce_exprs(self, other)
3080  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
def __ror__
Definition: z3py.py:3071
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.
def ctx_ref
Definition: z3py.py:304
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 3348 of file z3py.py.

3349  def __rrshift__(self, other):
3350  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3351 
3352  Use the function LShR() for the right logical shift
3353 
3354  >>> x = BitVec('x', 32)
3355  >>> 10 >> x
3356  10 >> x
3357  >>> (10 >> x).sexpr()
3358  '(bvashr #x0000000a x)'
3359  """
3360  a, b = _coerce_exprs(self, other)
3361  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.
def ctx_ref
Definition: z3py.py:304
def __rrshift__
Definition: z3py.py:3348
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 3304 of file z3py.py.

3305  def __rshift__(self, other):
3306  """Create the Z3 expression (arithmetical) right shift `self >> other`
3307 
3308  Use the function LShR() for the right logical shift
3309 
3310  >>> x, y = BitVecs('x y', 32)
3311  >>> x >> y
3312  x >> y
3313  >>> (x >> y).sexpr()
3314  '(bvashr x y)'
3315  >>> LShR(x, y).sexpr()
3316  '(bvlshr x y)'
3317  >>> BitVecVal(4, 3)
3318  4
3319  >>> BitVecVal(4, 3).as_signed_long()
3320  -4
3321  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3322  -2
3323  >>> simplify(BitVecVal(4, 3) >> 1)
3324  6
3325  >>> simplify(LShR(BitVecVal(4, 3), 1))
3326  2
3327  >>> simplify(BitVecVal(2, 3) >> 1)
3328  1
3329  >>> simplify(LShR(BitVecVal(2, 3), 1))
3330  1
3331  """
3332  a, b = _coerce_exprs(self, other)
3333  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.
def __rshift__
Definition: z3py.py:3304
def ctx_ref
Definition: z3py.py:304
def __rsub__ (   self,
  other 
)
Create the Z3 expression `other - self`.

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

Definition at line 3048 of file z3py.py.

3049  def __rsub__(self, other):
3050  """Create the Z3 expression `other - self`.
3051 
3052  >>> x = BitVec('x', 32)
3053  >>> 10 - x
3054  10 - x
3055  """
3056  a, b = _coerce_exprs(self, other)
3057  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
def __rsub__
Definition: z3py.py:3048
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement subtraction.
def ctx_ref
Definition: z3py.py:304
def __rtruediv__ (   self,
  other 
)
Create the Z3 expression (signed) division `other / self`.

Definition at line 3197 of file z3py.py.

3198  def __rtruediv__(self, other):
3199  """Create the Z3 expression (signed) division `other / self`."""
3200  return self.__rdiv__(other)
def __rtruediv__
Definition: z3py.py:3197
def __rdiv__
Definition: z3py.py:3181
def __rxor__ (   self,
  other 
)
Create the Z3 expression bitwise-xor `other ^ self`.

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

Definition at line 3117 of file z3py.py.

3118  def __rxor__(self, other):
3119  """Create the Z3 expression bitwise-xor `other ^ self`.
3120 
3121  >>> x = BitVec('x', 32)
3122  >>> 10 ^ x
3123  10 ^ x
3124  """
3125  a, b = _coerce_exprs(self, other)
3126  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
def __rxor__
Definition: z3py.py:3117
def ctx_ref
Definition: z3py.py:304
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.
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 3035 of file z3py.py.

3036  def __sub__(self, other):
3037  """Create the Z3 expression `self - other`.
3038 
3039  >>> x = BitVec('x', 32)
3040  >>> y = BitVec('y', 32)
3041  >>> x - y
3042  x - y
3043  >>> (x - y).sort()
3044  BitVec(32)
3045  """
3046  a, b = _coerce_exprs(self, other)
3047  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two&#39;s complement subtraction.
def ctx_ref
Definition: z3py.py:304
def __sub__
Definition: z3py.py:3035
def __truediv__ (   self,
  other 
)
Create the Z3 expression (signed) division `self / other`.

Definition at line 3177 of file z3py.py.

3178  def __truediv__(self, other):
3179  """Create the Z3 expression (signed) division `self / other`."""
3180  return self.__div__(other)
def __truediv__
Definition: z3py.py:3177
def __div__
Definition: z3py.py:3158
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 3104 of file z3py.py.

3105  def __xor__(self, other):
3106  """Create the Z3 expression bitwise-xor `self ^ other`.
3107 
3108  >>> x = BitVec('x', 32)
3109  >>> y = BitVec('y', 32)
3110  >>> x ^ y
3111  x ^ y
3112  >>> (x ^ y).sort()
3113  BitVec(32)
3114  """
3115  a, b = _coerce_exprs(self, other)
3116  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
def ctx_ref
Definition: z3py.py:304
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.
def __xor__
Definition: z3py.py:3104
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 2978 of file z3py.py.

2979  def size(self):
2980  """Return the number of bits of the bit-vector expression `self`.
2981 
2982  >>> x = BitVec('x', 32)
2983  >>> (x + 1).size()
2984  32
2985  >>> Concat(x, x).size()
2986  64
2987  """
2988  return self.sort().size()
def sort
Definition: z3py.py:752
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 2967 of file z3py.py.

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

2968  def sort(self):
2969  """Return the sort of the bit-vector expression `self`.
2970 
2971  >>> x = BitVec('x', 32)
2972  >>> x.sort()
2973  BitVec(32)
2974  >>> x.sort() == BitVecSort(32)
2975  True
2976  """
2977  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
Bit-Vectors.
Definition: z3py.py:2922
def as_ast
Definition: z3py.py:296
def ctx_ref
Definition: z3py.py:304
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.