summaryrefslogtreecommitdiff
path: root/src/api/python
diff options
context:
space:
mode:
authorAndres Noetzli <andres.noetzli@gmail.com>2020-06-06 01:24:17 -0700
committerGitHub <noreply@github.com>2020-06-06 01:24:17 -0700
commitfd60da4a22f02f6f5b82cef3585240c1b33595e9 (patch)
tree137d45e65f204c2f604fed65d47a7d7b4f716c78 /src/api/python
parent6a61c1a75b08867c7c06623b8c03084056b6bed7 (diff)
Keep definitions when global-declarations enabled (#4572)
Fixes #4552. Fixes #4555. The SMT-LIB standard mandates that definitions are kept when `:global-declarations` are enabled. Until now, CVC4 was keeping track of the symbols of a definition correctly but lost the body of the definition when the user context was popped. This commit fixes the issue by adding a `global` parameter to `SmtEngine::defineFunction()` and `SmtEngine::defineFunctionRec()`. If that parameter is set, the definitions of functions are added at level 0 to `d_definedFunctions` and the lemmas for recursive function definitions are kept in an additional list and asserted during each `checkSat` call. The commit also updates new API, the commands, and the parsers to reflect this change.
Diffstat (limited to 'src/api/python')
-rw-r--r--src/api/python/cvc4.pxd10
-rw-r--r--src/api/python/cvc4.pxi24
2 files changed, 19 insertions, 15 deletions
diff --git a/src/api/python/cvc4.pxd b/src/api/python/cvc4.pxd
index cc998306d..624b3c365 100644
--- a/src/api/python/cvc4.pxd
+++ b/src/api/python/cvc4.pxd
@@ -181,14 +181,14 @@ cdef extern from "api/cvc4cpp.h" namespace "CVC4::api":
Term declareFun(const string& symbol, const vector[Sort]& sorts, Sort sort) except +
Sort declareSort(const string& symbol, uint32_t arity) except +
Term defineFun(const string& symbol, const vector[Term]& bound_vars,
- Sort sort, Term term) except +
- Term defineFun(Term fun, const vector[Term]& bound_vars, Term term) except +
+ Sort sort, Term term, bint glbl) except +
+ Term defineFun(Term fun, const vector[Term]& bound_vars, Term term, bint glbl) except +
Term defineFunRec(const string& symbol, const vector[Term]& bound_vars,
- Sort sort, Term term) except +
+ Sort sort, Term term, bint glbl) except +
Term defineFunRec(Term fun, const vector[Term]& bound_vars,
- Term term) except +
+ Term term, bint glbl) except +
Term defineFunsRec(vector[Term]& funs, vector[vector[Term]]& bound_vars,
- vector[Term]& terms) except +
+ vector[Term]& terms, bint glbl) except +
vector[Term] getAssertions() except +
vector[pair[Term, Term]] getAssignment() except +
string getInfo(const string& flag) except +
diff --git a/src/api/python/cvc4.pxi b/src/api/python/cvc4.pxi
index 9dd9c1cde..b7593f6f1 100644
--- a/src/api/python/cvc4.pxi
+++ b/src/api/python/cvc4.pxi
@@ -797,13 +797,13 @@ cdef class Solver:
sort.csort = self.csolver.declareSort(symbol.encode(), arity)
return sort
- def defineFun(self, sym_or_fun, bound_vars, sort_or_term, t=None):
+ def defineFun(self, sym_or_fun, bound_vars, sort_or_term, t=None, glbl=False):
'''
Supports two uses:
Term defineFun(str symbol, List[Term] bound_vars,
- Sort sort, Term term)
+ Sort sort, Term term, bool glbl)
Term defineFun(Term fun, List[Term] bound_vars,
- Term term)
+ Term term, bool glbl)
'''
cdef Term term = Term()
cdef vector[c_Term] v
@@ -814,21 +814,23 @@ cdef class Solver:
term.cterm = self.csolver.defineFun((<str?> sym_or_fun).encode(),
<const vector[c_Term] &> v,
(<Sort?> sort_or_term).csort,
- (<Term?> t).cterm)
+ (<Term?> t).cterm,
+ <bint> glbl)
else:
term.cterm = self.csolver.defineFun((<Term?> sym_or_fun).cterm,
<const vector[c_Term]&> v,
- (<Term?> sort_or_term).cterm)
+ (<Term?> sort_or_term).cterm,
+ <bint> glbl)
return term
- def defineFunRec(self, sym_or_fun, bound_vars, sort_or_term, t=None):
+ def defineFunRec(self, sym_or_fun, bound_vars, sort_or_term, t=None, glbl=False):
'''
Supports two uses:
Term defineFunRec(str symbol, List[Term] bound_vars,
- Sort sort, Term term)
+ Sort sort, Term term, bool glbl)
Term defineFunRec(Term fun, List[Term] bound_vars,
- Term term)
+ Term term, bool glbl)
'''
cdef Term term = Term()
cdef vector[c_Term] v
@@ -839,11 +841,13 @@ cdef class Solver:
term.cterm = self.csolver.defineFunRec((<str?> sym_or_fun).encode(),
<const vector[c_Term] &> v,
(<Sort?> sort_or_term).csort,
- (<Term?> t).cterm)
+ (<Term?> t).cterm,
+ <bint> glbl)
else:
term.cterm = self.csolver.defineFunRec((<Term?> sym_or_fun).cterm,
<const vector[c_Term]&> v,
- (<Term?> sort_or_term).cterm)
+ (<Term?> sort_or_term).cterm,
+ <bint> glbl)
return term
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback