MCPcopy Create free account
hub / github.com/BasisResearch/lean.py / BitVecRef

Class BitVecRef

lean_py/z3/core.py:621–748  ·  view source on GitHub ↗

Bit-vector expression, maps to Lean's ``BitVec n``.

Source from the content-addressed store, hash-verified

619
620
621class BitVecRef(ExprRef):
622 """Bit-vector expression, maps to Lean's ``BitVec n``."""
623
624 __slots__ = ()
625
626 def __init__(
627 self,
628 ast: ASTNode,
629 sort: BitVecSortRef,
630 vars: frozenset[tuple[str, ASTSort]] = frozenset(),
631 ) -> None:
632 super().__init__(ast, sort, vars)
633
634 def _binop(self, op: str, other: BitVecRef | int) -> BitVecRef:
635 other = _coerce_bv(other, self._sort)
636 return BitVecRef(
637 BinOpNode(op, self._ast, other._ast),
638 self._sort, # type: ignore[arg-type]
639 _merge(self._vars, other._vars),
640 )
641
642 # Arithmetic
643 def __add__(self, other: BitVecRef | int) -> BitVecRef:
644 return self._binop(BinOp.ADD, other)
645
646 def __radd__(self, other: int) -> BitVecRef:
647 return _coerce_bv(other, self._sort)._binop(BinOp.ADD, self)
648
649 def __sub__(self, other: BitVecRef | int) -> BitVecRef:
650 return self._binop(BinOp.SUB, other)
651
652 def __rsub__(self, other: int) -> BitVecRef:
653 return _coerce_bv(other, self._sort)._binop(BinOp.SUB, self)
654
655 def __mul__(self, other: BitVecRef | int) -> BitVecRef:
656 return self._binop(BinOp.MUL, other)
657
658 def __rmul__(self, other: int) -> BitVecRef:
659 return _coerce_bv(other, self._sort)._binop(BinOp.MUL, self)
660
661 def __neg__(self) -> BitVecRef:
662 return BitVecRef(
663 UnOpNode(UnOp.NEG, self._ast),
664 self._sort, # type: ignore[arg-type]
665 self._vars,
666 )
667
668 # Bitwise
669 def __and__(self, other: BitVecRef | int) -> BitVecRef:
670 return self._binop(BinOp.BAND, other)
671
672 def __rand__(self, other: int) -> BitVecRef:
673 return _coerce_bv(other, self._sort)._binop(BinOp.BAND, self)
674
675 def __or__(self, other: BitVecRef | int) -> BitVecRef:
676 return self._binop(BinOp.BOR, other)
677
678 def __ror__(self, other: int) -> BitVecRef:

Callers 15

_binopMethod · 0.85
__neg__Method · 0.85
__invert__Method · 0.85
_wrap_exprFunction · 0.85
BitVecFunction · 0.85
ConstFunction · 0.85
IfFunction · 0.85
_coerce_bvFunction · 0.85
_coerce_valFunction · 0.85
ExtractFunction · 0.85
ConcatFunction · 0.85
ZeroExtFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected