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

2975  def __add__(self, other):
2976  """Create the Z3 expression `self + other`.
2977 
2978  >>> x = BitVec('x', 32)
2979  >>> y = BitVec('y', 32)
2980  >>> x + y
2981  x + y
2982  >>> (x + y).sort()
2983  BitVec(32)
2984  """
2985  a, b = _coerce_exprs(self, other)
2986  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
2987 
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:2975
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 3067 of file z3py.py.

3067  def __and__(self, other):
3068  """Create the Z3 expression bitwise-and `self & other`.
3069 
3070  >>> x = BitVec('x', 32)
3071  >>> y = BitVec('y', 32)
3072  >>> x & y
3073  x & y
3074  >>> (x & y).sort()
3075  BitVec(32)
3076  """
3077  a, b = _coerce_exprs(self, other)
3078  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3079 
def __and__(self, other)
Definition: z3py.py:3067
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 3144 of file z3py.py.

3144  def __div__(self, other):
3145  """Create the Z3 expression (signed) division `self / other`.
3146 
3147  Use the function UDiv() for unsigned division.
3148 
3149  >>> x = BitVec('x', 32)
3150  >>> y = BitVec('y', 32)
3151  >>> x / y
3152  x/y
3153  >>> (x / y).sort()
3154  BitVec(32)
3155  >>> (x / y).sexpr()
3156  '(bvsdiv x y)'
3157  >>> UDiv(x, y).sexpr()
3158  '(bvudiv x y)'
3159  """
3160  a, b = _coerce_exprs(self, other)
3161  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3162 
def __div__(self, other)
Definition: z3py.py:3144
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 3274 of file z3py.py.

3274  def __ge__(self, other):
3275  """Create the Z3 expression (signed) `other >= self`.
3276 
3277  Use the function UGE() for unsigned greater than or equal to.
3278 
3279  >>> x, y = BitVecs('x y', 32)
3280  >>> x >= y
3281  x >= y
3282  >>> (x >= y).sexpr()
3283  '(bvsge x y)'
3284  >>> UGE(x, y).sexpr()
3285  '(bvuge x y)'
3286  """
3287  a, b = _coerce_exprs(self, other)
3288  return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3289 
def __ge__(self, other)
Definition: z3py.py:3274
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 3258 of file z3py.py.

3258  def __gt__(self, other):
3259  """Create the Z3 expression (signed) `other > self`.
3260 
3261  Use the function UGT() for unsigned greater than.
3262 
3263  >>> x, y = BitVecs('x y', 32)
3264  >>> x > y
3265  x > y
3266  >>> (x > y).sexpr()
3267  '(bvsgt x y)'
3268  >>> UGT(x, y).sexpr()
3269  '(bvugt x y)'
3270  """
3271  a, b = _coerce_exprs(self, other)
3272  return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3273 
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:3258
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 3133 of file z3py.py.

3133  def __invert__(self):
3134  """Create the Z3 expression bitwise-not `~self`.
3135 
3136  >>> x = BitVec('x', 32)
3137  >>> ~x
3138  ~x
3139  >>> simplify(~(~x))
3140  x
3141  """
3142  return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3143 
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:3133
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 3226 of file z3py.py.

3226  def __le__(self, other):
3227  """Create the Z3 expression (signed) `other <= self`.
3228 
3229  Use the function ULE() for unsigned less than or equal to.
3230 
3231  >>> x, y = BitVecs('x y', 32)
3232  >>> x <= y
3233  x <= y
3234  >>> (x <= y).sexpr()
3235  '(bvsle x y)'
3236  >>> ULE(x, y).sexpr()
3237  '(bvule x y)'
3238  """
3239  a, b = _coerce_exprs(self, other)
3240  return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3241 
def __le__(self, other)
Definition: z3py.py:3226
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 3320 of file z3py.py.

