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

Function BV2Int

lean_py/z3/core.py:1601–1612  ·  view source on GitHub ↗

Convert a bit-vector to an integer. If is_signed is False (default, matching z3), uses unsigned (toNat). If is_signed is True, uses signed (toInt).

(x: BitVecRef, is_signed: bool = False)

Source from the content-addressed store, hash-verified

1599
1600
1601def BV2Int(x: BitVecRef, is_signed: bool = False) -> ArithRef:
1602 """Convert a bit-vector to an integer.
1603
1604 If is_signed is False (default, matching z3), uses unsigned (toNat).
1605 If is_signed is True, uses signed (toInt).
1606 """
1607 op = UnOp.BV2INT if is_signed else UnOp.BV2NAT
1608 return ArithRef(
1609 UnOpNode(op, x._ast),
1610 IntSort(),
1611 x._vars,
1612 )
1613
1614
1615def Int2BV(x: ArithRef, n: int) -> BitVecRef:

Callers 10

_applyMethod · 0.90
test_bv2intMethod · 0.90
test_bv2int_signedMethod · 0.90
test_bv2intMethod · 0.90
test_bv_to_int_groundMethod · 0.90
test_bv2int_unsignedMethod · 0.90
test_bv_to_intMethod · 0.90
test_bv_to_int_addMethod · 0.90

Calls 3

UnOpNodeClass · 0.90
ArithRefClass · 0.85
IntSortFunction · 0.85

Tested by 9

test_bv2intMethod · 0.72
test_bv2int_signedMethod · 0.72
test_bv2intMethod · 0.72
test_bv_to_int_groundMethod · 0.72
test_bv2int_unsignedMethod · 0.72
test_bv_to_intMethod · 0.72
test_bv_to_int_addMethod · 0.72