Z3
 
Loading...
Searching...
No Matches
Public Member Functions | Data Fields
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)
 
 py_value (self)
 
- Public Member Functions inherited from Z3PPObject
 use_pp (self)
 

Data Fields

 ctx
 
- Data Fields inherited from ExprRef
 ctx
 
 ast
 
- Data Fields inherited from AstRef
 ast
 
 ctx
 

Additional Inherited Members

- Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)
 

Detailed Description

Bit-vector expressions.

Definition at line 3593 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 3618 of file z3py.py.

3618 def __add__(self, other):
3619 """Create the Z3 expression `self + other`.
3620
3621 >>> x = BitVec('x', 32)
3622 >>> y = BitVec('y', 32)
3623 >>> x + y
3624 x + y
3625 >>> (x + y).sort()
3626 BitVec(32)
3627 """
3628 a, b = _coerce_exprs(self, other)
3629 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3630
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 3710 of file z3py.py.

3710 def __and__(self, other):
3711 """Create the Z3 expression bitwise-and `self & other`.
3712
3713 >>> x = BitVec('x', 32)
3714 >>> y = BitVec('y', 32)
3715 >>> x & y
3716 x & y
3717 >>> (x & y).sort()
3718 BitVec(32)
3719 """
3720 a, b = _coerce_exprs(self, other)
3721 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3722
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 3787 of file z3py.py.

3787 def __div__(self, other):
3788 """Create the Z3 expression (signed) division `self / other`.
3789
3790 Use the function UDiv() for unsigned division.
3791
3792 >>> x = BitVec('x', 32)
3793 >>> y = BitVec('y', 32)
3794 >>> x / y
3795 x/y
3796 >>> (x / y).sort()
3797 BitVec(32)
3798 >>> (x / y).sexpr()
3799 '(bvsdiv x y)'
3800 >>> UDiv(x, y).sexpr()
3801 '(bvudiv x y)'
3802 """
3803 a, b = _coerce_exprs(self, other)
3804 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3805
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 3917 of file z3py.py.

