mirror of
https://github.com/Z3Prover/z3
synced 2025-06-21 05:13:39 +00:00
update API functions
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
ce3fd22f3b
commit
4b3251dec1
1 changed files with 119 additions and 125 deletions
|
@ -25,15 +25,24 @@ Notes:
|
||||||
#include "api/api_model.h"
|
#include "api/api_model.h"
|
||||||
#include "api/api_ast_map.h"
|
#include "api/api_ast_map.h"
|
||||||
#include "api/api_ast_vector.h"
|
#include "api/api_ast_vector.h"
|
||||||
|
|
||||||
#include "qe/qe_vartest.h"
|
#include "qe/qe_vartest.h"
|
||||||
#include "qe/qe_lite.h"
|
#include "qe/qe_lite.h"
|
||||||
#include "muz/spacer/spacer_util.h"
|
#include "muz/spacer/spacer_util.h"
|
||||||
|
|
||||||
#include "ast/expr_map.h"
|
#include "ast/expr_map.h"
|
||||||
|
|
||||||
extern "C"
|
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_ast Z3_API Z3_qe_model_project (Z3_context c,
|
||||||
Z3_model m,
|
Z3_model m,
|
||||||
unsigned num_bounds,
|
unsigned num_bounds,
|
||||||
|
@ -45,16 +54,10 @@ extern "C"
|
||||||
RESET_ERROR_CODE();
|
RESET_ERROR_CODE();
|
||||||
|
|
||||||
app_ref_vector vars(mk_c(c)->m ());
|
app_ref_vector vars(mk_c(c)->m ());
|
||||||
for (unsigned i = 0; i < num_bounds; ++i)
|
if (!to_apps(num_bounds, bound, vars)) {
|
||||||
{
|
|
||||||
app *a = to_app (bound [i]);
|
|
||||||
if (a->get_kind () != AST_APP)
|
|
||||||
{
|
|
||||||
SET_ERROR_CODE (Z3_INVALID_ARG);
|
SET_ERROR_CODE (Z3_INVALID_ARG);
|
||||||
RETURN_Z3(0);
|
RETURN_Z3(0);
|
||||||
}
|
}
|
||||||
vars.push_back (a);
|
|
||||||
}
|
|
||||||
|
|
||||||
expr_ref result (mk_c(c)->m ());
|
expr_ref result (mk_c(c)->m ());
|
||||||
result = to_expr (body);
|
result = to_expr (body);
|
||||||
|
@ -79,16 +82,9 @@ extern "C"
|
||||||
|
|
||||||
ast_manager& man = mk_c(c)->m ();
|
ast_manager& man = mk_c(c)->m ();
|
||||||
app_ref_vector vars(man);
|
app_ref_vector vars(man);
|
||||||
for (unsigned i = 0; i < num_bounds; ++i)
|
if (!to_apps(num_bounds, bound, vars)) {
|
||||||
{
|
|
||||||
app *a = to_app (bound [i]);
|
|
||||||
if (a->get_kind () != AST_APP)
|
|
||||||
{
|
|
||||||
SET_ERROR_CODE (Z3_INVALID_ARG);
|
|
||||||
RETURN_Z3(0);
|
RETURN_Z3(0);
|
||||||
}
|
}
|
||||||
vars.push_back (a);
|
|
||||||
}
|
|
||||||
|
|
||||||
expr_ref result (mk_c(c)->m ());
|
expr_ref result (mk_c(c)->m ());
|
||||||
result = to_expr (body);
|
result = to_expr (body);
|
||||||
|
@ -145,11 +141,9 @@ extern "C"
|
||||||
ast_ref_vector &vVars = to_ast_vector_ref (vars);
|
ast_ref_vector &vVars = to_ast_vector_ref (vars);
|
||||||
|
|
||||||
app_ref_vector vApps (mk_c(c)->m());
|
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));
|
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);
|
SET_ERROR_CODE (Z3_INVALID_ARG);
|
||||||
RETURN_Z3(0);
|
RETURN_Z3(0);
|
||||||
}
|
}
|
||||||
|
@ -164,11 +158,11 @@ extern "C"
|
||||||
qe (vApps, result);
|
qe (vApps, result);
|
||||||
|
|
||||||
// -- copy back variables that were not eliminated
|
// -- copy back variables that were not eliminated
|
||||||
if (vApps.size () < vVars.size ())
|
if (vApps.size () < vVars.size ()) {
|
||||||
{
|
|
||||||
vVars.reset ();
|
vVars.reset ();
|
||||||
for (unsigned i = 0; i < vApps.size (); ++i)
|
for (app* v : vApps) {
|
||||||
vVars.push_back (vApps.get (i));
|
vVars.push_back (v);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mk_c(c)->save_ast_trail (result.get ());
|
mk_c(c)->save_ast_trail (result.get ());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue