This PR adds new is* functions from the cpp API to the python API.
In particular, it adds getFloatingPointValue() function from the cpp API.
A test (translated from term_black.cpp) is added.
getFloatingPointValue() returns a tuple, and so this requires importing an instance of tuples into cython.
const wchar_t* data() except +
size_t size() except +
+cdef extern from "<tuple>" namespace "std" nogil:
+ cdef cppclass tuple[T, U, S]:
+ pass
+
+cdef extern from "<tuple>" namespace "std":
+ uint32_t get0 "std::get<0>"(tuple[uint32_t,uint32_t,Term]) except +
+ uint32_t get1 "std::get<1>"(tuple[uint32_t,uint32_t,Term]) except +
+ Term get2 "std::get<2>"(tuple[uint32_t,uint32_t,Term]) except +
+
cdef extern from "api/cpp/cvc5.h" namespace "cvc5":
cdef cppclass Options:
pass
string getRealValue() except +
bint isBitVectorValue() except +
string getBitVectorValue(uint32_t base) except +
+ bint isFloatingPointPosZero() except +
+ bint isFloatingPointNegZero() except +
+ bint isFloatingPointPosInf() except +
+ bint isFloatingPointNegInf() except +
+ bint isFloatingPointNaN() except +
+ bint isFloatingPointValue() except +
+
+ tuple[uint32_t, uint32_t, Term] getFloatingPointValue() except +
vector[Term] getSequenceValue() except +
cdef cppclass TermHashFunction:
from cvc5 cimport Term as c_Term
from cvc5 cimport hash as c_hash
from cvc5 cimport wstring as c_wstring
-
+from cvc5 cimport tuple as c_tuple
+from cvc5 cimport get0, get1, get2
from cvc5kinds cimport Kind as c_Kind
cdef extern from "Python.h":
def isIntegerValue(self):
return self.cterm.isIntegerValue()
+
+ def isFloatingPointPosZero(self):
+ return self.cterm.isFloatingPointPosZero()
+
+ def isFloatingPointNegZero(self):
+ return self.cterm.isFloatingPointNegZero()
+
+ def isFloatingPointPosInf(self):
+ return self.cterm.isFloatingPointPosInf()
+
+ def isFloatingPointNegInf(self):
+ return self.cterm.isFloatingPointNegInf()
+
+ def isFloatingPointNaN(self):
+ return self.cterm.isFloatingPointNaN()
+
+ def isFloatingPointValue(self):
+ return self.cterm.isFloatingPointValue()
+
+ def getFloatingPointValue(self):
+ cdef c_tuple[uint32_t, uint32_t, c_Term] t = self.cterm.getFloatingPointValue()
+ cdef Term term = Term(self.solver)
+ term.cterm = get2(t)
+ return (get0(t), get1(t), term)
def getIntegerValue(self):
return int(self.cterm.getIntegerValue().decode())
tnull[0]
+def test_get_floating_point(solver):
+ bvval = solver.mkBitVector("0000110000000011")
+ fp = solver.mkFloatingPoint(5, 11, bvval)
+
+ assert fp.isFloatingPointValue()
+ assert not fp.isFloatingPointPosZero()
+ assert not fp.isFloatingPointNegZero()
+ assert not fp.isFloatingPointPosInf()
+ assert not fp.isFloatingPointNegInf()
+ assert not fp.isFloatingPointNaN()
+ assert (5, 11, bvval) == fp.getFloatingPointValue()
+
+ assert solver.mkPosZero(5, 11).isFloatingPointPosZero()
+ assert solver.mkNegZero(5, 11).isFloatingPointNegZero()
+ assert solver.mkPosInf(5, 11).isFloatingPointPosInf()
+ assert solver.mkNegInf(5, 11).isFloatingPointNegInf()
+ assert solver.mkNaN(5, 11).isFloatingPointNaN()
+
+
def test_is_integer(solver):
int1 = solver.mkInteger("-18446744073709551616")
int2 = solver.mkInteger("-18446744073709551615")
assert 0 == real1.getRealValue()
assert 0 == real2.getRealValue()
assert -17 == real3.getRealValue()
- assert -3/5 == real4.getRealValue()
- assert 127/10 == real5.getRealValue()
- assert 1/4294967297 == real6.getRealValue()
+ assert -3 / 5 == real4.getRealValue()
+ assert 127 / 10 == real5.getRealValue()
+ assert 1 / 4294967297 == real6.getRealValue()
assert 4294967297 == real7.getRealValue()
- assert 1/18446744073709551617 == real8.getRealValue()
+ assert 1 / 18446744073709551617 == real8.getRealValue()
assert float(18446744073709551617) == real9.getRealValue()