3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

remove deprecated user-theory plugins and other unused functionality from API

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2015-11-20 08:43:27 -08:00
parent e96d93ee42
commit 665af3d8b9
11 changed files with 2 additions and 2090 deletions

View file

@ -37,23 +37,6 @@ namespace api {
exit(1);
}
Z3_search_failure mk_Z3_search_failure(smt::failure f) {
switch(f) {
case smt::OK: return Z3_NO_FAILURE;
case smt::UNKNOWN: return Z3_UNKNOWN;
case smt::TIMEOUT: return Z3_TIMEOUT;
case smt::MEMOUT: return Z3_MEMOUT_WATERMARK;
case smt::CANCELED: return Z3_CANCELED;
case smt::NUM_CONFLICTS: return Z3_NUM_CONFLICTS;
case smt::THEORY: return Z3_THEORY;
case smt::QUANTIFIERS: return Z3_QUANTIFIERS;
default:
UNREACHABLE();
break;
}
return static_cast<Z3_search_failure>(f);
}
context::add_plugins::add_plugins(ast_manager & m) {
reg_decl_plugins(m);
}
@ -94,7 +77,6 @@ namespace api {
m_ast_trail(m()),
m_replay_stack() {
m_solver = 0;
m_error_code = Z3_OK;
m_print_mode = Z3_PRINT_SMTLIB_FULL;
m_searching = false;
@ -133,7 +115,6 @@ namespace api {
m_ast_trail.reset();
}
reset_parser();
dealloc(m_solver);
}
void context::interrupt() {
@ -302,52 +283,6 @@ namespace api {
}
}
// ------------------------
//
// Solver interface for backward compatibility
//
// ------------------------
smt::kernel & context::get_smt_kernel() {
if (!m_solver) {
m_fparams.updt_params(m_params);
m_solver = alloc(smt::kernel, m(), m_fparams);
}
return *m_solver;
}
void context::assert_cnstr(expr * a) {
get_smt_kernel().assert_expr(a);
}
lbool context::check(model_ref & m) {
flet<bool> searching(m_searching, true);
lbool r;
r = get_smt_kernel().check();
if (r != l_false)
get_smt_kernel().get_model(m);
return r;
}
void context::push() {
get_smt_kernel().push();
m_ast_lim.push_back(m_ast_trail.size());
m_replay_stack.push_back(0);
}
void context::pop(unsigned num_scopes) {
for (unsigned i = 0; i < num_scopes; ++i) {
unsigned sz = m_ast_lim.back();
m_ast_lim.pop_back();
dealloc(m_replay_stack.back());
m_replay_stack.pop_back();
while (m_ast_trail.size() > sz) {
m_ast_trail.pop_back();
}
}
SASSERT(num_scopes <= get_smt_kernel().get_scope_level());
get_smt_kernel().pop(num_scopes);
}
// ------------------------
//

View file

@ -44,7 +44,6 @@ namespace realclosure {
};
namespace api {
Z3_search_failure mk_Z3_search_failure(smt::failure f);
class context : public tactic_manager {
@ -62,7 +61,6 @@ namespace api {
// Support for old solver API
smt_params m_fparams;
smt::kernel * m_solver; // General purpose solver for backward compatibility
// -------------------------------
ast_ref_vector m_last_result; //!< used when m_user_ref_count == true
@ -210,13 +208,6 @@ namespace api {
//
// ------------------------
smt_params & fparams() { return m_fparams; }
bool has_solver() const { return m_solver != 0; }
smt::kernel & get_smt_kernel();
void assert_cnstr(expr * a);
lbool check(model_ref & m);
void push();
void pop(unsigned num_scopes);
unsigned get_num_scopes() const { return m_ast_lim.size(); }
// ------------------------
//

View file

@ -1,333 +0,0 @@
/*++
Copyright (c) 2012 Microsoft Corporation
Module Name:
api_user_theory.cpp
Abstract:
API for external theories
Author:
Leonardo de Moura (leonardo) 2012-02-29.
Revision History:
--*/
#include<iostream>
#include"z3.h"
#include"api_log_macros.h"
#include"api_context.h"
#include"api_util.h"
#include"user_smt_theory.h"
smt::user_theory * mk_t(Z3_theory t) {
return reinterpret_cast<smt::user_theory*>(t);
}
extern "C" {
///////////////////////////////
// Theory plugin
// No support for logging
Z3_theory Z3_mk_theory(Z3_context c, Z3_string th_name, void * ext_data) {
Z3_TRY;
RESET_ERROR_CODE();
if (mk_c(c)->get_smt_kernel().get_scope_level() > 0) {
SET_ERROR_CODE(Z3_INVALID_USAGE);
return 0;
}
return reinterpret_cast<Z3_theory>(mk_user_theory(mk_c(c)->get_smt_kernel(), c, ext_data, th_name));
Z3_CATCH_RETURN(0);
}
void * Z3_theory_get_ext_data(Z3_theory t) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
void * r = mk_t(t)->get_ext_data();
return r;
Z3_CATCH_RETURN(0);
}
Z3_sort Z3_theory_mk_sort(Z3_context c, Z3_theory t, Z3_symbol s) {
Z3_TRY;
RESET_ERROR_CODE();
sort * r = mk_t(t)->mk_sort(to_symbol(s));
mk_c(c)->save_ast_trail(r);
return of_sort(r);
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_theory_mk_value(Z3_context c, Z3_theory t, Z3_symbol n, Z3_sort s) {
Z3_TRY;
RESET_ERROR_CODE();
func_decl * d = mk_t(t)->mk_value_decl(to_symbol(n), to_sort(s));
app * r = mk_c(c)->m().mk_const(d);
mk_c(c)->save_ast_trail(r);
return of_ast(r);
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_theory_mk_constant(Z3_context c, Z3_theory t, Z3_symbol n, Z3_sort s) {
Z3_TRY;
RESET_ERROR_CODE();
Z3_func_decl d = Z3_theory_mk_func_decl(c, t, n, 0, 0, s);
app * r = mk_c(c)->m().mk_const(to_func_decl(d));
mk_c(c)->save_ast_trail(r);
return of_ast(r);
Z3_CATCH_RETURN(0);
}
Z3_func_decl Z3_theory_mk_func_decl(Z3_context c, Z3_theory t, Z3_symbol n,
unsigned domain_size, Z3_sort const domain[],
Z3_sort range) {
Z3_TRY;
RESET_ERROR_CODE();
func_decl * r = mk_t(t)->mk_func_decl(to_symbol(n), domain_size, to_sorts(domain), to_sort(range));
mk_c(c)->save_ast_trail(r);
return of_func_decl(r);
Z3_CATCH_RETURN(0);
}
Z3_context Z3_theory_get_context(Z3_theory t) {
Z3_context c = reinterpret_cast<Z3_context>(mk_t(t)->get_ext_context());
RESET_ERROR_CODE();
return c;
}
void Z3_set_delete_callback(Z3_theory t, Z3_theory_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_delete_fptr(reinterpret_cast<smt::theory_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_reduce_app_callback(Z3_theory t, Z3_reduce_app_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_reduce_app_fptr(reinterpret_cast<reduce_app_fptr>(f));
Z3_CATCH;
}
void Z3_set_reduce_eq_callback(Z3_theory t, Z3_reduce_eq_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_reduce_eq_fptr(reinterpret_cast<reduce_eq_fptr>(f));
Z3_CATCH;
}
void Z3_set_reduce_distinct_callback(Z3_theory t, Z3_reduce_distinct_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_reduce_distinct_fptr(reinterpret_cast<reduce_distinct_fptr>(f));
Z3_CATCH;
}
void Z3_set_new_app_callback(Z3_theory t, Z3_theory_ast_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_new_app_fptr(reinterpret_cast<smt::theory_app_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_new_elem_callback(Z3_theory t, Z3_theory_ast_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_new_elem_fptr(reinterpret_cast<smt::theory_app_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_init_search_callback(Z3_theory t, Z3_theory_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_init_search_fptr(reinterpret_cast<smt::theory_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_push_callback(Z3_theory t, Z3_theory_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_push_fptr(reinterpret_cast<smt::theory_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_pop_callback(Z3_theory t, Z3_theory_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_pop_fptr(reinterpret_cast<smt::theory_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_restart_callback(Z3_theory t, Z3_theory_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_restart_fptr(reinterpret_cast<smt::theory_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_reset_callback(Z3_theory t, Z3_theory_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_reset_fptr(reinterpret_cast<smt::theory_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_final_check_callback(Z3_theory t, Z3_theory_final_check_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_final_check_fptr(reinterpret_cast<smt::theory_final_check_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_new_eq_callback(Z3_theory t, Z3_theory_ast_ast_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_new_eq_fptr(reinterpret_cast<smt::theory_app_app_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_new_diseq_callback(Z3_theory t, Z3_theory_ast_ast_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_new_diseq_fptr(reinterpret_cast<smt::theory_app_app_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_new_assignment_callback(Z3_theory t, Z3_theory_ast_bool_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_new_assignment_fptr(reinterpret_cast<smt::theory_app_bool_callback_fptr>(f));
Z3_CATCH;
}
void Z3_set_new_relevant_callback(Z3_theory t, Z3_theory_ast_callback_fptr f) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->set_new_relevant_fptr(reinterpret_cast<smt::theory_app_callback_fptr>(f));
Z3_CATCH;
}
void Z3_theory_assert_axiom(Z3_theory t, Z3_ast ax) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->assert_axiom(to_ast(ax));
Z3_CATCH;
}
void Z3_theory_assume_eq(Z3_theory t, Z3_ast lhs, Z3_ast rhs) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->assume_eq(to_ast(lhs), to_ast(rhs));
Z3_CATCH;
}
void Z3_theory_enable_axiom_simplification(Z3_theory t, Z3_bool flag) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
mk_t(t)->enable_axiom_simplification(flag == Z3_TRUE);
Z3_CATCH;
}
Z3_ast Z3_theory_get_eqc_root(Z3_theory t, Z3_ast n) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return of_ast(mk_t(t)->get_root(to_ast(n)));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_theory_get_eqc_next(Z3_theory t, Z3_ast n) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return of_ast(mk_t(t)->get_next(to_ast(n)));
Z3_CATCH_RETURN(0);
}
unsigned Z3_theory_get_num_parents(Z3_theory t, Z3_ast n) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return mk_t(t)->get_num_parents(to_ast(n));
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_theory_get_parent(Z3_theory t, Z3_ast n, unsigned i) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return of_ast(mk_t(t)->get_parent(to_ast(n), i));
Z3_CATCH_RETURN(0);
}
unsigned Z3_theory_get_num_elems(Z3_theory t) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return mk_t(t)->get_num_asts();
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_theory_get_elem(Z3_theory t, unsigned i) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return of_ast(mk_t(t)->get_ast(i));
Z3_CATCH_RETURN(0);
}
unsigned Z3_theory_get_num_apps(Z3_theory t) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return mk_t(t)->get_num_parents();
Z3_CATCH_RETURN(0);
}
Z3_ast Z3_theory_get_app(Z3_theory t, unsigned i) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return of_ast(mk_t(t)->get_parent(i));
Z3_CATCH_RETURN(0);
}
Z3_bool Z3_theory_is_value(Z3_theory t, Z3_ast n) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return is_app(to_ast(n)) && mk_t(t)->get_family_id() == to_app(to_ast(n))->get_family_id();
Z3_CATCH_RETURN(Z3_FALSE);
}
Z3_bool Z3_theory_is_decl(Z3_theory t, Z3_func_decl d) {
Z3_context c = Z3_theory_get_context(t);
Z3_TRY;
RESET_ERROR_CODE();
return mk_t(t)->get_family_id() == to_func_decl(d)->get_family_id();
Z3_CATCH_RETURN(Z3_FALSE);
}
};

View file

@ -24,7 +24,6 @@ Copyright (c) 2015 Microsoft Corporation
#ifdef CorML3
DEFINE_TYPE(Z3_symbol);
DEFINE_TYPE(Z3_literals);
DEFINE_TYPE(Z3_theory);
DEFINE_TYPE(Z3_config);
DEFINE_TYPE(Z3_context);
DEFINE_TYPE(Z3_sort);
@ -55,7 +54,6 @@ DEFINE_TYPE(Z3_func_entry);
DEFINE_TYPE(Z3_fixedpoint);
DEFINE_TYPE(Z3_optimize);
DEFINE_TYPE(Z3_rcf_num);
DEFINE_VOID(Z3_theory_data);
#endif
#ifndef __int64
@ -1250,7 +1248,7 @@ typedef enum {
Z3_PK_INVALID
} Z3_param_kind;
#ifdef CorML3
#if 0
/**
\mlonly {!search_failure} \endmlonly \conly \brief
The different kinds of search failure types.
@ -1345,8 +1343,6 @@ typedef enum
def_Type('LITERALS', 'Z3_literals', 'Literals')
def_Type('CONSTRUCTOR', 'Z3_constructor', 'Constructor')
def_Type('CONSTRUCTOR_LIST', 'Z3_constructor_list', 'ConstructorList')
def_Type('THEORY', 'Z3_theory', 'ctypes.c_void_p')
def_Type('THEORY_DATA', 'Z3_theory_data', 'ctypes.c_void_p')
def_Type('SOLVER', 'Z3_solver', 'SolverObj')
def_Type('GOAL', 'Z3_goal', 'GoalObj')
def_Type('TACTIC', 'Z3_tactic', 'TacticObj')
@ -5389,391 +5385,6 @@ END_MLAPI_EXCLUDE
/*@}*/
#ifdef CorML3
/**
@name External Theory Plugins
*/
/*@{*/
#ifdef Conly
//
// callbacks and void* don't work with CAMLIDL.
//
typedef Z3_bool Z3_reduce_eq_callback_fptr(Z3_theory t, Z3_ast a, Z3_ast b, Z3_ast * r);
typedef Z3_bool Z3_reduce_app_callback_fptr(Z3_theory, Z3_func_decl, unsigned, Z3_ast const [], Z3_ast *);
typedef Z3_bool Z3_reduce_distinct_callback_fptr(Z3_theory, unsigned, Z3_ast const [], Z3_ast *);
typedef void Z3_theory_callback_fptr(Z3_theory t);
typedef Z3_bool Z3_theory_final_check_callback_fptr(Z3_theory);
typedef void Z3_theory_ast_callback_fptr(Z3_theory, Z3_ast);
typedef void Z3_theory_ast_bool_callback_fptr(Z3_theory, Z3_ast, Z3_bool);
typedef void Z3_theory_ast_ast_callback_fptr(Z3_theory, Z3_ast, Z3_ast);
#endif
#ifdef Conly
/**
\brief Create a new user defined theory. The new theory will be identified by the name \c th_name.
A theory must be created before asserting any assertion to the given context.
\conly Return \c NULL in case of failure.
\conly \c data is a pointer to an external data-structure that may be used to store
\conly theory specific additional data.
*/
Z3_theory Z3_API Z3_mk_theory(Z3_context c, Z3_string th_name, Z3_theory_data data);
/**
\brief Return a pointer to the external data-structure supplied to the function #Z3_mk_theory.
\see Z3_mk_theory
*/
Z3_theory_data Z3_API Z3_theory_get_ext_data(Z3_theory t);
#endif
/**
\brief Create an interpreted theory sort.
*/
Z3_sort Z3_API Z3_theory_mk_sort(Z3_context c, Z3_theory t, Z3_symbol s);
/**
\brief Create an interpreted theory constant value. Values are assumed to be different from each other.
*/
Z3_ast Z3_API Z3_theory_mk_value(Z3_context c, Z3_theory t, Z3_symbol n, Z3_sort s);
/**
\brief Create an interpreted constant for the given theory.
*/
Z3_ast Z3_API Z3_theory_mk_constant(Z3_context c, Z3_theory t, Z3_symbol n, Z3_sort s);
/**
\brief Create an interpreted function declaration for the given theory.
*/
Z3_func_decl Z3_API Z3_theory_mk_func_decl(Z3_context c, Z3_theory t, Z3_symbol n,
unsigned domain_size, Z3_sort const domain[],
Z3_sort range);
/**
\brief Return the context where the given theory is installed.
*/
Z3_context Z3_API Z3_theory_get_context(Z3_theory t);
#ifdef Conly
/**
\brief Set a callback that is invoked when theory \c t is deleted.
This callback should be used to delete external data-structures associated with the given theory.
\conly The callback has the form <tt>f(t)</tt>, where
\conly - \c t is the given theory
\see Z3_mk_theory
\conly \see Z3_theory_get_ext_data
*/
void Z3_API Z3_set_delete_callback(Z3_theory t, Z3_theory_callback_fptr f);
/**
\brief Set a callback for simplifying operators of the given theory.
The callback \c f is invoked by Z3's simplifier.
\conly It is of the form <tt>f(t, d, n, args, r)</tt>, where:
\conly - \c t is the given theory
\conly - \c d is the declaration of the theory operator
\conly - \c n is the number of arguments in the array \c args
\conly - \c args are arguments for the theory operator
\conly - \c r should contain the result: an expression equivalent to <tt>d(args[0], ..., args[n-1])</tt>.
\conly If <tt>f(t, d, n, args, r)</tt> returns false, then \c r is ignored, and Z3 assumes that no simplification was performed.
*/
void Z3_API Z3_set_reduce_app_callback(Z3_theory t, Z3_reduce_app_callback_fptr f);
/**
\brief Set a callback for simplifying the atom <tt>s_1 = s_2</tt>, when the
sort of \c s_1 and \c s_2 is an interpreted sort of the given theory.
The callback \c f is invoked by Z3's simplifier.
\conly It has the form <tt>f(t, s_1, s_2, r)</tt>, where:
\conly - \c t is the given theory
\conly - \c s_1 is the left-hand-side
\conly - \c s_2 is the right-hand-side
\conly - \c r should contain the result: an expression equivalent to <tt>s_1 = s_2</tt>.
\conly If <tt>f(t, s_1, s_2, r)</tt> returns false, then \c r is ignored, and Z3 assumes that no simplification was performed.
*/
void Z3_API Z3_set_reduce_eq_callback(Z3_theory t, Z3_reduce_eq_callback_fptr f);
/**
\brief Set a callback for simplifying the atom <tt>distinct(s_1, ..., s_n)</tt>, when the
sort of \c s_1, ..., \c s_n is an interpreted sort of the given theory.
The callback \c f is invoked by Z3's simplifier.
\conly It has the form <tt>f(t, n, args, r)</tt>, where:
\conly - \c t is the given theory
\conly - \c n is the number of arguments in the array \c args
\conly - \c args are arguments for distinct.
\conly - \c r should contain the result: an expression equivalent to <tt>distinct(s_1, ..., s_n)</tt>.
\conly If <tt>f(t, n, args, r)</tt> returns false, then \c r is ignored, and Z3 assumes that no simplification was performed.
*/
void Z3_API Z3_set_reduce_distinct_callback(Z3_theory t, Z3_reduce_distinct_callback_fptr f);
/**
\brief Set a callback that is invoked when a theory application
is finally added into the logical context. Note that, not every
application contained in an asserted expression is actually
added into the logical context because it may be simplified
during a preprocessing step.
\conly The callback has the form <tt>f(t, n)</tt>, where
\conly - \c t is the given theory
\conly - \c n is a theory application, that is, an expression of the form <tt>g(...)</tt> where \c g is a theory operator.
\remark An expression \c n added to the logical context at search level \c n,
will remain in the logical context until this level is backtracked.
*/
void Z3_API Z3_set_new_app_callback(Z3_theory t, Z3_theory_ast_callback_fptr f);
/**
\brief Set a callback that is invoked when an expression of
sort \c s, where \c s is an interpreted sort of the theory \c
t, is finally added into the logical context. Note that, not
every expression contained in an asserted expression is
actually added into the logical context because it may be
simplified during a preprocessing step.
\conly The callback has the form <tt>f(t, n)</tt>, where
\conly - \c t is the given theory
\conly - \c n is an expression of sort \c s, where \c s is an interpreted sort of \c t.
\remark An expression \c n added to the logical context at search level \c n,
will remain in the logical context until this level is backtracked.
*/
void Z3_API Z3_set_new_elem_callback(Z3_theory t, Z3_theory_ast_callback_fptr f);
/**
\brief Set a callback that is invoked when Z3 starts searching for a
satisfying assignment.
\conly The callback has the form <tt>f(t)</tt>, where
\conly - \c t is the given theory
*/
void Z3_API Z3_set_init_search_callback(Z3_theory t, Z3_theory_callback_fptr f);
/**
\brief Set a callback that is invoked when Z3 creates a
case-split (aka backtracking point).
When a case-split is created we say the search level is increased.
\conly The callback has the form <tt>f(t)</tt>, where
\conly - \c t is the given theory
*/
void Z3_API Z3_set_push_callback(Z3_theory t, Z3_theory_callback_fptr f);
/**
\brief Set a callback that is invoked when Z3 backtracks a
case-split.
When a case-split is backtracked we say the search level is decreased.
\conly The callback has the form <tt>f(t)</tt>, where
\conly - \c t is the given theory
*/
void Z3_API Z3_set_pop_callback(Z3_theory t, Z3_theory_callback_fptr f);
/**
\brief Set a callback that is invoked when Z3 restarts the
search for a satisfying assignment.
\conly The callback has the form <tt>f(t)</tt>, where
\conly - \c t is the given theory
*/
void Z3_API Z3_set_restart_callback(Z3_theory t, Z3_theory_callback_fptr f);
/**
\brief Set a callback that is invoked when the logical context
is reset by the user. This callback is useful for reseting any
data-structure maintained by the user theory solver.
\conly The callback has the form <tt>f(t)</tt>, where
\conly - \c t is the given theory
*/
void Z3_API Z3_set_reset_callback(Z3_theory t, Z3_theory_callback_fptr f);
/**
\brief Set a callback that is invoked before Z3 starts building a model.
A theory may use this callback to perform expensive operations.
\conly The callback has the form <tt>f(t)</tt>, where
\conly - \c t is the given theory
If the theory returns \mlonly \c false, \endmlonly \conly \c Z3_false,
Z3 will assume that theory is giving up,
and it will assume that it was not possible to decide if the asserted constraints
are satisfiable or not.
*/
void Z3_API Z3_set_final_check_callback(Z3_theory t, Z3_theory_final_check_callback_fptr f);
/**
\brief Set a callback that is invoked when an equality <tt>s_1 = s_2</tt>
is found by the logical context.
\conly The callback has the form <tt>f(t, s_1, s_2)</tt>, where:
\conly - \c t is the given theory
\conly - \c s_1 is the left-hand-side
\conly - \c s_2 is the right-hand-side
*/
void Z3_API Z3_set_new_eq_callback(Z3_theory t, Z3_theory_ast_ast_callback_fptr f);
/**
\brief Set a callback that is invoked when a disequality <tt>s_1 != s_2</tt>
is found by the logical context.
\conly The callback has the form <tt>f(t, s_1, s_2)</tt>, where:
\conly - \c t is the given theory
\conly - \c s_1 is the left-hand-side
\conly - \c s_2 is the right-hand-side
*/
void Z3_API Z3_set_new_diseq_callback(Z3_theory t, Z3_theory_ast_ast_callback_fptr f);
/**
\brief Set a callback that is invoked when a theory predicate is assigned to true/false by Z3.
\conly The callback has the form <tt>f(t, p, v)</tt>, where:
\conly - \c t is the given theory
\conly - \c p is the assigned predicate.
\conly - \c v is the value (true/false) assigned to \c p.
*/
void Z3_API Z3_set_new_assignment_callback(Z3_theory t, Z3_theory_ast_bool_callback_fptr f);
/**
\brief Set a callback that is invoked when an expression is
marked as relevant during the search. This callback is only
invoked when relevancy propagation is enabled.
\conly The callback has the form <tt>f(t, n)</tt>, where:
\conly - \c t is the given theory
\conly - \c n is the relevant expression
*/
void Z3_API Z3_set_new_relevant_callback(Z3_theory t, Z3_theory_ast_callback_fptr f);
#endif
/**
\brief Assert a theory axiom/lemmas during the search.
An axiom added at search level \c n will remain in the logical context until
level \c n is backtracked.
The callbacks for push (#Z3_set_push_callback) and pop
(#Z3_set_pop_callback) can be used to track when the search
level is increased (i.e., new case-split) and decreased (i.e.,
case-split is backtracked).
Z3 tracks the theory axioms asserted. So, multiple assertions of the same axiom are
ignored.
*/
void Z3_API Z3_theory_assert_axiom(Z3_theory t, Z3_ast ax);
/**
\brief Inform to the logical context that \c lhs and \c rhs have the same interpretation
in the model being built by theory \c t. If lhs = rhs is inconsistent with other theories,
then the logical context will backtrack.
For more information, see the paper "Model-Based Theory Combination" in the Z3 website.
*/
void Z3_API Z3_theory_assume_eq(Z3_theory t, Z3_ast lhs, Z3_ast rhs);
/**
\brief Enable/disable the simplification of theory axioms asserted using #Z3_theory_assert_axiom.
By default, the simplification of theory specific operators is disabled.
That is, the reduce theory callbacks are not invoked for theory axioms.
The default behavior is useful when asserting axioms stating properties of theory operators.
*/
void Z3_API Z3_theory_enable_axiom_simplification(Z3_theory t, Z3_bool flag);
/**
\brief Return the root of the equivalence class containing \c n.
*/
Z3_ast Z3_API Z3_theory_get_eqc_root(Z3_theory t, Z3_ast n);
/**
\brief Return the next element in the equivalence class containing \c n.
The elements in an equivalence class are organized in a circular list.
You can traverse the list by calling this function multiple times
using the result from the previous call. This is illustrated in the
code snippet below.
\code
Z3_ast curr = n;
do
curr = Z3_theory_get_eqc_next(theory, curr);
while (curr != n);
\endcode
*/
Z3_ast Z3_API Z3_theory_get_eqc_next(Z3_theory t, Z3_ast n);
/**
\brief Return the number of parents of \c n that are operators of the given theory.
*/
unsigned Z3_API Z3_theory_get_num_parents(Z3_theory t, Z3_ast n);
/**
\brief Return the i-th parent of \c n.
See #Z3_theory_get_num_parents.
*/
Z3_ast Z3_API Z3_theory_get_parent(Z3_theory t, Z3_ast n, unsigned i);
/**
\brief Return \c Z3_TRUE if \c n is an interpreted theory value.
*/
Z3_bool Z3_API Z3_theory_is_value(Z3_theory t, Z3_ast n);
/**
\brief Return \c Z3_TRUE if \c d is an interpreted theory declaration.
*/
Z3_bool Z3_API Z3_theory_is_decl(Z3_theory t, Z3_func_decl d);
/**
\brief Return the number of expressions of the given theory in
the logical context. These are the expressions notified using the
callback #Z3_set_new_elem_callback.
*/
unsigned Z3_API Z3_theory_get_num_elems(Z3_theory t);
/**
\brief Return the i-th elem of the given theory in the logical context.
\see Z3_theory_get_num_elems
*/
Z3_ast Z3_API Z3_theory_get_elem(Z3_theory t, unsigned i);
/**
\brief Return the number of theory applications in the logical
context. These are the expressions notified using the callback
#Z3_set_new_app_callback.
*/
unsigned Z3_API Z3_theory_get_num_apps(Z3_theory t);
/**
\brief Return the i-th application of the given theory in the logical context.
\see Z3_theory_get_num_apps
*/
Z3_ast Z3_API Z3_theory_get_app(Z3_theory t, unsigned i);
/*@}*/
#endif
#ifdef CorML4
/**
@name Fixedpoint facilities