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 __ne__ (self, other)
 
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 __str__ (self)
 
def __repr__ (self)
 
def sexpr (self)
 
def as_ast (self)
 
def get_id (self)
 
def ctx_ref (self)
 
def eq (self, other)
 
def translate (self, target)
 
def hash (self)
 
- Public Member Functions inherited from Z3PPObject
def use_pp (self)
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast
 
 ctx
 

Detailed Description

Bit-vector expressions.

Definition at line 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.

2989  def __add__(self, other):
2990  """Create the Z3 expression `self + other`.
2991 
2992  >>> x = BitVec('x', 32)
2993  >>> y = BitVec('y', 32)
2994  >>> x + y
2995  x + y
2996  >>> (x + y).sort()
2997  BitVec(32)
2998  """
2999  a, b = _coerce_exprs(self, other)
3000  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3001 
def __add__(self, other)
Definition: z3py.py:2989
def ctx_ref(self)
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.

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

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

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

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

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

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

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

3256  def __lt__(self, other):
3257  """Create the Z3 expression (signed) `other < self`.
3258 
3259  Use the function ULT() for unsigned less than.
3260 
3261  >>> x, y = BitVecs('x y', 32)
3262  >>> x < y
3263  x < y
3264  >>> (x < y).sexpr()
3265  '(bvslt x y)'
3266  >>> ULT(x, y).sexpr()
3267  '(bvult x y)'
3268  """
3269  a, b = _coerce_exprs(self, other)
3270  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3271 
def __lt__(self, other)
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(self)
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.

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

3012  def __mul__(self, other):
3013  """Create the Z3 expression `self * other`.
3014 
3015  >>> x = BitVec('x', 32)
3016  >>> y = BitVec('y', 32)
3017  >>> x * y
3018  x*y
3019  >>> (x * y).sort()
3020  BitVec(32)
3021  """
3022  a, b = _coerce_exprs(self, other)
3023  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3024 
def __mul__(self, other)
Definition: z3py.py:3012
def ctx_ref(self)
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.

3136  def __neg__(self):
3137  """Return an expression representing `-self`.
3138 
3139  >>> x = BitVec('x', 32)
3140  >>> -x
3141  -x
3142  >>> simplify(-(-x))
3143  x
3144  """
3145  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3146 
def as_ast(self)
Definition: z3py.py:296
def __neg__(self)
Definition: z3py.py:3136
def ctx_ref(self)
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 __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.

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

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

Definition at line 3127 of file z3py.py.

3127  def __pos__(self):
3128  """Return `self`.
3129 
3130  >>> x = BitVec('x', 32)
3131  >>> +x
3132  x
3133  """
3134  return self
3135 
def __pos__(self)
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.

3002  def __radd__(self, other):
3003  """Create the Z3 expression `other + self`.
3004 
3005  >>> x = BitVec('x', 32)
3006  >>> 10 + x
3007  10 + x
3008  """
3009  a, b = _coerce_exprs(self, other)
3010  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3011 
def __radd__(self, other)
Definition: z3py.py:3002
def ctx_ref(self)
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.

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

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

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

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

3025  def __rmul__(self, other):
3026  """Create the Z3 expression `other * self`.
3027 
3028  >>> x = BitVec('x', 32)
3029  >>> 10 * x
3030  10*x
3031  """
3032  a, b = _coerce_exprs(self, other)
3033  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3034 
def ctx_ref(self)
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 __rmul__(self, other)
Definition: z3py.py:3025
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.

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

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

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

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

Definition at line 3197 of file z3py.py.

3197  def __rtruediv__(self, other):
3198  """Create the Z3 expression (signed) division `other / self`."""
3199  return self.__rdiv__(other)
3200 
def __rdiv__(self, other)
Definition: z3py.py:3181
def __rtruediv__(self, other)
Definition: z3py.py:3197
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.

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

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

Definition at line 3177 of file z3py.py.

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

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

Referenced by BitVecNumRef.as_signed_long().

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

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