Z3
 
Loading...
Searching...
No Matches
BitVecRef Class Reference
+ Inheritance diagram for BitVecRef:

Public Member Functions

 sort (self)
 
 size (self)
 
 __add__ (self, other)
 
 __radd__ (self, other)
 
 __mul__ (self, other)
 
 __rmul__ (self, other)
 
 __sub__ (self, other)
 
 __rsub__ (self, other)
 
 __or__ (self, other)
 
 __ror__ (self, other)
 
 __and__ (self, other)
 
 __rand__ (self, other)
 
 __xor__ (self, other)
 
 __rxor__ (self, other)
 
 __pos__ (self)
 
 __neg__ (self)
 
 __invert__ (self)
 
 __div__ (self, other)
 
 __truediv__ (self, other)
 
 __rdiv__ (self, other)
 
 __rtruediv__ (self, other)
 
 __mod__ (self, other)
 
 __rmod__ (self, other)
 
 __le__ (self, other)
 
 __lt__ (self, other)
 
 __gt__ (self, other)
 
 __ge__ (self, other)
 
 __rshift__ (self, other)
 
 __lshift__ (self, other)
 
 __rrshift__ (self, other)
 
 __rlshift__ (self, other)
 
- Public Member Functions inherited from ExprRef
 as_ast (self)
 
 get_id (self)
 
 sort_kind (self)
 
 __eq__ (self, other)
 
 __hash__ (self)
 
 __ne__ (self, other)
 
 params (self)
 
 decl (self)
 
 kind (self)
 
 num_args (self)
 
 arg (self, idx)
 
 children (self)
 
 from_string (self, s)
 
 serialize (self)
 
- Public Member Functions inherited from AstRef
 __init__ (self, ast, ctx=None)
 
 __del__ (self)
 
 __deepcopy__ (self, memo={})
 
 __str__ (self)
 
 __repr__ (self)
 
 __nonzero__ (self)
 
 __bool__ (self)
 
 sexpr (self)
 
 ctx_ref (self)
 
 eq (self, other)
 
 translate (self, target)
 
 __copy__ (self)
 
 hash (self)
 
- Public Member Functions inherited from Z3PPObject
 use_pp (self)
 

Data Fields

 ctx = _coerce_exprs(self, other)
 
- Data Fields inherited from ExprRef
 ctx
 
 ast
 
- Data Fields inherited from AstRef
 ast = ast
 
 ctx = _get_ctx(ctx)
 

Additional Inherited Members

- Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)
 

Detailed Description

Bit-vector expressions.

Definition at line 3540 of file z3py.py.

Member Function Documentation

◆ __add__()

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