3320  def __lshift__(self, other):
3321  """Create the Z3 expression left shift `self << other`
3322 
3323  >>> x, y = BitVecs('x y', 32)
3324  >>> x << y
3325  x << y
3326  >>> (x << y).sexpr()
3327  '(bvshl x y)'
3328  >>> simplify(BitVecVal(2, 3) << 1)
3329  4
3330  """
3331  a, b = _coerce_exprs(self, other)
3332  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3333 
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:3320
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 3242 of file z3py.py.

3242  def __lt__(self, other):
3243  """Create the Z3 expression (signed) `other < self`.
3244 
3245  Use the function ULT() for unsigned less than.
3246 
3247  >>> x, y = BitVecs('x y', 32)
3248  >>> x < y
3249  x < y
3250  >>> (x < y).sexpr()
3251  '(bvslt x y)'
3252  >>> ULT(x, y).sexpr()
3253  '(bvult x y)'
3254  """
3255  a, b = _coerce_exprs(self, other)
3256  return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3257 
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:3242
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 3187 of file z3py.py.

3187  def __mod__(self, other):
3188  """Create the Z3 expression (signed) mod `self % other`.
3189 
3190  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3191 
3192  >>> x = BitVec('x', 32)
3193  >>> y = BitVec('y', 32)
3194  >>> x % y
3195  x%y
3196  >>> (x % y).sort()
3197  BitVec(32)
3198  >>> (x % y).sexpr()
3199  '(bvsmod x y)'
3200  >>> URem(x, y).sexpr()
3201  '(bvurem x y)'
3202  >>> SRem(x, y).sexpr()
3203  '(bvsrem x y)'
3204  """
3205  a, b = _coerce_exprs(self, other)
3206  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3207 
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:3187
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 2998 of file z3py.py.

2998  def __mul__(self, other):
2999  """Create the Z3 expression `self * other`.
3000 
3001  >>> x = BitVec('x', 32)
3002  >>> y = BitVec('y', 32)
3003  >>> x * y
3004  x*y
3005  >>> (x * y).sort()
3006  BitVec(32)
3007  """
3008  a, b = _coerce_exprs(self, other)
3009  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3010 
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:2998
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 3122 of file z3py.py.

3122  def __neg__(self):
3123  """Return an expression representing `-self`.
3124 
3125  >>> x = BitVec('x', 32)
3126  >>> -x
3127  -x
3128  >>> simplify(-(-x))
3129  x
3130  """
3131  return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3132 
def as_ast(self)
Definition: z3py.py:296
def __neg__(self)
Definition: z3py.py:3122
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 3044 of file z3py.py.

3044  def __or__(self, other):
3045  """Create the Z3 expression bitwise-or `self | other`.
3046 
3047  >>> x = BitVec('x', 32)
3048  >>> y = BitVec('y', 32)
3049  >>> x | y
3050  x | y
3051  >>> (x | y).sort()
3052  BitVec(32)
3053  """
3054  a, b = _coerce_exprs(self, other)
3055  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3056 
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:3044
def ctx_ref(self)
Definition: z3py.py:305
def __pos__ (   self)
Return `self`.

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

Definition at line 3113 of file z3py.py.

3113  def __pos__(self):
3114  """Return `self`.
3115 
3116  >>> x = BitVec('x', 32)
3117  >>> +x
3118  x
3119  """
3120  return self
3121 
def __pos__(self)
Definition: z3py.py:3113
def __radd__ (   self,
  other 
)
Create the Z3 expression `other + self`.

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

Definition at line 2988 of file z3py.py.

2988  def __radd__(self, other):
2989  """Create the Z3 expression `other + self`.
2990 
2991  >>> x = BitVec('x', 32)
2992  >>> 10 + x
2993  10 + x
2994  """
2995  a, b = _coerce_exprs(self, other)
2996  return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
2997 
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:2988
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 3080 of file z3py.py.

