Z3
 
Loading...
Searching...
No Matches
BitVecSortRef Class Reference

Bit-Vectors. More...

+ Inheritance diagram for BitVecSortRef:

Public Member Functions

 size (self)
 
 subsort (self, other)
 
 cast (self, val)
 
- Public Member Functions inherited from SortRef
 as_ast (self)
 
 get_id (self)
 
 kind (self)
 
 name (self)
 
 __eq__ (self, other)
 
 __ne__ (self, other)
 
 __gt__ (self, other)
 
 __hash__ (self)
 
- Public Member Functions inherited from AstRef
 __init__ (self, ast, ctx=None)
 
 __del__ (self)
 
 __deepcopy__ (self, memo={})
 
 __str__ (self)
 
 __repr__ (self)
 
 __eq__ (self, other)
 
 __hash__ (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)
 

Additional Inherited Members

- Data Fields inherited from AstRef
 ast = ast
 
 ctx = _get_ctx(ctx)
 
- Protected Member Functions inherited from Z3PPObject
 _repr_html_ (self)
 

Detailed Description

Bit-Vectors.

Bit-vector sort.

Definition at line 3592 of file z3py.py.

Member Function Documentation

◆ cast()

cast ( self,
val )
Try to cast `val` as a Bit-Vector.

>>> b = BitVecSort(32)
>>> b.cast(10)
10
>>> b.cast(10).sexpr()
'#x0000000a'

Reimplemented from SortRef.

Definition at line 3607 of file z3py.py.

3607 def cast(self, val):
3608 """Try to cast `val` as a Bit-Vector.
3609
3610 >>> b = BitVecSort(32)
3611 >>> b.cast(10)
3612 10
3613 >>> b.cast(10).sexpr()
3614 '#x0000000a'
3615 """
3616 if is_expr(val):
3617 if z3_debug():
3618 _z3_assert(self.ctx == val.ctx, "Context mismatch")
3619 # Idea: use sign_extend if sort of val is a bitvector of smaller size
3620 return val
3621 else:
3622 return BitVecVal(val, self)
3623
3624

◆ size()

size ( self)
Return the size (number of bits) of the bit-vector sort `self`.

>>> b = BitVecSort(32)
>>> b.size()
32

Definition at line 3595 of file z3py.py.

3595 def size(self):
3596 """Return the size (number of bits) of the bit-vector sort `self`.
3597
3598 >>> b = BitVecSort(32)
3599 >>> b.size()
3600 32
3601 """
3602 return int(Z3_get_bv_sort_size(self.ctx_ref(), self.ast))
3603
unsigned Z3_API Z3_get_bv_sort_size(Z3_context c, Z3_sort t)
Return the size of the given bit-vector sort.

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

◆ subsort()

subsort ( self,
other )
Return `True` if `self` is a subsort of `other`.

>>> IntSort().subsort(RealSort())
True

Reimplemented from SortRef.

Definition at line 3604 of file z3py.py.

3604 def subsort(self, other):
3605 return is_bv_sort(other) and self.size() < other.size()
3606