3565 def __add__(self, other):
3566 """Create the Z3 expression `self + other`.
3567
3568 >>> x = BitVec('x', 32)
3569 >>> y = BitVec('y', 32)
3570 >>> x + y
3571 x + y
3572 >>> (x + y).sort()
3573 BitVec(32)
3574 """
3575 a, b = _coerce_exprs(self, other)
3576 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3577
Z3_ast Z3_API Z3_mk_bvadd(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement addition.

◆ __and__()

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

3657 def __and__(self, other):
3658 """Create the Z3 expression bitwise-and `self & other`.
3659
3660 >>> x = BitVec('x', 32)
3661 >>> y = BitVec('y', 32)
3662 >>> x & y
3663 x & y
3664 >>> (x & y).sort()
3665 BitVec(32)
3666 """
3667 a, b = _coerce_exprs(self, other)
3668 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3669
Z3_ast Z3_API Z3_mk_bvand(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise and.

◆ __div__()

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

3734 def __div__(self, other):
3735 """Create the Z3 expression (signed) division `self / other`.
3736
3737 Use the function UDiv() for unsigned division.
3738
3739 >>> x = BitVec('x', 32)
3740 >>> y = BitVec('y', 32)
3741 >>> x / y
3742 x/y
3743 >>> (x / y).sort()
3744 BitVec(32)
3745 >>> (x / y).sexpr()
3746 '(bvsdiv x y)'
3747 >>> UDiv(x, y).sexpr()
3748 '(bvudiv x y)'
3749 """
3750 a, b = _coerce_exprs(self, other)
3751 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3752
Z3_ast Z3_API Z3_mk_bvsdiv(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed division.

Referenced by ArithRef.__truediv__(), and BitVecRef.__truediv__().

◆ __ge__()

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

3864 def __ge__(self, other):
3865 """Create the Z3 expression (signed) `other >= self`.
3866
3867 Use the function UGE() for unsigned greater than or equal to.
3868
3869 >>> x, y = BitVecs('x y', 32)
3870 >>> x >= y
3871 x >= y
3872 >>> (x >= y).sexpr()
3873 '(bvsge x y)'
3874 >>> UGE(x, y).sexpr()
3875 '(bvuge x y)'
3876 """
3877 a, b = _coerce_exprs(self, other)
3878 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3879
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.

◆ __gt__()

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

3848 def __gt__(self, other):
3849 """Create the Z3 expression (signed) `other > self`.
3850
3851 Use the function UGT() for unsigned greater than.
3852
3853 >>> x, y = BitVecs('x y', 32)
3854 >>> x > y
3855 x > y
3856 >>> (x > y).sexpr()
3857 '(bvsgt x y)'
3858 >>> UGT(x, y).sexpr()
3859 '(bvugt x y)'
3860 """
3861 a, b = _coerce_exprs(self, other)
3862 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3863
Z3_ast Z3_API Z3_mk_bvsgt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed greater than.

◆ __invert__()

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

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

Definition at line 3723 of file z3py.py.

3723 def __invert__(self):
3724 """Create the Z3 expression bitwise-not `~self`.
3725
3726 >>> x = BitVec('x', 32)
3727 >>> ~x
3728 ~x
3729 >>> simplify(~(~x))
3730 x
3731 """
3732 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3733
Z3_ast Z3_API Z3_mk_bvnot(Z3_context c, Z3_ast t1)
Bitwise negation.

◆ __le__()

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

3816 def __le__(self, other):
3817 """Create the Z3 expression (signed) `other <= self`.
3818
3819 Use the function ULE() for unsigned less than or equal to.
3820
3821 >>> x, y = BitVecs('x y', 32)
3822 >>> x <= y
3823 x <= y
3824 >>> (x <= y).sexpr()
3825 '(bvsle x y)'
3826 >>> ULE(x, y).sexpr()
3827 '(bvule x y)'
3828 """
3829 a, b = _coerce_exprs(self, other)
3830 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3831
Z3_ast Z3_API Z3_mk_bvsle(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than or equal to.

◆ __lshift__()

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

3910 def __lshift__(self, other):
3911 """Create the Z3 expression left shift `self << other`
3912
3913 >>> x, y = BitVecs('x y', 32)
3914 >>> x << y
3915 x << y
3916 >>> (x << y).sexpr()
3917 '(bvshl x y)'
3918 >>> simplify(BitVecVal(2, 3) << 1)
3919 4
3920 """
3921 a, b = _coerce_exprs(self, other)
3922 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3923
Z3_ast Z3_API Z3_mk_bvshl(Z3_context c, Z3_ast t1, Z3_ast t2)
Shift left.

◆ __lt__()

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

3832 def __lt__(self, other):
3833 """Create the Z3 expression (signed) `other < self`.
3834
3835 Use the function ULT() for unsigned less than.
3836
3837 >>> x, y = BitVecs('x y', 32)
3838 >>> x < y
3839 x < y
3840 >>> (x < y).sexpr()
3841 '(bvslt x y)'
3842 >>> ULT(x, y).sexpr()
3843 '(bvult x y)'
3844 """
3845 a, b = _coerce_exprs(self, other)
3846 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3847
Z3_ast Z3_API Z3_mk_bvslt(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed less than.

◆ __mod__()

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

3777 def __mod__(self, other):
3778 """Create the Z3 expression (signed) mod `self % other`.
3779
3780 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3781
3782 >>> x = BitVec('x', 32)
3783 >>> y = BitVec('y', 32)
3784 >>> x % y
3785 x%y
3786 >>> (x % y).sort()
3787 BitVec(32)
3788 >>> (x % y).sexpr()
3789 '(bvsmod x y)'
3790 >>> URem(x, y).sexpr()
3791 '(bvurem x y)'
3792 >>> SRem(x, y).sexpr()
3793 '(bvsrem x y)'
3794 """
3795 a, b = _coerce_exprs(self, other)
3796 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3797
Z3_ast Z3_API Z3_mk_bvsmod(Z3_context c, Z3_ast t1, Z3_ast t2)
Two's complement signed remainder (sign follows divisor).

◆ __mul__()

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

3588 def __mul__(self, other):
3589 """Create the Z3 expression `self * other`.
3590
3591 >>> x = BitVec('x', 32)
3592 >>> y = BitVec('y', 32)
3593 >>> x * y
3594 x*y
3595 >>> (x * y).sort()
3596 BitVec(32)
3597 """
3598 a, b = _coerce_exprs(self, other)
3599 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3600
Z3_ast Z3_API Z3_mk_bvmul(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement multiplication.

◆ __neg__()

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

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

Definition at line 3712 of file z3py.py.

3712 def __neg__(self):
3713 """Return an expression representing `-self`.
3714
3715 >>> x = BitVec('x', 32)
3716 >>> -x
3717 -x
3718 >>> simplify(-(-x))
3719 x
3720 """
3721 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3722
Z3_ast Z3_API Z3_mk_bvneg(Z3_context c, Z3_ast t1)
Standard two's complement unary minus.

◆ __or__()

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

3634 def __or__(self, other):
3635 """Create the Z3 expression bitwise-or `self | other`.
3636
3637 >>> x = BitVec('x', 32)
3638 >>> y = BitVec('y', 32)
3639 >>> x | y
3640 x | y
3641 >>> (x | y).sort()
3642 BitVec(32)
3643 """
3644 a, b = _coerce_exprs(self, other)
3645 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3646
Z3_ast Z3_API Z3_mk_bvor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise or.

◆ __pos__()

__pos__ ( self)
Return `self`.

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

Definition at line 3703 of file z3py.py.

3703 def __pos__(self):
3704 """Return `self`.
3705
3706 >>> x = BitVec('x', 32)
3707 >>> +x
3708 x
3709 """
3710 return self
3711

◆ __radd__()

__radd__ ( self,
other )
Create the Z3 expression `other + self`.

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

Definition at line 3578 of file z3py.py.

3578 def __radd__(self, other):
3579 """Create the Z3 expression `other + self`.
3580
3581 >>> x = BitVec('x', 32)
3582 >>> 10 + x
3583 10 + x
3584 """
3585 a, b = _coerce_exprs(self, other)
3586 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3587

◆ __rand__()

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

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

Definition at line 3670 of file z3py.py.

3670 def __rand__(self, other):
3671 """Create the Z3 expression bitwise-or `other & self`.
3672
3673 >>> x = BitVec('x', 32)
3674 >>> 10 & x
3675 10 & x
3676 """
3677 a, b = _coerce_exprs(self, other)
3678 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3679

◆ __rdiv__()

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

3757 def __rdiv__(self, other):
3758 """Create the Z3 expression (signed) division `other / self`.
3759
3760 Use the function UDiv() for unsigned division.
3761
3762 >>> x = BitVec('x', 32)
3763 >>> 10 / x
3764 10/x
3765 >>> (10 / x).sexpr()
3766 '(bvsdiv #x0000000a x)'
3767 >>> UDiv(10, x).sexpr()
3768 '(bvudiv #x0000000a x)'
3769 """
3770 a, b = _coerce_exprs(self, other)
3771 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3772

Referenced by ArithRef.__rtruediv__(), and BitVecRef.__rtruediv__().

◆ __rlshift__()

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

3938 def __rlshift__(self, other):
3939 """Create the Z3 expression left shift `other << self`.
3940
3941 Use the function LShR() for the right logical shift
3942
3943 >>> x = BitVec('x', 32)
3944 >>> 10 << x
3945 10 << x
3946 >>> (10 << x).sexpr()
3947 '(bvshl #x0000000a x)'
3948 """
3949 a, b = _coerce_exprs(self, other)
3950 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3951
3952

◆ __rmod__()

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

3798 def __rmod__(self, other):
3799 """Create the Z3 expression (signed) mod `other % self`.
3800
3801 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3802
3803 >>> x = BitVec('x', 32)
3804 >>> 10 % x
3805 10%x
3806 >>> (10 % x).sexpr()
3807 '(bvsmod #x0000000a x)'
3808 >>> URem(10, x).sexpr()
3809 '(bvurem #x0000000a x)'
3810 >>> SRem(10, x).sexpr()
3811 '(bvsrem #x0000000a x)'
3812 """
3813 a, b = _coerce_exprs(self, other)
3814 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3815

◆ __rmul__()

__rmul__ ( self,
other )
Create the Z3 expression `other * self`.

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

Definition at line 3601 of file z3py.py.

3601 def __rmul__(self, other):
3602 """Create the Z3 expression `other * self`.
3603
3604 >>> x = BitVec('x', 32)
3605 >>> 10 * x
3606 10*x
3607 """
3608 a, b = _coerce_exprs(self, other)
3609 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3610

◆ __ror__()

__ror__ ( self,
other )
Create the Z3 expression bitwise-or `other | self`.

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

Definition at line 3647 of file z3py.py.

3647 def __ror__(self, other):
3648 """Create the Z3 expression bitwise-or `other | self`.
3649
3650 >>> x = BitVec('x', 32)
3651 >>> 10 | x
3652 10 | x
3653 """
3654 a, b = _coerce_exprs(self, other)
3655 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3656

◆ __rrshift__()

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

3924 def __rrshift__(self, other):
3925 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3926
3927 Use the function LShR() for the right logical shift
3928
3929 >>> x = BitVec('x', 32)
3930 >>> 10 >> x
3931 10 >> x
3932 >>> (10 >> x).sexpr()
3933 '(bvashr #x0000000a x)'
3934 """
3935 a, b = _coerce_exprs(self, other)
3936 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3937
Z3_ast Z3_API Z3_mk_bvashr(Z3_context c, Z3_ast t1, Z3_ast t2)
Arithmetic shift right.

◆ __rshift__()

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

3880 def __rshift__(self, other):
3881 """Create the Z3 expression (arithmetical) right shift `self >> other`
3882
3883 Use the function LShR() for the right logical shift
3884
3885 >>> x, y = BitVecs('x y', 32)
3886 >>> x >> y
3887 x >> y
3888 >>> (x >> y).sexpr()
3889 '(bvashr x y)'
3890 >>> LShR(x, y).sexpr()
3891 '(bvlshr x y)'
3892 >>> BitVecVal(4, 3)
3893 4
3894 >>> BitVecVal(4, 3).as_signed_long()
3895 -4
3896 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3897 -2
3898 >>> simplify(BitVecVal(4, 3) >> 1)
3899 6
3900 >>> simplify(LShR(BitVecVal(4, 3), 1))
3901 2
3902 >>> simplify(BitVecVal(2, 3) >> 1)
3903 1
3904 >>> simplify(LShR(BitVecVal(2, 3), 1))
3905 1
3906 """
3907 a, b = _coerce_exprs(self, other)
3908 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3909

◆ __rsub__()

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

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

Definition at line 3624 of file z3py.py.

3624 def __rsub__(self, other):
3625 """Create the Z3 expression `other - self`.
3626
3627 >>> x = BitVec('x', 32)
3628 >>> 10 - x
3629 10 - x
3630 """
3631 a, b = _coerce_exprs(self, other)
3632 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3633
Z3_ast Z3_API Z3_mk_bvsub(Z3_context c, Z3_ast t1, Z3_ast t2)
Standard two's complement subtraction.

◆ __rtruediv__()

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

Definition at line 3773 of file z3py.py.

3773 def __rtruediv__(self, other):
3774 """Create the Z3 expression (signed) division `other / self`."""
3775 return self.__rdiv__(other)
3776

◆ __rxor__()

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

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

Definition at line 3693 of file z3py.py.

3693 def __rxor__(self, other):
3694 """Create the Z3 expression bitwise-xor `other ^ self`.
3695
3696 >>> x = BitVec('x', 32)
3697 >>> 10 ^ x
3698 10 ^ x
3699 """
3700 a, b = _coerce_exprs(self, other)
3701 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3702
Z3_ast Z3_API Z3_mk_bvxor(Z3_context c, Z3_ast t1, Z3_ast t2)
Bitwise exclusive-or.

◆ __sub__()

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

3611 def __sub__(self, other):
3612 """Create the Z3 expression `self - other`.
3613
3614 >>> x = BitVec('x', 32)
3615 >>> y = BitVec('y', 32)
3616 >>> x - y
3617 x - y
3618 >>> (x - y).sort()
3619 BitVec(32)
3620 """
3621 a, b = _coerce_exprs(self, other)
3622 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3623

◆ __truediv__()

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

Definition at line 3753 of file z3py.py.

3753 def __truediv__(self, other):
3754 """Create the Z3 expression (signed) division `self / other`."""
3755 return self.__div__(other)
3756

◆ __xor__()

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

3680 def __xor__(self, other):
3681 """Create the Z3 expression bitwise-xor `self ^ other`.
3682
3683 >>> x = BitVec('x', 32)
3684 >>> y = BitVec('y', 32)
3685 >>> x ^ y
3686 x ^ y
3687 >>> (x ^ y).sort()
3688 BitVec(32)
3689 """
3690 a, b = _coerce_exprs(self, other)
3691 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3692

◆ size()

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

3554 def size(self):
3555 """Return the number of bits of the bit-vector expression `self`.
3556
3557 >>> x = BitVec('x', 32)
3558 >>> (x + 1).size()
3559 32
3560 >>> Concat(x, x).size()
3561 64
3562 """
3563 return self.sort().size()
3564

Referenced by Goal.__len__(), ParamDescrsRef.__len__(), BitVecNumRef.as_signed_long(), BitVecRef.size(), and BitVecSortRef.subsort().

◆ sort()

sort ( self)
Return the sort of the bit-vector expression `self`.

>>> x = BitVec('x', 32)
>>> x.sort()
BitVec(32)
>>> x.sort() == BitVecSort(32)
True

Reimplemented from ExprRef.

Definition at line 3543 of file z3py.py.

3543 def sort(self):
3544 """Return the sort of the bit-vector expression `self`.
3545
3546 >>> x = BitVec('x', 32)
3547 >>> x.sort()
3548 BitVec(32)
3549 >>> x.sort() == BitVecSort(32)
3550 True
3551 """
3552 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3553
Z3_sort Z3_API Z3_get_sort(Z3_context c, Z3_ast a)
Return the sort of an AST node.

Referenced by ArrayRef.domain(), ArrayRef.domain_n(), ArithRef.is_int(), ArithRef.is_real(), ArrayRef.range(), BitVecRef.size(), and ExprRef.sort_kind().

Field Documentation

◆ ctx

ctx = _coerce_exprs(self, other)

Definition at line 3552 of file z3py.py.

Referenced by ArithRef.__add__(), BitVecRef.__add__(), BitVecRef.__and__(), FuncDeclRef.__call__(), AstMap.__contains__(), AstRef.__copy__(), AstVector.__copy__(), FuncInterp.__copy__(), Goal.__copy__(), ModelRef.__copy__(), AstMap.__deepcopy__(), AstRef.__deepcopy__(), AstVector.__deepcopy__(), Datatype.__deepcopy__(), FuncEntry.__deepcopy__(), FuncInterp.__deepcopy__(), Goal.__deepcopy__(), ModelRef.__deepcopy__(), ParamDescrsRef.__deepcopy__(), ParamsRef.__deepcopy__(), Statistics.__deepcopy__(), AstMap.__del__(), AstRef.__del__(), AstVector.__del__(), Context.__del__(), FuncEntry.__del__(), FuncInterp.__del__(), Goal.__del__(), ModelRef.__del__(), ParamDescrsRef.__del__(), ParamsRef.__del__(), ScopedConstructor.__del__(), ScopedConstructorList.__del__(), Solver.__del__(), Statistics.__del__(), ArithRef.__div__(), BitVecRef.__div__(), ExprRef.__eq__(), ArithRef.__ge__(), BitVecRef.__ge__(), AstMap.__getitem__(), AstVector.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), ArithRef.__gt__(), BitVecRef.__gt__(), BitVecRef.__invert__(), ArithRef.__le__(), BitVecRef.__le__(), AstMap.__len__(), AstVector.__len__(), ModelRef.__len__(), Statistics.__len__(), BitVecRef.__lshift__(), ArithRef.__lt__(), BitVecRef.__lt__(), ArithRef.__mod__(), BitVecRef.__mod__(), ArithRef.__mul__(), BitVecRef.__mul__(), BoolRef.__mul__(), ExprRef.__ne__(), ArithRef.__neg__(), BitVecRef.__neg__(), BitVecRef.__or__(), ArithRef.__pow__(), ArithRef.__radd__(), BitVecRef.__radd__(), BitVecRef.__rand__(), ArithRef.__rdiv__(), BitVecRef.__rdiv__(), AstMap.__repr__(), ParamDescrsRef.__repr__(), ParamsRef.__repr__(), Statistics.__repr__(), BitVecRef.__rlshift__(), ArithRef.__rmod__(), BitVecRef.__rmod__(), ArithRef.__rmul__(), BitVecRef.__rmul__(), BitVecRef.__ror__(), ArithRef.__rpow__(), BitVecRef.__rrshift__(), BitVecRef.__rshift__(), ArithRef.__rsub__(), BitVecRef.__rsub__(), BitVecRef.__rxor__(), AstMap.__setitem__(), AstVector.__setitem__(), ArithRef.__sub__(), BitVecRef.__sub__(), BitVecRef.__xor__(), DatatypeSortRef.accessor(), ExprRef.arg(), FuncEntry.arg_value(), FuncInterp.arity(), Goal.as_expr(), Solver.assert_and_track(), Goal.assert_exprs(), Solver.assert_exprs(), QuantifierRef.body(), Solver.check(), Goal.convert_model(), AstRef.ctx_ref(), ExprRef.decl(), ModelRef.decls(), ArrayRef.default(), RatNumRef.denominator(), Goal.depth(), Goal.dimacs(), FuncDeclRef.domain(), ArraySortRef.domain_n(), FuncInterp.else_value(), FuncInterp.entry(), AstMap.erase(), ModelRef.eval(), Goal.get(), ParamDescrsRef.get_documentation(), ModelRef.get_interp(), Statistics.get_key_value(), ParamDescrsRef.get_kind(), ParamDescrsRef.get_name(), ModelRef.get_sort(), ModelRef.get_universe(), Goal.inconsistent(), AstMap.keys(), Statistics.keys(), Solver.model(), SortRef.name(), QuantifierRef.no_pattern(), FuncEntry.num_args(), FuncInterp.num_entries(), Solver.num_scopes(), ModelRef.num_sorts(), FuncDeclRef.params(), QuantifierRef.pattern(), AlgebraicNumRef.poly(), Solver.pop(), Goal.prec(), ModelRef.project(), ModelRef.project_with_witness(), AstVector.push(), Solver.push(), QuantifierRef.qid(), ArraySortRef.range(), FuncDeclRef.range(), DatatypeSortRef.recognizer(), Context.ref(), AstMap.reset(), Solver.reset(), AstVector.resize(), ParamsRef.set(), Solver.set(), AstVector.sexpr(), Goal.sexpr(), ModelRef.sexpr(), Goal.size(), ParamDescrsRef.size(), QuantifierRef.skolem_id(), AstRef.translate(), AstVector.translate(), Goal.translate(), ModelRef.translate(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().