3080  def __rand__(self, other):
3081  """Create the Z3 expression bitwise-or `other & self`.
3082 
3083  >>> x = BitVec('x', 32)
3084  >>> 10 & x
3085  10 & x
3086  """
3087  a, b = _coerce_exprs(self, other)
3088  return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3089 
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:3080
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 3167 of file z3py.py.

3167  def __rdiv__(self, other):
3168  """Create the Z3 expression (signed) division `other / self`.
3169 
3170  Use the function UDiv() for unsigned division.
3171 
3172  >>> x = BitVec('x', 32)
3173  >>> 10 / x
3174  10/x
3175  >>> (10 / x).sexpr()
3176  '(bvsdiv #x0000000a x)'
3177  >>> UDiv(10, x).sexpr()
3178  '(bvudiv #x0000000a x)'
3179  """
3180  a, b = _coerce_exprs(self, other)
3181  return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3182 
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:3167
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 3348 of file z3py.py.

3348  def __rlshift__(self, other):
3349  """Create the Z3 expression left 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  '(bvshl #x0000000a x)'
3358  """
3359  a, b = _coerce_exprs(self, other)
3360  return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3361 
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:3348
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 3208 of file z3py.py.

3208  def __rmod__(self, other):
3209  """Create the Z3 expression (signed) mod `other % self`.
3210 
3211  Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3212 
3213  >>> x = BitVec('x', 32)
3214  >>> 10 % x
3215  10%x
3216  >>> (10 % x).sexpr()
3217  '(bvsmod #x0000000a x)'
3218  >>> URem(10, x).sexpr()
3219  '(bvurem #x0000000a x)'
3220  >>> SRem(10, x).sexpr()
3221  '(bvsrem #x0000000a x)'
3222  """
3223  a, b = _coerce_exprs(self, other)
3224  return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3225 
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:3208
def __rmul__ (   self,
  other 
)
Create the Z3 expression `other * self`.

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

Definition at line 3011 of file z3py.py.

3011  def __rmul__(self, other):
3012  """Create the Z3 expression `other * self`.
3013 
3014  >>> x = BitVec('x', 32)
3015  >>> 10 * x
3016  10*x
3017  """
3018  a, b = _coerce_exprs(self, other)
3019  return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3020 
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:3011
def __ror__ (   self,
  other 
)
Create the Z3 expression bitwise-or `other | self`.

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

Definition at line 3057 of file z3py.py.

3057  def __ror__(self, other):
3058  """Create the Z3 expression bitwise-or `other | self`.
3059 
3060  >>> x = BitVec('x', 32)
3061  >>> 10 | x
3062  10 | x
3063  """
3064  a, b = _coerce_exprs(self, other)
3065  return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3066 
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:3057
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 3334 of file z3py.py.

3334  def __rrshift__(self, other):
3335  """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3336 
3337  Use the function LShR() for the right logical shift
3338 
3339  >>> x = BitVec('x', 32)
3340  >>> 10 >> x
3341  10 >> x
3342  >>> (10 >> x).sexpr()
3343  '(bvashr #x0000000a x)'
3344  """
3345  a, b = _coerce_exprs(self, other)
3346  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3347 
def __rrshift__(self, other)
Definition: z3py.py:3334
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 3290 of file z3py.py.

3290  def __rshift__(self, other):
3291  """Create the Z3 expression (arithmetical) right shift `self >> other`
3292 
3293  Use the function LShR() for the right logical shift
3294 
3295  >>> x, y = BitVecs('x y', 32)
3296  >>> x >> y
3297  x >> y
3298  >>> (x >> y).sexpr()
3299  '(bvashr x y)'
3300  >>> LShR(x, y).sexpr()
3301  '(bvlshr x y)'
3302  >>> BitVecVal(4, 3)
3303  4
3304  >>> BitVecVal(4, 3).as_signed_long()
3305  -4
3306  >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3307  -2
3308  >>> simplify(BitVecVal(4, 3) >> 1)
3309  6
3310  >>> simplify(LShR(BitVecVal(4, 3), 1))
3311  2
3312  >>> simplify(BitVecVal(2, 3) >> 1)
3313  1
3314  >>> simplify(LShR(BitVecVal(2, 3), 1))
3315  1
3316  """
3317  a, b = _coerce_exprs(self, other)
3318  return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3319 
def __rshift__(self, other)
Definition: z3py.py:3290
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 3034 of file z3py.py.

