mirror of
https://github.com/Z3Prover/z3
synced 2025-05-06 15:25:46 +00:00
add ability to create and manipulate model objects
Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
parent
2c8e9aeb9c
commit
392334f779
4 changed files with 101 additions and 1 deletions
|
@ -30,6 +30,17 @@ Revision History:
|
|||
|
||||
extern "C" {
|
||||
|
||||
Z3_model Z3_API Z3_mk_model(Z3_context c) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_mk_model(c);
|
||||
RESET_ERROR_CODE();
|
||||
Z3_model_ref * m_ref = alloc(Z3_model_ref, *mk_c(c));
|
||||
m_ref->m_model = alloc(model, mk_c(c)->m());
|
||||
mk_c(c)->save_object(m_ref);
|
||||
RETURN_Z3(of_model(m_ref));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_model_inc_ref(Z3_context c, Z3_model m) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_model_inc_ref(c, m);
|
||||
|
@ -224,6 +235,31 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
Z3_func_interp Z3_API Z3_add_func_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast else_val) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_add_func_interp(c, m, f, else_val);
|
||||
RESET_ERROR_CODE();
|
||||
func_decl* d = to_func_decl(f);
|
||||
model* mdl = to_model_ref(m);
|
||||
Z3_func_interp_ref * f_ref = alloc(Z3_func_interp_ref, *mk_c(c), mdl);
|
||||
f_ref->m_func_interp = alloc(func_interp, mk_c(c)->m(), d->get_arity());
|
||||
mk_c(c)->save_object(f_ref);
|
||||
mdl->register_decl(d, f_ref->m_func_interp);
|
||||
f_ref->m_func_interp->set_else(to_expr(else_val));
|
||||
RETURN_Z3(of_func_interp(f_ref));
|
||||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_add_const_interp(Z3_context c, Z3_model m, Z3_func_decl f, Z3_ast a) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_add_const_interp(c, m, f, a);
|
||||
RESET_ERROR_CODE();
|
||||
func_decl* d = to_func_decl(f);
|
||||
model* mdl = to_model_ref(m);
|
||||
mdl->register_decl(d, to_expr(a));
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
void Z3_API Z3_func_interp_inc_ref(Z3_context c, Z3_func_interp f) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_func_interp_inc_ref(c, f);
|
||||
|
@ -292,6 +328,24 @@ extern "C" {
|
|||
Z3_CATCH_RETURN(0);
|
||||
}
|
||||
|
||||
void Z3_API Z3_add_func_entry(Z3_context c, Z3_func_interp fi, Z3_ast_vector args, Z3_ast value) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_add_func_entry(c, fi, args, value);
|
||||
//CHECK_NON_NULL(fi, void);
|
||||
//CHECK_NON_NULL(args, void);
|
||||
//CHECK_NON_NULL(value, void);
|
||||
func_interp* _fi = to_func_interp_ref(fi);
|
||||
expr* _value = to_expr(value);
|
||||
if (to_ast_vector_ref(args).size() != _fi->get_arity()) {
|
||||
SET_ERROR_CODE(Z3_IOB);
|
||||
return;
|
||||
}
|
||||
// check sorts of value
|
||||
expr* const* _args = (expr* const*) to_ast_vector_ref(args).c_ptr();
|
||||
_fi->insert_entry(_args, _value);
|
||||
Z3_CATCH;
|
||||
}
|
||||
|
||||
void Z3_API Z3_func_entry_inc_ref(Z3_context c, Z3_func_entry e) {
|
||||
Z3_TRY;
|
||||
LOG_Z3_func_entry_inc_ref(c, e);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue