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__
 
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 2939 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 2964 of file z3py.py.

2964  def __add__(self, other):
2965  """Create the Z3 expression `self + other`.
2966 
2967  >>> x = BitVec('x', 32)
2968  >>> y = BitVec('y', 32)
2969  >>> x + y
2970  x + y
2971  >>> (x + y).sort()
2972  BitVec(32)
2973  """
2974  a, b = _coerce_exprs(self, other)
2975  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2976 
Z3_ast Z3_API Z3_mk_bvadd(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Standard two's complement addition.
def __add__(self, other)
Definition: z3py.py:2964
def ctx_ref(self)
Definition: z3py.py:305
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 3056 of file z3py.py.

3056  def __and__(self, other):
3057  """Create the Z3 expression bitwise-and `self & other`.
3058 
3059  >>> x = BitVec('x', 32)
3060  >>> y = BitVec('y', 32)
3061  >>> x & y
3062  x & y
3063  >>> (x & y).sort()
3064  BitVec(32)
3065  """
3066  a, b = _coerce_exprs(self, other)
3067  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3068 
def __and__(self, other)
Definition: z3py.py:3056
Z3_ast Z3_API Z3_mk_bvand(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Bitwise and.
def ctx_ref(self)
Definition: z3py.py:305
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 3133 of file z3py.py.

3133  def __div__(self, other):
3134  """Create the Z3 expression (signed) division `self / other`.
3135 
3136  Use the function UDiv() for unsigned division.
3137 
3138  >>> x = BitVec('x', 32)
3139  >>> y = BitVec('y', 32)
3140  >>> x / y
3141  x/y
3142  >>> (x / y).sort()
3143  BitVec(32)
3144  >>> (x / y).sexpr()
3145  '(bvsdiv x y)'
3146  >>> UDiv(x, y).sexpr()
3147  '(bvudiv x y)'
3148  """
3149  a, b = _coerce_exprs(self, other)
3150  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3151 
def __div__(self, other)
Definition: z3py.py:3133
Z3_ast Z3_API Z3_mk_bvsdiv(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Two's complement signed division.
def ctx_ref(self)
Definition: z3py.py:305
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 3263 of file z3py.py.

3263  def __ge__(self, other):
3264  """Create the Z3 expression (signed) `other >= self`.
3265 
3266  Use the function UGE() for unsigned greater than or equal to.
3267 
3268  >>> x, y = BitVecs('x y', 32)
3269  >>> x >= y
3270  x >= y
3271  >>> (x >= y).sexpr()
3272  '(bvsge x y)'
3273  >>> UGE(x, y).sexpr()
3274  '(bvuge x y)'
3275  """
3276  a, b = _coerce_exprs(self, other)
3277  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3278 
def __ge__(self, other)
Definition: z3py.py:3263
Z3_ast Z3_API Z3_mk_bvsge(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Two's complement signed greater than or equal to.
def ctx_ref(self)
Definition: z3py.py:305
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 3247 of file z3py.py.

3247  def __gt__(self, other):
3248  """Create the Z3 expression (signed) `other > self`.
3249 
3250  Use the function UGT() for unsigned greater than.
3251 
3252  >>> x, y = BitVecs('x y', 32)
3253  >>> x > y
3254  x > y
3255  >>> (x > y).sexpr()
3256  '(bvsgt x y)'
3257  >>> UGT(x, y).sexpr()
3258  '(bvugt x y)'
3259  """
3260  a, b = _coerce_exprs(self, other)
3261  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3262 
Z3_ast Z3_API Z3_mk_bvsgt(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Two's complement signed greater than.
def __gt__(self, other)
Definition: z3py.py:3247
def ctx_ref(self)
Definition: z3py.py:305
def __invert__ (   self)
Create the Z3 expression bitwise-not `~self`.

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

Definition at line 3122 of file z3py.py.

3122  def __invert__(self):
3123  """Create the Z3 expression bitwise-not `~self`.
3124 
3125  >>> x = BitVec('x', 32)
3126  >>> ~x
3127  ~x
3128  >>> simplify(~(~x))
3129  x
3130  """
3131  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3132 
def as_ast(self)
Definition: z3py.py:296
Z3_ast Z3_API Z3_mk_bvnot(__in Z3_context c, __in Z3_ast t1)
Bitwise negation.
def ctx_ref(self)
Definition: z3py.py:305
def __invert__(self)
Definition: z3py.py:3122
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 3215 of file z3py.py.

3215  def __le__(self, other):
3216  """Create the Z3 expression (signed) `other <= self`.
3217 
3218  Use the function ULE() for unsigned less than or equal to.
3219 
3220  >>> x, y = BitVecs('x y', 32)
3221  >>> x <= y
3222  x <= y
3223  >>> (x <= y).sexpr()
3224  '(bvsle x y)'
3225  >>> ULE(x, y).sexpr()
3226  '(bvule x y)'
3227  """
3228  a, b = _coerce_exprs(self, other)
3229  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3230 
def __le__(self, other)
Definition: z3py.py:3215
Z3_ast Z3_API Z3_mk_bvsle(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Two's complement signed less than or equal to.
def ctx_ref(self)
Definition: z3py.py:305
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 3309 of file z3py.py.

3309  def __lshift__(self, other):
3310  """Create the Z3 expression left shift `self << other`
3311 
3312  >>> x, y = BitVecs('x y', 32)
3313  >>> x << y
3314  x << y
3315  >>> (x << y).sexpr()
3316  '(bvshl x y)'
3317  >>> simplify(BitVecVal(2, 3) << 1)
3318  4
3319  """
3320  a, b = _coerce_exprs(self, other)
3321  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3322 
Z3_ast Z3_API Z3_mk_bvshl(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Shift left.
def ctx_ref(self)
Definition: z3py.py:305
def __lshift__(self, other)
Definition: z3py.py:3309
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 3231 of file z3py.py.

3231  def __lt__(self, other):
3232  """Create the Z3 expression (signed) `other < self`.
3233 
3234  Use the function ULT() for unsigned less than.
3235 
3236  >>> x, y = BitVecs('x y', 32)
3237  >>> x < y
3238  x < y
3239  >>> (x < y).sexpr()
3240  '(bvslt x y)'
3241  >>> ULT(x, y).sexpr()
3242  '(bvult x y)'
3243  """
3244  a, b = _coerce_exprs(self, other)
3245  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3246 
Z3_ast Z3_API Z3_mk_bvslt(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Two's complement signed less than.
def __lt__(self, other)
Definition: z3py.py:3231
def ctx_ref(self)
Definition: z3py.py:305
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 3176 of file z3py.py.

3176  def __mod__(self, other):
3177  """Create the Z3 expression (signed) mod `self % other`.
3178 
3179  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3180 
3181  >>> x = BitVec('x', 32)
3182  >>> y = BitVec('y', 32)
3183  >>> x % y
3184  x%y
3185  >>> (x % y).sort()
3186  BitVec(32)
3187  >>> (x % y).sexpr()
3188  '(bvsmod x y)'
3189  >>> URem(x, y).sexpr()
3190  '(bvurem x y)'
3191  >>> SRem(x, y).sexpr()
3192  '(bvsrem x y)'
3193  """
3194  a, b = _coerce_exprs(self, other)
3195  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3196 
Z3_ast Z3_API Z3_mk_bvsmod(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Two's complement signed remainder (sign follows divisor).
def __mod__(self, other)
Definition: z3py.py:3176
def ctx_ref(self)
Definition: z3py.py:305
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 2987 of file z3py.py.

2987  def __mul__(self, other):
2988  """Create the Z3 expression `self * other`.
2989 
2990  >>> x = BitVec('x', 32)
2991  >>> y = BitVec('y', 32)
2992  >>> x * y
2993  x*y
2994  >>> (x * y).sort()
2995  BitVec(32)
2996  """
2997  a, b = _coerce_exprs(self, other)
2998  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2999 
Z3_ast Z3_API Z3_mk_bvmul(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Standard two's complement multiplication.
def __mul__(self, other)
Definition: z3py.py:2987
def ctx_ref(self)
Definition: z3py.py:305
def __neg__ (   self)
Return an expression representing `-self`.

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

Definition at line 3111 of file z3py.py.

3111  def __neg__(self):
3112  """Return an expression representing `-self`.
3113 
3114  >>> x = BitVec('x', 32)
3115  >>> -x
3116  -x
3117  >>> simplify(-(-x))
3118  x
3119  """
3120  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3121 
def as_ast(self)
Definition: z3py.py:296
def __neg__(self)
Definition: z3py.py:3111
Z3_ast Z3_API Z3_mk_bvneg(__in Z3_context c, __in Z3_ast t1)
Standard two's complement unary minus.
def ctx_ref(self)
Definition: z3py.py:305
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 3033 of file z3py.py.

3033  def __or__(self, other):
3034  """Create the Z3 expression bitwise-or `self | other`.
3035 
3036  >>> x = BitVec('x', 32)
3037  >>> y = BitVec('y', 32)
3038  >>> x | y
3039  x | y
3040  >>> (x | y).sort()
3041  BitVec(32)
3042  """
3043  a, b = _coerce_exprs(self, other)
3044  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3045 
Z3_ast Z3_API Z3_mk_bvor(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Bitwise or.
def __or__(self, other)
Definition: z3py.py:3033
def ctx_ref(self)
Definition: z3py.py:305
def __pos__ (   self)
Return `self`.

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

Definition at line 3102 of file z3py.py.

3102  def __pos__(self):
3103  """Return `self`.
3104 
3105  >>> x = BitVec('x', 32)
3106  >>> +x
3107  x
3108  """
3109  return self
3110 
def __pos__(self)
Definition: z3py.py:3102
def __radd__ (   self,
  other 
)
Create the Z3 expression `other + self`.

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

Definition at line 2977 of file z3py.py.

2977  def __radd__(self, other):
2978  """Create the Z3 expression `other + self`.
2979 
2980  >>> x = BitVec('x', 32)
2981  >>> 10 + x
2982  10 + x
2983  """
2984  a, b = _coerce_exprs(self, other)
2985  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2986 
Z3_ast Z3_API Z3_mk_bvadd(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Standard two's complement addition.
def __radd__(self, other)
Definition: z3py.py:2977
def ctx_ref(self)
Definition: z3py.py:305
def __rand__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other & self`.

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

Definition at line 3069 of file z3py.py.

3069  def __rand__(self, other):
3070  """Create the Z3 expression bitwise-or `other & self`.
3071 
3072  >>> x = BitVec('x', 32)
3073  >>> 10 & x
3074  10 & x
3075  """
3076  a, b = _coerce_exprs(self, other)
3077  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3078 
Z3_ast Z3_API Z3_mk_bvand(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Bitwise and.
def ctx_ref(self)
Definition: z3py.py:305
def __rand__(self, other)
Definition: z3py.py:3069
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 3156 of file z3py.py.

3156  def __rdiv__(self, other):
3157  """Create the Z3 expression (signed) division `other / self`.
3158 
3159  Use the function UDiv() for unsigned division.
3160 
3161  >>> x = BitVec('x', 32)
3162  >>> 10 / x
3163  10/x
3164  >>> (10 / x).sexpr()
3165  '(bvsdiv #x0000000a x)'
3166  >>> UDiv(10, x).sexpr()
3167  '(bvudiv #x0000000a x)'
3168  """
3169  a, b = _coerce_exprs(self, other)
3170  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3171 
Z3_ast Z3_API Z3_mk_bvsdiv(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Two's complement signed division.
def __rdiv__(self, other)
Definition: z3py.py:3156
def ctx_ref(self)
Definition: z3py.py:305
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 3337 of file z3py.py.

3337  def __rlshift__(self, other):
3338  """Create the Z3 expression left shift `other << self`.
3339 
3340  Use the function LShR() for the right logical shift
3341 
3342  >>> x = BitVec('x', 32)
3343  >>> 10 << x
3344  10 << x
3345  >>> (10 << x).sexpr()
3346  '(bvshl #x0000000a x)'
3347  """
3348  a, b = _coerce_exprs(self, other)
3349  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3350 
Z3_ast Z3_API Z3_mk_bvshl(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Shift left.
def ctx_ref(self)
Definition: z3py.py:305
def __rlshift__(self, other)
Definition: z3py.py:3337
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 3197 of file z3py.py.

3197  def __rmod__(self, other):
3198  """Create the Z3 expression (signed) mod `other % self`.
3199 
3200  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3201 
3202  >>> x = BitVec('x', 32)
3203  >>> 10 % x
3204  10%x
3205  >>> (10 % x).sexpr()
3206  '(bvsmod #x0000000a x)'
3207  >>> URem(10, x).sexpr()
3208  '(bvurem #x0000000a x)'
3209  >>> SRem(10, x).sexpr()
3210  '(bvsrem #x0000000a x)'
3211  """
3212  a, b = _coerce_exprs(self, other)
3213  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3214 
Z3_ast Z3_API Z3_mk_bvsmod(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Two's complement signed remainder (sign follows divisor).
def ctx_ref(self)
Definition: z3py.py:305
def __rmod__(self, other)
Definition: z3py.py:3197
def __rmul__ (   self,
  other 
)
Create the Z3 expression `other * self`.

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

Definition at line 3000 of file z3py.py.

3000  def __rmul__(self, other):
3001  """Create the Z3 expression `other * self`.
3002 
3003  >>> x = BitVec('x', 32)
3004  >>> 10 * x
3005  10*x
3006  """
3007  a, b = _coerce_exprs(self, other)
3008  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3009 
Z3_ast Z3_API Z3_mk_bvmul(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Standard two's complement multiplication.
def ctx_ref(self)
Definition: z3py.py:305
def __rmul__(self, other)
Definition: z3py.py:3000
def __ror__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other | self`.

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

Definition at line 3046 of file z3py.py.

3046  def __ror__(self, other):
3047  """Create the Z3 expression bitwise-or `other | self`.
3048 
3049  >>> x = BitVec('x', 32)
3050  >>> 10 | x
3051  10 | x
3052  """
3053  a, b = _coerce_exprs(self, other)
3054  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3055 
Z3_ast Z3_API Z3_mk_bvor(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Bitwise or.
def ctx_ref(self)
Definition: z3py.py:305
def __ror__(self, other)
Definition: z3py.py:3046
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 3323 of file z3py.py.

3323  def __rrshift__(self, other):
3324  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3325 
3326  Use the function LShR() for the right logical shift
3327 
3328  >>> x = BitVec('x', 32)
3329  >>> 10 >> x
3330  10 >> x
3331  >>> (10 >> x).sexpr()
3332  '(bvashr #x0000000a x)'
3333  """
3334  a, b = _coerce_exprs(self, other)
3335  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3336 
def __rrshift__(self, other)
Definition: z3py.py:3323
def ctx_ref(self)
Definition: z3py.py:305
Z3_ast Z3_API Z3_mk_bvashr(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Arithmetic shift right.
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 3279 of file z3py.py.

3279  def __rshift__(self, other):
3280  """Create the Z3 expression (arithmetical) right shift `self >> other`
3281 
3282  Use the function LShR() for the right logical shift
3283 
3284  >>> x, y = BitVecs('x y', 32)
3285  >>> x >> y
3286  x >> y
3287  >>> (x >> y).sexpr()
3288  '(bvashr x y)'
3289  >>> LShR(x, y).sexpr()
3290  '(bvlshr x y)'
3291  >>> BitVecVal(4, 3)
3292  4
3293  >>> BitVecVal(4, 3).as_signed_long()
3294  -4
3295  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3296  -2
3297  >>> simplify(BitVecVal(4, 3) >> 1)
3298  6
3299  >>> simplify(LShR(BitVecVal(4, 3), 1))
3300  2
3301  >>> simplify(BitVecVal(2, 3) >> 1)
3302  1
3303  >>> simplify(LShR(BitVecVal(2, 3), 1))
3304  1
3305  """
3306  a, b = _coerce_exprs(self, other)
3307  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3308 
def __rshift__(self, other)
Definition: z3py.py:3279
def ctx_ref(self)
Definition: z3py.py:305
Z3_ast Z3_API Z3_mk_bvashr(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Arithmetic shift right.
def __rsub__ (   self,
  other 
)
Create the Z3 expression `other - self`.

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

Definition at line 3023 of file z3py.py.

3023  def __rsub__(self, other):
3024  """Create the Z3 expression `other - self`.
3025 
3026  >>> x = BitVec('x', 32)
3027  >>> 10 - x
3028  10 - x
3029  """
3030  a, b = _coerce_exprs(self, other)
3031  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3032 
Z3_ast Z3_API Z3_mk_bvsub(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Standard two's complement subtraction.
def ctx_ref(self)
Definition: z3py.py:305
def __rsub__(self, other)
Definition: z3py.py:3023
def __rtruediv__ (   self,
  other 
)
Create the Z3 expression (signed) division `other / self`.

Definition at line 3172 of file z3py.py.

3172  def __rtruediv__(self, other):
3173  """Create the Z3 expression (signed) division `other / self`."""
3174  return self.__rdiv__(other)
3175 
def __rdiv__(self, other)
Definition: z3py.py:3156
def __rtruediv__(self, other)
Definition: z3py.py:3172
def __rxor__ (   self,
  other 
)
Create the Z3 expression bitwise-xor `other ^ self`.

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

Definition at line 3092 of file z3py.py.

3092  def __rxor__(self, other):
3093  """Create the Z3 expression bitwise-xor `other ^ self`.
3094 
3095  >>> x = BitVec('x', 32)
3096  >>> 10 ^ x
3097  10 ^ x
3098  """
3099  a, b = _coerce_exprs(self, other)
3100  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3101 
def __rxor__(self, other)
Definition: z3py.py:3092
Z3_ast Z3_API Z3_mk_bvxor(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Bitwise exclusive-or.
def ctx_ref(self)
Definition: z3py.py:305
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 3010 of file z3py.py.

3010  def __sub__(self, other):
3011  """Create the Z3 expression `self - other`.
3012 
3013  >>> x = BitVec('x', 32)
3014  >>> y = BitVec('y', 32)
3015  >>> x - y
3016  x - y
3017  >>> (x - y).sort()
3018  BitVec(32)
3019  """
3020  a, b = _coerce_exprs(self, other)
3021  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3022 
def __sub__(self, other)
Definition: z3py.py:3010
Z3_ast Z3_API Z3_mk_bvsub(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Standard two's complement subtraction.
def ctx_ref(self)
Definition: z3py.py:305
def __truediv__ (   self,
  other 
)
Create the Z3 expression (signed) division `self / other`.

Definition at line 3152 of file z3py.py.

3152  def __truediv__(self, other):
3153  """Create the Z3 expression (signed) division `self / other`."""
3154  return self.__div__(other)
3155 
def __div__(self, other)
Definition: z3py.py:3133
def __truediv__(self, other)
Definition: z3py.py:3152
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 3079 of file z3py.py.

3079  def __xor__(self, other):
3080  """Create the Z3 expression bitwise-xor `self ^ other`.
3081 
3082  >>> x = BitVec('x', 32)
3083  >>> y = BitVec('y', 32)
3084  >>> x ^ y
3085  x ^ y
3086  >>> (x ^ y).sort()
3087  BitVec(32)
3088  """
3089  a, b = _coerce_exprs(self, other)
3090  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3091 
def __xor__(self, other)
Definition: z3py.py:3079
Z3_ast Z3_API Z3_mk_bvxor(__in Z3_context c, __in Z3_ast t1, __in Z3_ast t2)
Bitwise exclusive-or.
def ctx_ref(self)
Definition: z3py.py:305
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 2953 of file z3py.py.

Referenced by BitVecNumRef.as_signed_long().

2953  def size(self):
2954  """Return the number of bits of the bit-vector expression `self`.
2955 
2956  >>> x = BitVec('x', 32)
2957  >>> (x + 1).size()
2958  32
2959  >>> Concat(x, x).size()
2960  64
2961  """
2962  return self.sort().size()
2963 
def sort(self)
Definition: z3py.py:748
def size(self)
Definition: z3py.py:2953
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 2942 of file z3py.py.

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

2942  def sort(self):
2943  """Return the sort of the bit-vector expression `self`.
2944 
2945  >>> x = BitVec('x', 32)
2946  >>> x.sort()
2947  BitVec(32)
2948  >>> x.sort() == BitVecSort(32)
2949  True
2950  """
2951  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
2952 
def as_ast(self)
Definition: z3py.py:296
Bit-Vectors.
Definition: z3py.py:2897
def sort(self)
Definition: z3py.py:2942
Z3_sort Z3_API Z3_get_sort(__in Z3_context c, __in Z3_ast a)
Return the sort of an AST node.
def ctx_ref(self)
Definition: z3py.py:305