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

Function RealVal

lean_py/z3/core.py:1143–1153  ·  view source on GitHub ↗
(n: int | float | str)

Source from the content-addressed store, hash-verified

1141
1142
1143def RealVal(n: int | float | str) -> ArithRef:
1144 if isinstance(n, float):
1145 num, den = n.as_integer_ratio()
1146 return RatNumRef(num, den)
1147 if isinstance(n, str):
1148 if "/" in n:
1149 num_s, den_s = n.split("/", 1)
1150 return RatNumRef(int(num_s.strip()), int(den_s.strip()))
1151 coerced: int | float = float(n) if "." in n or "e" in n.lower() else int(n)
1152 return RealVal(coerced)
1153 return ArithRef(ToRealNode(IntLit(n)), RealSort())
1154
1155
1156def BoolVal(b: bool) -> BoolRef:

Callers 9

test_realval_intMethod · 0.90
test_is_int_valueMethod · 0.90
test_realval_integerMethod · 0.90
test_int_to_realMethod · 0.90
__init__Method · 0.85

Calls 6

ToRealNodeClass · 0.90
IntLitClass · 0.90
RatNumRefClass · 0.85
ArithRefClass · 0.85
RealSortFunction · 0.85
lowerMethod · 0.80

Tested by 8

test_realval_intMethod · 0.72
test_is_int_valueMethod · 0.72
test_realval_integerMethod · 0.72
test_int_to_realMethod · 0.72