diff --git a/src/api/api_quant.cpp b/src/api/api_quant.cpp index 0da5c5a9273..bb9efa9c30b 100644 --- a/src/api/api_quant.cpp +++ b/src/api/api_quant.cpp @@ -383,6 +383,36 @@ extern "C" { Z3_CATCH_RETURN(0); } + Z3_symbol Z3_API Z3_get_quantifier_skolem_id(Z3_context c, Z3_ast a) { + Z3_TRY; + LOG_Z3_get_quantifier_skolem_id(c, a); + RESET_ERROR_CODE(); + ast * _a = to_ast(a); + if (_a->get_kind() == AST_QUANTIFIER) { + return of_symbol(to_quantifier(_a)->get_skid()); + } + else { + SET_ERROR_CODE(Z3_SORT_ERROR, nullptr); + return of_symbol(symbol::null); + } + Z3_CATCH_RETURN(of_symbol(symbol::null)); + } + + Z3_symbol Z3_API Z3_get_quantifier_id(Z3_context c, Z3_ast a) { + Z3_TRY; + LOG_Z3_get_quantifier_skolem_id(c, a); + RESET_ERROR_CODE(); + ast * _a = to_ast(a); + if (_a->get_kind() == AST_QUANTIFIER) { + return of_symbol(to_quantifier(_a)->get_qid()); + } + else { + SET_ERROR_CODE(Z3_SORT_ERROR, nullptr); + return of_symbol(symbol::null); + } + Z3_CATCH_RETURN(of_symbol(symbol::null)); + } + unsigned Z3_API Z3_get_quantifier_num_patterns(Z3_context c, Z3_ast a) { Z3_TRY; LOG_Z3_get_quantifier_num_patterns(c, a); diff --git a/src/api/python/z3/z3.py b/src/api/python/z3/z3.py index bac80b33ea9..053fd7dd105 100644 --- a/src/api/python/z3/z3.py +++ b/src/api/python/z3/z3.py @@ -2081,6 +2081,16 @@ def weight(self): """ return int(Z3_get_quantifier_weight(self.ctx_ref(), self.ast)) + def skolem_id(self): + """Return the skolem id of `self`. + """ + return _symbol2py(self.ctx, Z3_get_quantifier_skolem_id(self.ctx_ref(), self.ast)) + + def qid(self): + """Return the quantifier id of `self`. + """ + return _symbol2py(self.ctx, Z3_get_quantifier_id(self.ctx_ref(), self.ast)) + def num_patterns(self): """Return the number of patterns (i.e., quantifier instantiation hints) in `self`. diff --git a/src/api/z3_api.h b/src/api/z3_api.h index fafc3eebd47..0468ab91d55 100644 --- a/src/api/z3_api.h +++ b/src/api/z3_api.h @@ -5206,6 +5206,24 @@ extern "C" { */ unsigned Z3_API Z3_get_quantifier_weight(Z3_context c, Z3_ast a); + /** + \brief Obtain skolem id of quantifier. + + \pre Z3_get_ast_kind(a) == Z3_QUANTIFIER_AST + + def_API('Z3_get_quantifier_skolem_id', SYMBOL, (_in(CONTEXT), _in(AST))) + */ + Z3_symbol Z3_API Z3_get_quantifier_skolem_id(Z3_context c, Z3_ast a); + + /** + \brief Obtain id of quantifier. + + \pre Z3_get_ast_kind(a) == Z3_QUANTIFIER_AST + + def_API('Z3_get_quantifier_id', SYMBOL, (_in(CONTEXT), _in(AST))) + */ + Z3_symbol Z3_API Z3_get_quantifier_id(Z3_context c, Z3_ast a); + /** \brief Return number of patterns used in quantifier.