3034  def __rsub__(self, other):
3035  """Create the Z3 expression `other - self`.
3036 
3037  >>> x = BitVec('x', 32)
3038  >>> 10 - x
3039  10 - x
3040  """
3041  a, b = _coerce_exprs(self, other)
3042  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3043 
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:3034
def __rtruediv__ (   self,
  other 
)
Create the Z3 expression (signed) division `other / self`.

Definition at line 3183 of file z3py.py.

3183  def __rtruediv__(self, other):
3184  """Create the Z3 expression (signed) division `other / self`."""
3185  return self.__rdiv__(other)
3186 
def __rdiv__(self, other)
Definition: z3py.py:3167
def __rtruediv__(self, other)
Definition: z3py.py:3183
def __rxor__ (   self,
  other 
)
Create the Z3 expression bitwise-xor `other ^ self`.

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

Definition at line 3103 of file z3py.py.

3103  def __rxor__(self, other):
3104  """Create the Z3 expression bitwise-xor `other ^ self`.
3105 
3106  >>> x = BitVec('x', 32)
3107  >>> 10 ^ x
3108  10 ^ x
3109  """
3110  a, b = _coerce_exprs(self, other)
3111  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3112 
def __rxor__(self, other)
Definition: z3py.py:3103
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 3021 of file z3py.py.

3021  def __sub__(self, other):
3022  """Create the Z3 expression `self - other`.
3023 
3024  >>> x = BitVec('x', 32)
3025  >>> y = BitVec('y', 32)
3026  >>> x - y
3027  x - y
3028  >>> (x - y).sort()
3029  BitVec(32)
3030  """
3031  a, b = _coerce_exprs(self, other)
3032  return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3033 
def __sub__(self, other)
Definition: z3py.py:3021
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 3163 of file z3py.py.

3163  def __truediv__(self, other):
3164  """Create the Z3 expression (signed) division `self / other`."""
3165  return self.__div__(other)
3166 
def __div__(self, other)
Definition: z3py.py:3144
def __truediv__(self, other)
Definition: z3py.py:3163
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 3090 of file z3py.py.

3090  def __xor__(self, other):
3091  """Create the Z3 expression bitwise-xor `self ^ other`.
3092 
3093  >>> x = BitVec('x', 32)
3094  >>> y = BitVec('y', 32)
3095  >>> x ^ y
3096  x ^ y
3097  >>> (x ^ y).sort()
3098  BitVec(32)
3099  """
3100  a, b = _coerce_exprs(self, other)
3101  return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3102 
def __xor__(self, other)
Definition: z3py.py:3090
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 2964 of file z3py.py.

Referenced by BitVecNumRef.as_signed_long().

2964  def size(self):
2965  """Return the number of bits of the bit-vector expression `self`.
2966 
2967  >>> x = BitVec('x', 32)
2968  >>> (x + 1).size()
2969  32
2970  >>> Concat(x, x).size()
2971  64
2972  """
2973  return self.sort().size()
2974 
def sort(self)
Definition: z3py.py:752
def size(self)
Definition: z3py.py:2964
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 2953 of file z3py.py.

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

2953  def sort(self):
2954  """Return the sort of the bit-vector expression `self`.
2955 
2956  >>> x = BitVec('x', 32)
2957  >>> x.sort()
2958  BitVec(32)
2959  >>> x.sort() == BitVecSort(32)
2960  True
2961  """
2962  return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
2963 
def as_ast(self)
Definition: z3py.py:296
Bit-Vectors.
Definition: z3py.py:2908
def sort(self)
Definition: z3py.py:2953
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