3917 def __ge__(self, other):
3918 """Create the Z3 expression (signed) `other >= self`.
3919
3920 Use the function UGE() for unsigned greater than or equal to.
3921
3922 >>> x, y = BitVecs('x y', 32)
3923 >>> x >= y
3924 x >= y
3925 >>> (x >= y).sexpr()
3926 '(bvsge x y)'
3927 >>> UGE(x, y).sexpr()
3928 '(bvuge x y)'
3929 """
3930 a, b = _coerce_exprs(self, other)
3931 return BoolRef(Z3_mk_bvsge(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3932
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 3901 of file z3py.py.

3901 def __gt__(self, other):
3902 """Create the Z3 expression (signed) `other > self`.
3903
3904 Use the function UGT() for unsigned greater than.
3905
3906 >>> x, y = BitVecs('x y', 32)
3907 >>> x > y
3908 x > y
3909 >>> (x > y).sexpr()
3910 '(bvsgt x y)'
3911 >>> UGT(x, y).sexpr()
3912 '(bvugt x y)'
3913 """
3914 a, b = _coerce_exprs(self, other)
3915 return BoolRef(Z3_mk_bvsgt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3916
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 3776 of file z3py.py.

3776 def __invert__(self):
3777 """Create the Z3 expression bitwise-not `~self`.
3778
3779 >>> x = BitVec('x', 32)
3780 >>> ~x
3781 ~x
3782 >>> simplify(~(~x))
3783 x
3784 """
3785 return BitVecRef(Z3_mk_bvnot(self.ctx_ref(), self.as_ast()), self.ctx)
3786
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 3869 of file z3py.py.

3869 def __le__(self, other):
3870 """Create the Z3 expression (signed) `other <= self`.
3871
3872 Use the function ULE() for unsigned less than or equal to.
3873
3874 >>> x, y = BitVecs('x y', 32)
3875 >>> x <= y
3876 x <= y
3877 >>> (x <= y).sexpr()
3878 '(bvsle x y)'
3879 >>> ULE(x, y).sexpr()
3880 '(bvule x y)'
3881 """
3882 a, b = _coerce_exprs(self, other)
3883 return BoolRef(Z3_mk_bvsle(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3884
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 3963 of file z3py.py.

3963 def __lshift__(self, other):
3964 """Create the Z3 expression left shift `self << other`
3965
3966 >>> x, y = BitVecs('x y', 32)
3967 >>> x << y
3968 x << y
3969 >>> (x << y).sexpr()
3970 '(bvshl x y)'
3971 >>> simplify(BitVecVal(2, 3) << 1)
3972 4
3973 """
3974 a, b = _coerce_exprs(self, other)
3975 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3976
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 3885 of file z3py.py.

3885 def __lt__(self, other):
3886 """Create the Z3 expression (signed) `other < self`.
3887
3888 Use the function ULT() for unsigned less than.
3889
3890 >>> x, y = BitVecs('x y', 32)
3891 >>> x < y
3892 x < y
3893 >>> (x < y).sexpr()
3894 '(bvslt x y)'
3895 >>> ULT(x, y).sexpr()
3896 '(bvult x y)'
3897 """
3898 a, b = _coerce_exprs(self, other)
3899 return BoolRef(Z3_mk_bvslt(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3900
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 3830 of file z3py.py.

3830 def __mod__(self, other):
3831 """Create the Z3 expression (signed) mod `self % other`.
3832
3833 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3834
3835 >>> x = BitVec('x', 32)
3836 >>> y = BitVec('y', 32)
3837 >>> x % y
3838 x%y
3839 >>> (x % y).sort()
3840 BitVec(32)
3841 >>> (x % y).sexpr()
3842 '(bvsmod x y)'
3843 >>> URem(x, y).sexpr()
3844 '(bvurem x y)'
3845 >>> SRem(x, y).sexpr()
3846 '(bvsrem x y)'
3847 """
3848 a, b = _coerce_exprs(self, other)
3849 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3850
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 3641 of file z3py.py.

3641 def __mul__(self, other):
3642 """Create the Z3 expression `self * other`.
3643
3644 >>> x = BitVec('x', 32)
3645 >>> y = BitVec('y', 32)
3646 >>> x * y
3647 x*y
3648 >>> (x * y).sort()
3649 BitVec(32)
3650 """
3651 a, b = _coerce_exprs(self, other)
3652 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3653
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 3765 of file z3py.py.

3765 def __neg__(self):
3766 """Return an expression representing `-self`.
3767
3768 >>> x = BitVec('x', 32)
3769 >>> -x
3770 -x
3771 >>> simplify(-(-x))
3772 x
3773 """
3774 return BitVecRef(Z3_mk_bvneg(self.ctx_ref(), self.as_ast()), self.ctx)
3775
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 3687 of file z3py.py.

3687 def __or__(self, other):
3688 """Create the Z3 expression bitwise-or `self | other`.
3689
3690 >>> x = BitVec('x', 32)
3691 >>> y = BitVec('y', 32)
3692 >>> x | y
3693 x | y
3694 >>> (x | y).sort()
3695 BitVec(32)
3696 """
3697 a, b = _coerce_exprs(self, other)
3698 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3699
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 3756 of file z3py.py.

3756 def __pos__(self):
3757 """Return `self`.
3758
3759 >>> x = BitVec('x', 32)
3760 >>> +x
3761 x
3762 """
3763 return self
3764

◆ __radd__()

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

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

Definition at line 3631 of file z3py.py.

3631 def __radd__(self, other):
3632 """Create the Z3 expression `other + self`.
3633
3634 >>> x = BitVec('x', 32)
3635 >>> 10 + x
3636 10 + x
3637 """
3638 a, b = _coerce_exprs(self, other)
3639 return BitVecRef(Z3_mk_bvadd(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3640

◆ __rand__()

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

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

Definition at line 3723 of file z3py.py.

3723 def __rand__(self, other):
3724 """Create the Z3 expression bitwise-or `other & self`.
3725
3726 >>> x = BitVec('x', 32)
3727 >>> 10 & x
3728 10 & x
3729 """
3730 a, b = _coerce_exprs(self, other)
3731 return BitVecRef(Z3_mk_bvand(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3732

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

3810 def __rdiv__(self, other):
3811 """Create the Z3 expression (signed) division `other / self`.
3812
3813 Use the function UDiv() for unsigned division.
3814
3815 >>> x = BitVec('x', 32)
3816 >>> 10 / x
3817 10/x
3818 >>> (10 / x).sexpr()
3819 '(bvsdiv #x0000000a x)'
3820 >>> UDiv(10, x).sexpr()
3821 '(bvudiv #x0000000a x)'
3822 """
3823 a, b = _coerce_exprs(self, other)
3824 return BitVecRef(Z3_mk_bvsdiv(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3825

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

3991 def __rlshift__(self, other):
3992 """Create the Z3 expression left shift `other << self`.
3993
3994 Use the function LShR() for the right logical shift
3995
3996 >>> x = BitVec('x', 32)
3997 >>> 10 << x
3998 10 << x
3999 >>> (10 << x).sexpr()
4000 '(bvshl #x0000000a x)'
4001 """
4002 a, b = _coerce_exprs(self, other)
4003 return BitVecRef(Z3_mk_bvshl(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
4004
4005

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

3851 def __rmod__(self, other):
3852 """Create the Z3 expression (signed) mod `other % self`.
3853
3854 Use the function URem() for unsigned remainder, and SRem() for signed remainder.
3855
3856 >>> x = BitVec('x', 32)
3857 >>> 10 % x
3858 10%x
3859 >>> (10 % x).sexpr()
3860 '(bvsmod #x0000000a x)'
3861 >>> URem(10, x).sexpr()
3862 '(bvurem #x0000000a x)'
3863 >>> SRem(10, x).sexpr()
3864 '(bvsrem #x0000000a x)'
3865 """
3866 a, b = _coerce_exprs(self, other)
3867 return BitVecRef(Z3_mk_bvsmod(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3868

◆ __rmul__()

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

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

Definition at line 3654 of file z3py.py.

3654 def __rmul__(self, other):
3655 """Create the Z3 expression `other * self`.
3656
3657 >>> x = BitVec('x', 32)
3658 >>> 10 * x
3659 10*x
3660 """
3661 a, b = _coerce_exprs(self, other)
3662 return BitVecRef(Z3_mk_bvmul(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3663

◆ __ror__()

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

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

Definition at line 3700 of file z3py.py.

3700 def __ror__(self, other):
3701 """Create the Z3 expression bitwise-or `other | self`.
3702
3703 >>> x = BitVec('x', 32)
3704 >>> 10 | x
3705 10 | x
3706 """
3707 a, b = _coerce_exprs(self, other)
3708 return BitVecRef(Z3_mk_bvor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3709

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

3977 def __rrshift__(self, other):
3978 """Create the Z3 expression (arithmetical) right shift `other` >> `self`.
3979
3980 Use the function LShR() for the right logical shift
3981
3982 >>> x = BitVec('x', 32)
3983 >>> 10 >> x
3984 10 >> x
3985 >>> (10 >> x).sexpr()
3986 '(bvashr #x0000000a x)'
3987 """
3988 a, b = _coerce_exprs(self, other)
3989 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3990
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 3933 of file z3py.py.

3933 def __rshift__(self, other):
3934 """Create the Z3 expression (arithmetical) right shift `self >> other`
3935
3936 Use the function LShR() for the right logical shift
3937
3938 >>> x, y = BitVecs('x y', 32)
3939 >>> x >> y
3940 x >> y
3941 >>> (x >> y).sexpr()
3942 '(bvashr x y)'
3943 >>> LShR(x, y).sexpr()
3944 '(bvlshr x y)'
3945 >>> BitVecVal(4, 3)
3946 4
3947 >>> BitVecVal(4, 3).as_signed_long()
3948 -4
3949 >>> simplify(BitVecVal(4, 3) >> 1).as_signed_long()
3950 -2
3951 >>> simplify(BitVecVal(4, 3) >> 1)
3952 6
3953 >>> simplify(LShR(BitVecVal(4, 3), 1))
3954 2
3955 >>> simplify(BitVecVal(2, 3) >> 1)
3956 1
3957 >>> simplify(LShR(BitVecVal(2, 3), 1))
3958 1
3959 """
3960 a, b = _coerce_exprs(self, other)
3961 return BitVecRef(Z3_mk_bvashr(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3962

◆ __rsub__()

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

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

Definition at line 3677 of file z3py.py.

3677 def __rsub__(self, other):
3678 """Create the Z3 expression `other - self`.
3679
3680 >>> x = BitVec('x', 32)
3681 >>> 10 - x
3682 10 - x
3683 """
3684 a, b = _coerce_exprs(self, other)
3685 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3686
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 3826 of file z3py.py.

3826 def __rtruediv__(self, other):
3827 """Create the Z3 expression (signed) division `other / self`."""
3828 return self.__rdiv__(other)
3829

◆ __rxor__()

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

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

Definition at line 3746 of file z3py.py.

3746 def __rxor__(self, other):
3747 """Create the Z3 expression bitwise-xor `other ^ self`.
3748
3749 >>> x = BitVec('x', 32)
3750 >>> 10 ^ x
3751 10 ^ x
3752 """
3753 a, b = _coerce_exprs(self, other)
3754 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), b.as_ast(), a.as_ast()), self.ctx)
3755
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 3664 of file z3py.py.

3664 def __sub__(self, other):
3665 """Create the Z3 expression `self - other`.
3666
3667 >>> x = BitVec('x', 32)
3668 >>> y = BitVec('y', 32)
3669 >>> x - y
3670 x - y
3671 >>> (x - y).sort()
3672 BitVec(32)
3673 """
3674 a, b = _coerce_exprs(self, other)
3675 return BitVecRef(Z3_mk_bvsub(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3676

◆ __truediv__()

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

Definition at line 3806 of file z3py.py.

3806 def __truediv__(self, other):
3807 """Create the Z3 expression (signed) division `self / other`."""
3808 return self.__div__(other)
3809

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

3733 def __xor__(self, other):
3734 """Create the Z3 expression bitwise-xor `self ^ other`.
3735
3736 >>> x = BitVec('x', 32)
3737 >>> y = BitVec('y', 32)
3738 >>> x ^ y
3739 x ^ y
3740 >>> (x ^ y).sort()
3741 BitVec(32)
3742 """
3743 a, b = _coerce_exprs(self, other)
3744 return BitVecRef(Z3_mk_bvxor(self.ctx_ref(), a.as_ast(), b.as_ast()), self.ctx)
3745

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

3607 def size(self):
3608 """Return the number of bits of the bit-vector expression `self`.
3609
3610 >>> x = BitVec('x', 32)
3611 >>> (x + 1).size()
3612 32
3613 >>> Concat(x, x).size()
3614 64
3615 """
3616 return self.sort().size()
3617

Referenced by ParamDescrsRef.__len__(), Goal.__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 3596 of file z3py.py.

3596 def sort(self):
3597 """Return the sort of the bit-vector expression `self`.
3598
3599 >>> x = BitVec('x', 32)
3600 >>> x.sort()
3601 BitVec(32)
3602 >>> x.sort() == BitVecSort(32)
3603 True
3604 """
3605 return BitVecSortRef(Z3_get_sort(self.ctx_ref(), self.as_ast()), self.ctx)
3606
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

Definition at line 3605 of file z3py.py.

Referenced by ArithRef.__add__(), BitVecRef.__add__(), BitVecRef.__and__(), FuncDeclRef.__call__(), AstMap.__contains__(), AstRef.__copy__(), Goal.__copy__(), AstVector.__copy__(), FuncInterp.__copy__(), ModelRef.__copy__(), AstRef.__deepcopy__(), Datatype.__deepcopy__(), ParamsRef.__deepcopy__(), ParamDescrsRef.__deepcopy__(), Goal.__deepcopy__(), AstVector.__deepcopy__(), AstMap.__deepcopy__(), FuncEntry.__deepcopy__(), FuncInterp.__deepcopy__(), ModelRef.__deepcopy__(), Statistics.__deepcopy__(), Context.__del__(), AstRef.__del__(), ScopedConstructor.__del__(), ScopedConstructorList.__del__(), ParamsRef.__del__(), ParamDescrsRef.__del__(), Goal.__del__(), AstVector.__del__(), AstMap.__del__(), FuncEntry.__del__(), FuncInterp.__del__(), ModelRef.__del__(), Statistics.__del__(), Solver.__del__(), ArithRef.__div__(), BitVecRef.__div__(), ExprRef.__eq__(), ArithRef.__ge__(), BitVecRef.__ge__(), AstVector.__getitem__(), ModelRef.__getitem__(), Statistics.__getitem__(), AstMap.__getitem__(), ArithRef.__gt__(), BitVecRef.__gt__(), BitVecRef.__invert__(), ArithRef.__le__(), BitVecRef.__le__(), AstVector.__len__(), AstMap.__len__(), ModelRef.__len__(), Statistics.__len__(), BitVecRef.__lshift__(), ArithRef.__lt__(), BitVecRef.__lt__(), ArithRef.__mod__(), BitVecRef.__mod__(), BoolRef.__mul__(), ArithRef.__mul__(), BitVecRef.__mul__(), ExprRef.__ne__(), ArithRef.__neg__(), BitVecRef.__neg__(), BitVecRef.__or__(), ArithRef.__pow__(), ArithRef.__radd__(), BitVecRef.__radd__(), BitVecRef.__rand__(), ArithRef.__rdiv__(), BitVecRef.__rdiv__(), ParamsRef.__repr__(), ParamDescrsRef.__repr__(), AstMap.__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__(), AstVector.__setitem__(), AstMap.__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(), Solver.push(), AstVector.push(), QuantifierRef.qid(), FuncDeclRef.range(), ArraySortRef.range(), DatatypeSortRef.recognizer(), Context.ref(), AstMap.reset(), Solver.reset(), AstVector.resize(), Solver.set(), ParamsRef.set(), Goal.sexpr(), AstVector.sexpr(), ModelRef.sexpr(), ParamDescrsRef.size(), Goal.size(), QuantifierRef.skolem_id(), AstVector.translate(), AstRef.translate(), Goal.translate(), ModelRef.translate(), ParamsRef.validate(), FuncEntry.value(), QuantifierRef.var_name(), and QuantifierRef.var_sort().