3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-29 20:05:51 +00:00

fix at-most-1 constraint compiler bug

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2016-10-22 18:50:16 -07:00
parent bb6d826908
commit 23b9d3ef55
17 changed files with 369 additions and 62 deletions

View file

@ -27,6 +27,7 @@ Revision History:
#include"cancel_eh.h"
#include"scoped_timer.h"
#include"smt2parser.h"
#include"api_ast_vector.h"
extern "C" {
@ -296,6 +297,36 @@ extern "C" {
}
Z3_ast_vector Z3_API Z3_optimize_get_assertions(Z3_context c, Z3_optimize o) {
Z3_TRY;
LOG_Z3_optimize_get_assertions(c, o);
RESET_ERROR_CODE();
Z3_ast_vector_ref * v = alloc(Z3_ast_vector_ref, *mk_c(c), mk_c(c)->m());
mk_c(c)->save_object(v);
expr_ref_vector hard(mk_c(c)->m());
to_optimize_ptr(o)->get_hard_constraints(hard);
for (unsigned i = 0; i < hard.size(); i++) {
v->m_ast_vector.push_back(hard[i].get());
}
RETURN_Z3(of_ast_vector(v));
Z3_CATCH_RETURN(0);
}
unsigned Z3_API Z3_optimize_get_num_objectives(Z3_context c, Z3_optimize o) {
RESET_ERROR_CODE();
return to_optimize_ptr(o)->num_objectives();
}
Z3_ast Z3_API Z3_optimize_get_objective(Z3_context c, Z3_optimize o, unsigned index) {
Z3_TRY;
LOG_Z3_optimize_get_objective(c, o, index);
RESET_ERROR_CODE();
expr_ref result = to_optimize_ptr(o)->get_objective(index);
mk_c(c)->save_ast_trail(result);
RETURN_Z3(of_expr(result));
Z3_CATCH_RETURN(0);
}
};