3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-06-20 21:03:39 +00:00

update API functions

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-08-02 16:56:43 -07:00
parent ce3fd22f3b
commit 4b3251dec1

View file

@ -25,15 +25,24 @@ Notes:
#include "api/api_model.h"
#include "api/api_ast_map.h"
#include "api/api_ast_vector.h"
#include "qe/qe_vartest.h"
#include "qe/qe_lite.h"
#include "muz/spacer/spacer_util.h"
#include "ast/expr_map.h"
extern "C"
{
static bool to_apps(unsigned n, Z3_app const es[], app_ref_vector& result) {
for (unsigned i = 0; i < n; ++i) {
if (!is_app(to_app(es[i]))) {
return false;
}
result.push_back (to_app (es [i]));
}
return true;
}
Z3_ast Z3_API Z3_qe_model_project (Z3_context c,
Z3_model m,
unsigned num_bounds,
@ -45,16 +54,10 @@ extern "C"
RESET_ERROR_CODE();
app_ref_vector vars(mk_c(c)->m ());
for (unsigned i = 0; i < num_bounds; ++i)
{
app *a = to_app (bound [i]);
if (a->get_kind () != AST_APP)
{
if (!to_apps(num_bounds, bound, vars)) {
SET_ERROR_CODE (Z3_INVALID_ARG);
RETURN_Z3(0);
}
vars.push_back (a);
}
expr_ref result (mk_c(c)->m ());
result = to_expr (body);
@ -79,16 +82,9 @@ extern "C"
ast_manager& man = mk_c(c)->m ();
app_ref_vector vars(man);
for (unsigned i = 0; i < num_bounds; ++i)
{
app *a = to_app (bound [i]);
if (a->get_kind () != AST_APP)
{
SET_ERROR_CODE (Z3_INVALID_ARG);
if (!to_apps(num_bounds, bound, vars)) {
RETURN_Z3(0);
}
vars.push_back (a);
}
expr_ref result (mk_c(c)->m ());
result = to_expr (body);
@ -145,11 +141,9 @@ extern "C"
ast_ref_vector &vVars = to_ast_vector_ref (vars);
app_ref_vector vApps (mk_c(c)->m());
for (unsigned i = 0; i < vVars.size (); ++i)
{
for (unsigned i = 0; i < vVars.size (); ++i) {
app *a = to_app (vVars.get (i));
if (a->get_kind () != AST_APP)
{
if (a->get_kind () != AST_APP) {
SET_ERROR_CODE (Z3_INVALID_ARG);
RETURN_Z3(0);
}
@ -164,11 +158,11 @@ extern "C"
qe (vApps, result);
// -- copy back variables that were not eliminated
if (vApps.size () < vVars.size ())
{
if (vApps.size () < vVars.size ()) {
vVars.reset ();
for (unsigned i = 0; i < vApps.size (); ++i)
vVars.push_back (vApps.get (i));
for (app* v : vApps) {
vVars.push_back (v);
}
}
mk_c(c)->save_ast_trail (result.get ());