summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoryoni206 <yoni206@users.noreply.github.com>2021-06-01 02:40:54 -0700
committerGitHub <noreply@github.com>2021-06-01 11:40:54 +0200
commite7dccb880f08e14004501c827cd1c199a936cb64 (patch)
treedb4f6494eb458e254a9db3e23d17769a7b34aa0d /src
parentd80303ab28c0e14e41feaf16123f9fe5e50be0ec (diff)
FP value support in python API (#6644)
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.
Diffstat (limited to 'src')
-rw-r--r--src/api/python/cvc5.pxd17
-rw-r--r--src/api/python/cvc5.pxi27
2 files changed, 43 insertions, 1 deletions
diff --git a/src/api/python/cvc5.pxd b/src/api/python/cvc5.pxd
index ef65c9070..87a646666 100644
--- a/src/api/python/cvc5.pxd
+++ b/src/api/python/cvc5.pxd
@@ -27,6 +27,15 @@ cdef extern from "<string>" namespace "std":
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
@@ -387,6 +396,14 @@ cdef extern from "api/cpp/cvc5.h" namespace "cvc5::api":
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:
diff --git a/src/api/python/cvc5.pxi b/src/api/python/cvc5.pxi
index 7731f4e71..cd9e91e51 100644
--- a/src/api/python/cvc5.pxi
+++ b/src/api/python/cvc5.pxi
@@ -28,7 +28,8 @@ from cvc5 cimport ROUND_NEAREST_TIES_TO_AWAY
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":
@@ -1661,6 +1662,30 @@ cdef class Term:
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())
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback